github_api 0.4.11 → 0.5.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/README.md +76 -72
  2. data/features/cassettes/gists/starred.yml +48 -0
  3. data/features/cassettes/pagination/repos/commits/list.yml +193 -0
  4. data/features/cassettes/pagination/repos/commits/next.yml +183 -0
  5. data/features/cassettes/pagination/repos/diff/next.yml +45 -0
  6. data/features/cassettes/pagination/repos/list.yml +176 -0
  7. data/features/cassettes/pagination/repos/list/next.yml +222 -0
  8. data/features/cassettes/pagination/repos/per_page/each_page.yml +45 -0
  9. data/features/cassettes/repos/list.yml +92 -0
  10. data/features/error_codes.feature +1 -1
  11. data/features/gists.feature +12 -3
  12. data/features/gists/comments.feature +3 -3
  13. data/features/github_api.feature +13 -2
  14. data/features/pagination.feature +40 -39
  15. data/features/repos.feature +2 -2
  16. data/features/step_definitions/common_steps.rb +12 -0
  17. data/features/step_definitions/github_api_steps.rb +12 -1
  18. data/lib/github_api.rb +1 -1
  19. data/lib/github_api/api.rb +4 -2
  20. data/lib/github_api/api_factory.rb +11 -5
  21. data/lib/github_api/authorizations.rb +23 -32
  22. data/lib/github_api/client.rb +1 -0
  23. data/lib/github_api/events.rb +38 -38
  24. data/lib/github_api/filter.rb +1 -1
  25. data/lib/github_api/gists.rb +47 -42
  26. data/lib/github_api/gists/comments.rb +77 -84
  27. data/lib/github_api/git_data.rb +25 -6
  28. data/lib/github_api/git_data/blobs.rb +48 -45
  29. data/lib/github_api/git_data/commits.rb +76 -73
  30. data/lib/github_api/git_data/references.rb +137 -118
  31. data/lib/github_api/git_data/tags.rb +74 -70
  32. data/lib/github_api/git_data/trees.rb +88 -85
  33. data/lib/github_api/issues.rb +43 -31
  34. data/lib/github_api/issues/comments.rb +116 -119
  35. data/lib/github_api/issues/events.rb +20 -19
  36. data/lib/github_api/issues/labels.rb +200 -197
  37. data/lib/github_api/issues/milestones.rb +137 -134
  38. data/lib/github_api/orgs.rb +27 -23
  39. data/lib/github_api/orgs/members.rb +105 -108
  40. data/lib/github_api/orgs/teams.rb +236 -237
  41. data/lib/github_api/paged_request.rb +1 -1
  42. data/lib/github_api/pull_requests.rb +40 -42
  43. data/lib/github_api/pull_requests/comments.rb +140 -143
  44. data/lib/github_api/repos.rb +101 -67
  45. data/lib/github_api/repos/collaborators.rb +64 -68
  46. data/lib/github_api/repos/commits.rb +50 -39
  47. data/lib/github_api/repos/downloads.rb +107 -110
  48. data/lib/github_api/repos/forks.rb +38 -39
  49. data/lib/github_api/repos/hooks.rb +161 -167
  50. data/lib/github_api/repos/keys.rb +86 -86
  51. data/lib/github_api/repos/pub_sub_hubbub.rb +99 -87
  52. data/lib/github_api/repos/watching.rb +80 -82
  53. data/lib/github_api/request.rb +5 -9
  54. data/lib/github_api/users.rb +26 -16
  55. data/lib/github_api/users/emails.rb +47 -47
  56. data/lib/github_api/users/followers.rb +85 -86
  57. data/lib/github_api/users/keys.rb +73 -75
  58. data/lib/github_api/validations.rb +25 -0
  59. data/lib/github_api/validations/format.rb +23 -0
  60. data/lib/github_api/validations/presence.rb +25 -0
  61. data/lib/github_api/validations/required.rb +21 -0
  62. data/lib/github_api/validations/token.rb +41 -0
  63. data/lib/github_api/version.rb +3 -3
  64. data/spec/fixtures/repos/commit_comparison.json +112 -0
  65. data/spec/github/api_factory_spec.rb +17 -1
  66. data/spec/github/authorizations_spec.rb +36 -34
  67. data/spec/github/gists/comments_spec.rb +39 -45
  68. data/spec/github/gists_spec.rb +50 -53
  69. data/spec/github/git_data/blobs_spec.rb +27 -20
  70. data/spec/github/git_data/commits_spec.rb +20 -19
  71. data/spec/github/git_data/references_spec.rb +83 -46
  72. data/spec/github/git_data/tags_spec.rb +16 -15
  73. data/spec/github/git_data/trees_spec.rb +20 -19
  74. data/spec/github/git_data_spec.rb +10 -1
  75. data/spec/github/issues/comments_spec.rb +78 -68
  76. data/spec/github/issues/events_spec.rb +42 -34
  77. data/spec/github/issues/labels_spec.rb +89 -101
  78. data/spec/github/issues/milestones_spec.rb +76 -54
  79. data/spec/github/issues_spec.rb +53 -57
  80. data/spec/github/orgs/members_spec.rb +64 -49
  81. data/spec/github/orgs/teams_spec.rb +112 -101
  82. data/spec/github/orgs_spec.rb +41 -31
  83. data/spec/github/paged_request_spec.rb +6 -5
  84. data/spec/github/pull_requests/comments_spec.rb +39 -44
  85. data/spec/github/pull_requests_spec.rb +32 -48
  86. data/spec/github/repos/collaborators_spec.rb +40 -29
  87. data/spec/github/repos/commits_spec.rb +108 -64
  88. data/spec/github/repos/downloads_spec.rb +46 -45
  89. data/spec/github/repos/forks_spec.rb +23 -24
  90. data/spec/github/repos/hooks_spec.rb +69 -71
  91. data/spec/github/repos/keys_spec.rb +39 -34
  92. data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -4
  93. data/spec/github/repos/watching_spec.rb +31 -33
  94. data/spec/github/repos_spec.rb +74 -83
  95. data/spec/github/request_spec.rb +31 -2
  96. data/spec/github/users/emails_spec.rb +19 -17
  97. data/spec/github/users/followers_spec.rb +30 -28
  98. data/spec/github/users/keys_spec.rb +37 -33
  99. data/spec/github/users_spec.rb +124 -125
  100. data/spec/github/validations/format_spec.rb +42 -0
  101. data/spec/github/validations/presence_spec.rb +18 -0
  102. data/spec/github/validations/required_spec.rb +28 -0
  103. data/spec/github/validations/token_spec.rb +19 -0
  104. data/spec/github/validations_spec.rb +23 -0
  105. metadata +33 -10
  106. data/features/cassettes/pagination/repos.yml +0 -177
  107. data/features/cassettes/pagination/repos/next.yml +0 -177
  108. data/lib/github_api/validation.rb +0 -53
  109. data/spec/github/validation_spec.rb +0 -62
