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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b6fd5b3c475c49a2fa516dd0c0efeb160021fff64c92baeded00a2915e14cc1
4
- data.tar.gz: 90feb73a98cd846639b42189bb67bf4ebf65e41976fef99b2405e21ecb4e5762
3
+ metadata.gz: bfd85fc80770e0982a5791d46f49fb4406b356b9e9fa43be79a9af61d21e791b
4
+ data.tar.gz: 30b5161cf27bdb0a43d8f15a22f32693db5b75c018a07aa5860329b2898a01b7
5
5
  SHA512:
6
- metadata.gz: a5e959366dfb2e2fe68fb9f2cdaf64bb60e855597b5019d6363ba3ee83671fc2e082f2d022e7f295acf269d3beef321395369029b54075940254d5c1f75b8575
7
- data.tar.gz: d26de938c9b5b89d33bb4361c66a5f2048f08301fc805fe13fe5061c8f451c5d3e98e227c8501cd4551bbb5c0b3b3b5959894654dcec76a41f10ac4c46e03a8c
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', path: '../linear'
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
@@ -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
- # @param identifier [String] Issue identifier
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
- result = query(Issue::GET_BY_IDENTIFIER_QUERY, variables: { filter: { identifier: { eq: identifier } } })
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LinearApi
4
- VERSION = '0.5.0'
4
+ VERSION = '0.5.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linear_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TheOwnerStack