diff --git a/.travis.yml b/.travis.yml index 9e1f468..b6e788e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,19 @@ language: ruby bundler_args: --without debug script: "bundle exec rspec spec" +before_install: + - 'gem update --system --conservative || (gem i "rubygems-update:~>2.7" --no-document && update_rubygems)' + - 'gem update bundler --conservative' env: - - CI=true + global: + - CI=true + - NOKOGIRI_USE_SYSTEM_LIBRARIES=true rvm: - - 2.2 + - 2.2.2 - 2.3 - 2.4 + - 2.5 + - 2.6 - jruby-9 - rbx-3 cache: bundler diff --git a/Gemfile b/Gemfile index 9133985..6c412f4 100644 --- a/Gemfile +++ b/Gemfile @@ -5,8 +5,8 @@ gem 'rdf', github: "ruby-rdf/rdf", branch: "develop" gem 'rdf-xsd', github: "ruby-rdf/rdf-xsd", branch: "develop" group :development do - #gem 'linkeddata', github: "ruby-rdf/linkeddata", branch: "develop" - gem 'ebnf', github: "gkellogg/ebnf", branch: "develop" + gem 'linkeddata', github: "ruby-rdf/linkeddata", branch: "develop" + gem 'ebnf', github: "dryruby/ebnf", branch: "develop" gem 'json-ld', github: "ruby-rdf/json-ld", branch: "develop" gem 'rdf-aggregate-repo', github: "ruby-rdf/rdf-aggregate-repo", branch: "develop" gem 'rdf-isomorphic', github: "ruby-rdf/rdf-isomorphic", branch: "develop" @@ -27,8 +27,3 @@ group :development, :test do gem 'coveralls', require: false gem 'psych', platforms: [:mri, :rbx] end - -platforms :rbx do - gem 'rubysl', '~> 2.0' - gem 'rubinius', '~> 2.0' -end diff --git a/README.md b/README.md index deefffd..a494e83 100644 --- a/README.md +++ b/README.md @@ -247,7 +247,9 @@ Example usage: rdf serialize https://raw.githubusercontent.com/ruby-rdf/rdf-tabular/develop/etc/doap.csv \ --output-format ttl rdf tabular-json --input-format tabular https://raw.githubusercontent.com/ruby-rdf/rdf-tabular/develop/etc/doap.csv - rdf validate https://raw.githubusercontent.com/ruby-rdf/rdf-tabular/develop/etc/doap.csv + rdf validate https://raw.githubusercontent.com/ruby-rdf/rdf-tabular/develop/etc/doap.csv --validate + +Note that the `--validate` option must be used with the `validate` (or other) command to detect parse-time errors in addition to validating any resulting RDF triples. ## RDF Reader RDF::Tabular also acts as a normal RDF reader, using the standard RDF.rb Reader interface: @@ -266,8 +268,8 @@ Full documentation available on [RubyDoc](http://rubydoc.info/gems/rdf-tabular/f ## Dependencies * [Ruby](http://ruby-lang.org/) (>= 2.2.2) -* [RDF.rb](http://rubygems.org/gems/rdf) (>= 2.0) -* [JSON](https://rubygems.org/gems/json) (>= 1.5) +* [RDF.rb](http://rubygems.org/gems/rdf) (~> 3.0) +* [JSON](https://rubygems.org/gems/json) (>= 2.0) ## Installation The recommended installation method is via [RubyGems](http://rubygems.org/). diff --git a/VERSION b/VERSION index c043eea..b1b25a5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.1 +2.2.2 diff --git a/examples/issue-9/all_contents.csv b/examples/issue-9/all_contents.csv new file mode 100644 index 0000000..c61f292 --- /dev/null +++ b/examples/issue-9/all_contents.csv @@ -0,0 +1,3 @@ +MS_ID,item +111,222 +888,999 diff --git a/examples/issue-9/all_contents.csv-metadata.json b/examples/issue-9/all_contents.csv-metadata.json new file mode 100644 index 0000000..b345a60 --- /dev/null +++ b/examples/issue-9/all_contents.csv-metadata.json @@ -0,0 +1,39 @@ +{ + "@context": "http://www.w3.org/ns/csvw", + "tables": [ + { + "url": "all_contents.csv", + "tableSchema": { + "aboutUrl": "{_row}", + "primaryKey": [ + "MS_ID", + "item" + ], + "columns": [ + {"name": "MS_ID", "titles": "MS_ID"}, + {"name": "item", "titles": "item"} + ], + "foreignKeys": [ + { + "columnReference": "MS_ID", + "reference": { + "resource": "all_manuscripts.csv", + "columnReference": "MS_ID" + } + } + ] + } + }, + { + "url": "all_manuscripts.csv", + "tableSchema": { + "aboutUrl": "{_row}", + "primaryKey": "MS_ID", + "columns": [ + {"name": "MS_ID", "titles": "MS_ID"}, + {"name": "man", "titles": "man"} + ] + } + } + ] +} \ No newline at end of file diff --git a/examples/issue-9/all_manuscripts.csv b/examples/issue-9/all_manuscripts.csv new file mode 100644 index 0000000..b4f1e67 --- /dev/null +++ b/examples/issue-9/all_manuscripts.csv @@ -0,0 +1,3 @@ +MS_ID,man +111,333 +555,666 diff --git a/lib/rdf/tabular/metadata.rb b/lib/rdf/tabular/metadata.rb index 87a3962..8a2d0a5 100644 --- a/lib/rdf/tabular/metadata.rb +++ b/lib/rdf/tabular/metadata.rb @@ -564,7 +564,7 @@ def validate! end ## - # Validate metadata, raising an error containing all errors detected during validation + # Validate metadata and content, raising an error containing all errors detected during validation # @raise [Error] Raise error if metadata has any unexpected properties # @return [self] def validate @@ -1042,7 +1042,7 @@ def verify_compatible!(other) if !ca.object.has_key?(:name) && !cb.object.has_key?(:name) && ta.empty? && tb.empty? true elsif ca.object.has_key?(:name) && cb.object.has_key?(:name) - raise Error, "Columns don't match on name: #{ca.name}, #{cb.name}" unless ca.name == cb.name + raise Error, "Column #{index + 1} doesn't match on name: #{ca.name || 'no name'}, #{cb.name || 'no name'}" unless ca.name == cb.name elsif @options[:validate] || !ta.empty? && !tb.empty? # If validating, column compatibility requires strict match between titles titles_match = case @@ -1066,10 +1066,10 @@ def verify_compatible!(other) true elsif !@options[:validate] # If not validating, columns don't match, but processing continues - log_warn "Columns don't match on titles: #{ca.titles.inspect} vs #{cb.titles.inspect}" + log_warn "Column #{index + 1} doesn't match on titles: #{Array(ta['und']).join(',').inspect} vs #{Array(tb['und']).join(',').inspect}" true else - raise Error, "Columns don't match on titles: #{ca.titles.inspect} vs #{cb.titles.inspect}" + raise Error, "Column #{index + 1} doesn't match on titles: #{Array(ta['und']).join(',').inspect} vs #{Array(tb['und']).join(',').inspect}" end end index += 1 @@ -1826,7 +1826,7 @@ def embedded_metadata(input, metadata, options = {}) row.xpath('th').map(&:content).each_with_index do |value, index| # Skip columns skipCols = skipColumns.to_i - next if index < skipCols + next if index < skipCols || value.to_s.empty? # Trim value value.lstrip! if %w(true start).include?(trim.to_s) @@ -1837,7 +1837,7 @@ def embedded_metadata(input, metadata, options = {}) column = columns[index - skipCols] ||= { "titles" => {lang => []}, } - column["titles"][lang] << value + column["titles"][lang] << value if value end end else @@ -1858,7 +1858,7 @@ def embedded_metadata(input, metadata, options = {}) Array(row_data).each_with_index do |value, index| # Skip columns skipCols = skipColumns.to_i - next if index < skipCols + next if index < skipCols || value.to_s.empty? # Trim value value.lstrip! if %w(true start).include?(trim.to_s) diff --git a/rdf-tabular.gemspec b/rdf-tabular.gemspec index c7e16da..6c2c427 100755 --- a/rdf-tabular.gemspec +++ b/rdf-tabular.gemspec @@ -19,33 +19,25 @@ Gem::Specification.new do |gem| gem.require_paths = %w(lib) gem.extensions = %w() gem.test_files = Dir.glob('spec/*.rb') + Dir.glob('spec/data/**') - gem.has_rdoc = false gem.required_ruby_version = '>= 2.2.2' gem.requirements = [] gem.add_runtime_dependency 'bcp47', '~> 0.3', '>= 0.3.3' - #gem.add_runtime_dependency 'rdf', '~> 3.0' - #gem.add_runtime_dependency 'rdf-vocab', '~> 3.0' - #gem.add_runtime_dependency 'rdf-xsd', '~> 3.0' + gem.add_runtime_dependency 'rdf', '~> 3.0' + gem.add_runtime_dependency 'rdf-vocab', '~> 3.0' + gem.add_runtime_dependency 'rdf-xsd', '~> 3.0' #gem.add_runtime_dependency 'json-ld', '~> 3.0' - gem.add_runtime_dependency 'rdf', '>= 2.2', '< 4.0' - gem.add_runtime_dependency 'rdf-vocab', '>= 2.2', '< 4.0' - gem.add_runtime_dependency 'rdf-xsd', '>= 2.2', '< 4.0' gem.add_runtime_dependency 'json-ld', '>= 2.1', '< 4.0' gem.add_runtime_dependency 'addressable', '~> 2.3' - gem.add_development_dependency 'nokogiri', '~> 1.6' + gem.add_development_dependency 'nokogiri', '~> 1.8' gem.add_development_dependency 'rspec', '~> 3.7' gem.add_development_dependency 'rspec-its', '~> 1.2' - #gem.add_development_dependency 'rdf-isomorphic', '~> 3.0' - #gem.add_development_dependency 'rdf-spec', '~> 3.0' - #gem.add_development_dependency 'rdf-turtle', '~> 3.0' - #gem.add_development_dependency 'sparql', '~> 3.0' - gem.add_development_dependency 'rdf-isomorphic', '>= 2.2', '< 4.0' - gem.add_development_dependency 'rdf-spec', '>= 2.2', '< 4.0' - gem.add_development_dependency 'rdf-turtle', '>= 2.2', '< 4.0' - gem.add_development_dependency 'sparql', '>= 2.2', '< 4.0' + gem.add_development_dependency 'rdf-isomorphic', '~> 3.0' + gem.add_development_dependency 'rdf-spec', '~> 3.0' + gem.add_development_dependency 'rdf-turtle', '~> 3.0' + gem.add_development_dependency 'sparql', '~> 3.0' gem.add_development_dependency 'webmock', '~> 3.0' - gem.add_development_dependency 'yard' , '~> 0.9' + gem.add_development_dependency 'yard' , '~> 0.9.12' gem.post_install_message = nil end