@@ -1,172 +1,166 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Github
4
- class Repos
4
+ class Repos::Hooks < API
5
5
  # The Repository Hooks API manages the post-receive web and service hooks for a repository.
6
- module Hooks
7
-
8
- VALID_HOOK_PARAM_NAMES = %w[
9
- name
10
- config
11
- active
12
- events
13
- add_events
14
- remove_events
15
- ].freeze # :nodoc:
16
-
17
- # Active hooks can be configured to trigger for one or more events. The default event is push.
18
- # The available events are:
19
- VALID_HOOK_PARAM_VALUES = {
20
- 'events' => %w[
21
- push
22
- issues
23
- issue_comment
24
- commit_comment
25
- pull_request
26
- gollum
27
- watch
28
- download
29
- fork
30
- fork_apply
31
- member
32
- public
33
- ]
34
- }.freeze # :nodoc:
35
-
36
- REQUIRED_PARAMS = %w[ name config ].freeze # :nodoc:
37
-
38
- # List repository hooks
39
- #
40
- # = Examples
41
- # @github = Github.new
42
- # @github.repos.hooks 'user-name', 'repo-name'
43
- # @github.repos.hooks 'user-name', 'repo-name' { |hook| ... }
44
- #
45
- def hooks(user_name, repo_name, params={})
46
- _update_user_repo_params(user_name, repo_name)
47
- _validate_user_repo_params(user, repo) unless user? && repo?
48
- _normalize_params_keys(params)
49
-
50
- response = get("/repos/#{user}/#{repo}/hooks", params)
51
- return response unless block_given?
52
- response.each { |el| yield el }
53
- end
54
- alias :repo_hooks :hooks
55
- alias :repository_hooks :hooks
56
-
57
- # Get a single hook
58
- #
59
- # = Examples
60
- # @github = Github.new
61
- # @github.repos.hook 'user-name', 'repo-name'
62
- #
63
- def hook(user_name, repo_name, hook_id, params={})
64
- _update_user_repo_params(user_name, repo_name)
65
- _validate_user_repo_params(user, repo) unless user? && repo?
66
- _validate_presence_of hook_id
67
- _normalize_params_keys(params)
68
-
69
- get("/repos/#{user}/#{repo}/hooks/#{hook_id}", params)
70
- end
71
- alias :get_hook :hook
72
- alias :repo_hook :hook
73
- alias :repository_hook :hook
74
- alias :get_repo_hook :hook
75
-
76
- # Create a hook
77
- #
78
- # = Inputs
79
- # * <tt>:name</tt> - Required string - the name of the service that is being called.
80
- # * <tt>:config</tt> - Required hash - A Hash containing key/value pairs to provide settings for this hook.
81
- # * <tt>:events</tt> - Optional array - Determines what events the hook is triggered for. Default: ["push"]
82
- # * <tt>:active</tt> - Optional boolean - Determines whether the hook is actually triggered on pushes.
83
- #
84
- # = Examples
85
- # @github = Github.new
86
- # @github.repos.create_hook 'user-name', 'repo-name',
87
- # "name" => "web",
88
- # "active" => true,
89
- # "config" => {
90
- # "url" => "http://something.com/webhook"
91
- # }
92
- # }
93
- #
94
- def create_hook(user_name=nil, repo_name=nil, params={})
95
- _update_user_repo_params(user_name, repo_name)
96
- _validate_user_repo_params(user, repo) unless user? && repo?
97
-
98
- _normalize_params_keys(params)
99
- _filter_params_keys(VALID_HOOK_PARAM_NAMES, params, :recursive => false)
100
- _validate_inputs(REQUIRED_PARAMS, params)
101
-
102
- post("/repos/#{user}/#{repo}/hooks", params)
103
- end
104
-
105
- # Edit a hook
106
- #
107
- # = Inputs
108
- # * <tt>:name</tt> - Required string - the name of the service that is being called.
109
- # * <tt>:config</tt> - Required hash - A Hash containing key/value pairs to provide settings for this hook.
110
- # * <tt>:events</tt> - Optional array - Determines what events the hook is triggered for. This replaces the entire array of events. Default: ["push"].
111
- # * <tt>:add_events</tt> - Optional array - Determines a list of events to be added to the list of events that the Hook triggers for.
112
- # * <tt>:remove_events</tt> - Optional array - Determines a list of events to be removed from the list of events that the Hook triggers for.
113
- # * <tt>:active</tt> - Optional boolean - Determines whether the hook is actually triggered on pushes.
114
- #
115
- # = Examples
116
- # @github = Github.new
117
- # @github.repos.edit_hook 'user-name', 'repo-name',
118
- # "name" => "campfire",
119
- # "active" => true,
120
- # "config" => {
121
- # "subdomain" => "github",
122
- # "room" => "Commits",
123
- # "token" => "abc123"
124
- # }
125
- #
126
- def edit_hook(user_name, repo_name, hook_id, params={})
127
- _update_user_repo_params(user_name, repo_name)
128
- _validate_user_repo_params(user, repo) unless user? && repo?
129
- _validate_presence_of hook_id
130
-
131
- _normalize_params_keys(params)
132
- _filter_params_keys(VALID_HOOK_PARAM_NAMES, params, :recursive => false)
133
- _validate_inputs(REQUIRED_PARAMS, params)
134
-
135
- patch("/repos/#{user}/#{repo}/hooks/#{hook_id}", params)
136
- end
137
-
138
- # Test a hook
139
- #
140
- # This will trigger the hook with the latest push to the current repository.
141
- #
142
- # = Examples
143
- # @github = Github.new
144
- # @github.repos.test_hook 'user-name', 'repo-name', 'hook-id'
145
- #
146
- def test_hook(user_name, repo_name, hook_id, params={})
147
- _update_user_repo_params(user_name, repo_name)
148
- _validate_user_repo_params(user, repo) unless user? && repo?
149
- _validate_presence_of hook_id
150
- _normalize_params_keys(params)
151
-
152
- post("/repos/#{user}/#{repo}/hooks/#{hook_id}/test", params)
153
- end
154
-
155
- # Delete a hook
156
- #
157
- # = Examples
158
- # @github = Github.new
159
- # @github.repos.delete_hook 'user-name', 'repo-name', 'hook-id'
160
- #
161
- def delete_hook(user_name, repo_name, hook_id, params={})
162
- _update_user_repo_params(user_name, repo_name)
163
- _validate_user_repo_params(user, repo) unless user? && repo?
164
- _validate_presence_of hook_id
165
- _normalize_params_keys(params)
166
-
167
- delete("/repos/#{user}/#{repo}/hooks/#{hook_id}", params)
168
- end
169
-
170
- end # Hooks
171
- end # Repos
6
+
7
+ VALID_HOOK_PARAM_NAMES = %w[
8
+ name
9
+ config
10
+ active
11
+ events
12
+ add_events
13
+ remove_events
14
+ ].freeze # :nodoc:
15
+
16
+ # Active hooks can be configured to trigger for one or more events. The default event is push.
17
+ # The available events are:
18
+ VALID_HOOK_PARAM_VALUES = {
19
+ 'events' => %w[
20
+ push
21
+ issues
22
+ issue_comment
23
+ commit_comment
24
+ pull_request
25
+ gollum
26
+ watch
27
+ download
28
+ fork
29
+ fork_apply
30
+ member
31
+ public
32
+ ]
33
+ }.freeze # :nodoc:
34
+
35
+ REQUIRED_PARAMS = %w[ name config ].freeze # :nodoc:
36
+
37
+ # List repository hooks
38
+ #
39
+ # = Examples
40
+ # github = Github.new
41
+ # github.repos.hooks.list 'user-name', 'repo-name'
42
+ # github.repos.hooks.list 'user-name', 'repo-name' { |hook| ... }
43
+ #
44
+ def list(user_name, repo_name, params={})
45
+ _update_user_repo_params(user_name, repo_name)
46
+ _validate_user_repo_params(user, repo) unless user? && repo?
47
+ _normalize_params_keys(params)
48
+
49
+ response = get_request("/repos/#{user}/#{repo}/hooks", params)
50
+ return response unless block_given?
51
+ response.each { |el| yield el }
52
+ end
53
+ alias :all :list
54
+
55
+ # Get a single hook
56
+ #
57
+ # = Examples
58
+ # github = Github.new
59
+ # github.repos.hooks.get 'user-name', 'repo-name'
60
+ #
61
+ def get(user_name, repo_name, hook_id, params={})
62
+ _update_user_repo_params(user_name, repo_name)
63
+ _validate_user_repo_params(user, repo) unless user? && repo?
64
+ _validate_presence_of hook_id
65
+ _normalize_params_keys(params)
66
+
67
+ get_request("/repos/#{user}/#{repo}/hooks/#{hook_id}", params)
68
+ end
69
+ alias :find :get
70
+
71
+ # Create a hook
72
+ #
73
+ # = Inputs
74
+ # * <tt>:name</tt> - Required string - the name of the service that is being called.
75
+ # * <tt>:config</tt> - Required hash - A Hash containing key/value pairs to provide settings for this hook.
76
+ # * <tt>:events</tt> - Optional array - Determines what events the hook is triggered for. Default: ["push"]
77
+ # * <tt>:active</tt> - Optional boolean - Determines whether the hook is actually triggered on pushes.
78
+ #
79
+ # = Examples
80
+ # github = Github.new
81
+ # github.repos.hooks.create 'user-name', 'repo-name',
82
+ # "name" => "web",
83
+ # "active" => true,
84
+ # "config" => {
85
+ # "url" => "http://something.com/webhook"
86
+ # }
87
+ # }
88
+ #
89
+ def create(user_name, repo_name, params={})
90
+ _update_user_repo_params(user_name, repo_name)
91
+ _validate_user_repo_params(user, repo) unless user? && repo?
92
+
93
+ _normalize_params_keys(params)
94
+ _filter_params_keys(VALID_HOOK_PARAM_NAMES, params, :recursive => false)
95
+ _validate_inputs(REQUIRED_PARAMS, params)
96
+
97
+ post_request("/repos/#{user}/#{repo}/hooks", params)
98
+ end
99
+
100
+ # Edit a hook
101
+ #
102
+ # = Inputs
103
+ # * <tt>:name</tt> - Required string - the name of the service that is being called.
104
+ # * <tt>:config</tt> - Required hash - A Hash containing key/value pairs to provide settings for this hook.
105
+ # * <tt>:events</tt> - Optional array - Determines what events the hook is triggered for. This replaces the entire array of events. Default: ["push"].
106
+ # * <tt>:add_events</tt> - Optional array - Determines a list of events to be added to the list of events that the Hook triggers for.
107
+ # * <tt>:remove_events</tt> - Optional array - Determines a list of events to be removed from the list of events that the Hook triggers for.
108
+ # * <tt>:active</tt> - Optional boolean - Determines whether the hook is actually triggered on pushes.
109
+ #
110
+ # = Examples
111
+ # github = Github.new
112
+ # github.repos.hooks.edit 'user-name', 'repo-name',
113
+ # "name" => "campfire",
114
+ # "active" => true,
115
+ # "config" => {
116
+ # "subdomain" => "github",
117
+ # "room" => "Commits",
118
+ # "token" => "abc123"
119
+ # }
120
+ #
121
+ def edit(user_name, repo_name, hook_id, params={})
122
+ _update_user_repo_params(user_name, repo_name)
123
+ _validate_user_repo_params(user, repo) unless user? && repo?
124
+ _validate_presence_of hook_id
125
+
126
+ _normalize_params_keys(params)
127
+ _filter_params_keys(VALID_HOOK_PARAM_NAMES, params, :recursive => false)
128
+ _validate_inputs(REQUIRED_PARAMS, params)
129
+
130
+ patch_request("/repos/#{user}/#{repo}/hooks/#{hook_id}", params)
131
+ end
132
+
133
+ # Test a hook
134
+ #
135
+ # This will trigger the hook with the latest push to the current repository.
136
+ #
137
+ # = Examples
138
+ # github = Github.new
139
+ # github.repos.hooks.test 'user-name', 'repo-name', 'hook-id'
140
+ #
141
+ def test(user_name, repo_name, hook_id, params={})
142
+ _update_user_repo_params(user_name, repo_name)
143
+ _validate_user_repo_params(user, repo) unless user? && repo?
144
+ _validate_presence_of hook_id
145
+ _normalize_params_keys(params)
146
+
147
+ post_request("/repos/#{user}/#{repo}/hooks/#{hook_id}/test", params)
148
+ end
149
+
150
+ # Delete a hook
151
+ #
152
+ # = Examples
153
+ # github = Github.new
154
+ # github.repos.hooks.delete 'user-name', 'repo-name', 'hook-id'
155
+ #
156
+ def delete(user_name, repo_name, hook_id, params={})
157
+ _update_user_repo_params(user_name, repo_name)
158
+ _validate_user_repo_params(user, repo) unless user? && repo?
159
+ _validate_presence_of hook_id
160
+ _normalize_params_keys(params)
161
+
162
+ delete_request("/repos/#{user}/#{repo}/hooks/#{hook_id}", params)
163
+ end
164
+
165
+ end # Repos::Hooks
172
166
  end # Github
