Class: Bueller::Generator

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

Overview

Generator for creating a bueller-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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Generator

Returns a new instance of Generator.

Raises:



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
# File 'lib/bueller/generator.rb', line 66

def initialize(options = {})
  self.options = options

  self.project_name   = options[:project_name]
  if self.project_name.nil? || self.project_name.squeeze.strip == ""
    raise NoGitHubRepoNameGiven
  end

  self.development_dependencies = []
  self.testing_framework  = options[:testing_framework]
  self.documentation_framework = options[:documentation_framework]
  begin
    generator_mixin_name = "#{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.summary                = options[:summary] || 'TODO: one-line summary of your gem'
  self.description            = options[:description] || 'TODO: detailed description of your gem'
  self.use_cucumber    = options[:use_cucumber]
  self.use_reek        = options[:use_reek]
  self.use_roodi       = options[:use_roodi]
  self.setup_gemcutter = options[:gemcutter]
  self.setup_rubyforge = options[:rubyforge]

  development_dependencies << 'cucumber' if use_cucumber?

  development_dependencies << 'bueller'

  development_dependencies << 'reek' if use_reek?
  development_dependencies << 'roodi' if 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

#create_remote_repoObject Also known as: create_remote_repo?

Returns the value of attribute create_remote_repo.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def create_remote_repo
  @create_remote_repo
end

#descriptionObject

Returns the value of attribute description.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def description
  @description
end

#development_dependenciesObject

Returns the value of attribute development_dependencies.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def development_dependencies
  @development_dependencies
end

#documentation_frameworkObject

Returns the value of attribute documentation_framework.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def documentation_framework
  @documentation_framework
end

#git_remoteObject

Returns the value of attribute git_remote.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def git_remote
  @git_remote
end

#github_tokenObject

Returns the value of attribute github_token.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def github_token
  @github_token
end

#github_usernameObject

Returns the value of attribute github_username.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def github_username
  @github_username
end

#homepageObject

Returns the value of attribute homepage.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def homepage
  @homepage
end

#optionsObject

Returns the value of attribute options.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def options
  @options
end

#project_nameObject

Returns the value of attribute project_name.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def project_name
  @project_name
end

#repoObject

Returns the value of attribute repo.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def repo
  @repo
end

#setup_gemcutterObject

Returns the value of attribute setup_gemcutter.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def setup_gemcutter
  @setup_gemcutter
end

#setup_rubyforgeObject Also known as: setup_rubyforge?

Returns the value of attribute setup_rubyforge.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def setup_rubyforge
  @setup_rubyforge
end

#summaryObject

Returns the value of attribute summary.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def summary
  @summary
end

#target_dirObject

Returns the value of attribute target_dir.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def target_dir
  @target_dir
end

#testing_frameworkObject

Returns the value of attribute testing_framework.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def testing_framework
  @testing_framework
end

#use_cucumberObject Also known as: use_cucumber?

Returns the value of attribute use_cucumber.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def use_cucumber
  @use_cucumber
end

#use_reekObject Also known as: use_reek?

Returns the value of attribute use_reek.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def use_reek
  @use_reek
end

#use_roodiObject Also known as: use_roodi?

Returns the value of attribute use_roodi.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def use_roodi
  @use_roodi
end

#user_emailObject

Returns the value of attribute user_email.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def user_email
  @user_email
end

#user_nameObject

Returns the value of attribute user_name.



45
46
47
# File 'lib/bueller/generator.rb', line 45

def user_name
  @user_name
end

Class Method Details

.run(options = {}) ⇒ Object



61
62
63
64
# File 'lib/bueller/generator.rb', line 61

def self.run(options = {})
  generator = self.new(options)
  generator.run
end

Instance Method Details

#constant_nameObject



132
133
134
# File 'lib/bueller/generator.rb', line 132

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

#feature_filenameObject



152
153
154
# File 'lib/bueller/generator.rb', line 152

def feature_filename
  "#{project_name}.feature"
end

#features_dirObject



160
161
162
# File 'lib/bueller/generator.rb', line 160

def features_dir
  'features'
end

#features_steps_dirObject



168
169
170
# File 'lib/bueller/generator.rb', line 168

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

#features_support_dirObject



164
165
166
# File 'lib/bueller/generator.rb', line 164

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

#file_name_prefixObject



144
145
146
# File 'lib/bueller/generator.rb', line 144

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

#lib_dirObject



148
149
150
# File 'lib/bueller/generator.rb', line 148

def lib_dir
  'lib'
end

#lib_filenameObject



136
137
138
# File 'lib/bueller/generator.rb', line 136

def lib_filename
  "#{project_name}.rb"
end

#require_nameObject



140
141
142
# File 'lib/bueller/generator.rb', line 140

def require_name
  self.project_name
end

#runObject



122
123
124
125
126
127
128
129
130
# File 'lib/bueller/generator.rb', line 122

def run
  create_files
  create_version_control
  $stdout.puts "Bueller has prepared your gem in #{target_dir}"
  if create_remote_repo?
    create_and_push_repo
    $stdout.puts "Bueller has pushed your repo to #{homepage}"
  end
end

#steps_filenameObject



156
157
158
# File 'lib/bueller/generator.rb', line 156

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