xamplr-gen 1.9.4 → 1.9.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ begin
13
13
  gem.add_development_dependency "cucumber", ">= 0"
14
14
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
15
 
16
- gem.add_dependency('xamplr', '>=1.9.2')
16
+ gem.add_dependency('xamplr', '>=1.9.3')
17
17
  end
18
18
  Jeweler::GemcutterTasks.new
19
19
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.4
1
+ 1.9.5
@@ -98,7 +98,7 @@ _EOF_
98
98
  mappings << [ ns, module_name, "ns#{ count }" ]
99
99
  end
100
100
 
101
- text = @@specialisation_file_content.gsub(/{{MAPPING}}/) do
101
+ text = @@specialisation_file_content.gsub(/{{MAPPING}}/) do
102
102
  insert = []
103
103
  mappings.each do | ns, module_name, prefix |
104
104
  insert << " ['#{ ns }', '#{ module_name }', '#{ prefix }'],"
@@ -132,9 +132,12 @@ _EOF_
132
132
  # Xampl.set_default_persister_format(:xml_format)
133
133
 
134
134
  dirname = self.directory
135
+
136
+ =begin
137
+
135
138
  if File.directory? dirname then
136
139
  begin
137
- FileUtils.rm_rf([ dirname ])
140
+ FileUtils.rm_rf([ dirname ])
138
141
  rescue => e
139
142
  puts "could not clean up #{ dirname } -- #{ e }"
140
143
  return
@@ -144,6 +147,8 @@ _EOF_
144
147
  return
145
148
  end
146
149
 
150
+ =end
151
+
147
152
  Xampl.transaction("project-generation") do
148
153
 
149
154
  options = Options.new do | opts |
@@ -162,80 +167,82 @@ _EOF_
162
167
  end
163
168
 
164
169
  generator = Generator.new('generator')
165
- generator.go(:options => options,
166
- :filenames => filenames,
167
- :directory => directory)
168
-
169
- puts generator.print_elements(print_base_filename, print_options)
170
- self.write_specialisation_file(generator.elements_map)
171
-
172
- generated_files = Dir.glob("#{ self.directory }/*.rb")
173
- if 0 < generated_files.size then
174
- all = []
175
- #abs = []
176
- generated_files.each do | filename |
177
- all << "require \"\#\{ File.dirname __FILE__ \}/#{ File.basename(filename, '.rb') }\""
178
- #all << "require '#{ File.dirname(filename)[2..-1] }/#{ File.basename(filename, '.rb') }'"
179
- #abs_filename = File.expand_path(filename)
180
- #abs << "require '#{ File.dirname(abs_filename) }/#{ File.basename(abs_filename, '.rb') }'"
181
- end
170
+ okay = generator.go(:options => options,
171
+ :filenames => filenames,
172
+ :directory => directory)
173
+
174
+ if okay
175
+ puts generator.print_elements(print_base_filename, print_options)
176
+ self.write_specialisation_file(generator.elements_map)
177
+
178
+ generated_files = Dir.glob("#{ self.directory }/*.rb")
179
+ if 0 < generated_files.size then
180
+ all = []
181
+ #abs = []
182
+ generated_files.each do | filename |
183
+ all << "require \"\#\{ File.dirname __FILE__ \}/#{ File.basename(filename, '.rb') }\""
184
+ #all << "require '#{ File.dirname(filename)[2..-1] }/#{ File.basename(filename, '.rb') }'"
185
+ #abs_filename = File.expand_path(filename)
186
+ #abs << "require '#{ File.dirname(abs_filename) }/#{ File.basename(abs_filename, '.rb') }'"
187
+ end
182
188
 
