linear_api 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/lib/linear_api/client.rb +27 -2
- data/lib/linear_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bfd85fc80770e0982a5791d46f49fb4406b356b9e9fa43be79a9af61d21e791b
|
|
4
|
+
data.tar.gz: 30b5161cf27bdb0a43d8f15a22f32693db5b75c018a07aa5860329b2898a01b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6cd9e24591ae9ce4a807f7fb5758d8b759aa9a8f0b3e0c47fcdc600c55aba984781119c6319c58573370a69837761fe1bac307f052e019147007968b90080a8
|
|
7
|
+
data.tar.gz: be806327bb48559330ace30e6981146cbb7fcc27ad060027644951da7caa846dd9ee284c413625e684c74522a0bbaed6c3bba60594094f1144230903bcf0ae27
|
data/README.md
CHANGED
|
@@ -7,9 +7,7 @@ A Ruby gem for interacting with the [Linear](https://linear.app) GraphQL API. Cr
|
|
|
7
7
|
Add this line to your application's Gemfile:
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
|
-
gem 'linear_api'
|
|
11
|
-
# Or from GitHub:
|
|
12
|
-
gem 'linear_api', git: 'https://github.com/dan1d/linear_api.git'
|
|
10
|
+
gem 'linear_api'
|
|
13
11
|
```
|
|
14
12
|
|
|
15
13
|
Then run:
|
|
@@ -18,6 +16,12 @@ Then run:
|
|
|
18
16
|
bundle install
|
|
19
17
|
```
|
|
20
18
|
|
|
19
|
+
Or install it directly:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
gem install linear_api
|
|
23
|
+
```
|
|
24
|
+
|
|
21
25
|
For Rails applications, run the migrations:
|
|
22
26
|
|
|
23
27
|
```bash
|
data/lib/linear_api/client.rb
CHANGED
|
@@ -95,10 +95,24 @@ module LinearApi
|
|
|
95
95
|
|
|
96
96
|
# Get issue by identifier (e.g., "TOS-123") using direct filter query
|
|
97
97
|
#
|
|
98
|
-
#
|
|
98
|
+
# Parses the identifier into team key and issue number, then filters
|
|
99
|
+
# using the `number` and `team.key` fields on IssueFilter (Linear's
|
|
100
|
+
# GraphQL schema does not expose an `identifier` filter).
|
|
101
|
+
#
|
|
102
|
+
# @param identifier [String] Issue identifier (e.g., "TOS-123")
|
|
99
103
|
# @return [Result] Result with issue
|
|
100
104
|
def get_issue(identifier)
|
|
101
|
-
|
|
105
|
+
team_key, number = parse_identifier(identifier)
|
|
106
|
+
unless team_key && number
|
|
107
|
+
return Result.new(success: false, error: "Invalid identifier format: #{identifier} (expected TEAM-123)")
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
filter = {
|
|
111
|
+
number: { eq: number },
|
|
112
|
+
team: { key: { eq: team_key } }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
result = query(Issue::GET_BY_IDENTIFIER_QUERY, variables: { filter: filter })
|
|
102
116
|
return result if result.failure?
|
|
103
117
|
|
|
104
118
|
issues = result.data.dig('issues', 'nodes') || []
|
|
@@ -519,6 +533,17 @@ module LinearApi
|
|
|
519
533
|
input
|
|
520
534
|
end
|
|
521
535
|
|
|
536
|
+
# Parse an identifier like "TOS-123" into ["TOS", 123]
|
|
537
|
+
#
|
|
538
|
+
# @param identifier [String] e.g. "TOS-123"
|
|
539
|
+
# @return [Array(String, Integer), Array(nil, nil)] team key and number, or nils
|
|
540
|
+
def parse_identifier(identifier)
|
|
541
|
+
match = identifier&.match(/\A([A-Za-z]+)-(\d+)\z/)
|
|
542
|
+
return [nil, nil] unless match
|
|
543
|
+
|
|
544
|
+
[match[1].upcase, match[2].to_i]
|
|
545
|
+
end
|
|
546
|
+
|
|
522
547
|
def camelize(key)
|
|
523
548
|
key.to_s.gsub(/_([a-z])/) { ::Regexp.last_match(1).upcase }.to_sym
|
|
524
549
|
end
|
data/lib/linear_api/version.rb
CHANGED