apjson 0.0.1 → 0.0.2
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/VERSION +1 -1
- data/apjson.gemspec +1 -1
- data/bin/apjson +32 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/apjson.gemspec
CHANGED
data/bin/apjson
CHANGED
@@ -19,6 +19,23 @@ while arg = ARGV.shift
|
|
19
19
|
pp_flag = true
|
20
20
|
when "--puts"
|
21
21
|
puts_flag = true
|
22
|
+
when "--puts"
|
23
|
+
puts_flag = true
|
24
|
+
when "-i"
|
25
|
+
input_file = ARGV.shift
|
26
|
+
when "--input"
|
27
|
+
input_file = ARGV.shift
|
28
|
+
when "--help"
|
29
|
+
puts <<-EOF
|
30
|
+
usage: apjson [--p] [--pp] [--ap] [--puts]
|
31
|
+
[--input <path>] [--help] [<args>]
|
32
|
+
--p print by p method
|
33
|
+
--pp print by pretty print
|
34
|
+
--ap print by awesome print
|
35
|
+
--puts print by puts method
|
36
|
+
-i, --input FILE read from FILE
|
37
|
+
EOF
|
38
|
+
exit 0
|
22
39
|
else
|
23
40
|
args.push arg
|
24
41
|
end
|
@@ -26,7 +43,21 @@ end
|
|
26
43
|
|
27
44
|
ARGV.push *args
|
28
45
|
|
29
|
-
|
46
|
+
if input_file
|
47
|
+
unless File.exists?(input_file)
|
48
|
+
STDERR.puts "ERROR: #{input_file} does not exist."
|
49
|
+
exit 1
|
50
|
+
end
|
51
|
+
f = open(input_file)
|
52
|
+
if f.nil?
|
53
|
+
STDERR.puts "ERROR: could not open #{input_file}"
|
54
|
+
exit 1
|
55
|
+
end
|
56
|
+
input = f.read
|
57
|
+
f.close
|
58
|
+
else
|
59
|
+
input = STDIN.read
|
60
|
+
end
|
30
61
|
|
31
62
|
result = JSON.parse("#{input.gsub(/\r?\n/, "")}")
|
32
63
|
|
metadata
CHANGED