Class: Juwelier::Generator
- Inherits:
-
Object
- Object
- Juwelier::Generator
- Defined in:
- lib/juwelier/generator.rb,
lib/juwelier/generator/options.rb,
lib/juwelier/generator/rdoc_mixin.rb,
lib/juwelier/generator/riot_mixin.rb,
lib/juwelier/generator/yard_mixin.rb,
lib/juwelier/generator/application.rb,
lib/juwelier/generator/bacon_mixin.rb,
lib/juwelier/generator/rspec_mixin.rb,
lib/juwelier/generator/github_mixin.rb,
lib/juwelier/generator/shindo_mixin.rb,
lib/juwelier/generator/shoulda_mixin.rb,
lib/juwelier/generator/minitest_mixin.rb,
lib/juwelier/generator/testspec_mixin.rb,
lib/juwelier/generator/testunit_mixin.rb,
lib/juwelier/generator/micronaut_mixin.rb
Overview
Generator for creating a juwelier-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
-
#description ⇒ Object
Returns the value of attribute description.
-
#development_dependencies ⇒ Object
Returns the value of attribute development_dependencies.
-
#documentation_framework ⇒ Object
Returns the value of attribute documentation_framework.
-
#git_remote ⇒ Object
Returns the value of attribute git_remote.
-
#github_username ⇒ Object
Returns the value of attribute github_username.
-
#homepage ⇒ Object
Returns the value of attribute homepage.
-
#options ⇒ Object
Returns the value of attribute options.
-
#production_dependencies ⇒ Object
Returns the value of attribute production_dependencies.
-
#project_name ⇒ Object
Returns the value of attribute project_name.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#require_ruby_version ⇒ Object
Returns the value of attribute require_ruby_version.
-
#should_create_bin ⇒ Object
Returns the value of attribute should_create_bin.
-
#should_create_remote_repo ⇒ Object
Returns the value of attribute should_create_remote_repo.
-
#should_setup_rubyforge ⇒ Object
Returns the value of attribute should_setup_rubyforge.
-
#should_use_bundler ⇒ Object
Returns the value of attribute should_use_bundler.
-
#should_use_cucumber ⇒ Object
Returns the value of attribute should_use_cucumber.
-
#should_use_pry ⇒ Object
Returns the value of attribute should_use_pry.
-
#should_use_reek ⇒ Object
Returns the value of attribute should_use_reek.
-
#should_use_roodi ⇒ Object
Returns the value of attribute should_use_roodi.
-
#should_use_semver ⇒ Object
Returns the value of attribute should_use_semver.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#target_dir ⇒ Object
Returns the value of attribute target_dir.
-
#testing_framework ⇒ Object
Returns the value of attribute testing_framework.
-
#use_readme_format ⇒ Object
Returns the value of attribute use_readme_format.
-
#user_email ⇒ Object
Returns the value of attribute user_email.
-
#user_name ⇒ Object
Returns the value of attribute user_name.
Instance Method Summary collapse
- #bin_dir ⇒ Object
- #bin_filename ⇒ Object
- #constant_name ⇒ Object
- #feature_filename ⇒ Object
- #features_dir ⇒ Object
- #features_steps_dir ⇒ Object
- #features_support_dir ⇒ Object
- #file_name_prefix ⇒ Object
-
#initialize(options = {}) ⇒ Generator
constructor
A new instance of Generator.
- #lib_dir ⇒ Object
- #lib_filename ⇒ Object
- #require_name ⇒ Object
- #run ⇒ Object
- #steps_filename ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Generator
Returns a new instance of Generator.
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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/juwelier/generator.rb', line 61 def initialize( = {}) self. = extracted_directory = nil self.project_name = [: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.production_dependencies = [] self.testing_framework = [:testing_framework] self.documentation_framework = [: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 = [:directory] || extracted_directory || self.project_name self.summary = [:summary] || 'TODO: one-line summary of your gem' self.description = [:description] || 'TODO: longer description of your gem' self.should_use_cucumber = [:use_cucumber] self.should_use_reek = [:use_reek] self.should_use_roodi = [:use_roodi] self.should_setup_rubyforge = [:rubyforge] self.should_use_bundler = [:use_bundler] self.should_use_semver = [:use_semver] self.require_ruby_version = [:use_required_version] self.should_create_bin = [:create_bin] self.should_use_pry = [:use_pry] self.use_readme_format = [:readme_format] development_dependencies << ["cucumber", ">= 0"] if should_use_cucumber development_dependencies << ["bundler", "~> 1.0"] development_dependencies << ["juwelier", "~> #{Juwelier::Version::STRING}"] development_dependencies << ["simplecov", ">= 0"] development_dependencies << ["reek", "~> 1.2.8"] if should_use_reek development_dependencies << ["roodi", "~> 2.1.0"] if should_use_roodi development_dependencies << ["pry", "~> 0"] << ["pry-byebug", "~> 3"] << ["pry-doc", "~> 0"] << ["pry-remote", "~> 0"] << ["pry-rescue", "~> 1"] << ["pry-stack_explorer", "~> 0"] if should_use_pry production_dependencies << ["semver", "~> 1.0.1"] if should_use_semver self.user_name = [:user_name] self.user_email = [:user_email] self.homepage = [:homepage] self.git_remote = [:git_remote] raise NoGitUserName unless self.user_name raise NoGitUserEmail unless self.user_email extend GithubMixin end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def description @description end |
#development_dependencies ⇒ Object
Returns the value of attribute development_dependencies.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def development_dependencies @development_dependencies end |
#documentation_framework ⇒ Object
Returns the value of attribute documentation_framework.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def documentation_framework @documentation_framework end |
#git_remote ⇒ Object
Returns the value of attribute git_remote.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def git_remote @git_remote end |
#github_username ⇒ Object
Returns the value of attribute github_username.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def github_username @github_username end |
#homepage ⇒ Object
Returns the value of attribute homepage.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def homepage @homepage end |
#options ⇒ Object
Returns the value of attribute options.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def @options end |
#production_dependencies ⇒ Object
Returns the value of attribute production_dependencies.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def production_dependencies @production_dependencies end |
#project_name ⇒ Object
Returns the value of attribute project_name.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def project_name @project_name end |
#repo ⇒ Object
Returns the value of attribute repo.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def repo @repo end |
#require_ruby_version ⇒ Object
Returns the value of attribute require_ruby_version.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def require_ruby_version @require_ruby_version end |
#should_create_bin ⇒ Object
Returns the value of attribute should_create_bin.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def should_create_bin @should_create_bin end |
#should_create_remote_repo ⇒ Object
Returns the value of attribute should_create_remote_repo.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def should_create_remote_repo @should_create_remote_repo end |
#should_setup_rubyforge ⇒ Object
Returns the value of attribute should_setup_rubyforge.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def should_setup_rubyforge @should_setup_rubyforge end |
#should_use_bundler ⇒ Object
Returns the value of attribute should_use_bundler.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def should_use_bundler @should_use_bundler end |
#should_use_cucumber ⇒ Object
Returns the value of attribute should_use_cucumber.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def should_use_cucumber @should_use_cucumber end |
#should_use_pry ⇒ Object
Returns the value of attribute should_use_pry.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def should_use_pry @should_use_pry end |
#should_use_reek ⇒ Object
Returns the value of attribute should_use_reek.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def should_use_reek @should_use_reek end |
#should_use_roodi ⇒ Object
Returns the value of attribute should_use_roodi.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def should_use_roodi @should_use_roodi end |
#should_use_semver ⇒ Object
Returns the value of attribute should_use_semver.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def should_use_semver @should_use_semver end |
#summary ⇒ Object
Returns the value of attribute summary.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def summary @summary end |
#target_dir ⇒ Object
Returns the value of attribute target_dir.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def target_dir @target_dir end |
#testing_framework ⇒ Object
Returns the value of attribute testing_framework.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def testing_framework @testing_framework end |
#use_readme_format ⇒ Object
Returns the value of attribute use_readme_format.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def use_readme_format @use_readme_format end |
#user_email ⇒ Object
Returns the value of attribute user_email.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def user_email @user_email end |
#user_name ⇒ Object
Returns the value of attribute user_name.
51 52 53 |
# File 'lib/juwelier/generator.rb', line 51 def user_name @user_name end |
Instance Method Details
#bin_dir ⇒ Object
177 178 179 |
# File 'lib/juwelier/generator.rb', line 177 def bin_dir 'bin' end |
#bin_filename ⇒ Object
161 162 163 |
# File 'lib/juwelier/generator.rb', line 161 def bin_filename "#{should_create_bin}" end |
#constant_name ⇒ Object
153 154 155 |
# File 'lib/juwelier/generator.rb', line 153 def constant_name self.project_name.split(/[-_]/).collect{|each| each.capitalize }.join end |
#feature_filename ⇒ Object
181 182 183 |
# File 'lib/juwelier/generator.rb', line 181 def feature_filename "#{project_name}.feature" end |
#features_dir ⇒ Object
189 190 191 |
# File 'lib/juwelier/generator.rb', line 189 def features_dir 'features' end |
#features_steps_dir ⇒ Object
197 198 199 |
# File 'lib/juwelier/generator.rb', line 197 def features_steps_dir File.join(features_dir, 'step_definitions') end |
#features_support_dir ⇒ Object
193 194 195 |
# File 'lib/juwelier/generator.rb', line 193 def features_support_dir File.join(features_dir, 'support') end |
#file_name_prefix ⇒ Object
169 170 171 |
# File 'lib/juwelier/generator.rb', line 169 def file_name_prefix self.project_name.gsub('-', '_') end |
#lib_dir ⇒ Object
173 174 175 |
# File 'lib/juwelier/generator.rb', line 173 def lib_dir 'lib' end |
#lib_filename ⇒ Object
157 158 159 |
# File 'lib/juwelier/generator.rb', line 157 def lib_filename "#{project_name}.rb" end |
#require_name ⇒ Object
165 166 167 |
# File 'lib/juwelier/generator.rb', line 165 def require_name self.project_name end |
#run ⇒ Object
143 144 145 146 147 148 149 150 151 |
# File 'lib/juwelier/generator.rb', line 143 def run create_files create_version_control $stdout.puts "Juwelier has prepared your gem in #{target_dir}" if should_create_remote_repo create_and_push_repo $stdout.puts "Juwelier has pushed your repo to #{git_remote}" end end |
#steps_filename ⇒ Object
185 186 187 |
# File 'lib/juwelier/generator.rb', line 185 def steps_filename "#{project_name}_steps.rb" end |