Class: ShopifyAppGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ShopifyAppGenerator
- Defined in:
- lib/generators/shopify_app/shopify_app_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_bootstrap_gem ⇒ Object
- #add_config_variables ⇒ Object
- #add_routes ⇒ Object
- #copy_files ⇒ Object
- #display_readme ⇒ Object
- #remove_static_index ⇒ Object
Class Method Details
.source_root ⇒ Object
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_gem ⇒ Object
36 37 38 39 |
# File 'lib/generators/shopify_app/shopify_app_generator.rb', line 36 def add_bootstrap_gem insert_into_file "Gemfile", "\ngem 'less-rails-bootstrap'\n\n", :before => '# Gems used only for assets and not required' insert_into_file "Gemfile", "\ngem 'therubyracer', :platforms => :ruby\n\n", :before => 'end' end |
#add_config_variables ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/shopify_app/shopify_app_generator.rb', line 23 def add_config_variables api_key_str = api_key.nil? ? "ENV['SHOPIFY_API_KEY']" : api_key.inspect api_secret_str = secret.nil? ? "ENV['SHOPIFY_API_SECRET']" : secret.inspect inject_into_file 'config/application.rb', <<-DATA, :after => "class Application < Rails::Application\n" # Shopify API connection credentials: config.shopify.api_key = #{api_key_str} config.shopify.secret = #{api_secret_str} DATA end |
#add_routes ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/generators/shopify_app/shopify_app_generator.rb', line 41 def add_routes unless [:skip_routes] route "root :to => 'home#index'" route "match 'login/logout' => 'login#logout', :as => :logout" route "match 'login/finalize' => 'login#finalize', :as => :finalize" route "match 'login/authenticate' => 'login#authenticate', :as => :authenticate" route "match 'login' => 'login#index', :as => :login" route "match 'design' => 'home#design'" route "match 'welcome' => 'home#welcome'" route "match 'auth/shopify/callback' => 'login#finalize'" end end |
#copy_files ⇒ Object
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_readme ⇒ Object
54 55 56 57 |
# File 'lib/generators/shopify_app/shopify_app_generator.rb', line 54 def display_readme `bundle install` readme '../README' end |
#remove_static_index ⇒ Object
19 20 21 |
# File 'lib/generators/shopify_app/shopify_app_generator.rb', line 19 def remove_static_index remove_file 'public/index.html' end |