Class: Historian::CLI
- Inherits:
-
Thor
- Object
- Thor
- Historian::CLI
- Defined in:
- lib/historian/cli.rb
Overview
require ‘thor/actions’
Instance Attribute Summary collapse
-
#git ⇒ Object
Returns the value of attribute git.
-
#history ⇒ Object
Returns the value of attribute history.
-
#repo_directory ⇒ Object
Returns the value of attribute repo_directory.
Instance Method Summary collapse
- #commit_msg(message_file) ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #install ⇒ Object
- #post_commit ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/historian/cli.rb', line 10 def initialize(*) super @repo_directory = ProjectScout.scan Dir.pwd, :for => [ :git_repository ] history_file = File.join(repo_directory, "History.txt") unless File.exists? history_file File.open history_file, "w" end @history = File.open history_file, File::RDWR history.sync = true history.extend Historian::HistoryFile self.git = Historian::Git.new(repo_directory, history) end |
Instance Attribute Details
#git ⇒ Object
Returns the value of attribute git.
6 7 8 |
# File 'lib/historian/cli.rb', line 6 def git @git end |
#history ⇒ Object
Returns the value of attribute history.
6 7 8 |
# File 'lib/historian/cli.rb', line 6 def history @history end |
#repo_directory ⇒ Object
Returns the value of attribute repo_directory.
6 7 8 |
# File 'lib/historian/cli.rb', line 6 def repo_directory @repo_directory end |
Instance Method Details
#commit_msg(message_file) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/historian/cli.rb', line 25 def commit_msg() return nil if File.exists? amend_flag_file history_updated = false release = nil = [] File.open().each_line do |line| line = Historian::CommitMessage.parse_line line << line.to_s unless line.suppressed? case line.significance when :minor, :major, :patch history.update_history line.significance => line. history_updated = true when :release release = line. end end if release history_updated = true history.update_history :release => release File.open release_flag_file, "w" end if history_updated File.open amend_flag_file, "w" File.open(,"w") { |f| f.puts } end end |
#install ⇒ Object
56 57 58 59 |
# File 'lib/historian/cli.rb', line 56 def install git.install_hook :commit_msg git.install_hook :post_commit end |
#post_commit ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/historian/cli.rb', line 62 def post_commit if File.exists? amend_flag_file File.unlink amend_flag_file git.bundle_history_file end if File.exists? release_flag_file File.unlink release_flag_file git.tag_release end end |