nutshell-crm 0.0.5 → 0.0.6.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rbenv-version +1 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +5 -0
- data/README.md +37 -0
- data/Rakefile +14 -3
- data/lib/nutshell-crm.rb +92 -5
- data/lib/nutshell-crm/version.rb +1 -1
- data/nutshell-crm.gemspec +1 -0
- data/spec/nutshell-crm_spec.rb +17 -8
- data/vendor/bundle/bin/rake +19 -0
- data/vendor/bundle/gems/json-1.6.4/.gitignore +8 -0
- data/vendor/bundle/gems/json-1.6.4/.travis.yml +15 -0
- data/vendor/bundle/gems/json-1.6.4/CHANGES +227 -0
- data/vendor/bundle/gems/json-1.6.4/COPYING +58 -0
- data/vendor/bundle/gems/json-1.6.4/COPYING-json-jruby +57 -0
- data/vendor/bundle/gems/json-1.6.4/GPL +340 -0
- data/vendor/bundle/gems/json-1.6.4/Gemfile +11 -0
- data/vendor/bundle/gems/json-1.6.4/README-json-jruby.markdown +33 -0
- data/vendor/bundle/gems/json-1.6.4/README.rdoc +358 -0
- data/vendor/bundle/gems/json-1.6.4/Rakefile +408 -0
- data/vendor/bundle/gems/json-1.6.4/TODO +1 -0
- data/vendor/bundle/gems/json-1.6.4/VERSION +1 -0
- data/{README → vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/.keep} +0 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +52 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +900 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +901 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +261 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +262 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +82 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +34 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +900 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +901 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +81 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +82 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +82 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +82 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data/.keep +0 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/generator2_benchmark.rb +222 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/generator_benchmark.rb +224 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/ohai.json +1216 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/ohai.ruby +1 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/parser2_benchmark.rb +251 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/parser_benchmark.rb +259 -0
- data/vendor/bundle/gems/json-1.6.4/data/example.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/data/index.html +38 -0
- data/vendor/bundle/gems/json-1.6.4/data/prototype.js +4184 -0
- data/vendor/bundle/gems/json-1.6.4/diagrams/.keep +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/fbuffer/fbuffer.h +156 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/generator/Makefile +187 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/generator/extconf.rb +13 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/generator/generator.bundle +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/generator/generator.c +1384 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/generator/generator.h +161 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/generator/generator.o +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/json/ext/generator.bundle +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/json/ext/parser.bundle +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/Makefile +187 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/extconf.rb +13 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/parser.bundle +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/parser.c +2203 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/parser.h +77 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/parser.o +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/parser.rl +926 -0
- data/vendor/bundle/gems/json-1.6.4/install.rb +19 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/ByteListTranscoder.java +167 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/Generator.java +437 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/GeneratorMethods.java +232 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/GeneratorService.java +43 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/GeneratorState.java +522 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/OptionsReader.java +113 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/Parser.java +2640 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/Parser.rl +964 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/ParserService.java +35 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/RuntimeInfo.java +121 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/StringDecoder.java +166 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/StringEncoder.java +106 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/Utils.java +89 -0
- data/vendor/bundle/gems/json-1.6.4/json-java.gemspec +22 -0
- data/vendor/bundle/gems/json-1.6.4/json.gemspec +40 -0
- data/vendor/bundle/gems/json-1.6.4/json_pure.gemspec +42 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json.rb +62 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/bigdecimal.rb +21 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/complex.rb +22 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/core.rb +11 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/date.rb +34 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/date_time.rb +50 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/exception.rb +31 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/ostruct.rb +31 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/range.rb +29 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/rational.rb +22 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/regexp.rb +30 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/struct.rb +30 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/symbol.rb +25 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/time.rb +35 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/common.rb +470 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/ext.rb +21 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/ext/.keep +0 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/pure.rb +21 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/pure/generator.rb +468 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/pure/parser.rb +359 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/version.rb +8 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail1.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail10.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail11.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail12.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail13.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail14.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail18.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail19.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail2.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail20.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail21.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail22.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail23.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail24.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail25.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail27.json +2 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail28.json +2 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail3.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail4.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail5.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail6.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail7.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail8.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail9.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass1.json +56 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass15.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass16.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass17.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass2.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass26.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass3.json +6 -0
- data/vendor/bundle/gems/json-1.6.4/tests/setup_variant.rb +11 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json.rb +527 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json_addition.rb +188 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json_encoding.rb +65 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json_fixtures.rb +35 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json_generate.rb +249 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json_string_matching.rb +40 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json_unicode.rb +72 -0
- data/vendor/bundle/gems/json-1.6.4/tools/fuzz.rb +139 -0
- data/vendor/bundle/gems/json-1.6.4/tools/server.rb +62 -0
- data/vendor/bundle/gems/rake-0.9.2.2/.gemtest +0 -0
- data/vendor/bundle/gems/rake-0.9.2.2/CHANGES +522 -0
- data/vendor/bundle/gems/rake-0.9.2.2/MIT-LICENSE +21 -0
- data/vendor/bundle/gems/rake-0.9.2.2/README.rdoc +197 -0
- data/vendor/bundle/gems/rake-0.9.2.2/Rakefile +369 -0
- data/vendor/bundle/gems/rake-0.9.2.2/TODO +20 -0
- data/vendor/bundle/gems/rake-0.9.2.2/bin/rake +33 -0
- data/vendor/bundle/gems/rake-0.9.2.2/install.rb +90 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake.rb +69 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/alt_system.rb +109 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/application.rb +595 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/classic_namespace.rb +11 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/clean.rb +32 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/cloneable.rb +25 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/contrib/compositepublisher.rb +21 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/contrib/ftptools.rb +150 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/contrib/publisher.rb +73 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/contrib/rubyforgepublisher.rb +16 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/contrib/sshpublisher.rb +50 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/contrib/sys.rb +191 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/default_loader.rb +10 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/dsl_definition.rb +176 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/early_time.rb +18 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/ext/core.rb +27 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/ext/module.rb +39 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/ext/string.rb +167 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/ext/time.rb +14 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_creation_task.rb +24 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_list.rb +403 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_task.rb +47 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_utils.rb +114 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb +145 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/gempackagetask.rb +15 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/invocation_chain.rb +51 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/invocation_exception_mixin.rb +16 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/loaders/makefile.rb +40 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/multi_task.rb +16 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/name_space.rb +25 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/packagetask.rb +185 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/pathmap.rb +1 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/pseudo_status.rb +24 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/rake_module.rb +29 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb +22 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/rdoctask.rb +234 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/ruby182_test_unit_fix.rb +25 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/rule_recursion_overflow_error.rb +20 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/runtest.rb +21 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/task.rb +327 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/task_argument_error.rb +7 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/task_arguments.rb +78 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/task_manager.rb +307 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/tasklib.rb +22 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/testtask.rb +191 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/version.rb +8 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/win32.rb +55 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/file_creation.rb +34 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/helper.rb +492 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake.rb +40 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_application.rb +489 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_application_options.rb +335 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_clean.rb +14 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_definitions.rb +80 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_directory_task.rb +46 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_dsl.rb +77 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_early_time.rb +31 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_extension.rb +59 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_file_creation_task.rb +56 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_file_list.rb +628 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_file_list_path_map.rb +8 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_file_task.rb +102 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_file_utils.rb +305 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_ftp_file.rb +59 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_functional.rb +450 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_invocation_chain.rb +52 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_makefile_loader.rb +44 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_multi_task.rb +51 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_name_space.rb +43 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_package_task.rb +79 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_path_map.rb +157 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_path_map_explode.rb +34 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_path_map_partial.rb +18 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_pseudo_status.rb +21 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_rake_test_loader.rb +21 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_rdoc_task.rb +83 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_require.rb +40 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_rules.rb +327 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task.rb +267 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task_argument_parsing.rb +103 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task_arguments.rb +88 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task_lib.rb +9 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task_manager.rb +157 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task_manager_argument_resolution.rb +36 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task_with_arguments.rb +173 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_test_task.rb +120 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_top_level_functions.rb +111 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_win32.rb +72 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_sys.rb +20 -0
- data/vendor/bundle/specifications/json-1.6.4.gemspec +39 -0
- data/vendor/bundle/specifications/rake-0.9.2.2.gemspec +34 -0
- metadata +285 -18
@@ -0,0 +1,77 @@
|
|
1
|
+
#ifndef _PARSER_H_
|
2
|
+
#define _PARSER_H_
|
3
|
+
|
4
|
+
#include "ruby.h"
|
5
|
+
|
6
|
+
#ifndef HAVE_RUBY_RE_H
|
7
|
+
#include "re.h"
|
8
|
+
#endif
|
9
|
+
|
10
|
+
#ifdef HAVE_RUBY_ST_H
|
11
|
+
#include "ruby/st.h"
|
12
|
+
#else
|
13
|
+
#include "st.h"
|
14
|
+
#endif
|
15
|
+
|
16
|
+
#define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key))
|
17
|
+
|
18
|
+
/* unicode */
|
19
|
+
|
20
|
+
typedef unsigned long UTF32; /* at least 32 bits */
|
21
|
+
typedef unsigned short UTF16; /* at least 16 bits */
|
22
|
+
typedef unsigned char UTF8; /* typically 8 bits */
|
23
|
+
|
24
|
+
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
|
25
|
+
#define UNI_SUR_HIGH_START (UTF32)0xD800
|
26
|
+
#define UNI_SUR_HIGH_END (UTF32)0xDBFF
|
27
|
+
#define UNI_SUR_LOW_START (UTF32)0xDC00
|
28
|
+
#define UNI_SUR_LOW_END (UTF32)0xDFFF
|
29
|
+
|
30
|
+
typedef struct JSON_ParserStruct {
|
31
|
+
VALUE Vsource;
|
32
|
+
char *source;
|
33
|
+
long len;
|
34
|
+
char *memo;
|
35
|
+
VALUE create_id;
|
36
|
+
int max_nesting;
|
37
|
+
int current_nesting;
|
38
|
+
int allow_nan;
|
39
|
+
int parsing_name;
|
40
|
+
int symbolize_names;
|
41
|
+
int quirks_mode;
|
42
|
+
VALUE object_class;
|
43
|
+
VALUE array_class;
|
44
|
+
int create_additions;
|
45
|
+
VALUE match_string;
|
46
|
+
FBuffer *fbuffer;
|
47
|
+
} JSON_Parser;
|
48
|
+
|
49
|
+
#define GET_PARSER \
|
50
|
+
GET_PARSER_INIT; \
|
51
|
+
if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance")
|
52
|
+
#define GET_PARSER_INIT \
|
53
|
+
JSON_Parser *json; \
|
54
|
+
Data_Get_Struct(self, JSON_Parser, json)
|
55
|
+
|
56
|
+
#define MinusInfinity "-Infinity"
|
57
|
+
#define EVIL 0x666
|
58
|
+
|
59
|
+
static UTF32 unescape_unicode(const unsigned char *p);
|
60
|
+
static int convert_UTF32_to_UTF8(char *buf, UTF32 ch);
|
61
|
+
static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
62
|
+
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
63
|
+
static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
64
|
+
static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
65
|
+
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
66
|
+
static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd);
|
67
|
+
static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
68
|
+
static VALUE convert_encoding(VALUE source);
|
69
|
+
static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self);
|
70
|
+
static VALUE cParser_parse(VALUE self);
|
71
|
+
static JSON_Parser *JSON_allocate();
|
72
|
+
static void JSON_mark(JSON_Parser *json);
|
73
|
+
static void JSON_free(JSON_Parser *json);
|
74
|
+
static VALUE cJSON_parser_s_allocate(VALUE klass);
|
75
|
+
static VALUE cParser_source(VALUE self);
|
76
|
+
|
77
|
+
#endif
|
Binary file
|
@@ -0,0 +1,926 @@
|
|
1
|
+
#include "../fbuffer/fbuffer.h"
|
2
|
+
#include "parser.h"
|
3
|
+
|
4
|
+
/* unicode */
|
5
|
+
|
6
|
+
static const char digit_values[256] = {
|
7
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
8
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
9
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
|
10
|
+
-1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
|
11
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
12
|
+
10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
13
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
14
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
15
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
16
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
17
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
18
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
19
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
20
|
+
-1, -1, -1, -1, -1, -1, -1
|
21
|
+
};
|
22
|
+
|
23
|
+
static UTF32 unescape_unicode(const unsigned char *p)
|
24
|
+
{
|
25
|
+
char b;
|
26
|
+
UTF32 result = 0;
|
27
|
+
b = digit_values[p[0]];
|
28
|
+
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
29
|
+
result = (result << 4) | b;
|
30
|
+
b = digit_values[p[1]];
|
31
|
+
result = (result << 4) | b;
|
32
|
+
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
33
|
+
b = digit_values[p[2]];
|
34
|
+
result = (result << 4) | b;
|
35
|
+
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
36
|
+
b = digit_values[p[3]];
|
37
|
+
result = (result << 4) | b;
|
38
|
+
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
39
|
+
return result;
|
40
|
+
}
|
41
|
+
|
42
|
+
static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
|
43
|
+
{
|
44
|
+
int len = 1;
|
45
|
+
if (ch <= 0x7F) {
|
46
|
+
buf[0] = (char) ch;
|
47
|
+
} else if (ch <= 0x07FF) {
|
48
|
+
buf[0] = (char) ((ch >> 6) | 0xC0);
|
49
|
+
buf[1] = (char) ((ch & 0x3F) | 0x80);
|
50
|
+
len++;
|
51
|
+
} else if (ch <= 0xFFFF) {
|
52
|
+
buf[0] = (char) ((ch >> 12) | 0xE0);
|
53
|
+
buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80);
|
54
|
+
buf[2] = (char) ((ch & 0x3F) | 0x80);
|
55
|
+
len += 2;
|
56
|
+
} else if (ch <= 0x1fffff) {
|
57
|
+
buf[0] =(char) ((ch >> 18) | 0xF0);
|
58
|
+
buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80);
|
59
|
+
buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80);
|
60
|
+
buf[3] =(char) ((ch & 0x3F) | 0x80);
|
61
|
+
len += 3;
|
62
|
+
} else {
|
63
|
+
buf[0] = '?';
|
64
|
+
}
|
65
|
+
return len;
|
66
|
+
}
|
67
|
+
|
68
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
69
|
+
static VALUE CEncoding_ASCII_8BIT, CEncoding_UTF_8, CEncoding_UTF_16BE,
|
70
|
+
CEncoding_UTF_16LE, CEncoding_UTF_32BE, CEncoding_UTF_32LE;
|
71
|
+
static ID i_encoding, i_encode;
|
72
|
+
#else
|
73
|
+
static ID i_iconv;
|
74
|
+
#endif
|
75
|
+
|
76
|
+
static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
|
77
|
+
static VALUE CNaN, CInfinity, CMinusInfinity;
|
78
|
+
|
79
|
+
static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
|
80
|
+
i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_quirks_mode,
|
81
|
+
i_object_class, i_array_class, i_key_p, i_deep_const_get, i_match,
|
82
|
+
i_match_string, i_aset, i_aref, i_leftshift;
|
83
|
+
|
84
|
+
%%{
|
85
|
+
machine JSON_common;
|
86
|
+
|
87
|
+
cr = '\n';
|
88
|
+
cr_neg = [^\n];
|
89
|
+
ws = [ \t\r\n];
|
90
|
+
c_comment = '/*' ( any* - (any* '*/' any* ) ) '*/';
|
91
|
+
cpp_comment = '//' cr_neg* cr;
|
92
|
+
comment = c_comment | cpp_comment;
|
93
|
+
ignore = ws | comment;
|
94
|
+
name_separator = ':';
|
95
|
+
value_separator = ',';
|
96
|
+
Vnull = 'null';
|
97
|
+
Vfalse = 'false';
|
98
|
+
Vtrue = 'true';
|
99
|
+
VNaN = 'NaN';
|
100
|
+
VInfinity = 'Infinity';
|
101
|
+
VMinusInfinity = '-Infinity';
|
102
|
+
begin_value = [nft\"\-\[\{NI] | digit;
|
103
|
+
begin_object = '{';
|
104
|
+
end_object = '}';
|
105
|
+
begin_array = '[';
|
106
|
+
end_array = ']';
|
107
|
+
begin_string = '"';
|
108
|
+
begin_name = begin_string;
|
109
|
+
begin_number = digit | '-';
|
110
|
+
}%%
|
111
|
+
|
112
|
+
%%{
|
113
|
+
machine JSON_object;
|
114
|
+
include JSON_common;
|
115
|
+
|
116
|
+
write data;
|
117
|
+
|
118
|
+
action parse_value {
|
119
|
+
VALUE v = Qnil;
|
120
|
+
char *np = JSON_parse_value(json, fpc, pe, &v);
|
121
|
+
if (np == NULL) {
|
122
|
+
fhold; fbreak;
|
123
|
+
} else {
|
124
|
+
if (NIL_P(json->object_class)) {
|
125
|
+
rb_hash_aset(*result, last_name, v);
|
126
|
+
} else {
|
127
|
+
rb_funcall(*result, i_aset, 2, last_name, v);
|
128
|
+
}
|
129
|
+
fexec np;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
action parse_name {
|
134
|
+
char *np;
|
135
|
+
json->parsing_name = 1;
|
136
|
+
np = JSON_parse_string(json, fpc, pe, &last_name);
|
137
|
+
json->parsing_name = 0;
|
138
|
+
if (np == NULL) { fhold; fbreak; } else fexec np;
|
139
|
+
}
|
140
|
+
|
141
|
+
action exit { fhold; fbreak; }
|
142
|
+
|
143
|
+
pair = ignore* begin_name >parse_name ignore* name_separator ignore* begin_value >parse_value;
|
144
|
+
next_pair = ignore* value_separator pair;
|
145
|
+
|
146
|
+
main := (
|
147
|
+
begin_object
|
148
|
+
(pair (next_pair)*)? ignore*
|
149
|
+
end_object
|
150
|
+
) @exit;
|
151
|
+
}%%
|
152
|
+
|
153
|
+
static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
154
|
+
{
|
155
|
+
int cs = EVIL;
|
156
|
+
VALUE last_name = Qnil;
|
157
|
+
VALUE object_class = json->object_class;
|
158
|
+
|
159
|
+
if (json->max_nesting && json->current_nesting > json->max_nesting) {
|
160
|
+
rb_raise(eNestingError, "nesting of %d is too deep", json->current_nesting);
|
161
|
+
}
|
162
|
+
|
163
|
+
*result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
|
164
|
+
|
165
|
+
%% write init;
|
166
|
+
%% write exec;
|
167
|
+
|
168
|
+
if (cs >= JSON_object_first_final) {
|
169
|
+
if (json->create_additions) {
|
170
|
+
VALUE klassname;
|
171
|
+
if (NIL_P(json->object_class)) {
|
172
|
+
klassname = rb_hash_aref(*result, json->create_id);
|
173
|
+
} else {
|
174
|
+
klassname = rb_funcall(*result, i_aref, 1, json->create_id);
|
175
|
+
}
|
176
|
+
if (!NIL_P(klassname)) {
|
177
|
+
VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, klassname);
|
178
|
+
if (RTEST(rb_funcall(klass, i_json_creatable_p, 0))) {
|
179
|
+
*result = rb_funcall(klass, i_json_create, 1, *result);
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
return p + 1;
|
184
|
+
} else {
|
185
|
+
return NULL;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
%%{
|
191
|
+
machine JSON_value;
|
192
|
+
include JSON_common;
|
193
|
+
|
194
|
+
write data;
|
195
|
+
|
196
|
+
action parse_null {
|
197
|
+
*result = Qnil;
|
198
|
+
}
|
199
|
+
action parse_false {
|
200
|
+
*result = Qfalse;
|
201
|
+
}
|
202
|
+
action parse_true {
|
203
|
+
*result = Qtrue;
|
204
|
+
}
|
205
|
+
action parse_nan {
|
206
|
+
if (json->allow_nan) {
|
207
|
+
*result = CNaN;
|
208
|
+
} else {
|
209
|
+
rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p - 2);
|
210
|
+
}
|
211
|
+
}
|
212
|
+
action parse_infinity {
|
213
|
+
if (json->allow_nan) {
|
214
|
+
*result = CInfinity;
|
215
|
+
} else {
|
216
|
+
rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p - 8);
|
217
|
+
}
|
218
|
+
}
|
219
|
+
action parse_string {
|
220
|
+
char *np = JSON_parse_string(json, fpc, pe, result);
|
221
|
+
if (np == NULL) { fhold; fbreak; } else fexec np;
|
222
|
+
}
|
223
|
+
|
224
|
+
action parse_number {
|
225
|
+
char *np;
|
226
|
+
if(pe > fpc + 9 - json->quirks_mode && !strncmp(MinusInfinity, fpc, 9)) {
|
227
|
+
if (json->allow_nan) {
|
228
|
+
*result = CMinusInfinity;
|
229
|
+
fexec p + 10;
|
230
|
+
fhold; fbreak;
|
231
|
+
} else {
|
232
|
+
rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p);
|
233
|
+
}
|
234
|
+
}
|
235
|
+
np = JSON_parse_float(json, fpc, pe, result);
|
236
|
+
if (np != NULL) fexec np;
|
237
|
+
np = JSON_parse_integer(json, fpc, pe, result);
|
238
|
+
if (np != NULL) fexec np;
|
239
|
+
fhold; fbreak;
|
240
|
+
}
|
241
|
+
|
242
|
+
action parse_array {
|
243
|
+
char *np;
|
244
|
+
json->current_nesting++;
|
245
|
+
np = JSON_parse_array(json, fpc, pe, result);
|
246
|
+
json->current_nesting--;
|
247
|
+
if (np == NULL) { fhold; fbreak; } else fexec np;
|
248
|
+
}
|
249
|
+
|
250
|
+
action parse_object {
|
251
|
+
char *np;
|
252
|
+
json->current_nesting++;
|
253
|
+
np = JSON_parse_object(json, fpc, pe, result);
|
254
|
+
json->current_nesting--;
|
255
|
+
if (np == NULL) { fhold; fbreak; } else fexec np;
|
256
|
+
}
|
257
|
+
|
258
|
+
action exit { fhold; fbreak; }
|
259
|
+
|
260
|
+
main := (
|
261
|
+
Vnull @parse_null |
|
262
|
+
Vfalse @parse_false |
|
263
|
+
Vtrue @parse_true |
|
264
|
+
VNaN @parse_nan |
|
265
|
+
VInfinity @parse_infinity |
|
266
|
+
begin_number >parse_number |
|
267
|
+
begin_string >parse_string |
|
268
|
+
begin_array >parse_array |
|
269
|
+
begin_object >parse_object
|
270
|
+
) %*exit;
|
271
|
+
}%%
|
272
|
+
|
273
|
+
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
274
|
+
{
|
275
|
+
int cs = EVIL;
|
276
|
+
|
277
|
+
%% write init;
|
278
|
+
%% write exec;
|
279
|
+
|
280
|
+
if (cs >= JSON_value_first_final) {
|
281
|
+
return p;
|
282
|
+
} else {
|
283
|
+
return NULL;
|
284
|
+
}
|
285
|
+
}
|
286
|
+
|
287
|
+
%%{
|
288
|
+
machine JSON_integer;
|
289
|
+
|
290
|
+
write data;
|
291
|
+
|
292
|
+
action exit { fhold; fbreak; }
|
293
|
+
|
294
|
+
main := '-'? ('0' | [1-9][0-9]*) (^[0-9]? @exit);
|
295
|
+
}%%
|
296
|
+
|
297
|
+
static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
298
|
+
{
|
299
|
+
int cs = EVIL;
|
300
|
+
|
301
|
+
%% write init;
|
302
|
+
json->memo = p;
|
303
|
+
%% write exec;
|
304
|
+
|
305
|
+
if (cs >= JSON_integer_first_final) {
|
306
|
+
long len = p - json->memo;
|
307
|
+
fbuffer_clear(json->fbuffer);
|
308
|
+
fbuffer_append(json->fbuffer, json->memo, len);
|
309
|
+
fbuffer_append_char(json->fbuffer, '\0');
|
310
|
+
*result = rb_cstr2inum(FBUFFER_PTR(json->fbuffer), 10);
|
311
|
+
return p + 1;
|
312
|
+
} else {
|
313
|
+
return NULL;
|
314
|
+
}
|
315
|
+
}
|
316
|
+
|
317
|
+
%%{
|
318
|
+
machine JSON_float;
|
319
|
+
include JSON_common;
|
320
|
+
|
321
|
+
write data;
|
322
|
+
|
323
|
+
action exit { fhold; fbreak; }
|
324
|
+
|
325
|
+
main := '-'? (
|
326
|
+
(('0' | [1-9][0-9]*) '.' [0-9]+ ([Ee] [+\-]?[0-9]+)?)
|
327
|
+
| (('0' | [1-9][0-9]*) ([Ee] [+\-]?[0-9]+))
|
328
|
+
) (^[0-9Ee.\-]? @exit );
|
329
|
+
}%%
|
330
|
+
|
331
|
+
static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
332
|
+
{
|
333
|
+
int cs = EVIL;
|
334
|
+
|
335
|
+
%% write init;
|
336
|
+
json->memo = p;
|
337
|
+
%% write exec;
|
338
|
+
|
339
|
+
if (cs >= JSON_float_first_final) {
|
340
|
+
long len = p - json->memo;
|
341
|
+
fbuffer_clear(json->fbuffer);
|
342
|
+
fbuffer_append(json->fbuffer, json->memo, len);
|
343
|
+
fbuffer_append_char(json->fbuffer, '\0');
|
344
|
+
*result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
|
345
|
+
return p + 1;
|
346
|
+
} else {
|
347
|
+
return NULL;
|
348
|
+
}
|
349
|
+
}
|
350
|
+
|
351
|
+
|
352
|
+
%%{
|
353
|
+
machine JSON_array;
|
354
|
+
include JSON_common;
|
355
|
+
|
356
|
+
write data;
|
357
|
+
|
358
|
+
action parse_value {
|
359
|
+
VALUE v = Qnil;
|
360
|
+
char *np = JSON_parse_value(json, fpc, pe, &v);
|
361
|
+
if (np == NULL) {
|
362
|
+
fhold; fbreak;
|
363
|
+
} else {
|
364
|
+
if (NIL_P(json->array_class)) {
|
365
|
+
rb_ary_push(*result, v);
|
366
|
+
} else {
|
367
|
+
rb_funcall(*result, i_leftshift, 1, v);
|
368
|
+
}
|
369
|
+
fexec np;
|
370
|
+
}
|
371
|
+
}
|
372
|
+
|
373
|
+
action exit { fhold; fbreak; }
|
374
|
+
|
375
|
+
next_element = value_separator ignore* begin_value >parse_value;
|
376
|
+
|
377
|
+
main := begin_array ignore*
|
378
|
+
((begin_value >parse_value ignore*)
|
379
|
+
(ignore* next_element ignore*)*)?
|
380
|
+
end_array @exit;
|
381
|
+
}%%
|
382
|
+
|
383
|
+
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
384
|
+
{
|
385
|
+
int cs = EVIL;
|
386
|
+
VALUE array_class = json->array_class;
|
387
|
+
|
388
|
+
if (json->max_nesting && json->current_nesting > json->max_nesting) {
|
389
|
+
rb_raise(eNestingError, "nesting of %d is too deep", json->current_nesting);
|
390
|
+
}
|
391
|
+
*result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
|
392
|
+
|
393
|
+
%% write init;
|
394
|
+
%% write exec;
|
395
|
+
|
396
|
+
if(cs >= JSON_array_first_final) {
|
397
|
+
return p + 1;
|
398
|
+
} else {
|
399
|
+
rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p);
|
400
|
+
return NULL;
|
401
|
+
}
|
402
|
+
}
|
403
|
+
|
404
|
+
static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
|
405
|
+
{
|
406
|
+
char *p = string, *pe = string, *unescape;
|
407
|
+
int unescape_len;
|
408
|
+
|
409
|
+
while (pe < stringEnd) {
|
410
|
+
if (*pe == '\\') {
|
411
|
+
unescape = (char *) "?";
|
412
|
+
unescape_len = 1;
|
413
|
+
if (pe > p) rb_str_buf_cat(result, p, pe - p);
|
414
|
+
switch (*++pe) {
|
415
|
+
case 'n':
|
416
|
+
unescape = (char *) "\n";
|
417
|
+
break;
|
418
|
+
case 'r':
|
419
|
+
unescape = (char *) "\r";
|
420
|
+
break;
|
421
|
+
case 't':
|
422
|
+
unescape = (char *) "\t";
|
423
|
+
break;
|
424
|
+
case '"':
|
425
|
+
unescape = (char *) "\"";
|
426
|
+
break;
|
427
|
+
case '\\':
|
428
|
+
unescape = (char *) "\\";
|
429
|
+
break;
|
430
|
+
case 'b':
|
431
|
+
unescape = (char *) "\b";
|
432
|
+
break;
|
433
|
+
case 'f':
|
434
|
+
unescape = (char *) "\f";
|
435
|
+
break;
|
436
|
+
case 'u':
|
437
|
+
if (pe > stringEnd - 4) {
|
438
|
+
return Qnil;
|
439
|
+
} else {
|
440
|
+
char buf[4];
|
441
|
+
UTF32 ch = unescape_unicode((unsigned char *) ++pe);
|
442
|
+
pe += 3;
|
443
|
+
if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {
|
444
|
+
pe++;
|
445
|
+
if (pe > stringEnd - 6) return Qnil;
|
446
|
+
if (pe[0] == '\\' && pe[1] == 'u') {
|
447
|
+
UTF32 sur = unescape_unicode((unsigned char *) pe + 2);
|
448
|
+
ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16)
|
449
|
+
| (sur & 0x3FF));
|
450
|
+
pe += 5;
|
451
|
+
} else {
|
452
|
+
unescape = (char *) "?";
|
453
|
+
break;
|
454
|
+
}
|
455
|
+
}
|
456
|
+
unescape_len = convert_UTF32_to_UTF8(buf, ch);
|
457
|
+
unescape = buf;
|
458
|
+
}
|
459
|
+
break;
|
460
|
+
default:
|
461
|
+
p = pe;
|
462
|
+
continue;
|
463
|
+
}
|
464
|
+
rb_str_buf_cat(result, unescape, unescape_len);
|
465
|
+
p = ++pe;
|
466
|
+
} else {
|
467
|
+
pe++;
|
468
|
+
}
|
469
|
+
}
|
470
|
+
rb_str_buf_cat(result, p, pe - p);
|
471
|
+
return result;
|
472
|
+
}
|
473
|
+
|
474
|
+
%%{
|
475
|
+
machine JSON_string;
|
476
|
+
include JSON_common;
|
477
|
+
|
478
|
+
write data;
|
479
|
+
|
480
|
+
action parse_string {
|
481
|
+
*result = json_string_unescape(*result, json->memo + 1, p);
|
482
|
+
if (NIL_P(*result)) {
|
483
|
+
fhold;
|
484
|
+
fbreak;
|
485
|
+
} else {
|
486
|
+
FORCE_UTF8(*result);
|
487
|
+
fexec p + 1;
|
488
|
+
}
|
489
|
+
}
|
490
|
+
|
491
|
+
action exit { fhold; fbreak; }
|
492
|
+
|
493
|
+
main := '"' ((^([\"\\] | 0..0x1f) | '\\'[\"\\/bfnrt] | '\\u'[0-9a-fA-F]{4} | '\\'^([\"\\/bfnrtu]|0..0x1f))* %parse_string) '"' @exit;
|
494
|
+
}%%
|
495
|
+
|
496
|
+
static int
|
497
|
+
match_i(VALUE regexp, VALUE klass, VALUE memo)
|
498
|
+
{
|
499
|
+
if (regexp == Qundef) return ST_STOP;
|
500
|
+
if (RTEST(rb_funcall(klass, i_json_creatable_p, 0)) &&
|
501
|
+
RTEST(rb_funcall(regexp, i_match, 1, rb_ary_entry(memo, 0)))) {
|
502
|
+
rb_ary_push(memo, klass);
|
503
|
+
return ST_STOP;
|
504
|
+
}
|
505
|
+
return ST_CONTINUE;
|
506
|
+
}
|
507
|
+
|
508
|
+
static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
509
|
+
{
|
510
|
+
int cs = EVIL;
|
511
|
+
VALUE match_string;
|
512
|
+
|
513
|
+
*result = rb_str_buf_new(0);
|
514
|
+
%% write init;
|
515
|
+
json->memo = p;
|
516
|
+
%% write exec;
|
517
|
+
|
518
|
+
if (json->create_additions && RTEST(match_string = json->match_string)) {
|
519
|
+
VALUE klass;
|
520
|
+
VALUE memo = rb_ary_new2(2);
|
521
|
+
rb_ary_push(memo, *result);
|
522
|
+
rb_hash_foreach(match_string, match_i, memo);
|
523
|
+
klass = rb_ary_entry(memo, 1);
|
524
|
+
if (RTEST(klass)) {
|
525
|
+
*result = rb_funcall(klass, i_json_create, 1, *result);
|
526
|
+
}
|
527
|
+
}
|
528
|
+
|
529
|
+
if (json->symbolize_names && json->parsing_name) {
|
530
|
+
*result = rb_str_intern(*result);
|
531
|
+
}
|
532
|
+
if (cs >= JSON_string_first_final) {
|
533
|
+
return p + 1;
|
534
|
+
} else {
|
535
|
+
return NULL;
|
536
|
+
}
|
537
|
+
}
|
538
|
+
|
539
|
+
/*
|
540
|
+
* Document-class: JSON::Ext::Parser
|
541
|
+
*
|
542
|
+
* This is the JSON parser implemented as a C extension. It can be configured
|
543
|
+
* to be used by setting
|
544
|
+
*
|
545
|
+
* JSON.parser = JSON::Ext::Parser
|
546
|
+
*
|
547
|
+
* with the method parser= in JSON.
|
548
|
+
*
|
549
|
+
*/
|
550
|
+
|
551
|
+
static VALUE convert_encoding(VALUE source)
|
552
|
+
{
|
553
|
+
char *ptr = RSTRING_PTR(source);
|
554
|
+
long len = RSTRING_LEN(source);
|
555
|
+
if (len < 2) {
|
556
|
+
rb_raise(eParserError, "A JSON text must at least contain two octets!");
|
557
|
+
}
|
558
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
559
|
+
{
|
560
|
+
VALUE encoding = rb_funcall(source, i_encoding, 0);
|
561
|
+
if (encoding == CEncoding_ASCII_8BIT) {
|
562
|
+
if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
|
563
|
+
source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_32BE);
|
564
|
+
} else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
|
565
|
+
source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_16BE);
|
566
|
+
} else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
|
567
|
+
source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_32LE);
|
568
|
+
} else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
|
569
|
+
source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_16LE);
|
570
|
+
} else {
|
571
|
+
source = rb_str_dup(source);
|
572
|
+
FORCE_UTF8(source);
|
573
|
+
}
|
574
|
+
} else {
|
575
|
+
source = rb_funcall(source, i_encode, 1, CEncoding_UTF_8);
|
576
|
+
}
|
577
|
+
}
|
578
|
+
#else
|
579
|
+
if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
|
580
|
+
source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-32be"), source);
|
581
|
+
} else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
|
582
|
+
source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-16be"), source);
|
583
|
+
} else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
|
584
|
+
source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-32le"), source);
|
585
|
+
} else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
|
586
|
+
source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-16le"), source);
|
587
|
+
}
|
588
|
+
#endif
|
589
|
+
return source;
|
590
|
+
}
|
591
|
+
|
592
|
+
/*
|
593
|
+
* call-seq: new(source, opts => {})
|
594
|
+
*
|
595
|
+
* Creates a new JSON::Ext::Parser instance for the string _source_.
|
596
|
+
*
|
597
|
+
* Creates a new JSON::Ext::Parser instance for the string _source_.
|
598
|
+
*
|
599
|
+
* It will be configured by the _opts_ hash. _opts_ can have the following
|
600
|
+
* keys:
|
601
|
+
*
|
602
|
+
* _opts_ can have the following keys:
|
603
|
+
* * *max_nesting*: The maximum depth of nesting allowed in the parsed data
|
604
|
+
* structures. Disable depth checking with :max_nesting => false|nil|0, it
|
605
|
+
* defaults to 19.
|
606
|
+
* * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
|
607
|
+
* defiance of RFC 4627 to be parsed by the Parser. This option defaults to
|
608
|
+
* false.
|
609
|
+
* * *symbolize_names*: If set to true, returns symbols for the names
|
610
|
+
* (keys) in a JSON object. Otherwise strings are returned, which is also
|
611
|
+
* the default.
|
612
|
+
* * *create_additions*: If set to false, the Parser doesn't create
|
613
|
+
* additions even if a matchin class and create_id was found. This option
|
614
|
+
* defaults to true.
|
615
|
+
* * *object_class*: Defaults to Hash
|
616
|
+
* * *array_class*: Defaults to Array
|
617
|
+
*/
|
618
|
+
static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
619
|
+
{
|
620
|
+
VALUE source, opts;
|
621
|
+
GET_PARSER_INIT;
|
622
|
+
|
623
|
+
if (json->Vsource) {
|
624
|
+
rb_raise(rb_eTypeError, "already initialized instance");
|
625
|
+
}
|
626
|
+
rb_scan_args(argc, argv, "11", &source, &opts);
|
627
|
+
if (!NIL_P(opts)) {
|
628
|
+
opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
|
629
|
+
if (NIL_P(opts)) {
|
630
|
+
rb_raise(rb_eArgError, "opts needs to be like a hash");
|
631
|
+
} else {
|
632
|
+
VALUE tmp = ID2SYM(i_max_nesting);
|
633
|
+
if (option_given_p(opts, tmp)) {
|
634
|
+
VALUE max_nesting = rb_hash_aref(opts, tmp);
|
635
|
+
if (RTEST(max_nesting)) {
|
636
|
+
Check_Type(max_nesting, T_FIXNUM);
|
637
|
+
json->max_nesting = FIX2INT(max_nesting);
|
638
|
+
} else {
|
639
|
+
json->max_nesting = 0;
|
640
|
+
}
|
641
|
+
} else {
|
642
|
+
json->max_nesting = 19;
|
643
|
+
}
|
644
|
+
tmp = ID2SYM(i_allow_nan);
|
645
|
+
if (option_given_p(opts, tmp)) {
|
646
|
+
json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
|
647
|
+
} else {
|
648
|
+
json->allow_nan = 0;
|
649
|
+
}
|
650
|
+
tmp = ID2SYM(i_symbolize_names);
|
651
|
+
if (option_given_p(opts, tmp)) {
|
652
|
+
json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
|
653
|
+
} else {
|
654
|
+
json->symbolize_names = 0;
|
655
|
+
}
|
656
|
+
tmp = ID2SYM(i_quirks_mode);
|
657
|
+
if (option_given_p(opts, tmp)) {
|
658
|
+
VALUE quirks_mode = rb_hash_aref(opts, tmp);
|
659
|
+
json->quirks_mode = RTEST(quirks_mode) ? 1 : 0;
|
660
|
+
} else {
|
661
|
+
json->quirks_mode = 0;
|
662
|
+
}
|
663
|
+
tmp = ID2SYM(i_create_additions);
|
664
|
+
if (option_given_p(opts, tmp)) {
|
665
|
+
json->create_additions = RTEST(rb_hash_aref(opts, tmp));
|
666
|
+
} else {
|
667
|
+
json->create_additions = 1;
|
668
|
+
}
|
669
|
+
tmp = ID2SYM(i_create_id);
|
670
|
+
if (option_given_p(opts, tmp)) {
|
671
|
+
json->create_id = rb_hash_aref(opts, tmp);
|
672
|
+
} else {
|
673
|
+
json->create_id = rb_funcall(mJSON, i_create_id, 0);
|
674
|
+
}
|
675
|
+
tmp = ID2SYM(i_object_class);
|
676
|
+
if (option_given_p(opts, tmp)) {
|
677
|
+
json->object_class = rb_hash_aref(opts, tmp);
|
678
|
+
} else {
|
679
|
+
json->object_class = Qnil;
|
680
|
+
}
|
681
|
+
tmp = ID2SYM(i_array_class);
|
682
|
+
if (option_given_p(opts, tmp)) {
|
683
|
+
json->array_class = rb_hash_aref(opts, tmp);
|
684
|
+
} else {
|
685
|
+
json->array_class = Qnil;
|
686
|
+
}
|
687
|
+
tmp = ID2SYM(i_match_string);
|
688
|
+
if (option_given_p(opts, tmp)) {
|
689
|
+
VALUE match_string = rb_hash_aref(opts, tmp);
|
690
|
+
json->match_string = RTEST(match_string) ? match_string : Qnil;
|
691
|
+
} else {
|
692
|
+
json->match_string = Qnil;
|
693
|
+
}
|
694
|
+
}
|
695
|
+
} else {
|
696
|
+
json->max_nesting = 19;
|
697
|
+
json->allow_nan = 0;
|
698
|
+
json->create_additions = 1;
|
699
|
+
json->create_id = rb_funcall(mJSON, i_create_id, 0);
|
700
|
+
json->object_class = Qnil;
|
701
|
+
json->array_class = Qnil;
|
702
|
+
}
|
703
|
+
source = rb_convert_type(source, T_STRING, "String", "to_str");
|
704
|
+
if (!json->quirks_mode) {
|
705
|
+
source = convert_encoding(StringValue(source));
|
706
|
+
}
|
707
|
+
json->current_nesting = 0;
|
708
|
+
json->len = RSTRING_LEN(source);
|
709
|
+
json->source = RSTRING_PTR(source);;
|
710
|
+
json->Vsource = source;
|
711
|
+
return self;
|
712
|
+
}
|
713
|
+
|
714
|
+
%%{
|
715
|
+
machine JSON;
|
716
|
+
|
717
|
+
write data;
|
718
|
+
|
719
|
+
include JSON_common;
|
720
|
+
|
721
|
+
action parse_object {
|
722
|
+
char *np;
|
723
|
+
json->current_nesting = 1;
|
724
|
+
np = JSON_parse_object(json, fpc, pe, &result);
|
725
|
+
if (np == NULL) { fhold; fbreak; } else fexec np;
|
726
|
+
}
|
727
|
+
|
728
|
+
action parse_array {
|
729
|
+
char *np;
|
730
|
+
json->current_nesting = 1;
|
731
|
+
np = JSON_parse_array(json, fpc, pe, &result);
|
732
|
+
if (np == NULL) { fhold; fbreak; } else fexec np;
|
733
|
+
}
|
734
|
+
|
735
|
+
main := ignore* (
|
736
|
+
begin_object >parse_object |
|
737
|
+
begin_array >parse_array
|
738
|
+
) ignore*;
|
739
|
+
}%%
|
740
|
+
|
741
|
+
static VALUE cParser_parse_strict(VALUE self)
|
742
|
+
{
|
743
|
+
char *p, *pe;
|
744
|
+
int cs = EVIL;
|
745
|
+
VALUE result = Qnil;
|
746
|
+
GET_PARSER;
|
747
|
+
|
748
|
+
%% write init;
|
749
|
+
p = json->source;
|
750
|
+
pe = p + json->len;
|
751
|
+
%% write exec;
|
752
|
+
|
753
|
+
if (cs >= JSON_first_final && p == pe) {
|
754
|
+
return result;
|
755
|
+
} else {
|
756
|
+
rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p);
|
757
|
+
return Qnil;
|
758
|
+
}
|
759
|
+
}
|
760
|
+
|
761
|
+
|
762
|
+
%%{
|
763
|
+
machine JSON_quirks_mode;
|
764
|
+
|
765
|
+
write data;
|
766
|
+
|
767
|
+
include JSON_common;
|
768
|
+
|
769
|
+
action parse_value {
|
770
|
+
char *np = JSON_parse_value(json, fpc, pe, &result);
|
771
|
+
if (np == NULL) { fhold; fbreak; } else fexec np;
|
772
|
+
}
|
773
|
+
|
774
|
+
main := ignore* (
|
775
|
+
begin_value >parse_value
|
776
|
+
) ignore*;
|
777
|
+
}%%
|
778
|
+
|
779
|
+
static VALUE cParser_parse_quirks_mode(VALUE self)
|
780
|
+
{
|
781
|
+
char *p, *pe;
|
782
|
+
int cs = EVIL;
|
783
|
+
VALUE result = Qnil;
|
784
|
+
GET_PARSER;
|
785
|
+
|
786
|
+
%% write init;
|
787
|
+
p = json->source;
|
788
|
+
pe = p + json->len;
|
789
|
+
%% write exec;
|
790
|
+
|
791
|
+
if (cs >= JSON_quirks_mode_first_final && p == pe) {
|
792
|
+
return result;
|
793
|
+
} else {
|
794
|
+
rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p);
|
795
|
+
return Qnil;
|
796
|
+
}
|
797
|
+
}
|
798
|
+
|
799
|
+
/*
|
800
|
+
* call-seq: parse()
|
801
|
+
*
|
802
|
+
* Parses the current JSON text _source_ and returns the complete data
|
803
|
+
* structure as a result.
|
804
|
+
*/
|
805
|
+
static VALUE cParser_parse(VALUE self)
|
806
|
+
{
|
807
|
+
GET_PARSER;
|
808
|
+
|
809
|
+
if (json->quirks_mode) {
|
810
|
+
return cParser_parse_quirks_mode(self);
|
811
|
+
} else {
|
812
|
+
return cParser_parse_strict(self);
|
813
|
+
}
|
814
|
+
}
|
815
|
+
|
816
|
+
|
817
|
+
static JSON_Parser *JSON_allocate()
|
818
|
+
{
|
819
|
+
JSON_Parser *json = ALLOC(JSON_Parser);
|
820
|
+
MEMZERO(json, JSON_Parser, 1);
|
821
|
+
json->fbuffer = fbuffer_alloc(0);
|
822
|
+
return json;
|
823
|
+
}
|
824
|
+
|
825
|
+
static void JSON_mark(JSON_Parser *json)
|
826
|
+
{
|
827
|
+
rb_gc_mark_maybe(json->Vsource);
|
828
|
+
rb_gc_mark_maybe(json->create_id);
|
829
|
+
rb_gc_mark_maybe(json->object_class);
|
830
|
+
rb_gc_mark_maybe(json->array_class);
|
831
|
+
rb_gc_mark_maybe(json->match_string);
|
832
|
+
}
|
833
|
+
|
834
|
+
static void JSON_free(JSON_Parser *json)
|
835
|
+
{
|
836
|
+
fbuffer_free(json->fbuffer);
|
837
|
+
ruby_xfree(json);
|
838
|
+
}
|
839
|
+
|
840
|
+
static VALUE cJSON_parser_s_allocate(VALUE klass)
|
841
|
+
{
|
842
|
+
JSON_Parser *json = JSON_allocate();
|
843
|
+
return Data_Wrap_Struct(klass, JSON_mark, JSON_free, json);
|
844
|
+
}
|
845
|
+
|
846
|
+
/*
|
847
|
+
* call-seq: source()
|
848
|
+
*
|
849
|
+
* Returns a copy of the current _source_ string, that was used to construct
|
850
|
+
* this Parser.
|
851
|
+
*/
|
852
|
+
static VALUE cParser_source(VALUE self)
|
853
|
+
{
|
854
|
+
GET_PARSER;
|
855
|
+
return rb_str_dup(json->Vsource);
|
856
|
+
}
|
857
|
+
|
858
|
+
/*
|
859
|
+
* call-seq: quirks_mode?()
|
860
|
+
*
|
861
|
+
* Returns a true, if this parser is in quirks_mode, false otherwise.
|
862
|
+
*/
|
863
|
+
static VALUE cParser_quirks_mode_p(VALUE self)
|
864
|
+
{
|
865
|
+
GET_PARSER;
|
866
|
+
return json->quirks_mode ? Qtrue : Qfalse;
|
867
|
+
}
|
868
|
+
|
869
|
+
|
870
|
+
void Init_parser()
|
871
|
+
{
|
872
|
+
rb_require("json/common");
|
873
|
+
mJSON = rb_define_module("JSON");
|
874
|
+
mExt = rb_define_module_under(mJSON, "Ext");
|
875
|
+
cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
|
876
|
+
eParserError = rb_path2class("JSON::ParserError");
|
877
|
+
eNestingError = rb_path2class("JSON::NestingError");
|
878
|
+
rb_define_alloc_func(cParser, cJSON_parser_s_allocate);
|
879
|
+
rb_define_method(cParser, "initialize", cParser_initialize, -1);
|
880
|
+
rb_define_method(cParser, "parse", cParser_parse, 0);
|
881
|
+
rb_define_method(cParser, "source", cParser_source, 0);
|
882
|
+
rb_define_method(cParser, "quirks_mode?", cParser_quirks_mode_p, 0);
|
883
|
+
|
884
|
+
CNaN = rb_const_get(mJSON, rb_intern("NaN"));
|
885
|
+
CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
|
886
|
+
CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
|
887
|
+
|
888
|
+
i_json_creatable_p = rb_intern("json_creatable?");
|
889
|
+
i_json_create = rb_intern("json_create");
|
890
|
+
i_create_id = rb_intern("create_id");
|
891
|
+
i_create_additions = rb_intern("create_additions");
|
892
|
+
i_chr = rb_intern("chr");
|
893
|
+
i_max_nesting = rb_intern("max_nesting");
|
894
|
+
i_allow_nan = rb_intern("allow_nan");
|
895
|
+
i_symbolize_names = rb_intern("symbolize_names");
|
896
|
+
i_quirks_mode = rb_intern("quirks_mode");
|
897
|
+
i_object_class = rb_intern("object_class");
|
898
|
+
i_array_class = rb_intern("array_class");
|
899
|
+
i_match = rb_intern("match");
|
900
|
+
i_match_string = rb_intern("match_string");
|
901
|
+
i_key_p = rb_intern("key?");
|
902
|
+
i_deep_const_get = rb_intern("deep_const_get");
|
903
|
+
i_aset = rb_intern("[]=");
|
904
|
+
i_aref = rb_intern("[]");
|
905
|
+
i_leftshift = rb_intern("<<");
|
906
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
907
|
+
CEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8"));
|
908
|
+
CEncoding_UTF_16BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16be"));
|
909
|
+
CEncoding_UTF_16LE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16le"));
|
910
|
+
CEncoding_UTF_32BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-32be"));
|
911
|
+
CEncoding_UTF_32LE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-32le"));
|
912
|
+
CEncoding_ASCII_8BIT = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("ascii-8bit"));
|
913
|
+
i_encoding = rb_intern("encoding");
|
914
|
+
i_encode = rb_intern("encode");
|
915
|
+
#else
|
916
|
+
i_iconv = rb_intern("iconv");
|
917
|
+
#endif
|
918
|
+
}
|
919
|
+
|
920
|
+
/*
|
921
|
+
* Local variables:
|
922
|
+
* mode: c
|
923
|
+
* c-file-style: ruby
|
924
|
+
* indent-tabs-mode: nil
|
925
|
+
* End:
|
926
|
+
*/
|