Class: Montague::XMLExtractor::Publisher

Inherits:
Base
  • Object
show all
Defined in:
lib/montague/xml_extractor/publisher.rb

Overview

Publisher XML extractor

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Publisher

Returns a new instance of Publisher.


7
8
9
# File 'lib/montague/xml_extractor/publisher.rb', line 7

def initialize(xml)
  super
end

Instance Method Details

#conditionsArray<String>

Returns:

  • (Array<String>)

17
18
19
# File 'lib/montague/xml_extractor/publisher.rb', line 17

def conditions
  xpath_query_for_multi_value '/publisher/conditions/condition'
end

Returns:


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/montague/xml_extractor/publisher.rb', line 22

def copyright_links
  data = []
  xpath_result = xpath_query '/publisher/copyrightlinks/copyrightlink'
  xpath_result.each do |i|
    copyright_link = Montague::Model::CopyrightLink.new
    copyright_link.text = i.xpath('copyrightlinktext').text.strip
    copyright_link.url = i.xpath('copyrightlinkurl').text.strip
    data << copyright_link if copyright_link.data?
  end
  data
end

#idString

Returns Allows for dummy ID string when there is no RoMEO entry with numeric ID.

Returns:

  • (String)

    Allows for dummy ID string when there is no RoMEO entry with numeric ID


35
36
37
# File 'lib/montague/xml_extractor/publisher.rb', line 35

def id
  xpath_query_for_single_value('/publisher/@id').to_s
end

#mandatesArray<Montague::Model::Mandate>

Publisher compliance with the open access mandates of research funding agencies

Returns:


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/montague/xml_extractor/publisher.rb', line 41

def mandates
  xpath_result = xpath_query '/publisher/mandates/mandate'
  data = []
  xpath_result.each do |i|
    mandate = Montague::Model::Mandate.new
    funder = Montague::Model::Funder.new
    funder.name = i.xpath('funder/fundername').text.strip
    funder.acronym = i.xpath('funder/funderacronym').text.strip
    mandate.funder = funder if funder.data?
    mandate.publisher_complies = i.xpath('publishercomplies').text.strip
    mandate.compliance_type = i.xpath('compliancetype').text.strip
    mandate.selected_titles = i.xpath('selectedtitles').text.strip
    data << mandate if mandate.data?
  end
  data
end

#modelMontague::Model::Publisher


124
125
126
# File 'lib/montague/xml_extractor/publisher.rb', line 124

def model
  models.first unless models.empty?
end

#modelsArray<Montague::Model::Publisher>

Returns:


112
113
114
115
116
117
118
119
120
121
# File 'lib/montague/xml_extractor/publisher.rb', line 112

def models
  data = []
  xpath_result = xpath_query publisher_path
  xpath_result.each do |i|
    xml_extractor = Montague::XMLExtractor::Publisher.new i.to_s    # puts i.to_s

    data << xml_extractor.package_model
  end
  data
end

#nameString?

Returns:

  • (String, nil)

59
60
61
# File 'lib/montague/xml_extractor/publisher.rb', line 59

def name
  xpath_query_for_single_value '/publisher/name'
end

#name_aliasString

Returns:

  • (String)

12
13
14
# File 'lib/montague/xml_extractor/publisher.rb', line 12

def name_alias
  xpath_query_for_single_value '/publisher/alias'
end

#package_modelMontague::Model::Publisher


129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/montague/xml_extractor/publisher.rb', line 129

def package_model
  m = Montague::Model::Publisher.new
  m.alias = name_alias
  m.conditions =  conditions
  m.copyright_links = copyright_links
  m.id = id
  m.mandates = mandates
  m.name = name
  m.paid_access = paid_access
  m.pdf_version = pdf_version
  m.pre_prints = pre_prints
  m.post_prints = post_prints
  m.romeo_colour = romeo_colour
  m
end

Returns:


65
66
67
68
69
70
71
72
73
74
# File 'lib/montague/xml_extractor/publisher.rb', line 65

def paid_access
  xpath_result = xpath_query '/publisher/paidaccess'
  if !xpath_result.empty?
    paid_access = Montague::Model::PaidAccess.new
    paid_access.url = xpath_result.xpath('paidaccessurl').text.strip
    paid_access.name = xpath_result.xpath('paidaccessname').text.strip
    paid_access.notes = xpath_result.xpath('paidaccessnotes').text.strip
    paid_access
  end
end

#pdf_versionMontague::Model::Archiving?

Returns:


97
98
99
100
101
102
103
104
# File 'lib/montague/xml_extractor/publisher.rb', line 97

def pdf_version
  paths = {
    archiving: 'pdfversion',
    permission: 'pdfarchiving',
    restrictions: 'pdfrestrictions'
  }
  prints paths
end

#post_printsMontague::Model::Archiving?

Returns:


87
88
89
90
91
92
93
94
# File 'lib/montague/xml_extractor/publisher.rb', line 87

def post_prints
  paths = {
    archiving: 'postprints',
    permission: 'postarchiving',
    restrictions: 'postrestrictions'
  }
  prints paths
end

#pre_printsMontague::Model::Archiving?

Returns:


77
78
79
80
81
82
83
84
# File 'lib/montague/xml_extractor/publisher.rb', line 77

def pre_prints
  paths = {
    archiving: 'preprints',
    permission: 'prearchiving',
    restrictions: 'prerestrictions'
  }
  prints paths
end

#romeo_colourString?

Returns:

  • (String, nil)

107
108
109
# File 'lib/montague/xml_extractor/publisher.rb', line 107

def romeo_colour
 xpath_query_for_single_value '/publisher/romeocolour'
end