Class: Rails::Generator::Commands::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/generator_extensions.rb

Instance Method Summary collapse

Instance Method Details

#gem_code(gem_options) ⇒ Object



20
21
22
23
# File 'lib/generators/generator_extensions.rb', line 20

def gem_code(gem_options)
  gem_options[:lib] = gem_options[:name] unless gem_options.has_key? :lib
  code = "config.gem '#{gem_options[:name]}', :lib => '#{gem_options[:lib]}'"
end

#gsub_file_check(relative_destination, regexp, *args, &block) ⇒ Object



14
15
16
17
18
# File 'lib/generators/generator_extensions.rb', line 14

def gsub_file_check(relative_destination, regexp, *args, &block)
  path = destination_path(relative_destination)
  content = File.read(path)
  !(content =~ regexp).nil?
end

#route_code(route_options) ⇒ Object



8
9
10
11
12
# File 'lib/generators/generator_extensions.rb', line 8

def route_code(route_options)
  route_options[:path] = route_options[:name] unless route_options.has_key? :path
  code = "map.#{route_options[:name]} '#{route_options[:path]}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
  code += ", :conditions => #{route_options[:conditions]}" if route_options.has_key? :conditions
end