From d67fc23b150b60d4ce38f2f171d72035fc505976 Mon Sep 17 00:00:00 2001 From: Florian Frank Date: Mon, 24 Aug 2009 16:44:34 +0200 Subject: initial commit --- Rakefile | 51 ++++++++++++++++ author.incl | 2 + description.incl | 58 ++++++++++++++++++ diagrams/.keep | 0 doc/.keep | 0 edit_json.png | Bin 0 -> 55917 bytes footer.incl | 7 +++ header.incl | 11 ++++ headline.incl | 1 + index.html | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ index.tmpl | 12 ++++ installation.incl | 17 ++++++ json.png | Bin 0 -> 5288 bytes license.incl | 5 ++ linkbox.incl | 10 +++ logo.incl | 1 + meta.json | 19 ++++++ screenshots.html | 107 ++++++++++++++++++++++++++++++++ screenshots.tmpl | 21 +++++++ style.css | 93 ++++++++++++++++++++++++++++ usage.incl | 56 +++++++++++++++++ 21 files changed, 651 insertions(+) create mode 100644 Rakefile create mode 100644 author.incl create mode 100644 description.incl create mode 100644 diagrams/.keep create mode 100644 doc/.keep create mode 100644 edit_json.png create mode 100644 footer.incl create mode 100644 header.incl create mode 100644 headline.incl create mode 100644 index.html create mode 100644 index.tmpl create mode 100644 installation.incl create mode 100644 json.png create mode 100644 license.incl create mode 100644 linkbox.incl create mode 100644 logo.incl create mode 100644 meta.json create mode 100644 screenshots.html create mode 100644 screenshots.tmpl create mode 100644 style.css create mode 100644 usage.incl diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..b3e03ac --- /dev/null +++ b/Rakefile @@ -0,0 +1,51 @@ +require 'flott' +require 'json' +include Flott + +$meta = JSON.parse(File.read('meta.json')) + +task :default => [:doc, :homepage] + +desc "Create the project documentation." +task :doc do + if File.directory?('doc') + sh 'git rm -r doc' + end + sh 'git commit -m "deleted documentation" doc' + sh 'git checkout master' + rm_rf 'doc' + sh 'rake doc' + sh 'git checkout gh-pages' + sh 'git add doc' + sh 'git commit -m "generated documentation" doc' +end + +desc "Compile the homepage." +task :compile_homepage do + env = Environment.new + env.update($meta) + for tmpl in Dir['*.tmpl'] + ext = File.extname(tmpl) + out_name = tmpl.sub(/#{ext}$/, '.html') + warn "Compiling '#{tmpl}' -> '#{out_name}'." + File.open(out_name, 'w') do |o| + env.output = o + fp = Parser.from_filename(tmpl) + fp.evaluate(env) + end + end +end + +desc "Check the homepage with tidy." +task :tidy_homepage do + sh "tidy -e *index.html" +end + +desc "Compile and check the homepage." +task :homepage => [ :compile_homepage, :tidy_homepage ] + +desc "Publish the homepage to rubyforge." +task :publish_rubyforge => :homepage do + sh "scp -r rubyforge_index.html rubyforge.org:/var/www/gforge-projects/#{$meta['project_unixname']}/index.html" +end + # vim: set et sw=2 ts=2: diff --git a/author.incl b/author.incl new file mode 100644 index 0000000..eed563c --- /dev/null +++ b/author.incl @@ -0,0 +1,2 @@ +

Author

+[=@author] <[=@author_email]> diff --git a/description.incl b/description.incl new file mode 100644 index 0000000..762be2a --- /dev/null +++ b/description.incl @@ -0,0 +1,58 @@ +

Description

+

+This is a implementation of the JSON specification according to +RFC 4627. You can think of it as a low fat +alternative to XML, if you want to store data to disk or transmit it over a +network rather than use a verbose markup language. +

+

+Starting from version 1.0.0 on there +will be two variants available: +

+ +

+Both variants of the JSON generator escape all non-ASCII an control +characters with \uXXXX escape sequences, and support UTF-16 surrogate pairs +in order to be able to generate the whole range of unicode code points. This +means that generated JSON text is encoded as UTF-8 (because ASCII is a subset +of UTF-8) and at the same time avoids decoding problems for receiving +endpoints, that don't expect UTF-8 encoded texts. On the negative side this +may lead to a bit longer strings than necessarry. +

+

+It's also easy to extend JSON data types for arbitrary Ruby classes (including +your own) like this: +

+
+class Range
+  def to_json(*a)
+    {
+      'json_class'   => self.class.name,
+      'data'         => \[ first, last, exclude_end? ]
+    }.to_json(*a)
+  end
+
+  def self.json_create(o)
+    new(*o\['data'])
+  end
+end
+
+

+Now Range instances can be serialized/deserialized: +

+
+JSON.parse((1..10).to_json) == (1..10)
+
+

+A lot of additional information about JSON can be found Douglas Crockford's JSON +site. +

diff --git a/diagrams/.keep b/diagrams/.keep new file mode 100644 index 0000000..e69de29 diff --git a/doc/.keep b/doc/.keep new file mode 100644 index 0000000..e69de29 diff --git a/edit_json.png b/edit_json.png new file mode 100644 index 0000000..cd1fa8a Binary files /dev/null and b/edit_json.png differ diff --git a/footer.incl b/footer.incl new file mode 100644 index 0000000..f6abde4 --- /dev/null +++ b/footer.incl @@ -0,0 +1,7 @@ +

+ Valid XHTML 1.0 Transitional +

+ + diff --git a/header.incl b/header.incl new file mode 100644 index 0000000..b34c8cd --- /dev/null +++ b/header.incl @@ -0,0 +1,11 @@ + + + + + + [=@project_name] + + + diff --git a/headline.incl b/headline.incl new file mode 100644 index 0000000..d2e0f50 --- /dev/null +++ b/headline.incl @@ -0,0 +1 @@ +

[=@project_unixname] – [=@project_name]

diff --git a/index.html b/index.html new file mode 100644 index 0000000..b6e65a8 --- /dev/null +++ b/index.html @@ -0,0 +1,180 @@ + + + + + + JSON implementation for Ruby + + + + + + + + +
+

json – JSON implementation for Ruby

+ +

Description

+

+This is a implementation of the JSON specification according to +RFC 4627. You can think of it as a low fat +alternative to XML, if you want to store data to disk or transmit it over a +network rather than use a verbose markup language. +

+

+Starting from version 1.0.0 on there +will be two variants available: +

+ +

+Both variants of the JSON generator escape all non-ASCII an control +characters with \uXXXX escape sequences, and support UTF-16 surrogate pairs +in order to be able to generate the whole range of unicode code points. This +means that generated JSON text is encoded as UTF-8 (because ASCII is a subset +of UTF-8) and at the same time avoids decoding problems for receiving +endpoints, that don't expect UTF-8 encoded texts. On the negative side this +may lead to a bit longer strings than necessarry. +

+

+It's also easy to extend JSON data types for arbitrary Ruby classes (including +your own) like this: +

+
+class Range
+  def to_json(*a)
+    {
+      'json_class'   => self.class.name,
+      'data'         => [ first, last, exclude_end? ]
+    }.to_json(*a)
+  end
+
+  def self.json_create(o)
+    new(*o['data'])
+  end
+end
+
+

+Now Range instances can be serialized/deserialized: +

+
+JSON.parse((1..10).to_json) == (1..10)
+
+

+A lot of additional information about JSON can be found Douglas Crockford's JSON +site. +

+ +

Installation

+

+The library can be installed via rubygems: +

+
+# gem install json
+
+

+If you have to use the pure variant, you can use: +

+
+# gem install json_pure
+
+

+The gem and the source archive can also be downloaded directly from rubyforge.org. +

+ +

Usage

+

+If you require JSON like this: +

+
+require 'json'
+
+

+JSON first tries to load the extension variant. If this fails, the pure variant +is loaded and used. +

+

+To determine, which variant is active you can use the follwing methods: +

+ +

+If you want to enforce loading of a special variant, use +

+
+require 'json/ext'
+
+

+to load the extension variant. Or use +

+
+require 'json/pure'
+
+

+to use the pure variant. +

+

+You can choose to load a set of common additions to ruby core's objects if you +

+
+  require 'json/add/core'
+
+

+ To get the best compatibility to rails' JSON implementation, you can +

+
+    require 'json/add/rails'
+
+

+ Both of the additions attempt to require 'json' (like above) first, if it has not been required yet. +

+ +

Author

+Florian Frank <flori@ping.de> + +

License

+

+This is software is distributed under the same license as Ruby itself. See http://www.ruby-lang.org/en/LICENSE.txt. +

+ +
+

+ Valid XHTML 1.0 Transitional +

+ + + diff --git a/index.tmpl b/index.tmpl new file mode 100644 index 0000000..10e3a11 --- /dev/null +++ b/index.tmpl @@ -0,0 +1,12 @@ +[^header.incl] +[^linkbox.incl] +[^logo.incl] +
+[^headline.incl] +[^description.incl] +[^installation.incl] +[^usage.incl] +[^author.incl] +[^license.incl] +
+[^footer.incl] diff --git a/installation.incl b/installation.incl new file mode 100644 index 0000000..ad3e55c --- /dev/null +++ b/installation.incl @@ -0,0 +1,17 @@ +

Installation

+

+The library can be installed via rubygems: +

+
+# gem install [=@project_unixname]
+
+

+If you have to use the pure variant, you can use: +

+
+# gem install [=@project_unixname]_pure
+
+

+The gem and the source archive can also be downloaded directly from rubyforge.org. +

diff --git a/json.png b/json.png new file mode 100644 index 0000000..09e8a71 Binary files /dev/null and b/json.png differ diff --git a/license.incl b/license.incl new file mode 100644 index 0000000..0e6071f --- /dev/null +++ b/license.incl @@ -0,0 +1,5 @@ +

License

+

+This is software is distributed under the same license as Ruby itself. See http://www.ruby-lang.org/en/LICENSE.txt. +

diff --git a/linkbox.incl b/linkbox.incl new file mode 100644 index 0000000..415c886 --- /dev/null +++ b/linkbox.incl @@ -0,0 +1,10 @@ + diff --git a/logo.incl b/logo.incl new file mode 100644 index 0000000..40255bf --- /dev/null +++ b/logo.incl @@ -0,0 +1 @@ + diff --git a/meta.json b/meta.json new file mode 100644 index 0000000..10f4a67 --- /dev/null +++ b/meta.json @@ -0,0 +1,19 @@ +{ + "author_email":"flori@ping.de", + "author":"Florian Frank", + "documentation_url":"doc/index.html", + "download_url":"http://rubyforge.org/frs/?group_id=953", + "github_url": "http:\/\/github.com\/flori\/json\/tree\/master", + "project_name":"JSON implementation for Ruby", + "project_unixname":"json", + "project_url":"http://rubyforge.org/projects/json", + "screenshots":["edit_json.png", + "diagrams/JSON_array.png", + "diagrams/JSON_float.png", + "diagrams/JSON_integer.png", + "diagrams/JSON_object.png", + "diagrams/JSON.png", + "diagrams/JSON_string.png", + "diagrams/JSON_value.png" + ] +} diff --git a/screenshots.html b/screenshots.html new file mode 100644 index 0000000..a189799 --- /dev/null +++ b/screenshots.html @@ -0,0 +1,107 @@ + + + + + + JSON implementation for Ruby + + + + + + + + +
+

json – JSON implementation for Ruby

+ +

Screenshots

+

Here are some Screenshots from the graphical JSON Editor + edit_json.rb, that is included in the library package. To run it, a + working installation of Ruby GTK2 is necessary.

+ +
+ + Screenshot #1 + +
+ Screenshot #1 (Click to enlarge) +
+ +
+ + Screenshot #2 + +
+ Screenshot #2 (Click to enlarge) +
+ +
+ + Screenshot #3 + +
+ Screenshot #3 (Click to enlarge) +
+ +
+ + Screenshot #4 + +
+ Screenshot #4 (Click to enlarge) +
+ +
+ + Screenshot #5 + +
+ Screenshot #5 (Click to enlarge) +
+ +
+ + Screenshot #6 + +
+ Screenshot #6 (Click to enlarge) +
+ +
+ + Screenshot #7 + +
+ Screenshot #7 (Click to enlarge) +
+ +
+ + Screenshot #8 + +
+ Screenshot #8 (Click to enlarge) +
+ +
+

+ Valid XHTML 1.0 Transitional +

+ + + diff --git a/screenshots.tmpl b/screenshots.tmpl new file mode 100644 index 0000000..d688c8b --- /dev/null +++ b/screenshots.tmpl @@ -0,0 +1,21 @@ +[^header.incl] +[^linkbox.incl] +[^logo.incl] +
+[^headline.incl] +

Screenshots

+

Here are some Screenshots from the graphical JSON Editor + edit_json.rb, that is included in the library package. To run it, a + working installation of Ruby GTK2 is necessary.

+ [@screenshots.each_with_index do |s,i|] +
+ + Screenshot #[=i + 1] + +
+ Screenshot #[=i + 1] (Click to enlarge) +
+ [end] +
+[^footer.incl] diff --git a/style.css b/style.css new file mode 100644 index 0000000..ef0eaa4 --- /dev/null +++ b/style.css @@ -0,0 +1,93 @@ +body { + color: black; + background-color: white; + font-family: 'Verdana', 'Arial', sans-serif; + padding: 15px; + margin: 0; + font-size: 100.01%; +} +img { + border: 0; +} +pre { + margin: 25px; + background-color: silver; + color: navy; + border: 1px dashed black; + padding: 5px; +} +a { + color: #af0000; + background-color: white; + text-decoration: none; +} +a:hover { + text-decoration: underline; +} +img#logo { + float: left; +} +p.valid { + float: right; +} +ul#linkbox { + font-size: 12px; + float: right; + width: 150px; + margin: 0; + padding: 0; + border: 1px solid silver; +} +ul#linkbox li { + list-style: none; + margin: 0; + padding: 2px; +} +ul#linkbox a { + display: block; + padding: 5px; + text-decoration: none; + font-weight: bold; +} +ul#linkbox a:link { + color: white; + text-decoration: none; + background-color: #af0000; +} +ul#linkbox a:visited { + color: white; + text-decoration: none; + background-color: #af0000; +} +ul#linkbox a:hover { + color: white; + text-decoration: underline; + background-color: #af0000; +} +ul#linkbox a:active { + color: white; + text-decoration: underline; + background-color: #af0000; +} +div#content { + margin-right: 150px; + padding: 0 10px; +} +div#content h1 { + color: #af0000; + background-color: white; + font-size: 20px; + padding: 18px 0 18px 0; + margin: 0 90px; +} +div#content h2 { + font-size: 16px; + margin-bottom: 16px; +} +div#content p { + font-size: 14px; + margin-top: 14px; +} +span.caption { + font-size:12px; +} diff --git a/usage.incl b/usage.incl new file mode 100644 index 0000000..1497346 --- /dev/null +++ b/usage.incl @@ -0,0 +1,56 @@ +

Usage

+

+If you require JSON like this: +

+
+require 'json'
+
+

+JSON first tries to load the extension variant. If this fails, the pure variant +is loaded and used. +

+

+To determine, which variant is active you can use the follwing methods: +

+ +

+If you want to enforce loading of a special variant, use +

+
+require 'json/ext'
+
+

+to load the extension variant. Or use +

+
+require 'json/pure'
+
+

+to use the pure variant. +

+

+You can choose to load a set of common additions to ruby core's objects if you +

+
+  require 'json/add/core'
+
+

+ To get the best compatibility to rails' JSON implementation, you can +

+
+    require 'json/add/rails'
+
+

+ Both of the additions attempt to require 'json' (like above) first, if it has not been required yet. +

-- cgit v1.2.1