ojra 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +40 -0
- data/LICENSE +21 -0
- data/README.md +58 -0
- data/Rakefile +6 -0
- data/lib/ojra/client.rb +77 -0
- data/lib/ojra/version.rb +5 -0
- data/lib/ojra.rb +7 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 211acd3d634f9e9ddaf06dbcb9a4847abe24adf330be05813b42bc60ed0d81dd
|
4
|
+
data.tar.gz: 74ecc2f3d61f90151fb4991d484831d1ba34c6ac83d8a4866022305298f8250e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dbe9d37a5f02685aa4638e9f35520d7045e814e9d20b774b8d0ca53043b0b52185b5d0e5e372d6e0364def85846b05724a34823f2fdd3e903cb9034619980a71
|
7
|
+
data.tar.gz: f65c8b13a8063d052a7d4d853fe10b741949c8ae466263264f993592c4bf4ff9e315dd192ac2004719f97b2c49866571679bf99006845b7ad45d4561e9b953bb
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ojra (1.0.1)
|
5
|
+
faraday (~> 2.7)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.5.0)
|
11
|
+
faraday (2.7.3)
|
12
|
+
faraday-net_http (>= 2.0, < 3.1)
|
13
|
+
ruby2_keywords (>= 0.0.4)
|
14
|
+
faraday-net_http (3.0.2)
|
15
|
+
rake (13.0.6)
|
16
|
+
rspec (3.12.0)
|
17
|
+
rspec-core (~> 3.12.0)
|
18
|
+
rspec-expectations (~> 3.12.0)
|
19
|
+
rspec-mocks (~> 3.12.0)
|
20
|
+
rspec-core (3.12.0)
|
21
|
+
rspec-support (~> 3.12.0)
|
22
|
+
rspec-expectations (3.12.2)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.12.0)
|
25
|
+
rspec-mocks (3.12.2)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.12.0)
|
28
|
+
rspec-support (3.12.0)
|
29
|
+
ruby2_keywords (0.0.5)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
ojra!
|
36
|
+
rake (~> 13.0.6)
|
37
|
+
rspec (~> 3.12)
|
38
|
+
|
39
|
+
BUNDLED WITH
|
40
|
+
2.3.26
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 Juanjo Bazán
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# OJRA: Open Journals Reviewers API
|
2
|
+
|
3
|
+
A Ruby wrapper for the Open Journal's Reviewers application's API
|
4
|
+
|
5
|
+
## Use
|
6
|
+
|
7
|
+
### Installation
|
8
|
+
|
9
|
+
Install OJRA running:
|
10
|
+
|
11
|
+
```
|
12
|
+
gem install ojra
|
13
|
+
```
|
14
|
+
|
15
|
+
Or adding the gem to your project's `Gemfile`:
|
16
|
+
```ruby
|
17
|
+
gem "ojra"
|
18
|
+
```
|
19
|
+
|
20
|
+
### Authentication
|
21
|
+
|
22
|
+
Initialize the API Client class with the URL of the Reviewers site and a valid API token:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
require "ojra"
|
26
|
+
|
27
|
+
client = OJRA::Client("https://reviewers-app.url", "secretTOKEN1234")
|
28
|
+
```
|
29
|
+
|
30
|
+
### Available methods
|
31
|
+
|
32
|
+
**STATS:**
|
33
|
+
|
34
|
+
|
35
|
+
- **assign_reviewer(reviewer, issue_id)**: Add a new active review to a reviewers' stats
|
36
|
+
```ruby
|
37
|
+
client.assign_reviewer("reviewer21", 4321)
|
38
|
+
```
|
39
|
+
|
40
|
+
- **assign_reviewers(reviewers_list, issue_id)**: Add a new active review to a list of reviewers (array or comma separated string)
|
41
|
+
```ruby
|
42
|
+
client.assign_reviewers("@reviewer21, @reviewer33, @reviewer42", 4321)
|
43
|
+
client.assign_reviewers(["reviewer21", "reviewer33", "reviewer42"], 4321)
|
44
|
+
```
|
45
|
+
|
46
|
+
|
47
|
+
- **unassign_reviewer(reviewer, issue_id)**: Log end of review for a reviewer
|
48
|
+
```ruby
|
49
|
+
client.unassign_reviewer("@reviewer21", 4321)
|
50
|
+
```
|
51
|
+
|
52
|
+
|
53
|
+
- **unassign_reviewers(reviewers_list, issue_id)**: Log end of review for a list of reviewers (array or comma separated string)
|
54
|
+
```ruby
|
55
|
+
client.unassign_reviewers("@reviewer21, @reviewer33, @reviewer42", 4321)
|
56
|
+
client.unassign_reviewers(["reviewer21", "reviewer33", "reviewer42"], 4321)
|
57
|
+
```
|
58
|
+
|
data/Rakefile
ADDED
data/lib/ojra/client.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module OJRA
|
4
|
+
class Client
|
5
|
+
attr_reader :host_url, :token, :error_msg
|
6
|
+
|
7
|
+
def initialize(host_url, token)
|
8
|
+
@host_url = host_url.to_s.strip
|
9
|
+
@token = token.to_s.strip
|
10
|
+
@error_msg = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def configured?
|
14
|
+
!(host_url.empty? || token.empty?)
|
15
|
+
end
|
16
|
+
|
17
|
+
def assign_reviewer(reviewer, issue_id)
|
18
|
+
set_error_msg("Missing value: reviewer") and return if reviewer.to_s.strip.empty?
|
19
|
+
|
20
|
+
url = "#{host_url}/api/stats/update/#{reviewer}/review_assigned"
|
21
|
+
idempotency_key = "assign-#{reviewer}-#{issue_id}"
|
22
|
+
|
23
|
+
reviewers_api_post(url, { idempotency_key: idempotency_key })
|
24
|
+
end
|
25
|
+
|
26
|
+
def unassign_reviewer(reviewer, issue_id)
|
27
|
+
set_error_msg("Missing value: reviewer") and return if reviewer.to_s.strip.empty?
|
28
|
+
|
29
|
+
url = "#{host_url}/api/stats/update/#{reviewer}/review_unassigned"
|
30
|
+
idempotency_key = "unassign-#{reviewer}-#{issue_id}"
|
31
|
+
|
32
|
+
reviewers_api_post(url, { idempotency_key: idempotency_key })
|
33
|
+
end
|
34
|
+
|
35
|
+
def assign_reviewers(reviewers, issue_id)
|
36
|
+
reviewers_list = get_list(reviewers)
|
37
|
+
reviewers_list.each { |reviewer| assign_reviewer(reviewer, issue_id) }
|
38
|
+
end
|
39
|
+
|
40
|
+
def unassign_reviewers(reviewers, issue_id)
|
41
|
+
reviewers_list = get_list(reviewers)
|
42
|
+
reviewers_list.each { |reviewer| unassign_reviewer(reviewer, issue_id) }
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def unconfigured_api
|
48
|
+
raise UnconfiguredAPI.new("Missing configuration values for the API: host's URL and/or API Token")
|
49
|
+
end
|
50
|
+
|
51
|
+
def set_error_msg(message)
|
52
|
+
@error_msg = message
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_list(items)
|
56
|
+
items_list = []
|
57
|
+
if items.is_a?(String)
|
58
|
+
items_list = items.split(',').each(&:strip!)
|
59
|
+
elsif items.is_a?(Array)
|
60
|
+
items_list = items.each(&:strip!)
|
61
|
+
end
|
62
|
+
items_list
|
63
|
+
end
|
64
|
+
|
65
|
+
def reviewers_api_post(url, params)
|
66
|
+
unconfigured_api unless configured?
|
67
|
+
|
68
|
+
response = Faraday.post(url, params, { "TOKEN" => token })
|
69
|
+
|
70
|
+
if response.status.between?(400, 599)
|
71
|
+
set_error_msg("Error response code: #{response.status}")
|
72
|
+
end
|
73
|
+
|
74
|
+
response.status.between?(200, 299)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/ojra/version.rb
ADDED
data/lib/ojra.rb
ADDED
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ojra
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Juanjo Bazán
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-01-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 13.0.6
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 13.0.6
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.12'
|
55
|
+
description: Ruby wrapper for the Open Journal's Reviewers application's API
|
56
|
+
email:
|
57
|
+
- jjbazan@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".rspec"
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/ojra.rb
|
69
|
+
- lib/ojra/client.rb
|
70
|
+
- lib/ojra/version.rb
|
71
|
+
homepage: http://github.com/xuanxu/ojra
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata:
|
75
|
+
homepage_uri: http://github.com/xuanxu/ojra
|
76
|
+
source_code_uri: http://github.com/xuanxu/ojra
|
77
|
+
bug_tracker_uri: https://github.com/xuanxu/ojra/issues
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '3.0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubygems_version: 3.4.1
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Wrapper for the Open Journal's Reviewers API
|
97
|
+
test_files: []
|