Created
April 16, 2015 14:49
-
-
Save sonsongithub/7d1559f6cd1749fecc15 to your computer and use it in GitHub Desktop.
Ruby script to create label which means reddit.com API category.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'octokit' | |
client = Octokit::Client.new(:access_token => "") | |
labels = [ | |
"account", | |
"captcha", | |
"flair", | |
"reddit gold", | |
"links & comments", | |
"listings", | |
"live threads", | |
"private messages", | |
"moderation", | |
"multis", | |
"search", | |
"subreddits", | |
"users", | |
"wiki" | |
] | |
for i in 1..labels.length do | |
color = sprintf("%02X%02X%02X", Random.rand(255.0).to_i, Random.rand(255.0).to_i, Random.rand(255.0).to_i) | |
label = labels[i] | |
client.add_label("sonsongithub/reddift", label, color) | |
end | |
source = <<"EOS" | |
account | |
/api/v1/me | |
/api/v1/me/blocked | |
/api/v1/me/friends | |
/api/v1/me/karma | |
/api/v1/me/prefs | |
/api/v1/me/trophies | |
/prefs/blocked | |
/prefs/friends | |
/prefs/where | |
captcha | |
/api/needs_captcha | |
/api/new_captcha | |
/captcha/iden | |
flair | |
/api/clearflairtemplates | |
/api/deleteflair | |
/api/deleteflairtemplate | |
/api/flair | |
/api/flairconfig | |
/api/flaircsv | |
/api/flairlist | |
/api/flairselector | |
/api/flairtemplate | |
/api/selectflair | |
/api/setflairenabled | |
reddit gold | |
/api/v1/gold/gild/fullname | |
/api/v1/gold/give/username | |
links & comments | |
/api/comment | |
/api/del | |
/api/editusertext | |
/api/hide | |
/api/info | |
/api/marknsfw | |
/api/morechildren | |
/api/report | |
/api/save | |
/api/saved_categories | |
/api/sendreplies | |
/api/set_contest_mode | |
/api/set_subreddit_sticky | |
/api/store_visits | |
/api/submit | |
/api/unhide | |
/api/unmarknsfw | |
/api/unsave | |
/api/vote | |
listings | |
/by_id/names | |
/comments/article | |
/controversial | |
/duplicates/article | |
/hot | |
/new | |
/random | |
/related/article | |
/top | |
/sort | |
live threads | |
/api/live/create | |
/api/live/thread/accept_contributor_invite | |
/api/live/thread/close_thread | |
/api/live/thread/delete_update | |
/api/live/thread/edit | |
/api/live/thread/invite_contributor | |
/api/live/thread/leave_contributor | |
/api/live/thread/report | |
/api/live/thread/rm_contributor | |
/api/live/thread/rm_contributor_invite | |
/api/live/thread/set_contributor_permissions | |
/api/live/thread/strike_update | |
/api/live/thread/update | |
/live/thread | |
/live/thread/about | |
/live/thread/contributors | |
/live/thread/discussions | |
private messages | |
/api/block | |
/api/compose | |
/api/read_all_messages | |
/api/read_message | |
/api/unblock_subreddit | |
/api/unread_message | |
/message/inbox | |
/message/sent | |
/message/unread | |
/message/where | |
moderation | |
/about/edited | |
/about/log | |
/about/modqueue | |
/about/reports | |
/about/spam | |
/about/unmoderated | |
/about/location | |
/api/accept_moderator_invite | |
/api/approve | |
/api/distinguish | |
/api/ignore_reports | |
/api/leavecontributor | |
/api/leavemoderator | |
/api/remove | |
/api/unignore_reports | |
/stylesheet | |
multis | |
/api/filter/filterpath | |
/api/filter/filterpath/r/srname | |
/api/multi/copy | |
/api/multi/mine | |
/api/multi/rename | |
/api/multi/user/username | |
/api/multi/multipath | |
/api/multi/multipath/description | |
/api/multi/multipath/r/srname | |
search | |
/search | |
subreddits | |
/about/banned | |
/about/contributors | |
/about/moderators | |
/about/wikibanned | |
/about/wikicontributors | |
/about/where | |
/api/delete_sr_banner | |
/api/delete_sr_header | |
/api/delete_sr_icon | |
/api/delete_sr_img | |
/api/recommend/sr/srnames | |
/api/search_reddit_names | |
/api/site_admin | |
/api/submit_text | |
/api/subreddit_stylesheet | |
/api/subreddits_by_topic | |
/api/subscribe | |
/api/upload_sr_img | |
/r/subreddit/about | |
/r/subreddit/about/edit | |
/sidebar | |
/sticky | |
/subreddits/employee | |
/subreddits/gold | |
/subreddits/mine/contributor | |
/subreddits/mine/moderator | |
/subreddits/mine/subscriber | |
/subreddits/mine/where | |
/subreddits/new | |
/subreddits/popular | |
/subreddits/search | |
/subreddits/where | |
users | |
/api/friend | |
/api/setpermissions | |
/api/unfriend | |
/api/username_available | |
/api/v1/me/friends/id | |
/api/v1/me/notifications | |
/api/v1/me/notifications/id | |
/api/v1/user/id/trophies | |
/user/username/about | |
/user/username/comments | |
/user/username/disliked | |
/user/username/gilded | |
/user/username/hidden | |
/user/username/liked | |
/user/username/overview | |
/user/username/saved | |
/user/username/submitted | |
/user/username/where | |
wiki | |
/api/wiki/alloweditor/add | |
/api/wiki/alloweditor/del | |
/api/wiki/alloweditor/act | |
/api/wiki/edit | |
/api/wiki/hide | |
/api/wiki/revert | |
/wiki/discussions/page | |
/wiki/pages | |
/wiki/revisions | |
/wiki/revisions/page | |
/wiki/settings/page | |
/wiki/page | |
EOS | |
page = 1 | |
issues = [] | |
for i in 1..20 | |
puts page | |
array = client.list_issues("sonsongithub/reddift", {:page=>page}) | |
issues = issues + array | |
break if array.length == 0 | |
page = page + 1 | |
end | |
category = "" | |
table = {} | |
source.scan(/(^\w.+?$)|(^\/.+?$)/).each{|e| | |
if e[0] != nil | |
category = e[0] | |
elsif e[1] != nil | |
table[e[1]] = category | |
end | |
} | |
issues.each{|issue| | |
puts issue.title + "=>" + table[issue.title] | |
labels = [table[issue.title], "Not implemented"] | |
client.update_issue("sonsongithub/reddift", issue.number, issue.title, issue.body, {:labels=>labels}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment