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
- #finish ⇒ Object
- #gen_image_store ⇒ Object
- #gen_user ⇒ Object
- #setup_app ⇒ Object
-
#setup_ckeditor ⇒ Object
gem ‘ckeditor’, github: ‘galetahub/ckeditor’ rails generate ckeditor:install –orm=mongoid –backend=paperclip.
- #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
#finish ⇒ Object
178 179 180 181 182 183 184 |
# File 'lib/generators/mindapp/install_generator.rb', line 178 def finish puts "Mindapp installation finish, please run the following command:\n" puts "----------------------------------------\n" puts "bundle install\n" puts "rails generate mindapp:mongoid\n" puts "----------------------------------------\n" end |
#gen_image_store ⇒ Object
123 124 125 126 127 128 |
# File 'lib/generators/mindapp/install_generator.rb', line 123 def gen_image_store copy_file "cloudinary.yml","config/cloudinary.yml" copy_file ".env",".env" empty_directory "upload" # create upload directory just in case end |
#gen_user ⇒ Object
119 120 121 |
# File 'lib/generators/mindapp/install_generator.rb', line 119 def gen_user # copy_file "seeds.rb","db/seeds.rb" end |
#setup_app ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/generators/mindapp/install_generator.rb', line 111 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_ckeditor ⇒ Object
gem ‘ckeditor’, github: ‘galetahub/ckeditor’
rails generate ckeditor:install –orm=mongoid –backend=paperclip
168 169 170 171 172 173 174 175 176 |
# File 'lib/generators/mindapp/install_generator.rb', line 168 def setup_ckeditor initializer "ckeditor.rb" do %q{# gem 'ckeditor', github: 'galetahub/ckeditor' Ckeditor.setup do |config| require 'ckeditor/orm/mongoid' end } end end |
#setup_env ⇒ Object
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 84 85 86 87 88 89 90 91 92 |
# File 'lib/generators/mindapp/install_generator.rb', line 23 def setup_env create_file 'README.md', '' 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 = 'Mindapp2' DEFAULT_HEADER = 'Mindapp2' GMAP = false NEXT = "Next >" # comment IMAGE_LOCATION to use cloudinary (specify params in config/cloudinary.yml) IMAGE_LOCATION = "upload" # for debugging # DONT_SEND_MAIL = true } end initializer "mongoid.rb" do %q{# encoding: utf-8 # # Mongoid 6 follows the new pattern of AR5 requiring a belongs_to relation to always require its parent # belongs_to` will now trigger a validation error by default if the association is not present. # You can turn this off on a per-association basis with `optional: true`. # (Note this new default only applies to new Rails apps that will be generated with # `config.active_record.belongs_to_required_by_default = true` in initializer.) # Mongoid::Config.belongs_to_required_by_default = false } 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/initializers/assets.rb', :after => '# Precompile additional assets. ' do "\nRails.application.config.assets.precompile += %w( sarabun.css )\n" end end |
#setup_gems ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/generators/mindapp/install_generator.rb', line 130 def setup_gems gem 'maruku', '~> 0.7.3' gem 'rouge' gem 'normalize-rails' gem "font-awesome-rails" gem 'ckeditor', github: 'galetahub/ckeditor' gem 'mongoid-paperclip', require: 'mongoid_paperclip' gem 'meta-tags' gem 'jquery-turbolinks' gem "mongo", '~> 2.2' gem "bson", '~> 4.0' gem 'mongoid', github: 'mongodb/mongoid' # gem "mongoid" gem "nokogiri" # use for mindapp/doc gem 'haml', git: 'https://github.com/haml/haml' gem "mail" gem "prawn" gem "redcarpet" gem 'bcrypt-ruby', '~> 3.0.0' gem 'omniauth-identity' gem 'omniauth-facebook' gem 'dotenv-rails' gem 'cloudinary' gem 'kaminari' gem 'kaminari-mongoid' gem 'jquery-rails' gem_group :development, :test do gem "rspec" gem "rspec-rails" gem "better_errors" gem "binding_of_caller" gem 'pry-byebug' end end |
#setup_omniauth ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/generators/mindapp/install_generator.rb', line 94 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) } provider :facebook, ENV['FACEBOOK_API'], ENV['FACEBOOK_KEY'] end } end end |
#setup_routes ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 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 "mount Ckeditor::Engine => '/ckeditor'" route "resources :identities" route "resources :sessions" route "post '/auth/:provider/callback' => 'sessions#create'" route "get '/auth/:provider/callback' => 'sessions#create'" route "get '/auth/failure' => 'sessions#failure'" route "get '/logout' => 'sessions#destroy', :as => 'logout'" route "get ':controller(/:action(/:id))(.:format)'" route "post ':controller(/:action(/:id))(.:format)'" end |