ppy 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ppy +11 -0
- data/lib/ppy.rb +3 -2
- metadata +1 -1
data/bin/ppy
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'yaml'
|
4
4
|
require 'ppy'
|
5
5
|
|
6
|
+
# This first argument should always be the file to parse.
|
6
7
|
file = ARGV.first
|
7
8
|
|
8
9
|
abort 'No file argument provided.' if file.nil?
|
@@ -10,4 +11,14 @@ abort 'File does not exist.' unless File.exists?(file)
|
|
10
11
|
abort 'Directory provided, provide a file path instead.' if File.directory?(file)
|
11
12
|
|
12
13
|
yaml = YAML.load_file(file)
|
14
|
+
|
15
|
+
# If the vine gem is installed, only output a nested value if one has been
|
16
|
+
# provided as the second argument.
|
17
|
+
if Gem::Specification.find_by_name('vine')
|
18
|
+
unless ARGV[1].nil?
|
19
|
+
require 'vine'
|
20
|
+
yaml = yaml.vine(ARGV[1])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
13
24
|
PrettyYaml.print(yaml)
|
data/lib/ppy.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'rainbow'
|
2
2
|
|
3
3
|
module PrettyYaml
|
4
|
-
|
5
4
|
extend self
|
6
5
|
|
7
6
|
# Prints the actual data.
|
@@ -36,6 +35,8 @@ module PrettyYaml
|
|
36
35
|
puts "#{indent_string(level)}#{format_key('-')} #{format_value(value)}"
|
37
36
|
end
|
38
37
|
end
|
38
|
+
else
|
39
|
+
puts "#{indent_string(level)}#{format_value(data)}"
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
@@ -61,7 +62,7 @@ module PrettyYaml
|
|
61
62
|
when FalseClass
|
62
63
|
value.to_s.color(:red)
|
63
64
|
when NilClass
|
64
|
-
|
65
|
+
'nil'.color(:blue)
|
65
66
|
else
|
66
67
|
value
|
67
68
|
end
|