Class: BibliographicalImporter::JSON::Record

Inherits:
Object
  • Object
show all
Includes:
CommonRecordAttributes, ReferenceMethods
Defined in:
lib/bibliographical_importer/json.rb

Instance Attribute Summary collapse

Attributes included from CommonRecordAttributes

#abstract, #affiliation, #authors, #cited, #doi, #id_scopus, #id_wos, #journal, #journal_abbr, #keywords, #keywords_plus, #language, #pages, #references_scopus, #references_wos, #title, #type, #uid, #url, #volume, #year

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ReferenceMethods

#authors_apa_6, #cite_apa_6, #ref_apa_6, #ref_apa_6_brief, #ref_apa_6_brief_html

Methods included from DOIHelpers

#a_doi, #doi_without_http, #find_doi, #url_doi

Constructor Details

#initialize(json_value) ⇒ Record

Returns a new instance of Record



79
80
81
82
83
84
85
# File 'lib/bibliographical_importer/json.rb', line 79

def initialize(json_value)
  @jv=json_value
  @authors=[]
  parse_common


end

Instance Attribute Details

#jvObject (readonly)

Returns the value of attribute jv



65
66
67
# File 'lib/bibliographical_importer/json.rb', line 65

def jv
  @jv
end

#references_crossrefObject

Returns the value of attribute references_crossref



66
67
68
# File 'lib/bibliographical_importer/json.rb', line 66

def references_crossref
  @references_crossref
end

Class Method Details

.create(json) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/bibliographical_importer/json.rb', line 71

def self.create(json)
  #type=self.determine_type(bibtex_value)
  #klass="Reference_#{type.capitalize}".to_sym
  #BibliographicalImporter::JSON.const_get(klass).send(:new, bibtex_value)

  BibliographicalImporter::JSON::Record.new(json)
end

Instance Method Details

#authorObject



123
124
125
126
127
# File 'lib/bibliographical_importer/json.rb', line 123

def author
  #$log.info(@authors)
  @authors.join (" and ")

end

#parse_commonObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/bibliographical_importer/json.rb', line 86

def parse_common
  begin
    vh=@jv["message"]

    @uid=vh["URL"]
    @title=vh["title"].join(";")
    #$log.info("Parseando")
    #$log.info(vh["author"])
    @authors=vh["author"].map {|v|
      "#{v["family"]}, #{v["given"]}"
    } unless vh["author"].nil?

#          #$log.info(@authors)

    @journal=vh["container-title"].join(";")
    @year=vh["issued"]["date-parts"][0][0]
    @volume=vh["volume"]
    @pages=vh["page"]
    @type=vh["type"]
    @doi=vh["DOI"]
    @url=vh["URL"]
    @references_crossref=@jv["message"]["reference"]

  rescue Exception=>e
    #$log.info("Error:#{vh}")
    raise e
  end

end

#referencesObject



116
117
118
119
120
# File 'lib/bibliographical_importer/json.rb', line 116

def references
  @references_crossref.map {|v|
    Reference.new(v)
  } unless @references_crossref.nil?
end

#strip_lines(value) ⇒ Object



133
134
135
# File 'lib/bibliographical_importer/json.rb', line 133

def strip_lines(value)
  value.to_s.gsub(/\n\s*/, ' ')
end