Class: Theoj::Submission
- Inherits:
-
Object
- Object
- Theoj::Submission
- Includes:
- GitHub
- Defined in:
- lib/theoj/submission.rb
Instance Attribute Summary collapse
-
#journal ⇒ Object
Returns the value of attribute journal.
-
#paper ⇒ Object
Returns the value of attribute paper.
-
#review_issue ⇒ Object
Returns the value of attribute review_issue.
Instance Method Summary collapse
-
#all_metadata ⇒ Object
Removes archive_doi, adds neurolibre reproducibility assets DOIs.
-
#article_metadata ⇒ Object
Create metadata used to generate PDF/JATS outputs Removes archive_doi, adds neurolibre reproducibility assets DOIs.
- #citation_string ⇒ Object
- #dates_info ⇒ Object
- #deposit!(secret) ⇒ Object
-
#deposit_payload ⇒ Object
Removes archive_doi, adds neurolibre reproducibility assets DOIs.
- #editor_info ⇒ Object
-
#initialize(journal, review_issue, paper = nil) ⇒ Submission
constructor
A new instance of Submission.
- #metadata_info ⇒ Object
-
#metadata_payload ⇒ Object
Create a metadata json payload Removes archive_doi, adds neurolibre reproducibility assets DOIs.
- #paper_doi ⇒ Object
- #paper_id ⇒ Object
- #track ⇒ Object
Methods included from GitHub
#can_be_assignee?, #github_access_token, #github_client, #github_headers, #is_collaborator?, #is_invited?, #issue, #issue_labels, #user_login, #username?
Constructor Details
#initialize(journal, review_issue, paper = nil) ⇒ Submission
Returns a new instance of Submission.
15 16 17 18 19 |
# File 'lib/theoj/submission.rb', line 15 def initialize(journal, review_issue, paper=nil) @journal = journal @review_issue = review_issue @paper = paper || @review_issue.paper end |
Instance Attribute Details
#journal ⇒ Object
Returns the value of attribute journal.
11 12 13 |
# File 'lib/theoj/submission.rb', line 11 def journal @journal end |
#paper ⇒ Object
Returns the value of attribute paper.
13 14 15 |
# File 'lib/theoj/submission.rb', line 13 def paper @paper end |
#review_issue ⇒ Object
Returns the value of attribute review_issue.
12 13 14 |
# File 'lib/theoj/submission.rb', line 12 def review_issue @review_issue end |
Instance Method Details
#all_metadata ⇒ Object
Removes archive_doi, adds neurolibre reproducibility assets DOIs.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/theoj/submission.rb', line 124 def = { title: plaintext(paper.title), tags: paper., languages: paper.languages, authors: paper..collect { |a| a.to_h }, doi: paper_doi, software_repository_url: review_issue.target_repository, review_issue_id: review_issue.issue_id, review_editor: review_issue.editor, reviewers: review_issue.reviewers, volume: journal.current_volume, issue: journal.current_issue, year: journal.current_year, page: review_issue.issue_id, journal_alias: journal.alias, journal_name: journal.name, software_review_url: journal.reviews_repository_url(review_issue.issue_id), # Context changes from archive --> doi repository_doi: review_issue.repository_archive, data_doi: review_issue.data_archive, book_doi: review_issue.book_archive, docker_doi: review_issue.docker_archive, # Context does not change for this book_exec_url: review_issue.book_exec_url, citation_author: paper. } # @NeuroLibre -- END .merge!(editor_info, dates_info) [:citation_string] = build_citation_string() end |
#article_metadata ⇒ Object
Create metadata used to generate PDF/JATS outputs Removes archive_doi, adds neurolibre reproducibility assets DOIs.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/theoj/submission.rb', line 72 def { title: [:title], tags: [:tags], authors: [:authors], doi: [:doi], software_repository_url: [:software_repository_url], reviewers: [:reviewers].collect{|r| user_login(r)}, volume: [:volume], issue: [:issue], year: [:year], page: [:page], journal_alias: [:journal_alias], software_review_url: [:software_review_url], repository_doi: [:repository_doi], book_exec_url: [:book_exec_url], data_doi: [:data_doi], book_doi: [:book_doi], docker_doi: [:docker_doi], citation_string: [:citation_string], editor: [:editor], submitted_at: [:submitted_at], published_at: [:published_at] } end |
#citation_string ⇒ Object
110 111 112 |
# File 'lib/theoj/submission.rb', line 110 def citation_string [:citation_string] end |
#dates_info ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/theoj/submission.rb', line 182 def dates_info dates_info = { submitted_at: nil, published_at: nil } if review_issue.issue_id paper_lookup = Faraday.get(journal.url + "/papers/lookup/" + review_issue.issue_id.to_s) if paper_lookup.status == 200 info = JSON.parse(paper_lookup.body, symbolize_names: true) dates_info[:submitted_at] = format_date(info[:submitted]) if info[:submitted] dates_info[:published_at] = format_date(info[:accepted]) if info[:accepted] end if dates_info[:published_at] yvi = journal.year_volume_issue_for_date(Date.parse(dates_info[:published_at])) dates_info[:year] = yvi[0] dates_info[:volume] = yvi[1] dates_info[:issue] = yvi[2] end end dates_info end |
#deposit!(secret) ⇒ Object
105 106 107 108 |
# File 'lib/theoj/submission.rb', line 105 def deposit!(secret) parameters = deposit_payload.merge(secret: secret) Faraday.post(journal.data[:deposit_url], parameters.to_json, {"Content-Type" => "application/json"}) end |
#deposit_payload ⇒ Object
Removes archive_doi, adds neurolibre reproducibility assets DOIs.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/theoj/submission.rb', line 23 def deposit_payload { id: [:review_issue_id], metadata: Base64.encode64(), doi: [:doi], repository_doi: [:repository_doi], book_exec_url: [:book_exec_url], data_doi: [:data_doi], book_doi: [:book_doi], docker_doi: [:docker_doi], citation_string: citation_string, title: [:title] } end |
#editor_info ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/theoj/submission.rb', line 160 def editor_info editor_info = { editor: { github_user: user_login(review_issue.editor), name: nil, url: nil, orcid: nil } } if review_issue.editor editor_lookup = Faraday.get(journal.url + "/editors/lookup/" + user_login(review_issue.editor)) if editor_lookup.status == 200 info = JSON.parse(editor_lookup.body, symbolize_names: true) editor_info[:editor][:name] = info[:name] editor_info[:editor][:url] = info[:url] editor_info[:editor][:orcid] = info[:orcid] end end editor_info end |
#metadata_info ⇒ Object
101 102 103 |
# File 'lib/theoj/submission.rb', line 101 def @metadata_info ||= end |
#metadata_payload ⇒ Object
Create a metadata json payload Removes archive_doi, adds neurolibre reproducibility assets DOIs.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/theoj/submission.rb', line 42 def { paper: { title: [:title], tags: [:tags], languages: [:languages], authors: [:authors], doi: [:doi], repository_doi: [:repository_doi], book_exec_url: [:book_exec_url], data_doi: [:data_doi], book_doi: [:book_doi], docker_doi: [:docker_doi], repository_address: [:software_repository_url], editor: [:review_editor], reviewers: [:reviewers].collect(&:strip), volume: [:volume], issue: [:issue], year: [:year], page: [:page] } }.to_json end |
#paper_doi ⇒ Object
118 119 120 |
# File 'lib/theoj/submission.rb', line 118 def paper_doi journal.paper_doi_for_id(paper_id) end |
#paper_id ⇒ Object
114 115 116 |
# File 'lib/theoj/submission.rb', line 114 def paper_id journal.paper_id_from_issue(review_issue.issue_id) end |
#track ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/theoj/submission.rb', line 204 def track track_info = { name: nil, short_name: nil, code: nil, label: nil, parameterized: nil} if review_issue.issue_id track_lookup = Faraday.get(journal.url + "/papers/" + review_issue.issue_id.to_s + "/lookup_track" ) if track_lookup.status == 200 track_info = JSON.parse(track_lookup.body, symbolize_names: true) end end track_info end |