velocity_client_ruby 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile.lock +17 -1
- data/lib/velocity.rb +12 -0
- data/lib/velocity/api.rb +50 -0
- data/lib/velocity/contributor.rb +21 -0
- data/lib/velocity/version.rb +1 -1
- data/velocity_client_ruby.gemspec +4 -0
- metadata +50 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d19bcb60384a513c3b9dfb281561ebb20c542b2214054fe772ce2f01a6428b7
|
4
|
+
data.tar.gz: 89bfb6eecb38e4f16f7fea763e6432cfe2b6fbc4861cb5c8174ff03347d88cbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd1b2fef572887c31d1da03f9c15b431cbacf8eec9ded21dc8ea8eed95b7a244bbe8fd600fa313ed086bc006ca977c312d7af77f2f96eaee74db68fcc048daab
|
7
|
+
data.tar.gz: fda714153251af698e126e73109433c0bd47cc98669a2c1e925466baac21f9944746b736eb154ba5d7b43f0af2ec195fe0c860c70d00113df9a97d634061e72b
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,27 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
velocity_client_ruby (0.1.
|
4
|
+
velocity_client_ruby (0.1.1)
|
5
|
+
dotenv (~> 2.7)
|
6
|
+
httparty (~> 0.18)
|
5
7
|
|
6
8
|
GEM
|
7
9
|
remote: https://rubygems.org/
|
8
10
|
specs:
|
11
|
+
coderay (1.1.3)
|
9
12
|
diff-lcs (1.4.4)
|
13
|
+
dotenv (2.7.6)
|
14
|
+
httparty (0.18.1)
|
15
|
+
mime-types (~> 3.0)
|
16
|
+
multi_xml (>= 0.5.2)
|
17
|
+
method_source (1.0.0)
|
18
|
+
mime-types (3.3.1)
|
19
|
+
mime-types-data (~> 3.2015)
|
20
|
+
mime-types-data (3.2021.0704)
|
21
|
+
multi_xml (0.6.0)
|
22
|
+
pry (0.14.1)
|
23
|
+
coderay (~> 1.1)
|
24
|
+
method_source (~> 1.0)
|
10
25
|
rake (10.5.0)
|
11
26
|
rspec (3.10.0)
|
12
27
|
rspec-core (~> 3.10.0)
|
@@ -27,6 +42,7 @@ PLATFORMS
|
|
27
42
|
|
28
43
|
DEPENDENCIES
|
29
44
|
bundler (~> 1.17)
|
45
|
+
pry (~> 0.14)
|
30
46
|
rake (~> 10.0)
|
31
47
|
rspec (~> 3.0)
|
32
48
|
velocity_client_ruby!
|
data/lib/velocity.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require "velocity/api"
|
2
|
+
require "velocity/contributor"
|
3
|
+
require "dotenv/load"
|
4
|
+
|
1
5
|
module Velocity
|
2
6
|
class << self
|
3
7
|
attr_accessor :configuration
|
@@ -6,9 +10,17 @@ module Velocity
|
|
6
10
|
@configuration ||= Configuration.new
|
7
11
|
yield(configuration)
|
8
12
|
end
|
13
|
+
|
14
|
+
def configuration
|
15
|
+
@configuration ||= Configuration.new
|
16
|
+
end
|
9
17
|
end
|
10
18
|
|
11
19
|
class Configuration
|
12
20
|
attr_accessor :api_token
|
21
|
+
|
22
|
+
def api_token
|
23
|
+
@api_token || ENV["VELOCITY_API_TOKEN"]
|
24
|
+
end
|
13
25
|
end
|
14
26
|
end
|
data/lib/velocity/api.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Velocity
|
4
|
+
class Api
|
5
|
+
class NotFoundError < StandardError; end
|
6
|
+
class UnauthorizedError < StandardError; end
|
7
|
+
class InternalServerError < StandardError; end
|
8
|
+
class BadRequestError < StandardError; end
|
9
|
+
|
10
|
+
include HTTParty
|
11
|
+
|
12
|
+
base_uri "https://api.velocity.codeclimate.com/v1"
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@options = {
|
16
|
+
headers: {
|
17
|
+
authorization: "Bearer #{Velocity.configuration.api_token}"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def fetch_contributors(args)
|
23
|
+
parse_response(self.class.get("/people", @options.merge({
|
24
|
+
query: build_query_attributes(args)
|
25
|
+
})))
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse_response(response)
|
29
|
+
case response.code
|
30
|
+
when 200
|
31
|
+
JSON.parse(response.body)["data"]
|
32
|
+
when 400
|
33
|
+
errors = JSON.parse(response.body)["errors"]
|
34
|
+
raise BadRequestError.new(errors.first["title"] + ": " + errors.first["detail"])
|
35
|
+
when 401
|
36
|
+
raise UnauthorizedError.new("401 Unauthorized");
|
37
|
+
when 404
|
38
|
+
raise NotFoundError.new("404 not found error");
|
39
|
+
else
|
40
|
+
raise InternalServerError.new("#{response.code} something went wrong: #{response.body}")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def build_query_attributes(args)
|
45
|
+
args.map do |key, value|
|
46
|
+
"filter[#{key.to_s}][eq]=#{value}"
|
47
|
+
end.join("&")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Velocity
|
2
|
+
class Contributor
|
3
|
+
attr_accessor :id, :name, :email
|
4
|
+
|
5
|
+
def initialize(id:, email:, name:)
|
6
|
+
@id = id
|
7
|
+
@email = email
|
8
|
+
@name = name
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.where(args)
|
12
|
+
perform_request(args).map do |contributor|
|
13
|
+
new(id: contributor["id"], name: contributor["attributes"]["name"], email: contributor["attributes"]["email"])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.perform_request(args = {})
|
18
|
+
Velocity::Api.new.fetch_contributors(args)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/velocity/version.rb
CHANGED
@@ -36,4 +36,8 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_development_dependency "bundler", "~> 1.17"
|
37
37
|
spec.add_development_dependency "rake", "~> 10.0"
|
38
38
|
spec.add_development_dependency "rspec", "~> 3.0"
|
39
|
+
spec.add_development_dependency "pry", "~> 0.14"
|
40
|
+
|
41
|
+
spec.add_dependency "httparty", "~> 0.18"
|
42
|
+
spec.add_dependency "dotenv", "~>2.7"
|
39
43
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: velocity_client_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Antoniazzi
|
8
8
|
- Vera Protopopova
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-08-
|
12
|
+
date: 2021-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -53,6 +53,48 @@ dependencies:
|
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '3.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: pry
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.14'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.14'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: httparty
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.18'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.18'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: dotenv
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '2.7'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '2.7'
|
56
98
|
description: Interact with Velocity Teams API
|
57
99
|
email:
|
58
100
|
- vgsantoniazzi@gmail.com
|
@@ -71,6 +113,8 @@ files:
|
|
71
113
|
- bin/console
|
72
114
|
- bin/setup
|
73
115
|
- lib/velocity.rb
|
116
|
+
- lib/velocity/api.rb
|
117
|
+
- lib/velocity/contributor.rb
|
74
118
|
- lib/velocity/version.rb
|
75
119
|
- velocity_client_ruby.gemspec
|
76
120
|
homepage: http://velocity.codeclimate.com
|
@@ -79,7 +123,7 @@ licenses:
|
|
79
123
|
metadata:
|
80
124
|
homepage_uri: http://velocity.codeclimate.com
|
81
125
|
source_code_uri: https://github.com/codeclimate/velocity-client-ruby
|
82
|
-
post_install_message:
|
126
|
+
post_install_message:
|
83
127
|
rdoc_options: []
|
84
128
|
require_paths:
|
85
129
|
- lib
|
@@ -94,8 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
138
|
- !ruby/object:Gem::Version
|
95
139
|
version: '0'
|
96
140
|
requirements: []
|
97
|
-
rubygems_version: 3.0.
|
98
|
-
signing_key:
|
141
|
+
rubygems_version: 3.0.6
|
142
|
+
signing_key:
|
99
143
|
specification_version: 4
|
100
144
|
summary: Ruby Gem to interact with Velocity Teams API
|
101
145
|
test_files: []
|