Class: VersacommerceAppGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/versacommerce_app/versacommerce_app_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



10
11
12
# File 'lib/generators/versacommerce_app/versacommerce_app_generator.rb', line 10

def self.source_root
  File.join(File.dirname(__FILE__), 'templates')
end

Instance Method Details

#add_config_variablesObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/generators/versacommerce_app/versacommerce_app_generator.rb', line 24

def add_config_variables
  return if api_key.blank? || secret.blank?
  
  append_file 'config/versacommerce_api.yml', <<-DATA
development:
api_key: #{api_key}
secret: #{secret}

test:
api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

production:
api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  DATA
end

#add_routesObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/generators/versacommerce_app/versacommerce_app_generator.rb', line 42

def add_routes
  unless options[:skip_routes]
    route_without_newline "root :to => 'home#index'"
    route "end"
    route_without_newline "  delete '/logout' => :destroy"
    route_without_newline "  post '/login' => :create"
    route_without_newline "  get '/login' => :new"
    route_without_newline "  get '/finalize' => :finalize"
    route_without_newline "controller :sessions do"
  end
end

#copy_filesObject



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

def copy_files
  directory 'app'
  directory 'public'
  directory 'config'
end

#remove_static_indexObject



20
21
22
# File 'lib/generators/versacommerce_app/versacommerce_app_generator.rb', line 20

def remove_static_index
  remove_file 'public/index.html'
end

#show_readmeObject



54
55
56
57
# File 'lib/generators/versacommerce_app/versacommerce_app_generator.rb', line 54

def show_readme
  `bundle install`
  readme '../README'
end