@@ -1,103 +1,103 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Github
4
- class Repos
5
- module Keys
4
+ class Repos::Keys < API
6
5
 
7
- VALID_KEY_PARAM_NAMES = %w[ title key ].freeze
6
+ VALID_KEY_PARAM_NAMES = %w[ title key ].freeze
8
7
 
9
- # List deploy keys
10
- #
11
- # = Examples
12
- # @github = Github.new
13
- # @github.repos.keys 'user-name', 'repo-name'
14
- # @github.repos.keys 'user-name', 'repo-name' { |key| ... }
15
- #
16
- def keys(user_name=nil, repo_name=nil, params={})
17
- _update_user_repo_params(user_name, repo_name)
18
- _validate_user_repo_params(user, repo) unless user? && repo?
19
- _normalize_params_keys(params)
8
+ # List deploy keys
9
+ #
10
+ # = Examples
11
+ # github = Github.new
12
+ # github.repos.keys.list 'user-name', 'repo-name'
13
+ # github.repos.keys.list 'user-name', 'repo-name' { |key| ... }
14
+ #
15
+ def list(user_name, repo_name, params={})
16
+ _update_user_repo_params(user_name, repo_name)
17
+ _validate_user_repo_params(user, repo) unless user? && repo?
18
+ _normalize_params_keys(params)
20
19
 
