Module: TicGitNG::Command::State
- Defined in:
- lib/ticgit-ng/command/state.rb
Instance Method Summary collapse
- #available_states ⇒ Object
- #execute ⇒ Object
- #joined_states ⇒ Object
- #parser(opts) ⇒ Object
- #valid_state?(state) ⇒ Boolean
Instance Method Details
#available_states ⇒ Object
36 37 38 |
# File 'lib/ticgit-ng/command/state.rb', line 36 def available_states tic.tic_states.sort end |
#execute ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ticgit-ng/command/state.rb', line 8 def execute if args.size > 1 tid, new_state = args[0].strip, args[1].strip if valid_state?(new_state) tic.ticket_change(new_state, tid) else puts "Invalid State - please choose from: #{joined_states}" end elsif args.size > 0 # new state new_state = args[0].chomp if valid_state?(new_state) tic.ticket_change(new_state) else puts "Invalid State - please choose from: #{joined_states}" end else puts 'You need to at least specify a new state for the current ticket' puts "please choose from: #{joined_states}" end end |
#joined_states ⇒ Object
40 41 42 |
# File 'lib/ticgit-ng/command/state.rb', line 40 def joined_states available_states.join(', ') end |
#parser(opts) ⇒ Object
4 5 6 |
# File 'lib/ticgit-ng/command/state.rb', line 4 def parser(opts) opts. = "Usage: ti state [ticid] state" end |
#valid_state?(state) ⇒ Boolean
32 33 34 |
# File 'lib/ticgit-ng/command/state.rb', line 32 def valid_state?(state) available_states.include?(state) end |