Sha256: 50d12aa6a3988be3d3ba0673ba1fbb52ba482d755adc06a9af053ad07a13dcc8

Contents?: true

Size: 501 Bytes

Versions: 6

Compression:

Stored size: 501 Bytes

Contents

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

6 entries across 6 versions & 1 rubygems

Version Path
pt-flow-2.6.1 lib/pt-flow/branch.rb
pt-flow-2.6.0 lib/pt-flow/branch.rb
pt-flow-2.5.0 lib/pt-flow/branch.rb
pt-flow-2.4.0 lib/pt-flow/branch.rb
pt-flow-2.3.3 lib/pt-flow/branch.rb
pt-flow-2.3.2 lib/pt-flow/branch.rb