rujira 0.3.1 → 0.3.3

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: '099900e906a1d71b9c787fa6565fa02bdce269dba4ab74394f6c222b10f3a737'
4
- data.tar.gz: f00ae30d02ca63aecca57b1ea8099fa0afe2482de3baa385f92e7d29968ae83d
3
+ metadata.gz: e005db353dbe4f5df93ed7d8265c640c70d43b8cca83f8267172ce5b65d16f15
4
+ data.tar.gz: 6bce03f3b9b9569e10b6c64570e7cfd525f533d06b481a1d99575f175fa783a3
5
5
  SHA512:
6
- metadata.gz: 581f6a09da83eadd7ef5d474face9d61e34b91999c3009094c7be6a83872eb18a0c2a50fc1462b910b36b289b8e1277906744f738aae6c7f179a6cc0a3193e01
7
- data.tar.gz: 82d46f9a3a7d56a605d69cb5263c5b3be64fda4973920766de48cbe5b12a7e8b22d96b740497faa3edccbc4848a3d910ee1f66b897bcfd95927993b68ec45d5c
6
+ metadata.gz: 3060212250b292a3ce1382952cefc819ec9b4b6ebef7938a482cabe5c6a60bce9f13139bc2c2b83e66085b1f7650943b2c41f8b5b46442d0562fa2b23a0ca93c
7
+ data.tar.gz: 7c5b97a39dd04a3b21470033eec8cc7b76c867f2daeaff256936d11d31164835b9d12fc35d6e48578628a6ecb50fddcda448cbb60e717932136ee2718949d3e3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## [0.3.3] - 2025-09-13
2
+
3
+ ### 📚 Documentation
4
+
5
+ - Added comments from ai #4
6
+ - Added comments from ai #3
7
+ - Added comments from ai #2
8
+ - Added comments from ai
9
+ ## [0.3.2] - 2025-09-13
10
+
11
+ ### 🚜 Refactor
12
+
13
+ - Remove configuration
14
+
15
+ ### 📚 Documentation
16
+
17
+ - Updated inline description
1
18
  ## [0.3.1] - 2025-09-13
2
19
 
3
20
  ### 🚜 Refactor
@@ -61,23 +78,6 @@
61
78
 
62
79
  - Remove debug line
63
80
 
64
- ### ITMG
65
-
66
- - Work with missing methods
67
- - Rewrite tasks for gem
68
- - Added project create entrypoint
69
-
70
81
  ### Reafactor
71
82
 
72
83
  - Full
73
- ## [0.1.10] - 2024-07-05
74
-
75
- ### ITMG
76
-
77
- - Adding watchers and security level getter
78
- ## [0.1.9] - 2024-06-23
79
-
80
- ### ITMG
81
-
82
- - Description fixes
83
- - Release 0.1.8
@@ -2,9 +2,18 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO
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")`.
6
8
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/issue/%7BissueIdOrKey%7D/attachments
7
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
+ #
8
17
  def create(id_or_key, path, &block)
9
18
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
10
19
  client = @client
@@ -2,9 +2,14 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO
6
- # 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
+ #
7
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
+ #
8
13
  def initialize(client)
9
14
  super
10
15
  builder do
@@ -12,6 +17,11 @@ module Rujira
12
17
  end
13
18
  end
14
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
+ #
15
25
  def get(id)
16
26
  abort 'Board ID is required' if id.to_s.strip.empty?
17
27
  builder do
@@ -20,6 +30,10 @@ module Rujira
20
30
  run
21
31
  end
22
32
 
33
+ # Lists all boards visible to the current user.
34
+ #
35
+ # @return [Object] The API response containing a list of boards.
36
+ #
23
37
  def list
24
38
  builder do
25
39
  path 'board'
@@ -27,6 +41,11 @@ module Rujira
27
41
  run
28
42
  end
29
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
+ #
30
49
  def sprint(id)
31
50
  abort 'Board ID is required' if id.to_s.strip.empty?
32
51
  builder do
@@ -2,9 +2,22 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO
5
+ # Provides access to Jira issue comments via the REST API.
6
+ # API reference:
6
7
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/comment/%7BcommentId%7D/properties
8
+ #
7
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
+ #
8
21
  def create(id_or_key, &block)
9
22
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
10
23
  builder do
@@ -2,8 +2,14 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO
5
+ # Base class for Jira API resources.
6
+ # Provides common request setup, authorization, and request execution.
7
+ #
6
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
+ #
7
13
  def initialize(client)
