relaton-bib 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/relaton_bib/copyright_association.rb +1 -1
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/xml_parser.rb +45 -39
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 9da202081fac78dc82e84fd1387007c977be6981
         | 
| 4 | 
            +
              data.tar.gz: 6ef4319dc738576c1d0aca6972f5f061d27bf1bd
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2ec1ef406ba6067a466508200c8c948a342bb39d1a133910b74fb0522fdf0a70c3e1abbf164256f9c2b3a93f1d14b34dafdffdcc46bc12a68b2f9b141cb60d1a
         | 
| 7 | 
            +
              data.tar.gz: 3ed3da30cffeae49ef4e7737a76ea64f16823c41026b159c9eafd4a960262dc31cd71d6d627f415bb9d5701828ac2862ea91e764c872189bdb19f731011d04f5
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
| @@ -15,7 +15,7 @@ module RelatonBib | |
| 15 15 | 
             
                # @option owner [String] :abbreviation
         | 
| 16 16 | 
             
                # @option owner [String] :url
         | 
| 17 17 | 
             
                # @param from [String] date
         | 
| 18 | 
            -
                # @param to [String] date
         | 
| 18 | 
            +
                # @param to [String, NilClass] date
         | 
| 19 19 | 
             
                def initialize(owner:, from:, to: nil)
         | 
| 20 20 | 
             
                  @owner = if owner.is_a?(Hash)
         | 
| 21 21 | 
             
                             ContributionInfo.new entity: Organization.new(owner)
         | 
    
        data/lib/relaton_bib/version.rb
    CHANGED
    
    
| @@ -6,37 +6,42 @@ module RelatonBib | |
| 6 6 | 
             
                  def from_xml(xml)
         | 
| 7 7 | 
             
                    doc = Nokogiri::XML(xml)
         | 
| 8 8 | 
             
                    bibitem = doc.at "/bibitem"
         | 
| 9 | 
            -
                    BibliographicItem.new( | 
| 10 | 
            -
                      id:             bibitem[:id],
         | 
| 11 | 
            -
                      type:           bibitem[:type],
         | 
| 12 | 
            -
                      fetched:        bibitem.at("./fetched")&.text,
         | 
| 13 | 
            -
                      titles:         fetch_titles(bibitem),
         | 
| 14 | 
            -
                      link:           fetch_link(bibitem),
         | 
| 15 | 
            -
                      docid:          fetch_docid(bibitem),
         | 
| 16 | 
            -
                      docnumber:      bibitem.at("./docnumber")&.text,
         | 
| 17 | 
            -
                      dates:          fetch_dates(bibitem),
         | 
| 18 | 
            -
                      contributors:   fetch_contributors(bibitem),
         | 
| 19 | 
            -
                      edition:        bibitem.at("./edition")&.text,
         | 
| 20 | 
            -
                      version:        fetch_version(bibitem),
         | 
| 21 | 
            -
                      biblionote:     fetch_note(bibitem),
         | 
| 22 | 
            -
                      language:       bibitem.xpath("./language").map(&:text),
         | 
| 23 | 
            -
                      script:         bibitem.xpath("./script").map(&:text),
         | 
| 24 | 
            -
                      abstract:       fetch_abstract(bibitem),
         | 
| 25 | 
            -
                      docstatus:      fetch_status(bibitem),
         | 
| 26 | 
            -
                      copyright:      fetch_copyright(bibitem),
         | 
| 27 | 
            -
                      relations:      fetch_relations(bibitem),
         | 
| 28 | 
            -
                      series:         fetch_series(bibitem),
         | 
| 29 | 
            -
                      medium:         fetch_medium(bibitem),
         | 
| 30 | 
            -
                      place:          bibitem.xpath("./place").map(&:text),
         | 
| 31 | 
            -
                      extent:         fetch_extent(bibitem),
         | 
| 32 | 
            -
                      accesslocation: bibitem.xpath("./accesslocation").map(&:text),
         | 
| 33 | 
            -
                      classification: fetch_classification(bibitem),
         | 
| 34 | 
            -
                      validity:       fetch_validity(bibitem),
         | 
| 35 | 
            -
                    )
         | 
| 9 | 
            +
                    BibliographicItem.new(item_data(bibitem))
         | 
| 36 10 | 
             
                  end
         | 
| 37 11 |  | 
| 38 12 | 
             
                  private
         | 
| 39 13 |  | 
| 14 | 
            +
                  def item_data(bibitem)
         | 