183
- out_filename = "#{ self.directory }/all.rb"
184
- File.open(out_filename, 'w') do | out |
185
- out.puts all.join("\n")
186
- end
187
- puts "WRITE TO FILE: #{ out_filename }"
188
-
189
- #out_filename = "#{ self.directory }/all-absolute.rb"
190
- #File.open(out_filename, 'w') do | out |
191
- # out.puts abs.join("\n")
192
- #end
193
- #puts "WRITE TO FILE: #{ out_filename }"
194
-
195
- if File.exists?('./generated.yuml') && (cl_options[:download_yuml_png] || cl_options[:download_yuml_pdf]) then
196
- diagram = ""
197
- File.open("./generated.yuml") do | f |
198
- f.each do | line |
189
+ out_filename = "#{ self.directory }/all.rb"
190
+ File.open(out_filename, 'w') do | out |
191
+ out.puts all.join("\n")
192
+ end
193
+ puts "WRITE TO FILE: #{ out_filename }"
194
+
195
+ #out_filename = "#{ self.directory }/all-absolute.rb"
196
+ #File.open(out_filename, 'w') do | out |
197
+ # out.puts abs.join("\n")
198
+ #end
199
+ #puts "WRITE TO FILE: #{ out_filename }"
200
+
201
+ if File.exists?('./generated.yuml') && (cl_options[:download_yuml_png] || cl_options[:download_yuml_pdf]) then
202
+ diagram = ""
203
+ File.open("./generated.yuml") do | f |
204
+ f.each do | line |
199
205
  diagram << line.chomp
206
+ end
200
207
  end
201
- end
202
208
 
203
209
 
204
- okay = false
205
- if cl_options[:download_yuml_png] then
206
- begin
207
- filename = (true == cl_options[:download_yuml_png]) ? 'generated.png' : cl_options[:download_yuml_png]
208
- wget = "wget 'http://yuml.me/diagram/scruffy/class/#{diagram}' -O '#{filename}'"
209
- okay = system(wget)
210
- if okay then
211
- puts "downloaded yuml png"
212
- else
213
- puts "could not get the yuml png file -- #{ $? }"
210
+ okay = false
211
+ if cl_options[:download_yuml_png] then
212
+ begin
213
+ filename = (true == cl_options[:download_yuml_png]) ? 'generated.png' : cl_options[:download_yuml_png]
214
+ wget = "wget 'http://yuml.me/diagram/scruffy/class/#{diagram}' -O '#{filename}'"
215
+ okay = system(wget)
216
+ if okay then
217
+ puts "downloaded yuml png"
218
+ else
219
+ puts "could not get the yuml png file -- #{ $? }"
220
+ end
221
+ rescue => e
222
+ puts "could not get the yuml png file -- #{ e }"
214
223
  end
215
- rescue => e
216
- puts "could not get the yuml png file -- #{ e }"
217
224
  end
218
- end
219
225
 
220
- if cl_options[:download_yuml_pdf] then
221
- begin
222
- filename = (true == cl_options[:download_yuml_png]) ? 'generated.png' : cl_options[:download_yuml_png]
223
- wget = "wget 'http://yuml.me/diagram/scruffy/class/#{diagram}.pdf' -O '#{filename}'"
224
- okay = system(wget)
225
- puts "downloaded yuml pdf"
226
- if okay then
226
+ if cl_options[:download_yuml_pdf] then
227
+ begin
228
+ filename = (true == cl_options[:download_yuml_png]) ? 'generated.png' : cl_options[:download_yuml_png]
229
+ wget = "wget 'http://yuml.me/diagram/scruffy/class/#{diagram}.pdf' -O '#{filename}'"
230
+ okay = system(wget)
227
231
  puts "downloaded yuml pdf"
228
- else
229
- puts "could not get the yuml pdf file -- #{ $? }"
232
+ if okay then
233
+ puts "downloaded yuml pdf"
234
+ else
235
+ puts "could not get the yuml pdf file -- #{ $? }"
236
+ end
237
+ rescue => e
238
+ puts "could not get the yuml pdf file -- #{ e }"
230
239
  end
231
- rescue => e
232
- puts "could not get the yuml pdf file -- #{ e }"
233
240
  end
234
241
  end
235
242
  end
236
243
  end
237
-
238
244
  Xampl.rollback