8
14
  # Store the passed client object in an instance variable for later use
9
15
  @client = client
@@ -11,7 +17,7 @@ module Rujira
11
17
  # Configure requests using the client's builder DSL
12
18
  @client.request.builder do
13
19
  # Set the Bearer token for authorization
14
- bearer Configuration.token
20
+ bearer @token
15
21
 
16
22
  # Specify the default HTTP method for requests
17
23
  method :get
@@ -30,8 +36,9 @@ module Rujira
30
36
  # @return [Object] The configured request builder stored in @request.
31
37
  def builder(&block) = @client.request.builder(&block)
32
38
 
33
- # Delegate execution to the client's dispatch method
34
- # This triggers the configured request to be sent
39
+ # Executes the configured request.
40
+ #
41
+ # @return [Object] The API response after dispatching the request.
35
42
  def run = @client.dispatch
36
43
  end
37
44
  end
@@ -2,9 +2,19 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO
5
+ # Provides access to Jira dashboards via the REST API.
6
+ # API reference:
6
7
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/myself
8
+ #
7
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
+ #
8
18
  def get(id)
9
19
  abort 'Dashboard ID is required' if id.to_s.strip.empty?
10
20
  builder do
@@ -13,6 +23,13 @@ module Rujira
13
23
  run
14
24
  end
15
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
+ #
16
33
  def list
17
34
  builder do
18
35
  path 'dashboard'
@@ -2,9 +2,26 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO
5
+ # Provides access to Jira issues via the REST API.
6
+ # API reference:
6
7
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/issue
8
+ #
7
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
+ #
8
25
  def create(&block)
9
26
  builder do
10
27
  path 'issue'
@@ -14,6 +31,15 @@ module Rujira
14
31
  run
15
32
  end
16
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
+ #
17
43
  def get(id_or_key, &block)
18
44
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
19
45
  builder do
@@ -23,6 +49,15 @@ module Rujira
23
49
  run
24
50
  end
25
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
+ #
26
61
  def delete(id_or_key, &block)
27
62
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
28
63
  builder do
@@ -35,6 +70,17 @@ module Rujira
35
70
 
36
71
  alias del delete
37
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
+ #
38
84
  def edit(id_or_key, &block)
39
85
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
40
86
  builder do
@@ -45,11 +91,32 @@ module Rujira
45
91
  run
46
92
  end
47
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
+ #
48
105
  def comment(id_or_key, &block)
49
106
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
50
107
  @client.Comment.create id_or_key, &block
51
108
  end
52
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
+ #
53
120
  def watchers(id_or_key, name, &block)
54
121
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
55
122
  builder do
@@ -61,6 +128,16 @@ module Rujira
61
128
  run
62
129
  end
63
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
+ #
64
141
  def attachments(id_or_key, path, &block)
65
142
  abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
66
143
  @client.Attachments.create id_or_key, path, &block
@@ -2,9 +2,20 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO
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:
6
9
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/myself
10
+ #
7
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
+ #
8
19
  def get
9
20
  builder do
10
21
  path 'myself'
@@ -2,9 +2,27 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO
5
+ # Provides access to Jira projects via the REST API.
6
+ #
7
+ # API reference:
6
8
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/project
9
+ #
7
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
+ #
8
26
  def create(&block)
9
27
  builder do
10
28
  path 'project'
@@ -14,6 +32,17 @@ module Rujira
14
32
  run
15
33
  end
16
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
+ #
17
46
  def edit(id_or_key, &block)
18
47
  abort 'Project ID or KEY is required' if id_or_key.to_s.strip.empty?
19
48
  builder do
@@ -24,6 +53,15 @@ module Rujira
24
53
  run
25
54
  end
26
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
+ #
27
65
  def get(id_or_key, &block)
28
66
  abort 'Project ID or KEY is required' if id_or_key.to_s.strip.empty?
29
67
  builder do
@@ -33,6 +71,14 @@ module Rujira
33
71
  run
34
72
  end
35
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
+ #
36
82
  def list(&block)
37
83
  builder do
38
84
  path 'project'
@@ -41,6 +87,14 @@ module Rujira
41
87
  run
42
88
  end
43
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
+ #
44
98
  def delete(id_or_key)
45
99
  abort 'Project ID or KEY is required' if id_or_key.to_s.strip.empty?
46
100
  builder do
