Parent

Padrino::Generators::Project

Responsible for generating new Padrino projects based on the specified project components.

Public Class Methods

source_root() click to toggle source

Define the source template root

# File lib/padrino-gen/generators/project.rb, line 15
def self.source_root; File.expand_path(File.dirname(__FILE__)); end

Public Instance Methods

bundle_dependencies() click to toggle source

Bundle all required components using bundler and Gemfile

@api private

# File lib/padrino-gen/generators/project.rb, line 99
def bundle_dependencies
  if options[:bundle]
    run_bundler
  end
end
finish_message() click to toggle source

Finish message

@api private

# File lib/padrino-gen/generators/project.rb, line 108
def finish_message
  say
  say '=' * 65, :green
  say "#{name} is ready for development!", :green
  say '=' * 65, :green
  say "$ cd #{options[:root]}/#{name}"
  say "$ bundle" unless options[:bundle]
  say "="*65, :green
  say
end
git_author_email() click to toggle source

Returns the git author email config or a fill-in value

@api private

# File lib/padrino-gen/generators/project.rb, line 130
def git_author_email
  git_author_email = `git config user.email`.chomp rescue ''
  git_author_email.empty? ? "TODO: Write your email address" : git_author_email
end
git_author_name() click to toggle source

Returns the git author name config or a fill-in value

@api private

# File lib/padrino-gen/generators/project.rb, line 122
def git_author_name
  git_author_name = `git config user.name`.chomp rescue ''
  git_author_name.empty? ? "TODO: Write your name" : git_author_name
end
setup_components() click to toggle source

For each component, retrieve a valid choice and then execute the associated generator

@api private

# File lib/padrino-gen/generators/project.rb, line 84
def setup_components
  return if options[:template]
  @_components = options.dup.slice(*self.class.component_types)
  self.class.component_types.each do |comp|
    choice = @_components[comp] = resolve_valid_choice(comp)
    execute_component_setup(comp, choice)
  end
  store_component_config('.components')
  store_component_choice(:namespace, @project_name)
  store_component_choice(:migration_format, options[:migration_format])
end
setup_project() click to toggle source

Copies over the Padrino base application App

@api private

# File lib/padrino-gen/generators/project.rb, line 53
def setup_project
  valid_constant? name
  app = (options[:app] || "App")

  @project_name = name.gsub(/\W/, '_').underscore.camelize
  @app_name = app.gsub(/\W/, '_').underscore.camelize
  self.destination_root = File.join(options[:root], name)
  if options[:template] # Run the template to create project
    execute_runner(:template, options[:template])
  else # generate project without template
    directory('project/', destination_root)
    empty_directory destination_root('public/images')
    empty_directory destination_root('public/javascripts')
    empty_directory destination_root('public/stylesheets')
    empty_directory destination_root('tmp')
    store_component_config('.components')
    app_skeleton('app', options[:tiny])
    template 'templates/Gemfile.tt', destination_root('Gemfile')
    template 'templates/Rakefile.tt', destination_root('Rakefile')
    if options.gem?
      template 'templates/gem/gemspec.tt', destination_root(name + '.gemspec')
      template 'templates/gem/README.md.tt', destination_root('README.md')
      template 'templates/gem/lib/libname.tt', destination_root("lib/#{name}.rb")
      template 'templates/gem/lib/libname/version.tt', destination_root("lib/#{name}/version.rb")
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.