diff --git a/shard.lock b/shard.lock index 7a23ffd..135a1dc 100644 --- a/shard.lock +++ b/shard.lock @@ -2,11 +2,11 @@ version: 1.0 shards: crest: github: mamantoha/crest - version: 0.24.1 + version: 0.25.1 http-client-digest_auth: github: mamantoha/http-client-digest_auth - version: 0.3.0 + version: 0.4.0 myhtml: github: kostya/myhtml @@ -14,5 +14,5 @@ shards: webmock: github: manastech/webmock.cr - commit: 78bb0e3b5850c700da0e7fbdd2d6c180cc4a061b + commit: bb3eab30f6c7d1fdc0a7ff14cd136d68e860d1a7 diff --git a/spec/issue_spec.cr b/spec/issue_spec.cr index dd5ae47..aa0d11d 100644 --- a/spec/issue_spec.cr +++ b/spec/issue_spec.cr @@ -22,6 +22,12 @@ describe Muse::Dl::Issue do issue.title.should eq "Volume 20, Number 1, January 2020" end + it "should parse title correctly" do + issue.volume.should eq "20" + issue.number.should eq "1" + issue.date.should eq "January 2020" + end + it "should parser summary" do issue.summary.should eq <<-EOT Focusing on important research about the role of academic libraries and librarianship, portal also features commentary on issues in technology and publishing. Written for all those interested in the role of libraries within the academy, portal includes peer-reviewed articles addressing subjects such as library administration, information technology, and information policy. In its inaugural year, portal earned recognition as the runner-up for best new journal, awarded by the Council of Editors of Learned Journals (CELJ). An article in portal, "Master's and Doctoral Thesis Citations: Analysis and Trends of a Longitudinal Study," won the Jesse H. Shera Award for Distinguished Published Research from the Library Research Round Table of the American Library Association. diff --git a/src/issue.cr b/src/issue.cr index c8e004a..aad8b20 100644 --- a/src/issue.cr +++ b/src/issue.cr @@ -11,8 +11,11 @@ module Muse::Dl @info : Hash(String, String) @summary : String | Nil @publisher : String | Nil + @volume : String | Nil + @number : String | Nil + @date : String | Nil - getter :id, :title, :articles, :url, :summary, :publisher, :info + getter :id, :title, :articles, :url, :summary, :publisher, :info, :volume, :number, :date def initialize(id : String) @id = id @@ -28,6 +31,16 @@ module Muse::Dl @title = InfoParser.issue_title(h) @summary = InfoParser.summary(h) @publisher = InfoParser.journal_publisher(h) + parse_title + end + + def parse_title + t = @title + unless t.nil? + @volume = /Volume (\d+)/.match(t).try &.[1] + @number = /Number (\d+)/.match(t).try &.[1] + @date = /((January|February|March|April|May|June|July|August|September|October|November|December) (\d+))/.match(t).try &.[1] + end end end end