scon 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/scon +17 -5
- data/lib/scon/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8377b28ee321f0b44e28772d23efe4dfc0ff73ca
|
4
|
+
data.tar.gz: 8bc2deaba18501338f17f91da0497b320b4a6942
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 934760cee171efb0514fee07c8cfa966f12afd6b054852a748ba671aae8ce1bceef47992872d99ebb97295cd2e5c5cc999ce71d88b88ed7a257809bfe6946570
|
7
|
+
data.tar.gz: 842a0b902be8ed91a5ee0afadbca0efb3c4cffba8db4f9e756671de7c9ee117d2be6d94c7d19753b2e48f2e69f0e61b34b3b777a9ef0996df6ab91d07d6dbbf9
|
data/bin/scon
CHANGED
@@ -2,12 +2,13 @@
|
|
2
2
|
require 'scon'
|
3
3
|
require 'optparse'
|
4
4
|
|
5
|
-
@options = { :type => :json }
|
5
|
+
@options = { :type => :json, :parse => false }
|
6
6
|
OptionParser.new do |o|
|
7
7
|
o.on("-o", "--output FILE", "Output generated SCON to the file") {|x| @options[:output] = x }
|
8
8
|
o.on("-i", "--input FILE", "Input JSON from a specified file") {|x| @options[:input] = x }
|
9
|
-
o.on("--json", "Use JSON
|
10
|
-
o.on("--msgpack", "Use MessagePack
|
9
|
+
o.on("--json", "Use JSON") {|x| @options[:type] = :json}
|
10
|
+
o.on("--msgpack", "Use MessagePack") {|x| @options[:type] = :msgpack}
|
11
|
+
o.on("-p", "--parse", "Parse instead of Generate") { |x| @options[:parse] = true }
|
11
12
|
end.parse!
|
12
13
|
|
13
14
|
if @options.include? :type
|
@@ -18,6 +19,7 @@ else
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def parse data
|
22
|
+
return SCON.parse!(data) if @options[:parse]
|
21
23
|
case @type
|
22
24
|
when :json
|
23
25
|
return JSON.parse(data)
|
@@ -26,7 +28,17 @@ def parse data
|
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
31
|
+
def generate data
|
32
|
+
return SCON.generate!(data) unless @options[:parse]
|
33
|
+
case @type
|
34
|
+
when :json
|
35
|
+
return JSON.generate(data)
|
36
|
+
when :msgpack
|
37
|
+
return data.to_msgpack
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
29
41
|
data = @options.include?(:input) ? File.read(@options[:input]) : ARGF.read
|
30
|
-
|
42
|
+
new_data = generate parse(data)
|
31
43
|
|
32
|
-
@options.include?(:output) ? File.write(@options[:output],
|
44
|
+
@options.include?(:output) ? File.write(@options[:output], new_data) : $stdout.puts(new_data)
|
data/lib/scon/version.rb
CHANGED