Sha256: 48a3c0aa3fc17acc113c9c561d8040dedae3fa905ab04ff0377ac5f7343abcd3

Contents?: true

Size: 1.45 KB

Versions: 15

Compression:

Stored size: 1.45 KB

Contents

require 'rails/generators'

module SqlSearchNSort
	class InstallGenerator < Rails::Generators::Base

		source_paths << File.expand_path('../views/application', __FILE__)
		source_paths << File.expand_path('../assets/javascripts', __FILE__)
		source_paths << File.expand_path('../helpers', __FILE__)
		source_paths << File.expand_path('../config/initializers', __FILE__)

		def copy_files
			base_path = "app/views/application"
      copy_file('_search_form.html.haml', File.join(base_path, '_search_form.html.haml'))
      copy_file('_sort_form.html.haml', File.join(base_path, '_sort_form.html.haml'))

      base_path = "app/assets/javascripts"
      copy_file('sql_search_n_sort.js', File.join(base_path, 'sql_search_n_sort.js'))

      base_path = "config/initializers"
      copy_file('sql_search_n_sort.rb', File.join(base_path, 'sql_search_n_sort.rb'))
		end

		def require_jquery
			#could be either application.js or application.js.coffee or maybe something else in the future
			if app_js_fl = Dir["#{destination_root}/app/assets/javascripts/*"].select{|f| f =~ /application\.js/}.first
				inject_into_file app_js_fl,
		    before: "\n//= require_tree ." do
		      "\n//= require jquery"
		    end
			end
		end

		def insert_into_app_controller
			inject_into_file "app/controllers/application_controller.rb",
		    before: /^end/ do
		      %Q`\n\tinclude SqlSortSetup\n
	before_action :setup_sql_sort, :only => [:index, :sort_only_index]
		   \n`
		    end
		end

	end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
sql_search_n_sort-3.0.3 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-3.0.2 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-3.0.1 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-3.0.0 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-2.1.16 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-2.1.15 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-2.1.14 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-2.1.13 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-2.1.11 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-2.1.10 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-2.1.9 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-2.1.8 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-2.1.7 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-2.1.6 lib/generators/sql_search_n_sort/install_generator.rb
sql_search_n_sort-2.1.5 lib/generators/sql_search_n_sort/install_generator.rb