Class: Mindapp::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Mindapp::Generators::InstallGenerator
- Defined in:
- lib/generators/mindapp/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #gen_image_store ⇒ Object
- #gen_user ⇒ Object
- #setup_app ⇒ Object
- #setup_env ⇒ Object
- #setup_gems ⇒ Object
- #setup_omniauth ⇒ Object
- #setup_routes ⇒ Object
Class Method Details
.source_root ⇒ Object
5 6 7 |
# File 'lib/generators/mindapp/install_generator.rb', line 5 def self.source_root File.dirname(__FILE__) + "/templates" end |
Instance Method Details
#gen_image_store ⇒ Object
113 114 115 116 |
# File 'lib/generators/mindapp/install_generator.rb', line 113 def gen_image_store copy_file "cloudinary.yml","config/cloudinary.yml" empty_directory "upload" # create upload directory just in case end |
#gen_user ⇒ Object
109 110 111 |
# File 'lib/generators/mindapp/install_generator.rb', line 109 def gen_user # copy_file "seeds.rb","db/seeds.rb" end |
#setup_app ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/generators/mindapp/install_generator.rb', line 101 def setup_app inside("public") { run "mv index.html index.html.bak" } inside("app/views/layouts") { run "mv application.html.erb application.html.erb.bak" } inside("app/assets/javascripts") { run "mv application.js application.js.bak" } inside("app/assets/stylesheets") { run "mv application.css application.css.bak" } directory "app" end |
#setup_env ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/generators/mindapp/install_generator.rb', line 21 def setup_env create_file 'README.md', '' # bug in mongo ruby driver 1.6.1, wait for mongoid 2.4.7 # gem "mongo", "1.5.1" # gem "bson_ext", "1.5.1" # gem "mongoid" # run "bundle install" generate "mongoid:config" # generate "rspec:install" inject_into_file 'config/application.rb', :after => 'require "active_resource/railtie"' do "\nrequire 'mongoid/railtie'\n" "\nrequire 'rexml/document'\n" end application do %q{ # Mindapp default config.generators do |g| g.orm :mongoid g.template_engine :haml g.test_framework :rspec g.integration_tool :rspec end # gmail config config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :user_name => '[email protected]', :password => 'secret', :authentication => 'plain', :enable_starttls_auto => true } config.action_mailer.raise_delivery_errors = true config.action_mailer.perform_deliveries = true } end initializer "mindapp.rb" do %q{# encoding: utf-8 MM = "#{Rails.root}/app/mindapp/index.mm" DEFAULT_TITLE = 'Mindapp' DEFAULT_HEADER = 'Mindapp' GMAP = true NEXT = "Next >" # comment IMAGE_LOCATION to use cloudinary (specify params in config/cloudinary.yml) IMAGE_LOCATION = "upload" # for debugging # DONT_SEND_MAIL = true } end inject_into_file 'config/environment.rb', :after => "initialize!" do "\n\n# hack to fix cloudinary error https://github.com/archiloque/rest-client/issues/141" + "\nclass Hash\n remove_method :read\nrescue\nend" end inject_into_file 'config/environments/development.rb', :after => 'config.action_mailer.raise_delivery_errors = false' do "\n config.action_mailer.default_url_options = { :host => 'localhost:3000' }" end inject_into_file 'config/environments/production.rb', :after => 'config.assets.compile = false' do "\n config.assets.compile = true" end inject_into_file 'config/mongoid.yml', :after => ' # raise_not_found_error: true' do "\n raise_not_found_error: false" end end |
#setup_gems ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/generators/mindapp/install_generator.rb', line 118 def setup_gems gem "mongo", '1.5.1' gem "bson_ext", '1.5.1' gem "mongoid" gem "nokogiri" # use for mindapp/doc gem "rmagick", :require => "RMagick", :platform => "ruby" gem 'haml-rails' gem "mail" gem "prawn" gem "redcarpet" gem 'bcrypt-ruby', '~> 3.0.0' gem 'omniauth-identity' gem 'cloudinary' gem 'kaminari' gem_group :development, :test do gem "debugger" gem "rspec" gem "rspec-rails" gem "better_errors" gem "binding_of_caller" end end |
#setup_omniauth ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/generators/mindapp/install_generator.rb', line 85 def setup_omniauth # gem 'bcrypt-ruby', '~> 3.0.0' # gem 'omniauth-identity' initializer "omniauth.rb" do %q{ Rails.application.config.middleware.use OmniAuth::Builder do provider :identity, :fields => [:code, :email], :on_failed_registration=> lambda { |env| IdentitiesController.action(:new).call(env) } end } end end |
#setup_routes ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/generators/mindapp/install_generator.rb', line 9 def setup_routes route "root :to => 'mindapp#index'" # route "match '/mindapp/init/:module/:service(/:id)' => 'Mindapp#init'" route "resources :identities" route "resources :sessions" route "match '/auth/:provider/callback' => 'sessions#create'" route "match '/auth/failure' => 'sessions#failure'" route "match '/logout' => 'sessions#destroy', :as => 'logout'" route "match ':controller(/:action(/:id))(.:format)'" end |