kilza 1.0.4 → 1.0.6
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 +4 -4
- data/.coveralls.yml +1 -0
- data/README.md +3 -1
- data/bin/kilza +4 -6
- data/lib/kilza/class.rb +33 -12
- data/lib/kilza/language.rb +7 -3
- data/lib/kilza/language/java/java.erb +6 -2
- data/lib/kilza/property.rb +8 -0
- data/lib/kilza/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17f4a3986407598ff9c51551d15cb3dedc01c934
|
4
|
+
data.tar.gz: d18285c8fdf2e363b21ad71941d98d45ce9387e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b85a49727c028294a2a9f716bf77f23ec22d1f028f023e534646fd8b6fc41edb84d9bc7497936966e9c6fa4adb42401f89522ff9df375ceadf51ed6f4dffecd
|
7
|
+
data.tar.gz: 716bcd6688ca12ac7490b54080800d967075a42e463f1c39dc41cdd22c0cfd5681ff1eff6d11eab2391120eed04d637a7356896a4c2a6dffe8f16606152f1d32
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# Kilza
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/kilza)
|
4
|
+
|
3
5
|
[](https://travis-ci.org/Jaspion/Kilza)
|
4
6
|
|
5
|
-
[](https://coveralls.io/github/Jaspion/Kilza?branch=master)
|
6
8
|
|
7
9
|
[](http://inch-ci.org/github/jaspion/kilza)
|
8
10
|
|
data/bin/kilza
CHANGED
@@ -58,7 +58,7 @@ class KilzaApplication
|
|
58
58
|
|
59
59
|
json_string = ''
|
60
60
|
if (action == 1)
|
61
|
-
url = @prompt.ask(@pastel.bold('Please, what is the URL?')) do |q|
|
61
|
+
url = @prompt.ask(@pastel.bold('Please, what is the URL? ')) do |q|
|
62
62
|
q.required true
|
63
63
|
end
|
64
64
|
@prompt.say(@pastel.bold('Ok. I\'ll try to get the content right now.'))
|
@@ -105,8 +105,9 @@ class KilzaApplication
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def run
|
108
|
+
@prompt.say(@pastel.bold('Kilza - v' + Kilza::VERSION))
|
108
109
|
while (not @done)
|
109
|
-
action = @prompt.select(@pastel.bold('
|
110
|
+
action = @prompt.select(@pastel.bold('Master, what can I do for you?')) do |menu|
|
110
111
|
menu.default 1
|
111
112
|
menu.enum '.'
|
112
113
|
|
@@ -127,11 +128,8 @@ class KilzaApplication
|
|
127
128
|
if not class_package.nil?
|
128
129
|
@prompt.say(@pastel.bold('Target package: ') + class_package)
|
129
130
|
end
|
130
|
-
ok = @prompt.yes?('Is that correct?')
|
131
|
+
ok = @prompt.yes?('Is that correct? ')
|
131
132
|
if ok.nil? or ok
|
132
|
-
@prompt.say(@pastel.bold('Yes master. Now I\'m going to generate all files.'))
|
133
|
-
@prompt.say(@pastel.bold('Berebekan Katabamba Berebekan Katabamba Berebekan Katabamba'))
|
134
|
-
|
135
133
|
generate(lang, json_string, class_basename, target_path, class_package)
|
136
134
|
|
137
135
|
@prompt.say(@pastel.bold('Kikera!'))
|
data/lib/kilza/class.rb
CHANGED
@@ -11,34 +11,38 @@ module Kilza
|
|
11
11
|
# Array with all class properties
|
12
12
|
attr_accessor :properties
|
13
13
|
|
14
|
+
# Initializes a Class object
|
15
|
+
#
|
16
|
+
# @param name [String] Class Name
|
14
17
|
def initialize(name)
|
15
18
|
@name = Kilza.normalize(name).capitalize
|
16
19
|
@properties = []
|
17
20
|
@imports = []
|
18
21
|
end
|
19
22
|
|
20
|
-
# Search for a property by name
|
21
|
-
#
|
22
|
-
# @param name [String] Property name
|
23
|
-
#
|
24
|
-
# @return [Kilza::Property] The property found or nil
|
25
|
-
def find(name)
|
26
|
-
@properties.each { |p| return p if p.name == name }
|
27
|
-
nil
|
28
|
-
end
|
29
|
-
|
30
23
|
# Adds a new property
|
31
24
|
#
|
32
25
|
# @param property [Kilza::Property] Property to include
|
33
26
|
def push(property)
|
34
|
-
|
35
|
-
|
27
|
+
index = @properties.index(property)
|
28
|
+
if !index.nil?
|
29
|
+
current = @properties[index]
|
30
|
+
@properties[index] = update(current, property)
|
31
|
+
else
|
32
|
+
@properties.push(property)
|
33
|
+
end
|
36
34
|
end
|
37
35
|
|
38
36
|
def sources
|
39
37
|
fail 'It should be implemented'
|
40
38
|
end
|
41
39
|
|
40
|
+
# Returns the #Source object of this Class.
|
41
|
+
#
|
42
|
+
# @param lang [String] Language name (java, objc, ...)
|
43
|
+
# @param file_name [String] Source file name
|
44
|
+
#
|
45
|
+
# @return [Kilza::Source] Source object of this Class
|
42
46
|
def code(lang, file_name)
|
43
47
|
cur_path = File.expand_path(__FILE__)
|
44
48
|
erb_path = File.join(File.dirname(cur_path), 'language', lang)
|
@@ -61,5 +65,22 @@ module Kilza
|
|
61
65
|
properties: properties
|
62
66
|
}.to_s
|
63
67
|
end
|
68
|
+
|
69
|
+
protected
|
70
|
+
|
71
|
+
# Compares two properties and fill the src property with relevant
|
72
|
+
# dst property values. If src.type is nilclass and dst.type not, replaces
|
73
|
+
# it with dst.type
|
74
|
+
#
|
75
|
+
# @param property [Kilza::Property] Property to include
|
76
|
+
#
|
77
|
+
# @return [Kilza::Property] src property with new values
|
78
|
+
def update(src, dst)
|
79
|
+
src.type = dst.type if src.null? && !dst.null?
|
80
|
+
src.original_type = dst.original_type if src.null? && !dst.null?
|
81
|
+
src.array = dst.array unless src.array?
|
82
|
+
src.key = dst.key unless src.key
|
83
|
+
src
|
84
|
+
end
|
64
85
|
end
|
65
86
|
end
|
data/lib/kilza/language.rb
CHANGED
@@ -43,6 +43,7 @@ module Kilza
|
|
43
43
|
hash = JSON.parse(json_string)
|
44
44
|
hash = { base_name + 'Object' => hash } if hash.is_a?(Array)
|
45
45
|
parse_hash(base_name, hash)
|
46
|
+
|
46
47
|
@classes
|
47
48
|
end
|
48
49
|
|
@@ -69,7 +70,7 @@ module Kilza
|
|
69
70
|
# @return [Kilza::Property] new property
|
70
71
|
def property(name, type, array, key)
|
71
72
|
name = @reserved_delimiter + name unless @reserved_words.index(name).nil?
|
72
|
-
Property.new(name, type, array, key
|
73
|
+
Property.new(name, type, array, key)
|
73
74
|
end
|
74
75
|
|
75
76
|
# Searches for a Kilza::Class inside @classes
|
@@ -85,7 +86,7 @@ module Kilza
|
|
85
86
|
@classes.last
|
86
87
|
end
|
87
88
|
|
88
|
-
# Parses an element value an verify if it should create a new
|
89
|
+
# Parses an element value an verify if it should create a new Classs
|
89
90
|
# inside @classes
|
90
91
|
#
|
91
92
|
# @param class_name [String] Name of the class the element is inside
|
@@ -98,9 +99,12 @@ module Kilza
|
|
98
99
|
return parse_array(class_name, name, value) if type == 'array'
|
99
100
|
|
100
101
|
cur_class = find(class_name)
|
101
|
-
key = @equal_keys.index(name)
|
102
|
+
key = @equal_keys.index(name).nil? ? false : true
|
102
103
|
cur_class.push(property(name, type, array, key))
|
103
104
|
|
105
|
+
# if value is nil, consider it as an Object
|
106
|
+
find(name) if type == 'nilclass'
|
107
|
+
|
104
108
|
parse_hash(name, value) if type == 'hash'
|
105
109
|
end
|
106
110
|
|
@@ -99,8 +99,12 @@ public class <%= @name %> implements Serializable
|
|
99
99
|
@eq = []
|
100
100
|
@hs = []
|
101
101
|
for @property in @properties
|
102
|
-
|
103
|
-
|
102
|
+
if @property.boolean?
|
103
|
+
@eq.push("((#{@name}) obj).is#{@property.name.capitalize}().equals(#{@property.name})") if @property.key?
|
104
|
+
else
|
105
|
+
@eq.push("((#{@name}) obj).get#{@property.name.capitalize}().equals(#{@property.name})") if @property.key?
|
106
|
+
end
|
107
|
+
@hs.push("#{@property.name}.hashCode()") if @property.key?
|
104
108
|
end
|
105
109
|
%>
|
106
110
|
<% if @eq.length > 0 %>
|
data/lib/kilza/property.rb
CHANGED
@@ -11,6 +11,9 @@ module Kilza
|
|
11
11
|
|
12
12
|
# Ruby string type
|
13
13
|
# Can be object, fixnum, float, falseclass, trueclass and nilclass
|
14
|
+
attr_accessor :original_type
|
15
|
+
|
16
|
+
# Property type name
|
14
17
|
attr_accessor :type
|
15
18
|
|
16
19
|
# Indicates if the property represents an array of objects
|
@@ -20,6 +23,7 @@ module Kilza
|
|
20
23
|
# Indicates if the property should be used for comparing purposes
|
21
24
|
# Used to compare if one object is equal to another one
|
22
25
|
attr_accessor :key
|
26
|
+
alias_method :key?, :key
|
23
27
|
|
24
28
|
def initialize(name, type, array, key)
|
25
29
|
@name = Kilza.normalize(name)
|
@@ -50,6 +54,10 @@ module Kilza
|
|
50
54
|
@original_type == 'nilclass'
|
51
55
|
end
|
52
56
|
|
57
|
+
def ==(pr)
|
58
|
+
@name == pr.name
|
59
|
+
end
|
60
|
+
|
53
61
|
def to_s
|
54
62
|
{
|
55
63
|
name: @name,
|
data/lib/kilza/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kilza
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toshiro Sugii
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -145,6 +145,7 @@ executables:
|
|
145
145
|
extensions: []
|
146
146
|
extra_rdoc_files: []
|
147
147
|
files:
|
148
|
+
- .coveralls.yml
|
148
149
|
- .gitignore
|
149
150
|
- .travis.yml
|
150
151
|
- CODE_OF_CONDUCT.md
|