From 2712ac555c9e0735f0ef39b252faeb6a1141f939 Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Wed, 11 Sep 2024 11:56:41 +0800 Subject: [PATCH 1/4] feat: use new schemaLocation support in lutaml-model, fixes #9 --- Gemfile | 11 ++++++----- lib/ogc/gml/dictionary.rb | 2 -- ogc-gml.gemspec | 9 +-------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Gemfile b/Gemfile index 4972149..88210bc 100644 --- a/Gemfile +++ b/Gemfile @@ -5,8 +5,9 @@ source "https://rubygems.org" # Specify your gem's dependencies in ogc-gml.gemspec gemspec -gem "rake", "~> 13.0" - -gem "rspec", "~> 3.0" - -gem "rubocop", "~> 1.21" +gem "equivalent-xml" +gem "pry" +gem "rake" +gem "rspec" +gem "rubocop" +gem "xml-c14n" diff --git a/lib/ogc/gml/dictionary.rb b/lib/ogc/gml/dictionary.rb index 09ff426..f569c7f 100644 --- a/lib/ogc/gml/dictionary.rb +++ b/lib/ogc/gml/dictionary.rb @@ -21,13 +21,11 @@ class Dictionary < Lutaml::Model::Serializable attribute :remarks, :string attribute :dictionary_entry, DictionaryEntry, collection: true attribute :indirect_entry, IndirectEntry, collection: true - attribute :schema_location, :string xml do root "Dictionary" namespace "http://www.opengis.net/gml/3.2", "gml" - map_attribute "schemaLocation", to: :schema_location, prefix: "xsi", namespace: "http://www.w3.org/2001/XMLSchema-instance" map_attribute "id", to: :id, prefix: "gml", namespace: "http://www.opengis.net/gml/3.2" map_attribute "aggregationType", to: :aggregation_type, prefix: "gml", namespace: "http://www.opengis.net/gml/3.2" diff --git a/ogc-gml.gemspec b/ogc-gml.gemspec index 1230664..29a01a1 100644 --- a/ogc-gml.gemspec +++ b/ogc-gml.gemspec @@ -31,13 +31,6 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 2.7.0" - spec.add_runtime_dependency "lutaml-model" + spec.add_runtime_dependency "lutaml-model", "~> 0.3.10" spec.add_runtime_dependency "nokogiri" - - spec.add_development_dependency "equivalent-xml" - spec.add_development_dependency "pry", "~> 0.12.2" - spec.add_development_dependency "rake", "~> 13.0" - spec.add_development_dependency "rspec", "~> 3.11" - spec.add_development_dependency "rubocop", "~> 1.58" - spec.add_development_dependency "xml-c14n" end From 4b115c8aa8a672dd76ce922dbbe4c067ede78c5b Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Wed, 11 Sep 2024 11:56:58 +0800 Subject: [PATCH 2/4] chore: clean up spec description --- spec/ogc/gml/composite_curve_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/ogc/gml/composite_curve_spec.rb b/spec/ogc/gml/composite_curve_spec.rb index 94638ab..9e09b45 100644 --- a/spec/ogc/gml/composite_curve_spec.rb +++ b/spec/ogc/gml/composite_curve_spec.rb @@ -8,11 +8,11 @@ ).gsub("\t", " ") end - it "does something useful" do + it "round-trips CompositeCurve.xml" do output = Ogc::Gml::CompositeCurve.from_xml(input).to_xml( pretty: true, declaration: true, - encoding: "utf-8" + encoding: "utf-8", ) expect(output).to be_equivalent_to(input) From 6b08ee234175d7c9a64fb763ecf51395734e9f89 Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Wed, 11 Sep 2024 11:57:20 +0800 Subject: [PATCH 3/4] chore: rubocop --- .rubocop_todo.yml | 6 +++--- spec/ogc/gml/composite_curve_spec.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9ede9fd..632dec7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-08-30 12:07:56 UTC using RuboCop version 1.65.1. +# on 2024-09-11 03:57:05 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -24,10 +24,10 @@ Metrics/BlockLength: Style/Documentation: Enabled: false -# Offense count: 2 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma Style/TrailingCommaInArguments: Exclude: - - 'spec/ogc/gml/polygon_spec.rb' + - 'spec/ogc/gml/composite_curve_spec.rb' diff --git a/spec/ogc/gml/composite_curve_spec.rb b/spec/ogc/gml/composite_curve_spec.rb index 9e09b45..1272ba1 100644 --- a/spec/ogc/gml/composite_curve_spec.rb +++ b/spec/ogc/gml/composite_curve_spec.rb @@ -12,7 +12,7 @@ output = Ogc::Gml::CompositeCurve.from_xml(input).to_xml( pretty: true, declaration: true, - encoding: "utf-8", + encoding: "utf-8" ) expect(output).to be_equivalent_to(input) From 29510606aec8a6c4e452b1af7cafc18335c7fa17 Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Wed, 11 Sep 2024 12:07:53 +0800 Subject: [PATCH 4/4] fix: gmlring2.xml schemaLocation whitespace issue, fixes #9 --- .rubocop_todo.yml | 8 ++++---- spec/ogc/gml/polygon_spec.rb | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 632dec7..c80fce9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-09-11 03:57:05 UTC using RuboCop version 1.66.1. +# on 2024-09-11 04:07:13 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -17,17 +17,17 @@ Gemspec/RequiredRubyVersion: # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. # AllowedMethods: refine Metrics/BlockLength: - Max: 37 + Max: 40 # Offense count: 323 # Configuration parameters: AllowedConstants. Style/Documentation: Enabled: false -# Offense count: 1 +# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma Style/TrailingCommaInArguments: Exclude: - - 'spec/ogc/gml/composite_curve_spec.rb' + - 'spec/ogc/gml/polygon_spec.rb' diff --git a/spec/ogc/gml/polygon_spec.rb b/spec/ogc/gml/polygon_spec.rb index 7c61723..5d7f5e2 100644 --- a/spec/ogc/gml/polygon_spec.rb +++ b/spec/ogc/gml/polygon_spec.rb @@ -31,8 +31,11 @@ def file_contents(filename) %w[ gmlring2.xml ].each do |filename| - xit "round-trips #{filename}" do - input = file_contents(filename) + it "round-trips #{filename}" do + input = file_contents(filename).sub( + "xsi:schemaLocation=\"http://www.opengis.net/gml/3.2\n http://schemas.opengis.net/gml/3.2.1/gml.xsd\"", + " " + ) output = Ogc::Gml::Polygon.from_xml(input).to_xml( pretty: true, declaration: true,