ragoon 1.0.0 → 1.1.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -2
- data/lib/ragoon.rb +11 -6
- data/lib/ragoon/client.rb +32 -3
- data/lib/ragoon/error.rb +24 -0
- data/lib/ragoon/services.rb +1 -1
- data/lib/ragoon/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d599f1d03691cb88ef6728c4cecdbf69d1762ef
|
4
|
+
data.tar.gz: 18f8ce5b9989c066663da7f0079db320510b499a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '009eefbef6e6e0175c27233b6ff1fa167806601f7fc1ead1f17cb3556759ddb5fba0977f71ae3eb1ed2a80db810b6e8a16cef3a84395dbefe24292735644a89c'
|
7
|
+
data.tar.gz: d5e4ad9a3f7f5bfd8f9c478f8a40207d4ce8c9bedf49d57dc07634bf11ef74e828d61d47d1bbbbd6da8d7f7d0275aa763f4fc236b1ea4436749f347931a8e978
|
data/.gitignore
CHANGED
data/lib/ragoon.rb
CHANGED
@@ -4,6 +4,7 @@ require 'time'
|
|
4
4
|
|
5
5
|
require 'ragoon/version'
|
6
6
|
require 'ragoon/xml'
|
7
|
+
require 'ragoon/error'
|
7
8
|
require 'ragoon/client'
|
8
9
|
require 'ragoon/services'
|
9
10
|
require 'ragoon/services/schedule'
|
@@ -15,10 +16,11 @@ module Ragoon
|
|
15
16
|
|
16
17
|
def self.default_options
|
17
18
|
{
|
18
|
-
endpoint: ENV['GAROON_ENDPOINT'] ||
|
19
|
-
username: ENV['GAROON_USERNAME'] ||
|
20
|
-
password: ENV['GAROON_PASSWORD'] ||
|
21
|
-
version: ENV['GAROON_VERSION'] ||
|
19
|
+
endpoint: ENV['GAROON_ENDPOINT'] || raise_option_error('endpoint'),
|
20
|
+
username: ENV['GAROON_USERNAME'] || raise_option_error('username'),
|
21
|
+
password: ENV['GAROON_PASSWORD'] || raise_option_error('password'),
|
22
|
+
version: ENV['GAROON_VERSION'] || 4,
|
23
|
+
retry: ENV['GAROON_RETRY'] || 10,
|
22
24
|
}
|
23
25
|
end
|
24
26
|
|
@@ -30,8 +32,11 @@ module Ragoon
|
|
30
32
|
|
31
33
|
def self.secret_options
|
32
34
|
if @@secret_options.empty?
|
33
|
-
|
34
|
-
|
35
|
+
if File.exist?('./.secret_options')
|
36
|
+
@@secret_options = eval(File.read('./.secret_options'))
|
37
|
+
else
|
38
|
+
@@secret_options = default_options
|
39
|
+
end
|
35
40
|
end
|
36
41
|
@@secret_options
|
37
42
|
end
|
data/lib/ragoon/client.rb
CHANGED
@@ -7,9 +7,20 @@ class Ragoon::Client
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def request(action_name, body_node)
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
retry_count = @options[:retry].to_i
|
11
|
+
|
12
|
+
retry_count.times do
|
13
|
+
begin
|
14
|
+
request_once(action_name, body_node)
|
15
|
+
return
|
16
|
+
rescue Ragoon::Error => e
|
17
|
+
unless e.message.include?('指定された画面はアクセスできません。')
|
18
|
+
raise e
|
19
|
+
end
|
20
|
+
sleep(0.5)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
raise Ragoon::Error.new("試行回数が#{retry_count}回を超えたので終了しました。")
|
13
24
|
end
|
14
25
|
|
15
26
|
def result_set
|
@@ -19,4 +30,22 @@ class Ragoon::Client
|
|
19
30
|
def reset
|
20
31
|
@result_set = nil
|
21
32
|
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def request_once(action_name, body_node)
|
37
|
+
reset
|
38
|
+
@action_name = action_name
|
39
|
+
@body_node = body_node
|
40
|
+
@response = RestClient.post(endpoint, Ragoon::XML.render(action_name, body_node, @options))
|
41
|
+
ensure
|
42
|
+
raise_error unless result_set.xpath('//soap:Fault').empty?
|
43
|
+
end
|
44
|
+
|
45
|
+
def raise_error
|
46
|
+
raise Ragoon::Error.new(
|
47
|
+
result_set.xpath('//soap:Reason').text.strip,
|
48
|
+
result_set.xpath('//soap:Detail/*').map { |c| [c.name, c.text.strip] }.to_h
|
49
|
+
)
|
50
|
+
end
|
22
51
|
end
|
data/lib/ragoon/error.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
class Ragoon::Error < StandardError
|
2
|
+
def initialize(message = nil, details = {})
|
3
|
+
super(message)
|
4
|
+
@details = details
|
5
|
+
end
|
6
|
+
|
7
|
+
attr_reader :details
|
8
|
+
|
9
|
+
def code
|
10
|
+
@details['code']
|
11
|
+
end
|
12
|
+
|
13
|
+
def diagnosis
|
14
|
+
@details['diagnosis']
|
15
|
+
end
|
16
|
+
|
17
|
+
def cause
|
18
|
+
@details['cause']
|
19
|
+
end
|
20
|
+
|
21
|
+
def counter_measure
|
22
|
+
@details['counter_measure']
|
23
|
+
end
|
24
|
+
end
|
data/lib/ragoon/services.rb
CHANGED
@@ -7,7 +7,7 @@ class Ragoon::Services
|
|
7
7
|
|
8
8
|
attr_reader :client, :action_type
|
9
9
|
|
10
|
-
def initialize(options = Ragoon.
|
10
|
+
def initialize(options = Ragoon.secret_options)
|
11
11
|
@options = options
|
12
12
|
@action_type = self.class.name.split('::').pop.downcase.to_sym
|
13
13
|
@client = Ragoon::Client.new(self.endpoint, options)
|
data/lib/ragoon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ragoon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SHIOYA, Hiromu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- bin/setup
|
113
113
|
- lib/ragoon.rb
|
114
114
|
- lib/ragoon/client.rb
|
115
|
+
- lib/ragoon/error.rb
|
115
116
|
- lib/ragoon/services.rb
|
116
117
|
- lib/ragoon/services/notification.rb
|
117
118
|
- lib/ragoon/services/schedule.rb
|
@@ -139,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
140
|
version: '0'
|
140
141
|
requirements: []
|
141
142
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.6.
|
143
|
+
rubygems_version: 2.6.13
|
143
144
|
signing_key:
|
144
145
|
specification_version: 4
|
145
146
|
summary: Ragoon is a simple Garoon 3 API client.
|