Skip to content

Commit ab9939b

Browse files
committed
Initial Commit.
0 parents  commit ab9939b

11 files changed

+731
-0
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Gregg Kellogg <gregg@greggkellogg.net>

Gemfile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
source "https://rubygems.org"
2+
3+
gemspec
4+
gem 'rdf', git: "git://github.com/ruby-rdf/rdf.git", branch: "develop"
5+
gem 'rdf-spec', git: "git://github.com/ruby-rdf/rdf-spec.git", branch: "develop"
6+
gem 'bcp47'
7+
8+
group :development do
9+
gem "linkeddata"
10+
end
11+
12+
group :debug do
13+
gem "wirble"
14+
gem "byebug", platforms: [:mri_20, :mri_21]
15+
end
16+
17+
platforms :rbx do
18+
gem 'rubysl', '~> 2.0'
19+
gem 'rubinius', '~> 2.0'
20+
end

README.md

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Tabular Data RDF Reader and JSON serializer
2+
3+
[RDF-CSV][] reader for [RDF.rb][] and fully JSON serializer.
4+
5+
[![Gem Version](https://badge.fury.io/rb/rdf-csv.png)](http://badge.fury.io/rb/rdf-csv)
6+
[![Build Status](https://secure.travis-ci.org/ruby-rdf/rdf-csv.png?branch=master)](http://travis-ci.org/ruby-rdf/rdf-csv)
7+
8+
## Features
9+
10+
RDF::CSV parses and serializes CSV or other Tabular Data into [RDF][] and JSON.
11+
12+
Install with `gem install rdf-csv`
13+
14+
## Examples
15+
16+
require 'rubygems'
17+
require 'rdf/csv
18+
19+
## RDF Reader
20+
{RDF::CSV} also acts as a normal RDF reader, using the standard RDF.rb Reader interface:
21+
22+
graph = RDF::Graph.load("etc/doap.csv")
23+
24+
25+
## Documentation
26+
Full documentation available on [RubyDoc](http://rubydoc.info/gems/rdf-csv/file/README.md)
27+
28+
29+
### Principal Classes
30+
* {RDF::CSV}
31+
* {RDF::CSV::JSON}
32+
* {RDF::CSV::Format}
33+
* {RDF::CSV::Metadata}
34+
* {RDF::CSV::Reader}
35+
36+
## Dependencies
37+
* [Ruby](http://ruby-lang.org/) (>= 1.9.2)
38+
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 1.0)
39+
* [JSON](https://rubygems.org/gems/json) (>= 1.5)
40+
41+
## Installation
42+
The recommended installation method is via [RubyGems](http://rubygems.org/).
43+
To install the latest official release of the `RDF::CSV` gem, do:
44+
45+
% [sudo] gem install rdf-csv
46+
47+
## Mailing List
48+
* <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
49+
50+
## Author
51+
* [Gregg Kellogg](http://github.com/gkellogg) - <http://greggkellogg.net/>
52+
53+
## Contributing
54+
* Do your best to adhere to the existing coding conventions and idioms.
55+
* Don't use hard tabs, and don't leave trailing whitespace on any line.
56+
* Do document every method you add using [YARD][] annotations. Read the
57+
[tutorial][YARD-GS] or just look at the existing code for examples.
58+
* Don't touch the `json-ld.gemspec`, `VERSION` or `AUTHORS` files. If you need to
59+
change them, do so on your private branch only.
60+
* Do feel free to add yourself to the `CREDITS` file and the corresponding
61+
list in the the `README`. Alphabetical order applies.
62+
* Do note that in order for us to merge any non-trivial changes (as a rule
63+
of thumb, additions larger than about 15 lines of code), we need an
64+
explicit [public domain dedication][PDD] on record from you.
65+
66+
License
67+
-------
68+
69+
This is free and unencumbered public domain software. For more information,
70+
see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
71+
72+
[Ruby]: http://ruby-lang.org/
73+
[RDF]: http://www.w3.org/RDF/
74+
[YARD]: http://yardoc.org/
75+
[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
76+
[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
77+
[RDF.rb]: http://rubygems.org/gems/rdf

UNLICENSE

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <http://unlicense.org/>

VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.0

lib/rdf/csv.rb

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
$:.unshift(File.expand_path("..", __FILE__))
2+
require 'rdf' # @see http://rubygems.org/gems/rdf
3+
4+
module RDF
5+
##
6+
# **`RDF::CSV`** is a CSV extension for RDF.rb.
7+
#
8+
# @see http://w3c.github.io/csvw/
9+
#
10+
# @author [Gregg Kellogg](http://greggkellogg.net/)
11+
module LD
12+
require 'rdf/csv/format'
13+
autoload :Reader, 'rdf/csv/reader'
14+
autoload :VERSION, 'rdf/csv/version'
15+
autoload :Writer, 'rdf/csv/writer'
16+
end
17+
end

lib/rdf/csv/format.rb

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module RDF::CSV
2+
##
3+
# Tabular Data/CSV format specification.
4+
#
5+
# @example Obtaining a CSV format class
6+
# RDF::Format.for(:csv) #=> RDF::CSV::Format
7+
# RDF::Format.for(:tsv) #=> RDF::CSV::Format
8+
# RDF::Format.for("etc/foaf.csv")
9+
# RDF::Format.for("etc/foaf.tsv")
10+
# RDF::Format.for(:file_name => "etc/foaf.csv")
11+
# RDF::Format.for(:file_name => "etc/foaf.tsv")
12+
# RDF::Format.for(:file_extension => "csv")
13+
# RDF::Format.for(:file_extension => "tsv")
14+
# RDF::Format.for(:content_type => "text/csv")
15+
# RDF::Format.for(:content_type => "text/tab-separated-values")
16+
#
17+
# @example Obtaining serialization format MIME types
18+
# RDF::Format.content_types #=> {"text/csv" => [RDF::CSV::Format]}
19+
#
20+
# @example Obtaining serialization format file extension mappings
21+
# RDF::Format.file_extensions #=> {:csv => "text/csv"}
22+
#
23+
# @see http://www.w3.org/TR/rdf-testcases/#ntriples
24+
class Format < RDF::Format
25+
content_type 'text/csv',
26+
extensions: [:csv, :tsv],
27+
alias: 'text/tab-separated-values'
28+
content_encoding 'utf-8'
29+
30+
reader { RDF::CSV::Reader }
31+
32+
##
33+
# Sample detection to see if it matches JSON-LD
34+
#
35+
# Use a text sample to detect the format of an input file. Sub-classes implement
36+
# a matcher sufficient to detect probably format matches, including disambiguating
37+
# between other similar formats.
38+
#
39+
# @param [String] sample Beginning several bytes (~ 1K) of input.
40+
# @return [Boolean]
41+
def self.detect(sample)
42+
!!sample.match(/^(?:(?:\w )+,(?:\w ))$/)
43+
end
44+
end
45+
end

lib/rdf/csv/json.rb

Whitespace-only changes.

0 commit comments

Comments
 (0)