Class: WheelsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/wheels/wheels_generator.rb

Constant Summary collapse

SOURCE_ROOT =
source_root

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/generators/wheels/wheels_generator.rb', line 63

def self.next_migration_number(dirname)

  if ActiveRecord::Base.timestamped_migrations
    Time.now.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

#bundle_installObject



36
37
38
# File 'lib/generators/wheels/wheels_generator.rb', line 36

def bundle_install
  run 'bundle install'
end

#configure_generatorsObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/generators/wheels/wheels_generator.rb', line 44

def configure_generators
  generators_configuration = <<-END
  config.generators do |g|
    g.template_engine :haml
    g.fixture_replacement :factory_girl, :dir => 'spec/factories'
  end
  END

  environment generators_configuration
end

#executeObject



40
41
42
# File 'lib/generators/wheels/wheels_generator.rb', line 40

def execute
  execute_stategies
end

#initObject

class_option :template_engine, :type => :string, :aliases => “-t”,

:desc => "Template engine for the views. Available options are 'erb' and 'haml'."


20
21
22
# File 'lib/generators/wheels/wheels_generator.rb', line 20

def init
  initialize_templater
end

#init_gitObject



55
56
57
58
59
60
61
# File 'lib/generators/wheels/wheels_generator.rb', line 55

def init_git
  git :add => "."
  git :commit => "-m 'Initial commit'"
  if (a=ask("Enter github username/reponame or blank for none.")).length > 0
    run "git remote add origin [email protected]:#{a}.git"
  end
end

#load_recipesObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/wheels/wheels_generator.rb', line 24

def load_recipes
  required_recipes = %w(default jquery haml cancan postgresql)
  required_recipes.each {|required_recipe| apply recipe(required_recipe)}

#    apply recipe(ask("Which database? (m)ongoid or (p)ostgresql")=='m' ? 'mongoid' : 'postgresql')

  load_options
#    apply(recipe('cucumber')) if yes?("Do you want to some cukes?")
  apply recipe('design')
  apply recipe('wheels')
end