Class: ExtensionGenerator
- Inherits:
-
Rails::Generator::NamedBase
- Object
- Rails::Generator::NamedBase
- ExtensionGenerator
- Defined in:
- lib/generators/extension/extension_generator.rb
Instance Attribute Summary collapse
-
#extension_file_name ⇒ Object
readonly
Returns the value of attribute extension_file_name.
-
#extension_path ⇒ Object
readonly
Returns the value of attribute extension_path.
Instance Method Summary collapse
- #add_options!(opt) ⇒ Object
- #author_email ⇒ Object
- #author_info ⇒ Object
- #author_name ⇒ Object
- #class_name ⇒ Object
- #extension_name ⇒ Object
- #homepage ⇒ Object
-
#initialize(runtime_args, runtime_options = {}) ⇒ ExtensionGenerator
constructor
A new instance of ExtensionGenerator.
- #manifest ⇒ Object
Constructor Details
#initialize(runtime_args, runtime_options = {}) ⇒ ExtensionGenerator
Returns a new instance of ExtensionGenerator.
11 12 13 14 15 |
# File 'lib/generators/extension/extension_generator.rb', line 11 def initialize(runtime_args, = {}) super @extension_file_name = "#{file_name}_extension" @extension_path = "vendor/extensions/#{file_name}" end |
Instance Attribute Details
#extension_file_name ⇒ Object (readonly)
Returns the value of attribute extension_file_name.
9 10 11 |
# File 'lib/generators/extension/extension_generator.rb', line 9 def extension_file_name @extension_file_name end |
#extension_path ⇒ Object (readonly)
Returns the value of attribute extension_path.
9 10 11 |
# File 'lib/generators/extension/extension_generator.rb', line 9 def extension_path @extension_path end |
Instance Method Details
#add_options!(opt) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/generators/extension/extension_generator.rb', line 91 def (opt) opt.separator '' opt.separator 'Options:' opt.on("--with-test-unit", "Use Test::Unit for this extension instead of RSpec") { |v| [:with_test_unit] = v } end |
#author_email ⇒ Object
83 84 85 |
# File 'lib/generators/extension/extension_generator.rb', line 83 def ['user.email'] || 'your email' end |
#author_info ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/generators/extension/extension_generator.rb', line 71 def @author_info ||= begin Git.global_config rescue NameError {} end end |
#author_name ⇒ Object
87 88 89 |
# File 'lib/generators/extension/extension_generator.rb', line 87 def ['user.name'] || 'Your Name' end |
#class_name ⇒ Object
63 64 65 |
# File 'lib/generators/extension/extension_generator.rb', line 63 def class_name super.to_name.gsub(' ', '') + 'Extension' end |
#extension_name ⇒ Object
67 68 69 |
# File 'lib/generators/extension/extension_generator.rb', line 67 def extension_name class_name.to_name('Extension') end |
#homepage ⇒ Object
79 80 81 |
# File 'lib/generators/extension/extension_generator.rb', line 79 def homepage ['github.user'] ? "http://github.com/#{['github.user']}/radiant-#{file_name}-extension" : "http://example.com/#{file_name}" end |
#manifest ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/generators/extension/extension_generator.rb', line 17 def manifest record do |m| m.directory "#{extension_path}/app/controllers" m.directory "#{extension_path}/app/helpers" m.directory "#{extension_path}/app/models" m.directory "#{extension_path}/app/views" m.directory "#{extension_path}/config/locales" m.directory "#{extension_path}/config/initializers" m.directory "#{extension_path}/db/migrate" m.directory "#{extension_path}/lib/tasks" m.template 'README.md', "#{extension_path}/README.md" m.template 'extension.rb', "#{extension_path}/#{extension_file_name}.rb" m.template 'tasks.rake', "#{extension_path}/lib/tasks/#{extension_file_name}_tasks.rake" m.template 'en.yml', "#{extension_path}/config/locales/en.yml" m.template 'routes.rb', "#{extension_path}/config/routes.rb" m.template 'radiant_config.rb', "#{extension_path}/config/initializers/radiant_config.rb" m.template 'lib.rb', "#{extension_path}/lib/radiant-#{file_name}-extension.rb" m.template 'gemspec.rb', "#{extension_path}/radiant-#{file_name}-extension.gemspec" if [:with_test_unit] m.directory "#{extension_path}/test/fixtures" m.directory "#{extension_path}/test/functional" m.directory "#{extension_path}/test/unit" m.template 'Rakefile', "#{extension_path}/Rakefile" m.template 'test_helper.rb', "#{extension_path}/test/test_helper.rb" m.template 'functional_test.rb', "#{extension_path}/test/functional/#{extension_file_name}_test.rb" else m.directory "#{extension_path}/spec/controllers" m.directory "#{extension_path}/spec/models" m.directory "#{extension_path}/spec/views" m.directory "#{extension_path}/spec/helpers" m.directory "#{extension_path}/features/support" m.directory "#{extension_path}/features/step_definitions/admin" m.template 'RSpecRakefile', "#{extension_path}/Rakefile" m.template 'spec_helper.rb', "#{extension_path}/spec/spec_helper.rb" m.file 'spec.opts', "#{extension_path}/spec/spec.opts" m.file 'cucumber.yml', "#{extension_path}/cucumber.yml" m.template 'cucumber_env.rb', "#{extension_path}/features/support/env.rb" m.template 'cucumber_paths.rb', "#{extension_path}/features/support/paths.rb" end end end |