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.
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
1531 1532 1533 |
# File 'lib/hiiro/tasks.rb', line 1531 def name @name end |
#type ⇒ Object (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
#branch ⇒ Object
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_index ⇒ Object
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_name ⇒ Object
1549 |
# File 'lib/hiiro/tasks.rb', line 1549 def parent_name = nil |
#path ⇒ Object
1552 1553 1554 |
# File 'lib/hiiro/tasks.rb', line 1552 def path @_path end |
#session_name ⇒ Object
1543 |
# File 'lib/hiiro/tasks.rb', line 1543 def session_name = name |
#short_name ⇒ Object
1548 |
# File 'lib/hiiro/tasks.rb', line 1548 def short_name = name |
#subtask? ⇒ Boolean
1546 |
# File 'lib/hiiro/tasks.rb', line 1546 def subtask? = false |
#to_s ⇒ Object
1572 1573 1574 |
# File 'lib/hiiro/tasks.rb', line 1572 def to_s name end |
#top_level? ⇒ Boolean
1547 |
# File 'lib/hiiro/tasks.rb', line 1547 def top_level? = true |
#tree ⇒ Object
1550 |
# File 'lib/hiiro/tasks.rb', line 1550 def tree = nil |
#tree_name ⇒ Object
1544 |
# File 'lib/hiiro/tasks.rb', line 1544 def tree_name = nil |