rubigen 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.3.1 2008-04-25
2
+
3
+ * Fixed the require statements in generated tests for rails/merb generators
4
+ * Rails::Generator::Base is a valid generator superclass
5
+ * Rails generators have alternate template (based on standard NamedBase)
6
+ * test helpers define RAILS_ROOT for rails generators
7
+
1
8
  == 1.3.0 2008-04-25
2
9
 
3
10
  * component_generator: specific subclasses for rails + merb generators,
data/Manifest.txt CHANGED
@@ -44,6 +44,7 @@ rubygems_generators/application_generator/templates/usage
44
44
  rubygems_generators/component_generator/USAGE
45
45
  rubygems_generators/component_generator/component_generator_generator.rb
46
46
  rubygems_generators/component_generator/templates/generator.rb
47
+ rubygems_generators/component_generator/templates/rails_generator.rb
47
48
  rubygems_generators/component_generator/templates/readme
48
49
  rubygems_generators/component_generator/templates/test.rb
49
50
  rubygems_generators/component_generator/templates/test_generator_helper.rb
data/lib/rubigen/spec.rb CHANGED
@@ -27,11 +27,11 @@ module RubiGen
27
27
  def class_name
28
28
  "#{name.camelize}Generator"
29
29
  end
30
-
30
+
31
31
  def usage_file
32
32
  "#{path}/USAGE"
33
33
  end
34
-
34
+
35
35
  def visible?
36
36
  File.exists? usage_file
37
37
  end
@@ -41,10 +41,30 @@ module RubiGen
41
41
  # whose name matches the requested class name.
42
42
  def lookup_class
43
43
  ObjectSpace.each_object(Class) do |obj|
44
- return obj if obj.ancestors.include?(RubiGen::Base) and
44
+ return obj if valid_superclass?(obj) and
45
45
  obj.name.split('::').last == class_name
46
46
  end
47
47
  raise NameError, "Missing #{class_name} class in #{class_file}"
48
48
  end
49
+
50
+ def valid_superclass?(obj)
51
+ valid_generator_superclasses.each do |klass|
52
+ return true if obj.ancestors.include?(klass)
53
+ end
54
+ false
55
+ end
56
+
57
+ def valid_generator_superclasses
58
+ @valid_generator_superclasses ||= [
59
+ "RubiGen::Base",
60
+ "Rails::Generator::Base"
61
+ ].inject([]) do |list, class_name|
62
+ klass = class_name.split("::").inject(Object) do |klass, name|
63
+ klass.const_get(name) rescue nil
64
+ end
65
+ list << klass if klass
66
+ list
67
+ end
68
+ end
49
69
  end
50
70
  end
@@ -2,7 +2,7 @@ module Rubigen #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 3
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -14,6 +14,11 @@ if defined?(APP_ROOT)
14
14
  else
15
15
  APP_ROOT = app_root
16
16
  end
17
+ if defined?(RAILS_ROOT)
18
+ RAILS_ROOT.replace(app_root)
19
+ else
20
+ RAILS_ROOT = app_root
21
+ end
17
22
 
18
23
  begin
19
24
  require 'rubigen'
@@ -23,7 +23,7 @@ class ComponentGeneratorGenerator < RubiGen::Base
23
23
  m.directory "test"
24
24
 
25
25
  # Generator stub
26
- m.template "generator.rb", "#{path}/#{name}_generator.rb"
26
+ m.template generator, "#{path}/#{name}_generator.rb"
27
27
  m.template "test.rb", "test/test_#{name}_generator.rb"
28
28
  m.file "test_generator_helper.rb", "test/test_generator_helper.rb"
29
29
  m.file "usage", "#{path}/USAGE"
@@ -31,6 +31,15 @@ class ComponentGeneratorGenerator < RubiGen::Base
31
31
  end
32
32
  end
33
33
 
34
+ def generator
35
+ case (generator_type.to_sym rescue nil)
36
+ when :rails
37
+ "rails_generator.rb"
38
+ else
39
+ "generator.rb"
40
+ end
41
+ end
42
+
34
43
  def superclass_name
35
44
  case (generator_type.to_sym rescue nil)
36
45
  when :rails
@@ -42,6 +51,17 @@ class ComponentGeneratorGenerator < RubiGen::Base
42
51
  end
43
52
  end
44
53
 
54
+ def superclass_requirement
55
+ case (generator_type.to_sym rescue nil)
56
+ when :rails
57
+ ["rails_generator"]
58
+ when :merb
59
+ ["merb-core", "merb-gen"]
60
+ else
61
+ []
62
+ end
63
+ end
64
+
45
65
  protected
46
66
  def banner
47
67
  <<-EOS
@@ -0,0 +1,21 @@
1
+ class <%= class_name %> < <%= superclass_name %>
2
+ def manifest
3
+ record do |m|
4
+ # Ensure appropriate folder(s) exists
5
+ m.directory 'some_folder'
6
+
7
+ # Create stubs
8
+ # m.template "template.rb", "some_file_after_erb.rb"
9
+ # m.file "file", "some_file_copied"
10
+ end
11
+ end
12
+
13
+ protected
14
+ def banner
15
+ <<-EOS
16
+ Creates a ...
17
+
18
+ USAGE: #{$0} #{spec.name} name
19
+ EOS
20
+ end
21
+ end
@@ -1,13 +1,7 @@
1
1
  require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
2
 
3
- <% if generator_type.to_sym == :rails -%>
4
- module Rails; module Generator; end; end
5
- <% elsif generator_type.to_sym == :merb -%>
6
- module Merb; end
7
- <% end -%>
8
- <% if superclass_name != "RubiGen::Base" -%>
9
- class <%= superclass_name %> < RubiGen::Base
10
- end
3
+ <% for requirement in superclass_requirement -%>
4
+ require '<%= requirement %>'
11
5
  <% end -%>
12
6
 
13
7
  class Test<%= class_name %> < Test::Unit::TestCase
@@ -14,6 +14,11 @@ if defined?(APP_ROOT)
14
14
  else
15
15
  APP_ROOT = app_root
16
16
  end
17
+ if defined?(RAILS_ROOT)
18
+ RAILS_ROOT.replace(app_root)
19
+ else
20
+ RAILS_ROOT = app_root
21
+ end
17
22
 
18
23
  begin
19
24
  require 'rubigen'
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.0</a>
34
+ <a href="http://rubyforge.org/projects/rubigen" class="numbers">1.3.1</a>
35
35
  </div>
36
36
  <h1>Ruby Generator Framework</h1>
37
37
 
@@ -1,3 +1,3 @@
1
1
  // Announcement JS file
2
- var version = "1.3.0";
2
+ var version = "1.3.1";
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.0";
2
+ var version = "1.3.1";
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.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr Nic Williams
@@ -86,6 +86,7 @@ files:
86
86
  - rubygems_generators/component_generator/USAGE
87
87
  - rubygems_generators/component_generator/component_generator_generator.rb
88
88
  - rubygems_generators/component_generator/templates/generator.rb
89
+ - rubygems_generators/component_generator/templates/rails_generator.rb
89
90
  - rubygems_generators/component_generator/templates/readme
90
91
  - rubygems_generators/component_generator/templates/test.rb
91
92
  - rubygems_generators/component_generator/templates/test_generator_helper.rb