Class: Gem::Create::Builder
- Inherits:
-
Object
- Object
- Gem::Create::Builder
- Defined in:
- lib/rubygems/create/builder.rb
Overview
The Builder class is used to provide variables in ERB templates.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name of the gem.
-
#options ⇒ Object
readonly
The options supplied to the command line.
Instance Method Summary collapse
-
#author ⇒ Object
Returns the gem author’s name.
-
#email ⇒ Object
Returns the gem author’s email address.
-
#gem_class ⇒ Object
The class name of the gem in CamelCase.
-
#get_binding ⇒ Object
Returns the binding of this object.
-
#git ⇒ Object
The path to git.
-
#git_config(key) ⇒ Object
Returns the given variable from ‘git config`.
-
#github_name ⇒ Object
Returns the gem author’s Github username.
-
#initialize(name, options = {}) ⇒ Builder
constructor
Creates a new Builder.
-
#path ⇒ Object
The path of the gem.
Constructor Details
#initialize(name, options = {}) ⇒ Builder
Creates a new Builder
name - The name of the gem. options - The options used to create the gem.
14 15 16 17 |
# File 'lib/rubygems/create/builder.rb', line 14 def initialize(name, = {}) @options = @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name of the gem.
5 6 7 |
# File 'lib/rubygems/create/builder.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
The options supplied to the command line.
8 9 10 |
# File 'lib/rubygems/create/builder.rb', line 8 def @options end |
Instance Method Details
#author ⇒ Object
Returns the gem author’s name.
25 26 27 |
# File 'lib/rubygems/create/builder.rb', line 25 def [:author] || git_config('user.name') end |
#email ⇒ Object
Returns the gem author’s email address.
30 31 32 |
# File 'lib/rubygems/create/builder.rb', line 30 def email [:email] || git_config('user.email') end |
#gem_class ⇒ Object
The class name of the gem in CamelCase.
59 60 61 |
# File 'lib/rubygems/create/builder.rb', line 59 def gem_class name.split('-').map { |seg| seg.gsub(/(?:^|_| )(.)/) { $1.upcase } }.join('::') end |
#get_binding ⇒ Object
Returns the binding of this object.
20 21 22 |
# File 'lib/rubygems/create/builder.rb', line 20 def get_binding binding end |
#git ⇒ Object
The path to git.
49 50 51 |
# File 'lib/rubygems/create/builder.rb', line 49 def git [:git] || "git" end |
#git_config(key) ⇒ Object
Returns the given variable from ‘git config`
key - The key to query.
Returns a String.
44 45 46 |
# File 'lib/rubygems/create/builder.rb', line 44 def git_config(key) %x{#{git} config --global #{key} 2> /dev/null}.chomp.strip end |
#github_name ⇒ Object
Returns the gem author’s Github username.
35 36 37 |
# File 'lib/rubygems/create/builder.rb', line 35 def github_name [:github_name] || git_config('github.user') end |
#path ⇒ Object
The path of the gem.
54 55 56 |
# File 'lib/rubygems/create/builder.rb', line 54 def path name.gsub('-', '/') end |