lib/generators/kinney/install/install_generator.rb in kinney-0.0.3 vs lib/generators/kinney/install/install_generator.rb in kinney-0.1.0

- old
+ new

@@ -1,11 +1,11 @@ module Kinney module Generators class InstallGenerator < Rails::Generators::Base desc <<DESC Description: - Copy timeline_keeper files to your application. + Copy kinney files to your application. See README for changes that need to be made. DESC def self.source_root @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates')) end @@ -20,52 +20,73 @@ "\n//= require kinney\n" end gsub_file 'app/assets/javascripts/application.js', "//= require_tree .", '' end - def inject_css - application_css_scss = "app/assets/stylesheets/application.css.scss" - application_css = "app/assets/stylesheets/application.css" - css_file = File.exist?(application_css_scss) ? application_css_scss : application_css - - inject_into_file css_file, :before => " *= require_self" do - " *= require kinney\n*= require font-awesome" - end - gsub_file css_file, "*= require_tree .\n", '' + def create_css + remove_file("app/assets/stylesheets/application.css") + create_file "app/assets/stylesheets/application.css.scss", + %Q|@import "kinney";\n@import "font-awesome";| end - # create KinneyHelper - def create_kinney_helpers - template 'kinney_helper.rb', 'app/helpers/kinney_helper.rb' - template 'kinney_clip_helper.rb', 'app/helpers/kinney_clip_helper.rb' + def remove_turbolinks + gsub_file('Gemfile', %Q|gem 'turbolinks'|, '') + gsbu_file('app/assets/javascripts/application.js', '//= require turbolinks', '') end - def create_image_override + def insert_seeds + insert_into_file "db/seeds.rb", "\nKinney::Engine.load_seed\n" + end + + def remove_coffeescript + gsub_file('Gemfile', /^gem 'coffee-rails.*$'/, '') + end + + # # create KinneyHelper + # def create_kinney_helpers + # template 'kinney_helper.rb', 'app/helpers/kinney_helper.rb' + # end + + def create_model_overrides empty_directory 'app/models/kinney' template 'image.rb', 'app/models/kinney/image.rb' + template 'clip.rb', 'app/models/kinney/clip.rb' end def inject_routes routes = <<EOF ActiveAdmin.routes(self) - devise_for :admin_users, :class_name => 'Kinney::AdminUser' #ActiveAdmin::Devise.config.merge(:class_name => Kinney::AdminUser) - mount Ckeditor::Engine => "/ckeditor" + devise_for :admin_users, :class_name => 'Kinney::AdminUser' #ActiveAdmin::Devise.config.merge(:class_name => Kinney::AdminUser) mount Kinney::Engine => "/kinney", :as => 'kinney' root :to => 'kinney/pages#home' EOF - inject_into_file 'config/routes.rb', :after => 'routes.draw do' do + inject_into_file 'config/routes.rb', :after => 'routes.draw do' do routes end end def create_devise_initializer template 'devise.rb', 'config/initializers/devise.rb' end + def create_application_name + insert_into_file "app/helpers/application_helper.rb", after: "module ApplicationHelper\n" do + application_name = ask "What is the name of your application?" + text = <<EOF + def application_name + "#{application_name}" + end + def navbar_application_name + application_name + end +EOF + end + end + # ActiveAdmin setup def create_active_admin_css template 'active_admin.css.scss', 'app/assets/stylesheets/active_admin.css.scss' end @@ -87,17 +108,18 @@ def add_gems gems = <<EOF # added by Kinney -gem 'bootstrap-sass' # once these are published as gems we can use them from there, until then we need to have them in our Gemfile gem 'mediaelement_rails', :git => 'https://github.com/tobsch/mediaelement_rails.git' gem 'webvtt', :git => 'https://github.com/jronallo/webvtt.git' +gem 'compass-rails', '>= 2.0.alpha.0' +gem 'bootstrap-sass', git: 'https://github.com/thomas-mcdonald/bootstrap-sass.git', branch: 'master' EOF - inject_into_file 'Gemfile', :after => "source 'https://rubygems.org'" do + inject_into_file 'Gemfile', :after => "source 'https://rubygems.org'" do gems end end def mailer_setup @@ -109,10 +131,10 @@ :location => '/usr/sbin/sendmail', :arguments => '-i -t' } EOF - inject_into_file 'config/environments/development.rb', :after => 'Application.configure do' do + inject_into_file 'config/environments/development.rb', :after => 'Application.configure do' do mailer_config end end \ No newline at end of file