github_api 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. metadata +4 -140
  2. data/LICENSE.txt +0 -20
  3. data/README.rdoc +0 -228
  4. data/Rakefile +0 -52
  5. data/features/github_api.feature +0 -50
  6. data/features/step_definitions/github_api_steps.rb +0 -11
  7. data/features/support/env.rb +0 -13
  8. data/lib/github_api.rb +0 -73
  9. data/lib/github_api/api.rb +0 -175
  10. data/lib/github_api/api/utils.rb +0 -9
  11. data/lib/github_api/authorization.rb +0 -73
  12. data/lib/github_api/authorizations.rb +0 -119
  13. data/lib/github_api/cache_control.rb +0 -19
  14. data/lib/github_api/client.rb +0 -55
  15. data/lib/github_api/compatibility.rb +0 -23
  16. data/lib/github_api/configuration.rb +0 -96
  17. data/lib/github_api/connection.rb +0 -81
  18. data/lib/github_api/core_ext/array.rb +0 -14
  19. data/lib/github_api/core_ext/hash.rb +0 -42
  20. data/lib/github_api/error.rb +0 -35
  21. data/lib/github_api/events.rb +0 -202
  22. data/lib/github_api/gists.rb +0 -200
  23. data/lib/github_api/gists/comments.rb +0 -86
  24. data/lib/github_api/git_data.rb +0 -26
  25. data/lib/github_api/git_data/blobs.rb +0 -51
  26. data/lib/github_api/git_data/commits.rb +0 -78
  27. data/lib/github_api/git_data/references.rb +0 -113
  28. data/lib/github_api/git_data/tags.rb +0 -78
  29. data/lib/github_api/git_data/trees.rb +0 -89
  30. data/lib/github_api/issues.rb +0 -215
  31. data/lib/github_api/issues/comments.rb +0 -110
  32. data/lib/github_api/issues/events.rb +0 -50
  33. data/lib/github_api/issues/labels.rb +0 -191
  34. data/lib/github_api/issues/milestones.rb +0 -119
  35. data/lib/github_api/mime_type.rb +0 -55
  36. data/lib/github_api/orgs.rb +0 -95
  37. data/lib/github_api/orgs/members.rb +0 -120
  38. data/lib/github_api/orgs/teams.rb +0 -245
  39. data/lib/github_api/pull_requests.rb +0 -224
  40. data/lib/github_api/pull_requests/comments.rb +0 -144
  41. data/lib/github_api/repos.rb +0 -286
  42. data/lib/github_api/repos/collaborators.rb +0 -81
  43. data/lib/github_api/repos/commits.rb +0 -180
  44. data/lib/github_api/repos/downloads.rb +0 -155
  45. data/lib/github_api/repos/forks.rb +0 -48
  46. data/lib/github_api/repos/hooks.rb +0 -173
  47. data/lib/github_api/repos/keys.rb +0 -104
  48. data/lib/github_api/repos/pub_sub_hubbub.rb +0 -102
  49. data/lib/github_api/repos/watching.rb +0 -94
  50. data/lib/github_api/request.rb +0 -84
  51. data/lib/github_api/request/basic_auth.rb +0 -31
  52. data/lib/github_api/request/caching.rb +0 -33
  53. data/lib/github_api/request/oauth2.rb +0 -33
  54. data/lib/github_api/response.rb +0 -28
  55. data/lib/github_api/response/helpers.rb +0 -14
  56. data/lib/github_api/response/jsonize.rb +0 -26
  57. data/lib/github_api/response/mashify.rb +0 -24
  58. data/lib/github_api/response/raise_error.rb +0 -33
  59. data/lib/github_api/result.rb +0 -42
  60. data/lib/github_api/users.rb +0 -84
  61. data/lib/github_api/users/emails.rb +0 -49
  62. data/lib/github_api/users/followers.rb +0 -98
  63. data/lib/github_api/users/keys.rb +0 -84
  64. data/lib/github_api/version.rb +0 -12
  65. data/spec/README.rdoc +0 -22
  66. data/spec/coverage_adapter.rb +0 -14
  67. data/spec/fixtures/auths/authorization.json +0 -14
  68. data/spec/fixtures/auths/authorizations.json +0 -16
  69. data/spec/fixtures/events/events.json +0 -29
  70. data/spec/fixtures/issues/issue.json +0 -56
  71. data/spec/fixtures/issues/issues.json +0 -58
  72. data/spec/fixtures/orgs/members.json +0 -9
  73. data/spec/fixtures/orgs/org.json +0 -18
  74. data/spec/fixtures/orgs/orgs.json +0 -8
  75. data/spec/fixtures/orgs/team.json +0 -8
  76. data/spec/fixtures/orgs/team_repos.json +0 -29
  77. data/spec/fixtures/orgs/teams.json +0 -7
  78. data/spec/fixtures/repos/branches.json +0 -9
  79. data/spec/fixtures/repos/collaborators.json +0 -8
  80. data/spec/fixtures/repos/commit.json +0 -53
  81. data/spec/fixtures/repos/commit_comment.json +0 -16
  82. data/spec/fixtures/repos/commit_comments.json +0 -18
  83. data/spec/fixtures/repos/commits.json +0 -27
  84. data/spec/fixtures/repos/contributors.json +0 -8
  85. data/spec/fixtures/repos/download.json +0 -10
  86. data/spec/fixtures/repos/download_s3.json +0 -21
  87. data/spec/fixtures/repos/downloads.json +0 -12
  88. data/spec/fixtures/repos/fork.json +0 -27
  89. data/spec/fixtures/repos/forks.json +0 -29
  90. data/spec/fixtures/repos/hook.json +0 -15
  91. data/spec/fixtures/repos/hooks.json +0 -10
  92. data/spec/fixtures/repos/key.json +0 -6
  93. data/spec/fixtures/repos/keys.json +0 -8
  94. data/spec/fixtures/repos/languages.json +0 -4
  95. data/spec/fixtures/repos/repo.json +0 -90
  96. data/spec/fixtures/repos/repo_comments.json +0 -18
  97. data/spec/fixtures/repos/repos.json +0 -29
  98. data/spec/fixtures/repos/tags.json +0 -11
  99. data/spec/fixtures/repos/teams.json +0 -7
  100. data/spec/fixtures/repos/watched.json +0 -29
  101. data/spec/fixtures/repos/watchers.json +0 -8
  102. data/spec/fixtures/users/user.json +0 -32
  103. data/spec/github/api_spec.rb +0 -25
  104. data/spec/github/authorization_spec.rb +0 -176
  105. data/spec/github/authorizations_spec.rb +0 -242
  106. data/spec/github/client_spec.rb +0 -50
  107. data/spec/github/core_ext/hash_spec.rb +0 -44
  108. data/spec/github/events_spec.rb +0 -491
  109. data/spec/github/gists/comments_spec.rb +0 -5
  110. data/spec/github/gists_spec.rb +0 -5
  111. data/spec/github/git_data/blobs_spec.rb +0 -5
  112. data/spec/github/git_data/commits_spec.rb +0 -5
  113. data/spec/github/git_data/references_spec.rb +0 -5
  114. data/spec/github/git_data/tags_spec.rb +0 -5
  115. data/spec/github/git_data/trees_spec.rb +0 -5
  116. data/spec/github/git_data_spec.rb +0 -5
  117. data/spec/github/issues/comments_spec.rb +0 -5
  118. data/spec/github/issues/events_spec.rb +0 -5
  119. data/spec/github/issues/labels_spec.rb +0 -5
  120. data/spec/github/issues/milestones_spec.rb +0 -5
  121. data/spec/github/issues_spec.rb +0 -287
  122. data/spec/github/mime_type_spec.rb +0 -70
  123. data/spec/github/orgs/members_spec.rb +0 -275
  124. data/spec/github/orgs/teams_spec.rb +0 -563
  125. data/spec/github/orgs_spec.rb +0 -160
  126. data/spec/github/repos/collaborators_spec.rb +0 -169
  127. data/spec/github/repos/commits_spec.rb +0 -424
  128. data/spec/github/repos/downloads_spec.rb +0 -236
  129. data/spec/github/repos/forks_spec.rb +0 -103
  130. data/spec/github/repos/hooks_spec.rb +0 -307
  131. data/spec/github/repos/keys_spec.rb +0 -216
  132. data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -83
  133. data/spec/github/repos/watching_spec.rb +0 -222
  134. data/spec/github/repos_spec.rb +0 -571
  135. data/spec/github/result_spec.rb +0 -43
  136. data/spec/github/users_spec.rb +0 -140
  137. data/spec/github_spec.rb +0 -109
  138. data/spec/spec_helper.rb +0 -86
