Journal parser now parses all issues

pull/8/head
Nemo 3 years ago
parent d8702b2fcb
commit 4a358d0cb0
  1. 5
      spec/journal_spec.cr
  2. 9
      src/issue.cr
  3. 17
      src/journal.cr

@ -20,4 +20,9 @@ describe Muse::Dl::Journal do
it "should parse publisher" do
j.publisher.should eq "Johns Hopkins University Press"
end
it "should return issues" do
j.issues[0].id.should eq "41793"
j.issues[-1].id.should eq "1578"
end
end

@ -1,6 +1,13 @@
require "./thing.cr"
module Muse::Dl
class Issue < Muse::Dl::Thing
class Issue
@id : String
getter :id
def initialize(id : String)
@id = id
end
end
end

@ -1,12 +1,13 @@
require "./infoparser.cr"
require "myhtml"
require "./issue.cr"
module Muse::Dl
class Journal
getter :info, :summary, :publisher
getter :info, :summary, :publisher, :issues
@info = Hash(String, String).new
@summary : String
@publisher : String
@issues = [] of Muse::Dl::Issue
private getter :h
@ -15,6 +16,18 @@ module Muse::Dl
@info = InfoParser.infobox(h)
@summary = InfoParser.summary(h)
@publisher = InfoParser.journal_publisher(h)
parse_volumes(h)
end
def parse_volumes(myhtml : Myhtml::Parser)
myhtml.css("#available_issues_list_text a").each do |a|
link = a.attribute_by("href").to_s
matches = /\/issue\/(\d+)/.match link
if matches
@issues.push Muse::Dl::Issue.new matches[1]
end
end
end
end
end

Loading…
Cancel
Save