Class: Appleseed::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/appleseed/options.rb,
lib/appleseed/generator.rb,
lib/appleseed/application.rb,
lib/appleseed/generator/github_mixin.rb

Defined Under Namespace

Modules: GithubMixin Classes: Application, Options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Generator

Returns a new instance of Generator.

Raises:



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

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

  # Adjust project name so that it's a valid project name on both GitHub and also Heroku.
  self.project_name = self.project_name.gsub /\W/, '-'

  self.target_dir             = self.project_name

  self.summary                = options[:summary] || 'TODO: one-line summary of your web site'
  self.description            = options[:description] || 'TODO: longer description of your web site'

  self.template_url    = options[:template_url] || File.join(File.dirname(__FILE__),'..','..','templates','default.rb')

  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

  self.should_create_heroku_deployment = !options[:no_heroku]
  
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def description
  @description
end

#development_dependenciesObject

Returns the value of attribute development_dependencies.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def development_dependencies
  @development_dependencies
end

#documentation_frameworkObject

Returns the value of attribute documentation_framework.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def documentation_framework
  @documentation_framework
end

#git_remoteObject

Returns the value of attribute git_remote.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def git_remote
  @git_remote
end

#homepageObject

Returns the value of attribute homepage.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def homepage
  @homepage
end

#optionsObject

Returns the value of attribute options.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def options
  @options
end

#project_nameObject

Returns the value of attribute project_name.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def project_name
  @project_name
end

#repoObject

Returns the value of attribute repo.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def repo
  @repo
end

#should_create_github_repositoryObject

Returns the value of attribute should_create_github_repository.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def should_create_github_repository
  @should_create_github_repository
end

#should_create_heroku_deploymentObject

Returns the value of attribute should_create_heroku_deployment.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def should_create_heroku_deployment
  @should_create_heroku_deployment
end

#should_setup_rubyforgeObject

Returns the value of attribute should_setup_rubyforge.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def should_setup_rubyforge
  @should_setup_rubyforge
end

#should_use_bundlerObject

Returns the value of attribute should_use_bundler.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def should_use_bundler
  @should_use_bundler
end

#should_use_cucumberObject

Returns the value of attribute should_use_cucumber.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def should_use_cucumber
  @should_use_cucumber
end

#should_use_reekObject

Returns the value of attribute should_use_reek.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def should_use_reek
  @should_use_reek
end

#should_use_roodiObject

Returns the value of attribute should_use_roodi.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def should_use_roodi
  @should_use_roodi
end

#summaryObject

Returns the value of attribute summary.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def summary
  @summary
end

#target_dirObject

Returns the value of attribute target_dir.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def target_dir
  @target_dir
end

#template_urlObject

Returns the value of attribute template_url.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def template_url
  @template_url
end

#testing_frameworkObject

Returns the value of attribute testing_framework.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def testing_framework
  @testing_framework
end

#user_emailObject

Returns the value of attribute user_email.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def user_email
  @user_email
end

#user_nameObject

Returns the value of attribute user_name.



32
33
34
# File 'lib/appleseed/generator.rb', line 32

def user_name
  @user_name
end

Instance Method Details

#constant_nameObject



91
92
93
# File 'lib/appleseed/generator.rb', line 91

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

#feature_filenameObject



111
112
113
# File 'lib/appleseed/generator.rb', line 111

def feature_filename
  "#{project_name}.feature"
end

#features_dirObject



119
120
121
# File 'lib/appleseed/generator.rb', line 119

def features_dir
  'features'
end

#features_steps_dirObject



127
128
129
# File 'lib/appleseed/generator.rb', line 127

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

#features_support_dirObject



123
124
125
# File 'lib/appleseed/generator.rb', line 123

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

#file_name_prefixObject



103
104
105
# File 'lib/appleseed/generator.rb', line 103

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

#lib_dirObject



107
108
109
# File 'lib/appleseed/generator.rb', line 107

def lib_dir
  'lib'
end

#lib_filenameObject



95
96
97
# File 'lib/appleseed/generator.rb', line 95

def lib_filename
  "#{project_name}.rb"
end

#require_nameObject



99
100
101
# File 'lib/appleseed/generator.rb', line 99

def require_name
  self.project_name
end

#runObject



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/appleseed/generator.rb', line 77

def run
  create_files
  create_version_control
  $stdout.puts "Appleseed has prepared your new web application project in #{target_dir}"
  if should_create_github_repository
    create_and_push_repo
    $stdout.puts "Appleseed has pushed your git repository to #{git_remote}"
  end
  if should_create_heroku_deployment
    create_and_push_deployment
    $stdout.puts "Appleseed has pushed your web application to heroku"
  end
end

#steps_filenameObject



115
116
117
# File 'lib/appleseed/generator.rb', line 115

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