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/riot_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/github_mixin.rb,
lib/jeweler/generator/shindo_mixin.rb,
lib/jeweler/generator/shoulda_mixin.rb,
lib/jeweler/generator/minitest_mixin.rb,
lib/jeweler/generator/testspec_mixin.rb,
lib/jeweler/generator/testunit_mixin.rb,
lib/jeweler/generator/micronaut_mixin.rb

Overview

Generator for creating a jeweler-enabled project

Defined Under Namespace

Modules: BaconMixin, GithubMixin, MicronautMixin, MinitestMixin, RdocMixin, RiotMixin, RspecMixin, ShindoMixin, ShouldaMixin, TestspecMixin, TestunitMixin, YardMixin Classes: Application, Options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Generator

Returns a new instance of Generator.

Raises:



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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# 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

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def description
  @description
end

#development_dependenciesObject

Returns the value of attribute development_dependencies.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def development_dependencies
  @development_dependencies
end

#documentation_frameworkObject

Returns the value of attribute documentation_framework.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def documentation_framework
  @documentation_framework
end

#git_remoteObject

Returns the value of attribute git_remote.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def git_remote
  @git_remote
end

#github_tokenObject

Returns the value of attribute github_token.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def github_token
  @github_token
end

#github_usernameObject

Returns the value of attribute github_username.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def github_username
  @github_username
end

#homepageObject

Returns the value of attribute homepage.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def homepage
  @homepage
end

#optionsObject

Returns the value of attribute options.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def options
  @options
end

#project_nameObject

Returns the value of attribute project_name.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def project_name
  @project_name
end

#repoObject

Returns the value of attribute repo.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def repo
  @repo
end

#should_create_remote_repoObject

Returns the value of attribute should_create_remote_repo.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def should_create_remote_repo
  @should_create_remote_repo
end

#should_setup_rubyforgeObject

Returns the value of attribute should_setup_rubyforge.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def should_setup_rubyforge
  @should_setup_rubyforge
end

#should_use_bundlerObject

Returns the value of attribute should_use_bundler.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def should_use_bundler
  @should_use_bundler
end

#should_use_cucumberObject

Returns the value of attribute should_use_cucumber.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def should_use_cucumber
  @should_use_cucumber
end

#should_use_reekObject

Returns the value of attribute should_use_reek.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def should_use_reek
  @should_use_reek
end

#should_use_roodiObject

Returns the value of attribute should_use_roodi.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def should_use_roodi
  @should_use_roodi
end

#summaryObject

Returns the value of attribute summary.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def summary
  @summary
end

#target_dirObject

Returns the value of attribute target_dir.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def target_dir
  @target_dir
end

#testing_frameworkObject

Returns the value of attribute testing_framework.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def testing_framework
  @testing_framework
end

#user_emailObject

Returns the value of attribute user_email.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def user_email
  @user_email
end

#user_nameObject

Returns the value of attribute user_name.



48
49
50
# File 'lib/jeweler/generator.rb', line 48

def user_name
  @user_name
end

Instance Method Details

#constant_nameObject



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

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

#feature_filenameObject



155
156
157
# File 'lib/jeweler/generator.rb', line 155

def feature_filename
  "#{project_name}.feature"
end

#features_dirObject



163
164
165
# File 'lib/jeweler/generator.rb', line 163

def features_dir
  'features'
end

#features_steps_dirObject



171
172
173
# File 'lib/jeweler/generator.rb', line 171

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

#features_support_dirObject



167
168
169
# File 'lib/jeweler/generator.rb', line 167

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

#file_name_prefixObject



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

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

#lib_dirObject



151
152
153
# File 'lib/jeweler/generator.rb', line 151

def lib_dir
  'lib'
end

#lib_filenameObject



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

def lib_filename
  "#{project_name}.rb"
end

#require_nameObject



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

def require_name
  self.project_name
end

#runObject



125
126
127
128
129
130
131
132
133
# 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_filenameObject



159
160
161
# File 'lib/jeweler/generator.rb', line 159

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