gitlab 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +1 -0
  4. data/LICENSE.txt +1 -1
  5. data/README.md +28 -3
  6. data/bin/gitlab +7 -0
  7. data/gitlab.gemspec +3 -2
  8. data/lib/gitlab.rb +8 -0
  9. data/lib/gitlab/api.rb +1 -1
  10. data/lib/gitlab/cli.rb +57 -0
  11. data/lib/gitlab/cli_helpers.rb +141 -0
  12. data/lib/gitlab/client.rb +8 -6
  13. data/lib/gitlab/client/branches.rb +79 -0
  14. data/lib/gitlab/client/merge_requests.rb +15 -2
  15. data/lib/gitlab/client/projects.rb +25 -4
  16. data/lib/gitlab/client/repositories.rb +22 -23
  17. data/lib/gitlab/client/system_hooks.rb +58 -0
  18. data/lib/gitlab/client/users.rb +17 -0
  19. data/lib/gitlab/configuration.rb +3 -3
  20. data/lib/gitlab/objectified_hash.rb +8 -2
  21. data/lib/gitlab/request.rb +21 -5
  22. data/lib/gitlab/version.rb +1 -1
  23. data/spec/fixtures/branch.json +1 -0
  24. data/spec/fixtures/{project_branches.json → branches.json} +0 -0
  25. data/spec/fixtures/create_branch.json +1 -0
  26. data/spec/fixtures/merge_request_comments.json +1 -0
  27. data/spec/fixtures/project_commit.json +13 -0
  28. data/spec/fixtures/project_commit_diff.json +10 -0
  29. data/spec/fixtures/{project_branch.json → protect_branch.json} +1 -1
  30. data/spec/fixtures/system_hook.json +1 -0
  31. data/spec/fixtures/system_hook_test.json +1 -0
  32. data/spec/fixtures/system_hooks.json +1 -0
  33. data/spec/fixtures/unprotect_branch.json +1 -0
  34. data/spec/gitlab/cli_spec.rb +80 -0
  35. data/spec/gitlab/client/branches_spec.rb +103 -0
  36. data/spec/gitlab/client/groups_spec.rb +21 -21
  37. data/spec/gitlab/client/issues_spec.rb +26 -26
  38. data/spec/gitlab/client/merge_requests_spec.rb +45 -13
  39. data/spec/gitlab/client/milestones_spec.rb +11 -11
  40. data/spec/gitlab/client/notes_spec.rb +30 -30
  41. data/spec/gitlab/client/projects_spec.rb +93 -59
  42. data/spec/gitlab/client/repositories_spec.rb +28 -25
  43. data/spec/gitlab/client/snippets_spec.rb +16 -16
  44. data/spec/gitlab/client/system_hooks_spec.rb +69 -0
  45. data/spec/gitlab/client/users_spec.rb +60 -24
  46. data/spec/gitlab/objectified_hash_spec.rb +23 -0
  47. data/spec/gitlab/request_spec.rb +48 -0
  48. data/spec/gitlab_spec.rb +16 -7
  49. data/spec/spec_helper.rb +19 -8
  50. metadata +70 -22
@@ -5,41 +5,50 @@ describe Gitlab do
5
5
 
6
6
  describe ".client" do
7
7
  it "should be a Gitlab::Client" do
8
- Gitlab.client.should be_a Gitlab::Client
8
+ expect(Gitlab.client).to be_a Gitlab::Client
9
+ end
10
+ end
11
+
12
+ describe ".actions" do
13
+ it "should return an array of client methods" do
14
+ actions = Gitlab.actions
15
+ expect(actions).to be_an Array
16
+ expect(actions.first).to be_a Symbol
17
+ expect(actions.sort.first).to match(/add_/)
9
18
  end
10
19
  end
11
20
 
12
21
  describe ".endpoint=" do
13
22
  it "should set endpoint" do
14
23
  Gitlab.endpoint = 'https://api.example.com'
15
- Gitlab.endpoint.should == 'https://api.example.com'
24
+ expect(Gitlab.endpoint).to eq('https://api.example.com')
16
25
  end
17
26
  end
18
27
 
19
28
  describe ".private_token=" do
20
29
  it "should set private_token" do
21
30
  Gitlab.private_token = 'secret'
22
- Gitlab.private_token.should == 'secret'
31
+ expect(Gitlab.private_token).to eq('secret')
23
32
  end
24
33
  end
25
34
 
26
35
  describe ".sudo=" do