21
- response = get("/repos/#{user}/#{repo}/keys", params)
22
- return response unless block_given?
23
- response.each { |el| yield el }
24
- end
20
+ response = get_request("/repos/#{user}/#{repo}/keys", params)
21
+ return response unless block_given?
22
+ response.each { |el| yield el }
23
+ end
24
+ alias :all :list
25
25
 
26
- # Get a key
27
- #
28
- # = Examples
29
- # @github = Github.new
30
- # @github.repos.get_key 'user-name', 'repo-name', 'key-id'
31
- #
32
- def get_key(user_name, repo_name, key_id, params={})
33
- _update_user_repo_params(user_name, repo_name)
34
- _validate_user_repo_params(user, repo) unless user? && repo?
35
- _validate_presence_of key_id
36
- _normalize_params_keys(params)
26
+ # Get a key
27
+ #
28
+ # = Examples
29
+ # github = Github.new
30
+ # github.repos.keys.get 'user-name', 'repo-name', 'key-id'
31
+ #
32
+ def get(user_name, repo_name, key_id, params={})
33
+ _update_user_repo_params(user_name, repo_name)
34
+ _validate_user_repo_params(user, repo) unless user? && repo?
35
+ _validate_presence_of key_id
36
+ _normalize_params_keys(params)
37
37
 
