Class: VersionTracker::CommandLine
- Inherits:
-
Object
- Object
- VersionTracker::CommandLine
- Defined in:
- lib/version_tracker/command_line.rb
Defined Under Namespace
Modules: COMMANDS, RESULT_STATUS
Constant Summary collapse
- VALID_COMMANDS =
%w(init bump read tag)- VALID_PARTS =
%w(major minor patch)- DEFAULT_PART =
'patch'- DEFAULT_COMMIT_MESSAGE =
'Set Version to'
Instance Method Summary collapse
- #execute(args = [], options = {}) ⇒ Object
-
#initialize ⇒ CommandLine
constructor
A new instance of CommandLine.
Constructor Details
#initialize ⇒ CommandLine
Returns a new instance of CommandLine.
29 30 31 |
# File 'lib/version_tracker/command_line.rb', line 29 def initialize @version_tracker = VersionTracker::Bumper.new end |
Instance Method Details
#execute(args = [], options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/version_tracker/command_line.rb', line 34 def execute args = [], = {} command = args[0] || COMMANDS::READ raise VersionTrackerError, 'Invalid command' unless VALID_COMMANDS.include?(command) = .merge(:argument => args[1]) result = case command when COMMANDS::INIT @version_tracker.init [:argument] @version_tracker.version when COMMANDS::READ @version_tracker.version when COMMANDS::TAG self.git_tag "Successfully created tag for #{@version_tracker.version}" when COMMANDS::BUMP self.bump @version_tracker.version end self.release if !![:release] self.push if !![:push] && ![:release] [result, RESULT_STATUS::SUCCESS] rescue VersionTrackerError => e return [e., RESULT_STATUS::ERROR] end |