voltos 0.2.0 → 0.2.1

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: f4a9232be59e0741a341ca3a1943193065ac1f30
4
- data.tar.gz: 834922be6fa5007ab33c003a7d6db02844d67ec0
3
+ metadata.gz: 31b2704117c58bd5257ac339ee941f8de2973283
4
+ data.tar.gz: 4786a3ba2725165f9ea84df0eb4ce326c63df63d
5
5
  SHA512:
6
- metadata.gz: 05c840cf8ee45113e9947f59244910bedb483232bf8c4be518e9091bce98a9511c653971f3a34860f34d4207d32cc21770674ac50df41a7926e7012347fcd67f
7
- data.tar.gz: ea54395afa3f468b0e50b3a91f9223a974a91eca82509cf4f397919cd70cf59d115306eb2353a354e321deeb1cfbedb60ecc8739d733a4ff84f57171c34e35f5
6
+ metadata.gz: db19f9d34d21161730136bde177f3fcc2abe34edd455379618add46809583712eea20d61a31c99aa0138bd871876e448caa7692653a23cba0967e66cfe2fc9e5
7
+ data.tar.gz: 1f75eae336dd7c191c52bce2aa3bb44064a628166b74cc01e03bed4d18ea10bbb93346495dad5101e30c4a9f752e75ea33331a8f5475f07e3660932f7d500390
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Voltos Ruby bindings
2
2
 
3
- This gem provides Voltos Ruby bindings for provide a small SDK for access to the Voltos API from apps written in Ruby. Voltos ([https://voltos.online](https://voltos.online)) provides credentials-as-a-service for app and system developers.
3
+ This gem provides Voltos Ruby bindings to access the Voltos API from apps written in Ruby. Voltos ([https://voltos.online](https://voltos.online)) provides credentials-as-a-service for app and system developers.
4
+
5
+ Voltos stores your credentials (e.g. API keys, usernames, passwords, tokens) in a secure, central location - so that your apps can access them, and you can more easily manage them & access to them.
4
6
 
5
7
  ## Installation
6
8
 
@@ -20,24 +22,71 @@ Or install it yourself as:
20
22
 
21
23
  ## Getting started
22
24
 
23
- 1. Find your unique Voltos API key. See "Bundle" settings.
25
+ You'll use Voltos to load up a **bundle** of credentials each time. Think of a bundle as credentials that have been logically grouped together, e.g. a ``PROD`` bundle.
26
+
27
+ 1. Ensure your bundle(s) are organised how you want, on your Voltos account (https://voltos.online).
24
28
 
25
- 2. Set this key as an environment variable, e.g.
29
+ 2. Find the API key for the bundle that you want your app to load (e.g. bundle ``PROD``'s API key: 13579def13579def)
30
+
31
+ 2. Set this key as an environment variable in your app, e.g.
26
32
  ```ruby
27
33
  $ export VOLTOS_KEY=13579def13579def
28
34
 
29
35
  # or on a platform like Heroku
30
36
  $ heroku config:set VOLTOS_KEY=13579def13579def
31
37
  ```
32
- We'll use this key to load up our Voltos credentials (don't worry, you'll only need to set one key this way).
38
+ In a moment, we'll use this key to load up the matching Voltos bundle of credentials (and don't worry, you'll only need to set one environment variable this way).
33
39
 
34
- 3. Require the `voltos` gem early on, prior to where your trying to use any credentials
40
+ 3. Require the `voltos` gem early on, before you use the credentials:
35
41
  ```ruby
36
42
  require 'voltos'
37
- # access the credential "MAILER_API_TOKEN" that's in the bundle
38
- puts ENV["MAILER_API_TOKEN"]
43
+
44
+ # Voltos will automatically load the bundle matching the key you've specified in VOLTOS_KEY
45
+ # and load those credentials into ENV, ready to use
46
+
47
+ puts ENV['MY_SECRET_KEY']
39
48
  ```
40
49
 
50
+ ### Multiple bundles
51
+
52
+ Sometimes, you need to load up more than one bundle (e.g. you have ``DEV`` and ``PROD`` bundles to load when deploying on different environments).
53
+
54
+ 1. Get the respective API keys for those bundles (e.g. ``VOLTOS_COMMON`` and ``VOLTOS_PROD``).
55
+
56
+ 2. Set environment variables for these bundle keys:
57
+ ```ruby
58
+ $ export VOLTOS_COMMON=1294854fe52417a
59
+ $ export VOLTOS_PROD=8646ec352729c3
60
+
61
+ # or on a platform like Heroku
62
+ $ heroku config:set VOLTOS_COMMON=1294854fe52417a VOLTOS_PROD=8646ec352729c3
63
+ ```
64
+
65
+ 2. Manually load up each bundle of credentials at appropriate time for your app:
66
+ ```ruby
67
+
68
+ ## environment.rb - load up COMMON bundle with credentials common to all environments
69
+ Voltos.configure do |config|
70
+ config.api_key = ENV["VOLTOS_COMMON"]
71
+ end
72
+
73
+ voltos_creds = Voltos.load
74
+ voltos_creds.each do |key,val|
75
+ ENV[key] ||= val
76
+ end
77
+
78
+
79
+ ## production.rb - load up PROD bundle with credentials specific to prod environment
80
+ Voltos.configure do |config|
81
+ config.api_key = ENV["VOLTOS_PROD"]
82
+ end
83
+
84
+ voltos_creds = Voltos.load
85
+ voltos_creds.each do |key,val|
86
+ ENV[key] ||= val
87
+ end
88
+ ```
89
+
41
90
  ## Contributing
42
91
 
43
92
  Bug reports and pull requests are welcome on GitHub at https://github.com/voltos-online/voltos-ruby
@@ -0,0 +1,22 @@
1
+ begin
2
+ module Voltos
3
+ class Railtie < Rails::Railtie
4
+ config.before_configuration { load }
5
+
6
+ def load
7
+ Voltos.configure
8
+ Voltos.load
9
+ end
10
+
11
+ def root
12
+ Rails.root || Pathname.new(ENV["RAILS_ROOT"] || Dir.pwd)
13
+ end
14
+
15
+ def self.load
16
+ instance.load
17
+ end
18
+ end
19
+ end
20
+ rescue NameError
21
+ # Rails not loaded
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Voltos
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/voltos.rb CHANGED
@@ -10,7 +10,7 @@ module Voltos
10
10
 
11
11
  def self.configure
12
12
  self.configuration ||= Configuration.new
13
- yield(configuration)
13
+ yield(configuration) if block_given?
14
14
  end
15
15
 
16
16
  def self.load
@@ -58,11 +58,20 @@ module Voltos
58
58
 
59
59
  def initialize
60
60
  @api_url = ENV["VOLTOS_API_URL"] || "https://voltos.online/v1"
61
- @api_key = ENV["VOLTOS_API_KEY"]
61
+ @api_key = ENV["VOLTOS_KEY"]
62
62
  end
63
63
  end
64
64
  end
65
65
 
66
- if ENV["VOLTOS_API_KEY"]
66
+ begin
67
+ if Rails
68
+ require 'voltos/rails'
69
+ end
70
+ rescue NameError
71
+ # Rails not loaded
72
+ end
73
+
74
+ Voltos.configure
75
+ if ENV["VOLTOS_KEY"]
67
76
  Voltos.load
68
77
  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.2.0
4
+ version: 0.2.1
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-07 00:00:00.000000000 Z
11
+ date: 2016-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,6 +102,7 @@ files:
102
102
  - bin/console
103
103
  - bin/setup
104
104
  - lib/voltos.rb
105
+ - lib/voltos/rails.rb
105
106
  - lib/voltos/version.rb
106
107
  - voltos.gemspec
107
108
  homepage: http://rubygems.org/gems/voltos
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
124
  version: '0'
124
125
  requirements: []
125
126
  rubyforge_project:
126
- rubygems_version: 2.4.6
127
+ rubygems_version: 2.5.1
127
128
  signing_key:
128
129
  specification_version: 4
129
130
  summary: Access Voltos API