jira-ruby 2.3.0 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  4. data/.github/dependabot.yml +6 -0
  5. data/.github/workflows/CI.yml +28 -0
  6. data/.github/workflows/codeql.yml +100 -0
  7. data/.github/workflows/rubocop.yml +18 -0
  8. data/.rubocop.yml +188 -0
  9. data/Gemfile +11 -3
  10. data/Guardfile +2 -0
  11. data/README.md +94 -18
  12. data/Rakefile +3 -4
  13. data/jira-ruby.gemspec +11 -17
  14. data/lib/jira/base.rb +37 -28
  15. data/lib/jira/base_factory.rb +4 -1
  16. data/lib/jira/client.rb +64 -46
  17. data/lib/jira/has_many_proxy.rb +4 -2
  18. data/lib/jira/http_client.rb +17 -13
  19. data/lib/jira/http_error.rb +4 -0
  20. data/lib/jira/jwt_client.rb +18 -42
  21. data/lib/jira/oauth_client.rb +6 -3
  22. data/lib/jira/railtie.rb +2 -0
  23. data/lib/jira/request_client.rb +5 -1
  24. data/lib/jira/resource/agile.rb +7 -9
  25. data/lib/jira/resource/applinks.rb +5 -3
  26. data/lib/jira/resource/attachment.rb +43 -3
  27. data/lib/jira/resource/board.rb +5 -3
  28. data/lib/jira/resource/board_configuration.rb +2 -0
  29. data/lib/jira/resource/comment.rb +2 -0
  30. data/lib/jira/resource/component.rb +2 -0
  31. data/lib/jira/resource/createmeta.rb +3 -1
  32. data/lib/jira/resource/field.rb +9 -4
  33. data/lib/jira/resource/filter.rb +2 -0
  34. data/lib/jira/resource/issue.rb +35 -44
  35. data/lib/jira/resource/issue_picker_suggestions.rb +4 -1
  36. data/lib/jira/resource/issue_picker_suggestions_issue.rb +2 -0
  37. data/lib/jira/resource/issuelink.rb +2 -0
  38. data/lib/jira/resource/issuelinktype.rb +2 -0
  39. data/lib/jira/resource/issuetype.rb +2 -0
  40. data/lib/jira/resource/priority.rb +2 -0
  41. data/lib/jira/resource/project.rb +4 -2
  42. data/lib/jira/resource/rapidview.rb +5 -3
  43. data/lib/jira/resource/remotelink.rb +2 -0
  44. data/lib/jira/resource/resolution.rb +2 -0
  45. data/lib/jira/resource/serverinfo.rb +2 -0
  46. data/lib/jira/resource/sprint.rb +14 -23
  47. data/lib/jira/resource/status.rb +7 -1
  48. data/lib/jira/resource/status_category.rb +10 -0
  49. data/lib/jira/resource/suggested_issue.rb +2 -0
  50. data/lib/jira/resource/transition.rb +2 -0
  51. data/lib/jira/resource/user.rb +3 -1
  52. data/lib/jira/resource/version.rb +2 -0
  53. data/lib/jira/resource/watcher.rb +2 -1
  54. data/lib/jira/resource/webhook.rb +4 -2
  55. data/lib/jira/resource/worklog.rb +3 -2
  56. data/lib/jira/version.rb +3 -1
  57. data/lib/jira-ruby.rb +5 -3
  58. data/lib/tasks/generate.rake +4 -2
  59. data/spec/data/files/short.txt +1 -0
  60. data/spec/integration/attachment_spec.rb +3 -3
  61. data/spec/integration/comment_spec.rb +8 -8
  62. data/spec/integration/component_spec.rb +7 -7
  63. data/spec/integration/field_spec.rb +3 -3
  64. data/spec/integration/issue_spec.rb +20 -16
  65. data/spec/integration/issuelinktype_spec.rb +3 -3
  66. data/spec/integration/issuetype_spec.rb +3 -3
  67. data/spec/integration/priority_spec.rb +3 -3
  68. data/spec/integration/project_spec.rb +7 -7
  69. data/spec/integration/rapidview_spec.rb +9 -9
  70. data/spec/integration/resolution_spec.rb +3 -3
  71. data/spec/integration/status_category_spec.rb +20 -0
  72. data/spec/integration/status_spec.rb +4 -8
  73. data/spec/integration/transition_spec.rb +2 -2
  74. data/spec/integration/user_spec.rb +22 -8
  75. data/spec/integration/version_spec.rb +7 -7
  76. data/spec/integration/watcher_spec.rb +17 -18
  77. data/spec/integration/webhook.rb +5 -4
  78. data/spec/integration/worklog_spec.rb +8 -8
  79. data/spec/jira/base_factory_spec.rb +2 -1
  80. data/spec/jira/base_spec.rb +55 -41
  81. data/spec/jira/client_spec.rb +48 -34
  82. data/spec/jira/has_many_proxy_spec.rb +3 -3
  83. data/spec/jira/http_client_spec.rb +94 -27
  84. data/spec/jira/http_error_spec.rb +2 -2
  85. data/spec/jira/oauth_client_spec.rb +8 -6
  86. data/spec/jira/request_client_spec.rb +4 -4
  87. data/spec/jira/resource/agile_spec.rb +28 -28
  88. data/spec/jira/resource/attachment_spec.rb +142 -52
  89. data/spec/jira/resource/board_spec.rb +21 -20
  90. data/spec/jira/resource/createmeta_spec.rb +48 -48
  91. data/spec/jira/resource/field_spec.rb +30 -12
  92. data/spec/jira/resource/filter_spec.rb +4 -4
  93. data/spec/jira/resource/issue_picker_suggestions_spec.rb +17 -17
  94. data/spec/jira/resource/issue_spec.rb +43 -37
  95. data/spec/jira/resource/jira_picker_suggestions_issue_spec.rb +3 -3
  96. data/spec/jira/resource/project_factory_spec.rb +3 -2
  97. data/spec/jira/resource/project_spec.rb +16 -16
  98. data/spec/jira/resource/sprint_spec.rb +70 -3
  99. data/spec/jira/resource/status_spec.rb +21 -0
  100. data/spec/jira/resource/user_factory_spec.rb +4 -4
  101. data/spec/jira/resource/worklog_spec.rb +3 -3
  102. data/spec/mock_responses/sprint/1.json +13 -0
  103. data/spec/mock_responses/status/1.json +8 -1
  104. data/spec/mock_responses/status.json +40 -5
  105. data/spec/mock_responses/statuscategory/1.json +7 -0
  106. data/spec/mock_responses/statuscategory.json +30 -0
  107. data/spec/mock_responses/{user_username=admin.json → user_accountId=1234567890abcdef01234567.json} +2 -1
  108. data/spec/spec_helper.rb +1 -0
  109. data/spec/support/clients_helper.rb +3 -5
  110. data/spec/support/shared_examples/integration.rb +25 -28
  111. metadata +25 -257
  112. data/.travis.yml +0 -9
  113. data/example.rb +0 -232
  114. data/http-basic-example.rb +0 -113
  115. data/lib/jira/resource/sprint_report.rb +0 -8
  116. data/lib/jira/tasks.rb +0 -0
  117. data/spec/jira/jwt_uri_builder_spec.rb +0 -59
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 113ad755633d6eb87e63d7a97d3228f6649828547c01dee1ae1900ef0d575e2d
4
- data.tar.gz: d59620f52976814ee7db58df10213bdb512f042a8b8214789ed07288f2899b65
3
+ metadata.gz: ce094c983bd1fe30eb23f7aa69fe2d1098e72d483e048a8195b7c1cdbbd61525
4
+ data.tar.gz: 25c34ab3ef66571e69e7a6ba48d53f640dfcd4366b92365493e7adbf28b81862
5
5
  SHA512:
