miso-java 0.1.4 → 0.1.5

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -12,10 +12,10 @@ if ARGV[0] == 'create' and ARGV.size == 2
12
12
  elsif ARGV.size >= 3 and ARGV[0] == 'scaffold'
13
13
  @task = 'scaffold'
14
14
  else
15
- puts "To start a new app: miso-java create puppyapp"
16
- puts "To create a scaffold: miso-java scaffold Puppy name breed owner cuteness\n\n"
17
- puts "Tools for good hacking: script/build, script/stop, script/start, script/restart\n\n"
18
- puts "=== Full documentation: See http://blog.paradoxica.net/post/401365886/hello-miso \n\n"
15
+ puts "To start a new app: miso-java create puppyapp"
16
+ puts "To create a scaffold: miso-java scaffold Puppy name breed owner cuteness"
17
+ puts "Tools for good hacking: script/build, script/stop, script/start, script/restart"
18
+ puts "Full documentation: See http://blog.paradoxica.net/post/401365886/hello-miso\n\n"
19
19
  Process.exit
20
20
  end
21
21
 
@@ -5,10 +5,13 @@ module MisoJava
5
5
 
6
6
  class << self
7
7
 
8
+ # Loads the Miso template files for code generation.
8
9
  def load_template(path)
9
10
  return load_file("#{TEMPLATES}/#{path}")
10
11
  end
12
+
11
13
 
14
+ # Loads the contents of a single file from disk.
12
15
  def load_file(path)
13
16
  contents = ""
14
17
  file = File.new(path, "r")
@@ -19,8 +22,11 @@ module MisoJava
19
22
  return contents
20
23
  end
21
24
 
25
+
26
+ # Main code generation happens here.
27
+ # Replace tokens in template files with app config data.
22
28
  def generate(template, model, columns)
23
-
29
+
24
30
  # Application Name
25
31
  appname = Dir.pwd.split('/').last
26
32
  template.gsub!('[[APPNAME]]', appname.downcase)
@@ -88,17 +94,15 @@ module MisoJava
88
94
 
89
95
  # SQL
90
96
  column_names = ""
91
- columns.each do |column|
92
- column_names += "`#{column}` varchar(255) DEFAULT NULL,\n"
93
- end
94
- template.gsub!('[[ColumnLinesForSQL]]', column_names)
95
-
97
+ columns.each { |column| column_names += "`#{column}` varchar(255) DEFAULT NULL,\n" }
98
+ template.gsub!('[[ColumnLinesForSQL]]', column_names)
96
99
  template.gsub!('[[PWD]]', Dir.pwd.split('/').last)
97
100
 
98
101
  return template
99
102
  end
100
103
 
101
-
104
+ # Starts a new application, copying the skeleton to a
105
+ # folder named based on the user's command line input.
102
106
  def create_app(args)
103
107
  puts "Creating application: #{ARGV[1]}\n\n"
104
108
  FileUtils.cp_r "#{BASE}/template/skeleton", 'miso-skeleton'
@@ -109,9 +113,16 @@ module MisoJava
109
113
  web_xml.gsub!('[[AppName]]', ARGV[1].capitalize).gsub!('[[AppNameLowercase]]', ARGV[1].downcase)
110
114
  File.open("#{ARGV[1]}/web.xml", 'w') {|f| f.write(web_xml) }
111
115
 
112
- # Update DB Name
116
+ # Update DB Config
117
+ puts "Please type the MySQL username to use:"
118
+ username = STDIN.gets.chomp
119
+
120
+ puts "Please type the MySQL password for this user:"
121
+ password = STDIN.gets.chomp
122
+
113
123
  model = load_file("#{ARGV[1]}/app/miso/Model.java")
114
124
  model.gsub!('localhost/miso', "localhost/#{ARGV[1].downcase}")
125
+ model.gsub!('url, "root", ""', 'url, "'+ username + '", "' + password + '"')
115
126
  File.open("#{ARGV[1]}/app/miso/Model.java", 'w') {|f| f.write(model) }
116
127
 
117
128
  # Update Header Template Paths
@@ -119,9 +130,12 @@ module MisoJava
119
130
  header.gsub!('[[APPNAME]]', "#{ARGV[1].downcase}")
120
131
  File.open("#{ARGV[1]}/app/views/includes/header.html", 'w') {|f| f.write(header) }
121
132
 
122
-
123
133
  # Generate scripts
124
134
  %w(build restart start stop).each { |script| generate_script(script, ARGV[1].downcase) }
135
+
136
+ puts "== Hello Miso! Your app is ready."
137
+ puts "Type 'cd #{ARGV[1]}', then 'miso-java' to start building your app!\n\n"
138
+
125
139
  end
126
140
 
127
141
  def generate_script(name, app)
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{miso-java}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["C. Scott Andreas"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miso-java
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - C. Scott Andreas