vulcano 0.5.0 → 0.6.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8a9363a74d585fbbdc0cf2f8b66954c0d845c00
4
- data.tar.gz: d7c9e532ae296ccab6c00313301043f794b51729
3
+ metadata.gz: 2bec1a2e75ca067374d1f62dc992368be1d61511
4
+ data.tar.gz: 8d9add772d73b62f4c7e5a3326359c41b2f468f4
5
5
  SHA512:
6
- metadata.gz: f2811d6a2cce0e1f354501a7bc70f76912b320be1011c41685f276c6d1743d382e781a3b51067db7ec4f56010747ede8b88bd3cdc4f3717d81f327e948af4d42
7
- data.tar.gz: c8c83c16bf8042f5e4928fe230d288fe8d1ac07801276551d7a82790f0ba1220c150eefffbcd199205d44277c39fa6bb42102baf3839256646cb1241094e9910
6
+ metadata.gz: 8f2fa6e2d4c94a18cc6cffae2e1f70cc6c5f9feefb07ab5135d4beb43c4df53cc923486341952cc9768c8b5e451402c10ade270edd0d6bdffe41ff188765b62b
7
+ data.tar.gz: 88fb5229c05d5f6679c6c54c48364784853827a40e64a3d115d222b461f152e32b3638531e41e62d0acf96aa3976c956d749114933e0dba2c8720431e6309e6a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vulcano (0.4.0)
4
+ vulcano (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -23,9 +23,11 @@ Or install it yourself as:
23
23
  ## Usage
24
24
 
25
25
  ```bash
26
- vulcano json_path [output_folder]
26
+ vulcano json_path [options]
27
27
  ```
28
28
 
29
+ use `vulcano --help` to see the whole options list
30
+
29
31
  #### Examples
30
32
 
31
33
  ```
@@ -1,3 +1,3 @@
1
1
  module Vulcano
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/vulcano.rb CHANGED
@@ -3,16 +3,37 @@ require "vulcano/json_reader"
3
3
  require "vulcano/codable_generator"
4
4
  require "json"
5
5
  require "erb"
6
+ require 'optparse'
6
7
 
7
8
  module Vulcano
8
9
  class Main
9
10
  def start
10
11
  raise RuntimeError, 'The script has to be called with a JSON path' unless ARGV.length > 0
11
12
 
13
+ options = parse_options()
14
+
12
15
  json_path = ARGV[0]
13
- destination_folder = ARGV[1].nil? ? "." : ARGV[1]
16
+ destination_folder = options[:destination_folder].nil? ? "." : options[:destination_folder]
14
17
  json = JsonReader.new.read_from_file(json_path)
15
- CodableGenerator.new.generate_codable_file(json, destination_folder)
18
+ CodableGenerator.new.generate_codable_file(json, destination_folder, options[:class_name])
19
+ end
20
+
21
+ def parse_options
22
+ options = {}
23
+
24
+ OptionParser.new do |opts|
25
+ opts.banner = "Usage: vulcano json_path [options]"
26
+
27
+ opts.on("-d", "--destination-folder DESTINATION_FOLDER", String, "Destination folder for the generated source") do |destination_folder|
28
+ options[:destination_folder] = destination_folder
29
+ end
30
+
31
+ opts.on("-n", "--class-name CLASS_NAME", String, "Name for the generated class (the default name is 'Generated')") do |class_name|
32
+ options[:class_name] = class_name
33
+ end
34
+ end.parse!
35
+
36
+ return options
16
37
  end
17
38
  end
18
39
  end
@@ -1,3 +1,9 @@
1
+ //
2
+ // <%= @name %>.swift
3
+ //
4
+ // Generated with Vulcano https://rubygems.org/gems/vulcano/.
5
+ //
6
+
1
7
  class <%= @name %>: Codable {<% for @variable in @variables %>
2
8
  var <%= @variable.name %>: <%= @variable.type %><% end %><% if (@codable_keys != nil) then %>
3
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vulcano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Meloni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-12 00:00:00.000000000 Z
11
+ date: 2018-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler