github_api 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/README.md +2 -1
  2. data/lib/github_api/api.rb +5 -3
  3. data/lib/github_api/authorizations.rb +8 -8
  4. data/lib/github_api/connection.rb +1 -1
  5. data/lib/github_api/events.rb +8 -8
  6. data/lib/github_api/gists/comments.rb +7 -7
  7. data/lib/github_api/gists.rb +10 -10
  8. data/lib/github_api/git_data/blobs.rb +3 -3
  9. data/lib/github_api/git_data/commits.rb +3 -3
  10. data/lib/github_api/git_data/references.rb +7 -7
  11. data/lib/github_api/git_data/tags.rb +3 -3
  12. data/lib/github_api/git_data/trees.rb +3 -3
  13. data/lib/github_api/issues/comments.rb +7 -7
  14. data/lib/github_api/issues/events.rb +2 -2
  15. data/lib/github_api/issues/labels.rb +12 -11
  16. data/lib/github_api/issues/milestones.rb +8 -8
  17. data/lib/github_api/issues.rb +9 -9
  18. data/lib/github_api/normalizer.rb +27 -0
  19. data/lib/github_api/orgs/members.rb +7 -7
  20. data/lib/github_api/orgs/teams.rb +15 -16
  21. data/lib/github_api/orgs.rb +4 -3
  22. data/lib/github_api/parameter_filter.rb +32 -0
  23. data/lib/github_api/pull_requests/comments.rb +7 -7
  24. data/lib/github_api/pull_requests.rb +12 -12
  25. data/lib/github_api/repos/collaborators.rb +4 -4
  26. data/lib/github_api/repos/commits.rb +11 -11
  27. data/lib/github_api/repos/contents.rb +3 -3
  28. data/lib/github_api/repos/downloads.rb +5 -5
  29. data/lib/github_api/repos/forks.rb +3 -3
  30. data/lib/github_api/repos/hooks.rb +8 -8
  31. data/lib/github_api/repos/keys.rb +7 -7
  32. data/lib/github_api/repos/pub_sub_hubbub.rb +4 -4
  33. data/lib/github_api/repos/watching.rb +5 -5
  34. data/lib/github_api/repos.rb +13 -13
  35. data/lib/github_api/search.rb +4 -4
  36. data/lib/github_api/users/emails.rb +3 -3
  37. data/lib/github_api/users/followers.rb +5 -5
  38. data/lib/github_api/users/keys.rb +7 -7
  39. data/lib/github_api/users.rb +3 -3
  40. data/lib/github_api/validations/presence.rb +1 -0
  41. data/lib/github_api/version.rb +1 -1
  42. data/lib/github_api.rb +26 -25
  43. data/spec/github/api_spec.rb +4 -4
  44. data/spec/github/normalizer_spec.rb +20 -0
  45. data/spec/github/parameter_filter_spec.rb +71 -0
  46. metadata +42 -40
  47. data/lib/github_api/filter.rb +0 -57
  48. data/spec/github/filter_spec.rb +0 -82
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-12 00:00:00.000000000Z
12
+ date: 2012-06-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie
16
- requirement: &2153407400 !ruby/object:Gem::Requirement
16
+ requirement: &2153407020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: 1.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153407400
24
+ version_requirements: *2153407020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: faraday
27
- requirement: &2153406900 !ruby/object:Gem::Requirement
27
+ requirement: &2153406520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 0.8.0
32
+ version: 0.8.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2153406900
35
+ version_requirements: *2153406520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: multi_json
38
- requirement: &2153406420 !ruby/object:Gem::Requirement
38
+ requirement: &2153406040 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,21 +43,21 @@ dependencies:
43
43
  version: '1.3'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2153406420
