Class: GitPivot::Runner
- Inherits:
-
Object
- Object
- GitPivot::Runner
- Defined in:
- lib/runner.rb
Constant Summary collapse
- SUB_COMMANDS =
%w{current work display start finish note stack push tasks task complete}
- STATE_FILE =
"git_pivot.state"
Instance Method Summary collapse
-
#initialize(args) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ Runner
Returns a new instance of Runner.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/runner.rb', line 28 def initialize(args) @method, @cmd, @cmd_opts = process_args(args) # configuration stuff configuration = YAML.load_file("git_pivot.yml") if File.exist?(STATE_FILE) File.open(STATE_FILE) do |file| @states = Marshal.load(file) if @states.is_a?(Array) @states.uniq! else @states = nil end end end @git_pivot = GitPivot.new(configuration["project_id"], configuration["token"], configuration["owner"], configuration["use_git"]) end |
Instance Method Details
#run ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/runner.rb', line 47 def run args = [@method] if @method and @git_pivot.method(@method).arity.abs > 0 if @cmd_opts[:id] args << @cmd_opts[:id] elsif @states.any? args << @states.first else Trollop::die "Need to specify a story id" end if @cmd_opts[:name] args << @cmd_opts[:name].join(' ') end if @cmd_opts[:text] args << @cmd_opts[:text].join(' ') end if @cmd_opts[:"task-id"] args << @cmd_opts[:"task-id"] end end if @method == :start_story add_story_to_states(@cmd_opts[:id]) end if @method @git_pivot.send(*args) end # must do this after, in case finish fails, don't want to pop if @method == :finish_story if @states and @states.first == args[1] @states.shift save_state end end case @cmd when "stack" puts @states when "push" add_story_to_states(@cmd_opts[:id]) puts @states end end |