Skip to content

Commit

Permalink
Finish 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 31, 2016
2 parents 1078d99 + e9d598c commit 5df18e7
Show file tree
Hide file tree
Showing 18 changed files with 491 additions and 92 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/coverage/
Gemfile.lock
/.byebug_history
/spec/w3c-csvw/
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ script: "bundle exec rspec spec"
env:
- CI=true
rvm:
- 2.0
- 2.1
- 2.2.4
- 2.3.0
- jruby-9.0.4.0
- rbx-2
- 2.2.6
- 2.3.3
- 2.4.0
- jruby
- rbx
cache: bundler
sudo: false
matrix:
allow_failures:
- rvm: rbx-2
- rvm: rbx
- rvm: jruby

4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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 'json-ld', github: "ruby-rdf/json-ld", branch: "develop"
gem 'rdf-aggregate-repo', github: "ruby-rdf/rdf-aggregate-repo", branch: "develop"
Expand All @@ -14,11 +15,10 @@ group :development do
gem 'rdf-vocab', github: "ruby-rdf/rdf-vocab", branch: "develop"
gem 'sparql', github: "ruby-rdf/sparql", branch: "develop"
gem 'sparql-client', github: "ruby-rdf/sparql-client", branch: "develop"
gem 'sxp', github: "gkellogg/sxp-ruby", branch: "develop"
gem 'sxp', github: "dryruby/sxp.rb", branch: "develop"
end

group :debug do
gem "wirble"
gem "byebug", platforms: :mri
end

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ Full documentation available on [RubyDoc](http://rubydoc.info/gems/rdf-tabular/f
* {RDF::Tabular::Reader}

## Dependencies
* [Ruby](http://ruby-lang.org/) (>= 2.0)
* [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)

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.0
1.0.0
5 changes: 5 additions & 0 deletions dependencyci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
platform:
Rubygems:
rdf-isomorphic:
tests:
unmaintained: skip
1 change: 1 addition & 0 deletions examples/bpotw.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Identifier,Name,Description,Latitude,Longitude,ZONE,URL
53 changes: 53 additions & 0 deletions examples/bpotw.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"@context": ["http://www.w3.org/ns/csvw", {"@language": "en"}],
"url": "bpotw.csv",
"dc:title": "CSV distribution of bus-stops-2015-05-05 dataset",
"dcat:keyword": ["bus", "stop", "mobility"],
"dc:publisher": {
"schema:name": "Transport Agency of MyCity",
"schema:url": {"@id": "http://example.org"}
},
"dc:license": {"@id": "http://opendefinition.org/licenses/cc-by/"},
"dc:modified": {"@value": "2015-05-05", "@type": "xsd:date"},
"tableSchema": {
"columns": [{
"name": "stop_id",
"titles": ["Identifier"],
"dc:description": "An identifier for the bus stop.",
"datatype": "string",
"required": true
}, {
"name": "stop_name",
"titles": ["Name"],
"dc:description": "The name of the bus stop.",
"datatype": "string"
}, {
"name": "stop_desc",
"titles": ["Description"],
"dc:description": "A description for the bus stop.",
"datatype": "string"
}, {
"name": "stop_lat",
"titles": ["Latitude"],
"dc:description": "The latitude of the bus stop.",
"datatype": "number"
}, {
"name": "stop_long",
"titles": ["Longitude"],
"dc:description": "The longitude of the bus stop.",
"datatype": "number"
}, {
"name": "zone_id",
"titles": ["ZONE"],
"dc:description": "An identifier for the zone where the bus stop is located.",
"datatype": "string"
},
{
"name": "stop_url",
"titles": ["URL"],
"dc:description": "URL that identifies the bus stop.",
"datatype": "string"
}],
"primaryKey": "stop_id"
}
}
2 changes: 2 additions & 0 deletions examples/niklas.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
role
"aut,li"
11 changes: 11 additions & 0 deletions examples/niklas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"@context": "http://www.w3.org/ns/csvw",
"url": "niklas.csv",
"tableSchema": {
"columns": [{
"name": "role",
"separator": ",",
"valueUrl": "http://id.loc.gov/vocabulary/relators/{/role*}"
}]
}
}
4 changes: 2 additions & 2 deletions lib/rdf/tabular/format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ module RDF::Tabular
#
# @see http://www.w3.org/TR/rdf-testcases/#ntriples
class Format < RDF::Format
content_type 'text/csv',
content_type 'text/csv;q=0.4',
extensions: [:csv, :tsv],
alias: %w{
text/tab-separated-values
text/tab-separated-values;q=0.4
application/csvm+json
}
content_encoding 'utf-8'
Expand Down
33 changes: 7 additions & 26 deletions lib/rdf/tabular/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2171,33 +2171,13 @@ def value_matching_datatype(value, datatype, expanded_dt, language)
decimalChar = format["decimalChar"] || '.'
pattern = format["pattern"]

if !datatype.parse_uax35_number(pattern, value, groupChar || ",", decimalChar)
begin
value = datatype.parse_uax35_number(pattern, value, groupChar || ",", decimalChar)
rescue UAX35::ParseError
value_errors << "#{value} does not match numeric pattern #{pattern ? pattern.inspect : 'default'}"
end

# pattern facet failed
value_errors << "#{value} has repeating #{groupChar.inspect}" if groupChar && value.include?(groupChar*2)
value = value.gsub(groupChar || ',', '')
value = value.sub(decimalChar, '.')

# Extract percent or per-mille sign
percent = permille = false
case value
when /%/
value = value.sub('%', '')
percent = true
when /‰/
value = value.sub('‰', '')
permille = true
end

lit = RDF::Literal(value, datatype: expanded_dt)
if percent || permille
o = lit.object
o = o / 100 if percent
o = o / 1000 if permille
lit = RDF::Literal(o, datatype: expanded_dt)
end

if !lit.plain? && datatype.minimum && lit < datatype.minimum
value_errors << "#{value} < minimum #{datatype.minimum}"
Expand Down Expand Up @@ -2238,10 +2218,11 @@ def value_matching_datatype(value, datatype, expanded_dt, language)
end
end
when :date, :time, :dateTime, :dateTimeStamp, :datetime
if value = datatype.parse_uax35_date(format, value)
begin
value = datatype.parse_uax35_date(format, value)
lit = RDF::Literal(value, datatype: expanded_dt)
else
value_errors << "#{original_value} does not match format #{format}"
rescue UAX35::ParseError
value_errors << "#{value} does not match format #{format}"
end
when :duration, :dayTimeDuration, :yearMonthDuration
# SPEC CONFUSION: surely format also includes that for other duration types?
Expand Down
Loading

0 comments on commit 5df18e7

Please sign in to comment.