Class: Jeweler::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/jeweler/generator.rb,
lib/jeweler/generator/options.rb,
lib/jeweler/generator/rdoc_mixin.rb,
lib/jeweler/generator/yard_mixin.rb,
lib/jeweler/generator/application.rb,
lib/jeweler/generator/bacon_mixin.rb,
lib/jeweler/generator/rspec_mixin.rb,
lib/jeweler/generator/shoulda_mixin.rb,
lib/jeweler/generator/minitest_mixin.rb,
lib/jeweler/generator/testunit_mixin.rb,
lib/jeweler/generator/micronaut_mixin.rb

Defined Under Namespace

Modules: BaconMixin, MicronautMixin, MinitestMixin, RdocMixin, RspecMixin, ShouldaMixin, TestunitMixin, YardMixin Classes: Application, Options

Constant Summary collapse

DEFAULT_TESTING_FRAMEWORK =
:shoulda
DEFAULT_DOCUMENTATION_FRAMEWORK =
:rdoc

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_name, options = {}) ⇒ Generator

Returns a new instance of Generator.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/jeweler/generator.rb', line 45

def initialize(project_name, options = {})
  if project_name.nil? || project_name.squeeze.strip == ""
    raise NoGitHubRepoNameGiven
  end

  self.development_dependencies = []

  self.project_name   = project_name

  self.testing_framework  = (options[:testing_framework] || DEFAULT_TESTING_FRAMEWORK).to_sym
  self.documentation_framework = options[:documentation_framework] || DEFAULT_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] || self.project_name

  self.should_create_repo     = options[:create_repo]
  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_gemcutter = options[:gemcutter]
  self.should_setup_rubyforge = options[:rubyforge]

  development_dependencies << "cucumber" if should_use_cucumber

  use_user_git_config
  
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def description
  @description
end

#development_dependenciesObject

Returns the value of attribute development_dependencies.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def development_dependencies
  @development_dependencies
end

#documentation_frameworkObject

Returns the value of attribute documentation_framework.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def documentation_framework
  @documentation_framework
end

#github_tokenObject

Returns the value of attribute github_token.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def github_token
  @github_token
end

#github_usernameObject

Returns the value of attribute github_username.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def github_username
  @github_username
end

#project_nameObject

Returns the value of attribute project_name.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def project_name
  @project_name
end

#repoObject

Returns the value of attribute repo.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def repo
  @repo
end

#should_create_repoObject

Returns the value of attribute should_create_repo.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def should_create_repo
  @should_create_repo
end

#should_setup_gemcutterObject

Returns the value of attribute should_setup_gemcutter.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def should_setup_gemcutter
  @should_setup_gemcutter
end

#should_setup_rubyforgeObject

Returns the value of attribute should_setup_rubyforge.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def should_setup_rubyforge
  @should_setup_rubyforge
end

#should_use_cucumberObject

Returns the value of attribute should_use_cucumber.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def should_use_cucumber
  @should_use_cucumber
end

#should_use_reekObject

Returns the value of attribute should_use_reek.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def should_use_reek
  @should_use_reek
end

#should_use_roodiObject

Returns the value of attribute should_use_roodi.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def should_use_roodi
  @should_use_roodi
end

#summaryObject

Returns the value of attribute summary.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def summary
  @summary
end

#target_dirObject

Returns the value of attribute target_dir.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def target_dir
  @target_dir
end

#testing_frameworkObject

Returns the value of attribute testing_framework.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def testing_framework
  @testing_framework
end

#user_emailObject

Returns the value of attribute user_email.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def user_email
  @user_email
end

#user_nameObject

Returns the value of attribute user_name.



34
35
36
# File 'lib/jeweler/generator.rb', line 34

def user_name
  @user_name
end

Instance Method Details

#constant_nameObject



110
111
112
# File 'lib/jeweler/generator.rb', line 110

def constant_name
  self.project_name.split(/[-_]/).collect{|each| each.capitalize }.join
end

#feature_filenameObject



130
131
132
# File 'lib/jeweler/generator.rb', line 130

def feature_filename
  "#{project_name}.feature"
end

#features_dirObject



138
139
140
# File 'lib/jeweler/generator.rb', line 138

def features_dir
  'features'
end

#features_steps_dirObject



146
147
148
# File 'lib/jeweler/generator.rb', line 146

def features_steps_dir
  File.join(features_dir, 'step_definitions')
end

#features_support_dirObject



142
143
144
# File 'lib/jeweler/generator.rb', line 142

def features_support_dir
  File.join(features_dir, 'support')
end

#file_name_prefixObject



122
123
124
# File 'lib/jeweler/generator.rb', line 122

def file_name_prefix
  self.project_name.gsub('-', '_')
end

#git_remoteObject



102
103
104
# File 'lib/jeweler/generator.rb', line 102

def git_remote
  "[email protected]:#{github_username}/#{project_name}.git"
end

#lib_dirObject



126
127
128
# File 'lib/jeweler/generator.rb', line 126

def lib_dir
  'lib'
end

#lib_filenameObject



114
115
116
# File 'lib/jeweler/generator.rb', line 114

def lib_filename
  "#{project_name}.rb"
end

#project_homepageObject



106
107
108
# File 'lib/jeweler/generator.rb', line 106

def project_homepage
  "http://github.com/#{github_username}/#{project_name}"
end

#require_nameObject



118
119
120
# File 'lib/jeweler/generator.rb', line 118

def require_name
  self.project_name
end

#runObject



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/jeweler/generator.rb', line 90

def run
  create_files
  gitify
  $stdout.puts "Jeweler has prepared your gem in #{target_dir}"
  if should_create_repo
    create_and_push_repo
    $stdout.puts "Jeweler has pushed your repo to #{project_homepage}"
    enable_gem_for_repo
    $stdout.puts "Jeweler has enabled gem building for your repo"
  end
end

#steps_filenameObject



134
135
136
# File 'lib/jeweler/generator.rb', line 134

def steps_filename
  "#{project_name}_steps.rb"
end