Browse files

vendor json_pure

  • Loading branch information...
1 parent 115fe78 commit cfc684cb351ff6eb5790a261aed66f8106905ac4 @ddollar ddollar committed Mar 9, 2011
View
17 Gemfile.lock
@@ -2,7 +2,6 @@ PATH
remote: .
specs:
heroku (1.18.2)
- json (~> 1.5.1)
launchy (~> 0.3.2)
rest-client (>= 1.4.0, < 1.7.0)
@@ -13,29 +12,14 @@ GEM
configuration (1.2.0)
crack (0.1.8)
fakefs (0.3.1)
- json (1.5.1)
launchy (0.3.7)
configuration (>= 0.0.5)
rake (>= 0.8.1)
mime-types (1.16)
- rack (1.2.1)
rake (0.8.7)
rest-client (1.6.1)
mime-types (>= 1.16)
rspec (1.3.1)
- sequel (3.20.0)
- sinatra (1.0)
- rack (>= 1.0)
- sqlite3 (1.3.3)
- sqlite3-ruby (1.3.3)
- sqlite3 (>= 1.3.3)
- taps (0.3.17)
- json (~> 1.5.1)
- rack (>= 1.0.1)
- rest-client (>= 1.4.0, < 1.7.0)
- sequel (~> 3.20.0)
- sinatra (~> 1.0.0)
- sqlite3-ruby (~> 1.2)
webmock (1.5.0)
addressable (>= 2.2.2)
crack (>= 0.1.7)
@@ -48,5 +32,4 @@ DEPENDENCIES
heroku!
rake
rspec (~> 1.3.0)
- taps (~> 0.3.16)
webmock (~> 1.5.0)
View
3 heroku.gemspec
@@ -17,10 +17,9 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "fakefs", "~> 0.3.1"
gem.add_development_dependency "rake"
gem.add_development_dependency "rspec", "~> 1.3.0"
- gem.add_development_dependency "taps", "~> 0.3.16"
+ #gem.add_development_dependency "taps", "~> 0.3.16"
gem.add_development_dependency "webmock", "~> 1.5.0"
gem.add_dependency "rest-client", ">= 1.4.0", "< 1.7.0"
gem.add_dependency "launchy", "~> 0.3.2"
- gem.add_dependency "json", "~> 1.5.1"
end
View
3 lib/heroku-postgresql/client.rb
@@ -1,12 +1,11 @@
require "heroku/helpers"
-require "heroku/util/json"
+require "heroku/json"
module HerokuPostgresql
class Client
Version = 9
include Heroku::Helpers
- include Heroku::Util::JSON
def initialize(database_user, database_password, database_name)
@heroku_postgresql_host = ENV["HEROKU_POSTGRESQL_HOST"] || "https://shogun.heroku.com"
View
3 lib/heroku/client.rb
@@ -3,7 +3,7 @@
require 'uri'
require 'time'
require 'heroku/version'
-require "heroku/util/json"
+require 'heroku/json'
# A Ruby class to call the Heroku REST API. You might use this if you want to
# manage your Heroku apps from within a Ruby program, such as Capistrano.
@@ -15,7 +15,6 @@
# heroku.create('myapp')
#
class Heroku::Client
- include Heroku::Util::JSON
def self.version
Heroku::VERSION
View
3 lib/heroku/command.rb
@@ -1,7 +1,7 @@
require 'heroku/helpers'
require 'heroku/plugin'
require 'heroku/commands/base'
-require 'heroku/util/json'
+require 'heroku/json'
Dir["#{File.dirname(__FILE__)}/commands/*.rb"].each { |c| require c }
@@ -11,7 +11,6 @@ class InvalidCommand < RuntimeError; end
class CommandFailed < RuntimeError; end
extend Heroku::Helpers
- extend Heroku::Util::JSON
class << self
View
5 lib/heroku/json.rb
@@ -0,0 +1,5 @@
+unless Kernel.const_defined?(:JSON)
+ $:.unshift File.expand_path("../vendor/json_pure-1.5.1/lib", __FILE__)
+ require "json/pure"
+end
+
View
188 lib/heroku/vendor/json_pure-1.5.1/CHANGES
@@ -0,0 +1,188 @@
+2011-01-24 (1.5.1)
+ * Made rake-compiler build a fat binary gem. This should fix issue
+ https://github.com/flori/json/issues#issue/54.
+2011-01-22 (1.5.0)
+ * Included Java source codes for the Jruby extension made by Daniel Luz
+ <dev@mernen.com>.
+ * Output full exception message of deep_const_get to aid debugging.
+ * Fixed an issue with ruby 1.9 Module#const_defined? method, that was
+ reported by Riley Goodside.
+2010-08-09 (1.4.6)
+ * Fixed oversight reported in http://github.com/flori/json/issues/closed#issue/23,
+ always create a new object from the state prototype.
+ * Made pure and ext api more similar again.
+2010-08-07 (1.4.5)
+ * Manage data structure nesting depth in state object during generation. This
+ should reduce problems with to_json method definіtions that only have one
+ argument.
+ * Some fixes in the state objects and additional tests.
+2010-08-06 (1.4.4)
+ * Fixes build problem for rubinius under OS X, http://github.com/flori/json/issues/closed#issue/25
+ * Fixes crashes described in http://github.com/flori/json/issues/closed#issue/21 and
+ http://github.com/flori/json/issues/closed#issue/23
+2010-05-05 (1.4.3)
+ * Fixed some test assertions, from Ruby r27587 and r27590, patch by nobu.
+ * Fixed issue http://github.com/flori/json/issues/#issue/20 reported by
+ electronicwhisper@github. Thx!
+2010-04-26 (1.4.2)
+ * Applied patch from naruse Yui NARUSE <naruse@airemix.com> to make building with
+ Microsoft Visual C possible again.
+ * Applied patch from devrandom <c1.github@niftybox.net> in order to allow building of
+ json_pure if extensiontask is not present.
+ * Thanks to Dustin Schneider <dustin@stocktwits.com>, who reported a memory
+ leak, which is fixed in this release.
+ * Applied 993f261ccb8f911d2ae57e9db48ec7acd0187283 patch from josh@github.
+2010-04-25 (1.4.1)
+ * Fix for a bug reported by Dan DeLeo <dan@kallistec.com>, caused by T_FIXNUM
+ being different on 32bit/64bit architectures.
+2010-04-23 (1.4.0)
+ * Major speed improvements and building with simplified
+ directory/file-structure.
+ * Extension should at least be comapatible with MRI, YARV and Rubinius.
+2010-04-07 (1.2.4)
+ * Triger const_missing callback to make Rails' dynamic class loading work.
+2010-03-11 (1.2.3)
+ * Added a State#[] method which returns an attribute's value in order to
+ increase duck type compatibility to Hash.
+2010-02-27 (1.2.2)
+ * Made some changes to make the building of the parser/generator compatible
+ to Rubinius.
+2009-11-25 (1.2.1)
+ * Added :symbolize_names option to Parser, which returns symbols instead of
+ strings in object names/keys.
+2009-10-01 (1.2.0)
+ * fast_generate now raises an exeception for nan and infinite floats.
+ * On Ruby 1.8 json supports parsing of UTF-8, UTF-16BE, UTF-16LE, UTF-32BE,
+ and UTF-32LE JSON documents now. Under Ruby 1.9 the M17n conversion
+ functions are used to convert from all supported encodings. ASCII-8BIT
+ encoded strings are handled like all strings under Ruby 1.8 were.
+ * Better documentation
+2009-08-23 (1.1.9)
+ * Added forgotten main doc file extra_rdoc_files.
+2009-08-23 (1.1.8)
+ * Applied a patch by OZAWA Sakuro <sakuro@2238club.org> to make json/pure
+ work in environments that don't provide iconv.
+ * Applied patch by okkez_ in order to fix Ruby Bug #1768:
+ http://redmine.ruby-lang.org/issues/show/1768.
+ * Finally got around to avoid the rather paranoid escaping of ?/ characters
+ in the generator's output. The parsers aren't affected by this change.
+ Thanks to Rich Apodaca <rapodaca@metamolecular.com> for the suggestion.
+2009-06-29 (1.1.7)
+ * Security Fix for JSON::Pure::Parser. A specially designed string could
+ cause catastrophic backtracking in one of the parser's regular expressions
+ in earlier 1.1.x versions. JSON::Ext::Parser isn't affected by this issue.
+ Thanks to Bartosz Blimke <bartosz@new-bamboo.co.uk> for reporting this
+ problem.
+ * This release also uses a less strict ruby version requirement for the
+ creation of the mswin32 native gem.
+2009-05-10 (1.1.6)
+ * No changes. І tested native linux gems in the last release and they don't
+ play well with different ruby versions other than the one the gem was built
+ with. This release is just to bump the version number in order to skip the
+ native gem on rubyforge.
+2009-05-10 (1.1.5)
+ * Started to build gems with rake-compiler gem.
+ * Applied patch object/array class patch from Brian Candler
+ <B.Candler@pobox.com> and fixes.
+2009-04-01 (1.1.4)
+ * Fixed a bug in the creation of serialized generic rails objects reported by
+ Friedrich Graeter <graeter@hydrixos.org>.
+ * Deleted tests/runner.rb, we're using testrb instead.
+ * Editor supports Infinity in numbers now.
+ * Made some changes in order to get the library to compile/run under Ruby
+ 1.9.
+ * Improved speed of the code path for the fast_generate method in the pure
+ variant.
+2008-07-10 (1.1.3)
+ * Wesley Beary <monki@geemus.com> reported a bug in json/add/core's DateTime
+ handling: If the nominator and denominator of the offset were divisible by
+ each other Ruby's Rational#to_s returns them as an integer not a fraction
+ with '/'. This caused a ZeroDivisionError during parsing.
+ * Use Date#start and DateTime#start instead of sg method, while
+ remaining backwards compatible.
+ * Supports ragel >= 6.0 now.
+ * Corrected some tests.
+ * Some minor changes.
+2007-11-27 (1.1.2)
+ * Remember default dir (last used directory) in editor.
+ * JSON::Editor.edit method added, the editor can now receive json texts from
+ the clipboard via C-v.
+ * Load json texts from an URL pasted via middle button press.
+ * Added :create_additions option to Parser. This makes it possible to disable
+ the creation of additions by force, in order to treat json texts as data
+ while having additions loaded.
+ * Jacob Maine <jmaine@blurb.com> reported, that JSON(:foo) outputs a JSON
+ object if the rails addition is enabled, which is wrong. It now outputs a
+ JSON string "foo" instead, like suggested by Jacob Maine.
+ * Discovered a bug in the Ruby Bugs Tracker on rubyforge, that was reported
+ by John Evans lgastako@gmail.com. He could produce a crash in the JSON
+ generator by returning something other than a String instance from a
+ to_json method. I now guard against this by doing a rather crude type
+ check, which raises an exception instead of crashing.
+2007-07-06 (1.1.1)
+ * Yui NARUSE <naruse@airemix.com> sent some patches to fix tests for Ruby
+ 1.9. I applied them and adapted some of them a bit to run both on 1.8 and
+ 1.9.
+ * Introduced a JSON.parse! method without depth checking for people who like
+ danger.
+ * Made generate and pretty_generate methods configurable by an options hash.
+ * Added :allow_nan option to parser and generator in order to handle NaN,
+ Infinity, and -Infinity correctly - if requested. Floats, which aren't numbers,
+ aren't valid JSON according to RFC4627, so by default an exception will be
+ raised if any of these symbols are encountered. Thanks to Andrea Censi
+ <andrea.censi@dis.uniroma1.it> for his hint about this.
+ * Fixed some more tests for Ruby 1.9.
+ * Implemented dump/load interface of Marshal as suggested in ruby-core:11405
+ by murphy <murphy@rubychan.de>.
+ * Implemented the max_nesting feature for generate methods, too.
+ * Added some implementations for ruby core's custom objects for
+ serialisation/deserialisation purposes.
+2007-05-21 (1.1.0)
+ * Implemented max_nesting feature for parser to avoid stack overflows for
+ data from untrusted sources. If you trust the source, you can disable it
+ with the option max_nesting => false.
+ * Piers Cawley <pdcawley@bofh.org.uk> reported a bug, that not every
+ character can be escaped by ?\ as required by RFC4627. There's a
+ contradiction between David Crockford's JSON checker test vectors (in
+ tests/fixtures) and RFC4627, though. I decided to stick to the RFC, because
+ the JSON checker seems to be a bit older than the RFC.
+ * Extended license to Ruby License, which includes the GPL.
+ * Added keyboard shortcuts, and 'Open location' menu item to edit_json.rb.
+2007-05-09 (1.0.4)
+ * Applied a patch from Yui NARUSE <naruse@airemix.com> to make JSON compile
+ under Ruby 1.9. Thank you very much for mailing it to me!
+ * Made binary variants of JSON fail early, instead of falling back to the
+ pure version. This should avoid overshadowing of eventual problems while
+ loading of the binary.
+2007-03-24 (1.0.3)
+ * Improved performance of pure variant a bit.
+ * The ext variant of this release supports the mswin32 platform. Ugh!
+2007-03-24 (1.0.2)
+ * Ext Parser didn't parse 0e0 correctly into 0.0: Fixed!
+2007-03-24 (1.0.1)
+ * Forgot some object files in the build dir. I really like that - not!
+2007-03-24 (1.0.0)
+ * Added C implementations for the JSON generator and a ragel based JSON
+ parser in C.
+ * Much more tests, especially fixtures from json.org.
+ * Further improved conformance to RFC4627.
+2007-02-09 (0.4.3)
+ * Conform more to RFC4627 for JSON: This means JSON strings
+ now always must contain exactly one object "{ ... }" or array "[ ... ]" in
+ order to be parsed without raising an exception. The definition of what
+ constitutes a whitespace is narrower in JSON than in Ruby ([ \t\r\n]), and
+ there are differences in floats and integers (no octals or hexadecimals) as
+ well.
+ * Added aliases generate and pretty_generate of unparse and pretty_unparse.
+ * Fixed a test case.
+ * Catch an Iconv::InvalidEncoding exception, that seems to occur on some Sun
+ boxes with SunOS 5.8, if iconv doesn't support utf16 conversions. This was
+ reported by Andrew R Jackson <andrewj@bcm.tmc.edu>, thanks a bunch!
+2006-08-25 (0.4.2)
+ * Fixed a bug in handling solidi (/-characters), that was reported by
+ Kevin Gilpin <kevin.gilpin@alum.mit.edu>.
+2006-02-06 (0.4.1)
+ * Fixed a bug related to escaping with backslashes. Thanks for the report go
+ to Florian Munz <surf@theflow.de>.
+2005-09-23 (0.4.0)
+ * Initial Rubyforge Version
View
58 lib/heroku/vendor/json_pure-1.5.1/COPYING
@@ -0,0 +1,58 @@
+Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
+You can redistribute it and/or modify it under either the terms of the GPL
+(see GPL file), or the conditions below:
+
+ 1. You may make and give away verbatim copies of the source form of the
+ software without restriction, provided that you duplicate all of the
+ original copyright notices and associated disclaimers.
+
+ 2. You may modify your copy of the software in any way, provided that
+ you do at least ONE of the following:
+
+ a) place your modifications in the Public Domain or otherwise
+ make them Freely Available, such as by posting said
+ modifications to Usenet or an equivalent medium, or by allowing
+ the author to include your modifications in the software.
+
+ b) use the modified software only within your corporation or
+ organization.
+
+ c) rename any non-standard executables so the names do not conflict
+ with standard executables, which must also be provided.
+
+ d) make other distribution arrangements with the author.
+
+ 3. You may distribute the software in object code or executable
+ form, provided that you do at least ONE of the following:
+
+ a) distribute the executables and library files of the software,
+ together with instructions (in the manual page or equivalent)
+ on where to get the original distribution.
+
+ b) accompany the distribution with the machine-readable source of
+ the software.
+
+ c) give non-standard executables non-standard names, with
+ instructions on where to get the original software distribution.
+
+ d) make other distribution arrangements with the author.
+
+ 4. You may modify and include the part of the software into any other
+ software (possibly commercial). But some files in the distribution
+ are not written by the author, so that they are not under this terms.
+
+ They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
+ files under the ./missing directory. See each file for the copying
+ condition.
+
+ 5. The scripts and library files supplied as input to or produced as
+ output from the software do not automatically fall under the
+ copyright of the software, but belong to whomever generated them,
+ and may be sold commercially, and may be aggregated with this
+ software.
+
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE.
+
View
57 lib/heroku/vendor/json_pure-1.5.1/COPYING-json-jruby
@@ -0,0 +1,57 @@
+JSON-JRuby is copyrighted free software by Daniel Luz <mernen at gmail dot com>,
+and is a derivative work of Florian Frank's json library <flori at ping dot de>.
+You can redistribute it and/or modify it under either the terms of the GPL
+version 2 (see the file GPL), or the conditions below:
+
+ 1. You may make and give away verbatim copies of the source form of the
+ software without restriction, provided that you duplicate all of the
+ original copyright notices and associated disclaimers.
+
+ 2. You may modify your copy of the software in any way, provided that
+ you do at least ONE of the following:
+
+ a) place your modifications in the Public Domain or otherwise
+ make them Freely Available, such as by posting said
+ modifications to Usenet or an equivalent medium, or by allowing
+ the author to include your modifications in the software.
+
+ b) use the modified software only within your corporation or
+ organization.
+
+ c) give non-standard binaries non-standard names, with
+ instructions on where to get the original software distribution.
+
+ d) make other distribution arrangements with the author.
+
+ 3. You may distribute the software in object code or binary form,
+ provided that you do at least ONE of the following:
+
+ a) distribute the binaries and library files of the software,
+ together with instructions (in the manual page or equivalent)
+ on where to get the original distribution.
+
+ b) accompany the distribution with the machine-readable source of
+ the software.
+
+ c) give non-standard binaries non-standard names, with
+ instructions on where to get the original software distribution.
+
+ d) make other distribution arrangements with the author.
+
+ 4. You may modify and include the part of the software into any other
+ software (possibly commercial). But some files in the distribution
+ are not written by the author, so that they are not under these terms.
+
+ For the list of those files and their copying conditions, see the
+ file LEGAL.
+
+ 5. The scripts and library files supplied as input to or produced as
+ output from the software do not automatically fall under the
+ copyright of the software, but belong to whomever generated them,
+ and may be sold commercially, and may be aggregated with this
+ software.
+
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE.
View
340 lib/heroku/vendor/json_pure-1.5.1/GPL
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
View
356 lib/heroku/vendor/json_pure-1.5.1/README
@@ -0,0 +1,356 @@
+== Description
+
+This is a implementation of the JSON specification according to RFC 4627
+http://www.ietf.org/rfc/rfc4627.txt . Starting from version 1.0.0 on there
+will be two variants available:
+
+* A pure ruby variant, that relies on the iconv and the stringscan
+ extensions, which are both part of the ruby standard library.
+* The quite a bit faster C extension variant, which is in parts implemented
+ in C and comes with its own unicode conversion functions and a parser
+ generated by the ragel state machine compiler
+ http://www.cs.queensu.ca/~thurston/ragel .
+
+Both variants of the JSON generator generate UTF-8 character sequences by
+default. If an :ascii_only option with a true value is given, they escape all
+non-ASCII and 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.
+
+All strings, that are to be encoded as JSON strings, should be UTF-8 byte
+sequences on the Ruby side. To encode raw binary strings, that aren't UTF-8
+encoded, please use the to_json_raw_object method of String (which produces
+an object, that contains a byte array) and decode the result on the receiving
+endpoint.
+
+The JSON parsers can parse UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, and UTF-32LE
+JSON documents under Ruby 1.8. Under Ruby 1.9 they take advantage of Ruby's
+M17n features and can parse all documents which have the correct
+String#encoding set. If a document string has ASCII-8BIT as an encoding the
+parser attempts to figure out which of the UTF encodings from above it is and
+trys to parse it.
+
+== Installation
+
+It's recommended to use the extension variant of JSON, because it's faster than
+the pure ruby variant. If you cannot build it on your system, you can settle
+for the latter.
+
+Just type into the command line as root:
+
+ # rake install
+
+The above command will build the extensions and install them on your system.
+
+ # rake install_pure
+
+or
+
+ # ruby install.rb
+
+will just install the pure ruby implementation of JSON.
+
+If you use Rubygems you can type
+
+ # gem install json
+
+instead, to install the newest JSON version.
+
+There is also a pure ruby json only variant of the gem, that can be installed
+with:
+
+ # gem install json_pure
+
+== Compiling the extensions yourself
+
+If you want to build the extensions yourself you need rake:
+
+ You can get it from rubyforge:
+ http://rubyforge.org/projects/rake
+
+ or just type
+
+ # gem install rake
+
+ for the installation via rubygems.
+
+If you want to create the parser.c file from its parser.rl file or draw nice
+graphviz images of the state machines, you need ragel from: http://www.cs.queensu.ca/~thurston/ragel
+
+
+== Usage
+
+To use JSON you can
+ require 'json'
+to load the installed variant (either the extension 'json' or the pure
+variant 'json_pure'). If you have installed the extension variant, you can
+pick either the extension variant or the pure variant by typing
+ require 'json/ext'
+or
+ require 'json/pure'
+
+Now you can parse a JSON document into a ruby data structure by calling
+
+ JSON.parse(document)
+
+If you want to generate a JSON document from a ruby data structure call
+ JSON.generate(data)
+
+You can also use the pretty_generate method (which formats the output more
+verbosely and nicely) or fast_generate (which doesn't do any of the security
+checks generate performs, e. g. nesting deepness checks).
+
+To create a valid JSON document you have to make sure, that the output is
+embedded in either a JSON array [] or a JSON object {}. The easiest way to do
+this, is by putting your values in a Ruby Array or Hash instance.
+
+There are also the JSON and JSON[] methods which use parse on a String or
+generate a JSON document from an array or hash:
+
+ document = JSON 'test' => 23 # => "{\"test\":23}"
+ document = JSON['test'] => 23 # => "{\"test\":23}"
+
+and
+
+ data = JSON '{"test":23}' # => {"test"=>23}
+ data = JSON['{"test":23}'] # => {"test"=>23}
+
+You can choose to load a set of common additions to ruby core's objects if
+you
+ require 'json/add/core'
+
+After requiring this you can, e. g., serialise/deserialise Ruby ranges:
+
+ JSON JSON(1..10) # => 1..10
+
+To find out how to add JSON support to other or your own classes, read the
+section "More Examples" below.
+
+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.
+
+== More Examples
+
+To create a JSON document from a ruby data structure, you can call
+JSON.generate like that:
+
+ json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
+ # => "[1,2,{\"a\":3.141},false,true,null,\"4..10\"]"
+
+To get back a ruby data structure from a JSON document, you have to call
+JSON.parse on it:
+
+ JSON.parse json
+ # => [1, 2, {"a"=>3.141}, false, true, nil, "4..10"]
+
+Note, that the range from the original data structure is a simple
+string now. The reason for this is, that JSON doesn't support ranges
+or arbitrary classes. In this case the json library falls back to call
+Object#to_json, which is the same as #to_s.to_json.
+
+It's possible to add JSON support serialization to arbitrary classes by
+simply implementing a more specialized version of the #to_json method, that
+should return a JSON object (a hash converted to JSON with #to_json) like
+this (don't forget the *a for all the arguments):
+
+ class Range
+ def to_json(*a)
+ {
+ 'json_class' => self.class.name, # = 'Range'
+ 'data' => [ first, last, exclude_end? ]
+ }.to_json(*a)
+ end
+ end
+
+The hash key 'json_class' is the class, that will be asked to deserialise the
+JSON representation later. In this case it's 'Range', but any namespace of
+the form 'A::B' or '::A::B' will do. All other keys are arbitrary and can be
+used to store the necessary data to configure the object to be deserialised.
+
+If a the key 'json_class' is found in a JSON object, the JSON parser checks
+if the given class responds to the json_create class method. If so, it is
+called with the JSON object converted to a Ruby hash. So a range can
+be deserialised by implementing Range.json_create like this:
+
+ class Range
+ def self.json_create(o)
+ new(*o['data'])
+ end
+ end
+
+Now it possible to serialise/deserialise ranges as well:
+
+ json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
+ # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
+ JSON.parse json
+ # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
+
+JSON.generate always creates the shortest possible string representation of a
+ruby data structure in one line. This is good for data storage or network
+protocols, but not so good for humans to read. Fortunately there's also
+JSON.pretty_generate (or JSON.pretty_generate) that creates a more readable
+output:
+
+ puts JSON.pretty_generate([1, 2, {"a"=>3.141}, false, true, nil, 4..10])
+ [
+ 1,
+ 2,
+ {
+ "a": 3.141
+ },
+ false,
+ true,
+ null,
+ {
+ "json_class": "Range",
+ "data": [
+ 4,
+ 10,
+ false
+ ]
+ }
+ ]
+
+There are also the methods Kernel#j for generate, and Kernel#jj for
+pretty_generate output to the console, that work analogous to Core Ruby's p and
+the pp library's pp methods.
+
+The script tools/server.rb contains a small example if you want to test, how
+receiving a JSON object from a webrick server in your browser with the
+javasript prototype library http://www.prototypejs.org works.
+
+== Speed Comparisons
+
+I have created some benchmark results (see the benchmarks/data-p4-3Ghz
+subdir of the package) for the JSON-parser to estimate the speed up in the C
+extension:
+
+ Comparing times (call_time_mean):
+ 1 ParserBenchmarkExt#parser 900 repeats:
+ 553.922304770 ( real) -> 21.500x
+ 0.001805307
+ 2 ParserBenchmarkYAML#parser 1000 repeats:
+ 224.513358139 ( real) -> 8.714x
+ 0.004454078
+ 3 ParserBenchmarkPure#parser 1000 repeats:
+ 26.755020642 ( real) -> 1.038x
+ 0.037376163
+ 4 ParserBenchmarkRails#parser 1000 repeats:
+ 25.763381731 ( real) -> 1.000x
+ 0.038814780
+ calls/sec ( time) -> speed covers
+ secs/call
+
+In the table above 1 is JSON::Ext::Parser, 2 is YAML.load with YAML
+compatbile JSON document, 3 is is JSON::Pure::Parser, and 4 is
+ActiveSupport::JSON.decode. The ActiveSupport JSON-decoder converts the
+input first to YAML and then uses the YAML-parser, the conversion seems to
+slow it down so much that it is only as fast as the JSON::Pure::Parser!
+
+If you look at the benchmark data you can see that this is mostly caused by
+the frequent high outliers - the median of the Rails-parser runs is still
+overall smaller than the median of the JSON::Pure::Parser runs:
+
+ Comparing times (call_time_median):
+ 1 ParserBenchmarkExt#parser 900 repeats:
+ 800.592479481 ( real) -> 26.936x
+ 0.001249075
+ 2 ParserBenchmarkYAML#parser 1000 repeats:
+ 271.002390644 ( real) -> 9.118x
+ 0.003690004
+ 3 ParserBenchmarkRails#parser 1000 repeats:
+ 30.227910865 ( real) -> 1.017x
+ 0.033082008
+ 4 ParserBenchmarkPure#parser 1000 repeats:
+ 29.722384421 ( real) -> 1.000x
+ 0.033644676
+ calls/sec ( time) -> speed covers
+ secs/call
+
+I have benchmarked the JSON-Generator as well. This generated a few more
+values, because there are different modes that also influence the achieved
+speed:
+
+ Comparing times (call_time_mean):
+ 1 GeneratorBenchmarkExt#generator_fast 1000 repeats:
+ 547.354332608 ( real) -> 15.090x
+ 0.001826970
+ 2 GeneratorBenchmarkExt#generator_safe 1000 repeats:
+ 443.968212317 ( real) -> 12.240x
+ 0.002252414
+ 3 GeneratorBenchmarkExt#generator_pretty 900 repeats:
+ 375.104545883 ( real) -> 10.341x
+ 0.002665923
+ 4 GeneratorBenchmarkPure#generator_fast 1000 repeats:
+ 49.978706968 ( real) -> 1.378x
+ 0.020008521
+ 5 GeneratorBenchmarkRails#generator 1000 repeats:
+ 38.531868759 ( real) -> 1.062x
+ 0.025952543
+ 6 GeneratorBenchmarkPure#generator_safe 1000 repeats:
+ 36.927649925 ( real) -> 1.018x 7 (>=3859)
+ 0.027079979
+ 7 GeneratorBenchmarkPure#generator_pretty 1000 repeats:
+ 36.272134441 ( real) -> 1.000x 6 (>=3859)
+ 0.027569373
+ calls/sec ( time) -> speed covers
+ secs/call
+
+In the table above 1-3 are JSON::Ext::Generator methods. 4, 6, and 7 are
+JSON::Pure::Generator methods and 5 is the Rails JSON generator. It is now a
+bit faster than the generator_safe and generator_pretty methods of the pure
+variant but slower than the others.
+
+To achieve the fastest JSON document output, you can use the fast_generate
+method. Beware, that this will disable the checking for circular Ruby data
+structures, which may cause JSON to go into an infinite loop.
+
+Here are the median comparisons for completeness' sake:
+
+ Comparing times (call_time_median):
+ 1 GeneratorBenchmarkExt#generator_fast 1000 repeats:
+ 708.258020939 ( real) -> 16.547x
+ 0.001411915
+ 2 GeneratorBenchmarkExt#generator_safe 1000 repeats:
+ 569.105020353 ( real) -> 13.296x
+ 0.001757145
+ 3 GeneratorBenchmarkExt#generator_pretty 900 repeats:
+ 482.825371244 ( real) -> 11.280x
+ 0.002071142
+ 4 GeneratorBenchmarkPure#generator_fast 1000 repeats:
+ 62.717626652 ( real) -> 1.465x
+ 0.015944481
+ 5 GeneratorBenchmarkRails#generator 1000 repeats:
+ 43.965681162 ( real) -> 1.027x
+ 0.022745013
+ 6 GeneratorBenchmarkPure#generator_safe 1000 repeats:
+ 43.929073409 ( real) -> 1.026x 7 (>=3859)
+ 0.022763968
+ 7 GeneratorBenchmarkPure#generator_pretty 1000 repeats:
+ 42.802514491 ( real) -> 1.000x 6 (>=3859)
+ 0.023363113
+ calls/sec ( time) -> speed covers
+ secs/call
+
+== Author
+
+Florian Frank <mailto:flori@ping.de>
+
+== License
+
+Ruby License, see the COPYING file included in the source distribution. The
+Ruby License includes the GNU General Public License (GPL), Version 2, so see
+the file GPL as well.
+
+== Download
+
+The latest version of this library can be downloaded at
+
+* http://rubyforge.org/frs?group_id=953
+
+Online Documentation should be located at
+
+* http://json.rubyforge.org
View
33 lib/heroku/vendor/json_pure-1.5.1/README-json-jruby.markdown
@@ -0,0 +1,33 @@
+JSON-JRuby
+==========
+
+JSON-JRuby is a port of Florian Frank's native
+[`json` library](http://json.rubyforge.org/) to JRuby.
+It aims to be a perfect drop-in replacement for `json_pure`.
+
+
+Development version
+===================
+
+The latest version is available from the
+[Git repository](http://github.com/mernen/json-jruby/tree):
+
+ git clone git://github.com/mernen/json-jruby.git
+
+
+Compiling
+=========
+
+You'll need JRuby version 1.2 or greater to build JSON-JRuby.
+Its path must be set on the `jruby.dir` property of
+`nbproject/project.properties` (defaults to `../jruby`).
+
+Additionally, you'll need [Ant](http://ant.apache.org/), and
+[Ragel](http://www.cs.queensu.ca/~thurston/ragel/) 6.4 or greater.
+
+Then, from the folder where the sources are located, type:
+
+ ant clean jar
+
+to clean any leftovers from previous builds and generate the `.jar` files.
+To generate a RubyGem, specify the `gem` action rather than `jar`.
View
401 lib/heroku/vendor/json_pure-1.5.1/Rakefile
@@ -0,0 +1,401 @@
+begin
+ require 'rake/gempackagetask'
+rescue LoadError
+end
+
+begin
+ require 'rake/extensiontask'
+rescue LoadError
+ warn "WARNING: rake-compiler is not installed. You will not be able to build the json gem until you install it."
+end
+
+require 'rbconfig'
+include Config
+
+require 'rake/clean'
+CLOBBER.include Dir['benchmarks/data/*.{dat,log}']
+CLEAN.include FileList['diagrams/*.*'], 'doc', 'coverage', 'tmp',
+ FileList["ext/**/{Makefile,mkmf.log}"], 'build', 'dist', FileList['**/*.rbc'],
+ FileList["{ext,lib}/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def,jar,class}"],
+ FileList['java/src/**/*.class']
+
+MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
+PKG_NAME = 'json'
+PKG_TITLE = 'JSON Implementation for Ruby'
+PKG_VERSION = File.read('VERSION').chomp
+PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|tmp|coverage|Makefile|\.nfs\.|\.iml\Z/).exclude(/\.(so|bundle|o|class|#{CONFIG['DLEXT']})$/)
+
+EXT_ROOT_DIR = 'ext/json/ext'
+EXT_PARSER_DIR = "#{EXT_ROOT_DIR}/parser"
+EXT_PARSER_DL = "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}"
+RAGEL_PATH = "#{EXT_PARSER_DIR}/parser.rl"
+EXT_PARSER_SRC = "#{EXT_PARSER_DIR}/parser.c"
+PKG_FILES << EXT_PARSER_SRC
+EXT_GENERATOR_DIR = "#{EXT_ROOT_DIR}/generator"
+EXT_GENERATOR_DL = "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}"
+EXT_GENERATOR_SRC = "#{EXT_GENERATOR_DIR}/generator.c"
+
+JAVA_DIR = "java/src/json/ext"
+JAVA_RAGEL_PATH = "#{JAVA_DIR}/Parser.rl"
+JAVA_PARSER_SRC = "#{JAVA_DIR}/Parser.java"
+JAVA_SOURCES = FileList["#{JAVA_DIR}/*.java"]
+JAVA_CLASSES = []
+JRUBY_PARSER_JAR = File.expand_path("lib/json/ext/parser.jar")
+JRUBY_GENERATOR_JAR = File.expand_path("lib/json/ext/generator.jar")
+
+RAGEL_CODEGEN = %w[rlcodegen rlgen-cd ragel].find { |c| system(c, '-v') }
+RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find { |c| system(c, '-v') }
+
+def myruby(*args, &block)
+ @myruby ||= File.join(CONFIG['bindir'], CONFIG['ruby_install_name'])
+ options = (Hash === args.last) ? args.pop : {}
+ if args.length > 1 then
+ sh(*([@myruby] + args + [options]), &block)
+ else
+ sh("#{@myruby} #{args.first}", options, &block)
+ end
+end
+
+desc "Installing library (pure)"
+task :install_pure => :version do
+ myruby 'install.rb'
+end
+
+task :install_ext_really do
+ sitearchdir = CONFIG["sitearchdir"]
+ cd 'ext' do
+ for file in Dir["json/ext/*.#{CONFIG['DLEXT']}"]
+ d = File.join(sitearchdir, file)
+ mkdir_p File.dirname(d)
+ install(file, d)
+ end
+ end
+end
+
+desc "Installing library (extension)"
+task :install_ext => [ :compile_ext, :install_pure, :install_ext_really ]
+
+desc "Installing library (extension)"
+if RUBY_PLATFORM =~ /java/
+ task :install => :install_pure
+else
+ task :install => :install_ext
+end
+
+if defined?(Gem) and defined?(Rake::GemPackageTask)
+ spec_pure = Gem::Specification.new do |s|
+ s.name = 'json_pure'
+ s.version = PKG_VERSION
+ s.summary = PKG_TITLE
+ s.description = "This is a JSON implementation in pure Ruby."
+
+ s.files = PKG_FILES
+
+ s.require_path = 'lib'
+
+ s.bindir = "bin"
+ s.executables = [ "edit_json.rb", "prettify_json.rb" ]
+ s.default_executable = "edit_json.rb"
+
+ s.has_rdoc = true
+ s.extra_rdoc_files << 'README'
+ s.rdoc_options <<
+ '--title' << 'JSON implemention for ruby' << '--main' << 'README'
+ s.test_files.concat Dir['./tests/test_*.rb']
+
+ s.author = "Florian Frank"
+ s.email = "flori@ping.de"
+ s.homepage = "http://flori.github.com/#{PKG_NAME}"
+ s.rubyforge_project = "json"
+ end
+
+ Rake::GemPackageTask.new(spec_pure) do |pkg|
+ pkg.need_tar = true
+ pkg.package_files = PKG_FILES
+ end
+end
+
+if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::ExtensionTask)
+ spec_ext = Gem::Specification.new do |s|
+ s.name = 'json'
+ s.version = PKG_VERSION
+ s.summary = PKG_TITLE
+ s.description = "This is a JSON implementation as a Ruby extension in C."
+
+ s.files = PKG_FILES
+
+ s.extensions = FileList['ext/**/extconf.rb']
+
+ s.require_path = EXT_ROOT_DIR
+ s.require_paths << 'ext'
+ s.require_paths << 'lib'
+
+ s.bindir = "bin"
+ s.executables = [ "edit_json.rb", "prettify_json.rb" ]
+ s.default_executable = "edit_json.rb"
+
+ s.has_rdoc = true
+ s.extra_rdoc_files << 'README'
+ s.rdoc_options <<
+ '--title' << 'JSON implemention for Ruby' << '--main' << 'README'
+ s.test_files.concat Dir['./tests/test_*.rb']
+
+ s.author = "Florian Frank"
+ s.email = "flori@ping.de"
+ s.homepage = "http://flori.github.com/#{PKG_NAME}"
+ s.rubyforge_project = "json"
+ end
+
+ Rake::GemPackageTask.new(spec_ext) do |pkg|
+ pkg.need_tar = true
+ pkg.package_files = PKG_FILES
+ end
+
+ Rake::ExtensionTask.new do |ext|
+ ext.name = 'parser'
+ ext.gem_spec = spec_ext
+ ext.cross_compile = true
+ ext.cross_platform = %w[i386-mswin32 i386-mingw32]
+ ext.ext_dir = 'ext/json/ext/parser'
+ ext.lib_dir = 'lib/json/ext'
+ end
+
+ Rake::ExtensionTask.new do |ext|
+ ext.name = 'generator'
+ ext.gem_spec = spec_ext
+ ext.cross_compile = true
+ ext.cross_platform = %w[i386-mswin32 i386-mingw32]
+ ext.ext_dir = 'ext/json/ext/generator'
+ ext.lib_dir = 'lib/json/ext'
+ end
+end
+
+desc m = "Writing version information for #{PKG_VERSION}"
+task :version do
+ puts m
+ File.open(File.join('lib', 'json', 'version.rb'), 'w') do |v|
+ v.puts <<EOT
+module JSON
+ # JSON version
+ VERSION = '#{PKG_VERSION}'
+ VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
+ VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
+ VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
+ VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
+end
+EOT
+ end
+end
+
+desc "Testing library (pure ruby)"
+task :test_pure => :clean do
+ ENV['JSON'] = 'pure'
+ ENV['RUBYOPT'] = "-Ilib #{ENV['RUBYOPT']}"
+ myruby '-S', 'testrb', *Dir['./tests/test_*.rb']
+end
+
+desc "Testing library (pure ruby and extension)"
+task :test => [ :test_pure, :test_ext ]
+
+
+if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
+ file JAVA_PARSER_SRC => JAVA_RAGEL_PATH do
+ cd JAVA_DIR do
+ if RAGEL_CODEGEN == 'ragel'
+ sh "ragel Parser.rl -J -o Parser.java"
+ else
+ sh "ragel -x Parser.rl | #{RAGEL_CODEGEN} -J"
+ end
+ end
+ end
+
+ desc "Generate parser for java with ragel"
+ task :ragel => JAVA_PARSER_SRC
+
+ desc "Delete the ragel generated Java source"
+ task :ragel_clean do
+ rm_rf JAVA_PARSER_SRC
+ end
+
+ JRUBY_JAR = File.join(Config::CONFIG["libdir"], "jruby.jar")
+ if File.exist?(JRUBY_JAR)
+ JAVA_SOURCES.each do |src|
+ classpath = (Dir['java/lib/*.jar'] << 'java/src' << JRUBY_JAR) * ':'
+ obj = src.sub(/\.java\Z/, '.class')
+ file obj => src do
+ sh 'javac', '-classpath', classpath, '-source', '1.5', src
+ end
+ JAVA_CLASSES << obj
+ end
+ else
+ warn "WARNING: Cannot find jruby in path => Cannot build jruby extension!"
+ end
+
+ desc "Compiling jruby extension"
+ task :compile_ext => JAVA_CLASSES
+
+ desc "Package the jruby gem"
+ task :jruby_gem => :create_jar do
+ sh 'gem build json-java.gemspec'
+ mkdir_p 'pkg'
+ mv "json-#{PKG_VERSION}-java.gem", 'pkg'
+ end
+
+ desc "Testing library (jruby)"
+ task :test_ext => :create_jar do
+ ENV['JSON'] = 'ext'
+ myruby '-S', 'testrb', '-Ilib', *Dir['./tests/test_*.rb']
+ end
+
+ file JRUBY_PARSER_JAR => :compile_ext do
+ cd 'java/src' do
+ parser_classes = FileList[
+ "json/ext/ByteListTranscoder*.class",
+ "json/ext/OptionsReader*.class",
+ "json/ext/Parser*.class",
+ "json/ext/RuntimeInfo*.class",
+ "json/ext/StringDecoder*.class",
+ "json/ext/Utils*.class"
+ ]
+ sh 'jar', 'cf', File.basename(JRUBY_PARSER_JAR), *parser_classes
+ mv File.basename(JRUBY_PARSER_JAR), File.dirname(JRUBY_PARSER_JAR)
+ end
+ end
+
+ desc "Create parser jar"
+ task :create_parser_jar => JRUBY_PARSER_JAR
+
+ file JRUBY_GENERATOR_JAR => :compile_ext do
+ cd 'java/src' do
+ generator_classes = FileList[
+ "json/ext/ByteListTranscoder*.class",
+ "json/ext/OptionsReader*.class",
+ "json/ext/Generator*.class",
+ "json/ext/RuntimeInfo*.class",
+ "json/ext/StringEncoder*.class",
+ "json/ext/Utils*.class"
+ ]
+ sh 'jar', 'cf', File.basename(JRUBY_GENERATOR_JAR), *generator_classes
+ mv File.basename(JRUBY_GENERATOR_JAR), File.dirname(JRUBY_GENERATOR_JAR)
+ end
+ end
+
+ desc "Create generator jar"
+ task :create_generator_jar => JRUBY_GENERATOR_JAR
+
+ desc "Create parser and generator jars"
+ task :create_jar => [ :create_parser_jar, :create_generator_jar ]
+
+ desc "Build all gems and archives for a new release of the jruby extension."
+ task :release => [ :clean, :version, :jruby_gem ]
+else
+ desc "Compiling extension"
+ task :compile_ext => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
+
+ file EXT_PARSER_DL => EXT_PARSER_SRC do
+ cd EXT_PARSER_DIR do
+ myruby 'extconf.rb'
+ sh MAKE
+ end
+ cp "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
+ end
+
+ file EXT_GENERATOR_DL => EXT_GENERATOR_SRC do
+ cd EXT_GENERATOR_DIR do
+ myruby 'extconf.rb'
+ sh MAKE
+ end
+ cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
+ end
+
+ desc "Testing library (extension)"
+ task :test_ext => :compile_ext do
+ ENV['JSON'] = 'ext'
+ ENV['RUBYOPT'] = "-Iext:lib #{ENV['RUBYOPT']}"
+ myruby '-S', 'testrb', *Dir['./tests/test_*.rb']
+ end
+
+ desc "Benchmarking parser"
+ task :benchmark_parser do
+ ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
+ myruby 'benchmarks/parser_benchmark.rb'
+ myruby 'benchmarks/parser2_benchmark.rb'
+ end
+
+ desc "Benchmarking generator"
+ task :benchmark_generator do
+ ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
+ myruby 'benchmarks/generator_benchmark.rb'
+ myruby 'benchmarks/generator2_benchmark.rb'
+ end
+
+ desc "Benchmarking library"
+ task :benchmark => [ :benchmark_parser, :benchmark_generator ]
+
+ desc "Create RDOC documentation"
+ task :doc => [ :version, EXT_PARSER_SRC ] do
+ sh "sdoc -o doc -t '#{PKG_TITLE}' -m README README lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
+ end
+
+ desc "Generate parser with ragel"
+ task :ragel => EXT_PARSER_SRC
+
+ desc "Delete the ragel generated C source"
+ task :ragel_clean do
+ rm_rf EXT_PARSER_SRC
+ end
+
+ file EXT_PARSER_SRC => RAGEL_PATH do
+ cd EXT_PARSER_DIR do
+ if RAGEL_CODEGEN == 'ragel'
+ sh "ragel parser.rl -G2 -o parser.c"
+ else
+ sh "ragel -x parser.rl | #{RAGEL_CODEGEN} -G2"
+ end
+ end
+ end
+
+ desc "Generate diagrams of ragel parser (ps)"
+ task :ragel_dot_ps do
+ root = 'diagrams'
+ specs = []
+ File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
+ for s in specs
+ if RAGEL_DOTGEN == 'ragel'
+ sh "ragel #{RAGEL_PATH} -S#{s} -p -V | dot -Tps -o#{root}/#{s}.ps"
+ else
+ sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tps -o#{root}/#{s}.ps"
+ end
+ end
+ end
+
+ desc "Generate diagrams of ragel parser (png)"
+ task :ragel_dot_png do
+ root = 'diagrams'
+ specs = []
+ File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
+ for s in specs
+ if RAGEL_DOTGEN == 'ragel'
+ sh "ragel #{RAGEL_PATH} -S#{s} -p -V | dot -Tpng -o#{root}/#{s}.png"
+ else
+ sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tpng -o#{root}/#{s}.png"
+ end
+ end
+ end
+
+ desc "Generate diagrams of ragel parser"
+ task :ragel_dot => [ :ragel_dot_png, :ragel_dot_ps ]
+
+ task :environment do
+ ENV['RUBY_CC_VERSION'] = '1.8.7:1.9.2'
+ end
+
+ desc "Build all gems and archives for a new release of json and json_pure."
+ task :release => [ :clean, :version, :environment, :cross, :native, :gem, ] do
+ sh "#$0 clean native gem"
+ sh "#$0 clean package"
+ end
+end
+
+desc "Compile in the the source directory"
+task :default => [ :version ]
View
1 lib/heroku/vendor/json_pure-1.5.1/TODO
@@ -0,0 +1 @@
+
View
1 lib/heroku/vendor/json_pure-1.5.1/VERSION
@@ -0,0 +1 @@
+1.5.1
View
10 lib/heroku/vendor/json_pure-1.5.1/lib/json.rb
@@ -0,0 +1,10 @@
+require 'json/common'
+module JSON
+ require 'json/version'
+
+ begin
+ require 'json/ext'
+ rescue LoadError
+ require 'json/pure'
+ end
+end
View
147 lib/heroku/vendor/json_pure-1.5.1/lib/json/add/core.rb
@@ -0,0 +1,147 @@
+# This file contains implementations of ruby core's custom objects for
+# serialisation/deserialisation.
+
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+require 'date'
+
+class Symbol
+ def to_json(*a)
+ {
+ JSON.create_id => self.class.name,
+ 's' => to_s,
+ }.to_json(*a)
+ end
+
+ def self.json_create(o)
+ o['s'].to_sym
+ end
+end
+
+class Time
+ def self.json_create(object)
+ if usec = object.delete('u') # used to be tv_usec -> tv_nsec
+ object['n'] = usec * 1000
+ end
+ if respond_to?(:tv_nsec)
+ at(*object.values_at('s', 'n'))
+ else
+ at(object['s'], object['n'] / 1000)
+ end
+ end
+
+ def to_json(*args)
+ {
+ JSON.create_id => self.class.name,
+ 's' => tv_sec,
+ 'n' => respond_to?(:tv_nsec) ? tv_nsec : tv_usec * 1000
+ }.to_json(*args)
+ end
+end
+
+class Date
+ def self.json_create(object)
+ civil(*object.values_at('y', 'm', 'd', 'sg'))
+ end
+
+ alias start sg unless method_defined?(:start)
+
+ def to_json(*args)
+ {
+ JSON.create_id => self.class.name,
+ 'y' => year,
+ 'm' => month,
+ 'd' => day,
+ 'sg' => start,
+ }.to_json(*args)
+ end
+end
+
+class DateTime
+ def self.json_create(object)
+ args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
+ of_a, of_b = object['of'].split('/')
+ if of_b and of_b != '0'
+ args << Rational(of_a.to_i, of_b.to_i)
+ else
+ args << of_a
+ end
+ args << object['sg']
+ civil(*args)
+ end
+
+ alias start sg unless method_defined?(:start)
+
+ def to_json(*args)
+ {
+ JSON.create_id => self.class.name,
+ 'y' => year,
+ 'm' => month,
+ 'd' => day,
+ 'H' => hour,
+ 'M' => min,
+ 'S' => sec,
+ 'of' => offset.to_s,
+ 'sg' => start,
+ }.to_json(*args)
+ end
+end
+
+class Range
+ def self.json_create(object)
+ new(*object['a'])
+ end
+
+ def to_json(*args)
+ {
+ JSON.create_id => self.class.name,
+ 'a' => [ first, last, exclude_end? ]
+ }.to_json(*args)
+ end
+end
+
+class Struct
+ def self.json_create(object)
+ new(*object['v'])
+ end
+
+ def to_json(*args)
+ klass = self.class.name
+ klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!"
+ {
+ JSON.create_id => klass,
+ 'v' => values,
+ }.to_json(*args)
+ end
+end
+
+class Exception
+ def self.json_create(object)
+ result = new(object['m'])
+ result.set_backtrace object['b']
+ result
+ end
+
+ def to_json(*args)
+ {
+ JSON.create_id => self.class.name,
+ 'm' => message,
+ 'b' => backtrace,
+ }.to_json(*args)
+ end
+end
+
+class Regexp
+ def self.json_create(object)
+ new(object['s'], object['o'])
+ end
+
+ def to_json(*)
+ {
+ JSON.create_id => self.class.name,
+ 'o' => options,
+ 's' => source,
+ }.to_json
+ end
+end
View
8 lib/heroku/vendor/json_pure-1.5.1/lib/json/add/rails.rb
@@ -0,0 +1,8 @@
+# This file used to implementations of rails custom objects for
+# serialisation/deserialisation and is obsoleted now.
+
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+
+$DEBUG and warn "required json/add/rails which is obsolete now!"
View
419 lib/heroku/vendor/json_pure-1.5.1/lib/json/common.rb
@@ -0,0 +1,419 @@
+require 'json/version'
+
+module JSON
+ class << self
+ # If _object_ is string-like parse the string and return the parsed result
+ # as a Ruby data structure. Otherwise generate a JSON text from the Ruby
+ # data structure object and return it.
+ #
+ # The _opts_ argument is passed through to generate/parse respectively, see
+ # generate and parse for their documentation.
+ def [](object, opts = {})
+ if object.respond_to? :to_str
+ JSON.parse(object.to_str, opts)
+ else
+ JSON.generate(object, opts)
+ end
+ end
+
+ # Returns the JSON parser class, that is used by JSON. This might be either
+ # JSON::Ext::Parser or JSON::Pure::Parser.
+ attr_reader :parser
+
+ # Set the JSON parser class _parser_ to be used by JSON.
+ def parser=(parser) # :nodoc:
+ @parser = parser
+ remove_const :Parser if JSON.const_defined_in?(self, :Parser)
+ const_set :Parser, parser
+ end
+
+ # Return the constant located at _path_. The format of _path_ has to be
+ # either ::A::B::C or A::B::C. In any case A has to be located at the top
+ # level (absolute namespace path?). If there doesn't exist a constant at
+ # the given path, an ArgumentError is raised.
+ def deep_const_get(path) # :nodoc:
+ path.to_s.split(/::/).inject(Object) do |p, c|
+ case
+ when c.empty? then p
+ when JSON.const_defined_in?(p, c) then p.const_get(c)
+ else
+ begin
+ p.const_missing(c)
+ rescue NameError => e
+ raise ArgumentError, "can't get const #{path}: #{e}"
+ end
+ end
+ end
+ end
+
+ # Set the module _generator_ to be used by JSON.
+ def generator=(generator) # :nodoc:
+ old, $VERBOSE = $VERBOSE, nil
+ @generator = generator
+ generator_methods = generator::GeneratorMethods
+ for const in generator_methods.constants
+ klass = deep_const_get(const)
+ modul = generator_methods.const_get(const)
+ klass.class_eval do
+ instance_methods(false).each do |m|
+ m.to_s == 'to_json' and remove_method m
+ end
+ include modul
+ end
+ end
+ self.state = generator::State
+ const_set :State, self.state
+ const_set :SAFE_STATE_PROTOTYPE, State.new
+ const_set :FAST_STATE_PROTOTYPE, State.new(
+ :indent => '',
+ :space => '',
+ :object_nl => "",
+ :array_nl => "",
+ :max_nesting => false
+ )
+ const_set :PRETTY_STATE_PROTOTYPE, State.new(
+ :indent => ' ',
+ :space => ' ',
+ :object_nl => "\n",
+ :array_nl => "\n"
+ )
+ ensure
+ $VERBOSE = old
+ end
+
+ # Returns the JSON generator modul, that is used by JSON. This might be
+ # either JSON::Ext::Generator or JSON::Pure::Generator.
+ attr_reader :generator
+
+ # Returns the JSON generator state class, that is used by JSON. This might
+ # be either JSON::Ext::Generator::State or JSON::Pure::Generator::State.
+ attr_accessor :state
+
+ # This is create identifier, that is used to decide, if the _json_create_
+ # hook of a class should be called. It defaults to 'json_class'.
+ attr_accessor :create_id
+ end
+ self.create_id = 'json_class'
+
+ NaN = 0.0/0
+
+ Infinity = 1.0/0
+
+ MinusInfinity = -Infinity
+
+ # The base exception for JSON errors.
+ class JSONError < StandardError; end
+
+ # This exception is raised, if a parser error occurs.
+ class ParserError < JSONError; end
+
+ # This exception is raised, if the nesting of parsed datastructures is too
+ # deep.
+ class NestingError < ParserError; end
+
+ # :stopdoc:
+ class CircularDatastructure < NestingError; end
+ # :startdoc:
+
+ # This exception is raised, if a generator or unparser error occurs.
+ class GeneratorError < JSONError; end
+ # For backwards compatibility
+ UnparserError = GeneratorError
+
+ # This exception is raised, if the required unicode support is missing on the
+ # system. Usually this means, that the iconv library is not installed.
+ class MissingUnicodeSupport < JSONError; end
+
+ module_function
+
+ # Parse the JSON document _source_ into a Ruby data structure and return it.
+ #
+ # _opts_ can have the following
+ # keys:
+ # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
+ # structures. Disable depth checking with :max_nesting => false, it defaults
+ # to 19.
+ # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
+ # defiance of RFC 4627 to be parsed by the Parser. This option defaults
+ # to false.
+ # * *symbolize_names*: If set to true, returns symbols for the names
+ # (keys) in a JSON object. Otherwise strings are returned, which is also
+ # the default.
+ # * *create_additions*: If set to false, the Parser doesn't create
+ # additions even if a matchin class and create_id was found. This option
+ # defaults to true.
+ # * *object_class*: Defaults to Hash
+ # * *array_class*: Defaults to Array
+ def parse(source, opts = {})
+ Parser.new(source, opts).parse
+ end
+
+ # Parse the JSON document _source_ into a Ruby data structure and return it.
+ # The bang version of the parse method, defaults to the more dangerous values
+ # for the _opts_ hash, so be sure only to parse trusted _source_ documents.
+ #
+ # _opts_ can have the following keys:
+ # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
+ # structures. Enable depth checking with :max_nesting => anInteger. The parse!
+ # methods defaults to not doing max depth checking: This can be dangerous,
+ # if someone wants to fill up your stack.
+ # * *allow_nan*: If set to true, allow NaN, Infinity, and -Infinity in
+ # defiance of RFC 4627 to be parsed by the Parser. This option defaults
+ # to true.
+ # * *create_additions*: If set to false, the Parser doesn't create
+ # additions even if a matchin class and create_id was found. This option
+ # defaults to true.
+ def parse!(source, opts = {})
+ opts = {
+ :max_nesting => false,
+ :allow_nan => true
+ }.update(opts)
+ Parser.new(source, opts).parse
+ end
+
+ # Generate a JSON document from the Ruby data structure _obj_ and return
+ # it. _state_ is * a JSON::State object,
+ # * or a Hash like object (responding to to_hash),
+ # * an object convertible into a hash by a to_h method,
+ # that is used as or to configure a State object.
+ #
+ # It defaults to a state object, that creates the shortest possible JSON text
+ # in one line, checks for circular data structures and doesn't allow NaN,
+ # Infinity, and -Infinity.
+ #
+ # A _state_ hash can have the following keys:
+ # * *indent*: a string used to indent levels (default: ''),
+ # * *space*: a string that is put after, a : or , delimiter (default: ''),
+ # * *space_before*: a string that is put before a : pair delimiter (default: ''),
+ # * *object_nl*: a string that is put at the end of a JSON object (default: ''),
+ # * *array_nl*: a string that is put at the end of a JSON array (default: ''),
+ # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
+ # generated, otherwise an exception is thrown, if these values are
+ # encountered. This options defaults to false.
+ # * *max_nesting*: The maximum depth of nesting allowed in the data
+ # structures from which JSON is to be generated. Disable depth checking
+ # with :max_nesting => false, it defaults to 19.
+ #
+ # See also the fast_generate for the fastest creation method with the least
+ # amount of sanity checks, and the pretty_generate method for some
+ # defaults for a pretty output.
+ def generate(obj, opts = nil)
+ state = SAFE_STATE_PROTOTYPE.dup
+ if opts
+ if opts.respond_to? :to_hash
+ opts = opts.to_hash
+ elsif opts.respond_to? :to_h
+ opts = opts.to_h
+ else
+ raise TypeError, "can't convert #{opts.class} into Hash"
+ end
+ state = state.configure(opts)
+ end
+ state.generate(obj)
+ end
+
+ # :stopdoc:
+ # I want to deprecate these later, so I'll first be silent about them, and
+ # later delete them.
+ alias unparse generate
+ module_function :unparse
+ # :startdoc:
+
+ # Generate a JSON document from the Ruby data structure _obj_ and return it.
+ # This method disables the checks for circles in Ruby objects.
+ #
+ # *WARNING*: Be careful not to pass any Ruby data structures with circles as
+ # _obj_ argument, because this will cause JSON to go into an infinite loop.
+ def fast_generate(obj, opts = nil)
+ state = FAST_STATE_PROTOTYPE.dup
+ if opts
+ if opts.respond_to? :to_hash
+ opts = opts.to_hash
+ elsif opts.respond_to? :to_h
+ opts = opts.to_h
+ else
+ raise TypeError, "can't convert #{opts.class} into Hash"
+ end
+ state.configure(opts)
+ end
+ state.generate(obj)
+ end
+
+ # :stopdoc:
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
+ alias fast_unparse fast_generate
+ module_function :fast_unparse
+ # :startdoc:
+
+ # Generate a JSON document from the Ruby data structure _obj_ and return it.
+ # The returned document is a prettier form of the document returned by
+ # #unparse.
+ #
+ # The _opts_ argument can be used to configure the generator, see the
+ # generate method for a more detailed explanation.
+ def pretty_generate(obj, opts = nil)
+ state = PRETTY_STATE_PROTOTYPE.dup
+ if opts
+ if opts.respond_to? :to_hash
+ opts = opts.to_hash
+ elsif opts.respond_to? :to_h
+ opts = opts.to_h
+ else
+ raise TypeError, "can't convert #{opts.class} into Hash"
+ end
+ state.configure(opts)
+ end
+ state.generate(obj)
+ end
+
+ # :stopdoc:
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
+ alias pretty_unparse pretty_generate
+ module_function :pretty_unparse
+ # :startdoc:
+
+ # Load a ruby data structure from a JSON _source_ and return it. A source can
+ # either be a string-like object, an IO like object, or an object responding
+ # to the read method. If _proc_ was given, it will be called with any nested
+ # Ruby object as an argument recursively in depth first order.
+ #
+ # This method is part of the implementation of the load/dump interface of
+ # Marshal and YAML.
+ def load(source, proc = nil)
+ if source.respond_to? :to_str
+ source = source.to_str
+ elsif source.respond_to? :to_io
+ source = source.to_io.read
+ else
+ source = source.read
+ end
+ result = parse(source, :max_nesting => false, :allow_nan => true)
+ recurse_proc(result, &proc) if proc
+ result
+ end
+
+ def recurse_proc(result, &proc)
+ case result
+ when Array
+ result.each { |x| recurse_proc x, &proc }
+ proc.call result
+ when Hash
+ result.each { |x, y| recurse_proc x, &proc; recurse_proc y, &proc }
+ proc.call result
+ else
+ proc.call result
+ end
+ end
+
+ alias restore load
+ module_function :restore
+
+ # Dumps _obj_ as a JSON string, i.e. calls generate on the object and returns
+ # the result.
+ #
+ # If anIO (an IO like object or an object that responds to the write method)
+ # was given, the resulting JSON is written to it.
+ #
+ # If the number of nested arrays or objects exceeds _limit_ an ArgumentError
+ # exception is raised. This argument is similar (but not exactly the
+ # same!) to the _limit_ argument in Marshal.dump.
+ #
+ # This method is part of the implementation of the load/dump interface of
+ # Marshal and YAML.
+ def dump(obj, anIO = nil, limit = nil)
+ if anIO and limit.nil?
+ anIO = anIO.to_io if anIO.respond_to?(:to_io)
+ unless anIO.respond_to?(:write)
+ limit = anIO
+ anIO = nil
+ end
+ end
+ limit ||= 0
+ result = generate(obj, :allow_nan => true, :max_nesting => limit)
+ if anIO
+ anIO.write result
+ anIO
+ else
+ result
+ end
+ rescue JSON::NestingError
+ raise ArgumentError, "exceed depth limit"
+ end
+
+ # Swap consecutive bytes of _string_ in place.
+ def self.swap!(string) # :nodoc:
+ 0.upto(string.size / 2) do |i|
+ break unless string[2 * i + 1]
+ string[2 * i], string[2 * i + 1] = string[2 * i + 1], string[2 * i]
+ end
+ string
+ end
+
+ # Shortuct for iconv.
+ if ::String.method_defined?(:encode)
+ def self.iconv(to, from, string)
+ string.encode(to, from)
+ end
+ else
+ require 'iconv'
+ def self.iconv(to, from, string)
+ Iconv.iconv(to, from, string).first
+ end
+ end
+
+ if ::Object.method(:const_defined?).arity == 1
+ def self.const_defined_in?(modul, constant)
+ modul.const_defined?(constant)
+ end
+ else
+ def self.const_defined_in?(modul, constant)
+ modul.const_defined?(constant, false)
+ end
+ end
+end
+
+module ::Kernel
+ private
+
+ # Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
+ # one line.
+ def j(*objs)
+ objs.each do |obj|
+ puts JSON::generate(obj, :allow_nan => true, :max_nesting => false)
+ end
+ nil
+ end
+
+ # Ouputs _objs_ to STDOUT as JSON strings in a pretty format, with
+ # indentation and over many lines.
+ def jj(*objs)
+ objs.each do |obj|
+ puts JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)
+ end
+ nil
+ end
+
+ # If _object_ is string-like parse the string and return the parsed result as
+ # a Ruby data structure. Otherwise generate a JSON text from the Ruby data
+ # structure object and return it.
+ #
+ # The _opts_ argument is passed through to generate/parse respectively, see
+ # generate and parse for their documentation.
+ def JSON(object, *args)
+ if object.respond_to? :to_str
+ JSON.parse(object.to_str, args.first)
+ else
+ JSON.generate(object, args.first)
+ end
+ end
+end
+
+class ::Class
+ # Returns true, if this class can be used to create an instance
+ # from a serialised JSON string. The class has to implement a class
+ # method _json_create_ that expects a hash as first parameter, which includes
+ # the required data.
+ def json_creatable?
+ respond_to?(:json_create)
+ end
+end
View
1,369 lib/heroku/vendor/json_pure-1.5.1/lib/json/editor.rb
@@ -0,0 +1,1369 @@
+# To use the GUI JSON editor, start the edit_json.rb executable script. It
+# requires ruby-gtk to be installed.
+
+require 'gtk2'
+require 'json'
+require 'rbconfig'
+require 'open-uri'
+
+module JSON
+ module Editor
+ include Gtk
+
+ # Beginning of the editor window title
+ TITLE = 'JSON Editor'.freeze
+
+ # Columns constants
+ ICON_COL, TYPE_COL, CONTENT_COL = 0, 1, 2
+
+ # JSON primitive types (Containers)
+ CONTAINER_TYPES = %w[Array Hash].sort
+ # All JSON primitive types
+ ALL_TYPES = (%w[TrueClass FalseClass Numeric String NilClass] +
+ CONTAINER_TYPES).sort
+
+ # The Nodes necessary for the tree representation of a JSON document
+ ALL_NODES = (ALL_TYPES + %w[Key]).sort
+
+ DEFAULT_DIALOG_KEY_PRESS_HANDLER = lambda do |dialog, event|
+ case event.keyval
+ when Gdk::Keyval::GDK_Return
+ dialog.response Dialog::RESPONSE_ACCEPT
+ when Gdk::Keyval::GDK_Escape
+ dialog.response Dialog::RESPONSE_REJECT
+ end
+ end
+
+ # Returns the Gdk::Pixbuf of the icon named _name_ from the icon cache.
+ def Editor.fetch_icon(name)
+ @icon_cache ||= {}
+ unless @icon_cache.key?(name)
+ path = File.dirname(__FILE__)
+ @icon_cache[name] = Gdk::Pixbuf.new(File.join(path, name + '.xpm'))
+ end
+ @icon_cache[name]
+ end
+
+ # Opens an error dialog on top of _window_ showing the error message
+ # _text_.
+ def Editor.error_dialog(window, text)
+ dialog = MessageDialog.new(window, Dialog::MODAL,
+ MessageDialog::ERROR,
+ MessageDialog::BUTTONS_CLOSE, text)
+ dialog.show_all
+ dialog.run
+ rescue TypeError
+ dialog = MessageDialog.new(Editor.window, Dialog::MODAL,
+ MessageDialog::ERROR,
+ MessageDialog::BUTTONS_CLOSE, text)
+ dialog.show_all
+ dialog.run
+ ensure
+ dialog.destroy if dialog
+ end
+
+ # Opens a yes/no question dialog on top of _window_ showing the error
+ # message _text_. If yes was answered _true_ is returned, otherwise
+ # _false_.
+ def Editor.question_dialog(window, text)
+ dialog = MessageDialog.new(window, Dialog::MODAL,
+ MessageDialog::QUESTION,
+ MessageDialog::BUTTONS_YES_NO, text)
+ dialog.show_all
+ dialog.run do |response|
+ return Gtk::Dialog::RESPONSE_YES === response
+ end
+ ensure
+ dialog.destroy if dialog
+ end
+
+ # Convert the tree model starting from Gtk::TreeIter _iter_ into a Ruby
+ # data structure and return it.
+ def Editor.model2data(iter)
+ return nil if iter.nil?
+ case iter.type
+ when 'Hash'
+ hash = {}
+ iter.each { |c| hash[c.content] = Editor.model2data(c.first_child) }
+ hash
+ when 'Array'
+ array = Array.new(iter.n_children)
+ iter.each_with_index { |c, i| array[i] = Editor.model2data(c) }
+ array
+ when 'Key'
+ iter.content
+ when 'String'
+ iter.content
+ when 'Numeric'
+ content = iter.content
+ if /\./.match(content)
+ content.to_f
+ else
+ content.to_i
+ end
+ when 'TrueClass'
+ true
+ when 'FalseClass'
+ false
+ when 'NilClass'
+ nil
+ else
+ fail "Unknown type found in model: #{iter.type}"
+ end
+ end
+
+ # Convert the Ruby data structure _data_ into tree model data for Gtk and
+ # returns the whole model. If the parameter _model_ wasn't given a new
+ # Gtk::TreeStore is created as the model. The _parent_ parameter specifies
+ # the parent node (iter, Gtk:TreeIter instance) to which the data is
+ # appended, alternativeley the result of the yielded block is used as iter.
+ def Editor.data2model(data, model = nil, parent = nil)
+ model ||= TreeStore.new(Gdk::Pixbuf, String, String)
+ iter = if block_given?
+ yield model
+ else
+ model.append(parent)
+ end
+ case data
+ when Hash
+ iter.type = 'Hash'
+ data.sort.each do |key, value|
+ pair_iter = model.append(iter)
+ pair_iter.type = 'Key'
+ pair_iter.content = key.to_s
+ Editor.data2model(value, model, pair_iter)
+ end
+ when Array
+ iter.type = 'Array'
+ data.each do |value|
+ Editor.data2model(value, model, iter)
+ end
+ when Numeric
+ iter.type = 'Numeric'
+ iter.content = data.to_s
+ when String, true, false, nil
+ iter.type = data.class.name
+ iter.content = data.nil? ? 'null' : data.to_s
+ else
+ iter.type = 'String'
+ iter.content = data.to_s
+ end
+ model
+ end
+
+ # The Gtk::TreeIter class is reopened and some auxiliary methods are added.
+ class Gtk::TreeIter
+ include Enumerable
+
+ # Traverse each of this Gtk::TreeIter instance's children
+ # and yield to them.
+ def each
+ n_children.times { |i| yield nth_child(i) }
+ end
+
+ # Recursively traverse all nodes of this Gtk::TreeIter's subtree
+ # (including self) and yield to them.
+ def recursive_each(&block)
+ yield self
+ each do |i|
+ i.recursive_each(&block)
+ end
+ end
+
+ # Remove the subtree of this Gtk::TreeIter instance from the
+ # model _model_.
+ def remove_subtree(model)
+ while current = first_child
+ model.remove(current)
+ end
+ end
+
+ # Returns the type of this node.
+ def type
+ self[TYPE_COL]
+ end
+
+ # Sets the type of this node to _value_. This implies setting
+ # the respective icon accordingly.
+ def type=(value)
+ self[TYPE_COL] = value
+ self[ICON_COL] = Editor.fetch_icon(value)
+ end
+
+ # Returns the content of this node.
+ def content
+ self[CONTENT_COL]
+ end
+
+ # Sets the content of this node to _value_.
+ def content=(value)
+ self[CONTENT_COL] = value
+ end
+ end
+
+ # This module bundles some method, that can be used to create a menu. It
+ # should be included into the class in question.
+ module MenuExtension
+ include Gtk
+
+ # Creates a Menu, that includes MenuExtension. _treeview_ is the
+ # Gtk::TreeView, on which it operates.
+ def initialize(treeview)
+ @treeview = treeview
+ @menu = Menu.new
+ end
+
+ # Returns the Gtk::TreeView of this menu.
+ attr_reader :treeview
+
+ # Returns the menu.
+ attr_reader :menu
+
+ # Adds a Gtk::SeparatorMenuItem to this instance's #menu.
+ def add_separator
+ menu.append SeparatorMenuItem.new
+ end
+
+ # Adds a Gtk::MenuItem to this instance's #menu. _label_ is the label
+ # string, _klass_ is the item type, and _callback_ is the procedure, that
+ # is called if the _item_ is activated.
+ def add_item(label, keyval = nil, klass = MenuItem, &callback)
+ label = "#{label} (C-#{keyval.chr})" if keyval
+ item = klass.new(label)