6
- metadata.gz: e523698732b5cef8a220259ccf5c42c568ac7eea435ee2ed2f2018cdd25959597d23337a67fac037e00be85a8838d9d32a2c79a156da008380699d2c9529cb03
7
- data.tar.gz: cefe63455cb070951d73420dc1144b0c0a4651836427f507d218d3eb0780936e6a740842f6f2df8f68b14be8034bb196b4f5069d21ac0c3cd9e2a4292e43b456
6
+ metadata.gz: 363e629f6830f245fc2a64e337dc1a8eecff9899721467e1cf8fb150e30ed23ab93ef7469ab1eaadfa8e6d600512b33bdeedb6a0510aff66fdaad3c94fe470fb
7
+ data.tar.gz: d04851879ce041793922c0d26f645f672246af8ab061f26daba8df7666a264db7ed60636fd8dcacce9256c721b227a8561d871b1b87b292a1871295ec77398a4
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: Bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ A runnable code example to reproduce the issue.
15
+
16
+ **Expected behavior**
17
+ A clear and concise description of what you expected to happen.
18
+
19
+ **Additional context**
20
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: Feature
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context about the feature request here.
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
@@ -0,0 +1,28 @@
1
+ name: Ruby
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ name: CI-tests
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ ruby:
13
+ - '3.3'
14
+ - '3.2'
15
+ - '3.1'
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ bundler-cache: true
24
+
25
+ - name: Run tests
26
+ run: |
27
+ bundle exec rake jira:generate_public_cert
28
+ bundle exec rake spec
@@ -0,0 +1,100 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ "master" ]
17
+ paths-ignore:
18
+ - '**/*.md'
19
+ - 'http-basic-example.rb'
20
+ - 'example.rb'
21
+ pull_request:
22
+ branches: [ "master" ]
23
+ paths-ignore:
24
+ - '**/*.md'
25
+ - 'http-basic-example.rb'
26
+ - 'example.rb'
27
+ schedule:
28
+ - cron: '0 13 * * *'
29
+
30
+ jobs:
31
+ analyze:
32
+ name: Analyze (${{ matrix.language }})
33
+ # Runner size impacts CodeQL analysis time. To learn more, please see:
34
+ # - https://gh.io/recommended-hardware-resources-for-running-codeql
35
+ # - https://gh.io/supported-runners-and-hardware-resources
36
+ # - https://gh.io/using-larger-runners (GitHub.com only)
37
+ # Consider using larger runners or machines with greater resources for possible analysis time improvements.
38
+ runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
39
+ timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
40
+ permissions:
41
+ # required for all workflows
42
+ security-events: write
43
+
44
+ # required to fetch internal or private CodeQL packs
45
+ packages: read
46
+
47
+ # only required for workflows in private repositories
48
+ actions: read
49
+ contents: read
50
+
51
+ strategy:
52
+ fail-fast: false
53
+ matrix:
54
+ include:
55
+ - language: ruby
56
+ build-mode: none
57
+ # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
58
+ # Use `c-cpp` to analyze code written in C, C++ or both
59
+ # Use 'java-kotlin' to analyze code written in Java, Kotlin or both
60
+ # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
61
+ # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
62
+ # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
63
+ # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
64
+ # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
65
+ steps:
66
+ - name: Checkout repository
67
+ uses: actions/checkout@v4
68
+
69
+ # Initializes the CodeQL tools for scanning.
70
+ - name: Initialize CodeQL
71
+ uses: github/codeql-action/init@v3
72
+ with:
73
+ languages: ${{ matrix.language }}
74
+ build-mode: ${{ matrix.build-mode }}
75
+ # If you wish to specify custom queries, you can do so here or in a config file.
76
+ # By default, queries listed here will override any specified in a config file.
77
+ # Prefix the list here with "+" to use these queries and those in the config file.
78
+
79
+ # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
80
+ # queries: security-extended,security-and-quality
81
+
82
+ # If the analyze step fails for one of the languages you are analyzing with
83
+ # "We were unable to automatically build your code", modify the matrix above
84
+ # to set the build mode to "manual" for that language. Then modify this step
85
+ # to build your code.
86
+ # ℹ️ Command-line programs to run using the OS shell.
87
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
88
+ - if: matrix.build-mode == 'manual'
89
+ run: |
90
+ echo 'If you are using a "manual" build mode for one or more of the' \
91
+ 'languages you are analyzing, replace this with the commands to build' \
92
+ 'your code, for example:'
93
+ echo ' make bootstrap'
94
+ echo ' make release'
95
+ exit 1
96
+
97
+ - name: Perform CodeQL Analysis
98
+ uses: github/codeql-action/analyze@v3
99
+ with:
100
+ category: "/language:${{matrix.language}}"
@@ -0,0 +1,18 @@
1
+ name: Rubocop
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ rubocop:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - uses: actions/checkout@v4
11
+ - name: Set up Ruby
12
+ uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: '3.1'
15
+ bundler-cache: true
16
+ - name: Run rubocop
17
+ run: |
18
+ bundle exec rubocop --format github
data/.rubocop.yml ADDED
@@ -0,0 +1,188 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - 'example.rb'
7
+ - 'http-basic-example.rb'
8
+ - 'vendor/**/*'
9
+ NewCops: enable
10
+ TargetRubyVersion: 3.1
11
+
12
+ Naming/FileName:
13
+ Exclude:
14
+ - 'lib/jira-ruby.rb'
15
+
16
+ Naming/MethodName:
17
+ Enabled: false
18
+
19
+ Style/Documentation:
20
+ Enabled: false
21
+
22
+ Style/FrozenStringLiteralComment:
23
+ Exclude:
24
+ - 'spec/**/*'
25
+
26
+ ##
27
+ # Temporarily Disable
28
+ #
29
+ # We are going to disable these and fix in pull requests
30
+ ##
31
+ Layout/ClosingHeredocIndentation:
32
+ Enabled: false
33
+
34
+ Layout/EmptyLineAfterGuardClause:
35
+ Enabled: false
36
+
37
+ Layout/EmptyLinesAroundMethodBody:
38
+ Enabled: false
39
+
40
+ Layout/HashAlignment:
41
+ Enabled: false
42
+
43
+ Layout/LineLength:
44
+ Enabled: false
45
+
46
+ Lint/ConstantDefinitionInBlock:
47
+ Enabled: false
48
+
49
+ Lint/EmptyClass:
50
+ Enabled: false
51
+
52
+ Lint/IneffectiveAccessModifier:
53
+ Enabled: false
54
+
55
+ Lint/MissingSuper:
56
+ Enabled: false
57
+
58
+ Lint/RedundantCopDisableDirective:
59
+ Enabled: false
60
+
61
+ Lint/UselessAssignment:
62
+ Enabled: false
63
+
64
+ Metrics/AbcSize:
65
+ Enabled: false
66
+
67
+ Metrics/ClassLength:
68
+ Enabled: false
69
+
70
+ Metrics/CyclomaticComplexity:
71
+ Enabled: false
72
+
73
+ Metrics/MethodLength:
74
+ Enabled: false
75
+
76
+ Metrics/PerceivedComplexity:
77
+ Enabled: false
78
+
79
+ Naming/AccessorMethodName:
80
+ Enabled: false
81
+
82
+ Naming/BlockForwarding:
83
+ Enabled: false
84
+
85
+ Naming/HeredocDelimiterNaming:
86
+ Enabled: false
87
+
88
+ Naming/PredicateName:
89
+ Enabled: false
90
+
91
+ Naming/VariableNumber:
92
+ Enabled: false
93
+
94
+ RSpec/AnyInstance:
95
+ Enabled: false
96
+
97
+ RSpec/BeEq:
98
+ Enabled: false
99
+
100
+ RSpec/ContextWording:
101
+ Enabled: false
102
+
103
+ RSpec/ExampleLength:
104
+ Enabled: false
105
+
106
+ RSpec/ExpectInHook:
107
+ Enabled: false
108
+
109
+ RSpec/IndexedLet:
110
+ Enabled: false
111
+
112
+ RSpec/InstanceVariable:
113
+ Enabled: false
114
+
115
+ RSpec/LeakyConstantDeclaration:
116
+ Enabled: false
117
+
118
+ RSpec/MessageChain:
119
+ Enabled: false
120
+
121
+ RSpec/MessageSpies:
122
+ Enabled: false
123
+
124
+ RSpec/MultipleExpectations:
125
+ Enabled: false
126
+
127
+ RSpec/MultipleMemoizedHelpers:
128
+ Enabled: false
129
+
130
+ RSpec/NamedSubject:
131
+ Enabled: false
132
+
133
+ RSpec/NestedGroups:
134
+ Enabled: false
135
+
136
+ RSpec/NoExpectationExample:
137
+ Enabled: false
138
+
139
+ RSpec/PredicateMatcher:
140
+ Enabled: false
141
+
142
+ RSpec/ReceiveMessages:
143
+ Enabled: false
144
+
145
+ RSpec/RepeatedSubjectCall:
146
+ Enabled: false
147
+
148
+ RSpec/SpecFilePathFormat:
149
+ Enabled: false
150
+
151
+ RSpec/SpecFilePathSuffix:
152
+ Enabled: false
153
+
154
+ RSpec/StubbedMock:
155
+ Enabled: false
156
+
157
+ RSpec/SubjectStub:
158
+ Enabled: false
159
+
160
+ RSpec/VerifiedDoubleReference:
161
+ Enabled: false
162
+
163
+ RSpec/VerifiedDoubles:
164
+ Enabled: false
165
+
166
+ Security/Open:
167
+ Enabled: false
168
+
169
+ Style/ArgumentsForwarding:
170
+ Enabled: false
171
+
172
+ Style/CaseEquality:
173
+ Enabled: false
174
+
175
+ Style/ClassAndModuleChildren:
176
+ Enabled: false
177
+
178
+ Style/MissingRespondToMissing:
179
+ Enabled: false
180
+
181
+ Style/OpenStructUse:
182
+ Enabled: false
183
+
184
+ Style/OptionalBooleanParameter:
185
+ Enabled: false
186
+
187
+ Style/SymbolProc:
188
+ Enabled: false
data/Gemfile CHANGED
@@ -1,13 +1,21 @@
1
- source 'http://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  group :development do
4
- gem 'guard'
5
- gem 'guard-rspec'
6
+ gem 'guard', '~> 2.18', '>= 2.18.1'
7
+ gem 'guard-rspec', '~> 4.7', '>= 4.7.3'
8
+ gem 'railties'
9
+ gem 'rake', '~> 13.2', '>= 13.2.1'
10
+ gem 'rspec', '~> 3.0', '>= 3.13'
6
11
  gem 'wdm', '>= 0.1.0' if Gem.win_platform?
12
+ gem 'webmock', '~> 3.23', '>= 3.23.0'
7
13
  end
8
14
 
9
15
  group :development, :test do
10
16
  gem 'pry' # this was in the original Gemfile - but only needed in development & test
17
+ gem 'rubocop'
18
+ gem 'rubocop-rspec', require: false
11
19
  end
12
20
 
13
21
  # Specify your gem's dependencies in jira_api.gemspec
data/Guardfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  gem 'wdm', '>= 0.1.0' if Gem.win_platform?
2
4
  gem 'rspec', '~> 3.0.0'
3
5
 
data/README.md CHANGED
@@ -1,37 +1,114 @@
1
1
  # JIRA API Gem
2
2
 
3
3
  [![Code Climate](https://codeclimate.com/github/sumoheavy/jira-ruby.svg)](https://codeclimate.com/github/sumoheavy/jira-ruby)
4
- [![Build Status](https://travis-ci.org/sumoheavy/jira-ruby.svg?branch=master)](https://travis-ci.org/sumoheavy/jira-ruby)
4
+ [![Build Status](https://github.com/sumoheavy/jira-ruby/actions/workflows/CI.yml/badge.svg)](https://github.com/sumoheavy/jira-ruby/actions/workflows/CI.yml)
5
5
 
6
6
  This gem provides access to the Atlassian JIRA REST API.
7
7
 
8
- ## Slack
8
+ ## Example usage
9
9
 
10
- Join our Slack channel! You can find us [here](https://jira-ruby-slackin.herokuapp.com/)
10
+ # Jira Ruby API - Sample Usage
11
11
 
12
- ## Example usage
12
+ This sample usage demonstrates how you can interact with JIRA's API using the [jira-ruby gem](https://github.com/sumoheavy/jira-ruby).
13
13
 
14
- ```ruby
15
- require 'rubygems'
16
- require 'jira-ruby'
14
+ ### Dependencies
15
+
16
+ Before running, install the `jira-ruby` gem:
17
17
 
18
+ ```shell
19
+ gem install jira-ruby
20
+ ```
21
+
22
+ ### Sample Usage
23
+ Connect to JIRA
24
+ Firstly, establish a connection with your JIRA instance by providing a few configuration parameters:
25
+ There are other ways to connect to JIRA listed below | [Personal Access Token](#configuring-jira-to-use-personal-access-tokens-auth)
26
+ - private_key_file: The path to your RSA private key file.
27
+ - consumer_key: Your consumer key.
28
+ - site: The URL of your JIRA instance.
29
+
30
+ ```ruby
18
31
  options = {
19
- :username => 'username',
20
- :password => 'pass1234',
21
- :site => 'http://mydomain.atlassian.net:443/',
22
- :context_path => '',
23
- :auth_type => :basic
32
+ :private_key_file => "rsakey.pem",
33
+ :context_path => '',
34
+ :consumer_key => 'your_consumer_key',
35
+ :site => 'your_jira_instance_url'
24
36
  }
25
37
 
26
38
  client = JIRA::Client.new(options)
39
+ ```
27
40
 
28
- project = client.Project.find('SAMPLEPROJECT')
41
+ ### Retrieve and Display Projects
29
42
 
30
- project.issues.each do |issue|
31
- puts "#{issue.id} - #{issue.summary}"
43
+ After establishing the connection, you can fetch all projects and display their key and name:
44
+ ```ruby
45
+ projects = client.Project.all
46
+
47
+ projects.each do |project|
48
+ puts "Project -> key: #{project.key}, name: #{project.name}"
32
49
  end
33
50
  ```
34
51
 
52
+ ### Handling Fields by Name
53
+ The jira-ruby gem allows you to refer to fields by their custom names rather than identifiers. Make sure to map fields before using them:
54
+
55
+ ```ruby
56
+ client.Field.map_fields
57
+
58
+ old_way = issue.customfield_12345
59
+
60
+ # Note: The methods mapped here adopt a unique style combining PascalCase and snake_case conventions.
61
+ new_way = issue.Special_Field
62
+ ```
63
+
64
+ ### JQL Queries
65
+ To find issues based on specific criteria, you can use JIRA Query Language (JQL):
66
+
67
+ ```ruby
68
+ client.Issue.jql(a_normal_jql_search, fields:[:description, :summary, :Special_field, :created])
69
+ ```
70
+
71
+ ### Several actions can be performed on the Issue object such as create, update, transition, delete, etc:
72
+ ### Creating an Issue
73
+ ```ruby
74
+ issue = client.Issue.build
75
+ labels = ['label1', 'label2']
76
+ issue.save({
77
+ "fields" => {
78
+ "summary" => "blarg from in example.rb",
79
+ "project" => {"key" => "SAMPLEPROJECT"},
80
+ "issuetype" => {"id" => "3"},
81
+ "labels" => labels,
82
+ "priority" => {"id" => "1"}
83
+ }
84
+ })
85
+ ```
86
+
87
+ ### Updating/Transitioning an Issue
88
+ ```ruby
89
+ issue = client.Issue.find("10002")
90
+ issue.save({"fields"=>{"summary"=>"EVEN MOOOOOOARRR NINJAAAA!"}})
91
+
92
+ issue_transition = issue.transitions.build
93
+ issue_transition.save!('transition' => {'id' => transition_id})
94
+ ```
95
+
96
+ ### Deleting an Issue
97
+ ```ruby
98
+ issue = client.Issue.find('SAMPLEPROJECT-2')
99
+ issue.delete
100
+ ```
101
+
102
+ ### Other Capabilities
103
+ Apart from the operations listed above, this API wrapper supports several other capabilities like:
104
+ • Searching for a user
105
+ • Retrieving an issue's watchers
106
+ • Changing the assignee of an issue
107
+ • Adding attachments and comments to issues
108
+ • Managing issue links and much more.
109
+
110
+ Not all examples are shown in this README; refer to the complete script example for a full overview of the capabilities supported by this API wrapper.
111
+
35
112
  ## Links to JIRA REST API documentation
36
113
 
37
114
  * [Overview](https://developer.atlassian.com/display/JIRADEV/JIRA+REST+APIs)
@@ -87,7 +164,7 @@ key.
87
164
  > After you have entered all the information click OK and ensure OAuth authentication is
88
165
  > enabled.
89
166
 
90
- For 2 legged oauth in server mode only, not in cloud based JIRA, make sure to `Allow 2-Legged OAuth`
167
+ For two legged oauth in server mode only, not in cloud based JIRA, make sure to `Allow 2-Legged OAuth`
91
168
 
92
169
  ## Configuring JIRA to use HTTP Basic Auth
93
170
 
@@ -148,8 +225,7 @@ api_token = API_TOKEN_OBTAINED_FROM_JIRA_UI
148
225
  options = {
149
226
  :site => 'http://mydomain.atlassian.net:443/',
150
227
  :context_path => '',
151
- :username => '<the email you sign-in to Jira>',
152
- :password => api_token,
228
+ :default_headers => { 'Authorization' => "Bearer #{api_token}" },
153
229
  :auth_type => :basic
154
230
  }
155
231
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
 
3
5
  require 'rubygems'
@@ -13,13 +15,10 @@ task test: %i[prepare spec]
13
15
  desc 'Prepare and run rspec tests'
14
16
  task :prepare do
15
17
  rsa_key = File.expand_path('rsakey.pem')
16
- unless File.exist?(rsa_key)
17
- Rake::Task['jira:generate_public_cert'].invoke
18
- end
18
+ Rake::Task['jira:generate_public_cert'].invoke unless File.exist?(rsa_key)
19
19
  end
20
20
 
21
21
  desc 'Run RSpec tests'
22
- # RSpec::Core::RakeTask.new(:spec)
23
22
  RSpec::Core::RakeTask.new(:spec, [] => [:prepare]) do |task|
24
23
  task.rspec_opts = ['--color', '--format', 'doc']
25
24
  end
data/jira-ruby.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  $LOAD_PATH.push File.expand_path('lib', __dir__)
2
4
  require 'jira/version'
3
5
 
@@ -9,27 +11,19 @@ Gem::Specification.new do |s|
9
11
  s.summary = 'Ruby Gem for use with the Atlassian JIRA REST API'
10
12
  s.description = 'API for JIRA'
11
13
  s.licenses = ['MIT']
12
- s.metadata = { 'source_code_uri' => 'https://github.com/sumoheavy/jira-ruby' }
14
+ s.metadata = {
15
+ 'source_code_uri' => 'https://github.com/sumoheavy/jira-ruby',
16
+ 'rubygems_mfa_required' => 'true'
17
+ }
13
18
 
14
- s.required_ruby_version = '>= 1.9.3'
19
+ s.required_ruby_version = '>= 3.1.0'
15
20
 
16
21
  s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
22
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
23
  s.require_paths = ['lib']
20
24
 
21
- # Runtime Dependencies
22
- s.add_runtime_dependency 'activesupport'
23
- s.add_runtime_dependency 'atlassian-jwt'
24
- s.add_runtime_dependency 'multipart-post'
25
- s.add_runtime_dependency 'oauth', '~> 0.5', '>= 0.5.0'
26
-
27
- # Development Dependencies
28
- s.add_development_dependency 'guard', '~> 2.13', '>= 2.13.0'
29
- s.add_development_dependency 'guard-rspec', '~> 4.6', '>= 4.6.5'
30
- s.add_development_dependency 'pry', '~> 0.10', '>= 0.10.3'
31
- s.add_development_dependency 'railties'
32
- s.add_development_dependency 'rake', '~> 10.3', '>= 10.3.2'
33
- s.add_development_dependency 'rspec', '~> 3.0', '>= 3.0.0'
34
- s.add_development_dependency 'webmock', '~> 1.18', '>= 1.18.0'
25
+ s.add_dependency 'activesupport'
26
+ s.add_dependency 'atlassian-jwt'
27
+ s.add_dependency 'multipart-post'
28
+ s.add_dependency 'oauth', '~> 1.0'
35
29
  end