Skip to content

Commit

Permalink
Initial release.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed May 8, 2011
0 parents commit e47c763
Show file tree
Hide file tree
Showing 21 changed files with 498 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
/.yardoc/
/doc/
12 changes: 12 additions & 0 deletions .yardopts
@@ -0,0 +1,12 @@
--title "JSON-LD reader/writer for RDF.rb."
--output-dir doc/yard
--protected
--no-private
--hide-void-return
--markup markdown
--readme README.md
-
History.md
AUTHORS
VERSION
UNLICENSE
1 change: 1 addition & 0 deletions AUTHORS
@@ -0,0 +1 @@
* Gregg Kellogg <gregg@kellogg-assoc.com>
2 changes: 2 additions & 0 deletions History.md
@@ -0,0 +1,2 @@
=== 0.0.1
* First release of project scaffold.
1 change: 1 addition & 0 deletions README
87 changes: 87 additions & 0 deletions README.md
@@ -0,0 +1,87 @@
JSON-LD reader/writer
==================================

[JSON-LD][] reader/writer for [RDF.rb][RDF.rb] .

Features
--------

JSON::LD parses and serializes [JSON-LD][] into statements or triples.

Install with `gem install json-ld`

Examples
--------

require 'rubygems'
require 'json/ld'

Documentation
-------------

<http://rdf.rubyforge.org/json-ld>

* {JSON::LD}

Dependencies
------------

* [Ruby](http://ruby-lang.org/) (>= 1.8.7) or (>= 1.8.1 with [Backports][])
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.3.3)
* [JSON](https://rubygems.org/gems/json) (>= 1.5.1)

Installation
------------

The recommended installation method is via [RubyGems](http://rubygems.org/).
To install the latest official release of the `JSON-LD` gem, do:

% [sudo] gem install json-ld

Download
--------

To get a local working copy of the development repository, do:

% git clone git://github.com/gkellogg/json-ld.git

Mailing List
------------

* <http://lists.w3.org/Archives/Public/public-rdf-ruby/>

Author
------

* [Gregg Kellogg](http://github.com/gkellogg) - <http://kellogg-assoc.com/>


Contributing
------------

* Do your best to adhere to the existing coding conventions and idioms.
* Don't use hard tabs, and don't leave trailing whitespace on any line.
* Do document every method you add using [YARD][] annotations. Read the
[tutorial][YARD-GS] or just look at the existing code for examples.
* Don't touch the `.gemspec`, `VERSION` or `AUTHORS` files. If you need to
change them, do so on your private branch only.
* Do feel free to add yourself to the `CREDITS` file and the corresponding
list in the the `README`. Alphabetical order applies.
* Do note that in order for us to merge any non-trivial changes (as a rule
of thumb, additions larger than about 15 lines of code), we need an
explicit [public domain dedication][PDD] on record from you.

License
-------

This is free and unencumbered public domain software. For more information,
see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.

[Ruby]: http://ruby-lang.org/
[RDF]: http://www.w3.org/RDF/
[YARD]: http://yardoc.org/
[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
[RDF.rb]: http://rdf.rubyforge.org/
[Backports]: http://rubygems.org/gems/backports
[JSON-LD]: http://json-ld.org/spec/ED/20110507/
25 changes: 25 additions & 0 deletions Rakefile
@@ -0,0 +1,25 @@
require 'rubygems'

task :default => [ :spec ]

require 'rspec/core/rake_task'
desc 'Run specifications'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.rspec_opts = %w(--options spec/spec.opts) if File.exists?('spec/spec.opts')
end

desc "Run specs through RCov"
RSpec::Core::RakeTask.new("spec:rcov") do |spec|
spec.rcov = true
spec.rcov_opts = %q[--exclude "spec"]
end

desc "Generate HTML report specs"
RSpec::Core::RakeTask.new("doc:spec") do |spec|
spec.rspec_opts = ["--format", "html", "-o", "doc/spec.html"]
end

require 'yard'
YARD::Rake::YardocTask.new

task :default => :spec
24 changes: 24 additions & 0 deletions UNLICENSE
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>
1 change: 1 addition & 0 deletions VERSION
@@ -0,0 +1 @@
0.0.1
37 changes: 37 additions & 0 deletions json-ld.gemspec
@@ -0,0 +1,37 @@
#!/usr/bin/env ruby -rubygems
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
gem.version = File.read('VERSION').chomp
gem.date = File.mtime('VERSION').strftime('%Y-%m-%d')

gem.name = "json-ld"
gem.homepage = "http://rdf.rubyforge.org/json-ld"
gem.license = 'Public Domain' if gem.respond_to?(:license=)
gem.summary = "JSON-LD reader/writer for Ruby."
gem.description = gem.summary
gem.rubyforge_project = 'json-ld'

gem.authors = ['Gregg Kellogg']
gem.email = 'public-rdf-ruby@w3.org'

gem.platform = Gem::Platform::RUBY
gem.files = %w(AUTHORS CREDITS README UNLICENSE VERSION) + Dir.glob('lib/**/*.rb')
gem.bindir = %q(bin)
gem.executables = %w(json_ld)
gem.default_executable = gem.executables.first
gem.require_paths = %w(lib)
gem.extensions = %w()
gem.test_files = %w()
gem.has_rdoc = false

gem.required_ruby_version = '>= 1.8.1'
gem.requirements = []
gem.add_runtime_dependency 'rdf', '~> 0.4.0'
gem.add_runtime_dependency 'json', '>= 1.5.1'
gem.add_development_dependency 'nokogiri' , '>= 1.4.4'
gem.add_development_dependency 'yard' , '>= 0.6.0'
gem.add_development_dependency 'rspec', '>= 2.5.0'
gem.add_development_dependency 'rdf-spec', '~> 0.4.0'
gem.post_install_message = nil
end
31 changes: 31 additions & 0 deletions lib/json/ld.rb
@@ -0,0 +1,31 @@
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..')))
require 'rdf'

module JSON
##
# **`JSON::LD`** is a JSON-LD plugin for RDF.rb.
#
# @example Requiring the `JSON::LD` module
# require 'json/ld'
#
# @example Parsing RDF statements from a JSON-LD file
# JSON::LD::Reader.open("etc/foaf.jld") do |reader|
# reader.each_statement do |statement|
# puts statement.inspect
# end
# end
#
# @see http://rdf.rubyforge.org/
# @see http://www.w3.org/TR/REC-rdf-syntax/
#
# @author [Gregg Kellogg](http://greggkellogg.net/)
module LD
require 'json/ld/format'
autoload :Reader, 'json/ld/reader'
autoload :VERSION, 'json/ld/version'
autoload :Writer, 'json/ld/writer'

def self.debug?; @debug; end
def self.debug=(value); @debug = value; end
end
end
26 changes: 26 additions & 0 deletions lib/json/ld/format.rb
@@ -0,0 +1,26 @@
module RDF::N3
##
# RDFa format specification.
#
# @example Obtaining an Notation3 format class
# RDF::Format.for(:jld) #=> JSON::LD::Format
# RDF::Format.for("etc/foaf.jld")
# RDF::Format.for(:file_name => "etc/foaf.jld")
# RDF::Format.for(:file_extension => "jld")
# RDF::Format.for(:content_type => "application/json")
#
# @example Obtaining serialization format MIME types
# RDF::Format.content_types #=> {"application/json" => [JSON::LD::Format]}
#
# @example Obtaining serialization format file extension mappings
# RDF::Format.file_extensions #=> {:ttl => "application/json"}
#
# @see http://www.w3.org/TR/rdf-testcases/#ntriples
class Format < RDF::Format
content_type 'application/json', :extension => :jld
content_encoding 'utf-8'

reader { RDF::N3::Reader }
writer { RDF::N3::Writer }
end
end
11 changes: 11 additions & 0 deletions lib/json/ld/reader.rb
@@ -0,0 +1,11 @@
module JSON::LD
##
# A JSON-LD parser in Ruby.
#
# @see http://json-ld.org/spec/ED/20110507/
# @author [Gregg Kellogg](http://greggkellogg.net/)
class Reader < RDF::Reader
format Format
end
end

18 changes: 18 additions & 0 deletions lib/json/ld/version.rb
@@ -0,0 +1,18 @@
module RDF::N3::VERSION
VERSION_FILE = File.join(File.expand_path(File.dirname(__FILE__)), "..", "..", "..", "VERSION")
MAJOR, MINOR, TINY, EXTRA = File.read(VERSION_FILE).chop.split(".")

STRING = [MAJOR, MINOR, TINY, EXTRA].compact.join('.')

##
# @return [String]
def self.to_s() STRING end

##
# @return [String]
def self.to_str() STRING end

##
# @return [Array(Integer, Integer, Integer)]
def self.to_a() STRING.split(".") end
end
11 changes: 11 additions & 0 deletions lib/json/ld/writer.rb
@@ -0,0 +1,11 @@
module JSON::LD
##
# A JSON-LD parser in Ruby.
#
# @see http://json-ld.org/spec/ED/20110507/
# @author [Gregg Kellogg](http://greggkellogg.net/)
class Writer < RDF::Writer
format Format
end
end

6 changes: 6 additions & 0 deletions spec/format_spec.rb
@@ -0,0 +1,6 @@
# coding: utf-8
$:.unshift "."
require File.join(File.dirname(__FILE__), 'spec_helper')

describe "JSON::LD::Format" do
end

0 comments on commit e47c763

Please sign in to comment.