Class: PreCommit::Template
- Inherits:
-
Object
- Object
- PreCommit::Template
- Defined in:
- lib/pre-commit/template.rb
Constant Summary collapse
- TEMPLATE_DIR =
File.("../../../templates/gem", __FILE__)
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#copyright ⇒ Object
readonly
Returns the value of attribute copyright.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#gem_name ⇒ Object
readonly
Returns the value of attribute gem_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #all_files ⇒ Object
-
#initialize(*args) ⇒ Template
constructor
A new instance of Template.
- #save ⇒ Object
- #target_path(file) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Template
Returns a new instance of Template.
11 12 13 14 15 16 |
# File 'lib/pre-commit/template.rb', line 11 def initialize(*args) @name, @author, @email, @description = args @gem_name = "pre-commit-#{name}" @copyright = "#{Date.today.year} #{} #{email}" validate_params end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
9 10 11 |
# File 'lib/pre-commit/template.rb', line 9 def @author end |
#copyright ⇒ Object (readonly)
Returns the value of attribute copyright.
9 10 11 |
# File 'lib/pre-commit/template.rb', line 9 def copyright @copyright end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
9 10 11 |
# File 'lib/pre-commit/template.rb', line 9 def description @description end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
9 10 11 |
# File 'lib/pre-commit/template.rb', line 9 def email @email end |
#gem_name ⇒ Object (readonly)
Returns the value of attribute gem_name.
9 10 11 |
# File 'lib/pre-commit/template.rb', line 9 def gem_name @gem_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/pre-commit/template.rb', line 9 def name @name end |
Instance Method Details
#all_files ⇒ Object
31 32 33 34 |
# File 'lib/pre-commit/template.rb', line 31 def all_files Dir.glob("#{TEMPLATE_DIR}/**/*", File::FNM_DOTMATCH) .reject { |path| File.directory?(path) } end |
#save ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pre-commit/template.rb', line 18 def save puts "Generating #{gem_name}" all_files.each{|file| parse_and_save(file) } initialize_git puts <<-STEPS Next steps: - write your checks and tests for them - push code to github - open a ticket to merge your project: https://github.com/jish/pre-commit/issues STEPS end |
#target_path(file) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/pre-commit/template.rb', line 36 def target_path(file) file .sub(TEMPLATE_DIR, gem_name) .sub("GEM_NAME", gem_name) .sub("PLUGIN_NAME", name) end |