kilza 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/kilza +105 -85
- data/kilza.gemspec +4 -3
- data/lib/kilza/language/java.rb +5 -0
- data/lib/kilza/language/java/java.erb +3 -3
- data/lib/kilza/property.rb +1 -1
- data/lib/kilza/version.rb +1 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19afa4576243d4b81618c7a96e3fcfc171d1e40c
|
4
|
+
data.tar.gz: 5ebd96dd828845962476cd04e9d9b1c5f2c581e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7359efe86778e41c19a07fbd9b2e7719d73db4626c4630f1944d9ba4ab4c4576efd9c4155f5d88cdb3f720012617b4bb3a8d0ad9b88f8db6178fc131a931a2e5
|
7
|
+
data.tar.gz: 08bbb522b1b72075a981a2accd3ea2d4db85629cf417d0c22eb4f871bbb5d14428322f99297e78b0941788ce467d2a8610b894ba42efd7c54bf4f8e67e54c09e
|
data/bin/kilza
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require 'highline'
|
5
4
|
require 'kilza'
|
5
|
+
require 'pastel'
|
6
|
+
require 'tty'
|
7
|
+
require 'tty-prompt'
|
8
|
+
require 'tty-spinner'
|
6
9
|
require 'net/http'
|
7
10
|
require 'uri'
|
8
11
|
|
@@ -10,101 +13,118 @@ def read_url(url)
|
|
10
13
|
Net::HTTP.get(URI.parse(url))
|
11
14
|
end
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
cli.choose do |menu|
|
20
|
-
menu.prompt = ""
|
21
|
-
menu.choice("I want some JSON objects.") {
|
22
|
-
}
|
23
|
-
menu.choice("Nothing.") {
|
24
|
-
break
|
25
|
-
}
|
16
|
+
module TTY
|
17
|
+
class Prompt
|
18
|
+
class List
|
19
|
+
def numpad(value)
|
20
|
+
@numpad = value
|
21
|
+
end
|
26
22
|
end
|
23
|
+
end
|
24
|
+
end
|
27
25
|
|
28
|
-
|
29
|
-
cli.say "<%= color('\nWhere is your JSON string content?', BOLD) %>"
|
30
|
-
cli.choose do |menu|
|
31
|
-
menu.prompt = ""
|
32
|
-
menu.choice("It's online. I have an URL.") {
|
33
|
-
json_is_url = true
|
34
|
-
}
|
35
|
-
menu.choice("It's offline. I have the file path.") { cli.say("Ok.") }
|
36
|
-
end
|
26
|
+
class KilzaApplication
|
37
27
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
json_string = read_url(url)
|
43
|
-
else
|
44
|
-
file_path = cli.ask ("<%= color('\nPlease, what is the file path?', BOLD) %>")
|
45
|
-
json_string = File.read(file_path)
|
46
|
-
end
|
28
|
+
def initialize
|
29
|
+
@pastel = Pastel.new
|
30
|
+
@prompt = TTY::Prompt.new
|
31
|
+
@spinner = TTY::Spinner.new
|
47
32
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
class_basename = cli.ask "<%= color('\nMaster, which name would like to call the first class?', BOLD) %>"
|
52
|
-
|
53
|
-
target_lang = ''
|
54
|
-
cli.say("<%= color('\nPlease choose your target programming language?', BOLD) %>")
|
55
|
-
cli.choose do |menu|
|
56
|
-
menu.prompt = ""
|
57
|
-
menu.choice("Objective-C") {
|
58
|
-
target_lang = "objc"
|
59
|
-
}
|
60
|
-
menu.choice("Java") {
|
61
|
-
target_lang = "java"
|
62
|
-
}
|
63
|
-
end
|
33
|
+
@done = false
|
34
|
+
end
|
64
35
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
menu.
|
72
|
-
menu.choice("Yes.") {
|
73
|
-
}
|
74
|
-
menu.choice("No.") {
|
75
|
-
break
|
76
|
-
}
|
36
|
+
def get_lang
|
37
|
+
action = @prompt.select(@pastel.bold("Target programming language?")) do |menu|
|
38
|
+
menu.default 1
|
39
|
+
menu.numpad true
|
40
|
+
|
41
|
+
menu.choice "Objective-C", 1
|
42
|
+
menu.choice "Java", 2
|
77
43
|
end
|
44
|
+
action
|
45
|
+
end
|
78
46
|
|
79
|
-
|
80
|
-
|
47
|
+
def get_json
|
48
|
+
action = @prompt.select(@pastel.bold("Where is your JSON string content?")) do |menu|
|
49
|
+
menu.default 1
|
50
|
+
menu.numpad true
|
81
51
|
|
82
|
-
|
83
|
-
|
84
|
-
objc.classes(class_basename).each { |c|
|
85
|
-
c.sources.each{ |s|
|
86
|
-
File.write(File.join(target_path, s.file_name), s.source)
|
87
|
-
}
|
88
|
-
}
|
89
|
-
else
|
90
|
-
java = Kilza::Java.new(json_string)
|
91
|
-
java.classes(class_basename).each { |c|
|
92
|
-
c.sources.each{ |s|
|
93
|
-
File.write(File.join(target_path, s.file_name), s.source)
|
94
|
-
}
|
95
|
-
}
|
52
|
+
menu.choice "It's online. I have an URL.", 1
|
53
|
+
menu.choice "It's offline. I have the file path.", 2
|
96
54
|
end
|
97
55
|
|
98
|
-
|
56
|
+
json_string = ''
|
57
|
+
if (action == 1)
|
58
|
+
url = @prompt.ask(@pastel.bold("Please, what is the URL?")) do |q|
|
59
|
+
q.required true
|
60
|
+
end
|
61
|
+
@prompt.say(@pastel.bold("Ok. I'll try to get the content right now."))
|
62
|
+
json_string = read_url(url)
|
63
|
+
else
|
64
|
+
file_path = File.expand_path(@prompt.ask(@pastel.bold("Please, what is the file path? "))) do |q|
|
65
|
+
q.required true
|
66
|
+
end
|
67
|
+
json_string = File.read(file_path.chomp)
|
68
|
+
end
|
69
|
+
json_string
|
70
|
+
end
|
99
71
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
72
|
+
def run
|
73
|
+
while (not @done)
|
74
|
+
action = @prompt.select(@pastel.bold("Choose your destiny?")) do |menu|
|
75
|
+
menu.default 1
|
76
|
+
menu.numpad true
|
77
|
+
|
78
|
+
menu.choice 'I want some JSON objects.', 1
|
79
|
+
menu.choice 'Nothing.', 2
|
80
|
+
end
|
81
|
+
if action == 1
|
82
|
+
json_string = get_json
|
83
|
+
target_path = @prompt.ask(@pastel.bold("Master, where would you like to save? ")).chomp
|
84
|
+
target_path = File.expand_path(target_path)
|
85
|
+
class_basename = @prompt.ask(@pastel.bold("Master, which name would like to call the first class? ")).chomp
|
86
|
+
lang = get_lang
|
87
|
+
|
88
|
+
class_package = nil
|
89
|
+
if (lang == 2)
|
90
|
+
class_package = @prompt.ask(@pastel.bold("What is the target Java package? ")).chomp
|
91
|
+
end
|
92
|
+
|
93
|
+
@prompt.say(@pastel.bold("Target: ") + target_path)
|
94
|
+
@prompt.say(@pastel.bold("Base class name: ") + class_basename)
|
95
|
+
@prompt.say(@pastel.bold("Target language: ") + (lang == 1 ? 'Objective-C' : 'Java'))
|
96
|
+
if (not class_package.nil?)
|
97
|
+
@prompt.say(@pastel.bold("Target package: ") + class_package)
|
98
|
+
end
|
99
|
+
ok = @prompt.yes?('Is that correct?')
|
100
|
+
if (ok.nil? or ok)
|
101
|
+
@prompt.say(@pastel.bold("Yes master. Now I'm going to generate all files."))
|
102
|
+
@prompt.say(@pastel.bold("Berebekan Katabamba Berebekan Katabamba Berebekan Katabamba"))
|
103
|
+
|
104
|
+
if (lang == 1)
|
105
|
+
objc = Kilza::Objc.new(json_string)
|
106
|
+
objc.classes(class_basename).each { |c|
|
107
|
+
c.sources.each{ |s|
|
108
|
+
File.write(File.join(target_path, s.file_name), s.source)
|
109
|
+
}
|
110
|
+
}
|
111
|
+
else
|
112
|
+
java = Kilza::Java.new(json_string)
|
113
|
+
java.classes(class_basename).each { |c|
|
114
|
+
c.package = class_package
|
115
|
+
c.sources.each{ |s|
|
116
|
+
File.write(File.join(target_path, s.file_name), s.source)
|
117
|
+
}
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
@prompt.say(@pastel.bold("Kikera!"))
|
122
|
+
end
|
123
|
+
else
|
124
|
+
@done = true
|
125
|
+
end
|
126
|
+
end
|
106
127
|
end
|
107
128
|
end
|
108
129
|
|
109
|
-
|
110
|
-
exit
|
130
|
+
KilzaApplication.new.run
|
data/kilza.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Toshiro Sugii"]
|
10
10
|
spec.email = ["rtoshiro@printwtf.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{Parses JSON objects and generates objects
|
13
|
-
spec.description = %q{Parses JSON objects and generates objects
|
12
|
+
spec.summary = %q{Parses JSON objects and generates objects into other languages}
|
13
|
+
spec.description = %q{Parses JSON objects and generates objects into other languages}
|
14
14
|
spec.homepage = "https://github.com/Jaspion/Kilza"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
@@ -33,5 +33,6 @@ Gem::Specification.new do |spec|
|
|
33
33
|
|
34
34
|
spec.add_dependency "json"
|
35
35
|
spec.add_dependency "erubis"
|
36
|
-
spec.add_dependency "
|
36
|
+
spec.add_dependency "tty"
|
37
|
+
spec.add_dependency "pastel"
|
37
38
|
end
|
data/lib/kilza/language/java.rb
CHANGED
@@ -8,6 +8,11 @@ module Kilza
|
|
8
8
|
|
9
9
|
attr_accessor :package
|
10
10
|
|
11
|
+
def initialize(name, package = nil)
|
12
|
+
super(name)
|
13
|
+
@package = package
|
14
|
+
end
|
15
|
+
|
11
16
|
def sources
|
12
17
|
cur_path = File.expand_path(__FILE__)
|
13
18
|
java_path = File.join(File.dirname(cur_path), File.basename(cur_path, '.rb'), "java.erb")
|
@@ -80,14 +80,14 @@ public class <%= @name %> implements Serializable
|
|
80
80
|
}
|
81
81
|
|
82
82
|
<% for @property in @properties %>
|
83
|
-
public void set<%= @property.name.capitalize %>(<%= @property.type %> value) {
|
83
|
+
public void set<%= @property.name.capitalize %>(<%= @property.is_array? ? "ArrayList<" + @property.type + ">" : @property.type %> value) {
|
84
84
|
this.<%= @property.name %> = value;
|
85
85
|
}
|
86
86
|
|
87
87
|
<% if @property.is_boolean? %>
|
88
88
|
public <%= @property.type %> is<%= @property.name.capitalize %>() {
|
89
89
|
<% else %>
|
90
|
-
public <%= @property.type %> get<%= @property.name.capitalize %>() {
|
90
|
+
public <%= @property.is_array? ? "ArrayList<" + @property.type + ">" : @property.type %> get<%= @property.name.capitalize %>() {
|
91
91
|
<% end %>
|
92
92
|
return this.<%= @property.name %>;
|
93
93
|
}
|
@@ -98,7 +98,7 @@ public class <%= @name %> implements Serializable
|
|
98
98
|
@hs = []
|
99
99
|
for @property in @properties
|
100
100
|
@eq.push("((#{@name}) obj).get#{@property.name.capitalize}().equals(#{@property.name})") if (@property.is_key)
|
101
|
-
@hs.push("(
|
101
|
+
@hs.push("(#{@property.name}).hashCode()") if (@property.is_key)
|
102
102
|
end
|
103
103
|
%>
|
104
104
|
<% if @eq.length > 0 %>
|
data/lib/kilza/property.rb
CHANGED
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.2
|
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-01-
|
11
|
+
date: 2016-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: tty
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - '>='
|
@@ -94,7 +94,21 @@ dependencies:
|
|
94
94
|
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pastel
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Parses JSON objects and generates objects into other languages
|
98
112
|
email:
|
99
113
|
- rtoshiro@printwtf.com
|
100
114
|
executables:
|
@@ -148,5 +162,5 @@ rubyforge_project:
|
|
148
162
|
rubygems_version: 2.0.14
|
149
163
|
signing_key:
|
150
164
|
specification_version: 4
|
151
|
-
summary: Parses JSON objects and generates objects
|
165
|
+
summary: Parses JSON objects and generates objects into other languages
|
152
166
|
test_files: []
|