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



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

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

Instance Method Details

#add_config_localeObject



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/generators/versacommerce_app/versacommerce_app_generator.rb', line 64

def add_config_locale    
  inject_into_file 'config/application.rb', "  \n  # Configure the default encoding used in templates for Ruby 1.9.\n  config.encoding = \"utf-8\"\n  config.time_zone = 'Berlin'\n  \n  # Allow all origins to include this app via <frame> or <iframe>.\n  config.action_dispatch.default_headers = { 'X-Frame-Options' => 'ALLOWALL' }\n  DATA\nend\n", :after => "class Application < Rails::Application\n"

#add_config_variablesObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/generators/versacommerce_app/versacommerce_app_generator.rb', line 34

def add_config_variables
  return if api_key.blank? || secret.blank?
  
  append_file 'config/versacommerce_api.yml', "development:\napi_key: \#{api_key}\nsecret: \#{secret}\n\ntest:\napi_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nsecret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n\nproduction:\napi_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nsecret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n  DATA\nend\n"

#add_routesObject



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/generators/versacommerce_app/versacommerce_app_generator.rb', line 52

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



24
25
26
27
28
# File 'lib/generators/versacommerce_app/versacommerce_app_generator.rb', line 24

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

#create_initializer_fileObject



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

def create_initializer_file
  if Gem::Requirement.new('>= 4.1').satisfied_by? Gem::Version.new(::Rails::VERSION::STRING)
    create_file "config/initializers/cookies_serializer.rb", "# Be sure to restart your server when you modify this file.\n\nRails.application.config.action_dispatch.cookies_serializer = :marshal\n"
  end
end

#remove_static_indexObject



30
31
32
# File 'lib/generators/versacommerce_app/versacommerce_app_generator.rb', line 30

def remove_static_index
  remove_file 'public/index.html'
end

#show_readmeObject



76
77
78
79
# File 'lib/generators/versacommerce_app/versacommerce_app_generator.rb', line 76

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