denv 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8dc02ec38953c284f7e3683d224f5eedbc73f63
4
- data.tar.gz: b71b09fa0d21d8a24496a52e418b68bfbcef25ad
3
+ metadata.gz: ced7332ac2a27ac268f334af2a886672818f3830
4
+ data.tar.gz: 1b6ba14c478f1610e173f3a29234a97fe4727bb9
5
5
  SHA512:
6
- metadata.gz: b58bd7a2c6e6c0fd59780d072210c8bdf0403f07e3b3b1ad770a2ebabad35423862f13969e96431193e528a929d9a64c0d124362d4d072066d584013e2d44245
7
- data.tar.gz: 4073d21e171d9b0d10801b29b940a897526ab7743f8a4b2380f360af9396c40873b6e3ea8f072e5545d00464310b17a30bea38fcc3e954e410f211361f83b47d
6
+ metadata.gz: 43b8ddc20ff10804d0f74a4b9b126277191c81e8165caf1517c1a454764959c27fd0953c639e3a9e636cb3cd30550763a8ae6ecf8fefb2ffb0672b3b62164430
7
+ data.tar.gz: 2f5c62c157b1ca0b0d0a90f5d6dc71ff47d27af32ff863813b79ee5fde20e62684d8445730b357355144b335e9451c676f699910e3ab7df0613f5c35da16b87a
@@ -1,4 +1,7 @@
1
1
  # CHANGELOG.md for denv
2
+ ## 0.2.1
3
+ - Add command line tool (`denv`)
4
+
2
5
  ## 0.2.0
3
6
  - Behaves as over-write.
4
7
  - Add `Denv.build_env(filename)` to load and get env hash.
data/README.md CHANGED
@@ -40,6 +40,13 @@ puts ENV['AWESOME_SERVICE_CREDENTIAL'] #=> "xxxxxx"
40
40
  ### Rails integration
41
41
  denv automatically sets initializer for your Rails application, so you only have to write gem dependency to your Gemfile.
42
42
 
43
+ ### Command line tool
44
+ ```
45
+ denv --help
46
+ echo 'XXX=1' > .env
47
+ denv env |grep XXX #=> XXX=1
48
+ ```
49
+
43
50
  ## Development
44
51
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
52
 
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ lib = File.expand_path('../lib', __dir__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'denv'
5
+
6
+ def puts_version!
7
+ puts Denv::VERSION
8
+ exit
9
+ end
10
+
11
+ require 'optparse'
12
+ filename = Denv::DEFAULT_ENV_FILENAME
13
+ opt = OptionParser.new.
14
+ on('-f', '--filename FILENAME') {|v| filename = v }
15
+ opt.version = Denv::VERSION
16
+ opt.banner = "Usage: #{opt.program_name} [options] command [argument ...]"
17
+
18
+ begin
19
+ command = opt.parse(ARGV)
20
+ rescue OptionParser::InvalidOption
21
+ puts opt.help
22
+ exit 1
23
+ end
24
+
25
+ Denv.load(filename)
26
+
27
+ if command.empty?
28
+ puts opt.help
29
+ exit 1
30
+ else
31
+ exec(*command)
32
+ end
@@ -22,9 +22,9 @@ module Denv
22
22
  end
23
23
  end
24
24
 
25
- class << self
26
- DEFAULT_ENV_FILENAME = '.env'.freeze
25
+ DEFAULT_ENV_FILENAME = '.env'.freeze
27
26
 
27
+ class << self
28
28
  attr_accessor :callback
29
29
 
30
30
  # Read from .env file and load vars into `ENV`.
@@ -34,7 +34,7 @@ module Denv
34
34
  def load(filename = DEFAULT_ENV_FILENAME)
35
35
  filename = File.expand_path(filename.to_s)
36
36
  run_callback(filename) do
37
- build_env(filename).each {|k, v| ENV[k] = v }
37
+ ENV.update(build_env(filename))
38
38
  end
39
39
  end
40
40
 
@@ -1,3 +1,3 @@
1
1
  module Denv
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: denv
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
  - Taiki Ono
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-08 00:00:00.000000000 Z
11
+ date: 2016-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,7 +70,8 @@ description: Loads environment variables to `ENV` from `.env` file. No special t
70
70
  about shell meta characters.
71
71
  email:
72
72
  - taiks.4559@gmail.com
73
- executables: []
73
+ executables:
74
+ - denv
74
75
  extensions: []
75
76
  extra_rdoc_files: []
76
77
  files:
@@ -85,6 +86,7 @@ files:
85
86
  - bin/console
86
87
  - bin/setup
87
88
  - denv.gemspec
89
+ - exe/denv
88
90
  - lib/denv.rb
89
91
  - lib/denv/rails.rb
90
92
  - lib/denv/version.rb
@@ -109,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
111
  version: '0'
110
112
  requirements: []
111
113
  rubyforge_project:
112
- rubygems_version: 2.5.1
114
+ rubygems_version: 2.4.5
113
115
  signing_key:
114
116
  specification_version: 4
115
117
  summary: Loads environment variables to `ENV` from `.env` file. No special treatments