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 +4 -4
- data/README.md +25 -3
- data/bin/setup +1 -0
- data/dotgpg-environment.gemspec +3 -3
- data/lib/dotgpg/environment.rb +25 -0
- data/lib/dotgpg/environment/version.rb +2 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 753f0d40ed603a5d20e623f649b25f7ca5d578c6
|
4
|
+
data.tar.gz: 4c6143d61702df9f1d0e2ed18f8401c347397659
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6ff3395dc2bd5015a2b22c2fa8644ca73a45cdd11a83e9ded9894cae75b9703e0e2805c996a5bc441b179704f03cd65eaa608612d8212bf3157dd144135e3e4
|
7
|
+
data.tar.gz: 21ab79e55366b8f3bd168f5ebf0a9ad7bd75d3509464792b1758988627fad79505d14d05dbf2ae74d6e8980da169cf8318215d46575a937f555826a3bb1614cd
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Dotgpg::Environment
|
2
2
|
|
3
|
-
|
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
|
-
|
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/
|
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
data/dotgpg-environment.gemspec
CHANGED
@@ -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 = ["
|
11
|
-
spec.email = ["
|
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/
|
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"
|
data/lib/dotgpg/environment.rb
CHANGED
@@ -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
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- jonathan schatz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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
|
-
-
|
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/
|
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.
|
120
|
+
rubygems_version: 2.5.1
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: dotenv parser for dotgpg files
|