Class: Avm::Git::AutoCommitPath
- Defined in:
- lib/avm/git/auto_commit_path.rb
Constant Summary collapse
- CLASS_NAME_PATTERNS =
[%r{lib/((?!.*/lib/).+)\.rb\z}, %r{app/[^/]+/(.+)\.rb\z}].freeze
Instance Method Summary collapse
- #banner ⇒ Object
- #class_name ⇒ Object
- #commit ⇒ Object
- #commit_message ⇒ Object
- #relative_path ⇒ Object
- #run ⇒ Object
Instance Method Details
#banner ⇒ Object
20 21 22 23 24 |
# File 'lib/avm/git/auto_commit_path.rb', line 20 def infom "Checking \"#{relative_path}\"" infov ' * Class name', class_name infov ' * Commit message', end |
#class_name ⇒ Object
33 34 35 36 37 38 |
# File 'lib/avm/git/auto_commit_path.rb', line 33 def class_name CLASS_NAME_PATTERNS.each do |pattern| pattern.if_match(relative_path.to_path, false) { |m| return m[1].camelize } end raise "No pattern matched \"#{relative_path}\"" end |
#commit ⇒ Object
26 27 28 29 30 31 |
# File 'lib/avm/git/auto_commit_path.rb', line 26 def commit infom ' * Commiting...' git.system!('reset', 'HEAD') git.system!('add', '--', relative_path.to_path) git.system!('commit', '-m', , '--', relative_path.to_path) end |
#commit_message ⇒ Object
40 41 42 43 44 |
# File 'lib/avm/git/auto_commit_path.rb', line 40 def r = class_name r += ': remove' unless path.file? r + '.' end |
#relative_path ⇒ Object
46 47 48 |
# File 'lib/avm/git/auto_commit_path.rb', line 46 def relative_path path.relative_path_from(git.root_path) end |
#run ⇒ Object
15 16 17 18 |
# File 'lib/avm/git/auto_commit_path.rb', line 15 def run commit end |