obscure_yaml 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/obscure_yaml/cli.rb +22 -5
- data/lib/obscure_yaml/version.rb +1 -1
- data/lib/obscure_yaml.rb +7 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8cb65381c4bb6f6f29047bf4b7edf7080fb1cbb
|
4
|
+
data.tar.gz: f900378b076ebfcbf898bee3b7e1fb6aa7a7c3d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48cda1819f12cd9776993a1cc376fe9d50e63c25e6613fa2e70ff20140e9657adc1a7ba3b85c731dd2338de2c2e7898287541675ffbb3d832f7e0b67d32a823d
|
7
|
+
data.tar.gz: 13036cb2318f7a05d122491bd37f93b0ef12bd51439c9d412a89e0f9495460f7bf2eccf7eb8edf298101ae8793beeec161a69d251e8509b78a17167c8e36a373
|
data/lib/obscure_yaml/cli.rb
CHANGED
@@ -6,11 +6,28 @@ module ObscureYaml
|
|
6
6
|
module_function
|
7
7
|
|
8
8
|
def parse(arguments)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
mode = arguments.shift
|
10
|
+
output = arguments.last != arguments.first ? arguments.pop : $stdout
|
11
|
+
input = arguments.first || $stdin
|
12
|
+
with(input, 'r') do |input_object|
|
13
|
+
with(output, 'w+') do |output_object|
|
14
|
+
case mode
|
15
|
+
when DECODE
|
16
|
+
ObscureYaml.decode(output_object, input_object)
|
17
|
+
when ENCODE
|
18
|
+
ObscureYaml.encode(output_object, input_object)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def with(output, mode)
|
25
|
+
if output.kind_of?(IO)
|
26
|
+
yield output
|
27
|
+
else
|
28
|
+
open(output, mode) do |f|
|
29
|
+
yield f
|
30
|
+
end
|
14
31
|
end
|
15
32
|
end
|
16
33
|
|
data/lib/obscure_yaml/version.rb
CHANGED
data/lib/obscure_yaml.rb
CHANGED
@@ -1,27 +1,26 @@
|
|
1
1
|
# require 'obscure_yaml/base64'
|
2
2
|
require 'yaml'
|
3
3
|
require 'base64'
|
4
|
+
require 'open-uri'
|
4
5
|
module ObscureYaml
|
5
6
|
DEFAULT_DATA_KEY = 'data'
|
6
7
|
MAGIC_DELIMITER = '@'
|
7
8
|
module_function
|
8
9
|
|
9
|
-
def decode(
|
10
|
-
output << construct_yaml(
|
10
|
+
def decode(output, input)
|
11
|
+
output << construct_yaml(input, :output)
|
11
12
|
end
|
12
13
|
|
13
|
-
def encode(
|
14
|
-
|
15
|
-
f.write(construct_yaml(file_path, :input))
|
16
|
-
end
|
14
|
+
def encode(output, input)
|
15
|
+
output << construct_yaml(input, :input)
|
17
16
|
end
|
18
17
|
|
19
18
|
private
|
20
19
|
|
21
20
|
module_function
|
22
21
|
|
23
|
-
def construct_yaml(
|
24
|
-
YAML::
|
22
|
+
def construct_yaml(yaml_source, direction)
|
23
|
+
YAML::load(yaml_source.read).tap { |hsh|
|
25
24
|
data = hsh[obscured_data_key]
|
26
25
|
hsh[obscured_data_key] = data.map { |key, value|
|
27
26
|
[key, handle_coding(direction, value)]
|
@@ -35,7 +34,6 @@ module ObscureYaml
|
|
35
34
|
|
36
35
|
def value_or_file_contents(value)
|
37
36
|
return value unless detect_file(value)
|
38
|
-
require 'open-uri'
|
39
37
|
value_contents = open(value.gsub(magic_delimiter, '')) { |f| f.read }
|
40
38
|
end
|
41
39
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: obscure_yaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Glusman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: " There was no call for this really, except we needed it.\n"
|
14
14
|
email:
|