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
-
#article_metadata ⇒ Object
Create metadata used to generate PDF/JATS outputs.
- #citation_string ⇒ Object
- #dates_info ⇒ Object
- #deposit!(secret) ⇒ Object
-
#deposit_payload ⇒ Object
Create the payload to use to post for depositing with Open Journals.
- #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.
- #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
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/theoj/submission.rb', line 98 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), archive_doi: review_issue.archive, citation_author: paper. } .merge!(editor_info, dates_info) [:citation_string] = build_citation_string() end |
#article_metadata ⇒ Object
Create metadata used to generate PDF/JATS outputs
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/theoj/submission.rb', line 55 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], archive_doi: [:archive_doi], citation_string: [:citation_string], editor: [:editor], submitted_at: [:submitted_at], published_at: [:published_at] } end |
#citation_string ⇒ Object
86 87 88 |
# File 'lib/theoj/submission.rb', line 86 def citation_string [:citation_string] end |
#dates_info ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/theoj/submission.rb', line 147 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
81 82 83 84 |
# File 'lib/theoj/submission.rb', line 81 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
Create the payload to use to post for depositing with Open Journals
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/theoj/submission.rb', line 22 def deposit_payload { id: [:review_issue_id], metadata: Base64.encode64(), doi: [:doi], archive_doi: [:archive_doi], citation_string: citation_string, title: [:title] } end |
#editor_info ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/theoj/submission.rb', line 125 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
77 78 79 |
# File 'lib/theoj/submission.rb', line 77 def @metadata_info ||= end |
#metadata_payload ⇒ Object
Create a metadata json payload
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/theoj/submission.rb', line 34 def { paper: { title: [:title], tags: [:tags], languages: [:languages], authors: [:authors], doi: [:doi], archive_doi: [:archive_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
94 95 96 |
# File 'lib/theoj/submission.rb', line 94 def paper_doi journal.paper_doi_for_id(paper_id) end |
#paper_id ⇒ Object
90 91 92 |
# File 'lib/theoj/submission.rb', line 90 def paper_id journal.paper_id_from_issue(review_issue.issue_id) end |
#track ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/theoj/submission.rb', line 169 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 |