38
- get("/repos/#{user}/#{repo}/keys/#{key_id}", params)
39
- end
38
+ get_request("/repos/#{user}/#{repo}/keys/#{key_id}", params)
39
+ end
40
+ alias :find :get
40
41
 
41
- # Create a key
42
- #
43
- # = Inputs
44
- # * <tt>:title</tt> - Required string.
45
- # * <tt>:key</tt> - Required string.
46
- #
47
- # = Examples
48
- # @github = Github.new
49
- # @github.repos.create_key 'user-name', 'repo-name',
50
- # "title" => "octocat@octomac",
51
- # "key" => "ssh-rsa AAA..."
52
- #
53
- def create_key(user_name, repo_name, params={})
54
- _update_user_repo_params(user_name, repo_name)
55
- _validate_user_repo_params(user, repo) unless user? && repo?
56
- _normalize_params_keys(params)
57
- _filter_params_keys(VALID_KEY_PARAM_NAMES, params)
58
- _validate_inputs(VALID_KEY_PARAM_NAMES, params)
42
+ # Create a key
43
+ #
44
+ # = Inputs
45
+ # * <tt>:title</tt> - Required string.
46
+ # * <tt>:key</tt> - Required string.
47
+ #
48
+ # = Examples
49
+ # github = Github.new
50
+ # github.repos.keys.create 'user-name', 'repo-name',
51
+ # "title" => "octocat@octomac",
52
+ # "key" => "ssh-rsa AAA..."
53
+ #
54
+ def create(user_name, repo_name, params={})
55
+ _update_user_repo_params(user_name, repo_name)
56
+ _validate_user_repo_params(user, repo) unless user? && repo?
57
+ _normalize_params_keys(params)
58
+ _filter_params_keys(VALID_KEY_PARAM_NAMES, params)
59
+ _validate_inputs(VALID_KEY_PARAM_NAMES, params)
59
60
 