27
36
  it "should set sudo" do
28
37
  Gitlab.sudo = 'user'
29
- Gitlab.sudo.should == 'user'
38
+ expect(Gitlab.sudo).to eq('user')
30
39
  end
31
40
  end
32
41
 
33
42
  describe ".user_agent" do
34
43
  it "should return default user_agent" do
35
- Gitlab.user_agent.should == Gitlab::Configuration::DEFAULT_USER_AGENT
44
+ expect(Gitlab.user_agent).to eq(Gitlab::Configuration::DEFAULT_USER_AGENT)
36
45
  end
37
46
  end
38
47
 
39
48
  describe ".user_agent=" do
40
49
  it "should set user_agent" do
41
50
  Gitlab.user_agent = 'Custom User Agent'
42
- Gitlab.user_agent.should == 'Custom User Agent'
51
+ expect(Gitlab.user_agent).to eq('Custom User Agent')
43
52
  end
44
53
  end
45
54
 
@@ -48,7 +57,7 @@ describe Gitlab do
48
57
  it "should set #{key}" do
49
58
  Gitlab.configure do |config|
50
59
  config.send("#{key}=", key)
51
- Gitlab.send(key).should == key
60
+ expect(Gitlab.send(key)).to eq(key)
52
61
  end
53
62
  end
54
63
  end
@@ -2,6 +2,17 @@ require 'rspec'
2
2
  require 'webmock/rspec'
3
3
 
4
4
  require File.expand_path('../../lib/gitlab', __FILE__)
5
+ require File.expand_path('../../lib/gitlab/cli', __FILE__)
6
+
7
+ def capture_output
8
+ out = StringIO.new
9
+ $stdout = out
10
+ $stderr = out
11
+ yield
12
+ $stdout = STDOUT
13
+ $stderr = STDERR
14
+ out.string
15
+ end
5
16
 
6
17
  def load_fixture(name)
7
18
  File.new(File.dirname(__FILE__) + "/fixtures/#{name}.json")
@@ -17,47 +28,47 @@ end
17
28
  # GET
18
29
  def stub_get(path, fixture)
19
30
  stub_request(:get, "#{Gitlab.endpoint}#{path}").
20
- with(:query => {:private_token => Gitlab.private_token}).
31
+ with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token}).
21
32
  to_return(:body => load_fixture(fixture))
22
33
  end
23
34
 
24
35
  def a_get(path)
25
36
  a_request(:get, "#{Gitlab.endpoint}#{path}").
26
- with(:query => {:private_token => Gitlab.private_token})
37
+ with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token})
27
38
  end
28
39
 
29
40
  # POST
30
41
  def stub_post(path, fixture, status_code=200)
31
42
  stub_request(:post, "#{Gitlab.endpoint}#{path}").
32
- with(:query => {:private_token => Gitlab.private_token}).
43
+ with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token}).
33
44
  to_return(:body => load_fixture(fixture), :status => status_code)
34
45
  end
35
46
 
36
47
  def a_post(path)
37
48
  a_request(:post, "#{Gitlab.endpoint}#{path}").
38
- with(:query => {:private_token => Gitlab.private_token})
49
+ with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token})
39
50
  end
40
51
 
41
52
  # PUT
42
53
  def stub_put(path, fixture)
43
54
  stub_request(:put, "#{Gitlab.endpoint}#{path}").
44
- with(:query => {:private_token => Gitlab.private_token}).
55
+ with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token}).
45
56
  to_return(:body => load_fixture(fixture))
46
57
  end
47
58
 
48
59
  def a_put(path)
49
60
  a_request(:put, "#{Gitlab.endpoint}#{path}").
50
- with(:query => {:private_token => Gitlab.private_token})
61
+ with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token})
51
62
  end
52
63
 
53
64
  # DELETE
54
65
  def stub_delete(path, fixture)
55
66
  stub_request(:delete, "#{Gitlab.endpoint}#{path}").
56
- with(:query => {:private_token => Gitlab.private_token}).
67
+ with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token}).
57
68
  to_return(:body => load_fixture(fixture))
58
69
  end
59
70
 
60
71
  def a_delete(path)
61
72
  a_request(:delete, "#{Gitlab.endpoint}#{path}").
62
- with(:query => {:private_token => Gitlab.private_token})
73
+ with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token})
63
74
  end
