Sha256: e4c151863ffda1e9e846288bd5d0ed7125a2fc85d0ab76caf4233fc676ad1b8b

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require 'pgit'

module PGit
  module Bilateral
    class Story < ResponseHandler
      include Interactive
      def initialize(options)
        raise PGit::Error::User, "Invalid options. See `pgit iteration -h` for valid options." unless options_has_valid_scope(options)

        @iterations_obj = PGit::Pivotal::Iterations.new(get_scope_hash(options))
        @iterations = @iterations_obj.get!
        @question = _question
        @response_handlers = [PGit::Bilateral::HandleChooseStory]
      end

      def stories
        @iterations.inject([]) { |accum, iteration| accum | iteration.stories }
      end

      private

      def options(new_response)
        {response: new_response, stories: stories, parent_question: @question}
      end

      def _question
        Question.new do |q|
          q.question = "Which story do you want to branch-ify?"
          q.options = [stories, :back]
          q.columns = [:index, :story_type, :estimate, :name, :current_state]
        end
      end

      def get_scope_hash(options)
        options.select {|k,v| k == :scope}
      end

      def options_has_valid_scope(options)
        [:done, :current, :current_backlog, :backlog].inject(false) {|accum, valid_scope| accum || options.fetch(:scope).to_sym == valid_scope}

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pgit-1.0.0 lib/pgit/bilateral/story.rb