@@ -1,50 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Github
4
- class Issues
5
- module Events
6
-
7
- # List events for an issue
8
- #
9
- # = Examples
10
- # @github = Github.new
11
- # @github.issues.events 'user-name', 'repo-name', 'issue-id'
12
- #
13
- # List events for a repository
14
- #
15
- # = Examples
16
- # @github = Github.new
17
- # @github.issues.events 'user-name', 'repo-name'
18
- #
19
- def events(user_name=nil, repo_name=nil, issue_id=nil, params={})
20
- _update_user_repo_params(user_name, repo_name)
21
- _validate_user_repo_params(user, repo) unless user? && repo?
22
- _normalize_params_keys(params)
23
-
24
- response = if issue_id
25
- get("/repos/#{user}/#{repo}/issues/#{issue_id}/events", params)
26
- else
27
- get("/repos/#{user}/#{repo}/issues/events", params)
28
- end
29
- return response unless block_given?
30
- response.each { |el| yield el }
31
- end
32
-
33
- # Get a single event
34
- #
35
- # = Examples
36
- # @github = Github.new
37
- # @github.issues.event 'user-name', 'repo-name', 'event-id'
38
- #
39
- def event(user_name, repo_name, event_id, params={})
40
- _update_user_repo_params(user_name, repo_name)
41
- _validate_user_repo_params(user, repo) unless user? && repo?
42
- _validate_presence_of event_id
43
- _normalize_params_keys(params)
44
-
45
- get("/repos/#{user}/#{repo}/issues/events/#{event_id}")
46
- end
47
-
48
- end # Events
49
- end # Issues
50
- end # Github
@@ -1,191 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Github
4
- class Issues
5
- module Labels
6
-
7
- VALID_LABEL_INPUTS = %w[ name color ]
8
-
9
- # List all labels for a repository
10
- #
11
- # = Examples
12
- # @github = Github.new :user => 'user-name', :repo => 'repo-name'
13
- # @github.issues.labels
14
- # @github.issues.labels { |label| ... }
15
- #
16
- def labels(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)
20
-
21
- response = get("/repos/#{user}/#{repo}/labels", params)
22
- return response unless block_given?
23
- response.each { |el| yield el }
24
- end
25
-
26
- # Get a single label
27
- #
28
- # = Examples
29
- # @github = Github.new
30
- # @github.issues.label 'user-name', 'repo-name', 'label-id'
31
- #
32
- def label(user_name, repo_name, label_id, params={})
33
- _update_user_repo_params(user_name, repo_name)
34
- _validate_user_repo_params(user, repo) unless user? && repo?
35
- _normalize_params_keys(params)
36
-
37
- get("/repos/#{user}/#{repo}/labels/#{label_id}", params)
38
- end
39
-
40
- # Create a label
41
- #
42
- # = Inputs
43
- # <tt>:name</tt> - Required string
44
- # <tt>:color</tt> - Required string - 6 character hex code, without leading #
45
- #
46
- # = Examples
47
- # @github = Github.new :user => 'user-name', :repo => 'repo-name'
48
- # @github.issues.create_label :name => 'API', :color => 'FFFFFF'
49
- #
50
- def create_label(user_name=nil, repo_name=nil, params={})
51
- _update_user_repo_params(user_name, repo_name)
52
- _validate_user_repo_params(user, repo) unless user? && repo?
53
-
54
- _normalize_params_keys(params)
55
- _filter_params_keys(VALID_LABEL_INPUTS, params)
56
-
57
- raise ArgumentError, "Required params are: :name, :color" unless _validate_inputs(VALID_LABEL_INPUTS, params)
58
-
59
- post("/repos/#{user}/#{repo}/labels", params)
60
- end
61
-
62
- # Update a label
63
- #
64
- # = Inputs
65
- # <tt>:name</tt> - Required string
66
- # <tt>:color</tt> - Required string - 6 character hex code, without leading #
67
- #
68
- # = Examples
69
- # @github = Github.new
70
- # @github.issues.update_label 'user-name', 'repo-name', 'label-id', :name => 'API', :color => "FFFFFF"
71
- #
72
- def update_label(user_name, repo_name, label_id, params={})
73
- _update_user_repo_params(user_name, repo_name)
74
- _validate_user_repo_params(user, repo) unless user? && repo?
75
- _validate_presence_of label_id
76
-
77
- _normalize_params_keys(params)
78
- _filter_params_keys(VALID_LABEL_INPUTS, params)
79
-
80
- raise ArgumentError, "Required params are: :name, :color" unless _validate_inputs(VALID_LABEL_INPUTS, params)
81
-
82
- patch("/repos/#{user}/#{repo}/labels/#{label_id}", params)
83
- end
84
-
85
- # Delete a label
86
- #
87
- # = Examples
88
- # @github = Github.new
89
- # @github.issues.delete_label 'user-name', 'repo-name', 'label-id'
90
- #
91
- def delete_label(user_name, repo_name, label_id, params={})
92
- _update_user_repo_params(user_name, repo_name)
93
- _validate_user_repo_params(user, repo) unless user? && repo?
94
- _validate_presence_of milestone_id
95
- _normalize_params_keys(params)
96
-
97
- delete("/repos/#{user}/#{repo}/labels/#{label_id}", params)
98
- end
99
-
100
- # List labels on an issue
101
- #
102
- # = Examples
103
- # @github = Github.new
104
- # @github.issues.labels_for 'user-name', 'repo-name', 'issue-id'
105
- #
106
- def labels_for(user_name, repo_name, issue_id, params={})
107
- _update_user_repo_params(user_name, repo_name)
108
- _validate_user_repo_params(user, repo) unless user? && repo?
109
- _validate_presence_of(issue_id)
110
- _normalize_params_keys(params)
111
-
112
- get("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
113
- end
114
-
115
- # Add labels to an issue
116
- #
117
- # = Examples
118
- # @github = Github.new
119
- # @github.issues.add_labels 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...
120
- #
121
- def add_labels(user_name, repo_name, issue_id, *args)
122
- params = args.last.is_a?(Hash) ? args.pop : {}
123
- params['data'] = [args].flatten unless args.nil?
124
- _update_user_repo_params(user_name, repo_name)
125
- _validate_user_repo_params(user, repo) unless user? && repo?
126
- _validate_presence_of(issue_id)
127
- _normalize_params_keys(params)
128
-
129
- post("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
130
- end
131
-
132
- # Remove a label from an issue
133
- #
134
- # = Examples
135
- # @github = Github.new
136
- # @github.issues.remove_label 'user-name', 'repo-name', 'issue-id', 'label-id'
137
- #
138
- # Remove all labels from an issue
139
- # = Examples
140
- # @github = Github.new
141
- # @github.issues.remove_label 'user-name', 'repo-name', 'issue-id'
142
- #
143
- def remove_label(user_name, repo_name, issue_id, label_id=nil, params={})
144
- _update_user_repo_params(user_name, repo_name)
145
- _validate_user_repo_params(user, repo) unless user? && repo?
146
- _validate_presence_of(issue_id)
147
- _normalize_params_keys(params)
148
-
149
- if label_id
150
- delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_id}", params)
151
- else
152
- delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
153
- end
154
- end
155
-
156
- # Replace all labels for an issue
157
- #
158
- # Sending an empty array ([]) will remove all Labels from the Issue.
159
- #
160
- # = Examples
161
- # @github = Github.new
162
- # @github.issues.replace_labels 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...
163
- #
164
- def replace_labels(user_name, repo_name, issue_id, *args)
165
- params = args.last.is_a?(Hash) ? args.pop : {}
166
- params['data'] = [args].flatten unless args.nil?
167
- _update_user_repo_params(user_name, repo_name)
168
- _validate_user_repo_params(user, repo) unless user? && repo?
169
- _validate_presence_of(issue_id)
170
- _normalize_params_keys(params)
171
-
172
- put("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
173
- end
174
-
175
- # Get labels for every issue in a milestone
176
- #
177
- # = Examples
178
- # @github = Github.new
179
- # @github.issues.get_label 'user-name', 'repo-name', 'milestone-id'
180
- #
181
- def get_label(user_name, repo_name, milestone_id, params={})
182
- _update_user_repo_params(user_name, repo_name)
183
- _validate_user_repo_params(user, repo) unless user? && repo?
184
- _validate_presence_of(issue_id)
185
-
186
- get("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels", params)
187
- end
188
-
189
- end # Labels
190
- end # Issues
191
- end # Github
@@ -1,119 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Github
4
- class Issues
5
- module Milestones
6
-
7
- VALID_MILSTONE_OPTIONS = {
8
- 'state' => %w[ open closed ],
9
- 'sort' => %w[ due_date completeness ],
10
- 'direction' => %w[ desc asc ]
11
- }
12
-
13
- VALID_MILESTONE_INPUTS = %w[ title state description due_on ]
14
-
15
- # List milestones for a repository
16
- #
17
- # = Parameters
18
- # <tt>:state</tt> - <tt>open</tt>, <tt>closed</tt>, default: <tt>open</tt>
19
- # <tt>:sort</tt> - <tt>due_date</tt>, <tt>completeness</tt>, default: <tt>due_date</tt>
20
- # <tt>:direction</tt> - <tt>asc</tt>, <tt>desc</tt>, default: <tt>desc</tt>
21
- #
22
- # = Examples
23
- # @github = Github.new :user => 'user-name', :repo => 'repo-name'
24
- # @github.issues.milestones
25
- #
26
- def milestones(user_name=nil, repo_name=nil, params={})
27
- _update_user_repo_params(user_name, repo_name)
28
- _validate_user_repo_params(user, repo) unless user? && repo?
29
-
30
- _normalize_params_keys(params)
31
- _filter_params_keys(VALID_MILSTONE_OPTIONS.keys, params)
32
- _validate_params_values(VALID_MILSTONE_OPTIONS, params)
33
-
34
- response = get("/repos/#{user}/#{repo}/milestones", params)
35
- return response unless block_given?
36
- response.each { |el| yield el }
37
- end
38
-
39
- # Get a single milestone
40
- #
41
- # = Examples
42
- # @github = Github.new
43
- # @github.issues.milestone 'user-name', 'repo-name', 'milestone-id'
44
- #
45
- def milestone(user_name, repo_name, milestone_id, 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
- get("/repos/#{user}/#{repo}/milestones/#{milestone_id}", params)
51
- end
52
-
53
- # Create a milestone
54
- #
55
- # = Inputs
56
- # <tt>:title</tt> - Required string
57
- # <tt>:state</tt> - Optional string - <tt>open</tt> or <tt>closed</tt>
58
- # <tt>:description</tt> - Optional string
59
- # <tt>:due_on</tt> - Optional string - ISO 8601 time
60
- #
61
- # = Examples
62
- # @github = Github.new :user => 'user-name', :repo => 'repo-name'
63
- # @github.issues.create_milestone :title => 'hello-world'
64
- #
65
- def create_milestone(user_name=nil, repo_name=nil, params={})
66
- _update_user_repo_params(user_name, repo_name)
67
- _validate_user_repo_params(user, repo) unless user? && repo?
68
-
69
- _normalize_params_keys(params)
70
- _filter_params_keys(VALID_MILESTONE_INPUTS, params)
71
-
72
- raise ArgumentError, "Required params are: :title" unless _validate_inputs(%w[ title ], params)
73
-
74
- post("/repos/#{user}/#{repo}/milestones", params)
75
- end
76
-
77
- # Update a milestone
78
- #
79
- # = Inputs
80
- # <tt>:title</tt> - Required string
81
- # <tt>:state</tt> - Optional string - <tt>open</tt> or <tt>closed</tt>
82
- # <tt>:description</tt> - Optional string
83
- # <tt>:due_on</tt> - Optional string - ISO 8601 time
84
- #
85
- # = Examples
86
- # @github = Github.new
87
- # @github.issues.update_milestone 'user-name', 'repo-name', 'milestone-id', :title => 'hello-world'
88
- #
89
- def update_milestone(user_name, repo_name, milestone_id, params={})
90
- _update_user_repo_params(user_name, repo_name)
91
- _validate_user_repo_params(user, repo) unless user? && repo?
92
- _validate_presence_of milestone_id
93
-
94
- _normalize_params_keys(params)
95
- _filter_params_keys(VALID_MILESTONE_INPUTS, params)
96
-
97
- raise ArgumentError, "Required params are: :title" unless _validate_inputs(%w[ title ], params)
98
-
99
- patch("/repos/#{user}/#{repo}/milestones/#{milestone_id}", params)
100
- end
101
-
102
- # Delete a milestone
103
- #
104
- # = Examples
105
- # @github = Github.new
106
- # @github.issues.delete_milestone 'user-name', 'repo-name', 'milestone-id'
107
- #
108
- def delete_milestone(user_name, repo_name, milestone_id, params={})
109
- _update_user_repo_params(user_name, repo_name)
110
- _validate_user_repo_params(user, repo) unless user? && repo?
111
- _validate_presence_of milestone_id
112
- _normalize_params_keys(params)
113
-
114
- delete("/repos/#{user}/#{repo}/milestones/#{milestone_id}", params)
115
- end
116
-
117
- end # Milestones
118
- end # Issues
119
- end # Github
@@ -1,55 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Github
4
- module MimeType
5
-
6
- attr_accessor :accepts
7
-
8
- RESOURCE_LOOKUP = {
9
- :json => 'json',
10
- :issue => 'vnd.github-issue.',
11
- :issue_comment => 'vnd.github-issuecomment.',
12
- :commit_comment => 'vnd.github-commitcomment.',
13
- :pull_request => 'vnd.github-pull.',
14
- :pull_comment => 'vnd.github-pullcomment.',
15
- :gist_comment => 'vnd.github-gistcomment.',
16
- :blob => 'vnd.github-blob.'
17
- }
18
-
19
- MIME_LOOKUP = {
20
- :json => 'json',
21
- :blob => 'raw',
22
- :raw => 'raw+json',
23
- :text => 'text+json',
24
- :html => 'html+json',
25
- :full => 'full+json'
26
- }
27
-
28
- def parse(resource = nil, mime_type = :json)
29
- resource = lookup_resource(resource) if resource
30
- mime_type = lookup_mime(mime_type)
31
- self.accepts = "application/#{resource || ''}#{mime_type}"
32
- end
33
-
34
- def lookup_resource(name)
35
- RESOURCE_LOOKUP.fetch(name)
36
- end
37
-
38
- def lookup_mime(name)
39
- MIME_LOOKUP.fetch(name)
40
- end
41
-
42
- def _normalize_name(name)
43
- puts "NAME: #{name}"
44
- case name
45
- when String
46
- name.strip.downcase.to_sym
47
- when Symbol
48
- name
49
- else
50
- raise ArgumentError, 'Provided MIME Type is not a valid or recognized entry'
51
- end
52
- end
53
-
54
- end # MimeType
55
- end # Github
@@ -1,95 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Github
4
- class Orgs < API
5
- extend AutoloadHelper
6
-
7
- autoload_all 'github_api/orgs',
8
- :Members => 'members',
9
- :Teams => 'teams'
10
-
11
- include Github::Orgs::Members
12
- include Github::Orgs::Teams
13
-
14
- VALID_ORG_PARAM_NAMES = %w[
15
- billing_email
16
- company
17
- email
18
- location
19
- name
20
- ].freeze
21
-
22
- # Creates new Orgs API
23
- def initialize(options = {})
24
- super(options)
25
- end
26
-
27
- # List all public organizations for a user.
28
- #
29
- # = Examples
30
- # @github = Github.new :user => 'user-name'
31
- # @github.orgs.orgs
32
- #
33
- # List public and private organizations for the authenticated user.
34
- #
35
- # @github = Github.new :oauth_token => '..'
36
- # @github.orgs.org 'github'
37
- #
38
- def orgs(user_name=nil, params={})
39
- _update_user_repo_params(user_name)
40
- _normalize_params_keys(params)
41
-
42
- response = if user?
43
- get("/users/#{user}/orgs", params)
44
- else
45
- get("/user/orgs", params)
46
- end
47
- return response unless block_given?
48
- response.each { |el| yield el }
49
- end
50
- alias :list_orgs :orgs
51
- alias :list_organizations :orgs
52
-
53
- # Get properties for a single organization
54
- #
55
- # = Examples
56
- # @github = Github.new
57
- # @github.orgs.org 'github'
58
- #
59
- def org(org_name, params={})
60
- _validate_presence_of org_name
61
- get("/orgs/#{org_name}")
62
- end
63
- alias :get_org :org
64
- alias :organisation :org
65
-
66
- # Edit organization
67
- #
68
- # = Parameters
69
- # <tt>:billing_email</tt> - Optional string - Billing email address. This address is not publicized.
70
- # <tt>:company</tt> - Optional string
71
- # <tt>:email</tt> - Optional string
72
- # <tt>:location</tt> - Optional string
73
- # <tt>:name</tt> - Optional string
74
- #
75
- # = Examples
76
- # @github = Github.new :oauth_token => '...'
77
- # @github.orgs.edit_org 'github',
78
- # "billing_email" => "support@github.com",
79
- # "blog" => "https://github.com/blog",
80
- # "company" => "GitHub",
81
- # "email" => "support@github.com",
82
- # "location" => "San Francisco",
83
- # "name" => "github"
84
- #
85
- def edit_org(org_name, params={})
86
- _validate_presence_of org_name
87
- _normalize_params_keys(params)
88
- _filter_params_keys(VALID_ORG_PARAM_NAMES, params)
89
-
90
- patch("/orgs/#{org_name}", params)
91
- end
92
- alias :edit_organization :edit_org
93
-
94
- end # Orgs
95
- end # Github