metadata CHANGED
@@ -1,88 +1,107 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nihad Abbasov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-22 00:00:00.000000000 Z
11
+ date: 2014-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: terminal-table
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - '>='
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - '>='
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - '>='
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: webmock
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '>='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - '>='
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
- description: Ruby client for GitLab API
83
+ description: Ruby client and CLI for GitLab API
70
84
  email:
71
85
  - mail@narkoz.me
72
- executables: []
86
+ executables:
87
+ - gitlab
73
88
  extensions: []
74
89
  extra_rdoc_files: []
75
90
  files:
76
- - .gitignore
77
- - .travis.yml
91
+ - ".gitignore"
92
+ - ".travis.yml"
78
93
  - Gemfile
79
94
  - LICENSE.txt
80
95
  - README.md
81
96
  - Rakefile
97
+ - bin/gitlab
82
98
  - gitlab.gemspec
83
99
  - lib/gitlab.rb
84
100
  - lib/gitlab/api.rb
101
+ - lib/gitlab/cli.rb
102
+ - lib/gitlab/cli_helpers.rb
85
103
  - lib/gitlab/client.rb
104
+ - lib/gitlab/client/branches.rb
86
105
  - lib/gitlab/client/groups.rb
87
106
  - lib/gitlab/client/issues.rb
88
107
  - lib/gitlab/client/merge_requests.rb
@@ -91,13 +110,17 @@ files:
91
110
  - lib/gitlab/client/projects.rb
92
111
  - lib/gitlab/client/repositories.rb
93
112
  - lib/gitlab/client/snippets.rb
113
+ - lib/gitlab/client/system_hooks.rb
94
114
  - lib/gitlab/client/users.rb
95
115
  - lib/gitlab/configuration.rb
96
116
  - lib/gitlab/error.rb
97
117
  - lib/gitlab/objectified_hash.rb
98
118
  - lib/gitlab/request.rb
99
119
  - lib/gitlab/version.rb
120
+ - spec/fixtures/branch.json
121
+ - spec/fixtures/branches.json
100
122
  - spec/fixtures/comment_merge_request.json
123
+ - spec/fixtures/create_branch.json
101
124
  - spec/fixtures/create_merge_request.json
102
125
  - spec/fixtures/error_already_exists.json
103
126
  - spec/fixtures/group.json
@@ -111,14 +134,15 @@ files:
111
134
  - spec/fixtures/key.json
112
135
  - spec/fixtures/keys.json
113
136
  - spec/fixtures/merge_request.json
137
+ - spec/fixtures/merge_request_comments.json
114
138
  - spec/fixtures/merge_requests.json
115
139
  - spec/fixtures/milestone.json
116
140
  - spec/fixtures/milestones.json
117
141
  - spec/fixtures/note.json
118
142
  - spec/fixtures/notes.json
119
143
  - spec/fixtures/project.json
120
- - spec/fixtures/project_branch.json
121
- - spec/fixtures/project_branches.json
144
+ - spec/fixtures/project_commit.json
145
+ - spec/fixtures/project_commit_diff.json
122
146
  - spec/fixtures/project_commits.json
123
147
  - spec/fixtures/project_delete_key.json
124
148
  - spec/fixtures/project_for_user.json
@@ -130,14 +154,21 @@ files:
130
154
  - spec/fixtures/project_keys.json
131
155
  - spec/fixtures/project_tags.json
132
156
  - spec/fixtures/projects.json
157
+ - spec/fixtures/protect_branch.json
133
158
  - spec/fixtures/session.json
134
159
  - spec/fixtures/snippet.json
135
160
  - spec/fixtures/snippets.json
161
+ - spec/fixtures/system_hook.json
162
+ - spec/fixtures/system_hook_test.json
163
+ - spec/fixtures/system_hooks.json
136
164
  - spec/fixtures/team_member.json
137
165
  - spec/fixtures/team_members.json
166
+ - spec/fixtures/unprotect_branch.json
138
167
  - spec/fixtures/update_merge_request.json
139
168
  - spec/fixtures/user.json
140
169
  - spec/fixtures/users.json
170
+ - spec/gitlab/cli_spec.rb
171
+ - spec/gitlab/client/branches_spec.rb
141
172
  - spec/gitlab/client/groups_spec.rb
142
173
  - spec/gitlab/client/issues_spec.rb
143
174
  - spec/gitlab/client/merge_requests_spec.rb
@@ -146,7 +177,10 @@ files:
146
177
  - spec/gitlab/client/projects_spec.rb
147
178
  - spec/gitlab/client/repositories_spec.rb
