theoj 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5653737d1c10e9d0ab340155ea60bc4dfd9740032450d4bab4fe028fbd65cd1
4
- data.tar.gz: b0a4b24d0906bfaf9d3416f561df03f5d080236891cf9fff4d462858b3cfd897
3
+ metadata.gz: e9c9c517ea91deba2fcbca39a4098266b8b2adcf749de0c1803c0c36905d54d9
4
+ data.tar.gz: 1a4877b0a9e1bb9d58ceebf7a5bbca8cdaefcc2f35a7cbe2696570c828e6d96c
5
5
  SHA512:
6
- metadata.gz: '00090ef1f10e4021b09983fa5542f8771515c392a12d4e95e976179d59ea73fac73fc2b65109b81b7f1ee0ffe98eed080e0c75b0e609b88a629e3a86fcb9a02c'
7
- data.tar.gz: 131043601a4dc77c11019e77e2c9fcd705b2f693108139a12964299f931d25ae5e31dda2c11f297c7b0ded9fd12b4bf6008e7e27fb61b94b247568fc0fbe7bdb
6
+ metadata.gz: 4f6661c7163fedb8ba1248b2e1861c6a9f2c842ccfa2a4824fa42cd660ce7660c13b7097728c4078881748d3d69898a78f594717dffcfce08e6cb957e2c7a382
7
+ data.tar.gz: 2c812174f9bfd07155ada8ee909dca12a10398f05c042092d014b3401efecba59f9d9c3a2213fdd626a40b06d84156eadbe675e9877ce5950ec3c991b902d159
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
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
+
3
10
  ## 1.1.1 (2021-11-05)
4
11
 
5
12
  - Added support for test-journal
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
@@ -4,6 +4,8 @@ require "faraday"
4
4
 
5
5
  module Theoj
6
6
  class Submission
7
+ include Theoj::GitHub
8
+
7
9
  attr_accessor :journal
8
10
  attr_accessor :review_issue
9
11
  attr_accessor :paper
@@ -49,6 +51,66 @@ module Theoj
49
51
  metadata.to_json
50
52
  end
51
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
+
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"})
data/lib/theoj/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Theoj
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.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.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-05 00:00:00.000000000 Z
11
+ date: 2021-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit