loopiator 0.3.5 → 0.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0139c4834170b91b736915fd3b5cfb333eaacd77
4
- data.tar.gz: a1a963f7309f4e4b598d5ce5243f84afa397ec81
3
+ metadata.gz: c0052de38f588c5ec092a39c1db7c864cca70cce
4
+ data.tar.gz: 0481091a1d6a62b3f1f60a623d6e15e789abef5a
5
5
  SHA512:
6
- metadata.gz: 569d16bc8cb703c96b966f9a9f9fd05cabf4525145e55e6972873e4c3a5c9738dd9140f7063194815f668a1a1c6e7d3f817b663310f20804eed1a314300c6037
7
- data.tar.gz: 89396769939432c3c8779145aabccdf558ce94bb2bbe303bf56152bc839fd69038a5c0a8ce9e8e6951d10a157904ba8c51a74c65612e6ca8b5ee651475341402
6
+ metadata.gz: 66b943cfe25acd2ae8fed98f0e735e45419f9146ef08de839407a98724d6924d5f3a2a51729d28a2095ae40bf2ad27ce23546edd4849969a54798ab2b4dc0f0c
7
+ data.tar.gz: 14f432effad1d2f2fcf0190f1e2c931d125804e7a651147bbcf9f5068200b5c12e120c265d609602822a75f2394b109a303a742bb933b677c6fb9ac34e74f9f2
@@ -7,15 +7,14 @@ module Loopiator
7
7
 
8
8
  include Loopiator::Logger
9
9
 
10
- def initialize(connection_options = {}, debug = false)
11
- set_client(connection_options, debug: debug)
10
+ def initialize(connection_options = {})
11
+ connection_options.symbolize_keys!
12
+ set_client(connection_options)
12
13
  end
13
14
 
14
- def set_client(connection_options = {}, debug = false)
15
- connection_options = generate_connection_options(connection_options)
16
-
17
- self.client = XMLRPC::Client.new_from_hash(connection_options)
18
- enable_debugging if debug
15
+ def set_client(connection_options = {})
16
+ self.client = XMLRPC::Client.new_from_hash(generate_connection_options(connection_options))
17
+ enable_debugging if Loopiator.configuration.debug
19
18
  set_client_options(connection_options)
20
19
  end
21
20
 
@@ -53,7 +52,7 @@ module Loopiator
53
52
  private
54
53
  def generate_connection_options(connection_options = {})
55
54
  default_options = {
56
- host: Loopiator.configuration.host,
55
+ host: determine_host(connection_options),
57
56
  path: Loopiator.configuration.path,
58
57
  port: Loopiator.configuration.port,
59
58
 
@@ -72,6 +71,11 @@ module Loopiator
72
71
  default_options.merge(connection_options)
73
72
  end
74
73
 
74
+ def determine_host(connection_options = {})
75
+ env = (connection_options && !connection_options.empty?) ? connection_options.fetch(:environment, Loopiator.configuration.environment) : Loopiator.configuration.environment
76
+ Loopiator.configuration.hosts[env.to_sym]
77
+ end
78
+
75
79
  def enable_debugging
76
80
  self.client.instance_variable_get(:@http).set_debug_output($stderr)
77
81
  end
@@ -1,13 +1,21 @@
1
1
  module Loopiator
2
2
  class Configuration
3
- attr_accessor :host, :port, :path
3
+ attr_accessor :environment
4
+ attr_accessor :hosts, :port, :path
4
5
  attr_accessor :auth_user, :auth_password
5
6
  attr_accessor :use_ssl, :timeout
7
+ attr_accessor :debug
6
8
  attr_accessor :username, :password
7
9
  attr_accessor :proxy_host, :proxy_port, :proxy_user, :proxy_password
8
10
 
9
11
  def initialize
10
- self.host = "api.loopia.se"
12
+ self.environment = :production
13
+
14
+ self.hosts = {
15
+ production: "api.loopia.se",
16
+ test: "test-api.loopia.se"
17
+ }
18
+
11
19
  self.port = 443
12
20
  self.path = "/RPCSERV"
13
21
 
@@ -17,6 +25,8 @@ module Loopiator
17
25
  self.use_ssl = true
18
26
  self.timeout = 180
19
27
 
28
+ self.debug = false
29
+
20
30
  self.username = nil
21
31
  self.password = nil
22
32
 
data/lib/loopiator.rb CHANGED
@@ -10,7 +10,7 @@ require File.join(File.dirname(__FILE__), 'loopiator/credits')
10
10
  require File.join(File.dirname(__FILE__), 'loopiator/client')
11
11
 
12
12
  module Loopiator
13
- VERSION = "0.3.5"
13
+ VERSION = "0.3.6"
14
14
 
15
15
  class << self
16
16
  attr_writer :configuration
data/loopiator.gemspec CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = 'loopiator'
6
- s.version = '0.3.5'
6
+ s.version = '0.3.6'
7
7
 
8
8
  s.homepage = "https://github.com/Agiley/Loopiator"
9
9
  s.email = "sebastian@agiley.se"
@@ -12,10 +12,6 @@ describe "Loopiator Configuration" do
12
12
  expect(Loopiator.configuration.password).to be == nil
13
13
  end
14
14
 
15
- it "should have a default host set" do
16
- expect(Loopiator.configuration.host).to be == "api.loopia.se"
17
- end
18
-
19
15
  it "should have a default port set" do
20
16
  expect(Loopiator.configuration.port).to be == 443
21
17
  end
@@ -64,10 +60,6 @@ describe "Loopiator Configuration" do
64
60
  expect(Loopiator.configuration.proxy_port).to be == 8080
65
61
  end
66
62
 
67
- it "should have a default host set" do
68
- expect(Loopiator.configuration.host).to be == "api.loopia.se"
69
- end
70
-
71
63
  it "should have a default port set" do
72
64
  expect(Loopiator.configuration.port).to be == 443
73
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loopiator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Johnsson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-27 00:00:00.000000000 Z
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simpleidn