theoj 0.0.2 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -2
- data/lib/theoj/author.rb +83 -5
- data/lib/theoj/git.rb +2 -2
- data/lib/theoj/journal.rb +12 -7
- data/lib/theoj/journals_data.rb +35 -0
- data/lib/theoj/orcid.rb +96 -0
- data/lib/theoj/paper.rb +83 -12
- data/lib/theoj/published_paper.rb +46 -0
- data/lib/theoj/review_issue.rb +23 -1
- data/lib/theoj/submission.rb +70 -0
- data/lib/theoj/version.rb +1 -1
- data/lib/theoj.rb +4 -0
- metadata +63 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5653737d1c10e9d0ab340155ea60bc4dfd9740032450d4bab4fe028fbd65cd1
|
4
|
+
data.tar.gz: b0a4b24d0906bfaf9d3416f561df03f5d080236891cf9fff4d462858b3cfd897
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '00090ef1f10e4021b09983fa5542f8771515c392a12d4e95e976179d59ea73fac73fc2b65109b81b7f1ee0ffe98eed080e0c75b0e609b88a629e3a86fcb9a02c'
|
7
|
+
data.tar.gz: 131043601a4dc77c11019e77e2c9fcd705b2f693108139a12964299f931d25ae5e31dda2c11f297c7b0ded9fd12b4bf6008e7e27fb61b94b247568fc0fbe7bdb
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,40 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
##
|
3
|
+
## 1.1.1 (2021-11-05)
|
4
|
+
|
5
|
+
- Added support for test-journal
|
6
|
+
|
7
|
+
## 1.1.0 (2021-10-29)
|
8
|
+
|
9
|
+
- Added Theoj::PublishedPaper object with metadata from Journal's API
|
10
|
+
- Added custom Error class
|
11
|
+
|
12
|
+
## 1.0.0 (2021-10-20)
|
13
|
+
|
14
|
+
- Added method to Journal to create paper_id from issue_id
|
15
|
+
- Added method to Journal to get a DOI based on a paper id
|
16
|
+
- Added languages to Paper
|
17
|
+
- Added authors info to Paper
|
18
|
+
- Author object
|
19
|
+
- Added ORCID validation
|
20
|
+
- Added Submission object, grouping a paper, a review issue and a journal
|
21
|
+
- Added paper depositing
|
22
|
+
|
23
|
+
## 0.0.3 (2021-10-08)
|
24
|
+
|
25
|
+
- Added metadata methods to Paper
|
26
|
+
- Added to ReviewIssue: editor, reviewers, archive, version
|
27
|
+
- New method to read any value from review's issue body
|
28
|
+
- Values read from issue boy will be empty if Pending or TBD
|
29
|
+
- Added journal config data for OpenJournals: JOSS and JOSE
|
4
30
|
|
5
|
-
- Gem created
|
6
31
|
|
7
32
|
## 0.0.2 (2021-09-22)
|
8
33
|
|
9
34
|
- Available objects: Theoj::Journal, Theoj::ReviewIssue and Theoj::Paper
|
35
|
+
|
36
|
+
|
37
|
+
## 0.0.1 (2021-09-22)
|
38
|
+
|
39
|
+
- Gem created
|
40
|
+
|
data/lib/theoj/author.rb
CHANGED
@@ -1,16 +1,94 @@
|
|
1
|
+
require "nameable"
|
2
|
+
|
1
3
|
module Theoj
|
2
4
|
class Author
|
3
5
|
attr_accessor :name
|
4
6
|
attr_accessor :orcid
|
5
7
|
attr_accessor :affiliation
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
AUTHOR_FOOTNOTE_REGEX = /^[^\^]*/
|
10
|
+
|
11
|
+
# Initialized with authors & affiliations block in the YAML header from an Open Journal paper
|
12
|
+
# e.g. https://joss.readthedocs.io/en/latest/submitting.html#example-paper-and-bibliography
|
13
|
+
def initialize(name, orcid, index, affiliations_hash)
|
14
|
+
parse_name name
|
15
|
+
@orcid = validate_orcid orcid
|
16
|
+
@affiliation = build_affiliation_string(index, affiliations_hash)
|
17
|
+
end
|
18
|
+
|
19
|
+
def given_name
|
20
|
+
@parsed_name.first
|
21
|
+
end
|
22
|
+
|
23
|
+
def middle_name
|
24
|
+
@parsed_name.middle
|
25
|
+
end
|
26
|
+
|
27
|
+
def last_name
|
28
|
+
@parsed_name.last
|
29
|
+
end
|
30
|
+
|
31
|
+
def initials
|
32
|
+
[@parsed_name.first, @parsed_name.middle].compact.map {|v| v[0] + "."} * ' '
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_h
|
36
|
+
{
|
37
|
+
given_name: given_name,
|
38
|
+
middle_name: middle_name,
|
39
|
+
last_name: last_name,
|
40
|
+
orcid: orcid,
|
41
|
+
affiliation: affiliation
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def parse_name(author_name)
|
48
|
+
@parsed_name = Nameable::Latin.new.parse(strip_footnotes(author_name))
|
49
|
+
@name = @parsed_name.to_nameable
|
50
|
+
end
|
51
|
+
|
52
|
+
# Input: Arfon Smith^[Corresponding author: arfon@example.com]
|
53
|
+
# Output: Arfon Smith
|
54
|
+
def strip_footnotes(author_name)
|
55
|
+
author_name.to_s[AUTHOR_FOOTNOTE_REGEX]
|
56
|
+
end
|
57
|
+
|
58
|
+
def validate_orcid(author_orcid)
|
59
|
+
return nil if author_orcid.to_s.strip.empty?
|
60
|
+
|
61
|
+
validator = Theoj::Orcid.new(author_orcid)
|
62
|
+
if validator.valid?
|
63
|
+
return author_orcid.strip
|
64
|
+
else
|
65
|
+
raise Theoj::Error, "Problem with ORCID (#{author_orcid}) for #{self.name}. #{validator.error}"
|
66
|
+
end
|
11
67
|
end
|
12
68
|
|
13
|
-
|
69
|
+
# Takes the author affiliation index and a hash of all affiliations and
|
70
|
+
# associates them. Then builds the author affiliation string
|
71
|
+
def build_affiliation_string(index, affiliations_hash)
|
72
|
+
return nil if index.nil? # Some authors don't have an affiliation
|
73
|
+
|
74
|
+
# If multiple affiliations, parse each one and build the affiliation string
|
75
|
+
author_affiliations = []
|
76
|
+
|
77
|
+
# Turn YAML keys into strings so that mixed integer and string affiliations work
|
78
|
+
affiliations_hash.transform_keys!(&:to_s)
|
79
|
+
|
80
|
+
affiliations = index.to_s.split(',').map(&:strip)
|
81
|
+
|
82
|
+
# Raise if we can't parse the string, might be because of this bug :-(
|
83
|
+
# https://bugs.ruby-lang.org/issues/12451
|
84
|
+
affiliations.each do |a|
|
85
|
+
raise Theoj::Error, "Problem with affiliations for #{self.name}, perhaps the " +
|
86
|
+
"affiliations index need quoting?" unless affiliations_hash.has_key?(a)
|
87
|
+
|
88
|
+
author_affiliations << affiliations_hash[a].strip
|
89
|
+
end
|
90
|
+
|
91
|
+
author_affiliations.join(', ')
|
14
92
|
end
|
15
93
|
|
16
94
|
end
|
data/lib/theoj/git.rb
CHANGED
data/lib/theoj/journal.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "journals_data"
|
2
|
+
|
1
3
|
module Theoj
|
2
4
|
class Journal
|
3
5
|
attr_accessor :data
|
@@ -23,6 +25,15 @@ module Theoj
|
|
23
25
|
data[:current_issue] || (1 + ((Time.new.year * 12 + Time.new.month) - (launch_year * 12 + launch_month)))
|
24
26
|
end
|
25
27
|
|
28
|
+
def paper_id_from_issue(review_issue_id)
|
29
|
+
id = "%05d" % review_issue_id
|
30
|
+
"#{@alias}.#{id}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def paper_doi_for_id(paper_id)
|
34
|
+
"#@doi_prefix/#{paper_id}"
|
35
|
+
end
|
36
|
+
|
26
37
|
private
|
27
38
|
|
28
39
|
def set_data(custom_data)
|
@@ -35,13 +46,7 @@ module Theoj
|
|
35
46
|
end
|
36
47
|
|
37
48
|
def default_data
|
38
|
-
|
39
|
-
doi_prefix: "10.21105",
|
40
|
-
url: "http://joss.theoj.org",
|
41
|
-
name: "Journal of Open Source Software",
|
42
|
-
alias: "joss",
|
43
|
-
launch_date: "2016-05-05",
|
44
|
-
}
|
49
|
+
Theoj::JOURNALS_DATA[:joss]
|
45
50
|
end
|
46
51
|
|
47
52
|
def parsed_launch_date
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Theoj
|
2
|
+
JOURNALS_DATA = {
|
3
|
+
joss: {
|
4
|
+
doi_prefix: "10.21105",
|
5
|
+
url: "https://joss.theoj.org",
|
6
|
+
name: "Journal of Open Source Software",
|
7
|
+
alias: "joss",
|
8
|
+
launch_date: "2016-05-05",
|
9
|
+
papers_repository: "openjournals/joss-papers",
|
10
|
+
reviews_repository: "openjournals/joss-reviews",
|
11
|
+
deposit_url: "https://joss.theoj.org/papers/api_deposit"
|
12
|
+
},
|
13
|
+
jose: {
|
14
|
+
doi_prefix: "10.21105",
|
15
|
+
url: "https://jose.theoj.org",
|
16
|
+
name: "Journal of Open Source Education",
|
17
|
+
alias: "jose",
|
18
|
+
launch_date: "2018-03-07",
|
19
|
+
papers_repository: "openjournals/jose-papers",
|
20
|
+
reviews_repository: "openjournals/jose-reviews",
|
21
|
+
deposit_url: "https://joss.theoj.org/papers/api_deposit"
|
22
|
+
},
|
23
|
+
test_journal: {
|
24
|
+
doi_prefix: "10.21105",
|
25
|
+
url: "https://test.joss.theoj.org/",
|
26
|
+
name: "Test Journal",
|
27
|
+
alias: "test_journal",
|
28
|
+
launch_date: "2016-05-05",
|
29
|
+
papers_repository: "openjournals/joss-papers-testing",
|
30
|
+
reviews_repository: "openjournals/joss-reviews-testing",
|
31
|
+
deposit_url: "https://test.joss.theoj.org/papers/api_deposit"
|
32
|
+
}
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
data/lib/theoj/orcid.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
module Theoj
|
2
|
+
class Orcid
|
3
|
+
attr_reader :orcid, :error
|
4
|
+
|
5
|
+
def initialize(orcid)
|
6
|
+
@orcid = orcid.strip
|
7
|
+
@error = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def valid?
|
11
|
+
@error = nil
|
12
|
+
return false unless check_structure
|
13
|
+
return false unless check_length
|
14
|
+
return false unless check_chars
|
15
|
+
|
16
|
+
return false unless correct_checksum?
|
17
|
+
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def packed_orcid
|
22
|
+
orcid.gsub('-', '')
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Returns the last character of the string
|
28
|
+
def checksum_char
|
29
|
+
packed_orcid[-1]
|
30
|
+
end
|
31
|
+
|
32
|
+
def first_11
|
33
|
+
packed_orcid.chop
|
34
|
+
end
|
35
|
+
|
36
|
+
def check_structure
|
37
|
+
groups = orcid.split('-')
|
38
|
+
if groups.size == 4
|
39
|
+
return true
|
40
|
+
else
|
41
|
+
@error = "ORCID looks malformed"
|
42
|
+
return false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def check_length
|
47
|
+
if packed_orcid.length == 16
|
48
|
+
return true
|
49
|
+
else
|
50
|
+
@error = "ORCID looks to be the wrong length"
|
51
|
+
return false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def check_chars
|
56
|
+
valid = true
|
57
|
+
first_11.each_char do |c|
|
58
|
+
if !numeric?(c)
|
59
|
+
@error = "Invalid ORCID digit (#{c})"
|
60
|
+
valid = false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
return valid
|
65
|
+
end
|
66
|
+
|
67
|
+
def correct_checksum?
|
68
|
+
validate_against = checksum_char.to_i
|
69
|
+
validate_against = 10 if (checksum_char == "X" || checksum_char == "x")
|
70
|
+
|
71
|
+
if checksum == validate_against
|
72
|
+
return true
|
73
|
+
else
|
74
|
+
@error = "Invalid ORCID"
|
75
|
+
return false
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# https://support.orcid.org/knowledgebase/articles/116780-structure-of-the-orcid-identifier
|
80
|
+
def checksum
|
81
|
+
total = 0
|
82
|
+
first_11.each_char do |c|
|
83
|
+
total = (total + c.to_i) * 2
|
84
|
+
end
|
85
|
+
|
86
|
+
remainder = total % 11
|
87
|
+
result = (12 - remainder) % 11
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
def numeric?(s)
|
92
|
+
Float(s) != nil rescue false
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
data/lib/theoj/paper.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "find"
|
2
|
+
require "yaml"
|
3
|
+
require "rugged"
|
4
|
+
require "linguist"
|
3
5
|
|
4
6
|
module Theoj
|
5
7
|
class Paper
|
@@ -19,7 +21,46 @@ module Theoj
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def authors
|
22
|
-
|
24
|
+
@authors ||= parse_authors
|
25
|
+
end
|
26
|
+
|
27
|
+
def citation_author
|
28
|
+
surname = authors.first.last_name
|
29
|
+
initials = authors.first.initials
|
30
|
+
|
31
|
+
if authors.size > 1
|
32
|
+
return "#{surname} et al."
|
33
|
+
else
|
34
|
+
return "#{surname}, #{initials}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def title
|
39
|
+
@paper_metadata["title"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def tags
|
43
|
+
@paper_metadata["tags"]
|
44
|
+
end
|
45
|
+
|
46
|
+
def date
|
47
|
+
@paper_metadata["date"]
|
48
|
+
end
|
49
|
+
|
50
|
+
def languages
|
51
|
+
@languages ||= detect_languages
|
52
|
+
end
|
53
|
+
|
54
|
+
def bibliography_path
|
55
|
+
@paper_metadata["bibliography"]
|
56
|
+
end
|
57
|
+
|
58
|
+
def local_path
|
59
|
+
@local_path ||= "tmp/#{SecureRandom.hex}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def cleanup
|
63
|
+
FileUtils.rm_rf(local_path) if Dir.exist?(local_path)
|
23
64
|
end
|
24
65
|
|
25
66
|
def self.find_paper_path(search_path)
|
@@ -41,14 +82,6 @@ module Theoj
|
|
41
82
|
Paper.new(repository_url, branch, nil)
|
42
83
|
end
|
43
84
|
|
44
|
-
def cleanup
|
45
|
-
FileUtils.rm_rf(local_path) if Dir.exist?(local_path)
|
46
|
-
end
|
47
|
-
|
48
|
-
def local_path
|
49
|
-
@local_path ||= "tmp/#{SecureRandom.hex}"
|
50
|
-
end
|
51
|
-
|
52
85
|
private
|
53
86
|
|
54
87
|
def find_paper(path)
|
@@ -79,9 +112,47 @@ module Theoj
|
|
79
112
|
end
|
80
113
|
end
|
81
114
|
|
115
|
+
def parse_authors
|
116
|
+
parsed_authors = []
|
117
|
+
authors_metadata = @paper_metadata['authors']
|
118
|
+
affiliations_metadata = parse_affiliations(@paper_metadata['affiliations'])
|
119
|
+
|
120
|
+
# Loop through the authors block and build up the affiliation
|
121
|
+
authors_metadata.each do |author|
|
122
|
+
affiliation_index = author['affiliation']
|
123
|
+
failure "Author (#{author['name']}) is missing affiliation" if affiliation_index.nil?
|
124
|
+
begin
|
125
|
+
parsed_author = Author.new(author['name'], author['orcid'], affiliation_index, affiliations_metadata)
|
126
|
+
rescue Exception => e
|
127
|
+
failure(e.message)
|
128
|
+
end
|
129
|
+
parsed_authors << parsed_author
|
130
|
+
end
|
131
|
+
|
132
|
+
parsed_authors
|
133
|
+
end
|
134
|
+
|
135
|
+
def parse_affiliations(affliations_yaml)
|
136
|
+
affliations_metadata = {}
|
137
|
+
|
138
|
+
affliations_yaml.each do |affiliation|
|
139
|
+
affliations_metadata[affiliation['index']] = affiliation['name']
|
140
|
+
end
|
141
|
+
|
142
|
+
affliations_metadata
|
143
|
+
end
|
144
|
+
|
145
|
+
def detect_languages
|
146
|
+
repo = Rugged::Repository.discover(paper_path)
|
147
|
+
project = Linguist::Repository.new(repo, repo.head.target_id)
|
148
|
+
|
149
|
+
# Take top five languages from Linguist
|
150
|
+
project.languages.keys.take(5)
|
151
|
+
end
|
152
|
+
|
82
153
|
def failure(msg)
|
83
154
|
cleanup
|
84
|
-
raise
|
155
|
+
raise Theoj::Error, msg
|
85
156
|
end
|
86
157
|
end
|
87
158
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "yaml"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Theoj
|
6
|
+
class PublishedPaper
|
7
|
+
include Theoj::Git
|
8
|
+
|
9
|
+
attr_accessor :metadata
|
10
|
+
|
11
|
+
def initialize(doi)
|
12
|
+
doi_url = "https://doi.org/#{doi}"
|
13
|
+
doi_response = Faraday.get(doi_url)
|
14
|
+
if doi_response.status == 302
|
15
|
+
paper_url = doi_response.headers[:location]
|
16
|
+
else
|
17
|
+
raise Theoj::Error, "The DOI is invalid, url does not resolve #{doi_url}"
|
18
|
+
end
|
19
|
+
|
20
|
+
paper_data = Faraday.get(paper_url + ".json")
|
21
|
+
if paper_data.status == 200
|
22
|
+
@metadata = JSON.parse(paper_data.body, symbolize_names: true)
|
23
|
+
else
|
24
|
+
raise Theoj::Error, "Could not find the paper data at #{paper_url + ".json"}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
[:title, :state, :submitted_at, :doi, :published_at,
|
29
|
+
:volume, :issue, :year, :page, :authors, :editor,
|
30
|
+
:editor_name, :editor_url, :editor_orcid, :reviewers,
|
31
|
+
:languages, :tags, :software_repository, :paper_review,
|
32
|
+
:pdf_url, :software_archive].each do |method_name|
|
33
|
+
define_method(method_name) { metadata[method_name] }
|
34
|
+
define_method("#{method_name}=") {|value| @metadata[method_name] = value }
|
35
|
+
end
|
36
|
+
|
37
|
+
def yaml_metadata
|
38
|
+
metadata.to_yaml
|
39
|
+
end
|
40
|
+
|
41
|
+
def json_metadata
|
42
|
+
metadata.to_json
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
data/lib/theoj/review_issue.rb
CHANGED
@@ -16,7 +16,7 @@ module Theoj
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def issue_body
|
19
|
-
issue(repository, issue_id).body
|
19
|
+
@issue_body ||= issue(repository, issue_id).body
|
20
20
|
end
|
21
21
|
|
22
22
|
def paper
|
@@ -27,10 +27,30 @@ module Theoj
|
|
27
27
|
@target_repository ||= read_value_from_body("target-repository")
|
28
28
|
end
|
29
29
|
|
30
|
+
def reviewers
|
31
|
+
@reviewers ||= read_value_from_body("reviewers").split(",").map{|r| r.strip} - ["Pending", "TBD"]
|
32
|
+
end
|
33
|
+
|
34
|
+
def editor
|
35
|
+
@editor ||= read_value_from_body("editor")
|
36
|
+
end
|
37
|
+
|
38
|
+
def archive
|
39
|
+
@archive ||= read_value_from_body("archive")
|
40
|
+
end
|
41
|
+
|
42
|
+
def version
|
43
|
+
@version ||= read_value_from_body("version")
|
44
|
+
end
|
45
|
+
|
30
46
|
def paper_branch
|
31
47
|
@paper_branch ||= read_value_from_body("branch")
|
32
48
|
end
|
33
49
|
|
50
|
+
def value_for(value_name)
|
51
|
+
read_value_from_body(value_name)
|
52
|
+
end
|
53
|
+
|
34
54
|
private
|
35
55
|
|
36
56
|
def read_from_body(start_mark, end_mark)
|
@@ -38,6 +58,8 @@ module Theoj
|
|
38
58
|
issue_body.match(/#{start_mark}(.*)#{end_mark}/im) do |m|
|
39
59
|
text = m[1]
|
40
60
|
end
|
61
|
+
|
62
|
+
text = "" if ["Pending", "TBD"].include?(text.strip)
|
41
63
|
text.strip
|
42
64
|
end
|
43
65
|
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "json"
|
2
|
+
require "base64"
|
3
|
+
require "faraday"
|
4
|
+
|
5
|
+
module Theoj
|
6
|
+
class Submission
|
7
|
+
attr_accessor :journal
|
8
|
+
attr_accessor :review_issue
|
9
|
+
attr_accessor :paper
|
10
|
+
|
11
|
+
def initialize(journal, review_issue, paper=nil)
|
12
|
+
@journal = journal
|
13
|
+
@review_issue = review_issue
|
14
|
+
@paper = paper || @review_issue.paper
|
15
|
+
end
|
16
|
+
|
17
|
+
# Create the payload to use to post for depositing with Open Journals
|
18
|
+
def deposit_payload
|
19
|
+
{
|
20
|
+
id: review_issue.issue_id,
|
21
|
+
metadata: Base64.encode64(metadata_payload),
|
22
|
+
doi: paper_doi,
|
23
|
+
archive_doi: review_issue.archive,
|
24
|
+
citation_string: citation_string,
|
25
|
+
title: paper.title
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Create a metadata json payload
|
30
|
+
def metadata_payload
|
31
|
+
metadata = {
|
32
|
+
paper: {
|
33
|
+
title: paper.title,
|
34
|
+
tags: paper.tags,
|
35
|
+
languages: paper.languages,
|
36
|
+
authors: paper.authors.collect { |a| a.to_h },
|
37
|
+
doi: paper_doi,
|
38
|
+
archive_doi: review_issue.archive,
|
39
|
+
repository_address: review_issue.target_repository,
|
40
|
+
editor: review_issue.editor,
|
41
|
+
reviewers: review_issue.reviewers.collect(&:strip),
|
42
|
+
volume: journal.current_volume,
|
43
|
+
issue: journal.current_issue,
|
44
|
+
year: journal.current_year,
|
45
|
+
page: review_issue.issue_id,
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
metadata.to_json
|
50
|
+
end
|
51
|
+
|
52
|
+
def deposit!(secret)
|
53
|
+
parameters = deposit_payload.merge(secret: secret)
|
54
|
+
Faraday.post(journal.data[:deposit_url], parameters.to_json, {"Content-Type" => "application/json"})
|
55
|
+
end
|
56
|
+
|
57
|
+
def citation_string
|
58
|
+
paper_year = Time.now.strftime('%Y')
|
59
|
+
"#{paper.citation_author}, (#{paper_year}). #{paper.title}. #{journal.name}, #{journal.current_volume}(#{journal.current_issue}), #{review_issue.issue_id}, https://doi.org/#{paper_doi}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def paper_id
|
63
|
+
journal.paper_id_from_issue(review_issue.issue_id)
|
64
|
+
end
|
65
|
+
|
66
|
+
def paper_doi
|
67
|
+
journal.paper_doi_for_id(paper_id)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/theoj/version.rb
CHANGED
data/lib/theoj.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
require_relative "theoj/version"
|
2
2
|
require_relative "theoj/git"
|
3
3
|
require_relative "theoj/github"
|
4
|
+
require_relative "theoj/orcid"
|
5
|
+
require_relative "theoj/published_paper"
|
6
|
+
require_relative "theoj/submission"
|
4
7
|
require_relative "theoj/journal"
|
5
8
|
require_relative "theoj/review_issue"
|
6
9
|
require_relative "theoj/paper"
|
7
10
|
require_relative "theoj/author"
|
8
11
|
|
9
12
|
module Theoj
|
13
|
+
class Error < StandardError; end
|
10
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: theoj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juanjo Bazán
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -24,6 +24,62 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.21'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: openjournals-nameable
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: github-linguist
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rugged
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
27
83
|
- !ruby/object:Gem::Dependency
|
28
84
|
name: rake
|
29
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,15 +123,19 @@ files:
|
|
67
123
|
- lib/theoj/git.rb
|
68
124
|
- lib/theoj/github.rb
|
69
125
|
- lib/theoj/journal.rb
|
126
|
+
- lib/theoj/journals_data.rb
|
127
|
+
- lib/theoj/orcid.rb
|
70
128
|
- lib/theoj/paper.rb
|
129
|
+
- lib/theoj/published_paper.rb
|
71
130
|
- lib/theoj/review_issue.rb
|
131
|
+
- lib/theoj/submission.rb
|
72
132
|
- lib/theoj/version.rb
|
73
133
|
homepage: http://github.com/xuanxu/theoj
|
74
134
|
licenses:
|
75
135
|
- MIT
|
76
136
|
metadata:
|
77
137
|
bug_tracker_uri: https://github.com/xuanxu/theoj/issues
|
78
|
-
changelog_uri: https://github.com/xuanxu/theoj/blob/
|
138
|
+
changelog_uri: https://github.com/xuanxu/theoj/blob/main/CHANGELOG.md
|
79
139
|
documentation_uri: https://www.rubydoc.info/gems/theoj
|
80
140
|
homepage_uri: http://github.com/xuanxu/theoj
|
81
141
|
source_code_uri: http://github.com/xuanxu/theoj
|