Class: LanguageExtensionGenerator

Inherits:
Rails::Generator::NamedBase
  • Object
show all
Defined in:
lib/generators-rails2/language_extension/language_extension_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runtime_args, runtime_options = {}) ⇒ LanguageExtensionGenerator

Returns a new instance of LanguageExtensionGenerator.



6
7
8
9
10
11
# File 'lib/generators-rails2/language_extension/language_extension_generator.rb', line 6

def initialize(runtime_args, runtime_options = {})
  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_nameObject (readonly)

Returns the value of attribute extension_file_name.



4
5
6
# File 'lib/generators-rails2/language_extension/language_extension_generator.rb', line 4

def extension_file_name
  @extension_file_name
end

#extension_pathObject (readonly)

Returns the value of attribute extension_path.



4
5
6
# File 'lib/generators-rails2/language_extension/language_extension_generator.rb', line 4

def extension_path
  @extension_path
end

#localization_nameObject (readonly)

Returns the value of attribute localization_name.



4
5
6
# File 'lib/generators-rails2/language_extension/language_extension_generator.rb', line 4

def localization_name
  @localization_name
end

Instance Method Details

#add_options!(opt) ⇒ Object



35
36
37
38
39
40
# File 'lib/generators-rails2/language_extension/language_extension_generator.rb', line 35

def add_options!(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

#class_nameObject



27
28
29
# File 'lib/generators-rails2/language_extension/language_extension_generator.rb', line 27

def class_name
  super.to_name.gsub(' ', '') + 'LanguagePackExtension'
end

#copy_filesObject



46
47
48
# File 'lib/generators-rails2/language_extension/language_extension_generator.rb', line 46

def copy_files
  FileUtils.cp("#{RADIANT_ROOT}/config/locales/en_available_tags.yml","#{RADIANT_ROOT}/#{extension_path}/config/locales/#{localization_name}_available_tags.yml")
end

#extension_nameObject



31
32
33
# File 'lib/generators-rails2/language_extension/language_extension_generator.rb', line 31

def extension_name
  class_name.to_name('Extension')
end

#manifestObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/generators-rails2/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"
  end
  
end