Sha256: f35577b6b9209b1ca27a3cf1fcff6741f0f0e818bd4065d5f0574ba4b74f298e

Contents?: true

Size: 518 Bytes

Versions: 4

Compression:

Stored size: 518 Bytes

Contents

require 'i18n'
require 'active_support/core_ext/string/inflections'

module PT::Flow
  class Branch

    attr_accessor :name

    def self.current
      new(`git rev-parse --abbrev-ref HEAD`.strip)
    end

    def self.from_task(task)
      new("#{current.target}.#{task.name.parameterize[0..50]}.#{task.id}")
    end

    def initialize(name)
      @name = name
    end

    def target
      name.split('.').first
    end

    def task_id
      name[/\d+$/] || ''
    end

    def to_s
      name
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pt-flow-2.3.1 lib/pt-flow/branch.rb
pt-flow-2.3.0 lib/pt-flow/branch.rb
pt-flow-2.2.1 lib/pt-flow/branch.rb
pt-flow-2.2.0 lib/pt-flow/branch.rb