theoj 1.3.6 → 1.4.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: c515c77887a35b68e134958d1fc4e3b5c7f3fe0f49857ce6588840b78c066082
4
- data.tar.gz: 9ff11bb419fde2feea92704ad61435f74fa7353e5a69ab042fd6b1a43c18da91
3
+ metadata.gz: 8e40a25606ae1f2aaadf5e1459e1d9711b4c2650faa57cea6132a35d5c20cb8a
4
+ data.tar.gz: f84ded3ac7b898a5fe25cd469d6c559ad6aa57a38c293fc948cfa01604c0de89
5
5
  SHA512:
6
- metadata.gz: 9a6436cde4cf744a217527d0000d7ef222735d769db36539874f9c98ddef6c8f4e16b57bcc7b69a6a380e1557d46faf9a96c71f6a7006bd904e6e47d4f968a08
7
- data.tar.gz: 12b3e3893b21fa461b40fabcea661be6b43965fa92b6d02f8554f2dc079d6b209e924d34935ddbb8451590812c5fb62a84891e6f599844c40fbb43d8c6b5e2a4
6
+ metadata.gz: 140741757c989ae514fad023fffd967b5f7ad90a7c94b800aa9c8aa7aeb9af9eccfdf4ce111fa35f2f916e83a1baff945e87a49c74f226fd76eb5739535a58ed
7
+ data.tar.gz: e8ab0f0e2dbd6da6a81ef08b824cb7accaaa8dd9e9b378dbd72671528a774deb5f72c48465412c2d74ad1367ed680f21da852280f56dd991996692ae6b66b738
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.0 (2022-08-01)
4
+
5
+ - Added method to Journal to get year/volume/issue information for any date
6
+ - Submission metadata now takes into account published paper status
7
+
3
8
  ## 1.3.6 (2022-07-11)
4
9
 
5
10
  - Improve parsing os author names
data/lib/theoj/journal.rb CHANGED
@@ -42,6 +42,15 @@ module Theoj
42
42
  reviews_url
43
43
  end
44
44
 
45
+ def year_volume_issue_for_date(d)
46
+ d = Date.parse(d) if d.is_a? String
47
+ year = d.year
48
+ volume = year - (launch_year - 1)
49
+ issue = (1 + ((year * 12 + d.month) - (launch_year * 12 + launch_month)))
50
+
51
+ [year, volume, issue]
52
+ end
53
+
45
54
  private
46
55
 
47
56
  def set_data(custom_data)
@@ -1,3 +1,5 @@
1
+ require "date"
2
+
1
3
  module Theoj
