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.



1537
1538
1539
1540
1541
# File 'lib/hiiro/tasks.rb', line 1537

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



1531
1532
1533
# File 'lib/hiiro/tasks.rb', line 1531

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



1531
1532
1533
# File 'lib/hiiro/tasks.rb', line 1531

def type
  @type
end

Class Method Details

.from_project(name, path) ⇒ Object



1533
1534
1535
# File 'lib/hiiro/tasks.rb', line 1533

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

Instance Method Details

#branchObject



1556
1557
1558
1559
1560
# File 'lib/hiiro/tasks.rb', line 1556

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



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

def color_index = nil

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



1562
1563
1564
1565
1566
1567
1568
1569
1570
# File 'lib/hiiro/tasks.rb', line 1562

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

#parent_nameObject



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

def parent_name = nil

#pathObject



1552
1553
1554
# File 'lib/hiiro/tasks.rb', line 1552

def path
  @_path
end

#session_nameObject



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

def session_name = name

#short_nameObject



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

def short_name = name

#subtask?Boolean

Returns:

  • (Boolean)


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

def subtask? = false

#to_sObject



1572
1573
1574
# File 'lib/hiiro/tasks.rb', line 1572

def to_s
  name
end

#top_level?Boolean

Returns:

  • (Boolean)


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

def top_level? = true

#treeObject



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

def tree = nil

#tree_nameObject



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

def tree_name = nil