Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Feature/use in mounted rails engine #182

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/generators/casino/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ class InstallGenerator < Rails::Generators::Base
def install_migrations
return unless options['migration']

rake 'casino:install:migrations'
generate 'casino:migration'
end

def copy_config_files
return unless options['config_files']

copy_file 'cas.yml', 'config/cas.yml'
copy_file 'casino_and_overrides.scss', 'app/assets/stylesheets/casino_and_overrides.scss'
copy_file 'casino_and_overrides.scss', "app/assets/stylesheets/#{namespace_name}/casino_and_overrides.scss".squeeze('/')
end

def insert_assets_loader
insert_into_file 'app/assets/javascripts/application.js', :after => %r{//= require +['"]?jquery_ujs['"]?} do
insert_into_file "app/assets/javascripts/#{namespace_name}/application.js".squeeze('/'), :after => %r{//= require +['"]?jquery_ujs['"]?} do
"\n//= require casino"
end
end
Expand All @@ -43,5 +43,11 @@ def insert_engine_routes
def show_readme
readme 'README'
end

private
def namespace_name
Rails::Generators.namespace.to_s.underscore
end

end
end
24 changes: 24 additions & 0 deletions lib/generators/casino/migration_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'rails/generators/active_record'

module CASino
class MigrationGenerator < ::Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path('../../../../db/migrate', __FILE__)

namespace 'casino:migration'

desc 'Installs CASino migration files.'

def install
source_paths.each do |source_path|
Dir["#{source_path}/*.rb"].each do |filename|
migration_template File.basename(filename), "db/migrate/#{File.basename(filename).sub(/^\d+_/, '')}"
end
end
end

def self.next_migration_number(dirname)
ActiveRecord::Generators::Base.next_migration_number(dirname)
end
end
end