148
179
  - spec/gitlab/client/snippets_spec.rb
180
+ - spec/gitlab/client/system_hooks_spec.rb
149
181
  - spec/gitlab/client/users_spec.rb
182
+ - spec/gitlab/objectified_hash_spec.rb
183
+ - spec/gitlab/request_spec.rb
150
184
  - spec/gitlab_spec.rb
151
185
  - spec/spec_helper.rb
152
186
  homepage: https://github.com/narkoz/gitlab
@@ -158,22 +192,25 @@ require_paths:
158
192
  - lib
159
193
  required_ruby_version: !ruby/object:Gem::Requirement
160
194
  requirements:
161
- - - '>='
195
+ - - ">="
162
196
  - !ruby/object:Gem::Version
163
197
  version: '0'
164
198
  required_rubygems_version: !ruby/object:Gem::Requirement
165
199
  requirements:
166
- - - '>='
200
+ - - ">="
167
201
  - !ruby/object:Gem::Version
168
202
  version: '0'
169
203
  requirements: []
170
204
  rubyforge_project:
171
- rubygems_version: 2.1.7
205
+ rubygems_version: 2.2.2
172
206
  signing_key:
173
207
  specification_version: 4
174
- summary: A Ruby wrapper for the GitLab API
208
+ summary: A Ruby wrapper and CLI for the GitLab API
175
209
  test_files:
210
+ - spec/fixtures/branch.json
211
+ - spec/fixtures/branches.json
176
212
  - spec/fixtures/comment_merge_request.json
213
+ - spec/fixtures/create_branch.json
177
214
  - spec/fixtures/create_merge_request.json
178
215
  - spec/fixtures/error_already_exists.json
179
216
  - spec/fixtures/group.json
@@ -187,14 +224,15 @@ test_files:
187
224
  - spec/fixtures/key.json
188
225
  - spec/fixtures/keys.json
189
226
  - spec/fixtures/merge_request.json
227
+ - spec/fixtures/merge_request_comments.json
190
228
  - spec/fixtures/merge_requests.json
191
229
  - spec/fixtures/milestone.json
192
230
  - spec/fixtures/milestones.json
193
231
  - spec/fixtures/note.json
194
232
  - spec/fixtures/notes.json
195
233
  - spec/fixtures/project.json
196
- - spec/fixtures/project_branch.json
197
- - spec/fixtures/project_branches.json
234
+ - spec/fixtures/project_commit.json
235
+ - spec/fixtures/project_commit_diff.json
198
236
  - spec/fixtures/project_commits.json
199
237
  - spec/fixtures/project_delete_key.json
200
238
  - spec/fixtures/project_for_user.json
@@ -206,14 +244,21 @@ test_files:
206
244
  - spec/fixtures/project_keys.json
207
245
  - spec/fixtures/project_tags.json
208
246
  - spec/fixtures/projects.json
247
+ - spec/fixtures/protect_branch.json
209
248
  - spec/fixtures/session.json
210
249
  - spec/fixtures/snippet.json
211
250
  - spec/fixtures/snippets.json
251
+ - spec/fixtures/system_hook.json
252
+ - spec/fixtures/system_hook_test.json
253
+ - spec/fixtures/system_hooks.json
212
254
  - spec/fixtures/team_member.json
213
255
  - spec/fixtures/team_members.json
256
+ - spec/fixtures/unprotect_branch.json
214
257
  - spec/fixtures/update_merge_request.json
215
258
  - spec/fixtures/user.json
216
259
  - spec/fixtures/users.json
260
+ - spec/gitlab/cli_spec.rb
261
+ - spec/gitlab/client/branches_spec.rb
217
262
  - spec/gitlab/client/groups_spec.rb
218
263
  - spec/gitlab/client/issues_spec.rb
219
264
  - spec/gitlab/client/merge_requests_spec.rb
@@ -222,6 +267,9 @@ test_files:
222
267
  - spec/gitlab/client/projects_spec.rb
223
268
  - spec/gitlab/client/repositories_spec.rb
224
269
  - spec/gitlab/client/snippets_spec.rb
270
+ - spec/gitlab/client/system_hooks_spec.rb
225
271
  - spec/gitlab/client/users_spec.rb
272
+ - spec/gitlab/objectified_hash_spec.rb
273
+ - spec/gitlab/request_spec.rb
226
274
  - spec/gitlab_spec.rb
227
275
  - spec/spec_helper.rb