@@ -50,6 +104,15 @@ module Rujira
50
104
  run
51
105
  end
52
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
+ #
53
116
  def securitylevel(id_or_key, &block)
54
117
  abort 'Project ID or KEY is required' if id_or_key.to_s.strip.empty?
55
118
  builder do
@@ -2,9 +2,24 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO
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:
6
9
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/search
10
+ #
7
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
+ #
8
23
  def get(&block)
9
24
  builder do
10
25
  path 'search'
@@ -2,9 +2,20 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO
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:
6
9
  # https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/serverInfo
10
+ #
7
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
+ #
8
19
  def get
9
20
  builder do
10
21
  path 'serverInfo'
@@ -2,9 +2,17 @@
2
2
 
3
3
  module Rujira
4
4
  module Api
5
- # TODO
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:
6
9
  # https://docs.atlassian.com/jira-software/REST/9.17.0/#agile/1.0/sprint
10
+ #
7
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
+ #
8
16
  def initialize(client)
9
17
  super
10
18
  builder do
@@ -12,6 +20,16 @@ module Rujira
12
20
  end
13
21
  end
14
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
+ #
15
33
  def create(&block)
16
34
  builder do
17
35
  path 'sprint'
@@ -22,6 +40,17 @@ module Rujira
22
40
  run
23
41
  end
24
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
+ #
25
54
  def update(id, &block)
26
55
  abort 'Sprint ID is required' if id.to_s.strip.empty?
27
56
  raise ArgumentError, 'block is required' unless block
@@ -30,11 +59,22 @@ module Rujira
30
59
  path "sprint/#{id}"
31
60
  headers 'Content-Type': 'application/json', Accept: 'application/json'
32
61
  method :post
33
- instance_eval(&block) if block_given?
62
+ instance_eval(&block)
34
63
  end
35
64
  run
36
65
  end
37
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
+ #
38
78
  def replace(id, &block)
39
79
  abort 'Sprint ID is required' if id.to_s.strip.empty?
40
80
  raise ArgumentError, 'block is required' unless block
@@ -43,11 +83,16 @@ module Rujira
43
83
  path "sprint/#{id}"
44
84
  headers 'Content-Type': 'application/json', Accept: 'application/json'
45
85
  method :put
46
- instance_eval(&block) if block_given?
86
+ instance_eval(&block)
47
87
  end
48
88
  run
49
89
  end
50
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
+ #
51
96
  def get(id)
52
97
  abort 'Sprint ID is required' if id.to_s.strip.empty?
53
98
  builder do
@@ -56,6 +101,11 @@ module Rujira
56
101
  run
57
102
  end
58
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
+ #
59
109
  def get_issue(id)
60
110
  abort 'Sprint ID is required' if id.to_s.strip.empty?
61
111
  builder do
@@ -64,6 +114,11 @@ module Rujira
64
114
  run
65
115
  end
66
116
 
117
+ # Deletes a sprint.
118
+ #
119
+ # @param [Integer] id The sprint ID.
120
+ # @return [Object] The API response after deletion.
121
+ #
67
122
  def delete(id)
68
123
  abort 'Sprint ID is required' if id.to_s.strip.empty?
69
124
  builder do
@@ -73,6 +128,11 @@ module Rujira
73
128
  run
74
129
  end
75
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
+ #
76
136
  def properties(id)
77
137
  abort 'Sprint ID is required' if id.to_s.strip.empty?
78
138
  builder do
@@ -81,6 +141,15 @@ module Rujira
81
141
  run
82
142
  end
83
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
+ #
84
153
  def issue(id, issues)
85
154
  abort 'Sprint ID is required' if id.to_s.strip.empty?
86
155
  builder do
data/lib/rujira/client.rb CHANGED
@@ -1,16 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rujira
4
- # TODO
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
+ #
5
11
  class Client
12
+ # @return [Rujira::Request] The current request object being configured
6
13
  attr_accessor :request
7
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
+ #
8
23
  def initialize(url, debug: false)
9
24
  @uri = URI(url)
10
25
  @debug = ENV.fetch('RUJIRA_DEBUG', debug.to_s) == 'true'
11
26
  @request = Request.new
12
27
  end
13
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
+ #
14
38
  def method_missing(method_name, ...)
15
39
  resource_class = Rujira::Api.const_get(method_name.to_s)
16
40
  resource_class.new(self, ...)
