lib/railsthemes/theme_installer.rb in railsthemes-2.0.3 vs lib/railsthemes/theme_installer.rb in railsthemes-2.1.0
- old
+ new
@@ -64,22 +64,19 @@
### Begin RailsThemes basic generated routes ###
# Routes to RailsThemes Theme Example markup:
namespace :railsthemes do
- match '/' => 'railsthemes#index'
- match '/previews', controller: :previews, action: :index
- match '/previews/:name', controller: :previews, action: :show
- match '/previews/:feature/:partial', controller: :previews, action: :partial
- match '/:action', controller: :railsthemes
+ match '/' => 'railsthemes#index', :via => [:get]
+ match '/:action', :controller => :railsthemes, :via => [:get, :post]
end
# This is magical routing for errors (instead of using the static markup in
# public/*.html)
- match '/403', to: 'railsthemes_errors#403_forbidden'
- match '/404', to: 'railsthemes_errors#404_not_found'
- match '/500', to: 'railsthemes_errors#500_internal_server_error'
+ match '/403' => 'railsthemes_errors#403_forbidden', :via => [:get]
+ match '/404' => 'railsthemes_errors#404_not_found', :via => [:get]
+ match '/500' => 'railsthemes_errors#500_internal_server_error', :via => [:get]
### End RailsThemes basic generated routes ###
EOS
output.split("\n")
end
@@ -103,36 +100,63 @@
# General assumption is `bundler check` is always clean prior to installation (via ensurer),
# so if the gemspecs are in the Gemfile.lock, then the gem is in the Gemfile
def add_needed_gems
installed_gems = Utils.gemspecs.map(&:name)
- ['sass',
- 'jquery-rails',
- 'jquery-ui-rails',
- 'coderay',
- ].each do |gemname|
+ %w(
+ sass
+ jquery-rails
+ jquery-ui-rails
+ coderay
+ ).each do |gemname|
Utils.add_gem_to_gemfile gemname unless installed_gems.include?(gemname)
end
+ add_compass_rails_gem installed_gems
+ add_zurb_foundation_gem installed_gems
+ add_turbo_sprockets_gem installed_gems
+ end
+
+ def add_compass_rails_gem installed_gems
unless installed_gems.include?('compass-rails')
- Utils.add_gem_to_gemfile('compass-rails', :group => 'assets')
+ if Gem::Version.new(GemfileUtils.rails_version) < Gem::Version.new('4.0.0')
+ Utils.add_gem_to_gemfile('compass-rails', :group => 'assets')
+ else
+ # see http://stackoverflow.com/questions/17341042, compass-rails + Rails 4 issues
+ Utils.add_gem_to_gemfile('compass-rails', :version => '~> 2.0.alpha.0')
+ end
end
+ end
+ def add_zurb_foundation_gem installed_gems
unless installed_gems.include?('zurb-foundation')
- Utils.add_gem_to_gemfile('zurb-foundation', :version => '~> 4.0', :group => 'assets')
+ if Gem::Version.new(GemfileUtils.rails_version) < Gem::Version.new('4.0.0')
+ Utils.add_gem_to_gemfile('zurb-foundation', :version => '~> 4.0', :group => 'assets')
+ else
+ Utils.add_gem_to_gemfile('zurb-foundation', :version => '~> 4.0')
+ end
end
end
+ def add_turbo_sprockets_gem installed_gems
+ if Gem::Version.new(GemfileUtils.rails_version) < Gem::Version.new('4.0.0')
+ unless installed_gems.include?('turbo-sprockets-rails3')
+ Utils.add_gem_to_gemfile('turbo-sprockets-rails3', :group => 'assets')
+ end
+ end
+ end
+
def add_to_asset_precompilation_list theme_name
config_lines = Utils.lines('config/environments/production.rb')
count = config_lines.grep(/^\s*config.assets.precompile\s*\+=\s*%w\(\s*railsthemes_#{theme_name}\.js\s+railsthemes_#{theme_name}\.css\s*\)$/).count
if count == 0 # precompile line we want not found, add it
added = false # only want to add the new line once
Utils.safe_write('config/environments/production.rb') do |f|
config_lines.each do |line|
f.puts line
if !added && (line =~ /Precompile additional assets/ || line =~ /config\.assets\.precompile/)
f.puts " config.assets.precompile += %w( railsthemes_#{theme_name}.js railsthemes_#{theme_name}.css )"
+ f.puts " config.assets.precompile += %w( coderay.css )"
added = true
end
end
end
end