scon 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/scon +17 -5
  3. data/lib/scon/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96a8ac80f8ff0d178edd9e66402b49e7ab1d580d
4
- data.tar.gz: db5548b13106dfdfc836349d6b436697c213d950
3
+ metadata.gz: 8377b28ee321f0b44e28772d23efe4dfc0ff73ca
4
+ data.tar.gz: 8bc2deaba18501338f17f91da0497b320b4a6942
5
5
  SHA512:
6
- metadata.gz: 02acd1ce5075bff0b0de6878b25b4b6b5d81a6f193d770f5a361150fb47c45a66cfb407270739bb787cb917ab7c687bc07bc8c4742501283eea9266d9e729515
7
- data.tar.gz: 5aa365eef16c84a7b533dcd3665293cfe958b2d4d24aacb97b272a7aec243fbdf1720e84788c706f5115a1d7516285b7c52ece4bd6649c7037aa5dd522daa01f
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 as an input type") {|x| @options[:type] = :json}
10
- o.on("--msgpack", "Use MessagePack as an input type") {|x| @options[:type] = :msgpack}
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
- scon = SCON.generate! parse(data)
42
+ new_data = generate parse(data)
31
43
 
32
- @options.include?(:output) ? File.write(@options[:output], scon) : $stdout.puts(scon)
44
+ @options.include?(:output) ? File.write(@options[:output], new_data) : $stdout.puts(new_data)
data/lib/scon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SCON
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - JacisNonsense