github_api 0.4.11 → 0.5.0.rc1

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 (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
@@ -7,18 +7,24 @@ module Github
7
7
 
8
8
  # Instantiates a new github api object
9
9
  def self.new(klass, options={})
10
- return _create_instance(klass, options) if klass
10
+ return create_instance(klass, options) if klass
11
11
  raise ArgumentError, 'must provied klass to be instantiated'
12
12
  end
13
13
 
14
- private
15
-
16
14
  # Passes configuration options to instantiated class
17
- def self._create_instance(klass, options)
15
+ def self.create_instance(klass, options)
18
16
  options.symbolize_keys!
19
- instance = Github.const_get(klass.to_sym).new options
17
+ instance = convert_to_constant(klass.to_s).new options
20
18
  Github.api_client = instance
21
19
  instance
22
20
  end
21
+
22
+ def self.convert_to_constant(classes)
23
+ constant = Github
24
+ classes.split('::').each do |klass|
25
+ constant = constant.const_get klass
26
+ end
27
+ return constant
28
+ end
23
29
  end
24
30
  end # Github
@@ -17,56 +17,51 @@ module Github
17
17
  # List authorizations
18
18
  #
19
19
  # = Examples
20
- # @github = Github.new :basic_auth => 'login:password'
21
- # @github.oauth.authorizations
22
- # @github.oauth.authorizations { |auth| ... }
20
+ # github = Github.new :basic_auth => 'login:password'
21
+ # github.oauth.list
22
+ # github.oauth.list { |auth| ... }
23
23
  #
24
- def authorizations(params={})
24
+ def list(params={})
25
25
  _check_if_authenticated
26
26
  _normalize_params_keys(params)
27
27
 
28
- response = get("/authorizations", params)
28
+ response = get_request("/authorizations", params)
29
29
  return response unless block_given?
30
30
  response.each { |el| yield el }
31
31
  end
32
- alias :auths :authorizations
33
- alias :list_auths :authorizations
34
- alias :list_authorizations :authorizations
32
+ alias :all :list
35
33
 
36
34
  # Get a single authorization
37
35
  #
38
36
  # = Examples
39
- # @github = Github.new :basic_auth => 'login:password'
40
- # @github.oauth.authorization 'authorization-id'
37
+ # github = Github.new :basic_auth => 'login:password'
38
+ # github.oauth.get 'authorization-id'
41
39
  #
42
- def authorization(authorization_id, params={})
40
+ def get(authorization_id, params={})
43
41
  _validate_presence_of(authorization_id)
44
42
  _check_if_authenticated
45
43
  _normalize_params_keys params
46
44
 
47
- get "/authorizations/#{authorization_id}", params
45
+ get_request("/authorizations/#{authorization_id}", params)
48
46
  end
49
- alias :auth :authorization
50
- alias :get_auth :authorization
51
- alias :get_authorization :authorization
47
+ alias :find :get
52
48
 
53
49
  # Create a new authorization
54
50
  #
55
51
  # = Inputs
56
52
  # * <tt>:scopes</tt> - Optional array - A list of scopes that this authorization is in.
57
53
  # = Examples
58
- # @github = Github.new :basic_auth => 'login:password'
59
- # @github.oauth.create_authorization
54
+ # github = Github.new :basic_auth => 'login:password'
55
+ # github.oauth.create
60
56
  # "scopes" => ["public_repo"]
61
57
  #
62
- def create_authorization(params={})
58
+ def create(params={})
63
59
  _check_if_authenticated
64
60
  _normalize_params_keys(params)
65
61
  _filter_params_keys(VALID_AUTH_PARAM_NAMES, params)
66
62
 
67
- post("/authorizations", params)
63
+ post_request("/authorizations", params)
68
64
  end
69
- alias :create_auth :create_authorization
70
65
 
71
66
  # Update an existing authorization
72
67
  #
@@ -76,38 +71,34 @@ module Github
76
71
  # * <tt>:remove_scopes</tt> - Optional array - A list of scopes to remove from this authorization.
77
72
  #
78
73
  # = Examples
79
- # @github = Github.new :basic_auth => 'login:password'
80
- # @github.oauth.update_authorization
81
- # "add_scopes" => ["repo"],
74
+ # github = Github.new :basic_auth => 'login:password'
75
+ # github.oauth.update "authorization-id", "add_scopes" => ["repo"],
82
76
  #
83
- def update_authorization(authorization_id, params={})
77
+ def update(authorization_id, params={})
84
78
  _check_if_authenticated
85
79
  _validate_presence_of(authorization_id)
86
80
 
87
81
  _normalize_params_keys(params)
88
82
  _filter_params_keys(VALID_AUTH_PARAM_NAMES, params)
89
83
 
90
- patch("/authorizations/#{authorization_id}", params)
84
+ patch_request("/authorizations/#{authorization_id}", params)
91
85
  end
92
- alias :update_auth :update_authorization
93
86
 
94
87
  # Delete an authorization
95
88
  #
96
89
  # = Examples
97
- # @github.oauth.delete_authorization 'authorization-id'
90
+ # github.oauth.delete 'authorization-id'
98
91
  #
99
- def delete_authorization(authorization_id, params={})
92
+ def delete(authorization_id, params={})
100
93
  _check_if_authenticated
101
94
  _validate_presence_of(authorization_id)
102
95
 
103
96
  _normalize_params_keys(params)
104
97
  _filter_params_keys(VALID_AUTH_PARAM_NAMES, params)
105
98
 
106
- delete("/authorizations/#{authorization_id}", params)
99
+ delete_request("/authorizations/#{authorization_id}", params)
107
100
  end
108
- alias :delete_auth :delete_authorization
109
- alias :remove_auth :delete_authorization
110
- alias :remove_authorization :delete_authorization
101
+ alias :remove :delete
111
102
 
112
103
  private
113
104
 
@@ -50,6 +50,7 @@ module Github
50
50
  def oauth(options = {})
51
51
  @oauth ||= ApiFactory.new 'Authorizations', options
52
52
  end
53
+ alias :authorizations :oauth
53
54
 
54
55
  end # Client
55
56
  end # Github
@@ -11,14 +11,14 @@ module Github
11
11
  # List all public events
12
12
  #
13
13
  # = Examples
14
- # @github = Github.new
15
- # @github.events.public
16
- # @github.events.public { |event| ... }
14
+ # github = Github.new
15
+ # github.events.public
16
+ # github.events.public { |event| ... }
17
17
  #
18
18
  def public(params={})
19
19
  _normalize_params_keys(params)
20
20
 
21
- response = get("/events", params)
21
+ response = get_request("/events", params)
22
22
  return response unless block_given?
23
23
  response.each { |el| yield el }
24
24
  end
@@ -29,16 +29,16 @@ module Github
29
29
  # List all repository events for a given user
30
30
  #
31
31
  # = Examples
32
- # @github = Github.new
33
- # @github.events.repository_events 'user-name', 'repo-name'
34
- # @github.events.repository_events 'user-name', 'repo-name' { |event| ... }
32
+ # github = Github.new
33
+ # github.events.repository 'user-name', 'repo-name'
34
+ # github.events.repository 'user-name', 'repo-name' { |event| ... }
35
35
  #
36
36
  def repository(user_name=nil, repo_name=nil, params={})
37
37
  _update_user_repo_params(user_name, repo_name)
38
38
  _validate_user_repo_params(user, repo) unless user? && repo?
39
39
  _normalize_params_keys(params)
40
40
 
41
- response = get("/repos/#{user}/#{repo}/events", params)
41
+ response = get_request("/repos/#{user}/#{repo}/events", params)
42
42
  return response unless block_given?
43
43
  response.each { |el| yield el }
44
44
  end
@@ -50,16 +50,16 @@ module Github
50
50
  # List all issue events for a given repository
51
51
  #
52
52
  # = Examples
53
- # @github = Github.new
54
- # @github.events.issue 'user-name', 'repo-name'
55
- # @github.events.issue 'user-name', 'repo-name' { |event| ... }
53
+ # github = Github.new
54
+ # github.events.issue 'user-name', 'repo-name'
55
+ # github.events.issue 'user-name', 'repo-name' { |event| ... }
56
56
  #
57
57
  def issue(user_name=nil, repo_name=nil, params={})
58
58
  _update_user_repo_params(user_name, repo_name)
59
59
  _validate_user_repo_params(user, repo) unless user? && repo?
60
60
  _normalize_params_keys(params)
61
61
 
62
- response = get("/repos/#{user}/#{repo}/issues/events", params)
62
+ response = get_request("/repos/#{user}/#{repo}/issues/events", params)
63
63
  return response unless block_given?
64
64
  response.each { |el| yield el }
65
65
  end
@@ -70,16 +70,16 @@ module Github
70
70
  # List all public events for a network of repositories
71
71
  #
72
72
  # = Examples
73
- # @github = Github.new
74
- # @github.events.network 'user-name', 'repo-name'
75
- # @github.events.network 'user-name', 'repo-name' { |event| ... }
73
+ # github = Github.new
74
+ # github.events.network 'user-name', 'repo-name'
75
+ # github.events.network 'user-name', 'repo-name' { |event| ... }
76
76
  #
77
77
  def network(user_name=nil, repo_name=nil, params={})
78
78
  _update_user_repo_params(user_name, repo_name)
79
79
  _validate_user_repo_params(user, repo) unless user? && repo?
80
80
  _normalize_params_keys(params)
81
81
 
82
- response = get("/networks/#{user}/#{repo}/events", params)
82
+ response = get_request("/networks/#{user}/#{repo}/events", params)
83
83
  return response unless block_given?
84
84
  response.each { |el| yield el }
85
85
  end
@@ -91,15 +91,15 @@ module Github
91
91
  # List all public events for an organization
92
92
  #
93
93
  # = Examples
94
- # @github = Github.new
95
- # @github.events.org 'org-name'
96
- # @github.events.org 'org-name' { |event| ... }
94
+ # github = Github.new
95
+ # github.events.org 'org-name'
96
+ # github.events.org 'org-name' { |event| ... }
97
97
  #
98
98
  def org(org_name, params={})
99
99
  _validate_presence_of org_name
100
100
  _normalize_params_keys(params)
101
101
 
102
- response = get("/orgs/#{org_name}/events", params)
102
+ response = get_request("/orgs/#{org_name}/events", params)
103
103
  return response unless block_given?
104
104
  response.each { |el| yield el }
105
105
  end
@@ -115,16 +115,16 @@ module Github
115
115
  # Otherwise, you’ll only see public events.
116
116
  #
117
117
  # = Examples
118
- # @github = Github.new
119
- # @github.events.received 'user-name'
120
- # @github.events.received 'user-name' { |event| ... }
118
+ # github = Github.new
119
+ # github.events.received 'user-name'
120
+ # github.events.received 'user-name' { |event| ... }
121
121
  #
122
122
  # List all public events that a user has received
123
123
  #
124
124
  # = Examples
125
- # @github = Github.new
126
- # @github.events.received 'user-name', :public => true
127
- # @github.events.received 'user-name', :public => true { |event| ... }
125
+ # github = Github.new
126
+ # github.events.received 'user-name', :public => true
127
+ # github.events.received 'user-name', :public => true { |event| ... }
128
128
  #
129
129
  def received(user_name, params={})
130
130
  _validate_presence_of user_name
@@ -135,7 +135,7 @@ module Github
135
135
  '/public'
136
136
  end
137
137
 
138
- response = get("/users/#{user_name}/received_events#{public_events}", params)
138
+ response = get_request("/users/#{user_name}/received_events#{public_events}", params)
139
139
  return response unless block_given?
140
140
  response.each { |el| yield el }
141
141
  end
@@ -148,16 +148,16 @@ module Github
148
148
  # events. Otherwise, you’ll only see public events.
149
149
  #
150
150
  # = Examples
151
- # @github = Github.new
152
- # @github.events.performed 'user-name'
153
- # @github.events.performed 'user-name' { |event| ... }
151
+ # github = Github.new
152
+ # github.events.performed 'user-name'
153
+ # github.events.performed 'user-name' { |event| ... }
154
154
  #
155
155
  # List all public events that a user has performed
156
156
  #
157
157
  # = Examples
158
- # @github = Github.new
159
- # @github.events.performed 'user-name', :public => true
160
- # @github.events.performed 'user-name', :public => true { |event| ... }
158
+ # github = Github.new
159
+ # github.events.performed 'user-name', :public => true
160
+ # github.events.performed 'user-name', :public => true { |event| ... }
161
161
  #
162
162
  def performed(user_name, params={})
163
163
  _validate_presence_of user_name
@@ -168,7 +168,7 @@ module Github
168
168
  '/public'
169
169
  end
170
170
 
171
- response = get("/users/#{user_name}/events#{public_events}", params)
171
+ response = get_request("/users/#{user_name}/events#{public_events}", params)
172
172
  return response unless block_given?
173
173
  response.each { |el| yield el }
174
174
  end
@@ -181,15 +181,15 @@ module Github
181
181
  # as the user to view this.
182
182
  #
183
183
  # = Examples
184
- # @github = Github.new
185
- # @github.events.user_org 'user-name', 'org-name'
186
- # @github.events.user_org 'user-name', 'org-name' { |event| ... }
184
+ # github = Github.new
185
+ # github.events.user_org 'user-name', 'org-name'
186
+ # github.events.user_org 'user-name', 'org-name' { |event| ... }
187
187
  #
188
188
  def user_org(user_name, org_name, params={})
189
189
  _validate_presence_of user_name, org_name
190
190
  _normalize_params_keys(params)
191
191
 
192
- response = get("/users/#{user_name}/events/orgs/#{org_name}", params)
192
+ response = get_request("/users/#{user_name}/events/orgs/#{org_name}", params)
193
193
  return response unless block_given?
194
194
  response.each { |el| yield el }
195
195
  end
@@ -36,7 +36,7 @@ module Github
36
36
  case params
37
37
  when Hash
38
38
  params.keys.each do |k, v|
39
- unless (keys.include?(k) or Github::Validation::VALID_API_KEYS.include?(k))
39
+ unless (keys.include?(k) or Github::Validations::VALID_API_KEYS.include?(k))
40
40
  params.delete(k)
41
41
  else
42
42
  _filter_params_keys(keys, params[k]) if options[:recursive]
@@ -7,7 +7,7 @@ module Github
7
7
  autoload_all 'github_api/gists',
8
8
  :Comments => 'comments'
9
9
 
10
- include Github::Gists::Comments
10
+ # include Github::Gists::Comments
11
11
 
12
12
  REQUIRED_GIST_INPUTS = %w[
13
13
  description
@@ -21,49 +21,54 @@ module Github
21
21
  super(options)
22
22
  end
23
23
 
24
+ # Access to Gists::Comments API
25
+ def comments
26
+ @comments ||= ApiFactory.new 'Gists::Comments'
27
+ end
28
+
24
29
  # List a user's gists.
25
30
  #
26
31
  # = Examples
27
- # @github = Github.new :user => 'user-name'
28
- # @github.gists.gists
32
+ # github = Github.new :user => 'user-name'
33
+ # github.gists.list
29
34
  #
30
35
  # List the authenticated user’s gists or if called anonymously,
31
36
  # this will returns all public gists
32
37
  #
33
38
  # = Examples
34
- # @github = Github.new :oauth_token => '...'
35
- # @github.gists.gists
39
+ # github = Github.new :oauth_token => '...'
40
+ # github.gists.list
36
41
  #
37
- def gists(user_name=nil, params={})
42
+ def list(user_name=nil, params={})
38
43
  _update_user_repo_params(user_name)
39
44
  process_params do
40
45
  normalize params
41
46
  end
42
47
 
43
48
  response = if user
44
- get("/users/#{user}/gists", params)
49
+ get_request("/users/#{user}/gists", params)
45
50
  elsif oauth_token
46
- get("/gists", params)
51
+ get_request("/gists", params)
47
52
  else
48
- get("/gists/public", params)
53
+ get_request("/gists/public", params)
49
54
  end
50
55
  return response unless block_given?
51
56
  response.each { |el| yield el }
52
57
  end
53
- alias :list_gists :gists
58
+ alias :all :list
54
59
 
55
60
  # List the authenticated user's starred gists
56
61
  #
57
62
  # = Examples
58
- # @github = Github.new :oauth_token => '...'
59
- # @github.gists.starred
63
+ # github = Github.new :oauth_token => '...'
64
+ # github.gists.starred
60
65
  #
61
66
  def starred(params={})
62
67
  process_params do
63
68
  normalize params
64
69
  end
65
70
 
66
- response = get("/gists/starred", params)
71
+ response = get_request("/gists/starred", params)
67
72
  return response unless block_given?
68
73
  response.each { |el| yield el }
69
74
  end
@@ -71,16 +76,16 @@ module Github
71
76
  # Get a single gist
72
77
  #
73
78
  # = Examples
74
- # @github = Github.new
75
- # @github.gists.get_gist 'gist-id'
79
+ # github = Github.new
80
+ # github.gists.get 'gist-id'
76
81
  #
77
- def gist(gist_id, params={})
82
+ def get(gist_id, params={})
78
83
  _normalize_params_keys(params)
79
84
  _validate_presence_of(gist_id)
80
85
 
81
- get("/gists/#{gist_id}", params)
86
+ get_request("/gists/#{gist_id}", params)
82
87
  end
83
- alias :get_gist :gist
88
+ alias :find :get
84
89
 
85
90
  # Create a gist
86
91
  #
@@ -93,8 +98,8 @@ module Github
93
98
  # <tt>:content</tt> - Required string - File contents.
94
99
  #
95
100
  # = Examples
96
- # @github = Github.new
97
- # @github.gists.create_gist
101
+ # github = Github.new
102
+ # github.gists.create
98
103
  # 'description' => 'the description for this gist',
99
104
  # 'public' => true,
100
105
  # 'files' => {
@@ -103,11 +108,11 @@ module Github
103
108
  # }
104
109
  # }
105
110
  #
106
- def create_gist(params={})
111
+ def create(params={})
107
112
  _normalize_params_keys(params)
108
113
  _validate_inputs(REQUIRED_GIST_INPUTS, params)
109
114
 
110
- post("/gists", params)
115
+ post_request("/gists", params)
111
116
  end
112
117
 
113
118
  # Edit a gist
@@ -121,8 +126,8 @@ module Github
121
126
  # <tt>:filename</tt> - Optional string - New name for this file.
122
127
  #
123
128
  # = Examples
124
- # @github = Github.new :oauth_token => '...'
125
- # @github.gists.edit_gist 'gist-id',
129
+ # github = Github.new :oauth_token => '...'
130
+ # github.gists.edit 'gist-id',
126
131
  # 'description' => 'the description for this gist',
127
132
  # 'files' => {
128
133
  # 'file1.txt' => {
@@ -138,50 +143,50 @@ module Github
138
143
  # 'delete_the_file.txt' => nil
139
144
  # }
140
145
  #
141
- def edit_gist(gist_id, params={})
146
+ def edit(gist_id, params={})
142
147
  _validate_presence_of(gist_id)
143
148
  _normalize_params_keys(params)
144
149
 
145
- patch("/gists/#{gist_id}", params)
150
+ patch_request("/gists/#{gist_id}", params)
146
151
  end
147
152
 
148
153
  # Star a gist
149
154
  #
150
155
  # = Examples
151
- # @github = Github.new
152
- # @github.gists.star 'gist-id'
156
+ # github = Github.new
157
+ # github.gists.star 'gist-id'
153
158
  #
154
159
  def star(gist_id, params={})
155
160
  _validate_presence_of(gist_id)
156
161
  _normalize_params_keys(params)
157
162
 
158
- put("/gists/#{gist_id}/star", params)
163
+ put_request("/gists/#{gist_id}/star", params)
159
164
  end
160
165
 
161
166
  # Unstar a gist
162
167
  #
163
168
  # = Examples
164
- # @github = Github.new
165
- # @github.gists.unstar 'gist-id'
169
+ # github = Github.new
170
+ # github.gists.unstar 'gist-id'
166
171
  #
167
172
  def unstar(gist_id, params={})
168
173
  _validate_presence_of(gist_id)
169
174
  _normalize_params_keys(params)
170
175
 
171
- delete("/gists/#{gist_id}/star", params)
176
+ delete_request("/gists/#{gist_id}/star", params)
172
177
  end
173
178
 
174
179
  # Check if a gist is starred
175
180
  #
176
181
  # = Examples
177
- # @github = Github.new
178
- # @github.gists.unstar 'gist-id'
182
+ # github = Github.new
183
+ # github.gists.starred? 'gist-id'
179
184
  #
180
185
  def starred?(gist_id, params={})
181
186
  _validate_presence_of(gist_id)
182
187
  _normalize_params_keys(params)
183
188
 
184
- get("/gists/#{gist_id}/star", params)
189
+ get_request("/gists/#{gist_id}/star", params)
185
190
  true
186
191
  rescue Github::Error::NotFound
187
192
  false
@@ -190,27 +195,27 @@ module Github
190
195
  # Fork a gist
191
196
  #
192
197
  # = Examples
193
- # @github = Github.new
194
- # @github.gists.fork 'gist-id'
198
+ # github = Github.new
199
+ # github.gists.fork 'gist-id'
195
200
  #
196
201
  def fork(gist_id, params={})
197
202
  _validate_presence_of(gist_id)
198
203
  _normalize_params_keys(params)
199
204
 
200
- post("/gists/#{gist_id}/fork", params)
205
+ post_request("/gists/#{gist_id}/fork", params)
201
206
  end
202
207
 
203
208
  # Delete a gist
204
209
  #
205
210
  # = Examples
206
- # @github = Github.new
207
- # @github.gists.delete_gist 'gist-id'
211
+ # github = Github.new
212
+ # github.gists.delete 'gist-id'
208
213
  #
209
- def delete_gist(gist_id, params={})
214
+ def delete(gist_id, params={})
210
215
  _validate_presence_of(gist_id)
211
216
  _normalize_params_keys(params)
212
217
 
213
- delete("/gists/#{gist_id}", params)
218
+ delete_request("/gists/#{gist_id}", params)
214
219
  end
215
220
 
216
221
  end # Gists