class Jeweler::Generator

Generator for creating a jeweler-enabled project

Attributes

description[RW]
development_dependencies[RW]
documentation_framework[RW]
git_remote[RW]
github_token[RW]
github_username[RW]
homepage[RW]
options[RW]
project_name[RW]
repo[RW]
should_create_remote_repo[RW]
should_setup_rubyforge[RW]
should_use_bundler[RW]
should_use_cucumber[RW]
should_use_reek[RW]
should_use_roodi[RW]
summary[RW]
target_dir[RW]
testing_framework[RW]
user_email[RW]
user_name[RW]

Public Instance Methods

constant_name() click to toggle source
# File lib/jeweler/generator.rb, line 135
def constant_name
  self.project_name.split(%r[-_]/).collect{|each| each.capitalize }.join
end
feature_filename() click to toggle source
# File lib/jeweler/generator.rb, line 155
def feature_filename
  "#{project_name}.feature"
end
features_dir() click to toggle source
# File lib/jeweler/generator.rb, line 163
def features_dir
  'features'
end
features_steps_dir() click to toggle source
# File lib/jeweler/generator.rb, line 171
def features_steps_dir
  File.join(features_dir, 'step_definitions')
end
features_support_dir() click to toggle source
# File lib/jeweler/generator.rb, line 167
def features_support_dir
  File.join(features_dir, 'support')
end
file_name_prefix() click to toggle source
# File lib/jeweler/generator.rb, line 147
def file_name_prefix
  self.project_name.gsub('-', '_')
end
lib_dir() click to toggle source
# File lib/jeweler/generator.rb, line 151
def lib_dir
  'lib'
end
lib_filename() click to toggle source
# File lib/jeweler/generator.rb, line 139
def lib_filename
  "#{project_name}.rb"
end
require_name() click to toggle source
# File lib/jeweler/generator.rb, line 143
def require_name
  self.project_name
end
run() click to toggle source
# File lib/jeweler/generator.rb, line 125
def run
  create_files
  create_version_control
  $stdout.puts "Jeweler has prepared your gem in #{target_dir}"
  if should_create_remote_repo
    create_and_push_repo
    $stdout.puts "Jeweler has pushed your repo to #{homepage}"
  end
end
steps_filename() click to toggle source
# File lib/jeweler/generator.rb, line 159
def steps_filename
  "#{project_name}_steps.rb"
end

Public Class Methods

new(options = {}) click to toggle source
# File lib/jeweler/generator.rb, line 58
def initialize(options = {})
  self.options = options
  extracted_directory = nil

  self.project_name   = options[:project_name]
  if self.project_name.nil? || self.project_name.squeeze.strip == ""
    raise NoGitHubRepoNameGiven
  else
    path = File.split(self.project_name)

    if path.size > 1
      extracted_directory = File.join(path[0..-1])
      self.project_name = path.last
    end
  end

  self.development_dependencies = []
  self.testing_framework  = options[:testing_framework]
  self.documentation_framework = options[:documentation_framework]
  begin
    generator_mixin_name = "#{self.testing_framework.to_s.capitalize}Mixin"
    generator_mixin = self.class.const_get(generator_mixin_name)
    extend generator_mixin
  rescue NameError => e
    raise ArgumentError, "Unsupported testing framework (#{testing_framework})"
  end

  begin
    generator_mixin_name = "#{self.documentation_framework.to_s.capitalize}Mixin"
    generator_mixin = self.class.const_get(generator_mixin_name)
    extend generator_mixin
  rescue NameError => e
    raise ArgumentError, "Unsupported documentation framework (#{documentation_framework})"
  end

  self.target_dir             = options[:directory] || extracted_directory || self.project_name

  self.summary                = options[:summary] || 'TODO: one-line summary of your gem'
  self.description            = options[:description] || 'TODO: longer description of your gem'
  self.should_use_cucumber    = options[:use_cucumber]
  self.should_use_reek        = options[:use_reek]
  self.should_use_roodi       = options[:use_roodi]
  self.should_setup_rubyforge = options[:rubyforge]
  self.should_use_bundler     = options[:use_bundler]

  development_dependencies << ["cucumber", ">= 0"] if should_use_cucumber

  # TODO make bundler optional?
  development_dependencies << ["bundler", "~> 1.0.0"]
  development_dependencies << ["jeweler", "~> #{Jeweler::Version::STRING}"]
  development_dependencies << ["rcov", ">= 0"]

  development_dependencies << ["reek", "~> 1.2.8"] if should_use_reek
  development_dependencies << ["roodi", "~> 2.1.0"] if should_use_roodi

  self.user_name       = options[:user_name]
  self.user_email      = options[:user_email]
  self.homepage        = options[:homepage]
  
  self.git_remote      = options[:git_remote]

  raise NoGitUserName unless self.user_name
  raise NoGitUserEmail unless self.user_email

  extend GithubMixin
end