60
- post("/repos/#{user}/#{repo}/keys", params)
61
- end
61
+ post_request("/repos/#{user}/#{repo}/keys", params)
62
+ end
62
63
 
63
- # Edit a key
64
- #
65
- # = Inputs
66
- # * <tt>:title</tt> - Required string.
67
- # * <tt>:key</tt> - Required string.
68
- #
69
- # = Examples
70
- # @github = Github.new
71
- # @github.repos.create_key 'user-name', 'repo-name',
72
- # "title" => "octocat@octomac",
73
- # "key" => "ssh-rsa AAA..."
74
- #
75
- def edit_key(user_name, repo_name, key_id, params={})
76
- _update_user_repo_params(user_name, repo_name)
77
- _validate_user_repo_params(user, repo) unless user? && repo?
78
- _validate_presence_of key_id
64
+ # Edit a key
65
+ #
66
+ # = Inputs
67
+ # * <tt>:title</tt> - Required string.
68
+ # * <tt>:key</tt> - Required string.
69
+ #
70
+ # = Examples
71
+ # github = Github.new
72
+ # github.repos.keys.edit 'user-name', 'repo-name',
73
+ # "title" => "octocat@octomac",
74
+ # "key" => "ssh-rsa AAA..."
75
+ #
76
+ def edit(user_name, repo_name, key_id, params={})
77
+ _update_user_repo_params(user_name, repo_name)
78
+ _validate_user_repo_params(user, repo) unless user? && repo?
79
+ _validate_presence_of key_id
79
80
 
