engineyard-serverside 2.8.0.pre4 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/features/hook/running-a-deploy-hook.feature +277 -0
- data/features/hook/step_definitions/running-a-deploy-hook-steps.rb +200 -0
- data/features/step_definitions/command_steps.rb +8 -0
- data/features/step_definitions/version_steps.rb +5 -0
- data/features/support/env.rb +63 -0
- data/features/support/error_codes.rb +17 -0
- data/features/support/fs_helpers.rb +82 -0
- data/features/support/output_helpers.rb +7 -0
- data/features/support/runner.rb +41 -0
- data/features/version.feature +7 -0
- data/lib/engineyard-serverside/cli/app.rb +6 -0
- data/lib/engineyard-serverside/configuration.rb +3 -3
- data/lib/engineyard-serverside/deploy.rb +2 -1
- data/lib/engineyard-serverside/propagator.rb +1 -1
- data/lib/engineyard-serverside/shell.rb +38 -10
- data/lib/engineyard-serverside/version.rb +1 -1
- data/lib/engineyard-serverside.rb +2 -5
- data/spec/engineyard-serverside/callbacks/collection/combined_spec.rb +232 -0
- data/spec/engineyard-serverside/callbacks/collection/deploy_hooks_spec.rb +170 -0
- data/spec/engineyard-serverside/callbacks/collection/service_hooks/collection_spec.rb +171 -0
- data/spec/engineyard-serverside/callbacks/collection/service_hooks/combined_spec.rb +174 -0
- data/spec/engineyard-serverside/callbacks/collection/service_hooks_spec.rb +31 -0
- data/spec/engineyard-serverside/callbacks/collection_spec.rb +49 -0
- data/spec/engineyard-serverside/callbacks/distributor/remote_spec.rb +135 -0
- data/spec/engineyard-serverside/callbacks/distributor/viability_filter_spec.rb +208 -0
- data/spec/engineyard-serverside/callbacks/distributor_spec.rb +43 -0
- data/spec/engineyard-serverside/callbacks/executor/executable_spec.rb +386 -0
- data/spec/engineyard-serverside/callbacks/executor/ruby/context_spec.rb +538 -0
- data/spec/engineyard-serverside/callbacks/executor/ruby/executor_spec.rb +313 -0
- data/spec/engineyard-serverside/callbacks/executor/ruby_spec.rb +35 -0
- data/spec/engineyard-serverside/callbacks/executor_spec.rb +45 -0
- data/spec/engineyard-serverside/callbacks_spec.rb +31 -0
- data/spec/engineyard-serverside/cli/workflows/base_spec.rb +237 -0
- data/spec/engineyard-serverside/cli/workflows/calling_deploy_hooks_spec.rb +65 -0
- data/spec/engineyard-serverside/cli/workflows/deploying_applications_spec.rb +61 -0
- data/spec/engineyard-serverside/cli/workflows/disabling_maintenance_spec.rb +61 -0
- data/spec/engineyard-serverside/cli/workflows/enabling_maintenance_spec.rb +61 -0
- data/spec/engineyard-serverside/cli/workflows/helpers_spec.rb +64 -0
- data/spec/engineyard-serverside/cli/workflows/rolling_back_applications_spec.rb +61 -0
- data/spec/engineyard-serverside/cli/workflows/showing_maintenance_status_spec.rb +60 -0
- data/spec/engineyard-serverside/cli/workflows_spec.rb +87 -0
- data/spec/engineyard-serverside/dependency_manager/base_spec.rb +139 -0
- data/spec/engineyard-serverside/paths_spec.rb +820 -0
- data/spec/engineyard-serverside/propagator_spec.rb +56 -0
- data/spec/engineyard-serverside/server_spec.rb +390 -0
- data/spec/engineyard-serverside/shell/helpers_spec.rb +98 -0
- data/spec/engineyard-serverside/shell/yieldio_spec.rb +33 -0
- data/spec/engineyard-serverside/shell_spec.rb +543 -0
- data/spec/engineyard-serverside/slug/distributor_spec.rb +199 -0
- data/spec/engineyard-serverside/slug/enabler_spec.rb +191 -0
- data/spec/engineyard-serverside/slug/failure_handler_spec.rb +114 -0
- data/spec/engineyard-serverside/slug/finalizer_spec.rb +191 -0
- data/spec/engineyard-serverside/slug/generator_spec.rb +82 -0
- data/spec/engineyard-serverside/slug/migrator_spec.rb +137 -0
- data/spec/engineyard-serverside/slug/restarter_spec.rb +226 -0
- data/spec/engineyard-serverside/slug/source/updater_spec.rb +710 -0
- data/spec/engineyard-serverside/slug/source_spec.rb +40 -0
- data/spec/engineyard-serverside/source_spec.rb +171 -0
- data/spec/railway_spec.rb +130 -0
- data/spec/result/failure_spec.rb +113 -0
- data/spec/result/success_spec.rb +109 -0
- data/spec/result_spec.rb +23 -0
- data/spec/spec_helper.rb +3 -349
- metadata +189 -490
- data/lib/vendor/json_pure/COPYING +0 -57
- data/lib/vendor/json_pure/GPL +0 -340
- data/lib/vendor/json_pure/README.rdoc +0 -358
- data/lib/vendor/json_pure/VERSION +0 -1
- data/lib/vendor/json_pure/lib/json/add/bigdecimal.rb +0 -28
- data/lib/vendor/json_pure/lib/json/add/complex.rb +0 -22
- data/lib/vendor/json_pure/lib/json/add/core.rb +0 -11
- data/lib/vendor/json_pure/lib/json/add/date.rb +0 -34
- data/lib/vendor/json_pure/lib/json/add/date_time.rb +0 -48
- data/lib/vendor/json_pure/lib/json/add/exception.rb +0 -31
- data/lib/vendor/json_pure/lib/json/add/ostruct.rb +0 -31
- data/lib/vendor/json_pure/lib/json/add/range.rb +0 -29
- data/lib/vendor/json_pure/lib/json/add/rational.rb +0 -22
- data/lib/vendor/json_pure/lib/json/add/regexp.rb +0 -30
- data/lib/vendor/json_pure/lib/json/add/struct.rb +0 -30
- data/lib/vendor/json_pure/lib/json/add/symbol.rb +0 -25
- data/lib/vendor/json_pure/lib/json/add/time.rb +0 -38
- data/lib/vendor/json_pure/lib/json/common.rb +0 -484
- data/lib/vendor/json_pure/lib/json/ext.rb +0 -21
- data/lib/vendor/json_pure/lib/json/generic_object.rb +0 -70
- data/lib/vendor/json_pure/lib/json/pure/generator.rb +0 -522
- data/lib/vendor/json_pure/lib/json/pure/parser.rb +0 -359
- data/lib/vendor/json_pure/lib/json/pure.rb +0 -21
- data/lib/vendor/json_pure/lib/json/version.rb +0 -8
- data/lib/vendor/json_pure/lib/json.rb +0 -62
- data/lib/vendor/multi_json/CHANGELOG.md +0 -121
- data/lib/vendor/multi_json/CONTRIBUTING.md +0 -46
- data/lib/vendor/multi_json/Gemfile +0 -31
- data/lib/vendor/multi_json/LICENSE.md +0 -20
- data/lib/vendor/multi_json/README.md +0 -105
- data/lib/vendor/multi_json/Rakefile +0 -12
- data/lib/vendor/multi_json/lib/multi_json/adapters/gson.rb +0 -20
- data/lib/vendor/multi_json/lib/multi_json/adapters/json_common.rb +0 -35
- data/lib/vendor/multi_json/lib/multi_json/adapters/json_gem.rb +0 -12
- data/lib/vendor/multi_json/lib/multi_json/adapters/json_pure.rb +0 -12
- data/lib/vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb +0 -35
- data/lib/vendor/multi_json/lib/multi_json/adapters/oj.rb +0 -29
- data/lib/vendor/multi_json/lib/multi_json/adapters/ok_json.rb +0 -58
- data/lib/vendor/multi_json/lib/multi_json/adapters/yajl.rb +0 -20
- data/lib/vendor/multi_json/lib/multi_json/vendor/okjson.rb +0 -602
- data/lib/vendor/multi_json/lib/multi_json/version.rb +0 -3
- data/lib/vendor/multi_json/lib/multi_json.rb +0 -137
- data/lib/vendor/multi_json/spec/adapter_shared_example.rb +0 -162
- data/lib/vendor/multi_json/spec/helper.rb +0 -45
- data/lib/vendor/multi_json/spec/json_common_shared_example.rb +0 -36
- data/lib/vendor/multi_json/spec/multi_json_spec.rb +0 -151
- data/spec/archive_deploy_spec.rb +0 -53
- data/spec/basic_deploy_spec.rb +0 -26
- data/spec/bundler_deploy_spec.rb +0 -160
- data/spec/configuration_spec.rb +0 -206
- data/spec/custom_deploy_spec.rb +0 -128
- data/spec/deploy_hook_spec.rb +0 -378
- data/spec/deprecation_spec.rb +0 -23
- data/spec/ey_yml_customized_deploy_spec.rb +0 -99
- data/spec/fixtures/gitrepo.tar.gz +0 -0
- data/spec/fixtures/invalid_hook.rb +0 -1
- data/spec/fixtures/lockfiles/0.9-no-bundler +0 -111
- data/spec/fixtures/lockfiles/0.9-with-bundler +0 -117
- data/spec/fixtures/lockfiles/1.0-no-bundler +0 -54
- data/spec/fixtures/lockfiles/1.0.0.rc.1-with-bundler +0 -162
- data/spec/fixtures/lockfiles/1.0.18-do_mysql +0 -88
- data/spec/fixtures/lockfiles/1.0.18-do_postgres +0 -79
- data/spec/fixtures/lockfiles/1.0.18-mysql +0 -43
- data/spec/fixtures/lockfiles/1.0.18-mysql2 +0 -43
- data/spec/fixtures/lockfiles/1.0.18-pg +0 -43
- data/spec/fixtures/lockfiles/1.0.6-no-bundler +0 -51
- data/spec/fixtures/lockfiles/1.0.6-with-any-bundler +0 -52
- data/spec/fixtures/lockfiles/1.0.6-with-bundler +0 -52
- data/spec/fixtures/lockfiles/1.15.1-no-bundler +0 -51
- data/spec/fixtures/lockfiles/1.3.1-rails-3.2.13 +0 -112
- data/spec/fixtures/lockfiles/not-a-lockfile +0 -1
- data/spec/fixtures/repos/assets_detected/Gemfile +0 -5
- data/spec/fixtures/repos/assets_detected/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_detected/README +0 -1
- data/spec/fixtures/repos/assets_detected/Rakefile +0 -5
- data/spec/fixtures/repos/assets_detected/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_detected/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_detected/config/ey.yml +0 -3
- data/spec/fixtures/repos/assets_disabled/Gemfile +0 -5
- data/spec/fixtures/repos/assets_disabled/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_disabled/README +0 -1
- data/spec/fixtures/repos/assets_disabled/Rakefile +0 -6
- data/spec/fixtures/repos/assets_disabled/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_disabled/config/ey.yml +0 -3
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +0 -5
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +0 -1
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +0 -6
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +0 -5
- data/spec/fixtures/repos/assets_disabled_utf8/Gemfile +0 -5
- data/spec/fixtures/repos/assets_disabled_utf8/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_disabled_utf8/README +0 -3
- data/spec/fixtures/repos/assets_disabled_utf8/Rakefile +0 -5
- data/spec/fixtures/repos/assets_disabled_utf8/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled_utf8/config/application.rb +0 -7
- data/spec/fixtures/repos/assets_disabled_utf8/config/ey.yml +0 -3
- data/spec/fixtures/repos/assets_enabled_all/Gemfile +0 -5
- data/spec/fixtures/repos/assets_enabled_all/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_enabled_all/README +0 -1
- data/spec/fixtures/repos/assets_enabled_all/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_enabled_all/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_enabled_all/config/ey.yml +0 -6
- data/spec/fixtures/repos/assets_enabled_all/script/assets +0 -5
- data/spec/fixtures/repos/assets_enabled_all/tmp/obstruction +0 -1
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile +0 -3
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock +0 -10
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +0 -1
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +0 -8
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +0 -4
- data/spec/fixtures/repos/assets_enabled_util_only/Gemfile +0 -5
- data/spec/fixtures/repos/assets_enabled_util_only/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_enabled_util_only/README +0 -1
- data/spec/fixtures/repos/assets_enabled_util_only/Rakefile +0 -6
- data/spec/fixtures/repos/assets_enabled_util_only/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_enabled_util_only/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_enabled_util_only/config/ey.yml +0 -6
- data/spec/fixtures/repos/assets_error/Gemfile +0 -5
- data/spec/fixtures/repos/assets_error/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_error/README +0 -1
- data/spec/fixtures/repos/assets_error/Rakefile +0 -4
- data/spec/fixtures/repos/assets_error/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_error/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_error/config/ey.yml +0 -4
- data/spec/fixtures/repos/assets_in_hook/Gemfile +0 -5
- data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +0 -88
- data/spec/fixtures/repos/assets_in_hook/README +0 -2
- data/spec/fixtures/repos/assets_in_hook/Rakefile +0 -5
- data/spec/fixtures/repos/assets_in_hook/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_in_hook/config/application.rb +0 -5
- data/spec/fixtures/repos/assets_in_hook/config/ey.yml +0 -3
- data/spec/fixtures/repos/assets_in_hook/deploy/before_compile_assets.rb +0 -2
- data/spec/fixtures/repos/bundle_fails/Gemfile +0 -1
- data/spec/fixtures/repos/bundle_fails/README +0 -1
- data/spec/fixtures/repos/bundle_fails/deploy/after_bundle.rb +0 -1
- data/spec/fixtures/repos/bundler_disabled/Gemfile +0 -4
- data/spec/fixtures/repos/bundler_disabled/Gemfile.lock +0 -12
- data/spec/fixtures/repos/bundler_disabled/README +0 -1
- data/spec/fixtures/repos/bundler_disabled/config/ey.yml +0 -2
- data/spec/fixtures/repos/bundler_disabled/deploy/after_bundle.rb +0 -1
- data/spec/fixtures/repos/bundler_disabled/deploy/before_bundle.rb +0 -1
- data/spec/fixtures/repos/bundler_old/Gemfile +0 -5
- data/spec/fixtures/repos/bundler_old/Gemfile.lock +0 -15
- data/spec/fixtures/repos/bundler_old/README +0 -1
- data/spec/fixtures/repos/default/Gemfile +0 -4
- data/spec/fixtures/repos/default/Gemfile.lock +0 -12
- data/spec/fixtures/repos/default/README +0 -5
- data/spec/fixtures/repos/default/ey.yml +0 -3
- data/spec/fixtures/repos/executable_hooks/README +0 -1
- data/spec/fixtures/repos/executable_hooks/deploy/before_restart +0 -72
- data/spec/fixtures/repos/executable_hooks_not_executable/README +0 -3
- data/spec/fixtures/repos/executable_hooks_not_executable/deploy/before_restart +0 -3
- data/spec/fixtures/repos/ey_yml/Gemfile +0 -4
- data/spec/fixtures/repos/ey_yml/Gemfile.lock +0 -12
- data/spec/fixtures/repos/ey_yml/README +0 -1
- data/spec/fixtures/repos/ey_yml/config/ey.yml +0 -18
- data/spec/fixtures/repos/ey_yml/deploy/before_migrate.rb +0 -6
- data/spec/fixtures/repos/ey_yml_alt/Gemfile +0 -4
- data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +0 -12
- data/spec/fixtures/repos/ey_yml_alt/README +0 -1
- data/spec/fixtures/repos/ey_yml_alt/deploy/before_migrate.rb +0 -6
- data/spec/fixtures/repos/ey_yml_alt/ey.yml +0 -12
- data/spec/fixtures/repos/hook_fails/README +0 -1
- data/spec/fixtures/repos/hook_fails/deploy/before_deploy.rb +0 -1
- data/spec/fixtures/repos/hooks/README +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_bundle.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_compile_assets.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_deploy.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_migrate.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_restart.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/after_symlink.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_bundle.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_compile_assets.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_deploy.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_migrate.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_restart.rb +0 -1
- data/spec/fixtures/repos/hooks/deploy/before_symlink.rb +0 -1
- data/spec/fixtures/repos/multi_dep_manager/README +0 -1
- data/spec/fixtures/repos/multi_dep_manager/composer.json +0 -5
- data/spec/fixtures/repos/multi_dep_manager/composer.lock +0 -462
- data/spec/fixtures/repos/multi_dep_manager/package.json +0 -7
- data/spec/fixtures/repos/multi_dep_manager/public/index.php +0 -4
- data/spec/fixtures/repos/no_ey_config/Gemfile +0 -3
- data/spec/fixtures/repos/no_ey_config/Gemfile.lock +0 -10
- data/spec/fixtures/repos/no_ey_config/README +0 -1
- data/spec/fixtures/repos/no_ey_config/ey.yml +0 -3
- data/spec/fixtures/repos/no_ey_config_no_warning/Gemfile +0 -3
- data/spec/fixtures/repos/no_ey_config_no_warning/Gemfile.lock +0 -10
- data/spec/fixtures/repos/no_ey_config_no_warning/README +0 -1
- data/spec/fixtures/repos/no_ey_config_no_warning/ey.yml +0 -5
- data/spec/fixtures/repos/no_gemfile_lock/Gemfile +0 -4
- data/spec/fixtures/repos/no_gemfile_lock/README +0 -1
- data/spec/fixtures/repos/no_gemfile_lock/ey.yml +0 -3
- data/spec/fixtures/repos/nodejs/README +0 -1
- data/spec/fixtures/repos/nodejs/package.json +0 -7
- data/spec/fixtures/repos/not_bundled/README +0 -1
- data/spec/fixtures/repos/npm_disabled/README +0 -1
- data/spec/fixtures/repos/npm_disabled/config/ey.yml +0 -2
- data/spec/fixtures/repos/npm_disabled/package.json +0 -7
- data/spec/fixtures/repos/php_composer_disabled/README +0 -1
- data/spec/fixtures/repos/php_composer_disabled/composer.json +0 -5
- data/spec/fixtures/repos/php_composer_disabled/composer.lock +0 -462
- data/spec/fixtures/repos/php_composer_disabled/config/ey.yml +0 -2
- data/spec/fixtures/repos/php_composer_disabled/public/index.php +0 -4
- data/spec/fixtures/repos/php_composer_lock/README +0 -1
- data/spec/fixtures/repos/php_composer_lock/composer.json +0 -5
- data/spec/fixtures/repos/php_composer_lock/composer.lock +0 -462
- data/spec/fixtures/repos/php_composer_lock/public/index.php +0 -4
- data/spec/fixtures/repos/php_no_composer_lock/README +0 -1
- data/spec/fixtures/repos/php_no_composer_lock/composer.json +0 -21
- data/spec/fixtures/repos/php_no_composer_lock/public/index.php +0 -4
- data/spec/fixtures/repos/public_system/Gemfile +0 -4
- data/spec/fixtures/repos/public_system/Gemfile.lock +0 -12
- data/spec/fixtures/repos/public_system/README +0 -5
- data/spec/fixtures/repos/public_system/ey.yml +0 -3
- data/spec/fixtures/repos/public_system/public/system/cant_touch_this.txt +0 -3
- data/spec/fixtures/repos/sqlite3/Gemfile +0 -4
- data/spec/fixtures/repos/sqlite3/Gemfile.lock +0 -89
- data/spec/fixtures/repos/sqlite3/README +0 -1
- data/spec/fixtures/retwisj.war +0 -0
- data/spec/fixtures/valid_hook.rb +0 -1
- data/spec/git_strategy_spec.rb +0 -34
- data/spec/lockfile_parser_spec.rb +0 -126
- data/spec/maintenance_spec.rb +0 -44
- data/spec/multi_dependency_manager_spec.rb +0 -25
- data/spec/nodejs_deploy_spec.rb +0 -30
- data/spec/php_deploy_spec.rb +0 -81
- data/spec/platform_configure_spec.rb +0 -61
- data/spec/rails31_deploy_spec.rb +0 -172
- data/spec/restart_spec.rb +0 -43
- data/spec/rollback_spec.rb +0 -87
- data/spec/server_spec.rb +0 -70
- data/spec/services_deploy_spec.rb +0 -165
- data/spec/shell_spec.rb +0 -57
- data/spec/source/archive_spec.rb +0 -33
- data/spec/source/git_spec.rb +0 -44
- data/spec/sqlite3_deploy_spec.rb +0 -38
- data/spec/support/integration.rb +0 -103
- data/spec/support/source_doubles.rb +0 -28
- data/spec/support/timecop.rb +0 -5
- data/spec/symlink_spec.rb +0 -15
@@ -1,105 +0,0 @@
|
|
1
|
-
# MultiJSON
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/multi_json.png)][gem]
|
3
|
-
[![Build Status](https://secure.travis-ci.org/intridea/multi_json.png?branch=master)][travis]
|
4
|
-
[![Dependency Status](https://gemnasium.com/intridea/multi_json.png?travis)][gemnasium]
|
5
|
-
[![Code Climate](https://codeclimate.com/github/intridea/multi_json.png)][codeclimate]
|
6
|
-
|
7
|
-
[gem]: https://rubygems.org/gems/multi_json
|
8
|
-
[travis]: http://travis-ci.org/intridea/multi_json
|
9
|
-
[gemnasium]: https://gemnasium.com/intridea/multi_json
|
10
|
-
[codeclimate]: https://codeclimate.com/github/intridea/multi_json
|
11
|
-
|
12
|
-
Lots of Ruby libraries parse JSON and everyone has their favorite JSON coder.
|
13
|
-
Instead of choosing a single JSON coder and forcing users of your library to be
|
14
|
-
stuck with it, you can use MultiJSON instead, which will simply choose the
|
15
|
-
fastest available JSON coder. Here's how to use it:
|
16
|
-
|
17
|
-
```ruby
|
18
|
-
require 'multi_json'
|
19
|
-
|
20
|
-
MultiJson.load('{"abc":"def"}') #=> {"abc" => "def"}
|
21
|
-
MultiJson.load('{"abc":"def"}', :symbolize_keys => true) #=> {:abc => "def"}
|
22
|
-
MultiJson.dump({:abc => 'def'}) # convert Ruby back to JSON
|
23
|
-
MultiJson.dump({:abc => 'def'}, :pretty => true) # encoded in a pretty form (if supported by the coder)
|
24
|
-
```
|
25
|
-
|
26
|
-
When loading invalid JSON, multiJSON will throw a `MultiJson::LoadError`. `MultiJson::DecodeError` is an alias for backwards compatibility.
|
27
|
-
|
28
|
-
```ruby
|
29
|
-
MultiJson.load('invalid json') #=> MultiJson::LoadError
|
30
|
-
```
|
31
|
-
|
32
|
-
The `use` method, which sets the MultiJson adapter, takes either a symbol or a
|
33
|
-
class (to allow for custom JSON parsers) that responds to both `.load` and `.dump`
|
34
|
-
at the class level.
|
35
|
-
|
36
|
-
MultiJSON tries to have intelligent defaulting. That is, if you have any of the
|
37
|
-
supported engines already loaded, it will utilize them before attempting to
|
38
|
-
load any. When loading, libraries are ordered by speed. First Oj, then Yajl,
|
39
|
-
then the JSON gem, then JSON pure. If no other JSON library is available,
|
40
|
-
MultiJSON falls back to [OkJson][], a simple, vendorable JSON parser.
|
41
|
-
|
42
|
-
[okjson]: https://github.com/kr/okjson
|
43
|
-
|
44
|
-
## Supported JSON Engines
|
45
|
-
|
46
|
-
* [Oj](https://github.com/ohler55/oj) Optimized JSON by Peter Ohler
|
47
|
-
* [Yajl](https://github.com/brianmario/yajl-ruby) Yet Another JSON Library by Brian Lopez
|
48
|
-
* [JSON](https://github.com/flori/json) The default JSON gem with C-extensions (ships with Ruby 1.9)
|
49
|
-
* [JSON Pure](https://github.com/flori/json) A Ruby variant of the JSON gem
|
50
|
-
* [NSJSONSerialization](https://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html) Wrapper for Apple's NSJSONSerialization in the Cocoa Framework (MacRuby only)
|
51
|
-
* [gson.rb](https://github.com/avsej/gson.rb) A Ruby wrapper for google-gson library (JRuby only)
|
52
|
-
* [OkJson][okjson] A simple, vendorable JSON parser
|
53
|
-
|
54
|
-
## Supported Ruby Versions
|
55
|
-
This library aims to support and is [tested against][travis] the following Ruby
|
56
|
-
implementations:
|
57
|
-
|
58
|
-
* Ruby 1.8.7
|
59
|
-
* Ruby 1.9.2
|
60
|
-
* Ruby 1.9.3
|
61
|
-
* Ruby 2.0.0
|
62
|
-
* [JRuby][]
|
63
|
-
* [Rubinius][]
|
64
|
-
* [MacRuby][] (not tested on Travis CI)
|
65
|
-
|
66
|
-
[jruby]: http://www.jruby.org/
|
67
|
-
[rubinius]: http://rubini.us/
|
68
|
-
[macruby]: http://www.macruby.org/
|
69
|
-
|
70
|
-
If something doesn't work on one of these interpreters, it's a bug.
|
71
|
-
|
72
|
-
This library may inadvertently work (or seem to work) on other Ruby
|
73
|
-
implementations, however support will only be provided for the versions listed
|
74
|
-
above.
|
75
|
-
|
76
|
-
If you would like this library to support another Ruby version, you may
|
77
|
-
volunteer to be a maintainer. Being a maintainer entails making sure all tests
|
78
|
-
run and pass on that implementation. When something breaks on your
|
79
|
-
implementation, you will be responsible for providing patches in a timely
|
80
|
-
fashion. If critical issues for a particular implementation exist at the time
|
81
|
-
of a major release, support for that Ruby version may be dropped.
|
82
|
-
|
83
|
-
## Versioning
|
84
|
-
|
85
|
-
This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
|
86
|
-
of this scheme should be reported as bugs. Specifically, if a minor or patch
|
87
|
-
version is released that breaks backward compatibility, that version should be
|
88
|
-
immediately yanked and/or a new version should be immediately released that
|
89
|
-
restores compatibility. Breaking changes to the public API will only be
|
90
|
-
introduced with new major versions. As a result of this policy, you can (and
|
91
|
-
should) specify a dependency on this gem using the [Pessimistic Version
|
92
|
-
Constraint][pvc] with two digits of precision. For example:
|
93
|
-
|
94
|
-
```ruby
|
95
|
-
spec.add_dependency 'multi_json', '~> 1.0'
|
96
|
-
```
|
97
|
-
|
98
|
-
[semver]: http://semver.org/
|
99
|
-
[pvc]: http://docs.rubygems.org/read/chapter/16#page74
|
100
|
-
|
101
|
-
## Copyright
|
102
|
-
Copyright (c) 2010-2013 Michael Bleigh, Josh Kalderimis, Erik Michaels-Ober,
|
103
|
-
and Pavel Pravosud. See [LICENSE][] for details.
|
104
|
-
|
105
|
-
[license]: LICENSE.md
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'gson' unless defined?(::Gson)
|
2
|
-
|
3
|
-
module MultiJson
|
4
|
-
module Adapters
|
5
|
-
# Use the gson.rb library to dump/load.
|
6
|
-
module Gson
|
7
|
-
extend self
|
8
|
-
|
9
|
-
ParseError = ::Gson::DecodeError
|
10
|
-
|
11
|
-
def load(string, options={}) #:nodoc:
|
12
|
-
::Gson::Decoder.new(options).decode(string)
|
13
|
-
end
|
14
|
-
|
15
|
-
def dump(object, options={}) #:nodoc:
|
16
|
-
::Gson::Encoder.new(options).encode(object)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module MultiJson
|
2
|
-
module Adapters
|
3
|
-
module JsonCommon
|
4
|
-
def load(string, options={})
|
5
|
-
string = string.read if string.respond_to?(:read)
|
6
|
-
::JSON.parse("[#{string}]", process_load_options!(options)).first
|
7
|
-
end
|
8
|
-
|
9
|
-
def dump(object, options={})
|
10
|
-
object.to_json(process_dump_options!(options))
|
11
|
-
end
|
12
|
-
|
13
|
-
protected
|
14
|
-
|
15
|
-
def process_load_options!(options={})
|
16
|
-
process_options!({:create_additions => false}, options) do |opts|
|
17
|
-
opts.merge!(:symbolize_names => true) if options.delete(:symbolize_keys)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def process_dump_options!(options={})
|
22
|
-
process_options!({}, options) do |opts|
|
23
|
-
opts.merge!(::JSON::PRETTY_STATE_PROTOTYPE.to_h) if options.delete(:pretty)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def process_options!(default_options, options)
|
28
|
-
return default_options if options.empty?
|
29
|
-
yield default_options
|
30
|
-
default_options.merge!(options)
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
framework 'Foundation'
|
2
|
-
require 'multi_json/adapters/ok_json'
|
3
|
-
|
4
|
-
module MultiJson
|
5
|
-
module Adapters
|
6
|
-
module Nsjsonserialization
|
7
|
-
extend self, MultiJson::Adapters::OkJson
|
8
|
-
ParseError = ::MultiJson::OkJson::Error
|
9
|
-
|
10
|
-
def load(string, options={})
|
11
|
-
string = string.read if string.respond_to?(:read)
|
12
|
-
data = string.dataUsingEncoding(NSUTF8StringEncoding)
|
13
|
-
object = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves, error: nil)
|
14
|
-
if object
|
15
|
-
object = symbolize_keys(object) if options[:symbolize_keys]
|
16
|
-
object
|
17
|
-
else
|
18
|
-
super(string, options={})
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def dump(object, options={})
|
23
|
-
pretty = options[:pretty] ? NSJSONWritingPrettyPrinted : 0
|
24
|
-
object = object.as_json if object.respond_to?(:as_json)
|
25
|
-
if NSJSONSerialization.isValidJSONObject(object)
|
26
|
-
data = NSJSONSerialization.dataWithJSONObject(object, options: pretty, error: nil)
|
27
|
-
NSMutableString.alloc.initWithData(data, encoding: NSUTF8StringEncoding)
|
28
|
-
else
|
29
|
-
super(object, options)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'oj' unless defined?(::Oj)
|
2
|
-
|
3
|
-
module MultiJson
|
4
|
-
module Adapters
|
5
|
-
# Use the Oj library to dump/load.
|
6
|
-
module Oj
|
7
|
-
extend self
|
8
|
-
|
9
|
-
DEFAULT_OPTIONS = {:mode => :compat, :time_format => :ruby}.freeze
|
10
|
-
|
11
|
-
ParseError = if defined?(::Oj::ParseError)
|
12
|
-
::Oj::ParseError
|
13
|
-
else
|
14
|
-
SyntaxError
|
15
|
-
end
|
16
|
-
|
17
|
-
def load(string, options={}) #:nodoc:
|
18
|
-
options.merge!(:symbol_keys => options[:symbolize_keys])
|
19
|
-
options[:mode] = :strict
|
20
|
-
::Oj.load(string, DEFAULT_OPTIONS.merge(options))
|
21
|
-
end
|
22
|
-
|
23
|
-
def dump(object, options={}) #:nodoc:
|
24
|
-
options.merge!(:indent => 2) if options[:pretty]
|
25
|
-
::Oj.dump(object, DEFAULT_OPTIONS.merge(options))
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'multi_json/vendor/okjson'
|
2
|
-
|
3
|
-
module MultiJson
|
4
|
-
module Adapters
|
5
|
-
module OkJson
|
6
|
-
extend self
|
7
|
-
|
8
|
-
ParseError = ::MultiJson::OkJson::Error
|
9
|
-
|
10
|
-
def load(string, options={}) #:nodoc:
|
11
|
-
string = string.read if string.respond_to?(:read)
|
12
|
-
result = ::MultiJson::OkJson.decode("[#{string}]").first
|
13
|
-
options[:symbolize_keys] ? symbolize_keys(result) : result
|
14
|
-
end
|
15
|
-
|
16
|
-
def dump(object, options={}) #:nodoc:
|
17
|
-
::MultiJson::OkJson.valenc(stringify_keys(object))
|
18
|
-
end
|
19
|
-
|
20
|
-
def symbolize_keys(object) #:nodoc:
|
21
|
-
prepare_object(object) do |key|
|
22
|
-
key.is_a?(String) ? key.to_sym : key
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def stringify_keys(object) #:nodoc:
|
27
|
-
prepare_object(object) do |key|
|
28
|
-
key.respond_to?(:to_s) ? key.to_s : key
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def prepare_object(object, &key_modifier) #:nodoc:
|
33
|
-
case object
|
34
|
-
when Array
|
35
|
-
object.map do |value|
|
36
|
-
prepare_object(value, &key_modifier)
|
37
|
-
end
|
38
|
-
when Hash
|
39
|
-
object.inject({}) do |result, (key, value)|
|
40
|
-
new_key = key_modifier.call(key)
|
41
|
-
new_value = prepare_object(value, &key_modifier)
|
42
|
-
result.merge! new_key => new_value
|
43
|
-
end
|
44
|
-
when String, Numeric, true, false, nil
|
45
|
-
object
|
46
|
-
else
|
47
|
-
if object.respond_to?(:to_json)
|
48
|
-
object
|
49
|
-
elsif object.respond_to?(:to_s)
|
50
|
-
object.to_s
|
51
|
-
else
|
52
|
-
object
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'yajl' unless defined?(::Yajl)
|
2
|
-
|
3
|
-
module MultiJson
|
4
|
-
module Adapters
|
5
|
-
# Use the Yajl-Ruby library to dump/load.
|
6
|
-
module Yajl
|
7
|
-
extend self
|
8
|
-
|
9
|
-
ParseError = ::Yajl::ParseError
|
10
|
-
|
11
|
-
def load(string, options={}) #:nodoc:
|
12
|
-
::Yajl::Parser.new(:symbolize_keys => options[:symbolize_keys]).parse(string)
|
13
|
-
end
|
14
|
-
|
15
|
-
def dump(object, options={}) #:nodoc:
|
16
|
-
::Yajl::Encoder.encode(object, options)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|