palladium 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a30fbc7dbca9da77d81c7c23dfa78c53bd8510ab0e96aadb1537dbf46d27d747
4
+ data.tar.gz: 987c049a515fdb04f83bc82e1323faa3cb4f0ef590c2bb850a2962327207a888
5
+ SHA512:
6
+ metadata.gz: a6caf1e0c1fbbd2ccf07d1338bc4f8692639f501977cfd4273b7e5553577d69d70ca62d104b07e8c5fe711f66920640dcec6c99fe0ab459625ed2d5ee41f0f2d
7
+ data.tar.gz: 2929d78eccf92b4f56f4d4c89076f317739172695d86badedfc73946aac36ec4252d5e997da4200f6fb60230f7bf459590d115e54566c8a205f4b5869fd68d76
data/lib/palladium.rb ADDED
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'palladium/name'
4
+ require 'palladium/version'
5
+ require 'net/http'
6
+ require 'json'
7
+ require 'logger'
8
+ module Palladium
9
+ def self.new(options = {})
10
+ Palladium.new(options)
11
+ end
12
+
13
+ class Palladium
14
+ attr_reader :host, :product, :plan, :run, :product_id,
15
+ :plan_id, :run_id, :result_set_id, :port
16
+
17
+ def initialize(options = {})
18
+ @logger = Logger.new($stdout)
19
+ @logger.level = options[:log] || 1
20
+ options[:port] ||= 80
21
+ @http = Net::HTTP.new(options[:host], options[:port])
22
+ @host = options[:host]
23
+ @port = options[:port]
24
+ @product = options[:product]
25
+ @plan = options[:plan]
26
+ @run = options[:run]
27
+ @token = options[:token]
28
+ @product_id, @run_id, @plan_id, @result_set_id = nil
29
+ end
30
+
31
+ def set_result(options = {})
32
+ request = Net::HTTP::Post.new('/api/result_new',
33
+ 'Authorization' => @token,
34
+ 'Content-Type' => 'application/json')
35
+ params = { plan_data: { product_name: @product, name: @plan },
36
+ run_data: { name: @run },
37
+ result_set_data: { name: options[:name] },
38
+ result_data: { message: options[:description], status: options[:status] } }
39
+ params[:result_set_data][:run_id] = @run_id unless @run_id.nil?
40
+ request.body = params.to_json
41
+ result = JSON.parse(@http.request(request).body)
42
+ if result['other_data']
43
+ @run_id = result['other_data']['run_id']
44
+ @product_id ||= result['other_data']['product_id']
45
+ @plan_id ||= result['other_data']['plan_id']
46
+ @result_set_id = result['other_data']['result_set_id']
47
+ else
48
+ @run_id = result['run']['id']
49
+ @product_id ||= result['product']['id']
50
+ @plan_id ||= result['plan']['id']
51
+ @result_set_id = result['result_sets'][0]['id']
52
+ end
53
+ @result_set_link = result_set_link
54
+ @logger.info "Palladium: Link to result: #{@result_set_link}"
55
+ result
56
+ end
57
+
58
+ def get_result_sets(status)
59
+ request = Net::HTTP::Post.new('/api/result_sets_by_status',
60
+ 'Authorization' => @token,
61
+ 'Content-Type' => 'application/json')
62
+ request.body = { product_name: @product, plan_name: @plan, run_name: @run, status: status }.to_json
63
+ result = JSON.parse(@http.request(request).body)
64
+ @run_id = result['run']['id'] if result['run']
65
+ @product_id ||= result['product']['id'] if result['product']
66
+ @plan_id ||= result['plan']['id'] if result['plan']
67
+ result['result_sets']
68
+ end
69
+
70
+ # get link to result set
71
+ def result_set_link
72
+ "http#{'s' if @port == 443}://#{@host}/product/#{@product_id}/"\
73
+ "plan/#{@plan_id}/run/#{@run_id}/result_set/#{@result_set_id}"
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Palladium
4
+ NAME = 'palladium'
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Palladium
4
+ VERSION = '1.0.0'
5
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: palladium
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Rotatyy Dmitriy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-03-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop-performance
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-rake
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: rubocop-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2'
83
+ description: Wrapper gem for usage of Palladium API
84
+ email:
85
+ - flamine@list.ru
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - lib/palladium.rb
91
+ - lib/palladium/name.rb
92
+ - lib/palladium/version.rb
93
+ homepage: https://github.com/flaminestone/palladium
94
+ licenses:
95
+ - AGPL-3.0
96
+ metadata:
97
+ bug_tracker_uri: https://github.com/flaminestone/palladium/issues
98
+ changelog_uri: https://github.com/flaminestone/palladium/blob/master/CHANGELOG.md
99
+ documentation_uri: https://www.rubydoc.info/gems/palladium
100
+ homepage_uri: https://github.com/flaminestone/palladium
101
+ source_code_uri: https://github.com/flaminestone/palladium
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '2.5'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubygems_version: 3.0.8
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Gem for using Palladium API
121
+ test_files: []