Sha256: 3dce17bfe7fc6b739c4f02260990b9def289fc064fb8e60bdfee573940e77655

Contents?: true

Size: 525 Bytes

Versions: 2

Compression:

Stored size: 525 Bytes

Contents

module PT::Flow
  class Branch
    require 'i18n'
    require 'active_support/core_ext/string/inflections'

    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..60]}.#{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

2 entries across 2 versions & 1 rubygems

Version Path
pt-flow-0.6.1 lib/pt-flow/branch.rb
pt-flow-0.6.0 lib/pt-flow/branch.rb