gitlab 2.0.0

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 (51) hide show
  1. data/.gitignore +17 -0
  2. data/.travis.yml +2 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +24 -0
  5. data/README.md +64 -0
  6. data/Rakefile +9 -0
  7. data/gitlab.gemspec +25 -0
  8. data/lib/gitlab.rb +29 -0
  9. data/lib/gitlab/api.rb +17 -0
  10. data/lib/gitlab/client.rb +13 -0
  11. data/lib/gitlab/client/issues.rb +69 -0
  12. data/lib/gitlab/client/milestones.rb +59 -0
  13. data/lib/gitlab/client/projects.rb +155 -0
  14. data/lib/gitlab/client/repositories.rb +67 -0
  15. data/lib/gitlab/client/snippets.rb +64 -0
  16. data/lib/gitlab/client/users.rb +89 -0
  17. data/lib/gitlab/configuration.rb +38 -0
  18. data/lib/gitlab/error.rb +33 -0
  19. data/lib/gitlab/objectified_hash.rb +18 -0
  20. data/lib/gitlab/request.rb +73 -0
  21. data/lib/gitlab/version.rb +3 -0
  22. data/spec/fixtures/issue.json +1 -0
  23. data/spec/fixtures/issues.json +1 -0
  24. data/spec/fixtures/key.json +1 -0
  25. data/spec/fixtures/keys.json +1 -0
  26. data/spec/fixtures/milestone.json +1 -0
  27. data/spec/fixtures/milestones.json +1 -0
  28. data/spec/fixtures/project.json +1 -0
  29. data/spec/fixtures/project_branch.json +1 -0
  30. data/spec/fixtures/project_branches.json +1 -0
  31. data/spec/fixtures/project_commits.json +1 -0
  32. data/spec/fixtures/project_hook.json +1 -0
  33. data/spec/fixtures/project_hooks.json +1 -0
  34. data/spec/fixtures/project_issues.json +1 -0
  35. data/spec/fixtures/project_tags.json +1 -0
  36. data/spec/fixtures/projects.json +1 -0
  37. data/spec/fixtures/session.json +1 -0
  38. data/spec/fixtures/snippet.json +1 -0
  39. data/spec/fixtures/team_member.json +1 -0
  40. data/spec/fixtures/team_members.json +1 -0
  41. data/spec/fixtures/user.json +1 -0
  42. data/spec/fixtures/users.json +1 -0
  43. data/spec/gitlab/client/issues_spec.rb +88 -0
  44. data/spec/gitlab/client/milestones_spec.rb +66 -0
  45. data/spec/gitlab/client/projects_spec.rb +177 -0
  46. data/spec/gitlab/client/repositories_spec.rb +73 -0
  47. data/spec/gitlab/client/snippets_spec.rb +69 -0
  48. data/spec/gitlab/client/users_spec.rb +129 -0
  49. data/spec/gitlab_spec.rb +49 -0
  50. data/spec/spec_helper.rb +63 -0
  51. metadata +194 -0
