rubigen 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.3.2 2008-05-19
2
+
3
+ * app_gen/bin - includes #!/usr/bin/env ruby
4
+ * added examples of file_copy_each and template_copy_each to generators
5
+
1
6
  == 1.3.1 2008-04-25
2
7
 
3
8
  * Fixed the require statements in generated tests for rails/merb generators
@@ -155,7 +155,7 @@ module RubiGen
155
155
  # directories, renders templates, and more.
156
156
  class Create < Base
157
157
 
158
- # Check whether the given class names are already taken.
158
+ # Check whether the given class names are already taken.
159
159
  # In the future, expand to check other namespaces
160
160
  # such as the rest of the user's app.
161
161
  def class_collisions(*class_names)
@@ -191,7 +191,7 @@ module RubiGen
191
191
  # file 'config/empty.log', 'log/test.log', :chmod => 0664
192
192
  # :shebang sets the #!/usr/bin/ruby line for scripts
193
193
  # file 'bin/generate.rb', 'script/generate', :chmod => 0755, :shebang => '/usr/bin/env ruby'
194
- # :collision sets the collision option only for the destination file:
194
+ # :collision sets the collision option only for the destination file:
195
195
  # file 'settings/server.yml', 'config/server.yml', :collision => :skip
196
196
  #
197
197
  # Collisions are handled by checking whether the destination file
@@ -205,7 +205,7 @@ module RubiGen
205
205
 
206
206
  # If source and destination are identical then we're done.
207
207
  if destination_exists and identical?(source, destination, &block)
208
- return logger.identical(relative_destination)
208
+ return logger.identical(relative_destination)
209
209
  end
210
210
 
211
211
  # Check for and resolve file collisions.
@@ -259,7 +259,7 @@ module RubiGen
259
259
  file "#{path}#{file_name}", "#{path}#{file_name}", options
260
260
  end
261
261
  end
262
-
262
+
263
263
  def folder(template_path, path=nil, options = {})
264
264
  template_path = "/" if template_path.blank?
265
265
  source = source_path(template_path)
@@ -268,7 +268,7 @@ module RubiGen
268
268
  file "#{template_path}#{file_name}", "#{path}#{file_name}", options
269
269
  end
270
270
  end
271
-
271
+
272
272
  # Checks if the source and the destination file are identical. If
273
273
  # passed a block then the source file is a template that needs to first
274
274
  # be evaluated before being compared to the destination.
@@ -304,7 +304,7 @@ module RubiGen
304
304
  ERB.new(file.read, nil, '-').result(b)
305
305
  end
306
306
  end
307
-
307
+
308
308
  def template_copy_each(files, path = nil, options = {})
309
309
  path = path ? "#{path}/" : ""
310
310
  files.each do |file_name|
@@ -329,7 +329,7 @@ module RubiGen
329
329
  logger.create relative_path
330
330
  unless options[:pretend]
331
331
  FileUtils.mkdir_p(path)
332
-
332
+
333
333
  # Subversion doesn't do path adds, so we need to add
334
334
  # each directory individually.
335
335
  # So stack up the directory tree and add the paths to
@@ -362,8 +362,8 @@ module RubiGen
362
362
  files.reject! { |file| File.directory?(file) }
363
363
  files.map! { |path| path.sub("#{destination_root}/","") }
364
364
  files = files.uniq.sort
365
-
366
-
365
+
366
+
367
367
  destination = destination_path(relative_destination)
368
368
  destination_exists = File.exists?(destination)
369
369
 
@@ -380,7 +380,7 @@ module RubiGen
380
380
 
381
381
  # If we're pretending, back off now.
382
382
  return if options[:pretend]
383
-
383
+
384
384
  # Write destination file with optional shebang. Yield for content
385
385
  # if block given so templaters may render the source file. If a
386
386
  # shebang is requested, replace the existing shebang or insert a
@@ -392,7 +392,7 @@ module RubiGen
392
392
 
393
393
  # Optionally add file to subversion
394
394
  system("svn add #{destination}") if options[:svn]
395
-
395
+
396
396
  end
397
397
 
398
398
  # When creating a migration, it knows to find the first available file in db/migrate and use the migration.rb template.
@@ -484,7 +484,7 @@ end_message
484
484
  # If the directory is not in the status list, it
485
485
  # has no modifications so we can simply remove it
486
486
  system("svn rm #{destination}")
487
- end
487
+ end
488
488
  else
489
489
  FileUtils.rm(destination)
490
490
  end
@@ -593,7 +593,7 @@ end_message
593
593
  def readme(*args)
594
594
  logger.readme args.join(', ')
595
595
  end
596
-
596
+
597
597
  def migration_template(relative_source, relative_destination, options = {})
598
598
  migration_directory relative_destination
599
599
  logger.migration_template file_name
@@ -84,7 +84,7 @@ module RubiGen
84
84
  # It takes a name or symbol without the <tt>test_</tt> part and an optional super class.
85
85
  # the contents of the class source file is passed to a block.
86
86
  def assert_generated_test_for(name, parent="Test::Unit::TestCase")