46
+ version_requirements: *2153406040
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: oauth2
49
- requirement: &2153392320 !ruby/object:Gem::Requirement
49
+ requirement: &2153400220 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
- - - ~>
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
- version: '0.7'
54
+ version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2153392320
57
+ version_requirements: *2153400220
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nokogiri
60
- requirement: &2153391800 !ruby/object:Gem::Requirement
60
+ requirement: &2153399560 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.5.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2153391800
68
+ version_requirements: *2153399560
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &2153391320 !ruby/object:Gem::Requirement
71
+ requirement: &2153399020 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2153391320
79
+ version_requirements: *2153399020
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: cucumber
82
- requirement: &2153390860 !ruby/object:Gem::Requirement
82
+ requirement: &2153398480 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2153390860
90
+ version_requirements: *2153398480
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: yajl-ruby
93
- requirement: &2153390380 !ruby/object:Gem::Requirement
93
+ requirement: &2153397960 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.1.0
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2153390380
101
+ version_requirements: *2153397960
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: webmock
104
- requirement: &2153389860 !ruby/object:Gem::Requirement
104
+ requirement: &2153397380 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 1.8.0
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2153389860
112
+ version_requirements: *2153397380
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: vcr
115
- requirement: &2153389400 !ruby/object:Gem::Requirement
115
+ requirement: &2153396800 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 2.2.0
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *2153389400
123
+ version_requirements: *2153396800
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: simplecov
126
- requirement: &2153388880 !ruby/object:Gem::Requirement
126
+ requirement: &2153396220 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ~>
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: 0.6.1
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *2153388880
134
+ version_requirements: *2153396220
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: guard
137
- requirement: &2153388500 !ruby/object:Gem::Requirement
137
+ requirement: &2153395720 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *2153388500
145
+ version_requirements: *2153395720
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: guard-rspec
148
- requirement: &2153388020 !ruby/object:Gem::Requirement
148
+ requirement: &2153395140 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *2153388020
156
+ version_requirements: *2153395140
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: guard-cucumber
159
- requirement: &2153387560 !ruby/object:Gem::Requirement
159
+ requirement: &2153394600 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ! '>='
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: '0'
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *2153387560
167
+ version_requirements: *2153394600
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: rake
170
- requirement: &2153387140 !ruby/object:Gem::Requirement
170
+ requirement: &2153394100 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ! '>='
@@ -175,10 +175,10 @@ dependencies:
175
175
  version: '0'
176
176
  type: :development
177
177
  prerelease: false
178
- version_requirements: *2153387140
178
+ version_requirements: *2153394100
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: bundler
181
- requirement: &2153386680 !ruby/object:Gem::Requirement
181
+ requirement: &2153393640 !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements:
184
184
  - - ! '>='
@@ -186,7 +186,7 @@ dependencies:
186
186
  version: '0'
187
187
  type: :development
188
188
  prerelease: false
189
- version_requirements: *2153386680
189
+ version_requirements: *2153393640
190
190
  description: ! ' Ruby wrapper that supports all of the GitHub API v3 methods(nearly
191
191
  200). It''s build in a modular way, that is, you can either instantiate the whole
192
192
  api wrapper Github.new or use parts of it e.i. Github::Repos.new if working solely
@@ -316,7 +316,6 @@ files:
316
316
  - lib/github_api/error/validations.rb
317
317
  - lib/github_api/error.rb
318
318
  - lib/github_api/events.rb
319
- - lib/github_api/filter.rb
320
319
  - lib/github_api/gists/comments.rb
321
320
  - lib/github_api/gists.rb
322
321
  - lib/github_api/git_data/blobs.rb
@@ -331,6 +330,7 @@ files:
331
330
  - lib/github_api/issues/milestones.rb
332
331
  - lib/github_api/issues.rb
333
332
  - lib/github_api/mime_type.rb
333
+ - lib/github_api/normalizer.rb
334
334
  - lib/github_api/orgs/members.rb
335
335
  - lib/github_api/orgs/teams.rb
336
336
  - lib/github_api/orgs.rb
@@ -338,6 +338,7 @@ files:
338
338
  - lib/github_api/page_links.rb
339
339
  - lib/github_api/page_uri_processor.rb
340
340
  - lib/github_api/paged_request.rb
341
+ - lib/github_api/parameter_filter.rb
341
342
  - lib/github_api/params_hash.rb
342
343
  - lib/github_api/pull_requests/comments.rb
343
344
  - lib/github_api/pull_requests.rb
@@ -465,7 +466,6 @@ files:
465
466
  - spec/github/error/required_params_spec.rb
466
467
  - spec/github/error/unknown_value_spec.rb
467
468
  - spec/github/events_spec.rb
468
- - spec/github/filter_spec.rb
469
469
  - spec/github/gists/comments_spec.rb
470
470
  - spec/github/gists_spec.rb
471
471
  - spec/github/git_data/blobs_spec.rb
@@ -480,12 +480,14 @@ files:
480
480
  - spec/github/issues/milestones_spec.rb
481
481
  - spec/github/issues_spec.rb
482
482
  - spec/github/mime_type_spec.rb
483
+ - spec/github/normalizer_spec.rb
483
484
  - spec/github/orgs/members_spec.rb
484
485
  - spec/github/orgs/teams_spec.rb
485
486
  - spec/github/orgs_spec.rb
486
487
  - spec/github/page_iterator_spec.rb
487
488
  - spec/github/page_links_spec.rb
488
489
  - spec/github/paged_request_spec.rb
490
+ - spec/github/parameter_filter_spec.rb
489
491
  - spec/github/pull_requests/comments_spec.rb
490
492
  - spec/github/pull_requests_spec.rb
491
493
  - spec/github/repos/collaborators_spec.rb
@@ -526,7 +528,7 @@ files:
526
528
  homepage: https://github.com/peter-murach/github
527
529
  licenses: []
528
530
  post_install_message: ! "\n--------------------------------------------------------------------------------\nThank
529
- you for installing github_api-0.6.0.\n\n*NOTE*: Version 0.5.0 introduces breaking
531
+ you for installing github_api-0.6.1.\n\n*NOTE*: Version 0.5.0 introduces breaking
530
532
  changes to the way github api is queried.\nThe interface has been rewritten to be
531
533
  more consistent with REST verbs that\ninteract with GitHub hypermedia resources.
532
534
  Thus, to list resources 'list' or 'all'\nverbs are used, to retrieve individual
@@ -1,57 +0,0 @@
1
- module Github
2
- module Filter
3
-
4
- def process_params(*args)
5
- yield self if block_given?
6
- end
7
-
8
- def normalize(params)
9
- _normalize_params_keys params
10
- end
11
-
12
- def filter(keys, params)
13
- _filter_params_keys(keys, params)
14
- end
15
-
16
- # Turns any keys from nested hashes including nested arrays into strings
17
- def _normalize_params_keys(params) # :nodoc:
18
- case params
19
- when Hash
20
- params.keys.each do |k|
21
- params[k.to_s] = params.delete(k)
22
- _normalize_params_keys(params[k.to_s])
23
- end
24
- when Array
25
- params.map! do |el|
26
- _normalize_params_keys(el)
27
- end
28
- else
29
- params.to_s
30
- end
31
- return params
32
- end
33
-
34
- # Removes any keys from nested hashes that don't match predefiend keys
35
- # filter_valid_keys
36
- def _filter_params_keys(keys, params, options={:recursive => true}) # :nodoc:
37
- case params
38
- when Hash
39
- params.keys.each do |k, v|
40
- unless (keys.include?(k) or Github::Validations::VALID_API_KEYS.include?(k))
41
- params.delete(k)
42
- else
43
- _filter_params_keys(keys, params[k]) if options[:recursive]
44
- end
45
- end
46
- when Array
47
- params.map! do |el|
48
- _filter_params_keys(keys, el) if options[:recursive]
49
- end
50
- else
51
- params
52
- end
53
- return params
54
- end
55
-
56
- end # Filter
57
- end # Github
@@ -1,82 +0,0 @@
1
- require 'spec_helper'
2
- require 'github_api/core_ext/hash'
3
-
4
- describe Github::Filter do
5
- let(:github) { Github.new }
6
- let(:repos_instance) { Github::Repos.new }
7
- let(:block) {
8
- Proc.new do |repo|
9
- repo = repos_instance
10
- end
11
- }
12
- let(:hash) { { :a => { :b => { :c => 1 } } } }
13
-
14
- context '#process_params' do
15
-
16
- it 'correctly yields current api instance' do
17
- github.repos.should_receive(:process_params).and_yield repos_instance
18
- github.repos.process_params(&block).should eq repos_instance
19
- end
20
- end
21
-
22
- context '#normalize' do
23
- it 'should call normalize on passed block' do
24
- github.repos.process_params(&block).should respond_to :normalize
25
- end
26
-
27
- it 'should normalize params inside block' do
28
- github.repos.stub(:process_params).and_yield repos_instance
29
- github.repos.process_params do |repo|
30
- repo.normalize hash
31
- end
32
- hash.all_keys.should include 'a'
33
- hash.all_keys.should_not include :a
34
- end
35
- end
36
-
37
- context '#filter' do
38
- it 'should call filter on passed block' do
39
- github.repos.process_params(&block).should respond_to :filter
40
- end
41
-
42
- it 'should filter params inside block' do
43
- github.repos.stub(:process_params).and_yield repos_instance
44
- github.repos.process_params do |repo|
45
- repo.filter [:a], hash
46
- end
47
- hash.all_keys.should include :a
48
- hash.all_keys.should_not include :b
49
- end
50
- end
51
-
52
- context '#_normalize_params_keys' do
53
- it 'converts hash keys to string' do
54
- ['a', 'b', 'c'].each do |key|
55
- github.repos._normalize_params_keys(hash).all_keys.should include key
56
- end
57
- [:a, :b, :c].each do |key|
58
- github.repos._normalize_params_keys(hash).all_keys.should_not include key
59
- end
60
- end
61
- end
62
-
63
- context '#_filter_params_keys' do
64
- it 'removes unwanted keys from hash' do
65
- github.repos._filter_params_keys([:a], hash)
66
- hash.all_keys.should include :a
67
- hash.all_keys.should_not include :b
68
- hash.all_keys.should_not include :c
69
- end
70
-
71
- it 'recursively filters inputs tree' do
72
- github.repos._filter_params_keys([:a, :b], hash)
73
- hash.all_keys.should_not include :c
74
- end
75
-
76
- it 'filters inputs tree only on top level' do
77
- github.repos._filter_params_keys([:a, :b], hash, :recursive => false)
78
- hash.all_keys.should include :c
79
- end
80
- end
81
-
82
- end # Github::Filter