Module: Ramix::Helpers
- Included in:
- Builder
- Defined in:
- lib/ramix/helpers.rb
Overview
A set of helper methods will append to the template
Instance Method Summary collapse
- #before_callbacks ⇒ Object
- #callback_functions ⇒ Object
- #callbacks ⇒ Object
- #preparation_methods ⇒ Object
- #rails_version ⇒ Object
Instance Method Details
#before_callbacks ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ramix/helpers.rb', line 36 def before_callbacks <<-TEMPLATE if File.exist?('config/initializers/wrap_parameters.rb') and RUBY_VERSION < '1.9' gsub_file 'config/initializers/wrap_parameters.rb', "wrap_parameters format: [:json]", "wrap_parameters format => [:json]" end # WARNING: This version of mysql2 (0.3.11) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1 # WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x case rails_version when /3.0/ gsub_file 'Gemfile', "gem 'mysql2'", "gem 'mysql2', '~>0.2.18'" end # Use unicorn as the web server say_wizard('Use unicorn as the web server') gsub_file 'Gemfile', "# gem 'unicorn'", "gem 'unicorn'" TEMPLATE end |
#callback_functions ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ramix/helpers.rb', line 23 def callback_functions <<-TEMPLATE @after_bundler_blocks = [] def after_bundler(&block) @after_bundler_blocks << block end @after_everything_blocks = [] def after_everything(&block) @after_everything_blocks << block end TEMPLATE end |
#callbacks ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/ramix/helpers.rb', line 55 def callbacks <<-TEMPLATE say_wizard 'Install bundle' run 'bundle install' @after_bundler_blocks.each{ |b| b.call } @after_everything_blocks.each{ |b| b.call } TEMPLATE end |
#preparation_methods ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/ramix/helpers.rb', line 5 def preparation_methods <<-TEMPLATE def say_wizard(text) say "******" + text + "******" end TEMPLATE end |
#rails_version ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/ramix/helpers.rb', line 13 def rails_version <<-TEMPLATE # Check the version of your rails gem # Only support above 3.0 def rails_version [Rails::VERSION::MAJOR, Rails::VERSION::MINOR].join('.') end TEMPLATE end |