dotgpg-environment 0.1.1 → 0.2.0

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: b1cfe1d3e28469245ac9196ffc5d149f8f5242be
4
- data.tar.gz: 06a3f1e55ab6b0e53e8375a29e920c402856a465
3
+ metadata.gz: 753f0d40ed603a5d20e623f649b25f7ca5d578c6
4
+ data.tar.gz: 4c6143d61702df9f1d0e2ed18f8401c347397659
5
5
  SHA512:
6
- metadata.gz: 95b50155e3fbec48722ecf53495a09e5e425b35c9017350bf5639a0f7b360272c0835253fe89f7b35bb049d249c674a11ae4a2dde433a604d03da890c07cff72
7
- data.tar.gz: c1fa0c9836e69c68c4913662eb0e9d8380cc3ca2c653ee5056b0c7ee3d857ea17acbb21d9b996c7bf46eec7aa739f90e7dfe5b357a6f2386bdb8a3bf63ce9c09
6
+ metadata.gz: f6ff3395dc2bd5015a2b22c2fa8644ca73a45cdd11a83e9ded9894cae75b9703e0e2805c996a5bc441b179704f03cd65eaa608612d8212bf3157dd144135e3e4
7
+ data.tar.gz: 21ab79e55366b8f3bd168f5ebf0a9ad7bd75d3509464792b1758988627fad79505d14d05dbf2ae74d6e8980da169cf8318215d46575a937f555826a3bb1614cd
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Dotgpg::Environment
2
2
 
3
- monkeypatched version of dotenv's ```Environment``` class that can parse dotgpg-encrypted files.
3
+ This gem enables you to read and write [dotgpg](https://github.com/ConradIrwin/dotgpg)-encrypted files using an interface based on [Dotenv::Environment](https://github.com/bkeepers/dotenv/blob/master/lib/dotenv/environment.rb).
4
+
4
5
  ## Installation
5
6
 
6
7
  Add this line to your application's Gemfile:
@@ -20,7 +21,28 @@ Or install it yourself as:
20
21
  ## Usage
21
22
 
22
23
  ```ruby
23
- env = Dotgpg::Environment.new 'foo.gpg'
24
+ # create a new file
25
+ e = Dotgpg::Environment.new 'foo.gpg'
26
+
27
+ # set some values
28
+ e['FOO'] = "BAR"
29
+ e['BAZ'] = "BAT"
30
+
31
+ # save an encrypted version
32
+ e.write
33
+
34
+ # read in an existing file
35
+ f = Dotgpg::Environment.new 'foo.gpg'
36
+
37
+ # a call to #read is implicit if the provided file already exists
38
+ f['FOO']
39
+ # => "BAR"
40
+
41
+ # set values in the current ENV
42
+ f.apply!
43
+
44
+ # set values in the current ENV but don't overwrite existing values
45
+ f.apply
24
46
  ```
25
47
 
26
48
  ## Development
@@ -31,7 +53,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
31
53
 
32
54
  ## Contributing
33
55
 
34
- 1. Fork it ( https://github.com/vouch/dotgpg-environment/fork )
56
+ 1. Fork it ( https://github.com/modosc/dotgpg-environment/fork )
35
57
  2. Create your feature branch (`git checkout -b my-new-feature`)
36
58
  3. Commit your changes (`git commit -am 'Add some feature'`)
37
59
  4. Push to the branch (`git push origin my-new-feature`)
data/bin/setup CHANGED
@@ -2,6 +2,7 @@
2
2
  set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
 
5
+ gem install dotenv
5
6
  bundle install
6
7
 
7
8
  # Do any other automated setup that you need to do here
@@ -7,11 +7,11 @@ require "English"
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = "dotgpg-environment"
9
9
  spec.version = Dotgpg::Environment::VERSION
10
- spec.authors = ["Jonathan Schatz"]
11
- spec.email = ["jon@divisionbyzero.com"]
10
+ spec.authors = ["jonathan schatz"]
11
+ spec.email = ["modosc@users.noreply.github.com"]
12
12
 
13
13
  spec.summary = spec.description = "dotenv parser for dotgpg files"
14
- spec.homepage = "https://github.com/vouch/dotgpg-environment"
14
+ spec.homepage = "https://github.com/modosc/dotgpg-environment"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
17
  spec.bindir = "exe"
@@ -9,6 +9,11 @@ class Dotgpg
9
9
  dir = Dotgpg::Dir.closest(@filename)
10
10
 
11
11
  fail "not in a dotgpg directory" unless dir
12
+
13
+ # if the file's not there assume we're creating a new one and return an
14
+ # empty string
15
+ return '' unless File.exists? @filename
16
+
12
17
  # make a new stringio object to pass in
13
18
  s = StringIO.new
14
19
  dir.decrypt @filename, s
@@ -16,5 +21,25 @@ class Dotgpg
16
21
  s.rewind
17
22
  s.read
18
23
  end
24
+
25
+ def write
26
+ # use dotgpg here
27
+ dir = Dotgpg::Dir.closest(@filename)
28
+
29
+ fail "not in a dotgpg directory" unless dir
30
+ # make a new stringio object to pass in
31
+ s = StringIO.new
32
+
33
+ sort.each do |k,v|
34
+ # if our value has newlines or #'s it needs to be double-quoted. in
35
+ # addition newlines need to be \n and not actual multi-line strings,
36
+ # see https://github.com/bkeepers/dotenv#usage
37
+ v = v.inspect if v.to_s.match(/\n|#/)
38
+ s.write "#{k}=#{v}\n"
39
+ end
40
+
41
+ s.rewind
42
+ dir.encrypt @filename, s
43
+ end
19
44
  end
20
45
  end
@@ -1,6 +1,7 @@
1
+ require 'dotenv'
1
2
  require 'dotenv/environment'
2
3
  class Dotgpg
3
4
  class Environment < Dotenv::Environment
4
- VERSION = "0.1.1"
5
+ VERSION = "0.2.0"
5
6
  end
6
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotgpg-environment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Jonathan Schatz
7
+ - jonathan schatz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-28 00:00:00.000000000 Z
11
+ date: 2016-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,7 +82,7 @@ dependencies:
82
82
  version: 2.0.1
83
83
  description: dotenv parser for dotgpg files
84
84
  email:
85
- - jon@divisionbyzero.com
85
+ - modosc@users.noreply.github.com
86
86
  executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
@@ -98,7 +98,7 @@ files:
98
98
  - dotgpg-environment.gemspec
99
99
  - lib/dotgpg/environment.rb
100
100
  - lib/dotgpg/environment/version.rb
101
- homepage: https://github.com/vouch/dotgpg-environment
101
+ homepage: https://github.com/modosc/dotgpg-environment
102
102
  licenses: []
103
103
  metadata: {}
104
104
  post_install_message:
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  requirements: []
119
119
  rubyforge_project:
120
- rubygems_version: 2.4.6
120
+ rubygems_version: 2.5.1
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: dotenv parser for dotgpg files