80
- _normalize_params_keys(params)
81
- _filter_params_keys(VALID_KEY_PARAM_NAMES, params)
81
+ _normalize_params_keys(params)
82
+ _filter_params_keys(VALID_KEY_PARAM_NAMES, params)
82
83
 
83
- patch("/repos/#{user}/#{repo}/keys/#{key_id}", params)
84
- end
84
+ patch_request("/repos/#{user}/#{repo}/keys/#{key_id}", params)
85
+ end
85
86
 
86
- # Delete key
87
- #
88
- # = Examples
89
- # @github = Github.new
90
- # @github.repos.delete_key 'user-name', 'repo-name', 'key-id'
91
- #
92
- def delete_key(user_name, repo_name, key_id, params={})
93
- _update_user_repo_params(user_name, repo_name)
94
- _validate_user_repo_params(user, repo) unless user? && repo?
95
- _validate_presence_of key_id
96
- _normalize_params_keys(params)
87
+ # Delete key
88
+ #
89
+ # = Examples
90
+ # @github = Github.new
91
+ # @github.repos.keys.delete 'user-name', 'repo-name', 'key-id'
92
+ #
93
+ def delete(user_name, repo_name, key_id, params={})
94
+ _update_user_repo_params(user_name, repo_name)
95
+ _validate_user_repo_params(user, repo) unless user? && repo?
96
+ _validate_presence_of key_id
97
+ _normalize_params_keys(params)
97
98
 
98
- delete("/repos/#{user}/#{repo}/keys/#{key_id}", params)
99
- end
99
+ delete_request("/repos/#{user}/#{repo}/keys/#{key_id}", params)
100
+ end
100
101
 
101
- end # Keys
102
- end # Repos
102
+ end # Repos::Keys
103
103
  end # Github