Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' into jruby-1.7

Conflicts:
	README.markdown
  • Loading branch information...
commit 6c097f53ee28d46c396b82c5852128b95990700a 2 parents 5fcb133 + ab87ffa
@tka tka authored
Showing with 22,743 additions and 90 deletions.
  1. +1 −1  Info.plist
  2. +4 −4 README.markdown
  3. +1 −1  build_configuration.rb
  4. +0 −74 editor_extensions/vim-compassapp/plugin/compassapp.vim
  5. +15 −7 hosting_server/config.ru
  6. +2 −2 lib/documents/extensions_readme.txt
  7. BIN  lib/images/icon/favorite-16.png
  8. BIN  lib/images/icon/history-16.png
  9. +17 −0 lib/ruby/common/commonjs-0.2.6/.gitignore
  10. +3 −0  lib/ruby/common/commonjs-0.2.6/.gitmodules
  11. +10 −0 lib/ruby/common/commonjs-0.2.6/.travis.yml
  12. +7 −0 lib/ruby/common/commonjs-0.2.6/Gemfile
  13. +44 −0 lib/ruby/common/commonjs-0.2.6/README.md
  14. +9 −0 lib/ruby/common/commonjs-0.2.6/Rakefile
  15. +20 −0 lib/ruby/common/commonjs-0.2.6/commonjs.gemspec
  16. +6 −0 lib/ruby/common/commonjs-0.2.6/lib/commonjs.rb
  17. +39 −0 lib/ruby/common/commonjs-0.2.6/lib/commonjs/environment.rb
  18. +49 −0 lib/ruby/common/commonjs-0.2.6/lib/commonjs/module.rb
  19. +3 −0  lib/ruby/common/commonjs-0.2.6/lib/commonjs/version.rb
  20. +1 −0  lib/ruby/common/commonjs-0.2.6/spec/commonjs/libjs/assign_module_exports.js
  21. +1 −0  lib/ruby/common/commonjs-0.2.6/spec/commonjs/libjs/one.js
  22. +1 −0  lib/ruby/common/commonjs-0.2.6/spec/commonjs/libjs/three.js
  23. +1 −0  lib/ruby/common/commonjs-0.2.6/spec/commonjs/libjs2/one.js
  24. +1 −0  lib/ruby/common/commonjs-0.2.6/spec/commonjs/libjs2/two.js
  25. +10 −0 lib/ruby/common/commonjs-0.2.6/spec/commonjs/modules_extensions_spec.rb
  26. +34 −0 lib/ruby/common/commonjs-0.2.6/spec/commonjs/modules_spec.rb
  27. +33 −0 lib/ruby/common/commonjs-0.2.6/spec/commonjs/path_spec.rb
  28. +19 −0 lib/ruby/common/commonjs-0.2.6/spec/spec_helper.rb
  29. +1 −1  lib/ruby/common/execjs-1.4.0/lib/execjs/support/node_runner.js
  30. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json.rb
  31. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/add/bigdecimal.rb
  32. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/add/complex.rb
  33. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/add/core.rb
  34. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/add/date.rb
  35. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/add/date_time.rb
  36. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/add/exception.rb
  37. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/add/ostruct.rb
  38. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/add/range.rb
  39. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/add/rational.rb
  40. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/add/regexp.rb
  41. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/add/struct.rb
  42. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/add/symbol.rb
  43. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/add/time.rb
  44. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/common.rb
  45. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/ext.rb
  46. BIN  lib/ruby/common/json-1.8.0-java/lib/json/ext/generator.jar
  47. BIN  lib/ruby/common/json-1.8.0-java/lib/json/ext/parser.jar
  48. +70 −0 lib/ruby/common/json-1.8.0-java/lib/json/generic_object.rb
  49. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/pure.rb
  50. +522 −0 lib/ruby/common/json-1.8.0-java/lib/json/pure/generator.rb
  51. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/lib/json/pure/parser.rb
  52. +8 −0 lib/ruby/common/json-1.8.0-java/lib/json/version.rb
  53. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail1.json
  54. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail10.json
  55. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail11.json
  56. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail12.json
  57. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail13.json
  58. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail14.json
  59. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail18.json
  60. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail19.json
  61. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail2.json
  62. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail20.json
  63. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail21.json
  64. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail22.json
  65. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail23.json
  66. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail24.json
  67. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail25.json
  68. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail27.json
  69. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail28.json
  70. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail3.json
  71. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail4.json
  72. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail5.json
  73. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail6.json
  74. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail7.json
  75. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail8.json
  76. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/fail9.json
  77. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/pass1.json
  78. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/pass15.json
  79. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/pass16.json
  80. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/pass17.json
  81. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/pass2.json
  82. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/pass26.json
  83. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/fixtures/pass3.json
  84. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/setup_variant.rb
  85. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/test_json.rb
  86. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/test_json_addition.rb
  87. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/test_json_encoding.rb
  88. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/test_json_fixtures.rb
  89. +322 −0 lib/ruby/common/json-1.8.0-java/tests/test_json_generate.rb
  90. +75 −0 lib/ruby/common/json-1.8.0-java/tests/test_json_generic_object.rb
  91. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/test_json_string_matching.rb
  92. 0  lib/ruby/{jruby/json-1.7.7-java → common/json-1.8.0-java}/tests/test_json_unicode.rb
  93. +4 −0 lib/ruby/common/ruby-less-js/.gitignore
  94. +5 −0 lib/ruby/common/ruby-less-js/Gemfile
  95. +34 −0 lib/ruby/common/ruby-less-js/README.md
  96. +11 −0 lib/ruby/common/ruby-less-js/Rakefile
  97. +1 −0  lib/ruby/common/ruby-less-js/lib/less-js.rb
  98. +9 −0 lib/ruby/common/ruby-less-js/lib/less.js/.gitattributes
  99. 0  ...ompass_extensions/compass-h5bp/test/project/css/.gitkeep → common/ruby-less-js/lib/less.js/.npmignore}
  100. +177 −0 lib/ruby/common/ruby-less-js/lib/less.js/CHANGELOG.md
  101. +49 −0 lib/ruby/common/ruby-less-js/lib/less.js/CONTRIBUTING.md
  102. +179 −0 lib/ruby/common/ruby-less-js/lib/less.js/LICENSE
  103. +102 −0 lib/ruby/common/ruby-less-js/lib/less.js/Makefile
  104. +20 −0 lib/ruby/common/ruby-less-js/lib/less.js/README.md
  105. +3,979 −0 lib/ruby/common/ruby-less-js/lib/less.js/benchmark/benchmark.less
  106. +47 −0 lib/ruby/common/ruby-less-js/lib/less.js/benchmark/less-benchmark.js
  107. +267 −0 lib/ruby/common/ruby-less-js/lib/less.js/bin/lessc
  108. +6 −0 lib/ruby/common/ruby-less-js/lib/less.js/build/amd.js
  109. +9 −0 lib/ruby/common/ruby-less-js/lib/less.js/build/header.js
  110. +7 −0 lib/ruby/common/ruby-less-js/lib/less.js/build/require-rhino.js
  111. +7 −0 lib/ruby/common/ruby-less-js/lib/less.js/build/require.js
  112. +2,695 −0 lib/ruby/common/ruby-less-js/lib/less.js/dist/less-1.1.0.js
  113. +16 −0 lib/ruby/common/ruby-less-js/lib/less.js/dist/less-1.1.0.min.js
  114. +2,710 −0 lib/ruby/common/ruby-less-js/lib/less.js/dist/less-1.1.1.js
  115. +16 −0 lib/ruby/common/ruby-less-js/lib/less.js/dist/less-1.1.1.min.js
  116. +2,712 −0 lib/ruby/common/ruby-less-js/lib/less.js/dist/less-1.1.2.js
  117. +16 −0 lib/ruby/common/ruby-less-js/lib/less.js/dist/less-1.1.2.min.js
  118. +2,721 −0 lib/ruby/common/ruby-less-js/lib/less.js/dist/less-1.1.3.js
  119. +16 −0 lib/ruby/common/ruby-less-js/lib/less.js/dist/less-1.1.3.min.js
  120. +2,769 −0 lib/ruby/common/ruby-less-js/lib/less.js/dist/less-1.1.4.js
  121. +16 −0 lib/ruby/common/ruby-less-js/lib/less.js/dist/less-1.1.4.min.js
  122. +2,805 −0 lib/ruby/common/ruby-less-js/lib/less.js/dist/less-1.1.5.js
  123. +9 −0 lib/ruby/common/ruby-less-js/lib/less.js/dist/less-1.1.5.min.js
Sorry, we could not display the entire diff because too many files (4,895) changed.
View
2  Info.plist
@@ -30,7 +30,7 @@
<key>JVMVersion</key>
<string>1.6*</string>
<key>MainClass</key>
- <string>com.handlino.fireapp.Main</string>
+ <string>com.kkbox.fireapp.Main</string>
<key>ClassPath</key>
<array>
<string>$JAVAROOT/fire-app.jar</string>
View
8 README.markdown
@@ -1,4 +1,4 @@
-![Fire.app](https://github.com/handlino/FireApp/raw/master/lib/images/icon/256.png)
+![Fire.app](https://github.com/kkbox/FireApp/raw/master/lib/images/icon/256.png)
# Fire.app
@@ -32,8 +32,8 @@ If you want to build your own copy, you will need Java 7, [JRuby](http://jruby.o
## License
-Copyright (c) 2012 Handlino Inc.
+Copyright (c) 2012 KKBOX Inc.
Licensed under GPL v2.
-[fireapp]: http://fireapp.handlino.com/
-[fireapp-github]: http://github.com/handlino/fireapp
+[fireapp]: http://fireapp.kkbox.com/
+[fireapp-github]: http://github.com/kkbox/fireapp
View
2  build_configuration.rb
@@ -22,7 +22,7 @@
# The fully-qualified name of the main Java file used to initiate the application.
# default value: "org.monkeybars.rawr.Main"
#
- c.main_java_file = "com.handlino.fireapp.Main"
+ c.main_java_file = "com.kkbox.fireapp.Main"
# A list of directories where source files reside
# default value: ["src"]
View
74 editor_extensions/vim-compassapp/plugin/compassapp.vim
@@ -1,74 +0,0 @@
-func! CompassCompl(st,base)
- if a:st
- let line = getline('.')
- let start = col('.') - 1
- while start > 0 && line[start - 1] =~ '[a-z0-9\$@]'
- let start -= 1
- endwhile
- return start
- else
-
- let basefilename='~/.compass-ui/autocomplete_cache/'. substitute( expand('%:p'), '[^a-z0-9]', '_','g')
- if a:base[0] == "$"
- let wordfile=basefilename. "_variable"
- let get_word_cmd='test -f '. wordfile .' && cat '. wordfile .'|tr "\n" ,'
- exe 'let wordlist=['. system(get_word_cmd) . ']'
-
- " add variable in current file
- let file = getline(1, '$')
- let jfile = join(file, ' ')
- let int_vals = split(jfile, '\ze\$')
- let int_vars = {}
- for i in int_vals
- let val = matchstr(i, '^\$[a-z_][a-z_\-0-9]*')
- if val != ''
- call add(wordlist, val)
- endif
- endfor
-
- else
- let line = getline('.')
- if line =~ '@include'
- let wordfile=basefilename. "_mixin"
- let get_word_cmd='test -f '. wordfile .' && cat '. wordfile .'|tr "\n" ,'
- exe 'let wordlist=['. system(get_word_cmd) . ']'
-
- " add mixin in current file
- let int_vals = getline(1, '$')
- let int_vars = {}
- for i in int_vals
- let val = matchlist(i, '^@mixin \([a-z0-9\_]*[^{]*\)')
- if len(val) > 0 && val[1] != ''
- call add(wordlist, val[1])
- endif
- endfor
-
- " if you need complete mixin args, comment below 5 lines
- let clean_wordlist = []
- for i in wordlist
- call add(clean_wordlist, matchstr(i, "^[a-z0-9\-_]*"))
- endfor
- let wordlist = clean_wordlist
-
- endif
- endif
-
- " if we got scss words
- if exists('wordlist')
- let res = []
- for m in wordlist
- if m =~ '^' . a:base
- call add(res, m)
- endif
- endfor
-
- return res
- end
-
- " default match csscomplete#CompleteCSS
- return csscomplete#CompleteCSS(0, a:base)
- endif
-endfunc
-autocmd BufNewFile,BufRead *.scss set ft=scss.css iskeyword+=- ofu=CompassCompl
-autocmd BufNewFile,BufRead *.sass set ft=sass.css iskeyword+=- ofu=CompassCompl
-
View
22 hosting_server/config.ru
@@ -10,7 +10,7 @@ require 'redis'
require 'yaml'
require 'json'
-DOMAIN = "the-hold.handlino.com"
+DOMAIN = "the-hold.kkbox.com"
module Rack
module Session
@@ -22,7 +22,11 @@ module Rack
patten = Regexp.new("(?<version>\\d{8}-\\d{6})?\\.?(?<project>.+?)\\.(?<login>.+)\\.#{DOMAIN}$")
project_route = request.host.match(patten)
- cookie[:domain] = ".#{project_route[:project]}.#{project_route[:login]}.#{DOMAIN}"
+ if project_route
+ cookie[:domain] = ".#{project_route[:project]}.#{project_route[:login]}.#{DOMAIN}"
+ else
+ cookie[:domain] = request.host
+ end
Utils.set_cookie_header!(headers, @key, cookie)
end
@@ -45,8 +49,12 @@ class TheHoldApp
patten = Regexp.new("(?<version>\\d{8}-\\d{6})?\\.?(?<project>.+?)\\.(?<login>.+)\\.#{DOMAIN}$")
project_route = req.host.match(patten)
-
- site_key = "site-#{project_route[:project]}.#{project_route[:login]}.#{DOMAIN}"
+ if project_route
+ site_key = "site-#{project_route[:project]}.#{project_route[:login]}.#{DOMAIN}"
+ else
+ site_key = "site-#{req.host}"
+ project_route={version: nil}
+ end
site = @redis.hgetall(site_key)
return not_found if !( site["login"] && site["project"] )
@@ -282,8 +290,8 @@ EOL
cname = params["cname"]
begin
dns = Resolv::DNS.new
- target_name = dns.getresources(cname, Resolv::DNS::Resource::IN::CNAME).first.try(:name)
- if target_name && target_name.to_s == project_hostname
+ target_record = dns.getresources(cname, Resolv::DNS::Resource::IN::CNAME).first
+ if target_record && target_record.name.to_s == project_hostname
@redis.hmset("site-#{cname}", :login, params["login"], :project, params["project"] );
end
end
@@ -302,7 +310,7 @@ EOL
end
def not_found
- [404, {'Content-Type' => 'text/plain' }, ["Not Fonud"]]
+ [404, {'Content-Type' => 'text/plain' }, ["Not Found"]]
end
def forbidden
View
4 lib/documents/extensions_readme.txt
@@ -3,7 +3,7 @@ Install Compass Extension
Fire.app uses Compass extension as project template. If you put Compass extensions inside this folder, Fire.app will try to load it when the application starts.
-For more detailed information, please refer: https://github.com/handlino/FireApp/wiki/Use-compass-extensions
+For more detailed information, please refer: https://github.com/kkbox/FireApp/wiki/Use-compass-extensions
Create Your Own Project Template
@@ -25,4 +25,4 @@ If you do not have a manifest.rb, Compass will use "easy mode" and put everythin
For more detailed information, please refer: http://compass-style.org/help/tutorials/extensions/
-You can also download our sample project template and give it a try: https://github.com/handlino/compass-handlino
+You can also download our sample project template and give it a try: https://github.com/kkbox/compass-handlino
View
BIN  lib/images/icon/favorite-16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  lib/images/icon/history-16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
17 lib/ruby/common/commonjs-0.2.6/.gitignore
@@ -0,0 +1,17 @@
+*.gem
+*.rbc
+.bundle
+.config
+.yardoc
+Gemfile.lock
+InstalledFiles
+_yardoc
+coverage
+doc/
+lib/bundler/man
+pkg
+rdoc
+spec/reports
+test/tmp
+test/version_tmp
+tmp
View
3  lib/ruby/common/commonjs-0.2.6/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "spec/ext/commonjs"]
+ path = spec/ext/commonjs
+ url = https://github.com/kriskowal/commonjs.git
View
10 lib/ruby/common/commonjs-0.2.6/.travis.yml
@@ -0,0 +1,10 @@
+rvm:
+ - 1.9.3
+ - 1.9.2
+ - 1.8.7
+ - jruby-18mode
+ - jruby-19mode
+notifications:
+ recipients:
+ - cowboyd@thefrontside.net
+before_install: git submodule update --init
View
7 lib/ruby/common/commonjs-0.2.6/Gemfile
@@ -0,0 +1,7 @@
+source 'http://rubygems.org'
+
+# Specify your gem's dependencies in commonjs.gemspec
+gemspec
+
+gem "therubyracer", :platforms => :ruby
+gem "therubyrhino", "~> 1.73.3", :platforms => :jruby
View
44 lib/ruby/common/commonjs-0.2.6/README.md
@@ -0,0 +1,44 @@
+
+# CommonJS [![Build Status](https://secure.travis-ci.org/cowboyd/commonjs.rb.png)](http://travis-ci.org/cowboyd/commonjs.rb)
+
+Host CommonJS JavaScript environments in Ruby
+
+## Why?
+
+The internet is now awash with non-browser JavaScript code. Much of this code conforms to some
+simple conventions that let you use it anywhere you have a JavaScript interpreter available. These
+conventions are collectively called "commonjs"
+
+We have several JavaScript interpreters available to us from Ruby. Therefore, why shouldn't we be
+able to use commonjs applications and libraries?
+
+## Using common JS from Ruby.
+
+`CommonJS` now passes all of the Modules 1.0 unit tests
+
+ env = CommonJS::Environment.new(:path => '/path/to/lib/dir')
+ env.require('foo.js')
+
+
+
+## Future directions
+
+By default, all you get with a bare commonjs environment is the Modules API
+
+The plan however, is to allow you to extend your commonjs environment to have whatever native
+interfaces you want in it. So for example, if you want to allow filesystem access, as well as
+access to the process information, you would say:
+
+ env.modules :filesystem, :process
+
+## Supported runtimes
+
+### Current
+
+* The Ruby Racer (V8) - [https://github.com/cowboyd/therubyracer]
+* The Ruby Rhino (JRuby) - [https://github.com/cowboyd/therubyrhino]
+
+### Desired
+
+* Johnson (TraceMonkey) - [https://github.com/jbarnette/johnson]
+* Lyndon (MacRuby) - [https://github.com/defunkt/lyndon]
View
9 lib/ruby/common/commonjs-0.2.6/Rakefile
@@ -0,0 +1,9 @@
+#!/usr/bin/env rake
+require "bundler/gem_tasks"
+
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new('spec') do |spec|
+ spec.rspec_opts = ['--color', "--format documentation"]
+end
+
+task :default => :spec
View
20 lib/ruby/common/commonjs-0.2.6/commonjs.gemspec
@@ -0,0 +1,20 @@
+# -*- encoding: utf-8 -*-
+require File.expand_path('../lib/commonjs/version', __FILE__)
+
+Gem::Specification.new do |gem|
+ gem.authors = ["Charles Lowell"]
+ gem.email = ["cowboyd@thefrontside.net"]
+ gem.description = "Host CommonJS JavaScript environments in Ruby"
+ gem.summary = "Provide access to your Ruby and Operating System runtime via the commonjs API"
+ gem.homepage = "http://github.com/cowboyd/commonjs.rb"
+
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ gem.files = `git ls-files`.split("\n")
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ gem.name = "commonjs"
+ gem.require_paths = ["lib"]
+ gem.version = CommonJS::VERSION
+
+ gem.add_development_dependency "rake"
+ gem.add_development_dependency "rspec"
+end
View
6 lib/ruby/common/commonjs-0.2.6/lib/commonjs.rb
@@ -0,0 +1,6 @@
+require "commonjs/version"
+
+module CommonJS
+ autoload :Environment, 'commonjs/environment'
+ autoload :Module, 'commonjs/module'
+end
View
39 lib/ruby/common/commonjs-0.2.6/lib/commonjs/environment.rb
@@ -0,0 +1,39 @@
+require 'pathname'
+module CommonJS
+ class Environment
+
+ attr_reader :runtime
+
+ def initialize(runtime, options = {})
+ @runtime = runtime
+ @paths = [options[:path]].flatten.map {|path| Pathname(path)}
+ @modules = {}
+ end
+
+ def require(module_id)
+ unless mod = @modules[module_id]
+ filepath = find(module_id) or fail LoadError, "no such module '#{module_id}'"
+ load = @runtime.eval("(function(module, require, exports) {#{File.read(filepath)}})", filepath.expand_path.to_s)
+ @modules[module_id] = mod = Module.new(module_id, self)
+ load.call(mod, mod.require_function, mod.exports)
+ end
+ return mod.exports
+ end
+
+ def native(module_id, impl)
+ @modules[module_id] = Module::Native.new(impl)
+ end
+
+ def new_object
+ @runtime['Object'].new
+ end
+
+ private
+
+ def find(module_id)
+ if loadpath = @paths.find { |path| path.join("#{module_id}.js").exist? }
+ loadpath.join("#{module_id}.js")
+ end
+ end
+ end
+end
View
49 lib/ruby/common/commonjs-0.2.6/lib/commonjs/module.rb
@@ -0,0 +1,49 @@
+module CommonJS
+ class Module
+
+ attr_reader :id
+ attr_accessor :exports
+
+ def initialize(id, env)
+ @id = id
+ @env = env
+ @exports = env.new_object
+ @segments = id.split('/')
+ end
+
+ def require_function
+ @require_function ||= lambda do |*args|
+ this, module_id = *args
+ module_id ||= this #backwards compatibility with TRR < 0.10
+ @env.require(expand(module_id))
+ end
+ end
+
+ private
+
+ def expand(module_id)
+ return module_id unless module_id =~ /(\.|\..)/
+ module_id.split('/').inject(@segments[0..-2]) do |path, element|
+ path.tap do
+ if element == '.'
+ #do nothing
+ elsif element == '..'
+ path.pop
+ else
+ path.push element
+ end
+ end
+ end.join('/')
+ end
+
+
+ class Native
+
+ attr_reader :exports
+
+ def initialize(impl)
+ @exports = impl
+ end
+ end
+ end
+end
View
3  lib/ruby/common/commonjs-0.2.6/lib/commonjs/version.rb
@@ -0,0 +1,3 @@
+module CommonJS
+ VERSION = "0.2.6"
+end
View
1  lib/ruby/common/commonjs-0.2.6/spec/commonjs/libjs/assign_module_exports.js
@@ -0,0 +1 @@
+module.exports = function() {return 'I am your exports'}
View
1  lib/ruby/common/commonjs-0.2.6/spec/commonjs/libjs/one.js
@@ -0,0 +1 @@
+exports.one = 'one'
View
1  lib/ruby/common/commonjs-0.2.6/spec/commonjs/libjs/three.js
@@ -0,0 +1 @@
+exports.three = 'three'
View
1  lib/ruby/common/commonjs-0.2.6/spec/commonjs/libjs2/one.js
@@ -0,0 +1 @@
+exports.one = 1
View
1  lib/ruby/common/commonjs-0.2.6/spec/commonjs/libjs2/two.js
@@ -0,0 +1 @@
+exports.two = 2
View
10 lib/ruby/common/commonjs-0.2.6/spec/commonjs/modules_extensions_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+
+describe 'modules extensions' do
+ before do
+ @env = env_with_path_value File.expand_path('../libjs', __FILE__)
+ end
+ it "allows the exports object to be completely replaced" do
+ @env.require('assign_module_exports').call().should eql "I am your exports"
+ end
+end
View
34 lib/ruby/common/commonjs-0.2.6/spec/commonjs/modules_spec.rb
@@ -0,0 +1,34 @@
+# -*- encoding: utf-8 -*-
+require 'spec_helper'
+
+describe "modules 1.0" do
+
+ def self.make_before(path)
+ proc do
+ @env = env_with_path_value(path)
+ @env.native('system', QuietSystem.new)
+ end
+ end
+
+ tests = Pathname(__FILE__).dirname.join('../ext/commonjs/tests/modules/1.0')
+ tests.entries.each do |path|
+ next if ['.','..'].include?(path.to_s)
+
+ describe path do
+ before(&make_before(tests.join(path)))
+
+ it "" do
+ @env.require('program')
+ end
+ end
+ end
+
+ class QuietSystem
+ def stdio
+ self
+ end
+ def print
+ lambda {|*args|}
+ end
+ end
+end
View
33 lib/ruby/common/commonjs-0.2.6/spec/commonjs/path_spec.rb
@@ -0,0 +1,33 @@
+require 'spec_helper'
+
+describe "load paths: " do
+ describe "with a single path" do
+ before do
+ @env = env_with_path_value File.expand_path('../libjs', __FILE__)
+ end
+
+ it "finds modules in that path" do
+ @env.require('one').one.should eql 'one'
+ end
+
+ it "fails when a module is not in the path" do
+ expect {@env.require('not_here')}.should raise_error LoadError
+ end
+ end
+
+ describe "with multilpe paths" do
+ before do
+ @env = env_with_path_value [File.expand_path('../libjs2', __FILE__), File.expand_path('../libjs', __FILE__)]
+ end
+
+ it "finds modules in both paths" do
+ @env.require('two').two.should eql 2
+ @env.require('three').three.should eql 'three'
+ end
+
+ it "respects the order in which paths were specified" do
+ @env.require('one').one.to_i.should eql 1
+ end
+ end
+end
+
View
19 lib/ruby/common/commonjs-0.2.6/spec/spec_helper.rb
@@ -0,0 +1,19 @@
+
+require 'commonjs'
+require 'pathname'
+
+def env_with_path_value(path)
+ CommonJS::Environment.new new_runtime, :path => path
+end
+
+if defined?(JRUBY_VERSION)
+ require 'rhino'
+ def new_runtime
+ Rhino::Context.new
+ end
+else
+ require 'v8'
+ def new_runtime
+ V8::Context.new
+ end
+end
View
2  lib/ruby/common/execjs-1.4.0/lib/execjs/support/node_runner.js
@@ -1,4 +1,4 @@
-(function(program, execJS) { execJS(program) })(function(module, exports, require, console) { #{source}
+(function(program, execJS, module, exports, require) { execJS(program) })(function() { #{source}
}, function(program) {
var output, print = function(string) {
process.stdout.write('' + string);
View
0  lib/ruby/jruby/json-1.7.7-java/lib/json.rb → lib/ruby/common/json-1.8.0-java/lib/json.rb
File renamed without changes
View
0  .../jruby/json-1.7.7-java/lib/json/add/bigdecimal.rb → ...common/json-1.8.0-java/lib/json/add/bigdecimal.rb
File renamed without changes
View
0  ...uby/jruby/json-1.7.7-java/lib/json/add/complex.rb → ...by/common/json-1.8.0-java/lib/json/add/complex.rb
File renamed without changes
View
0  lib/ruby/jruby/json-1.7.7-java/lib/json/add/core.rb → lib/ruby/common/json-1.8.0-java/lib/json/add/core.rb
File renamed without changes
View
0  lib/ruby/jruby/json-1.7.7-java/lib/json/add/date.rb → lib/ruby/common/json-1.8.0-java/lib/json/add/date.rb
File renamed without changes
View
0  ...y/jruby/json-1.7.7-java/lib/json/add/date_time.rb → .../common/json-1.8.0-java/lib/json/add/date_time.rb
File renamed without changes
View
0  ...y/jruby/json-1.7.7-java/lib/json/add/exception.rb → .../common/json-1.8.0-java/lib/json/add/exception.rb
File renamed without changes
View
0  ...uby/jruby/json-1.7.7-java/lib/json/add/ostruct.rb → ...by/common/json-1.8.0-java/lib/json/add/ostruct.rb
File renamed without changes
View
0  lib/ruby/jruby/json-1.7.7-java/lib/json/add/range.rb → ...ruby/common/json-1.8.0-java/lib/json/add/range.rb
File renamed without changes
View
0  ...by/jruby/json-1.7.7-java/lib/json/add/rational.rb → ...y/common/json-1.8.0-java/lib/json/add/rational.rb
File renamed without changes
View
0  ...ruby/jruby/json-1.7.7-java/lib/json/add/regexp.rb → ...uby/common/json-1.8.0-java/lib/json/add/regexp.rb
File renamed without changes
View
0  ...ruby/jruby/json-1.7.7-java/lib/json/add/struct.rb → ...uby/common/json-1.8.0-java/lib/json/add/struct.rb
File renamed without changes
View
0  ...ruby/jruby/json-1.7.7-java/lib/json/add/symbol.rb → ...uby/common/json-1.8.0-java/lib/json/add/symbol.rb
File renamed without changes
View
0  lib/ruby/jruby/json-1.7.7-java/lib/json/add/time.rb → lib/ruby/common/json-1.8.0-java/lib/json/add/time.rb
File renamed without changes
View
0  lib/ruby/jruby/json-1.7.7-java/lib/json/common.rb → lib/ruby/common/json-1.8.0-java/lib/json/common.rb
File renamed without changes
View
0  lib/ruby/jruby/json-1.7.7-java/lib/json/ext.rb → lib/ruby/common/json-1.8.0-java/lib/json/ext.rb
File renamed without changes
View
BIN  lib/ruby/common/json-1.8.0-java/lib/json/ext/generator.jar
Binary file not shown
View
BIN  lib/ruby/common/json-1.8.0-java/lib/json/ext/parser.jar
Binary file not shown
View
70 lib/ruby/common/json-1.8.0-java/lib/json/generic_object.rb
@@ -0,0 +1,70 @@
+require 'ostruct'
+
+module JSON
+ class GenericObject < OpenStruct
+ class << self
+ alias [] new
+
+ def json_creatable?
+ @json_creatable
+ end
+
+ attr_writer :json_creatable
+
+ def json_create(data)
+ data = data.dup
+ data.delete JSON.create_id
+ self[data]
+ end
+
+ def from_hash(object)
+ case
+ when object.respond_to?(:to_hash)
+ result = new
+ object.to_hash.each do |key, value|
+ result[key] = from_hash(value)
+ end
+ result
+ when object.respond_to?(:to_ary)
+ object.to_ary.map { |a| from_hash(a) }
+ else
+ object
+ end
+ end
+
+ def load(source, proc = nil, opts = {})
+ result = ::JSON.load(source, proc, opts.merge(:object_class => self))
+ result.nil? ? new : result
+ end
+
+ def dump(obj, *args)
+ ::JSON.dump(obj, *args)
+ end
+ end
+ self.json_creatable = false
+
+ def to_hash
+ table
+ end
+
+ def [](name)
+ table[name.to_sym]
+ end
+
+ def []=(name, value)
+ __send__ "#{name}=", value
+ end
+
+ def |(other)
+ self.class[other.to_hash.merge(to_hash)]
+ end
+
+ def as_json(*)
+ { JSON.create_id => self.class.name }.merge to_hash
+ end
+
+ def to_json(*a)
+ as_json.to_json(*a)
+ end
+ end
+end
View
0  lib/ruby/jruby/json-1.7.7-java/lib/json/pure.rb → lib/ruby/common/json-1.8.0-java/lib/json/pure.rb
File renamed without changes
View
522 lib/ruby/common/json-1.8.0-java/lib/json/pure/generator.rb
@@ -0,0 +1,522 @@
+module JSON
+ MAP = {
+ "\x0" => '\u0000',
+ "\x1" => '\u0001',
+ "\x2" => '\u0002',
+ "\x3" => '\u0003',
+ "\x4" => '\u0004',
+ "\x5" => '\u0005',
+ "\x6" => '\u0006',
+ "\x7" => '\u0007',
+ "\b" => '\b',
+ "\t" => '\t',
+ "\n" => '\n',
+ "\xb" => '\u000b',
+ "\f" => '\f',
+ "\r" => '\r',
+ "\xe" => '\u000e',
+ "\xf" => '\u000f',
+ "\x10" => '\u0010',
+ "\x11" => '\u0011',
+ "\x12" => '\u0012',
+ "\x13" => '\u0013',
+ "\x14" => '\u0014',
+ "\x15" => '\u0015',
+ "\x16" => '\u0016',
+ "\x17" => '\u0017',
+ "\x18" => '\u0018',
+ "\x19" => '\u0019',
+ "\x1a" => '\u001a',
+ "\x1b" => '\u001b',
+ "\x1c" => '\u001c',
+ "\x1d" => '\u001d',
+ "\x1e" => '\u001e',
+ "\x1f" => '\u001f',
+ '"' => '\"',
+ '\\' => '\\\\',
+ } # :nodoc:
+
+ # Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with
+ # UTF16 big endian characters as \u????, and return it.
+ if defined?(::Encoding)
+ def utf8_to_json(string) # :nodoc:
+ string = string.dup
+ string.force_encoding(::Encoding::ASCII_8BIT)
+ string.gsub!(/["\\\x0-\x1f]/) { MAP[$&] }
+ string.force_encoding(::Encoding::UTF_8)
+ string
+ end
+
+ def utf8_to_json_ascii(string) # :nodoc:
+ string = string.dup
+ string.force_encoding(::Encoding::ASCII_8BIT)
+ string.gsub!(/["\\\x0-\x1f]/n) { MAP[$&] }
+ string.gsub!(/(
+ (?:
+ [\xc2-\xdf][\x80-\xbf] |
+ [\xe0-\xef][\x80-\xbf]{2} |
+ [\xf0-\xf4][\x80-\xbf]{3}
+ )+ |
+ [\x80-\xc1\xf5-\xff] # invalid
+ )/nx) { |c|
+ c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
+ s = JSON.iconv('utf-16be', 'utf-8', c).unpack('H*')[0]
+ s.force_encoding(::Encoding::ASCII_8BIT)
+ s.gsub!(/.{4}/n, '\\\\u\&')
+ s.force_encoding(::Encoding::UTF_8)
+ }
+ string.force_encoding(::Encoding::UTF_8)
+ string
+ rescue => e
+ raise GeneratorError.wrap(e)
+ end
+
+ def valid_utf8?(string)
+ encoding = string.encoding
+ (encoding == Encoding::UTF_8 || encoding == Encoding::ASCII) &&
+ string.valid_encoding?
+ end
+ module_function :valid_utf8?
+ else
+ def utf8_to_json(string) # :nodoc:
+ string.gsub(/["\\\x0-\x1f]/n) { MAP[$&] }
+ end
+
+ def utf8_to_json_ascii(string) # :nodoc:
+ string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] }
+ string.gsub!(/(
+ (?:
+ [\xc2-\xdf][\x80-\xbf] |
+ [\xe0-\xef][\x80-\xbf]{2} |
+ [\xf0-\xf4][\x80-\xbf]{3}
+ )+ |
+ [\x80-\xc1\xf5-\xff] # invalid
+ )/nx) { |c|
+ c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
+ s = JSON.iconv('utf-16be', 'utf-8', c).unpack('H*')[0]
+ s.gsub!(/.{4}/n, '\\\\u\&')
+ }
+ string
+ rescue => e
+ raise GeneratorError.wrap(e)
+ end
+
+ def valid_utf8?(string)
+ string =~
+ /\A( [\x09\x0a\x0d\x20-\x7e] # ASCII
+ | [\xc2-\xdf][\x80-\xbf] # non-overlong 2-byte
+ | \xe0[\xa0-\xbf][\x80-\xbf] # excluding overlongs
+ | [\xe1-\xec\xee\xef][\x80-\xbf]{2} # straight 3-byte
+ | \xed[\x80-\x9f][\x80-\xbf] # excluding surrogates
+ | \xf0[\x90-\xbf][\x80-\xbf]{2} # planes 1-3
+ | [\xf1-\xf3][\x80-\xbf]{3} # planes 4-15
+ | \xf4[\x80-\x8f][\x80-\xbf]{2} # plane 16
+ )*\z/nx
+ end
+ end
+ module_function :utf8_to_json, :utf8_to_json_ascii, :valid_utf8?
+
+
+ module Pure
+ module Generator
+ # This class is used to create State instances, that are use to hold data
+ # while generating a JSON text from a Ruby data structure.
+ class State
+ # Creates a State object from _opts_, which ought to be Hash to create
+ # a new State instance configured by _opts_, something else to create
+ # an unconfigured instance. If _opts_ is a State object, it is just
+ # returned.
+ def self.from_state(opts)
+ case
+ when self === opts
+ opts
+ when opts.respond_to?(:to_hash)
+ new(opts.to_hash)
+ when opts.respond_to?(:to_h)
+ new(opts.to_h)
+ else
+ SAFE_STATE_PROTOTYPE.dup
+ end
+ end
+
+ # Instantiates a new State object, configured by _opts_.
+ #
+ # _opts_ 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: ''),
+ # * *check_circular*: is deprecated now, use the :max_nesting option instead,
+ # * *max_nesting*: sets the maximum level of data structure nesting in
+ # the generated JSON, max_nesting = 0 if no maximum should be checked.
+ # * *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.
+ # * *quirks_mode*: Enables quirks_mode for parser, that is for example
+ # generating single JSON values instead of documents is possible.
+ def initialize(opts = {})
+ @indent = ''
+ @space = ''
+ @space_before = ''
+ @object_nl = ''
+ @array_nl = ''
+ @allow_nan = false
+ @ascii_only = false
+ @quirks_mode = false
+ @buffer_initial_length = 1024
+ configure opts
+ end
+
+ # This string is used to indent levels in the JSON text.
+ attr_accessor :indent
+
+ # This string is used to insert a space between the tokens in a JSON
+ # string.
+ attr_accessor :space
+
+ # This string is used to insert a space before the ':' in JSON objects.
+ attr_accessor :space_before
+
+ # This string is put at the end of a line that holds a JSON object (or
+ # Hash).
+ attr_accessor :object_nl
+
+ # This string is put at the end of a line that holds a JSON array.
+ attr_accessor :array_nl
+
+ # This integer returns the maximum level of data structure nesting in
+ # the generated JSON, max_nesting = 0 if no maximum is checked.
+ attr_accessor :max_nesting
+
+ # If this attribute is set to true, quirks mode is enabled, otherwise
+ # it's disabled.
+ attr_accessor :quirks_mode
+
+ # :stopdoc:
+ attr_reader :buffer_initial_length
+
+ def buffer_initial_length=(length)
+ if length > 0
+ @buffer_initial_length = length
+ end
+ end
+ # :startdoc:
+
+ # This integer returns the current depth data structure nesting in the
+ # generated JSON.
+ attr_accessor :depth
+
+ def check_max_nesting # :nodoc:
+ return if @max_nesting.zero?
+ current_nesting = depth + 1
+ current_nesting > @max_nesting and
+ raise NestingError, "nesting of #{current_nesting} is too deep"
+ end
+
+ # Returns true, if circular data structures are checked,
+ # otherwise returns false.
+ def check_circular?
+ !@max_nesting.zero?
+ end
+
+ # Returns true if NaN, Infinity, and -Infinity should be considered as
+ # valid JSON and output.
+ def allow_nan?
+ @allow_nan
+ end
+
+ # Returns true, if only ASCII characters should be generated. Otherwise
+ # returns false.
+ def ascii_only?
+ @ascii_only
+ end
+
+ # Returns true, if quirks mode is enabled. Otherwise returns false.
+ def quirks_mode?
+ @quirks_mode
+ end
+
+ # Configure this State instance with the Hash _opts_, and return
+ # itself.
+ def configure(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
+ for key, value in opts
+ instance_variable_set "@#{key}", value
+ end
+ @indent = opts[:indent] if opts.key?(:indent)
+ @space = opts[:space] if opts.key?(:space)
+ @space_before = opts[:space_before] if opts.key?(:space_before)
+ @object_nl = opts[:object_nl] if opts.key?(:object_nl)
+ @array_nl = opts[:array_nl] if opts.key?(:array_nl)
+ @allow_nan = !!opts[:allow_nan] if opts.key?(:allow_nan)
+ @ascii_only = opts[:ascii_only] if opts.key?(:ascii_only)
+ @depth = opts[:depth] || 0
+ @quirks_mode = opts[:quirks_mode] if opts.key?(:quirks_mode)
+ @buffer_initial_length ||= opts[:buffer_initial_length]
+
+ if !opts.key?(:max_nesting) # defaults to 100
+ @max_nesting = 100
+ elsif opts[:max_nesting]
+ @max_nesting = opts[:max_nesting]
+ else
+ @max_nesting = 0
+ end
+ self
+ end
+ alias merge configure
+
+ # Returns the configuration instance variables as a hash, that can be
+ # passed to the configure method.
+ def to_h
+ result = {}
+ for iv in instance_variables
+ iv = iv.to_s[1..-1]
+ result[iv.to_sym] = self[iv]
+ end
+ result
+ end
+
+ alias to_hash to_h
+
+ # Generates a valid JSON document from object +obj+ and returns the
+ # result. If no valid JSON document can be created this method raises a
+ # GeneratorError exception.
+ def generate(obj)
+ result = obj.to_json(self)
+ JSON.valid_utf8?(result) or raise GeneratorError,
+ "source sequence #{result.inspect} is illegal/malformed utf-8"
+ unless @quirks_mode
+ unless result =~ /\A\s*\[/ && result =~ /\]\s*\Z/ ||
+ result =~ /\A\s*\{/ && result =~ /\}\s*\Z/
+ then
+ raise GeneratorError, "only generation of JSON objects or arrays allowed"
+ end
+ end
+ result
+ end
+
+ # Return the value returned by method +name+.
+ def [](name)
+ if respond_to?(name)
+ __send__(name)
+ else
+ instance_variable_get("@#{name}")
+ end
+ end
+
+ def []=(name, value)
+ if respond_to?(name_writer = "#{name}=")
+ __send__ name_writer, value
+ else
+ instance_variable_set "@#{name}", value
+ end
+ end
+ end
+
+ module GeneratorMethods
+ module Object
+ # Converts this object to a string (calling #to_s), converts
+ # it to a JSON string, and returns the result. This is a fallback, if no
+ # special method #to_json was defined for some object.
+ def to_json(*) to_s.to_json end
+ end
+
+ module Hash
+ # Returns a JSON string containing a JSON object, that is unparsed from
+ # this Hash instance.
+ # _state_ is a JSON::State object, that can also be used to configure the
+ # produced JSON string output further.
+ # _depth_ is used to find out nesting depth, to indent accordingly.
+ def to_json(state = nil, *)
+ state = State.from_state(state)
+ state.check_max_nesting
+ json_transform(state)
+ end
+
+ private
+
+ def json_shift(state)
+ state.object_nl.empty? or return ''
+ state.indent * state.depth
+ end
+
+ def json_transform(state)
+ delim = ','
+ delim << state.object_nl
+ result = '{'
+ result << state.object_nl
+ depth = state.depth += 1
+ first = true
+ indent = !state.object_nl.empty?
+ each { |key,value|
+ result << delim unless first
+ result << state.indent * depth if indent
+ result << key.to_s.to_json(state)
+ result << state.space_before
+ result << ':'
+ result << state.space
+ result << value.to_json(state)
+ first = false
+ }
+ depth = state.depth -= 1
+ result << state.object_nl
+ result << state.indent * depth if indent
+ result << '}'
+ result
+ end
+ end
+
+ module Array
+ # Returns a JSON string containing a JSON array, that is unparsed from
+ # this Array instance.
+ # _state_ is a JSON::State object, that can also be used to configure the
+ # produced JSON string output further.
+ def to_json(state = nil, *)
+ state = State.from_state(state)
+ state.check_max_nesting
+ json_transform(state)
+ end
+
+ private
+
+ def json_transform(state)
+ delim = ','
+ delim << state.array_nl
+ result = '['
+ result << state.array_nl
+ depth = state.depth += 1
+ first = true
+ indent = !state.array_nl.empty?
+ each { |value|
+ result << delim unless first
+ result << state.indent * depth if indent
+ result << value.to_json(state)
+ first = false
+ }
+ depth = state.depth -= 1
+ result << state.array_nl
+ result << state.indent * depth if indent
+ result << ']'
+ end
+ end
+
+ module Integer
+ # Returns a JSON string representation for this Integer number.
+ def to_json(*) to_s end
+ end
+
+ module Float
+ # Returns a JSON string representation for this Float number.
+ def to_json(state = nil, *)
+ state = State.from_state(state)
+ case
+ when infinite?
+ if state.allow_nan?
+ to_s
+ else
+ raise GeneratorError, "#{self} not allowed in JSON"
+ end
+ when nan?
+ if state.allow_nan?
+ to_s
+ else
+ raise GeneratorError, "#{self} not allowed in JSON"
+ end
+ else
+ to_s
+ end
+ end
+ end
+
+ module String
+ if defined?(::Encoding)
+ # This string should be encoded with UTF-8 A call to this method
+ # returns a JSON string encoded with UTF16 big endian characters as
+ # \u????.
+ def to_json(state = nil, *args)
+ state = State.from_state(state)
+ if encoding == ::Encoding::UTF_8
+ string = self
+ else
+ string = encode(::Encoding::UTF_8)
+ end
+ if state.ascii_only?
+ '"' << JSON.utf8_to_json_ascii(string) << '"'
+ else
+ '"' << JSON.utf8_to_json(string) << '"'
+ end
+ end
+ else
+ # This string should be encoded with UTF-8 A call to this method
+ # returns a JSON string encoded with UTF16 big endian characters as
+ # \u????.
+ def to_json(state = nil, *args)
+ state = State.from_state(state)
+ if state.ascii_only?
+ '"' << JSON.utf8_to_json_ascii(self) << '"'
+ else
+ '"' << JSON.utf8_to_json(self) << '"'
+ end
+ end
+ end
+
+ # Module that holds the extinding methods if, the String module is
+ # included.
+ module Extend
+ # Raw Strings are JSON Objects (the raw bytes are stored in an
+ # array for the key "raw"). The Ruby String can be created by this
+ # module method.
+ def json_create(o)
+ o['raw'].pack('C*')
+ end
+ end
+
+ # Extends _modul_ with the String::Extend module.
+ def self.included(modul)
+ modul.extend Extend
+ end
+
+ # This method creates a raw object hash, that can be nested into
+ # other data structures and will be unparsed as a raw string. This
+ # method should be used, if you want to convert raw strings to JSON
+ # instead of UTF-8 strings, e. g. binary data.
+ def to_json_raw_object
+ {
+ JSON.create_id => self.class.name,
+ 'raw' => self.unpack('C*'),
+ }
+ end
+
+ # This method creates a JSON text from the result of
+ # a call to to_json_raw_object of this String.
+ def to_json_raw(*args)
+ to_json_raw_object.to_json(*args)
+ end
+ end
+
+ module TrueClass
+ # Returns a JSON string for true: 'true'.
+ def to_json(*) 'true' end
+ end
+
+ module FalseClass
+ # Returns a JSON string for false: 'false'.
+ def to_json(*) 'false' end
+ end
+
+ module NilClass
+ # Returns a JSON string for nil: 'null'.
+ def to_json(*) 'null' end
+ end
+ end
+ end
+ end
+end
View
0  ...uby/jruby/json-1.7.7-java/lib/json/pure/parser.rb → ...by/common/json-1.8.0-java/lib/json/pure/parser.rb
File renamed without changes
View
8 lib/ruby/common/json-1.8.0-java/lib/json/version.rb
@@ -0,0 +1,8 @@
+module JSON
+ # JSON version
+ VERSION = '1.8.0'
+ 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
View
0  ...y/jruby/json-1.7.7-java/tests/fixtures/fail1.json → .../common/json-1.8.0-java/tests/fixtures/fail1.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail10.json → ...common/json-1.8.0-java/tests/fixtures/fail10.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail11.json → ...common/json-1.8.0-java/tests/fixtures/fail11.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail12.json → ...common/json-1.8.0-java/tests/fixtures/fail12.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail13.json → ...common/json-1.8.0-java/tests/fixtures/fail13.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail14.json → ...common/json-1.8.0-java/tests/fixtures/fail14.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail18.json → ...common/json-1.8.0-java/tests/fixtures/fail18.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail19.json → ...common/json-1.8.0-java/tests/fixtures/fail19.json
File renamed without changes
View
0  ...y/jruby/json-1.7.7-java/tests/fixtures/fail2.json → .../common/json-1.8.0-java/tests/fixtures/fail2.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail20.json → ...common/json-1.8.0-java/tests/fixtures/fail20.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail21.json → ...common/json-1.8.0-java/tests/fixtures/fail21.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail22.json → ...common/json-1.8.0-java/tests/fixtures/fail22.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail23.json → ...common/json-1.8.0-java/tests/fixtures/fail23.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail24.json → ...common/json-1.8.0-java/tests/fixtures/fail24.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail25.json → ...common/json-1.8.0-java/tests/fixtures/fail25.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail27.json → ...common/json-1.8.0-java/tests/fixtures/fail27.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/fail28.json → ...common/json-1.8.0-java/tests/fixtures/fail28.json
File renamed without changes
View
0  ...y/jruby/json-1.7.7-java/tests/fixtures/fail3.json → .../common/json-1.8.0-java/tests/fixtures/fail3.json
File renamed without changes
View
0  ...y/jruby/json-1.7.7-java/tests/fixtures/fail4.json → .../common/json-1.8.0-java/tests/fixtures/fail4.json
File renamed without changes
View
0  ...y/jruby/json-1.7.7-java/tests/fixtures/fail5.json → .../common/json-1.8.0-java/tests/fixtures/fail5.json
File renamed without changes
View
0  ...y/jruby/json-1.7.7-java/tests/fixtures/fail6.json → .../common/json-1.8.0-java/tests/fixtures/fail6.json
File renamed without changes
View
0  ...y/jruby/json-1.7.7-java/tests/fixtures/fail7.json → .../common/json-1.8.0-java/tests/fixtures/fail7.json
File renamed without changes
View
0  ...y/jruby/json-1.7.7-java/tests/fixtures/fail8.json → .../common/json-1.8.0-java/tests/fixtures/fail8.json
File renamed without changes
View
0  ...y/jruby/json-1.7.7-java/tests/fixtures/fail9.json → .../common/json-1.8.0-java/tests/fixtures/fail9.json
File renamed without changes
View
0  ...y/jruby/json-1.7.7-java/tests/fixtures/pass1.json → .../common/json-1.8.0-java/tests/fixtures/pass1.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/pass15.json → ...common/json-1.8.0-java/tests/fixtures/pass15.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/pass16.json → ...common/json-1.8.0-java/tests/fixtures/pass16.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/pass17.json → ...common/json-1.8.0-java/tests/fixtures/pass17.json
File renamed without changes
View
0  ...y/jruby/json-1.7.7-java/tests/fixtures/pass2.json → .../common/json-1.8.0-java/tests/fixtures/pass2.json
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/fixtures/pass26.json → ...common/json-1.8.0-java/tests/fixtures/pass26.json
File renamed without changes
View
0  ...y/jruby/json-1.7.7-java/tests/fixtures/pass3.json → .../common/json-1.8.0-java/tests/fixtures/pass3.json
File renamed without changes
View
0  ...ruby/jruby/json-1.7.7-java/tests/setup_variant.rb → ...uby/common/json-1.8.0-java/tests/setup_variant.rb
File renamed without changes
View
0  lib/ruby/jruby/json-1.7.7-java/tests/test_json.rb → lib/ruby/common/json-1.8.0-java/tests/test_json.rb
File renamed without changes
View
0  ...jruby/json-1.7.7-java/tests/test_json_addition.rb → ...ommon/json-1.8.0-java/tests/test_json_addition.rb
File renamed without changes
View
0  ...jruby/json-1.7.7-java/tests/test_json_encoding.rb → ...ommon/json-1.8.0-java/tests/test_json_encoding.rb
File renamed without changes
View
0  ...jruby/json-1.7.7-java/tests/test_json_fixtures.rb → ...ommon/json-1.8.0-java/tests/test_json_fixtures.rb
File renamed without changes
View
322 lib/ruby/common/json-1.8.0-java/tests/test_json_generate.rb
@@ -0,0 +1,322 @@
+#!/usr/bin/env ruby
+# encoding: utf-8
+
+require 'test/unit'
+require File.join(File.dirname(__FILE__), 'setup_variant')
+
+class TestJSONGenerate < Test::Unit::TestCase
+ include JSON
+
+ def setup
+ @hash = {
+ 'a' => 2,
+ 'b' => 3.141,
+ 'c' => 'c',
+ 'd' => [ 1, "b", 3.14 ],
+ 'e' => { 'foo' => 'bar' },
+ 'g' => "\"\0\037",
+ 'h' => 1000.0,
+ 'i' => 0.001
+ }
+ @json2 = '{"a":2,"b":3.141,"c":"c","d":[1,"b",3.14],"e":{"foo":"bar"},' +
+ '"g":"\\"\\u0000\\u001f","h":1000.0,"i":0.001}'
+ @json3 = <<'EOT'.chomp
+{
+ "a": 2,
+ "b": 3.141,
+ "c": "c",
+ "d": [
+ 1,
+ "b",
+ 3.14
+ ],
+ "e": {
+ "foo": "bar"
+ },
+ "g": "\"\u0000\u001f",
+ "h": 1000.0,
+ "i": 0.001
+}
+EOT
+ end
+
+ def test_generate
+ json = generate(@hash)
+ assert_equal(JSON.parse(@json2), JSON.parse(json))
+ json = JSON[@hash]
+ assert_equal(JSON.parse(@json2), JSON.parse(json))
+ parsed_json = parse(json)
+ assert_equal(@hash, parsed_json)
+ json = generate({1=>2})
+ assert_equal('{"1":2}', json)
+ parsed_json = parse(json)
+ assert_equal({"1"=>2}, parsed_json)
+ assert_raise(GeneratorError) { generate(666) }
+ assert_equal '666', generate(666, :quirks_mode => true)
+ end
+
+ def test_generate_pretty
+ json = pretty_generate(@hash)
+ # hashes aren't (insertion) ordered on every ruby implementation assert_equal(@json3, json)
+ assert_equal(JSON.parse(@json3), JSON.parse(json))
+ parsed_json = parse(json)
+ assert_equal(@hash, parsed_json)
+ json = pretty_generate({1=>2})
+ assert_equal(<<'EOT'.chomp, json)
+{
+ "1": 2
+}
+EOT
+ parsed_json = parse(json)
+ assert_equal({"1"=>2}, parsed_json)
+ assert_raise(GeneratorError) { pretty_generate(666) }
+ assert_equal '666', pretty_generate(666, :quirks_mode => true)
+ end
+
+ def test_fast_generate
+ json = fast_generate(@hash)
+ assert_equal(JSON.parse(@json2), JSON.parse(json))
+ parsed_json = parse(json)
+ assert_equal(@hash, parsed_json)
+ json = fast_generate({1=>2})
+ assert_equal('{"1":2}', json)
+ parsed_json = parse(json)
+ assert_equal({"1"=>2}, parsed_json)
+ assert_raise(GeneratorError) { fast_generate(666) }
+ assert_equal '666', fast_generate(666, :quirks_mode => true)
+ end
+
+ def test_own_state
+ state = State.new
+ json = generate(@hash, state)
+ assert_equal(JSON.parse(@json2), JSON.parse(json))
+ parsed_json = parse(json)
+ assert_equal(@hash, parsed_json)
+ json = generate({1=>2}, state)
+ assert_equal('{"1":2}', json)
+ parsed_json = parse(json)
+ assert_equal({"1"=>2}, parsed_json)
+ assert_raise(GeneratorError) { generate(666, state) }
+ state.quirks_mode = true
+ assert state.quirks_mode?
+ assert_equal '666', generate(666, state)
+ end
+
+ def test_states
+ json = generate({1=>2}, nil)
+ assert_equal('{"1":2}', json)
+ s = JSON.state.new
+ assert s.check_circular?
+ assert s[:check_circular?]
+ h = { 1=>2 }
+ h[3] = h
+ assert_raises(JSON::NestingError) { generate(h) }
+ assert_raises(JSON::NestingError) { generate(h, s) }
+ s = JSON.state.new
+ a = [ 1, 2 ]
+ a << a
+ assert_raises(JSON::NestingError) { generate(a, s) }
+ assert s.check_circular?
+ assert s[:check_circular?]
+ end
+
+ def test_pretty_state
+ state = PRETTY_STATE_PROTOTYPE.dup
+ assert_equal({
+ :allow_nan => false,
+ :array_nl => "\n",
+ :ascii_only => false,
+ :buffer_initial_length => 1024,
+ :quirks_mode => false,
+ :depth => 0,
+ :indent => " ",
+ :max_nesting => 100,
+ :object_nl => "\n",
+ :space => " ",
+ :space_before => "",
+ }.sort_by { |n,| n.to_s }, state.to_h.sort_by { |n,| n.to_s })
+ end
+
+ def test_safe_state
+ state = SAFE_STATE_PROTOTYPE.dup
+ assert_equal({
+ :allow_nan => false,
+ :array_nl => "",
+ :ascii_only => false,
+ :buffer_initial_length => 1024,
+ :quirks_mode => false,
+ :depth => 0,
+ :indent => "",
+ :max_nesting => 100,
+ :object_nl => "",
+ :space => "",
+ :space_before => "",
+ }.sort_by { |n,| n.to_s }, state.to_h.sort_by { |n,| n.to_s })
+ end
+
+ def test_fast_state
+ state = FAST_STATE_PROTOTYPE.dup
+ assert_equal({
+ :allow_nan => false,
+ :array_nl => "",
+ :ascii_only => false,
+ :buffer_initial_length => 1024,
+ :quirks_mode => false,
+ :depth => 0,
+ :indent => "",
+ :max_nesting => 0,
+ :object_nl => "",
+ :space => "",
+ :space_before => "",
+ }.sort_by { |n,| n.to_s }, state.to_h.sort_by { |n,| n.to_s })
+ end
+
+ def test_allow_nan
+ assert_raises(GeneratorError) { generate([JSON::NaN]) }
+ assert_equal '[NaN]', generate([JSON::NaN], :allow_nan => true)
+ assert_raises(GeneratorError) { fast_generate([JSON::NaN]) }
+ assert_raises(GeneratorError) { pretty_generate([JSON::NaN]) }
+ assert_equal "[\n NaN\n]", pretty_generate([JSON::NaN], :allow_nan => true)
+ assert_raises(GeneratorError) { generate([JSON::Infinity]) }
+ assert_equal '[Infinity]', generate([JSON::Infinity], :allow_nan => true)
+ assert_raises(GeneratorError) { fast_generate([JSON::Infinity]) }
+ assert_raises(GeneratorError) { pretty_generate([JSON::Infinity]) }
+ assert_equal "[\n Infinity\n]", pretty_generate([JSON::Infinity], :allow_nan => true)
+ assert_raises(GeneratorError) { generate([JSON::MinusInfinity]) }
+ assert_equal '[-Infinity]', generate([JSON::MinusInfinity], :allow_nan => true)
+ assert_raises(GeneratorError) { fast_generate([JSON::MinusInfinity]) }
+ assert_raises(GeneratorError) { pretty_generate([JSON::MinusInfinity]) }
+ assert_equal "[\n -Infinity\n]", pretty_generate([JSON::MinusInfinity], :allow_nan => true)
+ end
+
+ def test_depth
+ ary = []; ary << ary
+ assert_equal 0, JSON::SAFE_STATE_PROTOTYPE.depth
+ assert_raises(JSON::NestingError) { JSON.generate(ary) }
+ assert_equal 0, JSON::SAFE_STATE_PROTOTYPE.depth
+ assert_equal 0, JSON::PRETTY_STATE_PROTOTYPE.depth
+ assert_raises(JSON::NestingError) { JSON.pretty_generate(ary) }
+ assert_equal 0, JSON::PRETTY_STATE_PROTOTYPE.depth
+ s = JSON.state.new
+ assert_equal 0, s.depth
+ assert_raises(JSON::NestingError) { ary.to_json(s) }
+ assert_equal 100, s.depth
+ end
+
+ def test_buffer_initial_length
+ s = JSON.state.new
+ assert_equal 1024, s.buffer_initial_length
+ s.buffer_initial_length = 0
+ assert_equal 1024, s.buffer_initial_length
+ s.buffer_initial_length = -1
+ assert_equal 1024, s.buffer_initial_length
+ s.buffer_initial_length = 128
+ assert_equal 128, s.buffer_initial_length
+ end
+
+ def test_gc
+ bignum_too_long_to_embed_as_string = 1234567890123456789012345
+ expect = bignum_too_long_to_embed_as_string.to_s
+ stress, GC.stress = GC.stress, true
+
+ 10.times do |i|
+ tmp = bignum_too_long_to_embed_as_string.to_json
+ assert_equal expect, tmp
+ end
+ ensure
+ GC.stress = stress
+ end if GC.respond_to?(:stress=)
+
+ def test_configure_using_configure_and_merge
+ numbered_state = {
+ :indent => "1",
+ :space => '2',
+ :space_before => '3',
+ :object_nl => '4',
+ :array_nl => '5'
+ }
+ state1 = JSON.state.new
+ state1.merge(numbered_state)
+ assert_equal '1', state1.indent
+ assert_equal '2', state1.space
+ assert_equal '3', state1.space_before
+ assert_equal '4', state1.object_nl
+ assert_equal '5', state1.array_nl
+ state2 = JSON.state.new
+ state2.configure(numbered_state)
+ assert_equal '1', state2.indent
+ assert_equal '2', state2.space
+ assert_equal '3', state2.space_before
+ assert_equal '4', state2.object_nl
+ assert_equal '5', state2.array_nl
+ end
+
+ def test_configure_hash_conversion
+ state = JSON.state.new
+ state.configure(:indent => '1')
+ assert_equal '1', state.indent
+ state = JSON.state.new
+ foo = 'foo'
+ assert_raise(TypeError) do
+ state.configure(foo)
+ end
+ def foo.to_h
+ { :indent => '2' }
+ end
+ state.configure(foo)
+ assert_equal '2', state.indent
+ end
+
+ if defined?(JSON::Ext::Generator)
+ def test_broken_bignum # [ruby-core:38867]
+ pid = fork do
+ Bignum.class_eval do
+ def to_s
+ end
+ end
+ begin
+ JSON::Ext::Generator::State.new.generate(1<<64)
+ exit 1
+ rescue TypeError
+ exit 0
+ end
+ end
+ _, status = Process.waitpid2(pid)
+ assert status.success?
+ rescue NotImplementedError
+ # forking to avoid modifying core class of a parent process and
+ # introducing race conditions of tests are run in parallel
+ end
+ end
+
+ def test_hash_likeness_set_symbol
+ state = JSON.state.new
+ assert_equal nil, state[:foo]
+ assert_equal nil.class, state[:foo].class
+ assert_equal nil, state['foo']
+ state[:foo] = :bar
+ assert_equal :bar, state[:foo]
+ assert_equal :bar, state['foo']
+ state_hash = state.to_hash
+ assert_kind_of Hash, state_hash
+ assert_equal :bar, state_hash[:foo]
+ end
+
+ def test_hash_likeness_set_string
+ state = JSON.state.new
+ assert_equal nil, state[:foo]
+ assert_equal nil, state['foo']
+ state['foo'] = :bar
+ assert_equal :bar, state[:foo]
+ assert_equal :bar, state['foo']
+ state_hash = state.to_hash
+ assert_kind_of Hash, state_hash
+ assert_equal :bar, state_hash[:foo]
+ end
+
+ def test_json_generate
+ assert_raise JSON::GeneratorError do
+ assert_equal true, JSON.generate(["\xea"])
+ end
+ end
+end
View
75 lib/ruby/common/json-1.8.0-java/tests/test_json_generic_object.rb
@@ -0,0 +1,75 @@
+#!/usr/bin/env ruby
+# encoding: utf-8
+
+require 'test/unit'
+require File.join(File.dirname(__FILE__), 'setup_variant')
+class TestJSONGenericObject < Test::Unit::TestCase
+ include JSON
+
+ def setup
+ @go = GenericObject[ :a => 1, :b => 2 ]
+ end
+
+ def test_attributes
+ assert_equal 1, @go.a
+ assert_equal 1, @go[:a]
+ assert_equal 2, @go.b
+ assert_equal 2, @go[:b]
+ assert_nil @go.c
+ assert_nil @go[:c]
+ end
+
+ def test_generate_json
+ switch_json_creatable do
+ assert_equal @go, JSON(JSON(@go), :create_additions => true)
+ end
+ end
+
+ def test_parse_json
+ assert_kind_of Hash, JSON('{ "json_class": "JSON::GenericObject", "a": 1, "b": 2 }', :create_additions => true)
+ switch_json_creatable do
+ assert_equal @go, l = JSON('{ "json_class": "JSON::GenericObject", "a": 1, "b": 2 }', :create_additions => true)
+ assert_equal 1, l.a
+ assert_equal @go, l = JSON('{ "a": 1, "b": 2 }', :object_class => GenericObject)
+ assert_equal 1, l.a
+ assert_equal GenericObject[:a => GenericObject[:b => 2]],
+ l = JSON('{ "a": { "b": 2 } }', :object_class => GenericObject)
+ assert_equal 2, l.a.b
+ end
+ end
+
+ def test_from_hash
+ result = GenericObject.from_hash(
+ :foo => { :bar => { :baz => true }, :quux => [ { :foobar => true } ] })
+ assert_kind_of GenericObject, result.foo
+ assert_kind_of GenericObject, result.foo.bar
+ assert_equal true, result.foo.bar.baz
+ assert_kind_of GenericObject, result.foo.quux.first
+ assert_equal true, result.foo.quux.first.foobar
+ assert_equal true, GenericObject.from_hash(true)
+ end
+
+ def test_json_generic_object_load
+ empty = JSON::GenericObject.load(nil)
+ assert_kind_of JSON::GenericObject, empty
+ simple_json = '{"json_class":"JSON::GenericObject","hello":"world"}'
+ simple = JSON::GenericObject.load(simple_json)
+ assert_kind_of JSON::GenericObject, simple
+ assert_equal "world", simple.hello
+ converting = JSON::GenericObject.load('{ "hello": "world" }')
+ assert_kind_of JSON::GenericObject, converting
+ assert_equal "world", converting.hello
+
+ json = JSON::GenericObject.dump(JSON::GenericObject[:hello => 'world'])
+ assert_equal JSON(json), JSON('{"json_class":"JSON::GenericObject","hello":"world"}')
+ end
+
+ private
+
+ def switch_json_creatable
+ JSON::GenericObject.json_creatable = true
+ yield
+ ensure
+ JSON::GenericObject.json_creatable = false
+ end
+end
View
0  ...son-1.7.7-java/tests/test_json_string_matching.rb → ...son-1.8.0-java/tests/test_json_string_matching.rb
File renamed without changes
View
0  .../jruby/json-1.7.7-java/tests/test_json_unicode.rb → ...common/json-1.8.0-java/tests/test_json_unicode.rb
File renamed without changes
View
4 lib/ruby/common/ruby-less-js/.gitignore
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
View
5 lib/ruby/common/ruby-less-js/Gemfile
@@ -0,0 +1,5 @@
+source "http://rubygems.org"
+
+gem 'rake'
+# Specify your gem's dependencies in ruby-less-js.gemspec
+gemspec
View
34 lib/ruby/common/ruby-less-js/README.md
@@ -0,0 +1,34 @@
+Ruby LessJs
+=================
+
+Ruby LessJs is a bridge to the official Javascript-based Less.js compiler.
+
+ LessJs.compile File.read("css.less")
+
+
+Installation
+------------
+
+ gem install less-js
+
+
+Dependencies
+------------
+
+This library depends on the `less-js-source` gem which will be
+updated any time a new version of Less.js is released. (The
+`less-js-source` gem's version number is synced with each
+official Less.js release.) This way you can build against
+different versions of Less.js by requiring the correct version of
+the `less-js-source` gem.
+
+*Note: version 1.1.1 of Less.js is tagged as 1.1.1.1 on the `less-js-source` gem.*
+
+### ExecJS
+
+The [ExecJS](https://github.com/sstephenson/execjs) library is used to automatically choose the best JavaScript engine for your platform. Check out its [README](https://github.com/sstephenson/execjs/blob/master/README.md) for a complete list of supported engines.
+
+Lifted From
+-----------
+
+The template for this gem was lifted from [Joshua Peek's](https://github.com/josh) [ruby-coffee-script](https://github.com/josh/ruby-coffee-script) gem.
View
11 lib/ruby/common/ruby-less-js/Rakefile
@@ -0,0 +1,11 @@
+require 'bundler'
+require 'rake/testtask'
+
+Bundler::GemHelper.install_tasks
+
+task :default => :test
+
+Rake::TestTask.new do |t|
+ t.warning = true
+end
+
View
1  lib/ruby/common/ruby-less-js/lib/less-js.rb
@@ -0,0 +1 @@
+require 'less_js'
View
9 lib/ruby/common/ruby-less-js/lib/less.js/.gitattributes
@@ -0,0 +1,9 @@
+*.js text eol=lf
+lessc text eol=lf
+*.less text eol=lf
+*.css text eol=lf
+*.htm text eol=lf
+
+*.jpg binary
+*.png binary
+*.jpeg binary
View
0  ...extensions/compass-h5bp/test/project/css/.gitkeep → lib/ruby/common/ruby-less-js/lib/less.js/.npmignore
File renamed without changes
View
177 lib/ruby/common/ruby-less-js/lib/less.js/CHANGELOG.md
@@ -0,0 +1,177 @@
+# 1.4.1
+
+2013-07-05
+
+ - fix syncImports and yui-compress option, as they were being ignored
+ - fixed several global variable leaks
+ - handle getting null or undefined passed as the options object
+
+# 1.4.0
+
+2013-06-05
+
+ - fix passing of strict maths option
+
+# 1.4.0 Beta 4
+
+2013-05-04
+
+ - change strictMaths to strictMath. Enable this with --strict-math=on in lessc and strictMath:true in JavaScript.
+ - change lessc option for strict units to --strict-units=off
+
+# 1.4.0 Beta 3
+
+2013-04-30
+
+ - strictUnits now defaults to false and the true case now gives more useful but less correct results, e.g. 2px/1px = 2px
+ - Process ./ when having relative paths
+ - add isunit function for mixin guards and non basic units
+ - extends recognise attributes
+ - exception errors extend the JavaScript Error
+ - remove es-5-shim as standard from the browser
+ - Fix path issues with windows/linux local paths
+
+# 1.4.0 Beta 1 & 2
+
+2013-03-07
+
+ - support for `:extend()` in selectors (e.g. `input:extend(.button) {}`) and `&:extend();` in ruleset (e.g. `input { &:extend(.button all); }`)
+ - maths is now only done inside brackets. This means font: statements, media queries and the calc function can use a simpler format without being escaped. Disable this with --strict-maths-off in lessc and strictMaths:false in JavaScript.
+ - units are calculated, e.g. 200cm+1m = 3m, 3px/1px = 3. If you use units inconsistently you will get an error. Suppress this error with --strict-units-off in lessc or strictUnits:false in JavaScript
+ - `(~"@var")` selector interpolation is removed. Use @{var} in selectors to have variable selectors
+ - default behaviour of import is to import each file once. `@import-once` has been removed.
+ - You can specify options on imports to force it to behave as css or less `@import (less) "file.css"` will process the file as less
+ - variables in mixins no longer 'leak' into their calling scope
+ - added data-uri function which will inline an image into the output css. If ieCompat option is true and file is too large, it will fallback to a url()
+ - significant bug fixes to our debug options
+ - other parameters can be used as defaults in mixins e.g. .a(@a, @b:@a)
+ - an error is shown if properties are used outside of a ruleset
+ - added extract function which picks a value out of a list, e.g. extract(12 13 14, 3) => 3
+ - added luma, hsvhue, hsvsaturation, hsvvalue functions
+ - added pow, pi, mod, tan, sin, cos, atan, asin, acos and sqrt math functions
+ - added convert function, e.g. convert(1rad, deg) => value in degrees
+ - lessc makes output directories if they don't exist
+ - lessc `@import` supports https and 301's
+ - lessc "-depends" option for lessc writes out the list of import files used in makefile format
+ - lessc "-lint" option just reports errors
+ - support for namespaces in attributes and selector interpolation in attributes
+ - other bug fixes
+
+# 1.3.3
+
+2012-12-30
+
+ - Fix critical bug with mixin call if using multiple brackets
+ - when using the filter contrast function, the function is passed through if the first argument is not a color
+
+# 1.3.2
+
+2012-12-28
+
+ - browser and server url re-writing is now aligned to not re-write (previous lessc behaviour)
+ - url-rewriting can be made to re-write to be relative to the entry file using the relative-urls option (less.relativeUrls option)
+ - rootpath option can be used to add a base path to every url
+ - Support mixin argument seperator of ';' so you can pass comma seperated values. e.g. `.mixin(23px, 12px;);`
+ - Fix lots of problems with named arguments in corner cases, not behaving as expected
+ - hsv, hsva, unit functions
+ - fixed lots more bad error messages
+ - fix `@import-once` to use the full path, not the relative one for determining if an import has been imported already
+ - support `:not(:nth-child(3))`
+ - mixin guards take units into account
+ - support unicode descriptors (`U+00A1-00A9`)
+ - support calling mixins with a stack when using `&` (broken in 1.3.1)
+ - support `@namespace` and namespace combinators
+ - when using % with colour functions, take into account a colour is out of 256
+ - when doing maths with a % do not divide by 100 and keep the unit
+ - allow url to contain % (e.g. %20 for a space)
+ - if a mixin guard stops execution a default mixin is not required
+ - units are output in strings (use the unit function if you need to get the value without unit)
+ - do not infinite recurse when mixins call mixins of the same name
+ - fix issue on important on mixin calls
+ - fix issue with multiple comments being confused
+ - tolerate multiple semi-colons on rules
+ - ignore subsequant `@charset`
+ - syncImport option for node.js to read files syncronously
+ - write the output directory if it is missing
+ - change dependency on cssmin to ycssmin
+ - lessc can load files over http
+ - allow calling less.watch() in non dev mode
+ - don't cache in dev mode
+ - less files cope with query parameters better
+ - sass debug statements are now chrome compatible
+ - modifyVars function added to re-render with different root variables
+
+# 1.3.1
+
+2012-10-18
+
+- Support for comment and @media debugging statements
+- bug fix for async access in chrome extensions
+- new functions tint, shade, multiply, screen, overlay, hardlight, difference, exclusion, average, negation, softlight, red, green, blue, contrast
+- allow escaped characters in attributes
+- in selectors support @{a} directly, e.g. .a.@{a} { color: black; }
+- add fraction parameter to round function
+- much better support for & selector
+- preserve order of link statements client side
+- lessc has better help
+- rhino version fixed
+- fix bugs in clientside error handling
+- support dpi, vmin, vm, dppx, dpcm units
+- Fix ratios in media statements
+- in mixin guards allow comparing colors and strings
+- support for -*-keyframes (for -khtml but now supports any)
+- in mix function, default weight to 50%
+- support @import-once
+- remove duplicate rules in output
+- implement named parameters when calling mixins
+- many numerous bug fixes
+
+# 1.3.0
+
+2012-03-10
+
+- @media bubbling
+- Support arbitrary entities as selectors
+- [Variadic argument support](https://gist.github.com/1933613)
+- Behaviour of zero-arity mixins has [changed](https://gist.github.com/1933613)
+- Allow `@import` directives in any selector
+- Media-query features can now be a variable
+- Automatic merging of media-query conditions
+- Fix global variable leaks
+- Fix error message on wrong-arity call
+- Fix an `@arguments` behaviour bug
+- Fix `::` selector output
+- Fix a bug when using @media with mixins
+
+
+# 1.2.1
+
+2012-01-15
+
+- Fix imports in browser
+- Improve error reporting in browser
+- Fix Runtime error reports from imported files
+- Fix `File not found` import error reporting
+
+
+# 1.2.0
+
+2012-01-07
+
+- Mixin guards
+- New function `percentage`
+- New `color` function to parse hex color strings
+- New type-checking stylesheet functions
+- Fix Rhino support
+- Fix bug in string arguments to mixin call
+- Fix error reporting when index is 0
+- Fix browser support in WebKit and IE
+- Fix string interpolation bug when var is empty
+- Support `!important` after mixin calls
+- Support vanilla @keyframes directive
+- Support variables in certain css selectors, like `nth-child`
+- Support @media and @import features properly
+- Improve @import support with media features
+- Improve error reports from imported files
+- Improve function call error reporting
+- Improve error-reporting
View
49 lib/ruby/common/ruby-less-js/lib/less.js/CONTRIBUTING.md
@@ -0,0 +1,49 @@
+# Contributing to Less.js
+
+> We welcome feature requests and bug reports. Please read these guidelines before submitting one.
+
+
+<span class="warning">**Words that begin with the at sign (`@`) must be wrapped in backticks!** </span>. as a courtesy to avoid sending notifications to any user that might have the `@username` being referenced. Remember, usernames start with the at sign.
+
+GitHub has other great markdown features as well, [go here to learn more about them](https://help.github.com/articles/github-flavored-markdown).
+
+
+## Reporting Issues
+
+We only accept issues that are bug reports or feature requests. Bugs must be isolated and reproducible problems that we can fix within the Less.js core. Please read the following guidelines before opening any issue.
+
+1. **Search for existing issues.** We get a lot of duplicate issues, and you'd help us out a lot by first checking if someone else has reported the same issue. Moreover, the issue may have already been resolved with a fix available.
+2. **Create an isolated and reproducible test case.** Be sure the problem exists in Less.js's code with [reduced test cases](http://css-tricks.com/reduced-test-cases/) that should be included in each bug report.
+3. **Test with the latest version**. We get a lot of issues that could be resolved by updating your version of Less.js.
+3. **Include a live example.** Please use [less2css.org](http://less2css.org/) for sharing your isolated test cases.
+4. **Share as much information as possible.** Include operating system and version. Describe how you use Less. If you use it in the browser, please include browser and version, and the version of Less.js you're using. Let us know if you're using the command line (`lessc`) or an external tool. And try to include steps to reproduce the bug.
+
+
+## Feature Requests
+
+* Please search for existing feature requests first to see if something similar already exists.
+* Include a clear and specific use-case. We love new ideas, but we do not add language features without a reason.
+* Consider whether or not your language feature would be better as a function or implemented in a 3rd-party build system such as [assemble-less](http://github.com/assemble/assemble-less).
+
+
+## Pull Requests
+
+_Pull requests are encouraged!_
+
+* Start by adding a feature request to get feedback and see how your idea is received.
+* If your pull request solves an existing issue, but it's different in some way, _please create a new issue_ and make sure to discuss it with the core contributors. Otherwise you risk your hard work being rejected.
+* Do not change the **./dist/** folder, we do this when releasing
+* _Please add tests_ for your work. Use `make test` to see if they pass node.js tests and `make browser-test` to see the browser ([PhantomJS](http://phantomjs.org/)) tests pass.
+
+
+### Coding Standards
+
+* Always use spaces, never tabs