lib/relaton_jis/hit.rb in relaton-jis-1.19.1 vs lib/relaton_jis/hit.rb in relaton-jis-1.19.2
- old
+ new
@@ -6,13 +6,13 @@
# @param [Nokogiri::XML::Element] node found node
# @param [RelatonJis::HitCollection] collection hit collection
#
# @return [RelatonJis::Hit] new hit
#
- def self.create(node, collection)
- a = node.at("./a")
- hit = { id: a.at("./text()").text.strip, url: a["href"] }
+ def self.create(hit, collection)
+ # a = node.at("./a")
+ # hit = { id: a.at("./text()").text.strip, url: a["href"] }
new hit, collection
end
#
# Check if hit matches reference
@@ -42,9 +42,16 @@
def id_parts
@id_parts ||= hit_collection.parse_ref hit[:id]
end
def fetch
- @fetch ||= Scraper.new(hit[:url]).fetch
+ return @fetch if defined? @fetch
+
+ # @fetch = Scraper.new(hit[:url]).fetch
+ yaml = Mechanize.new.get("#{Bibliography::GH_URL}#{hit[:file]}").body
+ hash = YAML.safe_load yaml
+ @fetch = RelatonJis::BibliographicItem.from_hash hash
+ @fetch.fetched = Date.today.to_s
+ @fetch
end
end
end