cirro-ruby-client 0.1.0 → 0.1.2
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/.circleci/config.yml +66 -0
- data/.circleci/gem_credentials +2 -0
- data/.rubocop.yml +118 -0
- data/Gemfile +10 -3
- data/Gemfile.lock +73 -1
- data/README.md +14 -15
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/cirro-ruby-client.gemspec +18 -15
- data/lib/cirro_io/client.rb +22 -0
- data/lib/cirro_io/client/app_worker.rb +9 -0
- data/lib/cirro_io/client/base.rb +20 -0
- data/lib/cirro_io/client/configuration.rb +30 -0
- data/lib/cirro_io/client/jwt_authentication.rb +25 -0
- data/lib/cirro_io/client/response_debugging_middleware.rb +10 -0
- data/lib/cirro_io/client/version.rb +7 -0
- metadata +41 -5
- data/lib/cirro_i_o/client.rb +0 -8
- data/lib/cirro_i_o/client/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90ef4e3b2eec3a5746f2592a6c201860d475ecc821206b699dafdd8a6ac12cd5
|
4
|
+
data.tar.gz: 5d4ecb0ea0c6e2a59505b46ac765e44e57a5e508ea3f355d7748887bd3ea1262
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4d3bff833b2204df8a8c6af7b54e6b61cdd849262aea8dac29870b22d397ad8915aeb50c36b7e186bec433f5aa68999bec673a8071d9f930d785a5a960e40d8
|
7
|
+
data.tar.gz: 7bbef31c78ba734ac45adccd83b0d7785aedc6f09d405b8e7e2850398bfc4951caeef07ae64c02d66d596b11421cb4a30f2e85f732f7ba5db872a8f4534833e0
|
@@ -0,0 +1,66 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
jobs:
|
4
|
+
build:
|
5
|
+
docker:
|
6
|
+
- image: circleci/ruby:2.7.1-node
|
7
|
+
environment:
|
8
|
+
- RAILS_ENV=test
|
9
|
+
- RACK_ENV=test
|
10
|
+
steps:
|
11
|
+
- checkout
|
12
|
+
- restore_cache:
|
13
|
+
keys:
|
14
|
+
- bundle-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
|
15
|
+
- run:
|
16
|
+
name: Install gems
|
17
|
+
command: bundle install --path ~/.cache/bundle
|
18
|
+
- save_cache:
|
19
|
+
key: bundle-{{.Branch}}-{{ checksum "Gemfile.lock" }}
|
20
|
+
paths:
|
21
|
+
- ~/.cache/bundle
|
22
|
+
- run:
|
23
|
+
name: Run tests
|
24
|
+
command: bundle exec rspec
|
25
|
+
- run:
|
26
|
+
name: Check code style
|
27
|
+
command: bundle exec rubocop
|
28
|
+
deploy:
|
29
|
+
docker:
|
30
|
+
- image: circleci/ruby:2.7.1-node
|
31
|
+
steps:
|
32
|
+
- checkout
|
33
|
+
- run:
|
34
|
+
name: Tag the version
|
35
|
+
command: |
|
36
|
+
git fetch --tags
|
37
|
+
version=$(cat lib/cirro_io/client/version.rb | grep VERSION | awk -F' = ' '{print $2}' | xargs)
|
38
|
+
if git rev-parse v"$version" >/dev/null 2>&1; then
|
39
|
+
echo "This version already exists. Please update the version";
|
40
|
+
exit 1
|
41
|
+
else
|
42
|
+
git tag v"$version"
|
43
|
+
git push origin v"$version"
|
44
|
+
fi
|
45
|
+
- run:
|
46
|
+
name: build gem
|
47
|
+
command: gem build cirro-ruby-client.gemspec
|
48
|
+
- run:
|
49
|
+
name: push to rubygems
|
50
|
+
command: |
|
51
|
+
version=$(cat lib/cirro_io/client/version.rb | grep VERSION | awk -F' = ' '{print $2}' | xargs)
|
52
|
+
echo "gem `gem --version`"
|
53
|
+
mkdir ~/.gem
|
54
|
+
cat .circleci/gem_credentials | sed -e "s/__RUBYGEMS_API_KEY__/${RUBYGEMS_API_KEY}/" > ~/.gem/credentials
|
55
|
+
chmod 0600 ~/.gem/credentials
|
56
|
+
gem push cirro-ruby-client-$version.gem
|
57
|
+
shred -u ~/.gem/credentials
|
58
|
+
|
59
|
+
workflows:
|
60
|
+
version: 2
|
61
|
+
deploy_the_gem:
|
62
|
+
jobs:
|
63
|
+
- build
|
64
|
+
- deploy:
|
65
|
+
requires:
|
66
|
+
- build
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rspec
|
3
|
+
# Explanations of all possible options:
|
4
|
+
# https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
5
|
+
AllCops:
|
6
|
+
DisplayCopNames: true
|
7
|
+
DisplayStyleGuide: true
|
8
|
+
Exclude:
|
9
|
+
- 'pkg/**/*'
|
10
|
+
- 'vendor/**/*'
|
11
|
+
- 'spec/fixtures/**/*'
|
12
|
+
|
13
|
+
Metrics/MethodLength:
|
14
|
+
Max: 25
|
15
|
+
|
16
|
+
Layout/LineLength:
|
17
|
+
Max: 160
|
18
|
+
|
19
|
+
# Details:
|
20
|
+
# http://c2.com/cgi/wiki?AbcMetric
|
21
|
+
Metrics/AbcSize:
|
22
|
+
# The ABC size is a calculated magnitude, so this number can be a Fixnum or
|
23
|
+
# a Float.
|
24
|
+
Max: 20
|
25
|
+
|
26
|
+
Style/StringLiterals:
|
27
|
+
EnforcedStyle: single_quotes
|
28
|
+
|
29
|
+
Style/HashSyntax:
|
30
|
+
EnforcedStyle: ruby19
|
31
|
+
|
32
|
+
Style/NumericLiterals:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Style/SignalException:
|
36
|
+
EnforcedStyle: only_raise
|
37
|
+
|
38
|
+
Metrics/ClassLength:
|
39
|
+
Max: 120
|
40
|
+
|
41
|
+
# TODO: enable this when Ruby 3.0 is out.
|
42
|
+
Style/FrozenStringLiteralComment:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Layout/FirstArrayElementIndentation:
|
46
|
+
EnforcedStyle: consistent
|
47
|
+
|
48
|
+
Style/NumericPredicate:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
Naming/VariableNumber:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
Style/SafeNavigation:
|
55
|
+
Enabled: false
|
56
|
+
|
57
|
+
Metrics/BlockLength:
|
58
|
+
CountComments: false
|
59
|
+
Max: 25
|
60
|
+
Exclude:
|
61
|
+
- 'Rakefile'
|
62
|
+
- '**/*.rake'
|
63
|
+
- 'spec/**/*.rb'
|
64
|
+
|
65
|
+
Layout/HeredocIndentation:
|
66
|
+
Enabled: false
|
67
|
+
|
68
|
+
Gemspec/OrderedDependencies:
|
69
|
+
Enabled: false
|
70
|
+
|
71
|
+
Style/FormatStringToken:
|
72
|
+
Enabled: false
|
73
|
+
|
74
|
+
Naming/MethodParameterName:
|
75
|
+
Enabled: false
|
76
|
+
|
77
|
+
Gemspec/RequiredRubyVersion:
|
78
|
+
Enabled: false
|
79
|
+
|
80
|
+
Style/TrailingCommaInArguments:
|
81
|
+
EnforcedStyleForMultiline: comma
|
82
|
+
|
83
|
+
Style/TrailingCommaInArrayLiteral:
|
84
|
+
EnforcedStyleForMultiline: comma
|
85
|
+
|
86
|
+
Style/TrailingCommaInHashLiteral:
|
87
|
+
EnforcedStyleForMultiline: comma
|
88
|
+
|
89
|
+
Naming/RescuedExceptionsVariableName:
|
90
|
+
Enabled: false
|
91
|
+
|
92
|
+
Lint/RaiseException:
|
93
|
+
Enabled: true
|
94
|
+
|
95
|
+
Lint/StructNewOverride:
|
96
|
+
Enabled: true
|
97
|
+
|
98
|
+
Style/HashEachMethods:
|
99
|
+
Enabled: true
|
100
|
+
|
101
|
+
Style/HashTransformKeys:
|
102
|
+
Enabled: true
|
103
|
+
|
104
|
+
Style/HashTransformValues:
|
105
|
+
Enabled: true
|
106
|
+
|
107
|
+
RSpec/FilePath:
|
108
|
+
Enabled: true
|
109
|
+
IgnoreMethods: true
|
110
|
+
|
111
|
+
Style/Documentation:
|
112
|
+
Enabled: false
|
113
|
+
|
114
|
+
RSpec/ExampleLength:
|
115
|
+
Enabled: false
|
116
|
+
|
117
|
+
RSpec/MultipleExpectations:
|
118
|
+
Enabled: false
|
data/Gemfile
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in cirro-ruby-client.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem
|
7
|
-
gem
|
6
|
+
gem 'rake', '~> 12.0'
|
7
|
+
gem 'rspec', '~> 3.0'
|
8
|
+
|
9
|
+
group :development do
|
10
|
+
gem 'pry'
|
11
|
+
gem 'rubocop', require: false
|
12
|
+
gem 'rubocop-rspec'
|
13
|
+
gem 'webmock'
|
14
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,58 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cirro-ruby-client (0.1.
|
4
|
+
cirro-ruby-client (0.1.2)
|
5
|
+
json_api_client
|
6
|
+
jwt
|
5
7
|
|
6
8
|
GEM
|
7
9
|
remote: https://rubygems.org/
|
8
10
|
specs:
|
11
|
+
activemodel (6.0.3.3)
|
12
|
+
activesupport (= 6.0.3.3)
|
13
|
+
activesupport (6.0.3.3)
|
14
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
+
i18n (>= 0.7, < 2)
|
16
|
+
minitest (~> 5.1)
|
17
|
+
tzinfo (~> 1.1)
|
18
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
19
|
+
addressable (2.7.0)
|
20
|
+
public_suffix (>= 2.0.2, < 5.0)
|
21
|
+
ast (2.4.1)
|
22
|
+
coderay (1.1.3)
|
23
|
+
concurrent-ruby (1.1.7)
|
24
|
+
crack (0.4.4)
|
9
25
|
diff-lcs (1.4.4)
|
26
|
+
faraday (1.0.1)
|
27
|
+
multipart-post (>= 1.2, < 3)
|
28
|
+
faraday_middleware (1.0.0)
|
29
|
+
faraday (~> 1.0)
|
30
|
+
hashdiff (1.0.1)
|
31
|
+
i18n (1.8.5)
|
32
|
+
concurrent-ruby (~> 1.0)
|
33
|
+
json_api_client (1.17.1)
|
34
|
+
activemodel (>= 3.2.0)
|
35
|
+
activesupport (>= 3.2.0)
|
36
|
+
addressable (~> 2.2)
|
37
|
+
faraday (>= 0.15.2, < 1.2.0)
|
38
|
+
faraday_middleware (>= 0.9.0, < 1.2.0)
|
39
|
+
rack (>= 0.2)
|
40
|
+
jwt (2.2.2)
|
41
|
+
method_source (1.0.0)
|
42
|
+
minitest (5.14.2)
|
43
|
+
multipart-post (2.1.1)
|
44
|
+
parallel (1.19.2)
|
45
|
+
parser (2.7.2.0)
|
46
|
+
ast (~> 2.4.1)
|
47
|
+
pry (0.13.1)
|
48
|
+
coderay (~> 1.1)
|
49
|
+
method_source (~> 1.0)
|
50
|
+
public_suffix (4.0.6)
|
51
|
+
rack (2.2.3)
|
52
|
+
rainbow (3.0.0)
|
10
53
|
rake (12.3.3)
|
54
|
+
regexp_parser (1.8.1)
|
55
|
+
rexml (3.2.4)
|
11
56
|
rspec (3.9.0)
|
12
57
|
rspec-core (~> 3.9.0)
|
13
58
|
rspec-expectations (~> 3.9.0)
|
@@ -21,14 +66,41 @@ GEM
|
|
21
66
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
67
|
rspec-support (~> 3.9.0)
|
23
68
|
rspec-support (3.9.3)
|
69
|
+
rubocop (0.92.0)
|
70
|
+
parallel (~> 1.10)
|
71
|
+
parser (>= 2.7.1.5)
|
72
|
+
rainbow (>= 2.2.2, < 4.0)
|
73
|
+
regexp_parser (>= 1.7)
|
74
|
+
rexml
|
75
|
+
rubocop-ast (>= 0.5.0)
|
76
|
+
ruby-progressbar (~> 1.7)
|
77
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
78
|
+
rubocop-ast (0.7.1)
|
79
|
+
parser (>= 2.7.1.5)
|
80
|
+
rubocop-rspec (1.43.2)
|
81
|
+
rubocop (~> 0.87)
|
82
|
+
ruby-progressbar (1.10.1)
|
83
|
+
thread_safe (0.3.6)
|
84
|
+
tzinfo (1.2.7)
|
85
|
+
thread_safe (~> 0.1)
|
86
|
+
unicode-display_width (1.7.0)
|
87
|
+
webmock (3.9.1)
|
88
|
+
addressable (>= 2.3.6)
|
89
|
+
crack (>= 0.3.2)
|
90
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
91
|
+
zeitwerk (2.4.0)
|
24
92
|
|
25
93
|
PLATFORMS
|
26
94
|
ruby
|
27
95
|
|
28
96
|
DEPENDENCIES
|
29
97
|
cirro-ruby-client!
|
98
|
+
pry
|
30
99
|
rake (~> 12.0)
|
31
100
|
rspec (~> 3.0)
|
101
|
+
rubocop
|
102
|
+
rubocop-rspec
|
103
|
+
webmock
|
32
104
|
|
33
105
|
BUNDLED WITH
|
34
106
|
2.1.4
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# CirroIO::Client
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This gem provides access to the [Cirro REST API](https://staging.cirro.io/api-docs/v1#cirro-api-documentation).
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -20,25 +18,26 @@ Or install it yourself as:
|
|
20
18
|
|
21
19
|
$ gem install cirro-ruby-client
|
22
20
|
|
23
|
-
## Usage
|
24
21
|
|
25
|
-
|
22
|
+
## Configuration
|
26
23
|
|
27
|
-
|
24
|
+
You need to create an initializer file in config/initializers.
|
28
25
|
|
29
|
-
|
26
|
+
```ruby
|
27
|
+
CirroIO::Client.configure do |c|
|
28
|
+
c.app_id 'WULnc6Y0rlaTBCSiHAb0kGWKFuIxPWBXJysyZeG3Rtw'
|
29
|
+
c.private_key_path './storage/cirro.pem'
|
30
|
+
c.site 'https://api.staging.cirro.io'
|
31
|
+
end
|
32
|
+
```
|
30
33
|
|
31
|
-
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).
|
32
34
|
|
33
|
-
##
|
35
|
+
## Development
|
34
36
|
|
35
|
-
|
37
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
36
38
|
|
39
|
+
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).
|
37
40
|
|
38
41
|
## License
|
39
42
|
|
40
43
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
-
|
42
|
-
## Code of Conduct
|
43
|
-
|
44
|
-
Everyone interacting in the Cirro::Ruby::Client project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cirro-ruby-client/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'cirro_io/client'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "cirro_i_o/client"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/cirro-ruby-client.gemspec
CHANGED
@@ -1,27 +1,30 @@
|
|
1
|
-
require_relative 'lib/
|
1
|
+
require_relative 'lib/cirro_io/client/version'
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
|
-
spec.name =
|
4
|
+
spec.name = 'cirro-ruby-client'
|
5
5
|
spec.version = CirroIO::Client::VERSION
|
6
|
-
spec.authors = [
|
7
|
-
spec.email = [
|
6
|
+
spec.authors = ['Cirro Dev Team']
|
7
|
+
spec.email = ['OrgtestIODevelopers@epam.com']
|
8
8
|
|
9
|
-
spec.summary =
|
10
|
-
spec.description =
|
11
|
-
spec.homepage =
|
12
|
-
spec.license =
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
9
|
+
spec.summary = 'Ruby client library for Cirro API'
|
10
|
+
spec.description = 'Simple wrapper for Cirro API'
|
11
|
+
spec.homepage = 'https://cirro.io/api-docs/v1#cirro-api-documentation'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
14
14
|
|
15
|
-
spec.metadata[
|
16
|
-
spec.metadata[
|
17
|
-
spec.metadata[
|
15
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
16
|
+
spec.metadata['source_code_uri'] = 'https://github.com/test-IO/cirro-ruby-client'
|
17
|
+
spec.metadata['changelog_uri'] = 'https://github.com/test-IO/cirro-ruby-client/CHANGELOG.md'
|
18
18
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
-
spec.files
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
22
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
23
|
end
|
24
|
-
spec.bindir =
|
24
|
+
spec.bindir = 'exe'
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
-
spec.require_paths = [
|
26
|
+
spec.require_paths = ['lib']
|
27
|
+
|
28
|
+
spec.add_runtime_dependency 'jwt'
|
29
|
+
spec.add_runtime_dependency 'json_api_client'
|
27
30
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'json_api_client'
|
2
|
+
require 'cirro_io/client/version'
|
3
|
+
require 'cirro_io/client/configuration'
|
4
|
+
require 'cirro_io/client/response_debugging_middleware'
|
5
|
+
require 'cirro_io/client/jwt_authentication'
|
6
|
+
require 'cirro_io/client/base'
|
7
|
+
require 'cirro_io/client/app_worker'
|
8
|
+
|
9
|
+
module CirroIO
|
10
|
+
module Client
|
11
|
+
class Error < StandardError; end
|
12
|
+
|
13
|
+
def self.configure
|
14
|
+
yield configuration if block_given?
|
15
|
+
Base.site = "#{configuration.site}/#{configuration.api_version}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.configuration
|
19
|
+
@configuration ||= Configuration.new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module CirroIO
|
2
|
+
module Client
|
3
|
+
class Base < JsonApiClient::Resource
|
4
|
+
self.route_format = :dasherized_route
|
5
|
+
self.json_key_format = :dasherized_key
|
6
|
+
|
7
|
+
# https://github.com/JsonApiClient/json_api_client/issues/215
|
8
|
+
def self.site=(url)
|
9
|
+
super(url)
|
10
|
+
connection.faraday.url_prefix = url
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
CirroIO::Client::Base.connection do |connection|
|
17
|
+
connection.use CirroIO::Client::JwtAuthentication
|
18
|
+
connection.use Faraday::Response::Logger
|
19
|
+
# connection.use CirroIO::Client::ResponseDebuggingMiddleware # This middleware can be injected during debugging or while adding new specs
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module CirroIO
|
2
|
+
module Client
|
3
|
+
class Configuration
|
4
|
+
def app_id(value = nil)
|
5
|
+
@app_id = value unless value.nil?
|
6
|
+
raise 'app_id must be defined' unless defined?(@app_id)
|
7
|
+
|
8
|
+
@app_id
|
9
|
+
end
|
10
|
+
|
11
|
+
def private_key_path(value = nil)
|
12
|
+
@private_key_path = value unless value.nil?
|
13
|
+
raise 'private_key_path must be defined' unless defined?(@private_key_path)
|
14
|
+
|
15
|
+
@private_key_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def site(value = nil)
|
19
|
+
@site = value unless value.nil?
|
20
|
+
raise 'site must be defined' unless defined?(@site)
|
21
|
+
|
22
|
+
@site
|
23
|
+
end
|
24
|
+
|
25
|
+
def api_version
|
26
|
+
'v1'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'jwt'
|
2
|
+
require 'openssl'
|
3
|
+
|
4
|
+
module CirroIO
|
5
|
+
module Client
|
6
|
+
class JwtAuthentication < Faraday::Middleware
|
7
|
+
def call(env)
|
8
|
+
private_pem = File.read(CirroIO::Client.configuration.private_key_path)
|
9
|
+
private_key = OpenSSL::PKey::RSA.new(private_pem)
|
10
|
+
|
11
|
+
payload = {
|
12
|
+
# JWT expiration time (10 minute maximum)
|
13
|
+
exp: Time.now.to_i + (10 * 60),
|
14
|
+
# App client id
|
15
|
+
iss: CirroIO::Client.configuration.app_id,
|
16
|
+
}
|
17
|
+
|
18
|
+
token = JWT.encode(payload, private_key, 'RS256')
|
19
|
+
|
20
|
+
env[:request_headers]['Authorization'] = "Bearer #{token}"
|
21
|
+
@app.call(env)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cirro-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cirro Dev Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
12
|
-
dependencies:
|
11
|
+
date: 2020-10-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jwt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json_api_client
|
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
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
description: Simple wrapper for Cirro API
|
14
42
|
email:
|
15
43
|
- OrgtestIODevelopers@epam.com
|
@@ -17,8 +45,11 @@ executables: []
|
|
17
45
|
extensions: []
|
18
46
|
extra_rdoc_files: []
|
19
47
|
files:
|
48
|
+
- ".circleci/config.yml"
|
49
|
+
- ".circleci/gem_credentials"
|
20
50
|
- ".gitignore"
|
21
51
|
- ".rspec"
|
52
|
+
- ".rubocop.yml"
|
22
53
|
- ".travis.yml"
|
23
54
|
- CODE_OF_CONDUCT.md
|
24
55
|
- Gemfile
|
@@ -29,8 +60,13 @@ files:
|
|
29
60
|
- bin/console
|
30
61
|
- bin/setup
|
31
62
|
- cirro-ruby-client.gemspec
|
32
|
-
- lib/
|
33
|
-
- lib/
|
63
|
+
- lib/cirro_io/client.rb
|
64
|
+
- lib/cirro_io/client/app_worker.rb
|
65
|
+
- lib/cirro_io/client/base.rb
|
66
|
+
- lib/cirro_io/client/configuration.rb
|
67
|
+
- lib/cirro_io/client/jwt_authentication.rb
|
68
|
+
- lib/cirro_io/client/response_debugging_middleware.rb
|
69
|
+
- lib/cirro_io/client/version.rb
|
34
70
|
homepage: https://cirro.io/api-docs/v1#cirro-api-documentation
|
35
71
|
licenses:
|
36
72
|
- MIT
|
data/lib/cirro_i_o/client.rb
DELETED