theoj 0.0.3 → 1.2.0
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 +27 -0
- data/lib/theoj/author.rb +83 -5
- data/lib/theoj/git.rb +2 -2
- data/lib/theoj/journal.rb +17 -0
- data/lib/theoj/journals_data.rb +16 -4
- data/lib/theoj/orcid.rb +96 -0
- data/lib/theoj/paper.rb +70 -15
- data/lib/theoj/published_paper.rb +46 -0
- data/lib/theoj/review_issue.rb +1 -1
- data/lib/theoj/submission.rb +132 -0
- data/lib/theoj/version.rb +1 -1
- data/lib/theoj.rb +4 -0
- metadata +61 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9c9c517ea91deba2fcbca39a4098266b8b2adcf749de0c1803c0c36905d54d9
|
4
|
+
data.tar.gz: 1a4877b0a9e1bb9d58ceebf7a5bbca8cdaefcc2f35a7cbe2696570c828e6d96c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f6661c7163fedb8ba1248b2e1861c6a9f2c842ccfa2a4824fa42cd660ce7660c13b7097728c4078881748d3d69898a78f594717dffcfce08e6cb957e2c7a382
|
7
|
+
data.tar.gz: 2c812174f9bfd07155ada8ee909dca12a10398f05c042092d014b3401efecba59f9d9c3a2213fdd626a40b06d84156eadbe675e9877ce5950ec3c991b902d159
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.2.0 (2021-11-23)
|
4
|
+
|
5
|
+
- Added reviews_repository_url to Journal
|
6
|
+
- Added article_metadata to Submission
|
7
|
+
- Added editor and paper dates lookup information in Submission
|
8
|
+
- Fixed error reading reviewers list from issue body
|
9
|
+
|
10
|
+
## 1.1.1 (2021-11-05)
|
11
|
+
|
12
|
+
- Added support for test-journal
|
13
|
+
|
14
|
+
## 1.1.0 (2021-10-29)
|
15
|
+
|
16
|
+
- Added Theoj::PublishedPaper object with metadata from Journal's API
|
17
|
+
- Added custom Error class
|
18
|
+
|
19
|
+
## 1.0.0 (2021-10-20)
|
20
|
+
|
21
|
+
- Added method to Journal to create paper_id from issue_id
|
22
|
+
- Added method to Journal to get a DOI based on a paper id
|
23
|
+
- Added languages to Paper
|
24
|
+
- Added authors info to Paper
|
25
|
+
- Author object
|
26
|
+
- Added ORCID validation
|
27
|
+
- Added Submission object, grouping a paper, a review issue and a journal
|
28
|
+
- Added paper depositing
|
29
|
+
|
3
30
|
## 0.0.3 (2021-10-08)
|
4
31
|
|
5
32
|
- Added metadata methods to Paper
|
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
@@ -25,6 +25,23 @@ module Theoj
|
|
25
25
|
data[:current_issue] || (1 + ((Time.new.year * 12 + Time.new.month) - (launch_year * 12 + launch_month)))
|
26
26
|
end
|
27
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
|
+
|
37
|
+
def reviews_repository_url(issue_id=nil)
|
38
|
+
reviews_url = "https://github.com/#{data[:reviews_repository]}"
|
39
|
+
if issue_id
|
40
|
+
reviews_url += "/issues/" + issue_id.to_s
|
41
|
+
end
|
42
|
+
reviews_url
|
43
|
+
end
|
44
|
+
|
28
45
|
private
|
29
46
|
|
30
47
|
def set_data(custom_data)
|
data/lib/theoj/journals_data.rb
CHANGED
@@ -6,8 +6,9 @@ module Theoj
|
|
6
6
|
name: "Journal of Open Source Software",
|
7
7
|
alias: "joss",
|
8
8
|
launch_date: "2016-05-05",
|
9
|
-
|
10
|
-
reviews_repository: "openjournals/joss-reviews"
|
9
|
+
papers_repository: "openjournals/joss-papers",
|
10
|
+
reviews_repository: "openjournals/joss-reviews",
|
11
|
+
deposit_url: "https://joss.theoj.org/papers/api_deposit"
|
11
12
|
},
|
12
13
|
jose: {
|
13
14
|
doi_prefix: "10.21105",
|
@@ -15,8 +16,19 @@ module Theoj
|
|
15
16
|
name: "Journal of Open Source Education",
|
16
17
|
alias: "jose",
|
17
18
|
launch_date: "2018-03-07",
|
18
|
-
|
19
|
-
reviews_repository: "openjournals/jose-reviews"
|
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"
|
20
32
|
}
|
21
33
|
}
|
22
34
|
end
|
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,22 +21,18 @@ module Theoj
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def authors
|
22
|
-
|
24
|
+
@authors ||= parse_authors
|
23
25
|
end
|
24
26
|
|
25
|
-
def
|
26
|
-
|
27
|
+
def citation_author
|
28
|
+
surname = authors.first.last_name
|
29
|
+
initials = authors.first.initials
|
27
30
|
|
28
|
-
if
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
break
|
33
|
-
end
|
34
|
-
end
|
31
|
+
if authors.size > 1
|
32
|
+
return "#{surname} et al."
|
33
|
+
else
|
34
|
+
return "#{surname}, #{initials}"
|
35
35
|
end
|
36
|
-
|
37
|
-
paper_path
|
38
36
|
end
|
39
37
|
|
40
38
|
def title
|
@@ -49,6 +47,10 @@ module Theoj
|
|
49
47
|
@paper_metadata["date"]
|
50
48
|
end
|
51
49
|
|
50
|
+
def languages
|
51
|
+
@languages ||= detect_languages
|
52
|
+
end
|
53
|
+
|
52
54
|
def bibliography_path
|
53
55
|
@paper_metadata["bibliography"]
|
54
56
|
end
|
@@ -61,6 +63,21 @@ module Theoj
|
|
61
63
|
FileUtils.rm_rf(local_path) if Dir.exist?(local_path)
|
62
64
|
end
|
63
65
|
|
66
|
+
def self.find_paper_path(search_path)
|
67
|
+
paper_path = nil
|
68
|
+
|
69
|
+
if Dir.exist? search_path
|
70
|
+
Find.find(search_path).each do |path|
|
71
|
+
if path =~ /paper\.tex$|paper\.md$/
|
72
|
+
paper_path = path
|
73
|
+
break
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
paper_path
|
79
|
+
end
|
80
|
+
|
64
81
|
def self.from_repo(repository_url, branch = "")
|
65
82
|
Paper.new(repository_url, branch, nil)
|
66
83
|
end
|
@@ -95,9 +112,47 @@ module Theoj
|
|
95
112
|
end
|
96
113
|
end
|
97
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
|
+
|
98
153
|
def failure(msg)
|
99
154
|
cleanup
|
100
|
-
raise
|
155
|
+
raise Theoj::Error, msg
|
101
156
|
end
|
102
157
|
end
|
103
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.transform_keys(&:to_s).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
@@ -28,7 +28,7 @@ module Theoj
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def reviewers
|
31
|
-
@reviewers ||= read_value_from_body("reviewers").split(",").map{|r| r.strip} - ["Pending", "TBD"]
|
31
|
+
@reviewers ||= read_value_from_body("reviewers-list").split(",").map{|r| r.strip} - ["Pending", "TBD"]
|
32
32
|
end
|
33
33
|
|
34
34
|
def editor
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require "json"
|
2
|
+
require "base64"
|
3
|
+
require "faraday"
|
4
|
+
|
5
|
+
module Theoj
|
6
|
+
class Submission
|
7
|
+
include Theoj::GitHub
|
8
|
+
|
9
|
+
attr_accessor :journal
|
10
|
+
attr_accessor :review_issue
|
11
|
+
attr_accessor :paper
|
12
|
+
|
13
|
+
def initialize(journal, review_issue, paper=nil)
|
14
|
+
@journal = journal
|
15
|
+
@review_issue = review_issue
|
16
|
+
@paper = paper || @review_issue.paper
|
17
|
+
end
|
18
|
+
|
19
|
+
# Create the payload to use to post for depositing with Open Journals
|
20
|
+
def deposit_payload
|
21
|
+
{
|
22
|
+
id: review_issue.issue_id,
|
23
|
+
metadata: Base64.encode64(metadata_payload),
|
24
|
+
doi: paper_doi,
|
25
|
+
archive_doi: review_issue.archive,
|
26
|
+
citation_string: citation_string,
|
27
|
+
title: paper.title
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# Create a metadata json payload
|
32
|
+
def metadata_payload
|
33
|
+
metadata = {
|
34
|
+
paper: {
|
35
|
+
title: paper.title,
|
36
|
+
tags: paper.tags,
|
37
|
+
languages: paper.languages,
|
38
|
+
authors: paper.authors.collect { |a| a.to_h },
|
39
|
+
doi: paper_doi,
|
40
|
+
archive_doi: review_issue.archive,
|
41
|
+
repository_address: review_issue.target_repository,
|
42
|
+
editor: review_issue.editor,
|
43
|
+
reviewers: review_issue.reviewers.collect(&:strip),
|
44
|
+
volume: journal.current_volume,
|
45
|
+
issue: journal.current_issue,
|
46
|
+
year: journal.current_year,
|
47
|
+
page: review_issue.issue_id,
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
metadata.to_json
|
52
|
+
end
|
53
|
+
|
54
|
+
# Create metadata used to generate PDF/JATS outputs
|
55
|
+
def article_metadata
|
56
|
+
metadata = {
|
57
|
+
title: paper.title,
|
58
|
+
tags: paper.tags,
|
59
|
+
languages: paper.languages,
|
60
|
+
authors: paper.authors.collect { |a| a.to_h },
|
61
|
+
doi: paper_doi,
|
62
|
+
software_repository_url: review_issue.target_repository,
|
63
|
+
reviewers: review_issue.reviewers.collect(&:strip),
|
64
|
+
volume: journal.current_volume,
|
65
|
+
issue: journal.current_issue,
|
66
|
+
year: journal.current_year,
|
67
|
+
page: review_issue.issue_id,
|
68
|
+
journal_alias: journal.alias,
|
69
|
+
software_review_url: journal.reviews_repository_url(review_issue.issue_id),
|
70
|
+
archive_doi: review_issue.archive,
|
71
|
+
citation_string: citation_string
|
72
|
+
}
|
73
|
+
|
74
|
+
metadata.merge(editor_info, dates_info)
|
75
|
+
end
|
76
|
+
|
77
|
+
def editor_info
|
78
|
+
editor_info = { editor: {
|
79
|
+
github_user: review_issue.editor,
|
80
|
+
name: nil,
|
81
|
+
url: nil,
|
82
|
+
orcid: nil
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
if review_issue.editor
|
87
|
+
editor_lookup = Faraday.get(journal.url + "/editors/lookup/" + user_login(review_issue.editor))
|
88
|
+
if editor_lookup.status == 200
|
89
|
+
info = JSON.parse(editor_lookup.body, symbolize_names: true)
|
90
|
+
editor_info[:editor][:name] = info[:name]
|
91
|
+
editor_info[:editor][:url] = info[:url]
|
92
|
+
editor_info[:editor][:orcid] = info[:orcid]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
editor_info
|
97
|
+
end
|
98
|
+
|
99
|
+
def dates_info
|
100
|
+
dates_info = { submitted_at: nil, published_at: nil }
|
101
|
+
|
102
|
+
if review_issue.issue_id
|
103
|
+
paper_lookup = Faraday.get(journal.url + "/papers/lookup/" + review_issue.issue_id.to_s)
|
104
|
+
if paper_lookup.status == 200
|
105
|
+
info = JSON.parse(paper_lookup.body, symbolize_names: true)
|
106
|
+
dates_info[:submitted_at] = info[:submitted]
|
107
|
+
dates_info[:published_at] = info[:accepted]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
dates_info
|
112
|
+
end
|
113
|
+
|
114
|
+
def deposit!(secret)
|
115
|
+
parameters = deposit_payload.merge(secret: secret)
|
116
|
+
Faraday.post(journal.data[:deposit_url], parameters.to_json, {"Content-Type" => "application/json"})
|
117
|
+
end
|
118
|
+
|
119
|
+
def citation_string
|
120
|
+
paper_year = Time.now.strftime('%Y')
|
121
|
+
"#{paper.citation_author}, (#{paper_year}). #{paper.title}. #{journal.name}, #{journal.current_volume}(#{journal.current_issue}), #{review_issue.issue_id}, https://doi.org/#{paper_doi}"
|
122
|
+
end
|
123
|
+
|
124
|
+
def paper_id
|
125
|
+
journal.paper_id_from_issue(review_issue.issue_id)
|
126
|
+
end
|
127
|
+
|
128
|
+
def paper_doi
|
129
|
+
journal.paper_doi_for_id(paper_id)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
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.2.0
|
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-23 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
|
@@ -68,8 +124,11 @@ files:
|
|
68
124
|
- lib/theoj/github.rb
|
69
125
|
- lib/theoj/journal.rb
|
70
126
|
- lib/theoj/journals_data.rb
|
127
|
+
- lib/theoj/orcid.rb
|
71
128
|
- lib/theoj/paper.rb
|
129
|
+
- lib/theoj/published_paper.rb
|
72
130
|
- lib/theoj/review_issue.rb
|
131
|
+
- lib/theoj/submission.rb
|
73
132
|
- lib/theoj/version.rb
|
74
133
|
homepage: http://github.com/xuanxu/theoj
|
75
134
|
licenses:
|