gitlab-ruby 0.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gitlab-ruby.gemspec +41 -0
- data/lib/gitlab/api/base.rb +17 -0
- data/lib/gitlab/api/issues.rb +32 -0
- data/lib/gitlab/client.rb +31 -0
- data/lib/gitlab/pagination.rb +31 -0
- data/lib/gitlab/response.rb +12 -0
- data/lib/gitlab/version.rb +3 -0
- data/lib/gitlab.rb +16 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bae0303d813deb88c096599308727f3f078b3b6c2f57de3546446f037ba1eba4
|
4
|
+
data.tar.gz: a4a9222fd8c8ac606ff47b082345f1f084cb8df5af0cf9ae38730b1bd17b7d7a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bfacc95fb95804577dfe04bb5c8b610278cd6dddd8eb398b8b79a47673f881dff0766118c25a93cb707a6be3b13998c1f51f627f0fab2958886f5e35ba00de23
|
7
|
+
data.tar.gz: ff14425d09ab5dc94ed2e77b3ff0a88869b7a312639c60dc961fbe8f9c903bae22368776791e0d1b3dc39c614aadc122948103af868f1c7353e527ad92e92fc8
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gitlab-ruby
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.1
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Taylor Scott
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Gitlab-Ruby
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gitlab/ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'gitlab-ruby'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install gitlab-ruby
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
#### Creating the client
|
26
|
+
```ruby
|
27
|
+
client = Gitlab::Client.new(private_token: 'secret')
|
28
|
+
response = client.issues.list
|
29
|
+
response.body.each do |issue|
|
30
|
+
# Do Something
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
#### Pagination
|
35
|
+
```ruby
|
36
|
+
loop do
|
37
|
+
page = 1
|
38
|
+
response = client.issues.list(page: 1)
|
39
|
+
response.body.each do |issue|
|
40
|
+
# Do Something
|
41
|
+
end
|
42
|
+
|
43
|
+
page = response.next_page
|
44
|
+
break if page.zero?
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
## Development
|
49
|
+
|
50
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
51
|
+
|
52
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
Bug reports and pull requests are welcome on GitHub at https://gitlab.com/skukx/gitlab-ruby.
|
57
|
+
|
58
|
+
|
59
|
+
## License
|
60
|
+
|
61
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gitlab"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/gitlab-ruby.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gitlab/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gitlab-ruby"
|
8
|
+
spec.version = Gitlab::VERSION
|
9
|
+
spec.authors = ["Taylor Scott"]
|
10
|
+
spec.email = ["tscott@deseretbook.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby client for GitLab API}
|
13
|
+
spec.description = %q{Ruby client for GitLab API}
|
14
|
+
spec.homepage = "https://gitlab.com/skukx/gitlab-ruby"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec"
|
36
|
+
spec.add_development_dependency "rubocop"
|
37
|
+
|
38
|
+
spec.add_dependency "activesupport"
|
39
|
+
spec.add_dependency "faraday"
|
40
|
+
spec.add_dependency "faraday_middleware"
|
41
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Gitlab
|
2
|
+
module Api
|
3
|
+
class Issues < Api::Base
|
4
|
+
PATH = 'issues'
|
5
|
+
|
6
|
+
def list(args = {})
|
7
|
+
response = connection.get(PATH, args)
|
8
|
+
handle_response(response)
|
9
|
+
end
|
10
|
+
|
11
|
+
def list_group(group, args = {})
|
12
|
+
response = connection.get(group_path(group), args)
|
13
|
+
handle_response(response)
|
14
|
+
end
|
15
|
+
|
16
|
+
def list_project(project, args = {})
|
17
|
+
response = connection.get(project_path(project), args)
|
18
|
+
handle_response(response)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def group_path(group)
|
24
|
+
"groups/#{group}/#{PATH}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def project_path(project)
|
28
|
+
"projects/#{project}/#{PATH}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Gitlab
|
2
|
+
class Client
|
3
|
+
attr_reader :connection
|
4
|
+
|
5
|
+
def self.api(name)
|
6
|
+
converted = name.to_s.classify.pluralize
|
7
|
+
klass = Gitlab::Api.const_get(converted)
|
8
|
+
define_method(name) { klass.new(connection) }
|
9
|
+
end
|
10
|
+
|
11
|
+
##
|
12
|
+
# Endpoint Definitions
|
13
|
+
#
|
14
|
+
api :issues
|
15
|
+
|
16
|
+
def initialize(private_token:, default_headers: {})
|
17
|
+
@private_token = private_token
|
18
|
+
@default_headers = default_headers.reverse_merge(
|
19
|
+
'PRIVATE-TOKEN': private_token
|
20
|
+
)
|
21
|
+
|
22
|
+
@connection = Faraday.new(url: API_URL) do |conn|
|
23
|
+
conn.headers = @default_headers
|
24
|
+
conn.request :json
|
25
|
+
conn.response :json
|
26
|
+
conn.response :logger
|
27
|
+
conn.adapter Faraday.default_adapter
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Gitlab
|
2
|
+
module Pagination
|
3
|
+
def current_page
|
4
|
+
headers['x-page'].to_i
|
5
|
+
end
|
6
|
+
|
7
|
+
def next_page
|
8
|
+
headers['x-next-page'].to_i
|
9
|
+
end
|
10
|
+
|
11
|
+
def prev_page
|
12
|
+
headers['x-prev-page'].to_i
|
13
|
+
end
|
14
|
+
|
15
|
+
def total_results
|
16
|
+
headers['x-total'].to_i
|
17
|
+
end
|
18
|
+
|
19
|
+
def total_pages
|
20
|
+
headers['x-total-pages'].to_i
|
21
|
+
end
|
22
|
+
|
23
|
+
def results_per_page
|
24
|
+
headers['x-per-page'].to_i
|
25
|
+
end
|
26
|
+
|
27
|
+
def request_next_page
|
28
|
+
raise NotMethodError
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/gitlab.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'active_support/hash_with_indifferent_access'
|
2
|
+
require 'active_support/inflector'
|
3
|
+
require 'faraday'
|
4
|
+
require 'faraday_middleware'
|
5
|
+
|
6
|
+
require 'gitlab/version'
|
7
|
+
require 'gitlab/pagination'
|
8
|
+
require 'gitlab/response'
|
9
|
+
|
10
|
+
require 'gitlab/api/base'
|
11
|
+
require 'gitlab/api/issues'
|
12
|
+
require 'gitlab/client'
|
13
|
+
|
14
|
+
module Gitlab
|
15
|
+
API_URL = 'https://gitlab.com/api/v4/'.freeze
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitlab-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Taylor Scott
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: faraday
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: faraday_middleware
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Ruby client for GitLab API
|
112
|
+
email:
|
113
|
+
- tscott@deseretbook.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".ruby-gemset"
|
121
|
+
- ".ruby-version"
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/console
|
127
|
+
- bin/setup
|
128
|
+
- gitlab-ruby.gemspec
|
129
|
+
- lib/gitlab.rb
|
130
|
+
- lib/gitlab/api/base.rb
|
131
|
+
- lib/gitlab/api/issues.rb
|
132
|
+
- lib/gitlab/client.rb
|
133
|
+
- lib/gitlab/pagination.rb
|
134
|
+
- lib/gitlab/response.rb
|
135
|
+
- lib/gitlab/version.rb
|
136
|
+
homepage: https://gitlab.com/skukx/gitlab-ruby
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
metadata:
|
140
|
+
allowed_push_host: https://rubygems.org
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">"
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: 1.3.1
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.7.6
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Ruby client for GitLab API
|
161
|
+
test_files: []
|