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
- NGYxZmEwYzBkZjIxZDg0YmRhNWI2NmI1NDI2ZGZiYTU3NTMwYmIwZQ==
4
+ NDM0YWIyYzlmNTMyYWJhZjA4Mzk3OGJhMWM1YTg0YjBmODliYWExZQ==
5
5
  data.tar.gz: !binary |-
6
- NzJhMGVjYzM2OTk1M2I0MjRiZjI4NjI1NWZiMzA1YTA0ZmQ1ZTdjZg==
6
+ ZTU4Y2IwYjZhNjM5NTI5YWZmMTBkZmNhNjM5ODNiMzE3ZTdhYWUxMQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTI3OThmNjFjMDYzZWI3OTQxYzU0ZTdlMmQ0ZTI3M2U1ZGUyODRjNTlhZWE1
10
- NDQzMTRiZGRmODRjNzQ2OTdjNzBlZTFhMGIyZDVlNTkyOGQ4MWE5MDFmZjdi
11
- NTYwNDRmYTBmZmQxYzNiMWZjZTQxY2NjMzE3ZTg0ZDBlNDRiYzM=
9
+ OGFiZDIxMWE0YzJjMGY0NDE3ZjgyNGYxNTdhYzAzNjc3ZTg1MDAyMzRmOTBh
10
+ ZGVmOTliMzRiY2ZlMmQxODcxM2M5NmJhNzViNDhiOTM3YzY5NDlkNDBiMDU4
11
+ OTVhYTAyMDJkNjI3ZTY1NWI2ZDA0YWMyNGZlMDI0MmJkMmU2ZGQ=
12
12
  data.tar.gz: !binary |-
13
- OTQ3N2NmZDUxMTE5ZmU3NzNiZGZiNGM0ZWNjNDNiMmNjMDdjZjM4MzA5OWE3
14
- YmU1MmNlZjZhYWZhZDc2YmM3Y2FhMzQwMjY4NGM5OTFlNzU1YjFhZmQ3ZWEw
15
- Y2IzZDRmNzdlMGYwMzk1Y2M1Njk4NmI1NDY5ZTY4NjJmMGFmNzQ=
13
+ MjdlZTRlNjhkODkxMWFkM2FiMjI2MGU1MWY5MTI4YWYyOWMxOThmODBlZTFh
14
+ MGU1OTkwZmE1NjU4MzZiZGY5ZjdiZWZmODhiMzAwMWE4MmM3OTM3MjkzZTdl
15
+ ODhiOGQ5MGE2MmE4MDIxNzlhN2E2YTJjMGI4NjhjM2ZlOGYzNGY=
@@ -1,6 +1,22 @@
1
- class CtgbIdsConverter::Config
2
- class << self
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
- @port = 80
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::Config.hydra.queue(request)
42
- CtgbIdsConverter::Config.hydra.run
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::Config.host}:#{CtgbIdsConverter::Config.port}"
50
+ "http://#{CtgbIdsConverter.configuration.host}:#{CtgbIdsConverter.configuration.port}"
51
51
  end
52
52
 
53
53
  def self.uri_token_part
54
- postfix = "token=#{CtgbIdsConverter::Config.token}"
54
+ postfix = "token=#{CtgbIdsConverter.configuration.token}"
55
55
  postfix.insert(0, '?') unless postfix.start_with? '?'
56
56
  end
57
57
 
@@ -1,3 +1,3 @@
1
1
  module CtgbIdsConverter
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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::Config.hydra = Typhoeus::Hydra.new
12
- CtgbIdsConverter::Config.host = 'localhost'
13
- CtgbIdsConverter::Config.token = 'zU4vFmORUQ9DBJPlJlt'
11
+ CtgbIdsConverter.configure do |config|
12
+ config.host = 'localhost'
13
+ config.token = 'zU4vFmORUQ9DBJPlJlt'
14
+ end
14
15
  end
15
- subject {CtgbIdsConverter::Config}
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::Config.port = 3001
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::Config.hydra = Typhoeus::Hydra.new
33
- CtgbIdsConverter::Config.host = 'localhost'
34
- CtgbIdsConverter::Config.token = 'zU4vFmORUQ9DBJPlJlt' #test user with insert public id privilege
35
- CtgbIdsConverter::Config.port = 3001
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::Config.token = 'dFdwK5Hhk5d3ocIebea' #test user without insert public id privilege
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ctgb-ids-converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - masciugo