envyml 0.1.0 → 0.1.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: 9d16cbee9ca6c89e5798f9fde13c54e39d197c25
4
- data.tar.gz: df134def32e4e4dc58831ff7526abc11b1af9357
3
+ metadata.gz: ff86fca594892a9da4cec7c2c3837adf1a56afbf
4
+ data.tar.gz: 4c9f3f3f5d2793b6a59b416adf36d1b38e4e9ac1
5
5
  SHA512:
6
- metadata.gz: 2d3cc65dc872296a26c976d7959a562dfa4ac505dfaeb81ef3aef676580eeeccb037e76c70c88d90921ceb53b1f25a73d1228c679f683f51893511c1a9042921
7
- data.tar.gz: d163066164c62238bad3d8e53b5909eaf775a2bc383454303e41c3a3099695c78d047880327684cc0e79c8a8e2e639124bac0bdcb82e227a9522ec0d2a3890ef
6
+ metadata.gz: e7ab60edb4111a72cbd8485e39f14b79016f1fb9653cec346e21c06b6a69f22d7b236b4628e081d8b360cafae446f35f1ad6702c1bcbd65fe742c2777e1f6768
7
+ data.tar.gz: b355571648aedfb97e8affe75d56f4459637655400b7c5191e704f8ff012bed10016065bc38489703d5ed83ac12245f85275c8bd0b16ffaa33ca441a27e1e86f
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Envyml
2
2
 
3
- Load environment yaml file into ENV ruby hash
3
+ Loads environment YAML file into
4
+ [ENV](https://ruby-doc.org/core-2.2.0/ENV.html) ruby hash.
5
+ Minimalistic approach. The goal is to keep less than 50 LOC forever.
4
6
 
5
7
  ## Installation
6
8
 
@@ -21,28 +23,45 @@ Or install it yourself as:
21
23
  ## Usage
22
24
 
23
25
  Create file `YOUR_PROJECT/config/env.yml`, with:
26
+ ```
27
+ key: VALUE
28
+ ```
29
+
30
+ Call `Envyml.load` to insert this file into ENV ruby hash.
31
+ *Don't forget to add config/env.yml to gitignore!*
32
+
33
+ ## Rails
34
+ If you are using Rails or just wants to separate your keys,
35
+ add environment sections to your file:
24
36
  ```
25
37
  development:
26
- key: VALUE
38
+ FOO: bar
39
+ KEY: value
40
+
41
+ test:
42
+ FOO: bar
43
+ KEY: value
27
44
  ```
28
45
 
29
- Call `Envyml.load` to insert env.yml into ENV ruby hash.
30
46
 
31
- By default:
32
- - It will load from YOUR_PROJECT/config/env.yml
33
- - It will use ENV['RAILS_ENV'] to determine the environment
34
- - If you are not using Rails it won't use environments, so leave only
35
- one environment section in env.yml, or it will raise
36
- `TypeError Exception: no implicit conversion of Hash into String`
47
+ ## Custom calls
48
+ You can customize filename, hardcode environment and much more.
49
+ Check /lib/envyml.rb to understand your options.
37
50
 
38
- *Custom calls*
39
- `Envyml.load('lib', 'test')`;
40
- `Envyml.load('lib')`
51
+ ```
52
+ Envyml.load('lib/my_file.yml', 'test')
53
+ Envyml.load('lib/my_file.yml')
54
+ ```
55
+
56
+ If you use Rails, but wish to force use without environments
57
+ ```
58
+ Envyml.load('lib/my_file.yml', false)
59
+ ```
41
60
 
42
61
  ## Testing and Contributing
43
62
 
44
63
  Make sure the tests are passing: `rake test`
45
- Feel free to send me pull requests
64
+ Feel free to send pull requests
46
65
 
47
66
  ## License
48
67
 
@@ -1,3 +1,3 @@
1
1
  module Envyml
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/envyml.rb CHANGED
@@ -4,7 +4,10 @@ require 'yaml'
4
4
  module Envyml
5
5
  def self.load(path = "#{ENV['PWD']}/config/env.yml", environment = ENV['RAILS_ENV'])
6
6
  data = YAML.load_file(path)
7
- data = data[environment] if environment
7
+
8
+ if environment
9
+ data = data[environment] || {}
10
+ end
8
11
 
9
12
  data.each do |key, value|
10
13
  ENV[key] = value
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envyml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Costa