Class: GemInit::App
Constant Summary collapse
- DEFAULT_GIT_CONFIG =
{ :user => { :name => "YOUR NAME", :email => "YOUR EMAIL", }, :github => { :name => "your_github_user_name" } }
Instance Attribute Summary collapse
-
#gem_name ⇒ Object
readonly
Returns the value of attribute gem_name.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
Instance Method Summary collapse
- #author ⇒ Object
- #email ⇒ Object
- #github_user ⇒ Object
-
#initialize(gem_name) ⇒ App
constructor
A new instance of App.
- #main ⇒ Object
Constructor Details
#initialize(gem_name) ⇒ App
Returns a new instance of App.
23 24 25 26 |
# File 'lib/gem_init/app.rb', line 23 def initialize(gem_name) @gem_name = gem_name.downcase @templates = File.("../templates", __FILE__) end |
Instance Attribute Details
#gem_name ⇒ Object (readonly)
Returns the value of attribute gem_name.
9 10 11 |
# File 'lib/gem_init/app.rb', line 9 def gem_name @gem_name end |
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
11 12 13 |
# File 'lib/gem_init/app.rb', line 11 def templates @templates end |
Instance Method Details
#author ⇒ Object
48 49 50 |
# File 'lib/gem_init/app.rb', line 48 def @author ||= git_config[:user][:name] end |
#email ⇒ Object
52 53 54 |
# File 'lib/gem_init/app.rb', line 52 def email @email ||= git_config[:user][:email] end |
#github_user ⇒ Object
56 57 58 |
# File 'lib/gem_init/app.rb', line 56 def github_user @github_user ||= git_config[:github][:user] end |
#main ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gem_init/app.rb', line 28 def main if File.exists?(gem_name) raise "Directory '#{gem_name}' already exists, bailing out." end mkdir_p module_lib_dir mkdir_p test_dir write_template(lib_dir, "module.rb", "#{gem_name}.rb") write_template(module_lib_dir, "version.rb") write_template(test_dir, "test_helper.rb") write_template(test_dir, "module_test.rb", "#{gem_name}_test.rb") write_template(gem_name, "gemspec", "#{gem_name}.gemspec") write_template(gem_name, "Gemfile.default") write_template(gem_name, "Gemfile.default", "Gemfile") write_template(gem_name, "Rakefile") write_template(gem_name, "MIT-LICENSE") write_template(gem_name, "README.md") write_template(gem_name, "gitignore", ".gitignore") `git init #{gem_name.shellescape}` end |