theoj 1.1.1 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5653737d1c10e9d0ab340155ea60bc4dfd9740032450d4bab4fe028fbd65cd1
4
- data.tar.gz: b0a4b24d0906bfaf9d3416f561df03f5d080236891cf9fff4d462858b3cfd897
3
+ metadata.gz: fe52209e20cb13390a2b85343485fc01a6251c7e98ceafc3eef6c9eed5aa4aa2
4
+ data.tar.gz: 2730c6f27f95b3c5175219241c415d8502e5f0631609cc5f2bd5a70f189f0838
5
5
  SHA512:
6
- metadata.gz: '00090ef1f10e4021b09983fa5542f8771515c392a12d4e95e976179d59ea73fac73fc2b65109b81b7f1ee0ffe98eed080e0c75b0e609b88a629e3a86fcb9a02c'
7
- data.tar.gz: 131043601a4dc77c11019e77e2c9fcd705b2f693108139a12964299f931d25ae5e31dda2c11f297c7b0ded9fd12b4bf6008e7e27fb61b94b247568fc0fbe7bdb
6
+ metadata.gz: b5979b4c89efbf24baa9a4ab03edb8d9f3d988ebedc75d262f573c4b64a55b37418211b8f162246aa8155859470e4d058fe08bbcddde417a7b3a9baa93542d8c
7
+ data.tar.gz: 2212d66e3d45784799c99681a01e75b45d1bae74152a04342abf499103082e4d13f142a51d006a92ac6a5388bbd184dec6de46eb801ba27f8a256f52d2a681f6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0 (2022-03-02)
4
+
5
+ - Change branches using git-switch instead of git-checkout to remove ambiguaties. Requires Git >= 2.23
6
+
7
+ ## 1.2.1 (2021-11-30)
8
+
9
+ - Changed metadata dates format to ISO
10
+ - Changed editor and reviewers metadata values to github login
11
+ - Removed languages from article metadata
12
+
13
+ ## 1.2.0 (2021-11-23)
14
+
15
+ - Added reviews_repository_url to Journal
16
+ - Added article_metadata to Submission
17
+ - Added editor and paper dates lookup information in Submission
18
+ - Fixed error reading reviewers list from issue body
19
+
3
20
  ## 1.1.1 (2021-11-05)
4
21
 
5
22
  - Added support for test-journal
data/lib/theoj/git.rb CHANGED
@@ -14,7 +14,7 @@ module Theoj
14
14
 
15
15
  def change_branch(branch, local_path)
16
16
  return true if (branch.nil? || branch.strip.empty?)
17
- stdout, stderr, status = Open3.capture3 "git -C #{local_path} checkout #{branch}"
17
+ stdout, stderr, status = Open3.capture3 "git -C #{local_path} switch #{branch}"
18
18
  status.success?
19
19
  end
20
20
  end
data/lib/theoj/github.rb CHANGED
@@ -52,7 +52,7 @@ module Theoj
52
52
 
53
53
  # Returns the user login (removes the @ from the username)
54
54
  def user_login(username)
55
- username.strip.sub(/^@/, "").downcase
55
+ username.to_s.strip.sub(/^@/, "").downcase
56
56
  end
57
57
 
58
58
  # Returns true if the string is a valid GitHub isername (starts with @)
data/lib/theoj/journal.rb CHANGED
@@ -34,6 +34,14 @@ module Theoj
34
34
  "#@doi_prefix/#{paper_id}"
35
35
  end
36
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
+
37
45
  private
38
46
 
39
47
  def set_data(custom_data)
@@ -35,7 +35,7 @@ module Theoj
35
35
  end
36
36
 
37
37
  def yaml_metadata
38
- metadata.to_yaml
38
+ metadata.transform_keys(&:to_s).to_yaml
39
39
  end
40
40
 
41
41
  def json_metadata
@@ -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
@@ -1,9 +1,12 @@
1
1
  require "json"
2
+ require "date"
2
3
  require "base64"
3
4
  require "faraday"
4
5
 
5
6
  module Theoj
6
7
  class Submission
8
+ include Theoj::GitHub
9
+
7
10
  attr_accessor :journal
8
11
  attr_accessor :review_issue
9
12
  attr_accessor :paper
@@ -49,6 +52,65 @@ module Theoj
49
52
  metadata.to_json
50
53
  end
51
54
 
55
+ # Create metadata used to generate PDF/JATS outputs
56
+ def article_metadata
57
+ metadata = {
58
+ title: paper.title,
59
+ tags: paper.tags,
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{|r| user_login(r)},
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: user_login(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] = format_date(info[:submitted]) if info[:submitted]
107
+ dates_info[:published_at] = format_date(info[:accepted]) if info[:accepted]
108
+ end
109
+ end
110
+
111
+ dates_info
112
+ end
113
+
52
114
  def deposit!(secret)
53
115
  parameters = deposit_payload.merge(secret: secret)
54
116
  Faraday.post(journal.data[:deposit_url], parameters.to_json, {"Content-Type" => "application/json"})
@@ -66,5 +128,12 @@ module Theoj
66
128
  def paper_doi
67
129
  journal.paper_doi_for_id(paper_id)
68
130
  end
131
+
132
+ private
133
+ def format_date(date_string)
134
+ Date.parse(date_string.to_s).strftime("%Y-%m-%d")
135
+ rescue Date::Error
136
+ nil
137
+ end
69
138
  end
70
139
  end
data/lib/theoj/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Theoj
2
- VERSION = "1.1.1"
2
+ VERSION = "1.3.0"
3
3
  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: 1.1.1
4
+ version: 1.3.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-05 00:00:00.000000000 Z
11
+ date: 2022-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit