Class: Rubyists::Linear::Label
- Inherits:
-
Object
- Object
- Rubyists::Linear::Label
- Includes:
- SemanticLogger::Loggable
- Defined in:
- lib/linear/models/label.rb
Overview
The Label class represents a Linear issue label.
Constant Summary collapse
- PLURAL =
:issueLabels
- Base =
fragment('BaseLabel', 'IssueLabel') do id description name isGroup createdAt updatedAt end
Class Method Summary collapse
-
.base_fragment ⇒ Object
rubocop:disable Metrics/AbcSize.
- .find_all_by_name(names) ⇒ Object
- .find_by_name(name) ⇒ Object
Instance Method Summary collapse
Class Method Details
.base_fragment ⇒ Object
rubocop:disable Metrics/AbcSize
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/linear/models/label.rb', line 25 def self.base_fragment # rubocop:disable Metrics/AbcSize define_method(:team) { updated_data[:team] } define_method(:team=) { |val| updated_data[:team] = val } define_method(:parent) { updated_data[:parent] } define_method(:parent=) { |val| updated_data[:parent] = val } fragment('LabelWithTeams', 'IssueLabel') do ___ Base parent { ___ Base } team { ___ Team.base_fragment } end end |
.find_all_by_name(names) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/linear/models/label.rb', line 38 def self.find_all_by_name(names) q = query do issueLabels(filter: { name: { in: names } }) do edges { node { ___ base_fragment } } end end data = Api.query(q) edges = data.dig(:issueLabels, :edges) raise NotFoundError, "No labels found: #{names}" unless edges edges.map { |edge| new edge[:node] } end |
.find_by_name(name) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/linear/models/label.rb', line 51 def self.find_by_name(name) them = find_all_by_name([name]) if them.size > 1 logger.warn('Found multiple matches for label name, using the first one returned', labels: them) end them.first end |
Instance Method Details
#display(_options) ⇒ Object
67 68 69 |
# File 'lib/linear/models/label.rb', line 67 def display() printf "%s\n", full end |
#full ⇒ Object
63 64 65 |
# File 'lib/linear/models/label.rb', line 63 def full format('%<to_s>-10s %<description>s', description:, to_s:) end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/linear/models/label.rb', line 59 def to_s format('%<name>s', name:) end |