Class: Theoj::RetractionNotice

Inherits:
Object
  • Object
show all
Defined in:
lib/theoj/retraction_notice.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doi, journal_alias) ⇒ RetractionNotice

Returns a new instance of RetractionNotice.



11
12
13
14
15
16
17
18
# File 'lib/theoj/retraction_notice.rb', line 11

def initialize(doi, journal_alias)
  journal_data = Theoj::JOURNALS_DATA[journal_alias.to_sym]
  if journal_data.nil?
    raise Theoj::Error, "Can't find journal #{journal_alias}"
  end
  @journal = Theoj::Journal.new(journal_data)
  @retracted_paper = Theoj::PublishedPaper.new(doi)
end

Instance Attribute Details

#journalObject

Returns the value of attribute journal.



9
10
11
# File 'lib/theoj/retraction_notice.rb', line 9

def journal
  @journal
end

#retracted_paperObject

Returns the value of attribute retracted_paper.



8
9
10
# File 'lib/theoj/retraction_notice.rb', line 8

def retracted_paper
  @retracted_paper
end

Instance Method Details

#citation_stringObject



70
71
72
# File 'lib/theoj/retraction_notice.rb', line 70

def citation_string
  "Editorial Board, (#{[:year]}). #{[:title]}. #{journal.name}, #{[:volume]}(#{[:issue]}), #{[:page]}, https://doi.org/#{[:doi]}"
end

#deposit!(secret) ⇒ Object



74
75
76
77
# File 'lib/theoj/retraction_notice.rb', line 74

def deposit!(secret)
  parameters = deposit_payload.merge(secret: secret)
  Faraday.post(journal.data[:retract_url], parameters.to_json, {"Content-Type" => "application/json"})
end

#deposit_payloadObject

Create the payload to use to post for depositing with Open Journals



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/theoj/retraction_notice.rb', line 44

def deposit_payload
   = {
    paper: {
      title: [:title],
      tags: [:tags],
      languages: [],
      authors: [:authors],
      doi: [:doi],
      archive_doi: [:archive_doi],
      repository_address: [:software_repository_url],
      editor: [:editor][:github_user],
      reviewers: [:reviewers],
      volume: [:volume],
      issue: [:issue],
      year: [:year],
      page: [:page]
    }
  }.to_json

  {
    doi: retracted_paper.doi,
    metadata: Base64.encode64(),
    citation_string: citation_string
  }
end

#metadataObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/theoj/retraction_notice.rb', line 20

def 
  {
    title: "Retraction notice for: " + retracted_paper.title,
    tags: [retracted_paper.tags].flatten,
    authors: [{ given_name: journal.alias.upcase,
                last_name: "Editorial Board",
                affiliation: journal.name}],
    doi: retracted_paper.doi + "R",
    software_repository_url: retracted_paper.software_repository,
    reviewers: [],
    volume: journal.current_volume,
    issue: journal.current_issue,
    year: journal.current_year,
    page: retracted_paper.page,
    journal_alias: journal.alias,
    software_review_url: retracted_paper.paper_review,
    archive_doi: retracted_paper.software_archive.to_s.gsub("https://doi.org/", ""),
    editor: { github_user: "openjournals", name: "Editorial Board", url: journal.data[:url] },
    submitted_at: Time.now.strftime("%Y-%m-%d"),
    published_at: Time.now.strftime("%Y-%m-%d")
  }
end