2
4
  JOURNALS_DATA = {
3
5
  joss: {
@@ -20,58 +20,105 @@ module Theoj
20
20
  # Create the payload to use to post for depositing with Open Journals
21
21
  def deposit_payload
22
22
  {
23
- id: review_issue.issue_id,
23
+ id: metadata_info[:review_issue_id],
24
24
  metadata: Base64.encode64(metadata_payload),
25
- doi: paper_doi,
26
- archive_doi: review_issue.archive,
25
+ doi: metadata_info[:doi],
26
+ archive_doi: metadata_info[:archive_doi],
27
27
  citation_string: citation_string,
28
- title: paper.title
28
+ title: metadata_info[:title]
29
29
  }
30
30
  end
31
31
 
32
32
  # Create a metadata json payload
33
33
  def metadata_payload
34
- metadata = {
34
+ {
35
35
  paper: {
36
- title: paper.title,
37
- tags: paper.tags,
38
- languages: paper.languages,
39
- authors: paper.authors.collect { |a| a.to_h },
40
- doi: paper_doi,
41
- archive_doi: review_issue.archive,
42
- repository_address: review_issue.target_repository,
43
- editor: review_issue.editor,
44
- reviewers: review_issue.reviewers.collect(&:strip),
45
- volume: journal.current_volume,
46
- issue: journal.current_issue,
47
- year: journal.current_year,
48
- page: review_issue.issue_id,
36
+ title: metadata_info[:title],
37
+ tags: metadata_info[:tags],
38
+ languages: metadata_info[:languages],
39
+ authors: metadata_info[:authors],
40
+ doi: metadata_info[:doi],
41
+ archive_doi: metadata_info[:archive_doi],
42
+ repository_address: metadata_info[:software_repository_url],
43
+ editor: metadata_info[:review_editor],
44
+ reviewers: metadata_info[:reviewers].collect(&:strip),
45
+ volume: metadata_info[:volume],
46
+ issue: metadata_info[:issue],
47
+ year: metadata_info[:year],
48
+ page: metadata_info[:page]
49
49
  }
50
- }
51
-
52
- metadata.to_json
50
+ }.to_json
53
51
  end
54
52
 
55
53
  # Create metadata used to generate PDF/JATS outputs
56
54
  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
- }
55
+ {
56
+ title: metadata_info[:title],
57
+ tags: metadata_info[:tags],
58
+ authors: metadata_info[:authors],
59
+ doi: metadata_info[:doi],
60
+ software_repository_url: metadata_info[:software_repository_url],
61
+ reviewers: metadata_info[:reviewers].collect{|r| user_login(r)},
62
+ volume: metadata_info[:volume],
63
+ issue: metadata_info[:issue],
64
+ year: metadata_info[:year],
65
+ page: metadata_info[:page],
66
+ journal_alias: metadata_info[:journal_alias],
67
+ software_review_url: metadata_info[:software_review_url],
68
+ archive_doi: metadata_info[:archive_doi],
69
+ citation_string: metadata_info[:citation_string],
70
+ editor: metadata_info[:editor],
71
+ submitted_at: metadata_info[:submitted_at],
72
+ published_at: metadata_info[:published_at]
73
+ }
74
+ end
75
+
76
+ def metadata_info
77
+ @metadata_info ||= all_metadata
78
+ end
79
+
80
+ def deposit!(secret)
81
+ parameters = deposit_payload.merge(secret: secret)
82
+ Faraday.post(journal.data[:deposit_url], parameters.to_json, {"Content-Type" => "application/json"})
83
+ end
84
+
85
+ def citation_string
86
+ metadata_info[:citation_string]
87
+ end
88
+
89
+ def paper_id
90
+ journal.paper_id_from_issue(review_issue.issue_id)
91
+ end
92
+
93
+ def paper_doi
94
+ journal.paper_doi_for_id(paper_id)
95
+ end
73
96
 
74
- metadata.merge(editor_info, dates_info)
97
+ def all_metadata
98
+ metadata = {
99
+ title: paper.title,
100
+ tags: paper.tags,
101
+ languages: paper.languages,
102
+ authors: paper.authors.collect { |a| a.to_h },
103
+ doi: paper_doi,
104
+ software_repository_url: review_issue.target_repository,
105
+ review_issue_id: review_issue.issue_id,
106
+ review_editor: review_issue.editor,
107
+ reviewers: review_issue.reviewers,
108
+ volume: journal.current_volume,
109
+ issue: journal.current_issue,
110
+ year: journal.current_year,
111
+ page: review_issue.issue_id,
112
+ journal_alias: journal.alias,
113
+ journal_name: journal.name,
114
+ software_review_url: journal.reviews_repository_url(review_issue.issue_id),
115
+ archive_doi: review_issue.archive,
116
+ citation_author: paper.citation_author
117
+ }
118
+
119
+ metadata.merge!(editor_info, dates_info)
120
+ metadata[:citation_string] = build_citation_string(metadata)
121
+ metadata
75
122
  end
76
123
 
77
124
  def editor_info
@@ -106,30 +153,24 @@ module Theoj
106
153
  dates_info[:submitted_at] = format_date(info[:submitted]) if info[:submitted]
107
154
  dates_info[:published_at] = format_date(info[:accepted]) if info[:accepted]
108
155
  end
156
+
157
+ if dates_info[:published_at]
158
+ yvi = journal.year_volume_issue_for_date(Date.parse(dates_info[:published_at]))
159
+ dates_info[:year] = yvi[0]
160
+ dates_info[:volume] = yvi[1]
161
+ dates_info[:issue] = yvi[2]
162
+ end
109
163
  end
110
164
 
111
165
  dates_info
112
166
  end
113
167
 
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
168
+ private
127
169
 
128
- def paper_doi
129
- journal.paper_doi_for_id(paper_id)
170
+ def build_citation_string(metadata)
171
+ "#{metadata[:citation_author]}, (#{metadata[:year]}). #{metadata[:title]}. #{metadata[:journal_name]}, #{metadata[:volume]}(#{metadata[:issue]}), #{metadata[:review_issue_id]}, https://doi.org/#{metadata[:doi]}"
130
172
  end
131
173
 
132
- private
133
174
  def format_date(date_string)
134
175
  Date.parse(date_string.to_s).strftime("%Y-%m-%d")
135
176
  rescue Date::Error
data/lib/theoj/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Theoj
2
- VERSION = "1.3.6"
2
+ VERSION = "1.4.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.3.6
4
+ version: 1.4.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: 2022-07-11 00:00:00.000000000 Z
11
+ date: 2022-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.25'
19
+ version: 5.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.25'
26
+ version: 5.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.3.0
33
+ version: 2.4.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.3.0
40
+ version: 2.4.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: openjournals-nameable
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.4.3
75
+ version: 1.5.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.4.3
82
+ version: 1.5.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement