iron_core 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/iron_core/client.rb +18 -11
- data/lib/iron_core/iron_error.rb +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/lib/iron_core/client.rb
CHANGED
@@ -18,7 +18,7 @@ module IronCore
|
|
18
18
|
def initialize(product, options = {}, extra_options_list = [])
|
19
19
|
@options_list = [:token, :project_id, :scheme, :host, :port, :api_version, :user_agent] + extra_options_list
|
20
20
|
|
21
|
-
load_from_hash(options)
|
21
|
+
load_from_hash('params', options)
|
22
22
|
load_from_config(product, options[:config_file] || options['config_file'])
|
23
23
|
load_from_config(product, '.iron.json')
|
24
24
|
load_from_config(product, 'iron.json')
|
@@ -29,23 +29,25 @@ module IronCore
|
|
29
29
|
@rest = Rest::Client.new
|
30
30
|
end
|
31
31
|
|
32
|
-
def set_option(name, value)
|
33
|
-
if send(name.to_s).nil?
|
32
|
+
def set_option(source, name, value)
|
33
|
+
if send(name.to_s).nil? && (not value.nil?)
|
34
|
+
IronCore::Logger.debug 'IronCore', "Setting #{name} to #{value} from #{source}"
|
35
|
+
|
34
36
|
send(name.to_s + '=', value)
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
def load_from_hash(hash)
|
40
|
+
def load_from_hash(source, hash)
|
39
41
|
return if hash.nil?
|
40
42
|
|
41
43
|
@options_list.each do |o|
|
42
|
-
set_option(o, hash[o.to_sym] || hash[o.to_s])
|
44
|
+
set_option(source, o, hash[o.to_sym] || hash[o.to_s])
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
46
48
|
def load_from_env(prefix)
|
47
49
|
@options_list.each do |o|
|
48
|
-
set_option(o, ENV[prefix + '_' + o.to_s.upcase])
|
50
|
+
set_option('environment variable', o, ENV[prefix + '_' + o.to_s.upcase])
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
@@ -55,9 +57,9 @@ module IronCore
|
|
55
57
|
if File.exists?(File.expand_path(config_file))
|
56
58
|
config = JSON.load(File.read(File.expand_path(config_file)))
|
57
59
|
|
58
|
-
load_from_hash(config['iron_' + product])
|
59
|
-
load_from_hash(config['iron'])
|
60
|
-
load_from_hash(config)
|
60
|
+
load_from_hash(config_file, config['iron_' + product])
|
61
|
+
load_from_hash(config_file, config['iron'])
|
62
|
+
load_from_hash(config_file, config)
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
@@ -140,8 +142,13 @@ module IronCore
|
|
140
142
|
|
141
143
|
raise IronCore::IronResponseError.new(response) if response.code != 200
|
142
144
|
|
143
|
-
|
144
|
-
|
145
|
+
# response in rest_client gem is a confusing object, of class String,
|
146
|
+
# but with 'to_i' redefined to return response code and
|
147
|
+
# 'body' defined to return itself
|
148
|
+
body = String.new(response.body)
|
149
|
+
|
150
|
+
return body unless parse_json
|
151
|
+
JSON.parse(body)
|
145
152
|
end
|
146
153
|
end
|
147
154
|
end
|
data/lib/iron_core/iron_error.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-06-
|
13
|
+
date: 2012-06-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -105,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
segments:
|
107
107
|
- 0
|
108
|
-
hash:
|
108
|
+
hash: 559513805
|
109
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
110
|
none: false
|
111
111
|
requirements:
|