@@ -0,0 +1,129 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".users" do
5
+ before do
6
+ stub_get("/users", "users")
7
+ @users = Gitlab.users
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ a_get("/users").should have_been_made
12
+ end
13
+
14
+ it "should return an array of users" do
15
+ @users.should be_an Array
16
+ @users.first.email.should == "john@example.com"
17
+ end
18
+ end
19
+
20
+ describe ".user" do
21
+ context "with user ID passed" do
22
+ before do
23
+ stub_get("/users/1", "user")
24
+ @user = Gitlab.user(1)
25
+ end
26
+
27
+ it "should get the correct resource" do
28
+ a_get("/users/1").should have_been_made
29
+ end
30
+
31
+ it "should return information about a user" do
32
+ @user.email.should == "john@example.com"
33
+ end
34
+ end
35
+
36
+ context "without user ID passed" do
37
+ before do
38
+ stub_get("/user", "user")
39
+ @user = Gitlab.user
40
+ end
41
+
42
+ it "should get the correct resource" do
43
+ a_get("/user").should have_been_made
44
+ end
45
+
46
+ it "should return information about an authorized user" do
47
+ @user.email.should == "john@example.com"
48
+ end
49
+ end
50
+ end
51
+
52
+ describe ".session" do
53
+ before do
54
+ stub_post("/session", "session")
55
+ @session = Gitlab.session("email", "pass")
56
+ end
57
+
58
+ it "should get the correct resource" do
59
+ a_post("/session").should have_been_made
60
+ end
61
+
62
+ it "should return information about a created session" do
63
+ @session.email.should == "john@example.com"
64
+ @session.private_token.should == "qEsq1pt6HJPaNciie3MG"
65
+ end
66
+ end
67
+
68
+ describe ".ssh_keys" do
69
+ before do
70
+ stub_get("/user/keys", "keys")
71
+ @keys = Gitlab.ssh_keys
72
+ end
73
+
74
+ it "should get the correct resource" do
75
+ a_get("/user/keys").should have_been_made
76
+ end
77
+
78
+ it "should return an array of SSH keys" do
79
+ @keys.should be_an Array
80
+ @keys.first.title.should == "narkoz@helium"
81
+ end
82
+ end
83
+
84
+ describe ".ssh_key" do
85
+ before do
86
+ stub_get("/user/keys/1", "key")
87
+ @key = Gitlab.ssh_key(1)
88
+ end
89
+
90
+ it "should get the correct resource" do
91
+ a_get("/user/keys/1").should have_been_made
92
+ end
93
+
94
+ it "should return information about an SSH key" do
95
+ @key.title.should == "narkoz@helium"
96
+ end
97
+ end
98
+
99
+ describe ".create_ssh_key" do
100
+ before do
101
+ stub_post("/user/keys", "key")
102
+ @key = Gitlab.create_ssh_key('title', 'body')
103
+ end
104
+
105
+ it "should get the correct resource" do
106
+ body = {:title => 'title', :key => 'body'}
107
+ a_post("/user/keys").with(:body => body).should have_been_made
108
+ end
109
+
110
+ it "should return information about a created SSH key" do
111
+ @key.title.should == "narkoz@helium"
112
+ end
113
+ end
114
+
115
+ describe ".delete_ssh_key" do
116
+ before do
117
+ stub_delete("/user/keys/1", "key")
118
+ @key = Gitlab.delete_ssh_key(1)
119
+ end
120
+
121
+ it "should get the correct resource" do
122
+ a_delete("/user/keys/1").should have_been_made
123
+ end
124
+
125
+ it "should return information about a deleted SSH key" do
126
+ @key.title.should == "narkoz@helium"
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab do
4
+ after { Gitlab.reset }
5
+
6
+ describe ".client" do
7
+ it "should be a Gitlab::Client" do
8
+ Gitlab.client.should be_a Gitlab::Client
9
+ end
10
+ end
11
+
12
+ describe ".endpoint=" do
13
+ it "should set endpoint" do
14
+ Gitlab.endpoint = 'https://api.example.com'
15
+ Gitlab.endpoint.should == 'https://api.example.com'
16
+ end
17
+ end
18
+
19
+ describe ".private_token=" do
20
+ it "should set private_token" do
21
+ Gitlab.private_token = 'secret'
22
+ Gitlab.private_token.should == 'secret'
23
+ end
24
+ end
25
+
26
+ describe ".user_agent" do
27
+ it "should return default user_agent" do
28
+ Gitlab.user_agent.should == Gitlab::Configuration::DEFAULT_USER_AGENT
29
+ end
30
+ end
31
+
32
+ describe ".user_agent=" do
33
+ it "should set user_agent" do
34
+ Gitlab.user_agent = 'Custom User Agent'
35
+ Gitlab.user_agent.should == 'Custom User Agent'
36
+ end
37
+ end
38
+
39
+ describe ".configure" do
40
+ Gitlab::Configuration::VALID_OPTIONS_KEYS.each do |key|
41
+ it "should set #{key}" do
42
+ Gitlab.configure do |config|
43
+ config.send("#{key}=", key)
44
+ Gitlab.send(key).should == key
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,63 @@
1
+ require 'rspec'
2
+ require 'webmock/rspec'
3
+
4
+ require File.expand_path('../../lib/gitlab', __FILE__)
5
+
6
+ def load_fixture(name)
7
+ File.new(File.dirname(__FILE__) + "/fixtures/#{name}.json")
8
+ end
9
+
10
+ RSpec.configure do |config|
11
+ config.before(:all) do
12
+ Gitlab.endpoint = 'https://api.example.com'
13
+ Gitlab.private_token = 'secret'
14
+ end
15
+ end
16
+
17
+ # GET
18
+ def stub_get(path, fixture)
19
+ stub_request(:get, "#{Gitlab.endpoint}#{path}").
20
+ with(:query => {:private_token => Gitlab.private_token}).
21
+ to_return(:body => load_fixture(fixture))
22
+ end
23
+
24
+ def a_get(path)
25
+ a_request(:get, "#{Gitlab.endpoint}#{path}").
26
+ with(:query => {:private_token => Gitlab.private_token})
27
+ end
28
+
29
+ # POST
30
+ def stub_post(path, fixture)
31
+ stub_request(:post, "#{Gitlab.endpoint}#{path}").
32
+ with(:query => {:private_token => Gitlab.private_token}).
33
+ to_return(:body => load_fixture(fixture))
34
+ end
35
+
36
+ def a_post(path)
37
+ a_request(:post, "#{Gitlab.endpoint}#{path}").
38
+ with(:query => {:private_token => Gitlab.private_token})
39
+ end
40
+
41
+ # PUT
42
+ def stub_put(path, fixture)
43
+ stub_request(:put, "#{Gitlab.endpoint}#{path}").
44
+ with(:query => {:private_token => Gitlab.private_token}).
45
+ to_return(:body => load_fixture(fixture))
46
+ end
47
+
48
+ def a_put(path)
49
+ a_request(:put, "#{Gitlab.endpoint}#{path}").
50
+ with(:query => {:private_token => Gitlab.private_token})
51
+ end
52
+
53
+ # DELETE
54
+ def stub_delete(path, fixture)
55
+ stub_request(:delete, "#{Gitlab.endpoint}#{path}").
56
+ with(:query => {:private_token => Gitlab.private_token}).
57
+ to_return(:body => load_fixture(fixture))
58
+ end
59
+
60
+ def a_delete(path)
61
+ a_request(:delete, "#{Gitlab.endpoint}#{path}").
62
+ with(:query => {:private_token => Gitlab.private_token})
63
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitlab
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nihad Abbasov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: webmock
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Ruby client for GitLab API
79
+ email:
80
+ - mail@narkoz.me
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - .travis.yml
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - gitlab.gemspec
92
+ - lib/gitlab.rb
93
+ - lib/gitlab/api.rb
94
+ - lib/gitlab/client.rb
95
+ - lib/gitlab/client/issues.rb
96
+ - lib/gitlab/client/milestones.rb
97
+ - lib/gitlab/client/projects.rb
98
+ - lib/gitlab/client/repositories.rb
99
+ - lib/gitlab/client/snippets.rb
100
+ - lib/gitlab/client/users.rb
101
+ - lib/gitlab/configuration.rb
102
+ - lib/gitlab/error.rb
103
+ - lib/gitlab/objectified_hash.rb
104
+ - lib/gitlab/request.rb
105
+ - lib/gitlab/version.rb
106
+ - spec/fixtures/issue.json
107
+ - spec/fixtures/issues.json
108
+ - spec/fixtures/key.json
109
+ - spec/fixtures/keys.json
110
+ - spec/fixtures/milestone.json
111
+ - spec/fixtures/milestones.json
112
+ - spec/fixtures/project.json
113
+ - spec/fixtures/project_branch.json
114
+ - spec/fixtures/project_branches.json
115
+ - spec/fixtures/project_commits.json
116
+ - spec/fixtures/project_hook.json
117
+ - spec/fixtures/project_hooks.json
118
+ - spec/fixtures/project_issues.json
119
+ - spec/fixtures/project_tags.json
120
+ - spec/fixtures/projects.json
121
+ - spec/fixtures/session.json
122
+ - spec/fixtures/snippet.json
123
+ - spec/fixtures/team_member.json
124
+ - spec/fixtures/team_members.json
125
+ - spec/fixtures/user.json
126
+ - spec/fixtures/users.json
127
+ - spec/gitlab/client/issues_spec.rb
128
+ - spec/gitlab/client/milestones_spec.rb
129
+ - spec/gitlab/client/projects_spec.rb
130
+ - spec/gitlab/client/repositories_spec.rb
131
+ - spec/gitlab/client/snippets_spec.rb
132
+ - spec/gitlab/client/users_spec.rb
133
+ - spec/gitlab_spec.rb
134
+ - spec/spec_helper.rb
135
+ homepage: https://github.com/narkoz/gitlab
136
+ licenses: []
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ segments:
148
+ - 0
149
+ hash: -751626136500933347
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ segments:
157
+ - 0
158
+ hash: -751626136500933347
159
+ requirements: []
160
+ rubyforge_project:
161
+ rubygems_version: 1.8.24
162
+ signing_key:
163
+ specification_version: 3
164
+ summary: A Ruby wrapper for the GitLab API
165
+ test_files:
166
+ - spec/fixtures/issue.json
167
+ - spec/fixtures/issues.json
168
+ - spec/fixtures/key.json
169
+ - spec/fixtures/keys.json
170
+ - spec/fixtures/milestone.json
171
+ - spec/fixtures/milestones.json
172
+ - spec/fixtures/project.json
173
+ - spec/fixtures/project_branch.json
174
+ - spec/fixtures/project_branches.json
175
+ - spec/fixtures/project_commits.json
176
+ - spec/fixtures/project_hook.json
177
+ - spec/fixtures/project_hooks.json
178
+ - spec/fixtures/project_issues.json
179
+ - spec/fixtures/project_tags.json
180
+ - spec/fixtures/projects.json
181
+ - spec/fixtures/session.json
182
+ - spec/fixtures/snippet.json
183
+ - spec/fixtures/team_member.json
184
+ - spec/fixtures/team_members.json
185
+ - spec/fixtures/user.json
186
+ - spec/fixtures/users.json
187
+ - spec/gitlab/client/issues_spec.rb
188
+ - spec/gitlab/client/milestones_spec.rb
189
+ - spec/gitlab/client/projects_spec.rb
190
+ - spec/gitlab/client/repositories_spec.rb
191
+ - spec/gitlab/client/snippets_spec.rb
192
+ - spec/gitlab/client/users_spec.rb
193
+ - spec/gitlab_spec.rb
194
+ - spec/spec_helper.rb