Class: Jinda::Generators::ConfigGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Jinda::Generators::ConfigGenerator
- Defined in:
- lib/generators/jinda/config_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #backup_files ⇒ Object
- #finish ⇒ Object
- #gen_image_store ⇒ Object
- #setup_ckeditor ⇒ Object
- #setup_mongoid ⇒ Object
- #setup_omniauth ⇒ Object
Class Method Details
.source_root ⇒ Object
4 5 6 |
# File 'lib/generators/jinda/config_generator.rb', line 4 def self.source_root File.dirname(__FILE__) + "/templates" end |
Instance Method Details
#backup_files ⇒ Object
8 9 10 11 12 13 |
# File 'lib/generators/jinda/config_generator.rb', line 8 def backup_files st=" " inside("config/initializes") {(File.file? "omniauth.rb") ? (mv omniauth.rb omniauth.rb.bak) : (puts "new omniauth.rb created")} inside("config/initializes") {(File.file? "mongoid.rb") ? (mv mongoid.rb omniauth.rb.bak) : (puts "new mongoid.rb created")} inside("config/initializes") {(File.file? "ckeditor.rb") ? (mv ckeditor.rb ckeditor.rb.bak) : (puts "new ckeditor.rb created")} end |
#finish ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/generators/jinda/config_generator.rb', line 72 def finish puts " configured omniauth.\n" puts " configured setup_ckeditor.\n" puts " configured Mongoid.\n" puts "\n" puts "Next: To set up user/password as admin/secret\n" puts "Please run the following command:\n" puts "----------------------------------------\n" puts "rake jinda:seed\n" puts "----------------------------------------\n" end |
#gen_image_store ⇒ Object
16 17 18 19 20 |
# File 'lib/generators/jinda/config_generator.rb', line 16 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 |
#setup_ckeditor ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/generators/jinda/config_generator.rb', line 41 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_mongoid ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/generators/jinda/config_generator.rb', line 52 def setup_mongoid generate "mongoid:config" inject_into_file 'config/mongoid.yml', :after => ' # raise_not_found_error: true' do "\n raise_not_found_error: false" end inject_into_file 'config/mongoid.yml', :after => ' # belongs_to_required_by_default: true' do "\n belongs_to_required_by_default: false" end inject_into_file 'config/mongoid.yml', :after => ' # app_name: MyApplicationName' do "\n\nproduction:" + "\n clients:" + "\n default:" + "\n uri: <%= ENV['MONGODB_URI'] %>" + "\n options:" + "\n raise_not_found_error: false" + "\n belongs_to_required_by_default: false\n" end end |
#setup_omniauth ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/jinda/config_generator.rb', line 22 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 |