Class: ShopifyAppGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



9
10
11
# File 'lib/generators/shopify_app/shopify_app_generator.rb', line 9

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

Instance Method Details

#add_bootstrap_gemObject



34
35
36
37
38
39
# File 'lib/generators/shopify_app/shopify_app_generator.rb', line 34

def add_bootstrap_gem
  gem_group :development, :test do
    gem "less-rails-bootstrap"
    gem 'therubyracer', :platforms => :ruby
  end
end

#add_config_variablesObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/shopify_app/shopify_app_generator.rb', line 23

def add_config_variables
  return if api_key.blank? || secret.blank?

  inject_into_file 'config/application.rb', <<-DATA, :after => "class Application < Rails::Application\n"

  # Shopify API connection credentials:
  config.shopify.api_key = '#{api_key}'
  config.shopify.secret = '#{secret}'
  DATA
end

#add_routesObject



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/generators/shopify_app/shopify_app_generator.rb', line 41

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 "  get 'auth/shopify/callback' => :show"
    route_without_newline "  post 'login' => :create"
    route_without_newline "  get 'login' => :new"
    route_without_newline "controller :sessions do"
    route "get 'design' => 'home#design'"
    route_without_newline "get 'welcome' => 'home#welcome'"
  end
end

#copy_filesObject



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

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

#display_readmeObject



55
56
57
58
59
60
61
# File 'lib/generators/shopify_app/shopify_app_generator.rb', line 55

def display_readme
  Bundler.with_clean_env do
    run 'bundle install'
  end

  readme '../README'
end

#remove_static_indexObject



19
20
21
# File 'lib/generators/shopify_app/shopify_app_generator.rb', line 19

def remove_static_index
  remove_file 'public/index.html'
end