87
- assert_generated_class "test/test_#{name.to_s.underscore}",parent do |body|
87
+ assert_generated_class "test/test_#{name.to_s.underscore}", parent do |body|
88
88
  yield body if block_given?
89
89
  end
90
90
  end
@@ -2,7 +2,7 @@ module Rubigen #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 3
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
1
3
  require 'rubygems'
2
4
  require 'rubigen'
3
5
 
@@ -1,12 +1,12 @@
1
1
  class <%= class_name %> < RubiGen::Base
2
-
2
+
3
3
  DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
4
4
  Config::CONFIG['ruby_install_name'])
5
-
5
+
6
6
  default_options :author => nil
7
-
7
+
8
8
  attr_reader :name
9
-
9
+
10
10
  def initialize(runtime_args, runtime_options = {})
11
11
  super
12
12
  usage if args.empty?
@@ -23,9 +23,11 @@ class <%= class_name %> < RubiGen::Base
23
23
 
24
24
  # Create stubs
25
25
  # m.template "template.rb", "some_file_after_erb.rb"
26
+ # m.template_copy_each ["template.rb", "template2.rb"]
26
27
  # m.file "file", "some_file_copied"
27
-
28
- m.dependency "install_rubigen_scripts", [destination_root, <%= scope_str %>],
28
+ # m.file_copy_each ["path/to/file", "path/to/file2"]
29
+
30
+ m.dependency "install_rubigen_scripts", [destination_root, <%= scope_str %>],
29
31
  :shebang => options[:shebang], :collision => :force
30
32
  end
31
33
  end
@@ -49,7 +51,7 @@ EOS
49
51
  # "Default: none") { |options[:author]| }
50
52
  opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
51
53
  end
52
-
54
+
53
55
  def extract_options
54
56
  # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
55
57
  # Templates can access these value via the attr_reader-generated methods, but not the
@@ -6,11 +6,11 @@ class Test<%= class_name %> < Test::Unit::TestCase
6
6
  def setup
7
7
  bare_setup
8
8
  end
9
-
9
+
10
10
  def teardown
11
11
  bare_teardown
12
12
  end
13
-
13
+
14
14
  # Some generator-related assertions:
15
15
  # assert_generated_file(name, &block) # block passed the file contents
16
16
  # assert_directory_exists(name)
@@ -24,19 +24,19 @@ class Test<%= class_name %> < Test::Unit::TestCase
24
24
  # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
25
25
  # bare_setup - place this in setup method to create the APP_ROOT folder for each test
26
26
  # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
27
-
27
+
28
28
  def test_generator_without_options
29
29
  run_generator('<%= name %>', [APP_ROOT], sources)
30
30
  assert_directory_exists "path/to/included/folder"
31
31
  assert_generated_file "path/to/included/folder/some_file"
32
32
  end
33
-
33
+
34
34
  private
35
35
  def sources
36
36
  [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
37
37
  ]
38
38
  end
39
-
39
+
40
40
  def generator_path
41
41
  "<%= generator_path %>"
42
42
  end
@@ -18,7 +18,9 @@ class <%= class_name %> < <%= superclass_name %>
18
18
 
19
19
  # Create stubs
20
20
  # m.template "template.rb", "some_file_after_erb.rb"
21
+ # m.template_copy_each ["template.rb", "template2.rb"]
21
22
  # m.file "file", "some_file_copied"
23
+ # m.file_copy_each ["path/to/file", "path/to/file2"]
22
24
  end
23
25
  end
24
26
 
data/website/index.html CHANGED
@@ -31,7 +31,7 @@
31
31
  <h1>rubigen</h1>
32
32
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/rubigen"; return false'>
33
33
  <p>Get Version</p>
34
- <a href="http://rubyforge.org/projects/rubigen" class="numbers">1.3.1</a>
34
+ <a href="http://rubyforge.org/projects/rubigen" class="numbers">1.3.2</a>
35
35
  </div>
36
36
  <h1>Ruby Generator Framework</h1>
37
37
 
@@ -365,7 +365,7 @@ script/generate component_generator
365
365
 
366
366
  <p>Comments are welcome. Send an email to <a href="mailto:drnicwilliams@gmail.com">Dr Nic Williams</a> via the <a href="http://groups.google.com/group/rubigen">forum</a></p>
367
367
  <p class="coda">
368
- <a href="drnicwilliams@gmail.com">Dr Nic Williams</a>, 5th March 2008<br>
368
+ <a href="drnicwilliams@gmail.com">Dr Nic Williams</a>, 19th May 2008<br>
369
369
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
370
370
  </p>
371
371
  </div>
@@ -1,3 +1,3 @@
1
1
  // Announcement JS file
2
- var version = "1.3.1";
2
+ var version = "1.3.2";
3
3
  MagicAnnouncement.show('compositekeys', version);
data/website/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // Version JS file
2
- var version = "1.3.1";
2
+ var version = "1.3.2";
3
3
 
4
4
  document.write(" - " + version);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubigen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr Nic Williams
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-04-25 00:00:00 +10:00
13
+ date: 2008-05-19 00:00:00 +10:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency