rujira 0.3.2 → 0.3.4

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: fe3605d3169c9d351d102aac1f818d45248668dbfebfde6ed50efad8185d67ec
4
- data.tar.gz: 36d1b09cc7bb319c25a006135d149aa634ba1a86f60fbcef030fda6e518673d0
3
+ metadata.gz: 8b6d18c441bf30cd86f00a38ccb4a2be266fdbc3aa312f607292d6a7d25d0a26
4
+ data.tar.gz: 326fb2ea52c1cb8f41f0c7ecfb9e511b325315c6f0bc89df5bc4a8ce4f13edb6
5
5
  SHA512:
6
- metadata.gz: d14e41226a19f4aec0f4bc56ccf60642c37fd6e3c08bda3871655e7bae9e45e67bd8ef8870049493938680b8ad6aed073cc5cb83fadc7fa9829b2a3e491d05dd
7
- data.tar.gz: b7e70af74ed15946de2d724dbfa0d654a4f4698b7626f1db931f16c2711b3f6cd68a8671727aaaae27bdb34c8549687af67bd516e324e56cfb02420e3962e5cf
6
+ metadata.gz: 4a3c6713caa660260b313a2cd6f3727ba831a7ace828a2fa1f55ae9e827b31a18854abd9f66c06014f07845dd12cbe439bd70d4c4d78ea5f40a847bd0fffe5cb
7
+ data.tar.gz: '0498ad7989466f66ddb76bd02e793e5ac2905d843db1101f14a3502487bb2efd51effa7f9836c51cf51a8ae4bf5173557daa6ab07b893cd9ad78370bd4aa0c9d'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## [0.3.4] - 2025-09-13
2
+
3
+ ### 🐛 Bug Fixes
4
+
5
+ - Fix for tasks
6
+ ## [0.3.3] - 2025-09-13
7
+
8
+ ### 📚 Documentation
9
+
10
+ - Added comments from ai #4
11
+ - Added comments from ai #3
12
+ - Added comments from ai #2
13
+ - Added comments from ai
1
14
  ## [0.3.2] - 2025-09-13
2
15
 
3
16
  ### 🚜 Refactor
@@ -70,12 +83,6 @@
70
83
 
71
84
  - Remove debug line
72
85
 
73
- ### ITMG
74
-
75
- - Work with missing methods
76
- - Rewrite tasks for gem
77
- - Added project create entrypoint
78
-
79
86
  ### Reafactor
80
87
 
81
88
  - Full
@@ -2,10 +2,18 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO: add docs
6
- # Some description
5
+ # This class provides methods to manage Jira issue attachments via the REST API.
6
+ # Currently, it supports creating (uploading) attachments for a given issue ID or key.
7
+ # Example: Attach a file to an issue by calling `create("ISSUE-123", "/path/to/file")`.
7
8
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/issue/%7BissueIdOrKey%7D/attachments
8
9
  class Attachments < Common
10
+ # Uploads a file as an attachment to the specified Jira issue.
11
+ #
12
+ # @param [String] id_or_key The issue ID or key to which the file will be attached.
13
+ # @param [String] path The local file path of the attachment to upload.
14
+ # @yield [builder] Optional block to customize the request builder.
15
+ # @return [Object] The API response after executing the request.
16
+ #
9
17
  def create(id_or_key, path, &block)
10
18
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
11
19
  client = @client
@@ -2,10 +2,14 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO: add docs
6
- # Some description
7
- # https://docs.atlassian.com/jira-software/REST/9.17.0/#agile/1.0/board
5
+ # Provides access to Jira Agile board resources via the REST API.
6
+ # API reference: https://docs.atlassian.com/jira-software/REST/9.17.0/#agile/1.0/board
7
+ #
8
8
  class Board < Common
9
+ # Initializes a new Board API client.
10
+ #
11
+ # @param [Object] client The HTTP client instance used to perform requests.
12
+ #
9
13
  def initialize(client)
10
14
  super
11
15
  builder do
@@ -13,6 +17,11 @@ module Rujira
13
17
  end
14
18
  end
15
19
 
20
+ # Retrieves details for a specific board by its ID.
21
+ #
22
+ # @param [Integer, String] id The board ID.
23
+ # @return [Object] The API response containing board details.
24
+ #
16
25
  def get(id)
17
26
  abort 'Board ID is required' if id.to_s.strip.empty?
18
27
  builder do
@@ -21,6 +30,10 @@ module Rujira
21
30
  run
22
31
  end
23
32
 
33
+ # Lists all boards visible to the current user.
34
+ #
35
+ # @return [Object] The API response containing a list of boards.
36
+ #
24
37
  def list
25
38
  builder do
26
39
  path 'board'
@@ -28,6 +41,11 @@ module Rujira
28
41
  run
29
42
  end
30
43
 
44
+ # Retrieves all sprints for a specific board.
45
+ #
46
+ # @param [Integer, String] id The board ID.
47
+ # @return [Object] The API response containing sprints.
48
+ #
31
49
  def sprint(id)
32
50
  abort 'Board ID is required' if id.to_s.strip.empty?
33
51
  builder do
@@ -2,10 +2,22 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO: add docs
6
- # Some description
5
+ # Provides access to Jira issue comments via the REST API.
6
+ # API reference:
7
7
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/comment/%7BcommentId%7D/properties
8
+ #
8
9
  class Comment < Common
10
+ # Creates a new comment for the specified Jira issue.
11
+ #
12
+ # @param [String] id_or_key The issue ID or key where the comment will be added.
13
+ # @yield [builder] Optional block to customize the request payload (e.g., setting comment body).
14
+ # @return [Object] The API response containing the created comment.
15
+ #
16
+ # @example Create a comment with body text
17
+ # client.Comment.create("ISSUE-123") do
18
+ # payload body: "This is a test comment"
19
+ # end
20
+ #
9
21
  def create(id_or_key, &block)
10
22
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
11
23
  builder do
@@ -2,9 +2,14 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO: add docs
6
- # Some description
5
+ # Base class for Jira API resources.
6
+ # Provides common request setup, authorization, and request execution.
7
+ #
7
8
  class Common
9
+ # Initializes a new API resource.
10
+ #
11
+ # @param [Object] client The HTTP client instance used to build and dispatch requests.
12
+ #
8
13
  def initialize(client)
9
14
  # Store the passed client object in an instance variable for later use
10
15
  @client = client
@@ -31,8 +36,9 @@ module Rujira
31
36
  # @return [Object] The configured request builder stored in @request.
32
37
  def builder(&block) = @client.request.builder(&block)
33
38
 
34
- # Delegate execution to the client's dispatch method
35
- # This triggers the configured request to be sent
39
+ # Executes the configured request.
40
+ #
41
+ # @return [Object] The API response after dispatching the request.
36
42
  def run = @client.dispatch
37
43
  end
38
44
  end
@@ -2,10 +2,19 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO: add docs
6
- # Some description
5
+ # Provides access to Jira dashboards via the REST API.
6
+ # API reference:
7
7
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/myself
8
+ #
8
9
  class Dashboard < Common
10
+ # Retrieves a specific dashboard by its ID.
11
+ #
12
+ # @param [Integer, String] id The dashboard ID.
13
+ # @return [Object] The API response containing dashboard details.
14
+ #
15
+ # @example Get a dashboard by ID
16
+ # client.Dashboard.get(10001)
17
+ #
9
18
  def get(id)
10
19
  abort 'Dashboard ID is required' if id.to_s.strip.empty?
11
20
  builder do
@@ -14,6 +23,13 @@ module Rujira
14
23
  run
15
24
  end
16
25
 
26
+ # Lists all dashboards visible to the current user.
27
+ #
28
+ # @return [Object] The API response containing a list of dashboards.
29
+ #
30
+ # @example List dashboards
31
+ # client.Dashboard.list
32
+ #
17
33
  def list
18
34
  builder do
19
35
  path 'dashboard'
@@ -2,10 +2,26 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO: add docs
6
- # Some description
5
+ # Provides access to Jira issues via the REST API.
6
+ # API reference:
7
7
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/issue
8
+ #
8
9
  class Issue < Common
10
+ # Creates a new issue.
11
+ #
12
+ # @yield [builder] Optional block to configure the request payload.
13
+ # @return [Object] The API response containing the created issue.
14
+ #
15
+ # @example Create an issue
16
+ # client.Issue.create do
17
+ # payload fields: {
18
+ # summary: "New bug report",
19
+ # issuetype: { name: 'Task' },
20
+ # project: { key: "TEST" },
21
+ # description: 'This task was generated by the bot when creating changes in the repository.'
22
+ # }
23
+ # end
24
+ #
9
25
  def create(&block)
10
26
  builder do
11
27
  path 'issue'
@@ -15,6 +31,15 @@ module Rujira
15
31
  run
16
32
  end
17
33
 
34
+ # Retrieves an issue by its ID or key.
35
+ #
36
+ # @param [String] id_or_key The issue ID or key.
37
+ # @yield [builder] Optional block to configure the request.
38
+ # @return [Object] The API response containing the issue details.
39
+ #
40
+ # @example Get an issue
41
+ # client.Issue.get("TEST-123")
42
+ #
18
43
  def get(id_or_key, &block)
19
44
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
20
45
  builder do
@@ -24,6 +49,15 @@ module Rujira
24
49
  run
25
50
  end
26
51
 
52
+ # Deletes an issue by its ID or key.
53
+ #
54
+ # @param [String] id_or_key The issue ID or key.
55
+ # @yield [builder] Optional block to configure the request.
56
+ # @return [Object] The API response after deletion.
57
+ #
58
+ # @example Delete an issue
59
+ # client.Issue.delete("TEST-123")
60
+ #
27
61
  def delete(id_or_key, &block)
28
62
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
29
63
  builder do
@@ -36,6 +70,17 @@ module Rujira
36
70
 
37
71
  alias del delete
38
72
 
73
+ # Updates an existing issue.
74
+ #
75
+ # @param [String] id_or_key The issue ID or key.
76
+ # @yield [builder] Optional block to configure the update payload.
77
+ # @return [Object] The API response after updating the issue.
78
+ #
79
+ # @example Edit an issue
80
+ # client.Issue.edit("TEST-123") do
81
+ # payload fields: { summary: "Updated summary" }
82
+ # end
83
+ #
39
84
  def edit(id_or_key, &block)
40
85
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
41
86
  builder do
@@ -46,11 +91,32 @@ module Rujira
46
91
  run
47
92
  end
48
93
 
94
+ # Adds a comment to an issue.
95
+ #
96
+ # @param [String] id_or_key The issue ID or key.
97
+ # @yield [builder] Optional block to configure the comment payload.
98
+ # @return [Object] The API response containing the created comment.
99
+ #
100
+ # @example Add a comment
101
+ # client.Issue.comment("TEST-123") do
102
+ # payload body: "This is a comment"
103
+ # end
104
+ #
49
105
  def comment(id_or_key, &block)
50
106
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
51
107
  @client.Comment.create id_or_key, &block
52
108
  end
53
109
 
110
+ # Adds a watcher to an issue.
111
+ #
112
+ # @param [String] id_or_key The issue ID or key.
113
+ # @param [String] name The username to add as a watcher.
114
+ # @yield [builder] Optional block to configure the request.
115
+ # @return [Object] The API response after adding the watcher.
116
+ #
117
+ # @example Add a watcher
118
+ # client.Issue.watchers("TEST-123", "johndoe")
119
+ #
54
120
  def watchers(id_or_key, name, &block)
55
121
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
56
122
  builder do
@@ -62,6 +128,16 @@ module Rujira
62
128
  run
63
129
  end
64
130
 
131
+ # Uploads an attachment to an issue.
132
+ #
133
+ # @param [String] id_or_key The issue ID or key.
134
+ # @param [String] path The local file path of the attachment.
135
+ # @yield [builder] Optional block to configure the request.
136
+ # @return [Object] The API response containing the uploaded attachment.
137
+ #
138
+ # @example Upload an attachment
139
+ # client.Issue.attachments("TEST-123", "/tmp/file.txt")
140
+ #
65
141
  def attachments(id_or_key, path, &block)
66
142
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
67
143
  @client.Attachments.create id_or_key, path, &block
@@ -2,10 +2,20 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO: add docs
6
- # Some description
5
+ # Provides access to the Jira "Myself" resource via the REST API.
6
+ # Allows retrieving details about the currently authenticated user.
7
+ #
8
+ # API reference:
7
9
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/myself
10
+ #
8
11
  class Myself < Common
12
+ # Retrieves details of the currently authenticated user.
13
+ #
14
+ # @return [Object] The API response containing user details.
15
+ #
16
+ # @example Get current user details
17
+ # client.Myself.get
18
+ #
9
19
  def get
10
20
  builder do
11
21
  path 'myself'
@@ -2,10 +2,27 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO: add docs
6
- # Some description
5
+ # Provides access to Jira projects via the REST API.
6
+ #
7
+ # API reference:
7
8
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/project
9
+ #
8
10
  class Project < Common
11
+ # Creates a new project.
12
+ #
13
+ # @yield [builder] Optional block to configure the request payload.
14
+ # @return [Object] The API response containing the created project.
15
+ #
16
+ # @example Create a project
17
+ # client.Project.create do
18
+ # payload {
19
+ # key: "TEST",
20
+ # name: "Test Project",
21
+ # projectTypeKey: "software",
22
+ # projectTemplateKey: "com.atlassian.jira-core-project-templates:jira-core-project-management"
23
+ # }
24
+ # end
25
+ #
9
26
  def create(&block)
10
27
  builder do
11
28
  path 'project'
@@ -15,6 +32,17 @@ module Rujira
15
32
  run
16
33
  end
17
34
 
35
+ # Updates an existing project.
36
+ #
37
+ # @param [String] id_or_key The project ID or key.
38
+ # @yield [builder] Optional block to configure the update payload.
39
+ # @return [Object] The API response after updating the project.
40
+ #
41
+ # @example Update a project
42
+ # client.Project.edit("TEST") do
43
+ # payload { name: "Renamed Project" }
44
+ # end
45
+ #
18
46
  def edit(id_or_key, &block)
19
47
  abort 'Project ID or KEY is required' if id_or_key.to_s.strip.empty?
20
48
  builder do
@@ -25,6 +53,15 @@ module Rujira
25
53
  run
26
54
  end
27
55
 
56
+ # Retrieves a specific project by ID or key.
57
+ #
58
+ # @param [String] id_or_key The project ID or key.
59
+ # @yield [builder] Optional block to configure the request.
60
+ # @return [Object] The API response containing project details.
61
+ #
62
+ # @example Get a project
63
+ # client.Project.get("TEST")
64
+ #
28
65
  def get(id_or_key, &block)
29
66
  abort 'Project ID or KEY is required' if id_or_key.to_s.strip.empty?
30
67
  builder do
@@ -34,6 +71,14 @@ module Rujira
34
71
  run
35
72
  end
36
73
 
74
+ # Lists all projects visible to the current user.
75
+ #
76
+ # @yield [builder] Optional block to configure the request.
77
+ # @return [Object] The API response containing the list of projects.
78
+ #
79
+ # @example List projects
80
+ # client.Project.list
81
+ #
37
82
  def list(&block)
38
83
  builder do
39
84
  path 'project'
@@ -42,6 +87,14 @@ module Rujira
42
87
  run
43
88
  end
44
89
 
90
+ # Deletes a project by ID or key.
91
+ #
92
+ # @param [String] id_or_key The project ID or key.
93
+ # @return [Object] The API response after deletion.
94
+ #
95
+ # @example Delete a project
96
+ # client.Project.delete("TEST")
97
+ #
45
98
  def delete(id_or_key)
46
99
  abort 'Project ID or KEY is required' if id_or_key.to_s.strip.empty?
47
100
  builder do
@@ -51,6 +104,15 @@ module Rujira
51
104
  run
52
105
  end
53
106
 
107
+ # Retrieves the security levels for a specific project.
108
+ #
109
+ # @param [String] id_or_key The project ID or key.
110
+ # @yield [builder] Optional block to configure the request.
111
+ # @return [Object] The API response containing security levels.
112
+ #
113
+ # @example Get project security levels
114
+ # client.Project.securitylevel("TEST")
115
+ #
54
116
  def securitylevel(id_or_key, &block)
55
117
  abort 'Project ID or KEY is required' if id_or_key.to_s.strip.empty?
56
118
  builder do
@@ -2,10 +2,24 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO: add docs
6
- # Some description
5
+ # Provides access to Jira issue search via the REST API.
6
+ # Allows searching for issues using JQL (Jira Query Language).
7
+ #
8
+ # API reference:
7
9
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/search
10
+ #
8
11
  class Search < Common
12
+ # Executes a search query against Jira issues.
13
+ #
14
+ # @yield [builder] Optional block to configure the request payload
15
+ # (e.g., provide JQL, fields, pagination).
16
+ # @return [Object] The API response containing matching issues.
17
+ #
18
+ # @example Search issues with JQL
19
+ # client.Search.get do
20
+ # payload jql: "project = TEST AND status = 'To Do'", maxResults: 10
21
+ # end
22
+ #
9
23
  def get(&block)
10
24
  builder do
11
25
  path 'search'
@@ -2,10 +2,20 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO: add docs
6
- # Some description
5
+ # Provides access to Jira server information via the REST API.
6
+ # Retrieves details about the Jira server instance, including version and build info.
7
+ #
8
+ # API reference:
7
9
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/serverInfo
10
+ #
8
11
  class ServerInfo < Common
12
+ # Retrieves Jira server information.
13
+ #
14
+ # @return [Object] The API response containing server details.
15
+ #
16
+ # @example Get server info
17
+ # client.Server_info.get
18
+ #
9
19
  def get
10
20
  builder do
11
21
  path 'serverInfo'
@@ -2,10 +2,17 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO: add docs
6
- # Some description
5
+ # Provides access to Jira sprints via the Agile REST API.
6
+ # Allows creating, updating, retrieving, and managing sprints and their issues.
7
+ #
8
+ # API reference:
7
9
  # https://docs.atlassian.com/jira-software/REST/9.17.0/#agile/1.0/sprint
10
+ #
8
11
  class Sprint < Common
12
+ # Initializes a new Sprint API client.
13
+ #
14
+ # @param [Object] client The HTTP client instance used to perform requests.
15
+ #
9
16
  def initialize(client)
10
17
  super
11
18
  builder do
@@ -13,6 +20,16 @@ module Rujira
13
20
  end
14
21
  end
15
22
 
23
+ # Creates a new sprint.
24
+ #
25
+ # @yield [builder] Optional block to configure the sprint payload.
26
+ # @return [Object] The API response containing the created sprint.
27
+ #
28
+ # @example Create a sprint
29
+ # client.Sprint.create do
30
+ # payload name: "Sprint 1", startDate: "2025-09-01", endDate: "2025-09-14", originBoardId: 1
31
+ # end
32
+ #
16
33
  def create(&block)
17
34
  builder do
18
35
  path 'sprint'
@@ -23,6 +40,17 @@ module Rujira
23
40
  run
24
41
  end
25
42
 
43
+ # Updates an existing sprint partially.
44
+ #
45
+ # @param [Integer] id The sprint ID.
46
+ # @yield [builder] Block to configure update payload (required).
47
+ # @return [Object] The API response after updating the sprint.
48
+ #
49
+ # @example Update sprint
50
+ # client.Sprint.update(1) do
51
+ # payload name: "Updated Sprint Name"
52
+ # end
53
+ #
26
54
  def update(id, &block)
27
55
  abort 'Sprint ID is required' if id.to_s.strip.empty?
28
56
  raise ArgumentError, 'block is required' unless block
@@ -31,11 +59,22 @@ module Rujira
31
59
  path "sprint/#{id}"
32
60
  headers 'Content-Type': 'application/json', Accept: 'application/json'
33
61
  method :post
34
- instance_eval(&block) if block_given?
62
+ instance_eval(&block)
35
63
  end
36
64
  run
37
65
  end
38
66
 
67
+ # Replaces an existing sprint.
68
+ #
69
+ # @param [Integer] id The sprint ID.
70
+ # @yield [builder] Block to configure replace payload (required).
71
+ # @return [Object] The API response after replacing the sprint.
72
+ #
73
+ # @example Replace sprint
74
+ # client.Sprint.replace(1) do
75
+ # payload name: "New Sprint Name", startDate: "2025-09-01", endDate: "2025-09-14"
76
+ # end
77
+ #
39
78
  def replace(id, &block)
40
79
  abort 'Sprint ID is required' if id.to_s.strip.empty?
41
80
  raise ArgumentError, 'block is required' unless block
@@ -44,11 +83,16 @@ module Rujira
44
83
  path "sprint/#{id}"
45
84
  headers 'Content-Type': 'application/json', Accept: 'application/json'
46
85
  method :put
47
- instance_eval(&block) if block_given?
86
+ instance_eval(&block)
48
87
  end
49
88
  run
50
89
  end
51
90
 
91
+ # Retrieves details of a specific sprint.
92
+ #
93
+ # @param [Integer] id The sprint ID.
94
+ # @return [Object] The API response containing sprint details.
95
+ #
52
96
  def get(id)
53
97
  abort 'Sprint ID is required' if id.to_s.strip.empty?
54
98
  builder do
@@ -57,6 +101,11 @@ module Rujira
57
101
  run
58
102
  end
59
103
 
104
+ # Retrieves all issues in a sprint.
105
+ #
106
+ # @param [Integer] id The sprint ID.
107
+ # @return [Object] The API response containing issues.
108
+ #
60
109
  def get_issue(id)
61
110
  abort 'Sprint ID is required' if id.to_s.strip.empty?
62
111
  builder do
@@ -65,6 +114,11 @@ module Rujira
65
114
  run
66
115
  end
67
116
 
117
+ # Deletes a sprint.
118
+ #
119
+ # @param [Integer] id The sprint ID.
120
+ # @return [Object] The API response after deletion.
121
+ #
68
122
  def delete(id)
69
123
  abort 'Sprint ID is required' if id.to_s.strip.empty?
70
124
  builder do
@@ -74,6 +128,11 @@ module Rujira
74
128
  run
75
129
  end
76
130
 
131
+ # Retrieves all properties of a sprint.
132
+ #
133
+ # @param [Integer] id The sprint ID.
134
+ # @return [Object] The API response containing sprint properties.
135
+ #
77
136
  def properties(id)
78
137
  abort 'Sprint ID is required' if id.to_s.strip.empty?
79
138
  builder do
@@ -82,6 +141,15 @@ module Rujira
82
141
  run
83
142
  end
84
143
 
144
+ # Adds issues to a sprint.
145
+ #
146
+ # @param [Integer] id The sprint ID.
147
+ # @param [Array<Integer>] issues List of issue IDs to add to the sprint.
148
+ # @return [Object] The API response after adding issues.
149
+ #
150
+ # @example Add issues to a sprint
151
+ # client.Sprint.issue(1, [101, 102])
152
+ #
85
153
  def issue(id, issues)
86
154
  abort 'Sprint ID is required' if id.to_s.strip.empty?
87
155
  builder do
data/lib/rujira/client.rb CHANGED
@@ -1,17 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rujira
4
- # TODO: add docs
5
- # Some description
4
+ # Main Jira API client.
5
+ # Provides access to Jira resources via method_missing delegation to API classes.
6
+ #
7
+ # Example:
8
+ # client = Rujira::Client.new("https://jira.example.com")
9
+ # client.issue.get("TEST-123")
10
+ #
6
11
  class Client
12
+ # @return [Rujira::Request] The current request object being configured
7
13
  attr_accessor :request
8
14
 
15
+ # Initializes a new Jira client.
16
+ #
17
+ # @param [String] url Base URL of the Jira instance.
18
+ # @param [Boolean] debug Whether to enable debug logging. Can also be set via ENV['RUJIRA_DEBUG'].
19
+ #
20
+ # @example Initialize client
21
+ # client = Rujira::Client.new("https://jira.example.com", debug: true)
22
+ #
9
23
  def initialize(url, debug: false)
10
24
  @uri = URI(url)
11
25
  @debug = ENV.fetch('RUJIRA_DEBUG', debug.to_s) == 'true'
12
26
  @request = Request.new
13
27
  end
14
28
 
29
+ # Dynamically instantiates the appropriate API resource class.
30
+ #
31
+ # @param [Symbol] method_name Name of the API resource (e.g., :issue, :project)
32
+ # @param [...] args Arguments passed to the resource class constructor
33
+ # @return [Object] An instance of the corresponding API resource class
34
+ #
35
+ # @example Access an API resource
36
+ # client.issue.get("TEST-123")
37
+ #
15
38
  def method_missing(method_name, ...)
16
39
  resource_class = Rujira::Api.const_get(method_name.to_s)
17
40
  resource_class.new(self, ...)
@@ -19,19 +42,33 @@ module Rujira
19
42
  super
20
43
  end
21
44
 
45
+ # Options for Faraday connection.
46
+ #
47
+ # @return [Hash] Options including URL, headers, and params
48
+ #
22
49
  def options
23
50
  {
24
51
  url: @uri,
25
52
  headers: @request.headers,
26
53
  params: @request.params
27
-
28
54
  }
29
55
  end
30
56
 
57
+ # Checks if a resource class exists for method_missing.
58
+ #
59
+ # @param [Symbol] method_name Method name to check
60
+ # @param [Boolean] include_private Include private methods
61
+ # @return [Boolean] true if the resource exists, false otherwise
62
+ #
31
63
  def respond_to_missing?(method_name, include_private = false)
32
64
  Rujira::Api.const_defined?(method_name.to_s) || super
33
65
  end
34
66
 
67
+ # Executes the configured request.
68
+ #
69
+ # @return [Object] The API response body if successful
70
+ # @raise [RuntimeError] If the request fails or method is unsupported
71
+ #
35
72
  def dispatch # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
36
73
  unless %i[get delete head post put patch].include?(@request.method)
37
74
  raise "method #{@request.method} not supported"
@@ -49,6 +86,10 @@ module Rujira
49
86
  end
50
87
  end
51
88
 
89
+ # Builds the Faraday connection for HTTP requests.
90
+ #
91
+ # @return [Faraday::Connection] Configured Faraday connection
92
+ #
52
93
  def connection
53
94
  Faraday.new(options) do |builder|
54
95
  builder.request :authorization, *@request.authorization if @request.authorization
@@ -60,10 +101,20 @@ module Rujira
60
101
  end
61
102
  end
62
103
 
104
+ # Prepares a file for multipart upload.
105
+ #
106
+ # @param [String] path Path to the file
107
+ # @return [Faraday::Multipart::FilePart] File ready for upload
108
+ #
63
109
  def file(path)
64
110
  Faraday::Multipart::FilePart.new(path, 'multipart/form-data')
65
111
  end
66
112
 
113
+ # Generates mock JSON files for API responses (useful for caching or testing).
114
+ #
115
+ # @param [Object] res API response object
116
+ # @return [void]
117
+ #
67
118
  def generate_mocks(res)
68
119
  path = res.to_hash[:url].path
69
120
  cache_path = File.join('.cache', path)
@@ -3,11 +3,17 @@
3
3
  require 'fileutils'
4
4
 
5
5
  module Rujira
6
- # TODO: add docs
7
- # Some description
6
+ # Represents an HTTP request configuration for Jira API calls.
7
+ # Used internally by Rujira::Client to build requests with headers, params, payloads, and authorization.
8
+ #
8
9
  class Request
9
- attr_reader :authorization, :options
10
+ # @return [Array, nil] Authorization information, e.g., Bearer token or basic auth credentials
11
+ attr_reader :authorization
12
+ # @return [Hash] Additional options for the request (currently unused)
13
+ attr_reader :options
10
14
 
15
+ # Initializes a new request object with default values.
16
+ #
11
17
  def initialize
12
18
  @token = ENV['RUJIRA_TOKEN'] if ENV.include?('RUJIRA_TOKEN')
13
19
  @method = :get
@@ -19,53 +25,104 @@ module Rujira
19
25
  @path = nil
20
26
  end
21
27
 
28
+ # Evaluates a block in the context of the request for configuration.
29
+ #
30
+ # @yield [self] Block used to set path, headers, params, method, etc.
31
+ # @return [Request] Returns self for chaining.
32
+ #
33
+ # @example Configure a request
34
+ # request.builder do
35
+ # path 'issue/TEST-123'
36
+ # method :get
37
+ # headers 'X-Custom-Header': 'value'
38
+ # end
39
+ #
22
40
  def builder(&block)
23
41
  return self unless block_given?
24
42
 
25
43
  instance_eval(&block)
26
44
  self
27
45
  end
28
-
29
46
  alias build builder
30
47
 
48
+ # Sets the base REST path for the request.
49
+ #
50
+ # @param [String] path The base path (e.g., 'rest/api/2' or 'rest/agile/1.0')
51
+ # @return [void]
52
+ #
31
53
  def rest_base(path)
32
54
  @rest_base_path = path
33
55
  end
34
56
 
57
+ # Gets or sets query parameters for the request.
58
+ #
59
+ # @param [Hash, nil] params Optional parameters to set.
60
+ # @return [Hash] The current parameters.
61
+ #
35
62
  def params(params = nil)
