gpgenv 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gpgenv/exec_command.rb +17 -1
- data/lib/gpgenv/profile.rb +40 -0
- data/lib/gpgenv/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f53c68a5984ba9f9b5e583242c21319cd8b378fb
|
4
|
+
data.tar.gz: 117960f3ebbccd6744e3afabb7dae6a519e40638
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de27f8b06e937383264654be602747a3281aba890bb65c3a775b4de4ae6605ee929659868c19230e7c504a36aba8ee844c884f4f876d9fed46881040def87754
|
7
|
+
data.tar.gz: 4ca93d6e4ffd4a1134708107b79f586797baa28ebe15517eae860d30c2c71c24eab8d5d7d5b5b9792b9120438d2b172864a32f1e8b55930b0c6ed8d6f35fb2ac
|
data/lib/gpgenv/exec_command.rb
CHANGED
@@ -1,14 +1,30 @@
|
|
1
1
|
require 'clamp'
|
2
2
|
require 'gpgenv/base_command'
|
3
|
+
require 'gpgenv/profile'
|
3
4
|
require 'gpgenv'
|
4
5
|
|
5
6
|
class Gpgenv
|
6
7
|
class ExecCommand < Gpgenv::BaseCommand
|
7
8
|
|
9
|
+
option ['-p', '--profile'], "PROFILE", "Profile to use, from ~/.gpgenvrc", attribute_name: :profile
|
8
10
|
parameter "ARGUMENTS ...", "arguments", :attribute_name => :args
|
9
11
|
|
10
12
|
def execute
|
11
|
-
|
13
|
+
executor.exec_command args[0..-1].join(' ')
|
14
|
+
end
|
15
|
+
|
16
|
+
def executor
|
17
|
+
# If GPGENV_PRPOFILE is set or a profile is passed on the CLI, use the given profile
|
18
|
+
# Otherwise use a standard Gpgenv object to execute.
|
19
|
+
if prof
|
20
|
+
Profile.new("#{ENV['HOME']}/.gpgenvrc", prof)
|
21
|
+
else
|
22
|
+
gpgenv
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def prof
|
27
|
+
profile || ENV['GPGENV_PROFILE']
|
12
28
|
end
|
13
29
|
|
14
30
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class Gpgenv
|
4
|
+
class Profile
|
5
|
+
attr_reader :file, :name
|
6
|
+
def initialize(file, name)
|
7
|
+
@file = file
|
8
|
+
@name = name
|
9
|
+
end
|
10
|
+
|
11
|
+
def exec_command(cmd)
|
12
|
+
exec(read_files, cmd)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def read_files
|
18
|
+
hash = {}
|
19
|
+
gpgenvs.each do |gpgenv|
|
20
|
+
hash.merge!(gpgenv.read_files)
|
21
|
+
end
|
22
|
+
hash
|
23
|
+
end
|
24
|
+
|
25
|
+
def gpgenvs
|
26
|
+
fail(".gpgenvrc file does not exist") unless File.exist?(file)
|
27
|
+
yaml = YAML.load(File.read(file))
|
28
|
+
fail("Invalid .gpgenvrc file") unless yaml.is_a?(Hash)
|
29
|
+
value = yaml[name]
|
30
|
+
|
31
|
+
fail("No such profile: #{name} in .gpgenvrc") unless value
|
32
|
+
fail("Invalid .gpgenvrc file") if !value.is_a?(Array)
|
33
|
+
|
34
|
+
value.map{ |dir| Gpgenv.new(dir: dir) }
|
35
|
+
rescue Psych::SyntaxError => e
|
36
|
+
fail("Malformed .gpgenvrc file: #{e.message}")
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/lib/gpgenv/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gpgenv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Shea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/gpgenv/export_command.rb
|
145
145
|
- lib/gpgenv/gpgenv_command.rb
|
146
146
|
- lib/gpgenv/import_command.rb
|
147
|
+
- lib/gpgenv/profile.rb
|
147
148
|
- lib/gpgenv/set_command.rb
|
148
149
|
- lib/gpgenv/shell_command.rb
|
149
150
|
- lib/gpgenv/version.rb
|