@@ -18,19 +42,33 @@ module Rujira
18
42
  super
19
43
  end
20
44
 
45
+ # Options for Faraday connection.
46
+ #
47
+ # @return [Hash] Options including URL, headers, and params
48
+ #
21
49
  def options
22
50
  {
23
- url: Configuration.url,
51
+ url: @uri,
24
52
  headers: @request.headers,
25
53
  params: @request.params
26
-
27
54
  }
28
55
  end
29
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
+ #
30
63
  def respond_to_missing?(method_name, include_private = false)
31
64
  Rujira::Api.const_defined?(method_name.to_s) || super
32
65
  end
33
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
+ #
34
72
  def dispatch # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
35
73
  unless %i[get delete head post put patch].include?(@request.method)
36
74
  raise "method #{@request.method} not supported"
@@ -48,6 +86,10 @@ module Rujira
48
86
  end
49
87
  end
50
88
 
89
+ # Builds the Faraday connection for HTTP requests.
90
+ #
91
+ # @return [Faraday::Connection] Configured Faraday connection
92
+ #
51
93
  def connection
52
94
  Faraday.new(options) do |builder|
53
95
  builder.request :authorization, *@request.authorization if @request.authorization
@@ -59,10 +101,20 @@ module Rujira
59
101
  end
60
102
  end
61
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
+ #
62
109
  def file(path)
63
110
  Faraday::Multipart::FilePart.new(path, 'multipart/form-data')
64
111
  end
65
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
+ #
66
118
  def generate_mocks(res)
67
119
  path = res.to_hash[:url].path
68
120
  cache_path = File.join('.cache', path)
data/lib/rujira/error.rb CHANGED
@@ -3,14 +3,16 @@
3
3
  module Rujira
4
4
  class Error < StandardError; end
5
5
 
6
- # TODO
6
+ # TODO: add docs
7
+ # Some description
7
8
  class PathArgumentError < Error
8
9
  def message
9
10
  "No argument to 'path' was given."
10
11
  end
11
12
  end
12
13
 
13
- # TODO
14
+ # TODO: add docs
15
+ # Some description
14
16
  class DataArgumentError < Error
15
17
  def message
16
18
  "No argument to 'data' was given."
@@ -3,13 +3,19 @@
3
3
  require 'fileutils'
4
4
 
5
5
  module Rujira
6
- # TODO
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
+ #
7
9
  class Request
8
- 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
9
14
 
15
+ # Initializes a new request object with default values.
16
+ #
10
17
  def initialize
11
- @token = Configuration.token
12
- @debug = Configuration.debug
18
+ @token = ENV['RUJIRA_TOKEN'] if ENV.include?('RUJIRA_TOKEN')
13
19
  @method = :get
14
20
  @params = {}
15
21
  @headers = {}
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rujira
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.3'
5
5
  end
data/lib/rujira.rb CHANGED
@@ -1,13 +1,14 @@
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
- require_relative 'rujira/configuration'
11
12
  require_relative 'rujira/request'
12
13
  require_relative 'rujira/client'
13
14
  require_relative 'rujira/api/common'
@@ -22,10 +23,27 @@ require_relative 'rujira/api/dashboard'
22
23
  require_relative 'rujira/api/board'
23
24
  require_relative 'rujira/api/sprint'
24
25
 
25
- # TODO
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.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Semenov
@@ -67,7 +67,6 @@ files:
67
67
  - lib/rujira/api/server_info.rb
68
68
  - lib/rujira/api/sprint.rb
69
69
  - lib/rujira/client.rb
70
- - lib/rujira/configuration.rb
71
70
  - lib/rujira/error.rb
72
71
  - lib/rujira/request.rb
73
72
  - lib/rujira/tasks/generate.rake
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rujira
4
- # TODO
5
- module Configuration
6
- def self.token
7
- return ENV['RUJIRA_TOKEN'] if ENV.include?('RUJIRA_TOKEN')
8
-
9
- raise 'The environment variable RUJIRA_TOKEN is not set'
10
- end
11
-
12
- def self.url
13
- return ENV['RUJIRA_URL'] if ENV.include?('RUJIRA_URL')
14
-
15
- 'http://localhost:8080'
16
- end
17
-
18
- def self.debug
19
- return false unless ENV.include?('RUJIRA_DEBUG')
20
-
21
- ENV['RUJIRA_DEBUG'].match?(/^true$/)
22
- end
23
- end
24
- end