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



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

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

#gsub_file_check(relative_destination, regexp, *_args) ⇒ Object



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

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

#route_code(route_options) ⇒ Object



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

def route_code(route_options)
  route_options[:path] = route_options[:name] unless route_options.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.key? :conditions
end