Class: BlogBasic::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/blog_basic/install/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



14
15
16
# File 'lib/generators/blog_basic/install/install_generator.rb', line 14

def self.next_migration_number(dirname)
  Time.now.strftime("%Y%m%d%H%M%S")
end

.source_rootObject



10
11
12
# File 'lib/generators/blog_basic/install/install_generator.rb', line 10

def self.source_root
  @_active_admin_source_root ||= File.expand_path("../templates", __FILE__)
end

Instance Method Details

#copy_configObject



39
40
41
# File 'lib/generators/blog_basic/install/install_generator.rb', line 39

def copy_config
  copy_file "blog_basic.yml", "config/blog_basic.yml"
end

#copy_initializerObject



18
19
20
# File 'lib/generators/blog_basic/install/install_generator.rb', line 18

def copy_initializer
  template 'omniauth.rb.erb', 'config/initializers/blog_omniauth.rb'
end

#create_assetsObject



34
35
36
37
# File 'lib/generators/blog_basic/install/install_generator.rb', line 34

def create_assets
  #generate "active_admin:assets"
  copy_file "blog_kit.css", "vendor/assets/stylesheets/blog_kit.css"
end

#create_migrationsObject



47
48
49
50
51
52
53
# File 'lib/generators/blog_basic/install/install_generator.rb', line 47

def create_migrations
  Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath|
    name = File.basename(filepath)
    migration_template "migrations/#{name}", "db/migrate/#{name.gsub(/^\d+_/,'')}"
    sleep 1
  end
end

#load_dependenciesObject



43
44
45
# File 'lib/generators/blog_basic/install/install_generator.rb', line 43

def load_dependencies
#        application "require 'rack/openid'"
end

#setup_routesObject

def setup_directory

empty_directory "app/admin"
template 'dashboards.rb', 'app/admin/dashboards.rb'

end



27
28
29
30
31
32
# File 'lib/generators/blog_basic/install/install_generator.rb', line 27

def setup_routes
  route "mount BlogBasic::Engine => \"/blog\""
  route "match '/signin' => redirect('/auth/google')"
  route "match '/auth/:provider/callback', to: 'blog_basic/sessions#create'"
  route "match '/signout' => 'blog_basic/sessions#destroy', :as => :signout"
end