ppy 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/ppy +12 -3
- data/lib/ppy/nested_access.rb +2 -2
- data/lib/ppy.rb +4 -3
- metadata +1 -1
data/bin/ppy
CHANGED
@@ -12,10 +12,19 @@ abort 'Directory provided, provide a file path instead.' if File.directory?(file
|
|
12
12
|
|
13
13
|
yaml = YAML.load_file(file)
|
14
14
|
|
15
|
-
#
|
16
|
-
# provided as the second argument.
|
15
|
+
# Only output a nested value if one has been provided as the second argument.
|
17
16
|
unless ARGV[1].nil?
|
18
|
-
|
17
|
+
require 'ppy/nested_access'
|
18
|
+
require 'optparse'
|
19
|
+
|
20
|
+
seperator = ENV['PPY_SEPERATOR'] || '.'
|
21
|
+
|
22
|
+
OptionParser.new do |opt|
|
23
|
+
opt.on('-s SEPERATOR', '--seperator SEPERATOR') { |s| seperator = s }
|
24
|
+
opt.parse!
|
25
|
+
end
|
26
|
+
|
27
|
+
yaml = yaml.nested_access(ARGV[1], seperator)
|
19
28
|
end
|
20
29
|
|
21
30
|
PrettyYaml.print(yaml)
|
data/lib/ppy/nested_access.rb
CHANGED
data/lib/ppy.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'rainbow'
|
2
|
-
require 'ppy/nested_access'
|
3
2
|
|
4
3
|
module PrettyYaml
|
5
4
|
extend self
|
6
5
|
|
6
|
+
INDENT = ' '
|
7
|
+
|
7
8
|
# Prints the actual data.
|
8
9
|
def print(data, level = 0)
|
9
10
|
case data
|
@@ -30,7 +31,7 @@ module PrettyYaml
|
|
30
31
|
puts string + ' ' + empty_value(value)
|
31
32
|
else
|
32
33
|
puts string
|
33
|
-
|
34
|
+
print(value, level + 1)
|
34
35
|
end
|
35
36
|
else
|
36
37
|
puts "#{indent_string(level)}#{format_key('-')} #{format_value(value)}"
|
@@ -43,7 +44,7 @@ module PrettyYaml
|
|
43
44
|
|
44
45
|
# Creates space indentation for a string, based on a level int.
|
45
46
|
def indent_string(level = 0)
|
46
|
-
|
47
|
+
INDENT * level
|
47
48
|
end
|
48
49
|
|
49
50
|
# Formats an empty_value.
|