Class: LanguageExtensionGenerator
- Inherits:
-
Rails::Generator::NamedBase
- Object
- Rails::Generator::NamedBase
- LanguageExtensionGenerator
- Defined in:
- lib/generators/language_extension/language_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.
-
#localization_name ⇒ Object
readonly
Returns the value of attribute localization_name.
Instance Method Summary collapse
- #add_options!(opt) ⇒ Object
- #author_email ⇒ Object
- #author_info ⇒ Object
- #author_name ⇒ Object
- #class_name ⇒ Object
- #copy_files ⇒ Object
- #extension_name ⇒ Object
- #homepage ⇒ Object
-
#initialize(runtime_args, runtime_options = {}) ⇒ LanguageExtensionGenerator
constructor
A new instance of LanguageExtensionGenerator.
- #manifest ⇒ Object
Constructor Details
#initialize(runtime_args, runtime_options = {}) ⇒ LanguageExtensionGenerator
Returns a new instance of LanguageExtensionGenerator.
6 7 8 9 10 11 |
# File 'lib/generators/language_extension/language_extension_generator.rb', line 6 def initialize(runtime_args, = {}) super @extension_file_name = "#{file_name}_language_pack_extension" @extension_path = "vendor/extensions/#{file_name}_language_pack" @localization_name = localization_name end |
Instance Attribute Details
#extension_file_name ⇒ Object (readonly)
Returns the value of attribute extension_file_name.
4 5 6 |
# File 'lib/generators/language_extension/language_extension_generator.rb', line 4 def extension_file_name @extension_file_name end |
#extension_path ⇒ Object (readonly)
Returns the value of attribute extension_path.
4 5 6 |
# File 'lib/generators/language_extension/language_extension_generator.rb', line 4 def extension_path @extension_path end |
#localization_name ⇒ Object (readonly)
Returns the value of attribute localization_name.
4 5 6 |
# File 'lib/generators/language_extension/language_extension_generator.rb', line 4 def localization_name @localization_name end |
Instance Method Details
#add_options!(opt) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/generators/language_extension/language_extension_generator.rb', line 56 def (opt) # opt.separator '' # opt.separator 'Options:' # opt.on("--with-test-unit", # "Use Test::Unit for this extension instead of RSpec") { |v| options[:with_test_unit] = v } end |
#author_email ⇒ Object
48 49 50 |
# File 'lib/generators/language_extension/language_extension_generator.rb', line 48 def ['user.email'] || 'your email' end |
#author_info ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/generators/language_extension/language_extension_generator.rb', line 36 def @author_info ||= begin Git.global_config rescue NameError {} end end |
#author_name ⇒ Object
52 53 54 |
# File 'lib/generators/language_extension/language_extension_generator.rb', line 52 def ['user.name'] || 'Your Name' end |
#class_name ⇒ Object
28 29 30 |
# File 'lib/generators/language_extension/language_extension_generator.rb', line 28 def class_name super.to_name.gsub(' ', '') + 'LanguagePackExtension' end |
#copy_files ⇒ Object
67 68 69 |
# File 'lib/generators/language_extension/language_extension_generator.rb', line 67 def copy_files FileUtils.cp("#{TRUSTY_CMS_ROOT}/config/locales/en_available_tags.yml","#{TRUSTY_CMS_ROOT}/#{extension_path}/config/locales/#{localization_name}_available_tags.yml") end |
#extension_name ⇒ Object
32 33 34 |
# File 'lib/generators/language_extension/language_extension_generator.rb', line 32 def extension_name class_name.to_name('Extension') end |
#homepage ⇒ Object
44 45 46 |
# File 'lib/generators/language_extension/language_extension_generator.rb', line 44 def homepage ['github.user'] ? "http://github.com/#{['github.user']}/radiant-#{file_name}-extension" : "http://example.com/#{file_name}" end |
#manifest ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/language_extension/language_extension_generator.rb', line 13 def manifest record do |m| m.directory "#{extension_path}/config/locales" m.directory "#{extension_path}/lib/tasks" m.template 'README', "#{extension_path}/README" 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 'lang.yml', "#{extension_path}/config/locales/#{localization_name}.yml" m.template 'available_tags.yml', "#{extension_path}/config/locales/#{localization_name}_available_tags.yml" m.template 'lib.rb', "#{extension_path}/lib/radiant-#{file_name}_language_pack-extension.rb" m.template 'gemspec.rb', "#{extension_path}/radiant-#{file_name}_language_pack-extension.gemspec" end end |