Class: Hiiro::FallbackTarget
- Inherits:
-
Object
- Object
- Hiiro::FallbackTarget
- Defined in:
- lib/hiiro/tasks.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #branch ⇒ Object
- #color_index ⇒ Object
- #display_data(scope: :task, environment:) ⇒ Object
-
#initialize(name:, path:, type:) ⇒ FallbackTarget
constructor
A new instance of FallbackTarget.
- #parent_name ⇒ Object
- #path ⇒ Object
- #session_name ⇒ Object
- #short_name ⇒ Object
- #subtask? ⇒ Boolean
- #to_s ⇒ Object
- #top_level? ⇒ Boolean
- #tree ⇒ Object
- #tree_name ⇒ Object
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
1600 1601 1602 |
# File 'lib/hiiro/tasks.rb', line 1600 def name @name end |
#type ⇒ Object (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
#branch ⇒ Object
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_index ⇒ Object
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_name ⇒ Object
1618 |
# File 'lib/hiiro/tasks.rb', line 1618 def parent_name = nil |
#path ⇒ Object
1621 1622 1623 |
# File 'lib/hiiro/tasks.rb', line 1621 def path @_path end |
#session_name ⇒ Object
1612 |
# File 'lib/hiiro/tasks.rb', line 1612 def session_name = name |
#short_name ⇒ Object
1617 |
# File 'lib/hiiro/tasks.rb', line 1617 def short_name = name |
#subtask? ⇒ Boolean
1615 |
# File 'lib/hiiro/tasks.rb', line 1615 def subtask? = false |
#to_s ⇒ Object
1641 1642 1643 |
# File 'lib/hiiro/tasks.rb', line 1641 def to_s name end |
#top_level? ⇒ Boolean
1616 |
# File 'lib/hiiro/tasks.rb', line 1616 def top_level? = true |
#tree ⇒ Object
1619 |
# File 'lib/hiiro/tasks.rb', line 1619 def tree = nil |
#tree_name ⇒ Object
1613 |
# File 'lib/hiiro/tasks.rb', line 1613 def tree_name = nil |