Skip to content

Instantly share code, notes, and snippets.

@iruca3
Last active April 27, 2016 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iruca3/5507be6135157ee19e61 to your computer and use it in GitHub Desktop.
Save iruca3/5507be6135157ee19e61 to your computer and use it in GitHub Desktop.
require 'esa'
access_token = 'アクセストークン'
team = 'チーム名'
old_bucket_name = '旧バケット名'
new_bucket_name = '新バケット名'
client = Esa::Client.new(access_token: access_token, current_team: team)
page = 1
while true
posts = client.posts(q: old_bucket_name, page: page)
body = posts.body
body['posts'].each do |post|
new_body = post['body_md'].gsub(old_bucket_name, new_bucket_name)
client.update_post(post['number'], name: post['name'], body_md: new_body, updated_by: 'esa_bot')
puts "UPDATED: #{post['number']}"
sleep 1
end
break unless body['next_page']
page += 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment