Sha256: 89fce724461a5b75f606d40d4a76c64a5bc7cfc10b3a7687b7743e24c31fff54

Contents?: true

Size: 870 Bytes

Versions: 11

Compression:

Stored size: 870 Bytes

Contents

require "cp8_cli/adhoc_story"
require "cp8_cli/github/issue"

module Cp8Cli
  module Commands
    class Start
      def initialize(name)
        @name = name
      end

      def run
        check_version
        if story
          story.start
        else
          Command.error "No name/url provided"
        end
      end

      private

        attr_reader :name

        def check_version
          unless Version.latest?
            Command.error "Your `cp8_cli` version is out of date. Please run `gem update cp8_cli`."
          end
        end

        def story
          @_story ||= find_or_create_story
        end

        def find_or_create_story
          if name.to_s.start_with?("https://github.com")
            Github::Issue.find_by_url(name)
          elsif name.present?
            AdhocStory.new(name)
          end
        end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cp8_cli-9.1.1 lib/cp8_cli/commands/start.rb
cp8_cli-9.1.0 lib/cp8_cli/commands/start.rb
cp8_cli-9.0.3 lib/cp8_cli/commands/start.rb
cp8_cli-9.0.2 lib/cp8_cli/commands/start.rb
cp8_cli-9.0.1 lib/cp8_cli/commands/start.rb
cp8_cli-9.0.0 lib/cp8_cli/commands/start.rb
cp8_cli-8.2.1 lib/cp8_cli/commands/start.rb
cp8_cli-8.2.0 lib/cp8_cli/commands/start.rb
cp8_cli-8.1.0 lib/cp8_cli/commands/start.rb
cp8_cli-8.0.1 lib/cp8_cli/commands/start.rb
cp8_cli-8.0.0 lib/cp8_cli/commands/start.rb