Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew2net committed Nov 15, 2023
1 parent 03cde05 commit ace5ec7
Show file tree
Hide file tree
Showing 47 changed files with 554 additions and 545 deletions.
16 changes: 9 additions & 7 deletions lib/relaton_iso/scrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,23 +389,25 @@ def script(lang)
def fetch_dates(doc, ref) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/MethodLength
dates = []
%r{^[^\s]+\s[\d-]+:(?<ref_date_str>\d{4})} =~ ref
pub_date_str = doc.xpath("//span[@itemprop='releaseDate']").text
pub_date_str = doc.at("//span[@itemprop='releaseDate']")
if ref_date_str
ref_date = Date.strptime ref_date_str, "%Y"
if pub_date_str.empty?
if pub_date_str.nil?
dates << { type: "published", on: ref_date_str }
else
pub_date = Date.strptime pub_date_str, "%Y"
pub_date = Date.strptime pub_date_str.text, "%Y"
if pub_date.year > ref_date.year
dates << { type: "published", on: ref_date_str }
dates << { type: "updated", on: pub_date_str }
dates << { type: "updated", on: pub_date_str.text }
else
dates << { type: "published", on: pub_date_str }
dates << { type: "published", on: pub_date_str.text }
end
end
elsif !pub_date_str.empty?
dates << { type: "published", on: pub_date_str }
elsif pub_date_str
dates << { type: "published", on: pub_date_str.text }
end
corr_data = doc.at "//span[@itemprop='dateModified']"
dates << { type: "corrected", on: corr_data.text } if corr_data
dates
end

Expand Down
2 changes: 1 addition & 1 deletion lib/relaton_iso/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module RelatonIso
VERSION = "1.16.3"
VERSION = "1.16.4"
end
2 changes: 1 addition & 1 deletion spec/fixtures/all_parts.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<bibdata type="standard" schema-version="v1.2.4">
<bibdata type="standard" schema-version="v1.2.5">
<fetched>2023-08-25</fetched>
<title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information</title>
<title type="title-main" format="text/plain" language="en" script="Latn">Metadata</title>
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/hit.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<bibdata type="standard" schema-version="v1.2.4">
<bibdata type="standard" schema-version="v1.2.5">
<fetched>2023-07-15</fetched>
<title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information</title>
<title type="title-main" format="text/plain" language="en" script="Latn">Metadata</title>
Expand Down
14 changes: 7 additions & 7 deletions spec/fixtures/hits.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<documents>
<bibitem id="ISO19115-2-2019" type="standard" schema-version="v1.2.4">
<bibitem id="ISO19115-2-2019" type="standard" schema-version="v1.2.5">
<fetched>2023-10-19</fetched>
<title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information</title>
<title type="title-main" format="text/plain" language="en" script="Latn">Metadata</title>
Expand Down Expand Up @@ -61,7 +61,7 @@
</relation>
<place>Geneva</place>
</bibitem>
<bibitem id="ISO19115-2-2019/Amd1-2022" type="standard" schema-version="v1.2.4">
<bibitem id="ISO19115-2-2019/Amd1-2022" type="standard" schema-version="v1.2.5">
<fetched>2023-10-19</fetched>
<title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information</title>
<title type="title-main" format="text/plain" language="en" script="Latn">Metadata</title>
Expand Down Expand Up @@ -110,7 +110,7 @@
</copyright>
<place>Geneva</place>
</bibitem>
<bibitem id="ISO19115-3-2023" type="standard" schema-version="v1.2.4">
<bibitem id="ISO19115-3-2023" type="standard" schema-version="v1.2.5">
<fetched>2023-10-19</fetched>
<title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information</title>
<title type="title-main" format="text/plain" language="en" script="Latn">Metadata</title>
Expand Down Expand Up @@ -170,7 +170,7 @@ Le présent document décrit la procédure utilisée pour générer des schémas
</relation>
<place>Geneva</place>
</bibitem>
<bibitem id="ISO/TS19157-2-2016" type="standard" schema-version="v1.2.4">
<bibitem id="ISO/TS19157-2-2016" type="standard" schema-version="v1.2.5">
<fetched>2023-10-19</fetched>
<title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information </title>
<title type="title-main" format="text/plain" language="en" script="Latn">Data quality</title>
Expand Down Expand Up @@ -218,7 +218,7 @@ Le présent document décrit la procédure utilisée pour générer des schémas
</copyright>
<place>Geneva</place>
</bibitem>
<bibitem id="ISO19115-2-2009" type="standard" schema-version="v1.2.4">
<bibitem id="ISO19115-2-2009" type="standard" schema-version="v1.2.5">
<fetched>2023-10-19</fetched>
<title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information</title>
<title type="title-main" format="text/plain" language="en" script="Latn">Metadata</title>
Expand Down Expand Up @@ -274,7 +274,7 @@ Le présent document décrit la procédure utilisée pour générer des schémas
</relation>
<place>Geneva</place>
</bibitem>
<bibitem id="ISO/TS19115-3-2016" type="standard" schema-version="v1.2.4">
<bibitem id="ISO/TS19115-3-2016" type="standard" schema-version="v1.2.5">
<fetched>2023-10-19</fetched>
<title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information</title>
<title type="title-main" format="text/plain" language="en" script="Latn"> Metadata</title>
Expand Down Expand Up @@ -340,7 +340,7 @@ This implementation model does not alter the semantics of the target conceptual
</relation>
<place>Geneva</place>
</bibitem>
<bibitem id="ISO/TS19139-2-2012" type="standard" schema-version="v1.2.4">
<bibitem id="ISO/TS19139-2-2012" type="standard" schema-version="v1.2.5">
<fetched>2023-10-19</fetched>
<title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information</title>
<title type="title-main" format="text/plain" language="en" script="Latn">Metadata</title>
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/iso_19115_en.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<bibitem id="ISO19115" type="standard" schema-version="v1.2.4">
<bibitem id="ISO19115" type="standard" schema-version="v1.2.5">
<fetched>2023-05-10</fetched>
<title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information</title>
<title type="title-main" format="text/plain" language="en" script="Latn">Metadata</title>
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/iso_19115_fr.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<bibitem id="ISO19115" type="standard" schema-version="v1.2.4">
<bibitem id="ISO19115" type="standard" schema-version="v1.2.5">
<fetched>2023-05-10</fetched>
<title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information</title>
<title type="title-main" format="text/plain" language="en" script="Latn">Metadata</title>
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/iso_19115_keep_year.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<bibitem id="ISO19115-1" type="standard" schema-version="v1.2.4">
<bibitem id="ISO19115-1" type="standard" schema-version="v1.2.5">
<fetched>2023-07-15</fetched>
<title type="title-intro" format="text/plain" language="en" script="Latn">Geographic information</title>
<title type="title-main" format="text/plain" language="en" script="Latn">Metadata</title>
Expand Down
7 changes: 7 additions & 0 deletions spec/relaton_iso/iso_bibliography_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,13 @@
expect(result.docidentifier[0].id).to eq "ISO/IEC 27001:2022"
end

it "doc with corrected date", vcr: "iso_iec_2382_2015" do
result = RelatonIso::IsoBibliography.get "ISO/IEC 2382:2015"
expect(result.docidentifier[0].id).to eq "ISO/IEC 2382:2015"
corrected_date = result.date.detect { |d| d.type == "corrected" }
expect(corrected_date.on.to_s).to eq "2022-10"
end

context "try to fetch stages" do
it "ISO" do
VCR.use_cassette "iso_22934" do
Expand Down
14 changes: 7 additions & 7 deletions spec/vcr_cassettes/git_hub_not_found.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions spec/vcr_cassettes/hit.yml

Large diffs are not rendered by default.

160 changes: 80 additions & 80 deletions spec/vcr_cassettes/hit_collection_xml.yml

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions spec/vcr_cassettes/hits.yml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions spec/vcr_cassettes/iso_00000_2014.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions spec/vcr_cassettes/iso_10844_2014_awi_amd_1.yml

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions spec/vcr_cassettes/iso_123.yml

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions spec/vcr_cassettes/iso_125_2020.yml

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions spec/vcr_cassettes/iso_16063_1_1999_cd_amd_2.yml

Large diffs are not rendered by default.

Loading

0 comments on commit ace5ec7

Please sign in to comment.