voltos 0.0.93 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/voltos/version.rb +1 -1
  3. data/lib/voltos.rb +19 -10
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 183c110bb7f2b1f56deb19eafb077c0fcd831752
4
- data.tar.gz: baae03c07b0dca53be3ce5313342302a0a95f94f
3
+ metadata.gz: 43fd3512151f184d1c2787b5ab1d2114a7e8a57d
4
+ data.tar.gz: 5ce65cddbe0bf0ace798da5b2fe3a8d0ad059ef9
5
5
  SHA512:
6
- metadata.gz: d3fd8f96975eb575fdce506196fea796ff66aaca54e0d22af5579e3064c7b8080be56fa3991780173b4823bb58ea2d99d5a8a9af01ecaddf06b8e9668bf31ded
7
- data.tar.gz: eb96beb92b2ca1321b71f93fb77c0067e1abaa59fc69f102b3da76f9f8eb7d0c7e7eec8009591085ab79633a4cf3d2c0887096ab2aa386b7f53ce2c4f8435e73
6
+ metadata.gz: e62cc432dc00c766cf3ca3a167bcbd8b77e7325ca4397cb3956c0d33470d0fc478d947ff0e7b8d170a885354d24b62b92a31b33311bd4ee48397f6f8dc4cfc98
7
+ data.tar.gz: c959f9d4980cff8df0382447c76605a523c6cae402c266bbd85d63891223a9b69cf74a915942d5b763aaea2efb40f20d345651695b4bf652fe5dd498e7346d3b
@@ -1,3 +1,3 @@
1
1
  module Voltos
2
- VERSION = "0.0.93"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/voltos.rb CHANGED
@@ -12,20 +12,27 @@ module Voltos
12
12
  self.configuration ||= Configuration.new
13
13
  yield(configuration)
14
14
  end
15
-
15
+
16
16
  def self.load
17
- json_str = Curl.get("https://voltos.online/v1/credentials") do |http|
17
+ json_str = Curl.get("#{Voltos.configuration.api_url}/credentials") do |http|
18
18
  http.headers["Authorization"] = "Token token=#{Voltos.configuration.api_key}"
19
19
  end
20
- Voltos.configuration.json_creds = JSON.parse(json_str.body_str)
21
- Voltos.configuration.status = Voltos.configuration.json_creds["status"]
22
- Voltos.configuration.message = Voltos.configuration.json_creds["message"]
20
+ data = JSON.parse(json_str.body_str)
21
+ if data.has_key?("status")
22
+ Voltos.configuration.json_creds = data
23
+ Voltos.configuration.status = Voltos.configuration.json_creds["status"]
24
+ Voltos.configuration.message = Voltos.configuration.json_creds["message"]
25
+ else
26
+ data.each do |key, val|
27
+ ENV[key] ||= val
28
+ end
29
+ end
23
30
  end
24
-
31
+
25
32
  def self.bundles
26
33
  Voltos.configuration.json_creds["data"]["bundles"].keys
27
34
  end
28
-
35
+
29
36
  def self.key(bundle_name, env_key)
30
37
  if not bundle_name.empty?
31
38
  Voltos.configuration.json_creds["data"]["bundles"][bundle_name][env_key]
@@ -33,22 +40,24 @@ module Voltos
33
40
  Voltos.configuration.json_creds["data"]["unbundled"][env_key]
34
41
  end
35
42
  end
36
-
43
+
37
44
  def self.status
38
45
  return Voltos.configuration.status
39
46
  end
40
-
47
+
41
48
  def self.message
42
49
  return Voltos.configuration.message
43
50
  end
44
-
51
+
45
52
  class Configuration
46
53
  attr_accessor :api_key
54
+ attr_accessor :api_url
47
55
  attr_accessor :json_creds
48
56
  attr_accessor :status
49
57
  attr_accessor :message
50
58
 
51
59
  def initialize
60
+ @api_url = ENV["VOLTOS_API_URL"] || "https://voltos.online/v1"
52
61
  @api_key = ""
53
62
  end
54
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voltos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.93
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel May
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-03 00:00:00.000000000 Z
11
+ date: 2016-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler