Class: Hiiro::FallbackTarget

Inherits:
Object
  • Object
show all
Defined in:
lib/hiiro/tasks.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, path:, type:) ⇒ FallbackTarget

Returns a new instance of FallbackTarget.



1606
1607
1608
1609
1610
# File 'lib/hiiro/tasks.rb', line 1606

def initialize(name:, path:, type:)
  @name = name
  @_path = path
  @type = type
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



1600
1601
1602
# File 'lib/hiiro/tasks.rb', line 1600

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



1600
1601
1602
# File 'lib/hiiro/tasks.rb', line 1600

def type
  @type
end

Class Method Details

.from_project(name, path) ⇒ Object



1602
1603
1604
# File 'lib/hiiro/tasks.rb', line 1602

def self.from_project(name, path)
  new(name: name, path: path, type: :project)
end

Instance Method Details

#branchObject



1625
1626
1627
1628
1629
# File 'lib/hiiro/tasks.rb', line 1625

def branch
  return nil unless @_path
  out = IO.popen(['git', '-C', @_path, 'rev-parse', '--abbrev-ref', 'HEAD'], err: File::NULL, &:read)
  out&.strip&.then { |b| b.empty? ? nil : b }
end

#color_indexObject



1614
# File 'lib/hiiro/tasks.rb', line 1614

def color_index = nil

#display_data(scope: :task, environment:) ⇒ Object



1631
1632
1633
1634
1635
1636
1637
1638
1639
# File 'lib/hiiro/tasks.rb', line 1631

def display_data(scope: :task, environment:)
  br = branch
  {
    name: name,
    tree: '(project)',
    branch: br ? "[#{br}]" : '(none)',
    session: "(#{name})"
  }
end

#parent_nameObject



1618
# File 'lib/hiiro/tasks.rb', line 1618

def parent_name = nil

#pathObject



1621
1622
1623
# File 'lib/hiiro/tasks.rb', line 1621

def path
  @_path
end

#session_nameObject



1612
# File 'lib/hiiro/tasks.rb', line 1612

def session_name = name

#short_nameObject



1617
# File 'lib/hiiro/tasks.rb', line 1617

def short_name = name

#subtask?Boolean

Returns:

  • (Boolean)


1615
# File 'lib/hiiro/tasks.rb', line 1615

def subtask? = false

#to_sObject



1641
1642
1643
# File 'lib/hiiro/tasks.rb', line 1641

def to_s
  name
end

#top_level?Boolean

Returns:

  • (Boolean)


1616
# File 'lib/hiiro/tasks.rb', line 1616

def top_level? = true

#treeObject



1619
# File 'lib/hiiro/tasks.rb', line 1619

def tree = nil

#tree_nameObject



1613
# File 'lib/hiiro/tasks.rb', line 1613

def tree_name = nil