ctgb-ids-converter 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDM0YWIyYzlmNTMyYWJhZjA4Mzk3OGJhMWM1YTg0YjBmODliYWExZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTU4Y2IwYjZhNjM5NTI5YWZmMTBkZmNhNjM5ODNiMzE3ZTdhYWUxMQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGFiZDIxMWE0YzJjMGY0NDE3ZjgyNGYxNTdhYzAzNjc3ZTg1MDAyMzRmOTBh
|
10
|
+
ZGVmOTliMzRiY2ZlMmQxODcxM2M5NmJhNzViNDhiOTM3YzY5NDlkNDBiMDU4
|
11
|
+
OTVhYTAyMDJkNjI3ZTY1NWI2ZDA0YWMyNGZlMDI0MmJkMmU2ZGQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjdlZTRlNjhkODkxMWFkM2FiMjI2MGU1MWY5MTI4YWYyOWMxOThmODBlZTFh
|
14
|
+
MGU1OTkwZmE1NjU4MzZiZGY5ZjdiZWZmODhiMzAwMWE4MmM3OTM3MjkzZTdl
|
15
|
+
ODhiOGQ5MGE2MmE4MDIxNzlhN2E2YTJjMGI4NjhjM2ZlOGYzNGY=
|
@@ -1,6 +1,22 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module CtgbIdsConverter
|
2
|
+
|
3
|
+
class << self
|
4
|
+
attr_accessor :configuration
|
5
|
+
end
|
6
|
+
|
7
|
+
class Config
|
3
8
|
attr_accessor :host, :hydra, :token, :port
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
self.port = 80
|
12
|
+
self.hydra = Typhoeus::Hydra.new
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configure
|
18
|
+
self.configuration ||= Config.new
|
19
|
+
yield(configuration) if block_given?
|
4
20
|
end
|
5
|
-
|
21
|
+
|
6
22
|
end
|
@@ -38,8 +38,8 @@ class CtgbIdsConverter::RemoteConverter
|
|
38
38
|
# puts response.response_body.class
|
39
39
|
return yield(response)
|
40
40
|
end
|
41
|
-
CtgbIdsConverter
|
42
|
-
CtgbIdsConverter
|
41
|
+
CtgbIdsConverter.configuration.hydra.queue(request)
|
42
|
+
CtgbIdsConverter.configuration.hydra.run
|
43
43
|
end
|
44
44
|
|
45
45
|
def self.get_uri(resource_path)
|
@@ -47,11 +47,11 @@ class CtgbIdsConverter::RemoteConverter
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def self.uri_host_part
|
50
|
-
"http://#{CtgbIdsConverter
|
50
|
+
"http://#{CtgbIdsConverter.configuration.host}:#{CtgbIdsConverter.configuration.port}"
|
51
51
|
end
|
52
52
|
|
53
53
|
def self.uri_token_part
|
54
|
-
postfix = "token=#{CtgbIdsConverter
|
54
|
+
postfix = "token=#{CtgbIdsConverter.configuration.token}"
|
55
55
|
postfix.insert(0, '?') unless postfix.start_with? '?'
|
56
56
|
end
|
57
57
|
|
@@ -8,18 +8,19 @@ end
|
|
8
8
|
|
9
9
|
describe "CtgbIdsConverter configuration attributes for service on linux2" do
|
10
10
|
before(:each) do
|
11
|
-
CtgbIdsConverter
|
12
|
-
|
13
|
-
|
11
|
+
CtgbIdsConverter.configure do |config|
|
12
|
+
config.host = 'localhost'
|
13
|
+
config.token = 'zU4vFmORUQ9DBJPlJlt'
|
14
|
+
end
|
14
15
|
end
|
15
|
-
subject {CtgbIdsConverter
|
16
|
+
subject {CtgbIdsConverter.configuration}
|
16
17
|
its(:hydra){ should be_a_kind_of(Typhoeus::Hydra)}
|
17
18
|
its(:host){ should == 'localhost'}
|
18
19
|
its(:token){ should == 'zU4vFmORUQ9DBJPlJlt'}
|
19
20
|
its(:port){ should == 80}
|
20
21
|
context "when set port to 3001" do
|
21
22
|
before(:each) do
|
22
|
-
CtgbIdsConverter
|
23
|
+
CtgbIdsConverter.configuration.port = 3001
|
23
24
|
end
|
24
25
|
its(:port){ should == 3001}
|
25
26
|
end
|
@@ -29,10 +30,11 @@ end
|
|
29
30
|
describe CtgbIdsConverter::RemoteConverter do
|
30
31
|
subject(:converter) { CtgbIdsConverter::RemoteConverter }
|
31
32
|
before(:each) do
|
32
|
-
CtgbIdsConverter
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
CtgbIdsConverter.configure do |config|
|
34
|
+
config.host = 'localhost'
|
35
|
+
config.token = 'zU4vFmORUQ9DBJPlJlt'
|
36
|
+
config.port = 3001
|
37
|
+
end
|
36
38
|
end
|
37
39
|
|
38
40
|
describe ".connected?" do
|
@@ -54,7 +56,7 @@ describe CtgbIdsConverter::RemoteConverter do
|
|
54
56
|
context "when providing a new public id but user has no intert privileges" do
|
55
57
|
# for this to work AN000000 should be missing in the conversion id DB (ids_pair table)
|
56
58
|
before(:each) do
|
57
|
-
CtgbIdsConverter
|
59
|
+
CtgbIdsConverter.configuration.token = 'dFdwK5Hhk5d3ocIebea' #test user without insert public id privilege
|
58
60
|
end
|
59
61
|
specify { expect {converter.code('AN000000')}.to raise_error CtgbIdsConverter::UnauthorizedConversionException }
|
60
62
|
end
|