-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathproject.rb
More file actions
54 lines (44 loc) · 1.3 KB
/
project.rb
File metadata and controls
54 lines (44 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# frozen_string_literal: true
require 'gqli'
module Rubyists
# Namespace for Linear
module Linear
M :base_model
Project = Class.new(BaseModel)
# The Project class represents a Linear workflow state.
class Project
include SemanticLogger::Loggable
Base = fragment('BaseProject', 'Project') do
id
name
content
slugId
description
url
createdAt
updatedAt
end
def slug
File.basename(url).sub("-#{slugId}", '')
end
def match_score?(string) # rubocop:disable Naming/PredicateMethod
return 100 if matches_attributes?(string, :id, :url)
downed = string.downcase
return 100 if downed.split.join('-') == slug || downed == name.downcase
return 75 if name.include?(string) || slug.include?(downed)
return 50 if description.downcase.include?(downed)
0
end
# Does :string _exactly_ match any of the attribute values in *attrs?
def matches_attributes?(string, *attrs)
Array(attrs).any? { |attr| string.casecmp?(data.fetch(attr.to_sym)) }
end
def to_s
format('%<name>-12s %<url>s', name:, url:)
end
def inspection
format('name: "%<name>s" type: "%<url>s"', name:, url:)
end
end
end
end