36
63
  return @params if params.nil?
37
64
 
38
65
  @params = params
39
66
  end
40
67
 
68
+ # Gets or sets HTTP headers for the request.
69
+ #
70
+ # @param [Hash, nil] headers Optional headers to set.
71
+ # @return [Hash] The current headers.
72
+ #
41
73
  def headers(headers = nil)
42
74
  return @headers if headers.nil?
43
75
 
44
76
  @headers = headers
45
77
  end
46
78
 
79
+ # Gets or sets the HTTP method for the request.
80
+ #
81
+ # @param [Symbol, nil] method Optional HTTP method (:get, :post, etc.)
82
+ # @return [Symbol] The current method.
83
+ #
47
84
  def method(method = nil)
48
85
  return @method if method.nil?
49
86
 
50
87
  @method = method
51
88
  end
52
89
 
90
+ # Sets Bearer token authorization.
91
+ #
92
+ # @param [String] token The token to use for authorization.
93
+ # @return [void]
94
+ #
53
95
  def bearer(token)
54
96
  @authorization = 'Bearer', -> { token }
55
97
  end
56
98
 
99
+ # Sets basic authentication.
100
+ #
101
+ # @param [String] username The username.
102
+ # @param [String] password The password.
103
+ # @return [void]
104
+ #
57
105
  def basic(username, password)
58
106
  @authorization = :basic, username, password
59
107
  end
60
108
 
109
+ # Gets or sets the request path (appended to rest_base_path).
110
+ #
111
+ # @param [String, nil] path The relative path to set.
112
+ # @return [String] The full path combining rest_base_path and the given path.
113
+ #
61
114
  def path(path = nil)
62
115
  return @path if path.nil?
63
116
 
64
117
  @path = "#{@rest_base_path}/#{path}"
65
-
66
118
  @path
67
119
  end
68
120
 
121
+ # Gets or sets the request payload (body for POST/PUT/PATCH requests).
122
+ #
123
+ # @param [Object, nil] payload The payload to set.
124
+ # @return [Object] The current payload.
125
+ #
69
126
  def payload(payload = nil)
70
127
  return @payload if payload.nil?
71
128
 
@@ -15,7 +15,8 @@ module Rujira
15
15
  end
16
16
 
17
17
  def client
18
- @client ||= Rujira::Client.new('http://localhost:8080', debug: false)
18
+ url = ENV.fetch('RUJIRA_URL', 'http://localhost:8080')
19
+ @client ||= Rujira::Client.new(url, debug: false)
19
20
  end
20
21
 
21
22
  def fetch_options(params, name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rujira
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.4'
5
5
  end
data/lib/rujira.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Load Rake tasks if Rake is defined
3
4
  Dir[File.join(__dir__, 'rujira', 'tasks', '*.rake')].each { |r| load r } if defined?(Rake)
4
5
 
5
6
  require 'faraday'
6
7
  require 'faraday/multipart'
7
8
  require 'json'
9
+
8
10
  require_relative 'rujira/error'
9
11
  require_relative 'rujira/version'
10
12
  require_relative 'rujira/request'
@@ -21,11 +23,27 @@ require_relative 'rujira/api/dashboard'
21
23
  require_relative 'rujira/api/board'
22
24
  require_relative 'rujira/api/sprint'
23
25
 
24
- # TODO: add docs
25
- # Some description
26
+ # Main Rujira module.
27
+ # Serves as the namespace for the Jira SDK.
28
+ #
29
+ # Provides utility methods and custom error handling.
30
+ #
26
31
  module Rujira
32
+ # Custom error class for Rujira SDK
33
+ #
34
+ # @example
35
+ # raise Rujira::Error, "Something went wrong"
36
+ #
27
37
  class Error < StandardError; end
28
38
 
39
+ # Checks if an environment variable is truthy.
40
+ #
41
+ # @param [String] var The name of the environment variable
42
+ # @return [Boolean] true if the value is 'true', '1', or 'yes' (case-insensitive), false otherwise
43
+ #
44
+ # @example Check if debug mode is enabled
45
+ # Rujira.env_var?('RUJIRA_DEBUG')
46
+ #
29
47
  def self.env_var?(var)
30
48
  %w[true 1 yes].include?(ENV[var]&.downcase)
31
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rujira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Semenov