245
+
239
246
  end
240
247
  end
241
248
  end
@@ -211,10 +211,6 @@ module XamplGenerator
211
211
  end
212
212
 
213
213
  def generate(directory_name, params={:verbose => false}, &eval_context)
214
- if directory_name then
215
- FileUtils.mkdir_p(directory_name) unless File.exist?(directory_name)
216
- end
217
-
218
214
  ensure_templates
219
215
 
220
216
  module_names = Set.new
@@ -244,13 +240,35 @@ module XamplGenerator
244
240
  if element.class_name == element.package then
245
241
  puts "ERROR: Class #{ element.package } is in a module with the same name -- this NOT going to work"
246
242
  elsif module_names.member?(element.class_name)
247
- puts "WARNING: a Class and a Module have the same name (#{ element.package }) -- this is highly unlikely to work"
243
+ puts "WARNING: a Class and a Module have the same name (#{ element.package } or maybe #{ element.class_name }) -- this is highly unlikely to work"
248
244
  end
249
245
 
250
246
  @templates.child_modules(place)
251
247
  end
252
248
  end
253
249
 
250
+ unless @generated_package_map then
251
+ puts "Nothing to do. That is, NOTHING is generated. (Are you where you think you are?)"
252
+ return false
253
+ end
254
+
255
+ if File.directory? directory_name then
256
+ begin
257
+ FileUtils.rm_rf([ directory_name ])
258
+ rescue => e
259
+ puts "could not clean up #{ directory_name } -- #{ e }"
260
+ return
261
+ end
262
+ elsif File.exists? directory_name then
263
+ puts "please move #{ directory_name } out of the way of xampl-gen"
264
+ return
265
+ end
266
+
267
+ if directory_name then
268
+ FileUtils.mkdir_p(directory_name) unless File.exist?(directory_name)
269
+ end
270
+
271
+
254
272
  @elements_map.each do |ns, elements|
255
273
  elements.element_child.each do |element|
256
274
  place = find_place(directory_name, element.package)
@@ -290,6 +308,7 @@ module XamplGenerator
290
308
  end
291
309
 
292
310
  report_elements if params[:verbose]
311
+ return true
293
312
  end
294
313
 
295
314
  def report_elements
data/xamplr-gen.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{xamplr-gen}
8
- s.version = "1.9.4"
8
+ s.version = "1.9.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bob Hutchison"]
12
- s.date = %q{2010-01-20}
12
+ s.date = %q{2010-02-01}
13
13
  s.default_executable = %q{xampl-gen}
14
14
  s.description = %q{This is the xampl code generator for Ruby.}
15
15
  s.email = %q{hutch@xampl.com}
@@ -85,14 +85,14 @@ Gem::Specification.new do |s|
85
85
 
86
86
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
87
87
  s.add_development_dependency(%q<cucumber>, [">= 0"])
88
- s.add_runtime_dependency(%q<xamplr>, [">= 1.9.2"])
88
+ s.add_runtime_dependency(%q<xamplr>, [">= 1.9.3"])
89
89
  else
90
90
  s.add_dependency(%q<cucumber>, [">= 0"])
91
- s.add_dependency(%q<xamplr>, [">= 1.9.2"])
91
+ s.add_dependency(%q<xamplr>, [">= 1.9.3"])
92
92
  end
93
93
  else
94
94
  s.add_dependency(%q<cucumber>, [">= 0"])
95
- s.add_dependency(%q<xamplr>, [">= 1.9.2"])
95
+ s.add_dependency(%q<xamplr>, [">= 1.9.3"])
96
96
  end
97
97
  end
98
98
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xamplr-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.4
4
+ version: 1.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Hutchison
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-20 00:00:00 -05:00
12
+ date: 2010-02-01 00:00:00 -05:00
13
13
  default_executable: xampl-gen
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.9.2
33
+ version: 1.9.3
34
34
  version:
35
35
  description: This is the xampl code generator for Ruby.
36
36
  email: hutch@xampl.com