class DateBook::InstallGenerator

DateBook Install Generator

Public Instance Methods

add_initializer() click to toggle source
# File lib/generators/date_book/install/install_generator.rb, line 69
def add_initializer
  output(
    "Next, you'll need an initializer for Date Book.",
    :magenta
  )
  template(
    'config/initializers/date_book.rb',
    'config/initializers/date_book.rb'
  )
end
add_migrations() click to toggle source
# File lib/generators/date_book/install/install_generator.rb, line 93
def add_migrations
  output 'Next come migrations.', :magenta
  rake 'date_book:install:migrations'
end
add_models() click to toggle source
# File lib/generators/date_book/install/install_generator.rb, line 80
def add_models
  output(
    'Models for you to extend will be placed in your models directory',
    :magenta
  )
  template 'app/models/calendar.rb', 'app/models/calendar.rb'
  template 'app/models/event.rb', 'app/models/event.rb'
  template(
    'app/models/event_occurrence.rb', 'app/models/event_occurrence.rb'
  )
  template 'app/models/schedule.rb', 'app/models/schedule.rb'
end
add_route() click to toggle source
# File lib/generators/date_book/install/install_generator.rb, line 98
def add_route
  output 'Adding DateBook to your routes.rb file', :magenta
  gsub_file(
    'config/routes.rb',
    %r{mount DateBook::Engine => '/.*', as: 'date_book'},
    ''
  )
  route("mount DateBook::Engine => '/date_book', as: 'date_book'")
end
add_to_user() click to toggle source
# File lib/generators/date_book/install/install_generator.rb, line 45
    def add_to_user
      output(
        "Adding DateBook to your #{user_model_name.downcase} model",
        :magenta
      )
      gsub_file "app/models/#{user_model_name.downcase}.rb", /acts_as_owner/, ''
      inject_into_file(
        "app/models/#{user_model_name.downcase}.rb",
        after: "rolify\n"
      ) do
        <<-'RUBY'
  acts_as_owner
        RUBY
      end
    end
hello() click to toggle source
# File lib/generators/date_book/install/install_generator.rb, line 12
def hello
  output 'DateBook Installer will now install itself', :magenta
end
install_bootstrap_leather() click to toggle source
# File lib/generators/date_book/install/install_generator.rb, line 61
def install_bootstrap_leather
  output(
    'To make building in bootstrap easier, we use Bootstrap Leather.',
    :magenta
  )
  generate('bootstrap_leather:install')
end
install_cancan() click to toggle source
# File lib/generators/date_book/install/install_generator.rb, line 27
def install_cancan
  output(
    "For authorization, DateBook uses CanCanCan. Let's get you started "\
      'with a customizable ability.rb file.',
    :magenta
  )
  template 'app/models/ability.rb', 'app/models/ability.rb'
end
install_devise() click to toggle source

all public methods in here will be run in order

# File lib/generators/date_book/install/install_generator.rb, line 18
def install_devise
  output(
    'To start with, Devise is used to authenticate users. No need to '\
      "install it separately, I'll do that now.", :magenta
  )
  generate('devise:install')
  generate("devise #{user_model_name}")
end
install_rolify() click to toggle source
# File lib/generators/date_book/install/install_generator.rb, line 36
def install_rolify
  output(
    "To provide varying roles for Users, we'll use Rolify. Let's set that "\
      'up now.',
    :magenta
  )
  generate('rolify', "Role #{user_model_name}")
end