| 15 | 
            +
                    {
         | 
| 16 | 
            +
                      id: bibitem[:id],
         | 
| 17 | 
            +
                      type: bibitem[:type],
         | 
| 18 | 
            +
                      fetched: bibitem.at("./fetched")&.text,
         | 
| 19 | 
            +
                      titles: fetch_titles(bibitem),
         | 
| 20 | 
            +
                      formattedref: fref(bibitem),
         | 
| 21 | 
            +
                      link: fetch_link(bibitem),
         | 
| 22 | 
            +
                      docid: fetch_docid(bibitem),
         | 
| 23 | 
            +
                      docnumber: bibitem.at("./docnumber")&.text,
         | 
| 24 | 
            +
                      dates: fetch_dates(bibitem),
         | 
| 25 | 
            +
                      contributors: fetch_contributors(bibitem),
         | 
| 26 | 
            +
                      edition: bibitem.at("./edition")&.text,
         | 
| 27 | 
            +
                      version: fetch_version(bibitem),
         | 
| 28 | 
            +
                      biblionote: fetch_note(bibitem),
         | 
| 29 | 
            +
                      language: bibitem.xpath("./language").map(&:text),
         | 
| 30 | 
            +
                      script: bibitem.xpath("./script").map(&:text),
         | 
| 31 | 
            +
                      abstract: fetch_abstract(bibitem),
         | 
| 32 | 
            +
                      docstatus: fetch_status(bibitem),
         | 
| 33 | 
            +
                      copyright: fetch_copyright(bibitem),
         | 
| 34 | 
            +
                      relations: fetch_relations(bibitem),
         | 
| 35 | 
            +
                      series: fetch_series(bibitem),
         | 
| 36 | 
            +
                      medium: fetch_medium(bibitem),
         | 
| 37 | 
            +
                      place: bibitem.xpath("./place").map(&:text),
         | 
| 38 | 
            +
                      extent: fetch_extent(bibitem),
         | 
| 39 | 
            +
                      accesslocation: bibitem.xpath("./accesslocation").map(&:text),
         | 
| 40 | 
            +
                      classification: fetch_classification(bibitem),
         | 
| 41 | 
            +
                      validity: fetch_validity(bibitem),
         | 
| 42 | 
            +
                    }
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
             | 
| 40 45 | 
             
                  def fetch_version(item)
         | 
| 41 46 | 
             
                    version = item.at "./version"
         | 
| 42 47 | 
             
                    return unless version
         | 
| @@ -191,16 +196,20 @@ module RelatonBib | |
| 191 196 | 
             
                      PersonIdentifier.new pi[:type], pi.text
         | 
| 192 197 | 
             
                    end
         | 
| 193 198 |  | 
| 194 | 
            -
                     | 
| 195 | 
            -
                     | 
| 199 | 
            +
                    cn = person.at "./name/completename"
         | 
| 200 | 
            +
                    cname = if cn
         | 
| 201 | 
            +
                              LocalizedString.new(cn.text, cn[:language], cn[:script])
         | 
| 202 | 
            +
                            else
         | 
| 203 | 
            +
                              nil
         | 
| 204 | 
            +
                            end
         | 
| 196 205 |  | 
| 197 | 
            -
                     | 
| 198 | 
            -
                     | 
| 206 | 
            +
                    sn = person.at "./name/surname"
         | 
| 207 | 
            +
                    sname = sn ? LocalizedString.new(sn.text, sn[:language], sn[:script]) : nil
         | 
| 199 208 |  | 
| 200 209 | 
             
                    name = FullName.new(
         | 
| 201 | 
            -
                      completename:  | 
| 210 | 
            +
                      completename: cname, surname: sname,
         | 
| 202 211 | 
             
                      initials: name_part(person, "initial"), forenames: name_part(person, "forename"),
         | 
| 203 | 
            -
                      additions: name_part(person, " | 
| 212 | 
            +
                      additions: name_part(person, "addition"), prefix: name_part(person, "prefix")
         | 
| 204 213 | 
             
                    )
         | 
| 205 214 |  | 
| 206 215 | 
             
                    Person.new(
         | 
| @@ -212,7 +221,7 @@ module RelatonBib | |
| 212 221 | 
             
                  end
         | 
| 213 222 |  | 
| 214 223 | 
             
                  def name_part(person, part)
         | 
| 215 | 
            -
                     | 
| 224 | 
            +
                    person.xpath("./name/#{part}").map do |np|
         | 
| 216 225 | 
             
                      LocalizedString.new np.text, np[:language]
         | 
| 217 226 | 
             
                    end
         | 
| 218 227 | 
             
                  end
         | 
| @@ -261,15 +270,12 @@ module RelatonBib | |
| 261 270 | 
             
                        BibItemLocality.new(
         | 
| 262 271 | 
             
                          l[:type],
         | 
| 263 272 | 
             
                          LocalizedString.new(l.at("./referenceFrom").text),
         | 
| 264 | 
            -
                          ref_to
         | 
| 273 | 
            +
                          ref_to,
         | 
| 265 274 | 
             
                        )
         | 
| 266 275 | 
             
                      end
         | 
| 267 | 
            -
                      bibitem = rel&.at "./bibitem"
         | 
| 268 276 | 
             
                      DocumentRelation.new(
         | 
| 269 277 | 
             
                        type: rel[:type],
         | 
| 270 | 
            -
                        bibitem: BibliographicItem.new(
         | 
| 271 | 
            -
                          type: bibitem[:type], formattedref: fref(bibitem), docstatus: fetch_status(bibitem)
         | 
| 272 | 
            -
                        ),
         | 
| 278 | 
            +
                        bibitem: BibliographicItem.new(item_data(rel.at("./bibitem"))),
         | 
| 273 279 | 
             
                        bib_locality: localities,
         | 
| 274 280 | 
             
                      )
         | 
| 275 281 | 
             
                    end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: relaton-bib
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ribose Inc.
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2019-05- | 
| 11 | 
            +
            date: 2019-05-03 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |