isodoc 0.8.13 → 0.9.0
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/isodoc/function/references.rb +33 -17
 - data/lib/isodoc/version.rb +1 -1
 - data/spec/isodoc/ref_spec.rb +8 -8
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 9a6782d0471fb7cd450a7dce15e825e76a86e4f3c8854ddc69faaa648f65974c
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 8062dc310b20e6c1d13a41ac100489dff153be0152a543c20b1aa043093aa72c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: fc34ddc8a06fd1632889c00b4a60641c33f983a5b6c3ac6c18c290992d7a8dee91d3074044513ce3608146488a710fa1a0099a09b2103bcc63355c7e570572be
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: f9977b4049756a609cc048e022aa138731182beb53a36be53dfb8a46b7285a48c836fa280782ea95f10d06196c05e6bf5a99a5b02dee0c50b6b190e4f2f74f83
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
| 
         @@ -5,17 +5,28 @@ module IsoDoc::Function 
     | 
|
| 
       5 
5 
     | 
    
         
             
                # references anyway; keeping here instead of in IsoDoc::Iso for now
         
     | 
| 
       6 
6 
     | 
    
         
             
                def docid_l10n(x)
         
     | 
| 
       7 
7 
     | 
    
         
             
                  return x if x.nil?
         
     | 
| 
       8 
     | 
    
         
            -
                  x.gsub(/All Parts 
     | 
| 
      
 8 
     | 
    
         
            +
                  x.gsub(/All Parts/i, @all_parts_lbl.downcase)
         
     | 
| 
       9 
9 
     | 
    
         
             
                end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
                def iso_bibitem_ref_code(b)
         
     | 
| 
       12 
12 
     | 
    
         
             
                  isocode = b.at(ns("./docidentifier")).text
         
     | 
| 
       13 
     | 
    
         
            -
                   
     | 
| 
       14 
     | 
    
         
            -
                   
     | 
| 
      
 13 
     | 
    
         
            +
                  prefix = b&.at(ns("./docidentifier/@type"))&.text
         
     | 
| 
      
 14 
     | 
    
         
            +
                  #isodate = b.at(ns("./date[@type = 'published']"))
         
     | 
| 
      
 15 
     | 
    
         
            +
                  #allparts = b.at(ns("./allparts"))
         
     | 
| 
       15 
16 
     | 
    
         
             
                  reference = docid_l10n(isocode)
         
     | 
| 
       16 
     | 
    
         
            -
                  reference += ":#{date_range(isodate)}" if isodate
         
     | 
| 
       17 
     | 
    
         
            -
                  reference += " (#{@all_parts_lbl.downcase})" if allparts&.text == "true"
         
     | 
| 
       18 
     | 
    
         
            -
                  reference
         
     | 
| 
      
 17 
     | 
    
         
            +
                  #reference += ":#{date_range(isodate)}" if isodate
         
     | 
| 
      
 18 
     | 
    
         
            +
                  #reference += " (#{@all_parts_lbl.downcase})" if allparts&.text == "true"
         
     | 
| 
      
 19 
     | 
    
         
            +
                  docid_prefix(prefix, reference)
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                def docid_prefix(prefix, docid)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  docid = "#{prefix} #{docid}" unless omit_docid_prefix(prefix)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  docid
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                def omit_docid_prefix(prefix)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  return true if prefix.nil? || prefix.empty?
         
     | 
| 
      
 29 
     | 
    
         
            +
                  return ["ISO"].include? prefix
         
     | 
| 
       19 
30 
     | 
    
         
             
                end
         
     | 
| 
       20 
31 
     | 
    
         | 
| 
       21 
32 
     | 
    
         
             
                def date_note_process(b, ref)
         
     | 
| 
         @@ -58,8 +69,9 @@ module IsoDoc::Function 
     | 
|
| 
       58 
69 
     | 
    
         
             
                  end
         
     | 
| 
       59 
70 
     | 
    
         
             
                end
         
     | 
| 
       60 
71 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
                def ref_entry_code(r, ordinal, t)
         
     | 
| 
       62 
     | 
    
         
            -
                   
     | 
| 
      
 72 
     | 
    
         
            +
                def ref_entry_code(r, ordinal, prefix, t)
         
     | 
| 
      
 73 
     | 
    
         
            +
                  t = docid_prefix(prefix, t)
         
     | 
| 
      
 74 
     | 
    
         
            +
                  if /^\d+$/.match(t) && !prefix
         
     | 
| 
       63 
75 
     | 
    
         
             
                    prefix_bracketed_ref(r, t)
         
     | 
| 
       64 
76 
     | 
    
         
             
                  else
         
     | 
| 
       65 
77 
     | 
    
         
             
                    prefix_bracketed_ref(r, ordinal)
         
     | 
| 
         @@ -78,7 +90,8 @@ module IsoDoc::Function 
     | 
|
| 
       78 
90 
     | 
    
         
             
                  list.p **attr_code(iso_bibitem_entry_attrs(b, bibliography)) do |r|
         
     | 
| 
       79 
91 
     | 
    
         
             
                    if bibliography
         
     | 
| 
       80 
92 
     | 
    
         
             
                      id = docid_l10n(b.at(ns("./docidentifier")).text.gsub(/[\[\]]/, ""))
         
     | 
| 
       81 
     | 
    
         
            -
                       
     | 
| 
      
 93 
     | 
    
         
            +
                      prefix = b&.at(ns("./docidentifier/@type"))&.text
         
     | 
| 
      
 94 
     | 
    
         
            +
                      ref_entry_code(r, ordinal, prefix, id)
         
     | 
| 
       82 
95 
     | 
    
         
             
                    else
         
     | 
| 
       83 
96 
     | 
    
         
             
                      r << "#{iso_bibitem_ref_code(b)}, "
         
     | 
| 
       84 
97 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -166,25 +179,28 @@ module IsoDoc::Function 
     | 
|
| 
       166 
179 
     | 
    
         
             
                  end
         
     | 
| 
       167 
180 
     | 
    
         
             
                end
         
     | 
| 
       168 
181 
     | 
    
         | 
| 
       169 
     | 
    
         
            -
                def format_ref(ref, isopub, date, allparts)
         
     | 
| 
      
 182 
     | 
    
         
            +
                def format_ref(ref, prefix, isopub, date, allparts)
         
     | 
| 
       170 
183 
     | 
    
         
             
                  if isopub
         
     | 
| 
       171 
     | 
    
         
            -
                    if date
         
     | 
| 
       172 
     | 
    
         
            -
                      on = date.at(ns("./on"))
         
     | 
| 
       173 
     | 
    
         
            -
                      ref += on&.text == "--" ? ":--" : ":#{date_range(date)}"
         
     | 
| 
       174 
     | 
    
         
            -
                      ref += " (all parts)" if allparts
         
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
      
 184 
     | 
    
         
            +
                    #if date
         
     | 
| 
      
 185 
     | 
    
         
            +
                      #on = date.at(ns("./on"))
         
     | 
| 
      
 186 
     | 
    
         
            +
                      #ref += on&.text == "--" ? ":--" : "" # ":#{date_range(date)}"
         
     | 
| 
      
 187 
     | 
    
         
            +
                      #ref += " (all parts)" if allparts
         
     | 
| 
      
 188 
     | 
    
         
            +
                     # ref = docid_prefix(prefix, ref)
         
     | 
| 
      
 189 
     | 
    
         
            +
                    #end
         
     | 
| 
       176 
190 
     | 
    
         
             
                  end
         
     | 
| 
       177 
     | 
    
         
            -
             
     | 
| 
      
 191 
     | 
    
         
            +
                      ref = docid_prefix(prefix, ref)
         
     | 
| 
      
 192 
     | 
    
         
            +
                  return "[#{ref}]" if /^\d+$/.match(ref) && !prefix && !/^\[.*\]$/.match(ref)
         
     | 
| 
       178 
193 
     | 
    
         
             
                  ref
         
     | 
| 
       179 
194 
     | 
    
         
             
                end
         
     | 
| 
       180 
195 
     | 
    
         | 
| 
       181 
196 
     | 
    
         
             
                def reference_names(ref)
         
     | 
| 
       182 
197 
     | 
    
         
             
                  isopub = ref.at(ns(ISO_PUBLISHER_XPATH))
         
     | 
| 
       183 
198 
     | 
    
         
             
                  docid = ref.at(ns("./docidentifier"))
         
     | 
| 
      
 199 
     | 
    
         
            +
                  prefix = ref.at(ns("./docidentifier/@type"))
         
     | 
| 
       184 
200 
     | 
    
         
             
                  # return ref_names(ref) unless docid
         
     | 
| 
       185 
201 
     | 
    
         
             
                  date = ref.at(ns("./date[@type = 'published']"))
         
     | 
| 
       186 
202 
     | 
    
         
             
                  allparts = ref.at(ns("./allparts"))
         
     | 
| 
       187 
     | 
    
         
            -
                  reference = format_ref(docid_l10n(docid.text), isopub, date, allparts)
         
     | 
| 
      
 203 
     | 
    
         
            +
                  reference = format_ref(docid_l10n(docid.text), prefix&.text, isopub, date, allparts)
         
     | 
| 
       188 
204 
     | 
    
         
             
                  @anchors[ref["id"]] = { xref: reference }
         
     | 
| 
       189 
205 
     | 
    
         
             
                end
         
     | 
| 
       190 
206 
     | 
    
         | 
    
        data/lib/isodoc/version.rb
    CHANGED
    
    
    
        data/spec/isodoc/ref_spec.rb
    CHANGED
    
    | 
         @@ -15,7 +15,7 @@ RSpec.describe IsoDoc do 
     | 
|
| 
       15 
15 
     | 
    
         
             
                <bibliography><references id="_normative_references" obligation="informative"><title>Normative References</title>
         
     | 
| 
       16 
16 
     | 
    
         
             
            <bibitem id="ISO712" type="standard">
         
     | 
| 
       17 
17 
     | 
    
         
             
              <title format="text/plain">Cereals and cereal products</title>
         
     | 
| 
       18 
     | 
    
         
            -
              <docidentifier>ISO 712</docidentifier>
         
     | 
| 
      
 18 
     | 
    
         
            +
              <docidentifier type="ISO">ISO 712</docidentifier>
         
     | 
| 
       19 
19 
     | 
    
         
             
              <contributor>
         
     | 
| 
       20 
20 
     | 
    
         
             
                <role type="publisher"/>
         
     | 
| 
       21 
21 
     | 
    
         
             
                <organization>
         
     | 
| 
         @@ -25,7 +25,7 @@ RSpec.describe IsoDoc do 
     | 
|
| 
       25 
25 
     | 
    
         
             
            </bibitem>
         
     | 
| 
       26 
26 
     | 
    
         
             
            <bibitem id="ISO16634" type="standard">
         
     | 
| 
       27 
27 
     | 
    
         
             
              <title format="text/plain">Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs</title>
         
     | 
| 
       28 
     | 
    
         
            -
              <docidentifier>ISO 16634</docidentifier>
         
     | 
| 
      
 28 
     | 
    
         
            +
              <docidentifier type="ISO">ISO 16634:-- (all parts)</docidentifier>
         
     | 
| 
       29 
29 
     | 
    
         
             
              <date type="published"><on>--</on></date>
         
     | 
| 
       30 
30 
     | 
    
         
             
              <contributor>
         
     | 
| 
       31 
31 
     | 
    
         
             
                <role type="publisher"/>
         
     | 
| 
         @@ -38,7 +38,7 @@ RSpec.describe IsoDoc do 
     | 
|
| 
       38 
38 
     | 
    
         
             
            </bibitem>
         
     | 
| 
       39 
39 
     | 
    
         
             
            <bibitem id="ISO20483" type="standard">
         
     | 
| 
       40 
40 
     | 
    
         
             
              <title format="text/plain">Cereals and pulses</title>
         
     | 
| 
       41 
     | 
    
         
            -
              <docidentifier>ISO 20483</docidentifier>
         
     | 
| 
      
 41 
     | 
    
         
            +
              <docidentifier type="ISO">ISO 20483:2013-2014</docidentifier>
         
     | 
| 
       42 
42 
     | 
    
         
             
              <date type="published"><from>2013</from><to>2014</to></date>
         
     | 
| 
       43 
43 
     | 
    
         
             
              <contributor>
         
     | 
| 
       44 
44 
     | 
    
         
             
                <role type="publisher"/>
         
     | 
| 
         @@ -49,14 +49,14 @@ RSpec.describe IsoDoc do 
     | 
|
| 
       49 
49 
     | 
    
         
             
            </bibitem>
         
     | 
| 
       50 
50 
     | 
    
         
             
            <bibitem id="ref1">
         
     | 
| 
       51 
51 
     | 
    
         
             
              <formattedref format="application/x-isodoc+xml"><smallcap>Standard No I.C.C 167</smallcap>. <em>Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method</em> (see <link target="http://www.icc.or.at"/>)</formattedref>
         
     | 
| 
       52 
     | 
    
         
            -
              <docidentifier> 
     | 
| 
      
 52 
     | 
    
         
            +
              <docidentifier type="ICC">167</docidentifier>
         
     | 
| 
       53 
53 
     | 
    
         
             
            </bibitem>
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
55 
     | 
    
         
             
            </references><references id="_bibliography" obligation="informative">
         
     | 
| 
       56 
56 
     | 
    
         
             
              <title>Bibliography</title>
         
     | 
| 
       57 
57 
     | 
    
         
             
            <bibitem id="ISO3696" type="standard">
         
     | 
| 
       58 
58 
     | 
    
         
             
              <title format="text/plain">Water for analytical laboratory use</title>
         
     | 
| 
       59 
     | 
    
         
            -
              <docidentifier>ISO 3696</docidentifier>
         
     | 
| 
      
 59 
     | 
    
         
            +
              <docidentifier type="ISO">ISO 3696</docidentifier>
         
     | 
| 
       60 
60 
     | 
    
         
             
              <contributor>
         
     | 
| 
       61 
61 
     | 
    
         
             
                <role type="publisher"/>
         
     | 
| 
       62 
62 
     | 
    
         
             
                <organization>
         
     | 
| 
         @@ -70,7 +70,7 @@ RSpec.describe IsoDoc do 
     | 
|
| 
       70 
70 
     | 
    
         
             
            </bibitem>
         
     | 
| 
       71 
71 
     | 
    
         
             
            <bibitem id="ref11">
         
     | 
| 
       72 
72 
     | 
    
         
             
              <formattedref format="application/x-isodoc+xml"><smallcap>Standard No I.C.C 167</smallcap>. <em>Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method</em> (see <link target="http://www.icc.or.at"/>)</formattedref>
         
     | 
| 
       73 
     | 
    
         
            -
              <docidentifier> 
     | 
| 
      
 73 
     | 
    
         
            +
              <docidentifier type="IETF">RFC 10</docidentifier>
         
     | 
| 
       74 
74 
     | 
    
         
             
            </bibitem>
         
     | 
| 
       75 
75 
     | 
    
         | 
| 
       76 
76 
     | 
    
         | 
| 
         @@ -95,7 +95,7 @@ RSpec.describe IsoDoc do 
     | 
|
| 
       95 
95 
     | 
    
         
             
                             <p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
         
     | 
| 
       96 
96 
     | 
    
         
             
                             <p id="ISO712" class="NormRef">ISO 712, <i> Cereals and cereal products</i></p>
         
     | 
| 
       97 
97 
     | 
    
         
             
                             <p id="ISO16634" class="NormRef">ISO 16634:-- (all parts)<a rel="footnote" href="#fn:1" epub:type="footnote"><sup>1</sup></a>, <i> Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs</i></p>
         
     | 
| 
       98 
     | 
    
         
            -
                             <p id="ISO20483" class="NormRef">ISO 20483:2013 
     | 
| 
      
 98 
     | 
    
         
            +
                             <p id="ISO20483" class="NormRef">ISO 20483:2013-2014, <i> Cereals and pulses</i></p>
         
     | 
| 
       99 
99 
     | 
    
         
             
                             <p id="ref1" class="NormRef">ICC 167, <span style="font-variant:small-caps;">Standard No I.C.C 167</span>. <i>Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method</i> (see <a href="http://www.icc.or.at">http://www.icc.or.at</a>)</p>
         
     | 
| 
       100 
100 
     | 
    
         
             
                           </div>
         
     | 
| 
       101 
101 
     | 
    
         
             
                           <br/>
         
     | 
| 
         @@ -103,7 +103,7 @@ RSpec.describe IsoDoc do 
     | 
|
| 
       103 
103 
     | 
    
         
             
                             <h1 class="Section3">Bibliography</h1>
         
     | 
| 
       104 
104 
     | 
    
         
             
                             <p id="ISO3696" class="Biblio">[1]  ISO 3696, <i> Water for analytical laboratory use</i></p>
         
     | 
| 
       105 
105 
     | 
    
         
             
                             <p id="ref10" class="Biblio">[10]  <span style="font-variant:small-caps;">Standard No I.C.C 167</span>. <i>Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method</i> (see <a href="http://www.icc.or.at">http://www.icc.or.at</a>)</p>
         
     | 
| 
       106 
     | 
    
         
            -
                             <p id="ref11" class="Biblio">[3]  IETF RFC 10 
     | 
| 
      
 106 
     | 
    
         
            +
                             <p id="ref11" class="Biblio">[3]  IETF RFC 10, <span style="font-variant:small-caps;">Standard No I.C.C 167</span>. <i>Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method</i> (see <a href="http://www.icc.or.at">http://www.icc.or.at</a>)</p>
         
     | 
| 
       107 
107 
     | 
    
         
             
                           </div>
         
     | 
| 
       108 
108 
     | 
    
         
             
                           <aside id="fn:1" class="footnote">
         
     | 
| 
       109 
109 
     | 
    
         
             
                     <p>Under preparation. (Stage at the time of publication ISO/DIS 16634)</p>
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: isodoc
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.9.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Ribose Inc.
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2018-09- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2018-09-04 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: asciimath
         
     |