Class: Jeweler::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/jeweler/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Generator.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/jeweler/generator.rb', line 30

def initialize(github_repo_name, options = {})
  check_user_git_config()
  
  if github_repo_name.nil?
    raise NoGitHubRepoNameGiven
  end
  self.github_repo_name = github_repo_name

  self.github_remote = "[email protected]:#{github_username}/#{github_repo_name}.git"
  self.github_url = "http://github.com/#{github_username}/#{github_repo_name}"

  self.test_style = options[:test_style] || :shoulda
  self.target_dir = options[:directory] || self.github_repo_name
  self.lib_dir = File.join(target_dir, 'lib')
  self.constant_name = self.github_repo_name.split(/[-_]/).collect{|each| each.capitalize }.join
  self.file_name_prefix = self.github_repo_name.gsub('-', '_')
  self.should_create_repo = options[:create_repo]
  self.summary = options[:summary] || 'TODO'
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def config
  @config
end

#constant_nameObject

Returns the value of attribute constant_name.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def constant_name
  @constant_name
end

#file_name_prefixObject

Returns the value of attribute file_name_prefix.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def file_name_prefix
  @file_name_prefix
end

#github_remoteObject

Returns the value of attribute github_remote.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def github_remote
  @github_remote
end

#github_repo_nameObject

Returns the value of attribute github_repo_name.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def github_repo_name
  @github_repo_name
end

#github_tokenObject

Returns the value of attribute github_token.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def github_token
  @github_token
end

#github_urlObject

Returns the value of attribute github_url.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def github_url
  @github_url
end

#github_usernameObject

Returns the value of attribute github_username.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def github_username
  @github_username
end

#lib_dirObject

Returns the value of attribute lib_dir.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def lib_dir
  @lib_dir
end

#repoObject

Returns the value of attribute repo.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def repo
  @repo
end

#should_create_repoObject

Returns the value of attribute should_create_repo.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def should_create_repo
  @should_create_repo
end

#summaryObject

Returns the value of attribute summary.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def summary
  @summary
end

#target_dirObject

Returns the value of attribute target_dir.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def target_dir
  @target_dir
end

#test_styleObject

Returns the value of attribute test_style.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def test_style
  @test_style
end

#user_emailObject

Returns the value of attribute user_email.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def user_email
  @user_email
end

#user_nameObject

Returns the value of attribute user_name.



24
25
26
# File 'lib/jeweler/generator.rb', line 24

def user_name
  @user_name
end

Instance Method Details

#runObject



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/jeweler/generator.rb', line 50

def run
  create_files
  gitify
  puts "Jeweler has prepared your gem in #{github_repo_name}"
  if should_create_repo
    create_and_push_repo
    puts "Jeweler has pushed your repo to #{github_url}"
    enable_gem_for_repo
    puts "Jeweler has enabled gem building for your repo"
  end
end

#test_dirObject



71
72
73
# File 'lib/jeweler/generator.rb', line 71

def test_dir
  File.join(target_dir, testspec)
end

#testspecObject



62
63
64
65
66
67
68
69
# File 'lib/jeweler/generator.rb', line 62

def testspec
  case test_style
  when :shoulda
    'test'
  when :bacon
    'spec'
  end
end