backbone-deep-rails 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/lib/backbone/deep/rails/version.rb +1 -1
- metadata +18 -245
- data/vendor/bundle/cache/activemodel-3.2.11.gem +0 -0
- data/vendor/bundle/cache/activesupport-3.2.11.gem +0 -0
- data/vendor/bundle/gems/activesupport-3.2.11/CHANGELOG.md +0 -157
- data/vendor/bundle/gems/activesupport-3.2.11/MIT-LICENSE +0 -20
- data/vendor/bundle/gems/activesupport-3.2.11/README.rdoc +0 -33
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support.rb +0 -82
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/all.rb +0 -3
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/backtrace_cleaner.rb +0 -99
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/base64.rb +0 -54
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/basic_object.rb +0 -21
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/benchmarkable.rb +0 -55
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/buffered_logger.rb +0 -125
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/builder.rb +0 -6
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/cache.rb +0 -638
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/cache/file_store.rb +0 -178
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/cache/mem_cache_store.rb +0 -206
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/cache/memory_store.rb +0 -159
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/cache/null_store.rb +0 -44
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/cache/strategy/local_cache.rb +0 -169
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/callbacks.rb +0 -626
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/concern.rb +0 -131
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/configurable.rb +0 -90
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext.rb +0 -3
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/array.rb +0 -8
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/array/access.rb +0 -46
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/array/conversions.rb +0 -164
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/array/extract_options.rb +0 -29
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/array/grouping.rb +0 -100
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/array/prepend_and_append.rb +0 -7
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/array/random_access.rb +0 -30
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/array/uniq_by.rb +0 -16
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/array/wrap.rb +0 -48
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/benchmark.rb +0 -7
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/big_decimal.rb +0 -1
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/big_decimal/conversions.rb +0 -45
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/class.rb +0 -4
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/class/attribute.rb +0 -115
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/class/attribute_accessors.rb +0 -168
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/class/delegating_attributes.rb +0 -44
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/class/subclasses.rb +0 -36
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/date/acts_like.rb +0 -8
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/date/calculations.rb +0 -276
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/date/conversions.rb +0 -106
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/date/freeze.rb +0 -33
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/date/zones.rb +0 -14
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/date_time/acts_like.rb +0 -13
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/date_time/calculations.rb +0 -143
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/date_time/conversions.rb +0 -103
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/date_time/zones.rb +0 -21
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/enumerable.rb +0 -127
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/exception.rb +0 -3
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/file.rb +0 -2
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/file/atomic.rb +0 -42
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/file/path.rb +0 -5
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/float.rb +0 -1
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/float/rounding.rb +0 -19
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/hash.rb +0 -9
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/hash/conversions.rb +0 -175
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/hash/deep_dup.rb +0 -18
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/hash/deep_merge.rb +0 -21
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/hash/diff.rb +0 -13
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/hash/except.rb +0 -23
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/hash/indifferent_access.rb +0 -24
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/hash/keys.rb +0 -54
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/hash/reverse_merge.rb +0 -23
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/hash/slice.rb +0 -40
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/integer.rb +0 -3
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/integer/inflections.rb +0 -17
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/integer/multiple.rb +0 -10
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/integer/time.rb +0 -39
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/io.rb +0 -15
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/kernel.rb +0 -4
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/kernel/agnostics.rb +0 -11
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/kernel/debugger.rb +0 -10
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/kernel/reporting.rb +0 -93
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/kernel/singleton_class.rb +0 -13
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/load_error.rb +0 -23
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/logger.rb +0 -83
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/module.rb +0 -12
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/module/aliasing.rb +0 -70
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/module/anonymous.rb +0 -24
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/module/attr_internal.rb +0 -39
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/module/attribute_accessors.rb +0 -64
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/module/delegation.rb +0 -153
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/module/deprecation.rb +0 -9
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/module/introspection.rb +0 -88
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/module/method_names.rb +0 -14
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/module/qualified_const.rb +0 -64
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/module/reachable.rb +0 -8
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/module/remove_method.rb +0 -16
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/module/synchronization.rb +0 -45
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/name_error.rb +0 -18
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/numeric.rb +0 -2
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/numeric/bytes.rb +0 -44
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/numeric/time.rb +0 -79
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object.rb +0 -13
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/acts_like.rb +0 -10
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/blank.rb +0 -121
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/conversions.rb +0 -4
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/duplicable.rb +0 -119
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/inclusion.rb +0 -25
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/instance_variables.rb +0 -33
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/to_json.rb +0 -19
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/to_param.rb +0 -55
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/to_query.rb +0 -27
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/try.rb +0 -57
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/with_options.rb +0 -43
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/proc.rb +0 -14
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/process.rb +0 -1
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/process/daemon.rb +0 -23
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/range.rb +0 -5
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/range/blockless_step.rb +0 -29
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/range/conversions.rb +0 -21
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/range/cover.rb +0 -3
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/range/include_range.rb +0 -21
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/range/overlaps.rb +0 -8
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/regexp.rb +0 -5
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/rexml.rb +0 -46
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string.rb +0 -14
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/access.rb +0 -99
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/behavior.rb +0 -6
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/conversions.rb +0 -66
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/encoding.rb +0 -11
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/exclude.rb +0 -11
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/filters.rb +0 -49
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/inflections.rb +0 -202
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/inquiry.rb +0 -13
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/interpolation.rb +0 -2
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/multibyte.rb +0 -72
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/output_safety.rb +0 -186
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/starts_ends_with.rb +0 -4
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/strip.rb +0 -26
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/string/xchar.rb +0 -18
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/time/acts_like.rb +0 -8
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/time/calculations.rb +0 -360
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/time/conversions.rb +0 -85
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/time/marshal.rb +0 -57
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/time/publicize_conversion_methods.rb +0 -10
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/time/zones.rb +0 -86
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/uri.rb +0 -30
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/dependencies.rb +0 -703
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/dependencies/autoload.rb +0 -50
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/deprecation.rb +0 -18
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/deprecation/behaviors.rb +0 -49
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/deprecation/method_wrappers.rb +0 -29
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/deprecation/proxy_wrappers.rb +0 -81
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/deprecation/reporting.rb +0 -65
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/descendants_tracker.rb +0 -45
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/duration.rb +0 -110
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/file_update_checker.rb +0 -121
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/file_watcher.rb +0 -36
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/gzip.rb +0 -30
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/hash_with_indifferent_access.rb +0 -178
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/i18n.rb +0 -9
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/i18n_railtie.rb +0 -102
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/inflections.rb +0 -63
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/inflector.rb +0 -7
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/inflector/inflections.rb +0 -174
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb +0 -321
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/inflector/transliterate.rb +0 -98
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/json.rb +0 -2
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/json/decoding.rb +0 -79
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/json/encoding.rb +0 -284
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/json/variable.rb +0 -9
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb +0 -46
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/locale/en.yml +0 -36
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/log_subscriber.rb +0 -122
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/log_subscriber/test_helper.rb +0 -101
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/memoizable.rb +0 -116
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/message_encryptor.rb +0 -103
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/message_verifier.rb +0 -74
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/multibyte.rb +0 -44
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/multibyte/chars.rb +0 -476
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/multibyte/exceptions.rb +0 -8
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/multibyte/unicode.rb +0 -393
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/multibyte/utils.rb +0 -60
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/notifications.rb +0 -154
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/notifications/fanout.rb +0 -61
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/notifications/instrumenter.rb +0 -53
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/option_merger.rb +0 -25
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/ordered_hash.rb +0 -222
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/ordered_options.rb +0 -61
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/railtie.rb +0 -59
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/rescuable.rb +0 -115
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/ruby/shim.rb +0 -22
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/string_inquirer.rb +0 -21
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/tagged_logging.rb +0 -80
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/test_case.rb +0 -34
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/testing/assertions.rb +0 -97
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/testing/declarative.rb +0 -40
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/testing/deprecation.rb +0 -55
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/testing/isolation.rb +0 -157
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/testing/mochaing.rb +0 -7
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/testing/pending.rb +0 -52
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/testing/performance.rb +0 -317
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/testing/performance/jruby.rb +0 -115
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/testing/performance/rubinius.rb +0 -113
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/testing/performance/ruby.rb +0 -152
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/testing/performance/ruby/mri.rb +0 -57
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/testing/performance/ruby/yarv.rb +0 -57
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/testing/setup_and_teardown.rb +0 -118
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/time.rb +0 -35
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/time/autoload.rb +0 -5
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/time_with_zone.rb +0 -358
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/values/time_zone.rb +0 -397
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/values/unicode_tables.dat +0 -0
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/version.rb +0 -10
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/whiny_nil.rb +0 -24
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/xml_mini.rb +0 -168
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/xml_mini/jdom.rb +0 -175
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/xml_mini/libxml.rb +0 -80
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/xml_mini/libxmlsax.rb +0 -86
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/xml_mini/nokogiri.rb +0 -84
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/xml_mini/nokogirisax.rb +0 -88
- data/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/xml_mini/rexml.rb +0 -130
- data/vendor/bundle/specifications/activesupport-3.2.11.gemspec +0 -33
@@ -1,638 +0,0 @@
|
|
1
|
-
require 'benchmark'
|
2
|
-
require 'zlib'
|
3
|
-
require 'active_support/core_ext/array/extract_options'
|
4
|
-
require 'active_support/core_ext/array/wrap'
|
5
|
-
require 'active_support/core_ext/benchmark'
|
6
|
-
require 'active_support/core_ext/exception'
|
7
|
-
require 'active_support/core_ext/class/attribute_accessors'
|
8
|
-
require 'active_support/core_ext/numeric/bytes'
|
9
|
-
require 'active_support/core_ext/numeric/time'
|
10
|
-
require 'active_support/core_ext/object/to_param'
|
11
|
-
require 'active_support/core_ext/string/inflections'
|
12
|
-
|
13
|
-
module ActiveSupport
|
14
|
-
# See ActiveSupport::Cache::Store for documentation.
|
15
|
-
module Cache
|
16
|
-
autoload :FileStore, 'active_support/cache/file_store'
|
17
|
-
autoload :MemoryStore, 'active_support/cache/memory_store'
|
18
|
-
autoload :MemCacheStore, 'active_support/cache/mem_cache_store'
|
19
|
-
autoload :NullStore, 'active_support/cache/null_store'
|
20
|
-
|
21
|
-
# These options mean something to all cache implementations. Individual cache
|
22
|
-
# implementations may support additional options.
|
23
|
-
UNIVERSAL_OPTIONS = [:namespace, :compress, :compress_threshold, :expires_in, :race_condition_ttl]
|
24
|
-
|
25
|
-
module Strategy
|
26
|
-
autoload :LocalCache, 'active_support/cache/strategy/local_cache'
|
27
|
-
end
|
28
|
-
|
29
|
-
class << self
|
30
|
-
# Creates a new CacheStore object according to the given options.
|
31
|
-
#
|
32
|
-
# If no arguments are passed to this method, then a new
|
33
|
-
# ActiveSupport::Cache::MemoryStore object will be returned.
|
34
|
-
#
|
35
|
-
# If you pass a Symbol as the first argument, then a corresponding cache
|
36
|
-
# store class under the ActiveSupport::Cache namespace will be created.
|
37
|
-
# For example:
|
38
|
-
#
|
39
|
-
# ActiveSupport::Cache.lookup_store(:memory_store)
|
40
|
-
# # => returns a new ActiveSupport::Cache::MemoryStore object
|
41
|
-
#
|
42
|
-
# ActiveSupport::Cache.lookup_store(:mem_cache_store)
|
43
|
-
# # => returns a new ActiveSupport::Cache::MemCacheStore object
|
44
|
-
#
|
45
|
-
# Any additional arguments will be passed to the corresponding cache store
|
46
|
-
# class's constructor:
|
47
|
-
#
|
48
|
-
# ActiveSupport::Cache.lookup_store(:file_store, "/tmp/cache")
|
49
|
-
# # => same as: ActiveSupport::Cache::FileStore.new("/tmp/cache")
|
50
|
-
#
|
51
|
-
# If the first argument is not a Symbol, then it will simply be returned:
|
52
|
-
#
|
53
|
-
# ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new)
|
54
|
-
# # => returns MyOwnCacheStore.new
|
55
|
-
def lookup_store(*store_option)
|
56
|
-
store, *parameters = *Array.wrap(store_option).flatten
|
57
|
-
|
58
|
-
case store
|
59
|
-
when Symbol
|
60
|
-
store_class_name = store.to_s.camelize
|
61
|
-
store_class =
|
62
|
-
begin
|
63
|
-
require "active_support/cache/#{store}"
|
64
|
-
rescue LoadError => e
|
65
|
-
raise "Could not find cache store adapter for #{store} (#{e})"
|
66
|
-
else
|
67
|
-
ActiveSupport::Cache.const_get(store_class_name)
|
68
|
-
end
|
69
|
-
store_class.new(*parameters)
|
70
|
-
when nil
|
71
|
-
ActiveSupport::Cache::MemoryStore.new
|
72
|
-
else
|
73
|
-
store
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def expand_cache_key(key, namespace = nil)
|
78
|
-
expanded_cache_key = namespace ? "#{namespace}/" : ""
|
79
|
-
|
80
|
-
if prefix = ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]
|
81
|
-
expanded_cache_key << "#{prefix}/"
|
82
|
-
end
|
83
|
-
|
84
|
-
expanded_cache_key << retrieve_cache_key(key)
|
85
|
-
expanded_cache_key
|
86
|
-
end
|
87
|
-
|
88
|
-
private
|
89
|
-
|
90
|
-
def retrieve_cache_key(key)
|
91
|
-
case
|
92
|
-
when key.respond_to?(:cache_key) then key.cache_key
|
93
|
-
when key.is_a?(Array) then key.map { |element| retrieve_cache_key(element) }.to_param
|
94
|
-
else key.to_param
|
95
|
-
end.to_s
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# An abstract cache store class. There are multiple cache store
|
100
|
-
# implementations, each having its own additional features. See the classes
|
101
|
-
# under the ActiveSupport::Cache module, e.g.
|
102
|
-
# ActiveSupport::Cache::MemCacheStore. MemCacheStore is currently the most
|
103
|
-
# popular cache store for large production websites.
|
104
|
-
#
|
105
|
-
# Some implementations may not support all methods beyond the basic cache
|
106
|
-
# methods of +fetch+, +write+, +read+, +exist?+, and +delete+.
|
107
|
-
#
|
108
|
-
# ActiveSupport::Cache::Store can store any serializable Ruby object.
|
109
|
-
#
|
110
|
-
# cache = ActiveSupport::Cache::MemoryStore.new
|
111
|
-
#
|
112
|
-
# cache.read("city") # => nil
|
113
|
-
# cache.write("city", "Duckburgh")
|
114
|
-
# cache.read("city") # => "Duckburgh"
|
115
|
-
#
|
116
|
-
# Keys are always translated into Strings and are case sensitive. When an
|
117
|
-
# object is specified as a key and has a +cache_key+ method defined, this
|
118
|
-
# method will be called to define the key. Otherwise, the +to_param+
|
119
|
-
# method will be called. Hashes and Arrays can also be used as keys. The
|
120
|
-
# elements will be delimited by slashes, and the elements within a Hash
|
121
|
-
# will be sorted by key so they are consistent.
|
122
|
-
#
|
123
|
-
# cache.read("city") == cache.read(:city) # => true
|
124
|
-
#
|
125
|
-
# Nil values can be cached.
|
126
|
-
#
|
127
|
-
# If your cache is on a shared infrastructure, you can define a namespace
|
128
|
-
# for your cache entries. If a namespace is defined, it will be prefixed on
|
129
|
-
# to every key. The namespace can be either a static value or a Proc. If it
|
130
|
-
# is a Proc, it will be invoked when each key is evaluated so that you can
|
131
|
-
# use application logic to invalidate keys.
|
132
|
-
#
|
133
|
-
# cache.namespace = lambda { @last_mod_time } # Set the namespace to a variable
|
134
|
-
# @last_mod_time = Time.now # Invalidate the entire cache by changing namespace
|
135
|
-
#
|
136
|
-
#
|
137
|
-
# Caches can also store values in a compressed format to save space and
|
138
|
-
# reduce time spent sending data. Since there is overhead, values must be
|
139
|
-
# large enough to warrant compression. To turn on compression either pass
|
140
|
-
# <tt>:compress => true</tt> in the initializer or as an option to +fetch+
|
141
|
-
# or +write+. To specify the threshold at which to compress values, set the
|
142
|
-
# <tt>:compress_threshold</tt> option. The default threshold is 16K.
|
143
|
-
class Store
|
144
|
-
|
145
|
-
cattr_accessor :logger, :instance_writer => true
|
146
|
-
|
147
|
-
attr_reader :silence, :options
|
148
|
-
alias :silence? :silence
|
149
|
-
|
150
|
-
# Create a new cache. The options will be passed to any write method calls except
|
151
|
-
# for :namespace which can be used to set the global namespace for the cache.
|
152
|
-
def initialize(options = nil)
|
153
|
-
@options = options ? options.dup : {}
|
154
|
-
end
|
155
|
-
|
156
|
-
# Silence the logger.
|
157
|
-
def silence!
|
158
|
-
@silence = true
|
159
|
-
self
|
160
|
-
end
|
161
|
-
|
162
|
-
# Silence the logger within a block.
|
163
|
-
def mute
|
164
|
-
previous_silence, @silence = defined?(@silence) && @silence, true
|
165
|
-
yield
|
166
|
-
ensure
|
167
|
-
@silence = previous_silence
|
168
|
-
end
|
169
|
-
|
170
|
-
# Set to true if cache stores should be instrumented. Default is false.
|
171
|
-
def self.instrument=(boolean)
|
172
|
-
Thread.current[:instrument_cache_store] = boolean
|
173
|
-
end
|
174
|
-
|
175
|
-
def self.instrument
|
176
|
-
Thread.current[:instrument_cache_store] || false
|
177
|
-
end
|
178
|
-
|
179
|
-
# Fetches data from the cache, using the given key. If there is data in
|
180
|
-
# the cache with the given key, then that data is returned.
|
181
|
-
#
|
182
|
-
# If there is no such data in the cache (a cache miss), then nil will be
|
183
|
-
# returned. However, if a block has been passed, that block will be run
|
184
|
-
# in the event of a cache miss. The return value of the block will be
|
185
|
-
# written to the cache under the given cache key, and that return value
|
186
|
-
# will be returned.
|
187
|
-
#
|
188
|
-
# cache.write("today", "Monday")
|
189
|
-
# cache.fetch("today") # => "Monday"
|
190
|
-
#
|
191
|
-
# cache.fetch("city") # => nil
|
192
|
-
# cache.fetch("city") do
|
193
|
-
# "Duckburgh"
|
194
|
-
# end
|
195
|
-
# cache.fetch("city") # => "Duckburgh"
|
196
|
-
#
|
197
|
-
# You may also specify additional options via the +options+ argument.
|
198
|
-
# Setting <tt>:force => true</tt> will force a cache miss:
|
199
|
-
#
|
200
|
-
# cache.write("today", "Monday")
|
201
|
-
# cache.fetch("today", :force => true) # => nil
|
202
|
-
#
|
203
|
-
# Setting <tt>:compress</tt> will store a large cache entry set by the call
|
204
|
-
# in a compressed format.
|
205
|
-
#
|
206
|
-
#
|
207
|
-
# Setting <tt>:expires_in</tt> will set an expiration time on the cache.
|
208
|
-
# All caches support auto-expiring content after a specified number of
|
209
|
-
# seconds. This value can be specified as an option to the constructor
|
210
|
-
# (in which case all entries will be affected), or it can be supplied to
|
211
|
-
# the +fetch+ or +write+ method to effect just one entry.
|
212
|
-
#
|
213
|
-
# cache = ActiveSupport::Cache::MemoryStore.new(:expires_in => 5.minutes)
|
214
|
-
# cache.write(key, value, :expires_in => 1.minute) # Set a lower value for one entry
|
215
|
-
#
|
216
|
-
# Setting <tt>:race_condition_ttl</tt> is very useful in situations where a cache entry
|
217
|
-
# is used very frequently and is under heavy load. If a cache expires and due to heavy load
|
218
|
-
# seven different processes will try to read data natively and then they all will try to
|
219
|
-
# write to cache. To avoid that case the first process to find an expired cache entry will
|
220
|
-
# bump the cache expiration time by the value set in <tt>:race_condition_ttl</tt>. Yes
|
221
|
-
# this process is extending the time for a stale value by another few seconds. Because
|
222
|
-
# of extended life of the previous cache, other processes will continue to use slightly
|
223
|
-
# stale data for a just a big longer. In the meantime that first process will go ahead
|
224
|
-
# and will write into cache the new value. After that all the processes will start
|
225
|
-
# getting new value. The key is to keep <tt>:race_condition_ttl</tt> small.
|
226
|
-
#
|
227
|
-
# If the process regenerating the entry errors out, the entry will be regenerated
|
228
|
-
# after the specified number of seconds. Also note that the life of stale cache is
|
229
|
-
# extended only if it expired recently. Otherwise a new value is generated and
|
230
|
-
# <tt>:race_condition_ttl</tt> does not play any role.
|
231
|
-
#
|
232
|
-
# # Set all values to expire after one minute.
|
233
|
-
# cache = ActiveSupport::Cache::MemoryStore.new(:expires_in => 1.minute)
|
234
|
-
#
|
235
|
-
# cache.write("foo", "original value")
|
236
|
-
# val_1 = nil
|
237
|
-
# val_2 = nil
|
238
|
-
# sleep 60
|
239
|
-
#
|
240
|
-
# Thread.new do
|
241
|
-
# val_1 = cache.fetch("foo", :race_condition_ttl => 10) do
|
242
|
-
# sleep 1
|
243
|
-
# "new value 1"
|
244
|
-
# end
|
245
|
-
# end
|
246
|
-
#
|
247
|
-
# Thread.new do
|
248
|
-
# val_2 = cache.fetch("foo", :race_condition_ttl => 10) do
|
249
|
-
# "new value 2"
|
250
|
-
# end
|
251
|
-
# end
|
252
|
-
#
|
253
|
-
# # val_1 => "new value 1"
|
254
|
-
# # val_2 => "original value"
|
255
|
-
# # sleep 10 # First thread extend the life of cache by another 10 seconds
|
256
|
-
# # cache.fetch("foo") => "new value 1"
|
257
|
-
#
|
258
|
-
# Other options will be handled by the specific cache store implementation.
|
259
|
-
# Internally, #fetch calls #read_entry, and calls #write_entry on a cache miss.
|
260
|
-
# +options+ will be passed to the #read and #write calls.
|
261
|
-
#
|
262
|
-
# For example, MemCacheStore's #write method supports the +:raw+
|
263
|
-
# option, which tells the memcached server to store all values as strings.
|
264
|
-
# We can use this option with #fetch too:
|
265
|
-
#
|
266
|
-
# cache = ActiveSupport::Cache::MemCacheStore.new
|
267
|
-
# cache.fetch("foo", :force => true, :raw => true) do
|
268
|
-
# :bar
|
269
|
-
# end
|
270
|
-
# cache.fetch("foo") # => "bar"
|
271
|
-
def fetch(name, options = nil)
|
272
|
-
if block_given?
|
273
|
-
options = merged_options(options)
|
274
|
-
key = namespaced_key(name, options)
|
275
|
-
unless options[:force]
|
276
|
-
entry = instrument(:read, name, options) do |payload|
|
277
|
-
payload[:super_operation] = :fetch if payload
|
278
|
-
read_entry(key, options)
|
279
|
-
end
|
280
|
-
end
|
281
|
-
if entry && entry.expired?
|
282
|
-
race_ttl = options[:race_condition_ttl].to_f
|
283
|
-
if race_ttl and Time.now.to_f - entry.expires_at <= race_ttl
|
284
|
-
entry.expires_at = Time.now + race_ttl
|
285
|
-
write_entry(key, entry, :expires_in => race_ttl * 2)
|
286
|
-
else
|
287
|
-
delete_entry(key, options)
|
288
|
-
end
|
289
|
-
entry = nil
|
290
|
-
end
|
291
|
-
|
292
|
-
if entry
|
293
|
-
instrument(:fetch_hit, name, options) { |payload| }
|
294
|
-
entry.value
|
295
|
-
else
|
296
|
-
result = instrument(:generate, name, options) do |payload|
|
297
|
-
yield
|
298
|
-
end
|
299
|
-
write(name, result, options)
|
300
|
-
result
|
301
|
-
end
|
302
|
-
else
|
303
|
-
read(name, options)
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
# Fetches data from the cache, using the given key. If there is data in
|
308
|
-
# the cache with the given key, then that data is returned. Otherwise,
|
309
|
-
# nil is returned.
|
310
|
-
#
|
311
|
-
# Options are passed to the underlying cache implementation.
|
312
|
-
def read(name, options = nil)
|
313
|
-
options = merged_options(options)
|
314
|
-
key = namespaced_key(name, options)
|
315
|
-
instrument(:read, name, options) do |payload|
|
316
|
-
entry = read_entry(key, options)
|
317
|
-
if entry
|
318
|
-
if entry.expired?
|
319
|
-
delete_entry(key, options)
|
320
|
-
payload[:hit] = false if payload
|
321
|
-
nil
|
322
|
-
else
|
323
|
-
payload[:hit] = true if payload
|
324
|
-
entry.value
|
325
|
-
end
|
326
|
-
else
|
327
|
-
payload[:hit] = false if payload
|
328
|
-
nil
|
329
|
-
end
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
|
-
# Read multiple values at once from the cache. Options can be passed
|
334
|
-
# in the last argument.
|
335
|
-
#
|
336
|
-
# Some cache implementation may optimize this method.
|
337
|
-
#
|
338
|
-
# Returns a hash mapping the names provided to the values found.
|
339
|
-
def read_multi(*names)
|
340
|
-
options = names.extract_options!
|
341
|
-
options = merged_options(options)
|
342
|
-
results = {}
|
343
|
-
names.each do |name|
|
344
|
-
key = namespaced_key(name, options)
|
345
|
-
entry = read_entry(key, options)
|
346
|
-
if entry
|
347
|
-
if entry.expired?
|
348
|
-
delete_entry(key, options)
|
349
|
-
else
|
350
|
-
results[name] = entry.value
|
351
|
-
end
|
352
|
-
end
|
353
|
-
end
|
354
|
-
results
|
355
|
-
end
|
356
|
-
|
357
|
-
# Writes the value to the cache, with the key.
|
358
|
-
#
|
359
|
-
# Options are passed to the underlying cache implementation.
|
360
|
-
def write(name, value, options = nil)
|
361
|
-
options = merged_options(options)
|
362
|
-
instrument(:write, name, options) do |payload|
|
363
|
-
entry = Entry.new(value, options)
|
364
|
-
write_entry(namespaced_key(name, options), entry, options)
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
# Deletes an entry in the cache. Returns +true+ if an entry is deleted.
|
369
|
-
#
|
370
|
-
# Options are passed to the underlying cache implementation.
|
371
|
-
def delete(name, options = nil)
|
372
|
-
options = merged_options(options)
|
373
|
-
instrument(:delete, name) do |payload|
|
374
|
-
delete_entry(namespaced_key(name, options), options)
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
# Return true if the cache contains an entry for the given key.
|
379
|
-
#
|
380
|
-
# Options are passed to the underlying cache implementation.
|
381
|
-
def exist?(name, options = nil)
|
382
|
-
options = merged_options(options)
|
383
|
-
instrument(:exist?, name) do |payload|
|
384
|
-
entry = read_entry(namespaced_key(name, options), options)
|
385
|
-
if entry && !entry.expired?
|
386
|
-
true
|
387
|
-
else
|
388
|
-
false
|
389
|
-
end
|
390
|
-
end
|
391
|
-
end
|
392
|
-
|
393
|
-
# Delete all entries with keys matching the pattern.
|
394
|
-
#
|
395
|
-
# Options are passed to the underlying cache implementation.
|
396
|
-
#
|
397
|
-
# All implementations may not support this method.
|
398
|
-
def delete_matched(matcher, options = nil)
|
399
|
-
raise NotImplementedError.new("#{self.class.name} does not support delete_matched")
|
400
|
-
end
|
401
|
-
|
402
|
-
# Increment an integer value in the cache.
|
403
|
-
#
|
404
|
-
# Options are passed to the underlying cache implementation.
|
405
|
-
#
|
406
|
-
# All implementations may not support this method.
|
407
|
-
def increment(name, amount = 1, options = nil)
|
408
|
-
raise NotImplementedError.new("#{self.class.name} does not support increment")
|
409
|
-
end
|
410
|
-
|
411
|
-
# Increment an integer value in the cache.
|
412
|
-
#
|
413
|
-
# Options are passed to the underlying cache implementation.
|
414
|
-
#
|
415
|
-
# All implementations may not support this method.
|
416
|
-
def decrement(name, amount = 1, options = nil)
|
417
|
-
raise NotImplementedError.new("#{self.class.name} does not support decrement")
|
418
|
-
end
|
419
|
-
|
420
|
-
# Cleanup the cache by removing expired entries.
|
421
|
-
#
|
422
|
-
# Options are passed to the underlying cache implementation.
|
423
|
-
#
|
424
|
-
# All implementations may not support this method.
|
425
|
-
def cleanup(options = nil)
|
426
|
-
raise NotImplementedError.new("#{self.class.name} does not support cleanup")
|
427
|
-
end
|
428
|
-
|
429
|
-
# Clear the entire cache. Be careful with this method since it could
|
430
|
-
# affect other processes if shared cache is being used.
|
431
|
-
#
|
432
|
-
# Options are passed to the underlying cache implementation.
|
433
|
-
#
|
434
|
-
# All implementations may not support this method.
|
435
|
-
def clear(options = nil)
|
436
|
-
raise NotImplementedError.new("#{self.class.name} does not support clear")
|
437
|
-
end
|
438
|
-
|
439
|
-
protected
|
440
|
-
# Add the namespace defined in the options to a pattern designed to match keys.
|
441
|
-
# Implementations that support delete_matched should call this method to translate
|
442
|
-
# a pattern that matches names into one that matches namespaced keys.
|
443
|
-
def key_matcher(pattern, options)
|
444
|
-
prefix = options[:namespace].is_a?(Proc) ? options[:namespace].call : options[:namespace]
|
445
|
-
if prefix
|
446
|
-
source = pattern.source
|
447
|
-
if source.start_with?('^')
|
448
|
-
source = source[1, source.length]
|
449
|
-
else
|
450
|
-
source = ".*#{source[0, source.length]}"
|
451
|
-
end
|
452
|
-
Regexp.new("^#{Regexp.escape(prefix)}:#{source}", pattern.options)
|
453
|
-
else
|
454
|
-
pattern
|
455
|
-
end
|
456
|
-
end
|
457
|
-
|
458
|
-
# Read an entry from the cache implementation. Subclasses must implement this method.
|
459
|
-
def read_entry(key, options) # :nodoc:
|
460
|
-
raise NotImplementedError.new
|
461
|
-
end
|
462
|
-
|
463
|
-
# Write an entry to the cache implementation. Subclasses must implement this method.
|
464
|
-
def write_entry(key, entry, options) # :nodoc:
|
465
|
-
raise NotImplementedError.new
|
466
|
-
end
|
467
|
-
|
468
|
-
# Delete an entry from the cache implementation. Subclasses must implement this method.
|
469
|
-
def delete_entry(key, options) # :nodoc:
|
470
|
-
raise NotImplementedError.new
|
471
|
-
end
|
472
|
-
|
473
|
-
private
|
474
|
-
# Merge the default options with ones specific to a method call.
|
475
|
-
def merged_options(call_options) # :nodoc:
|
476
|
-
if call_options
|
477
|
-
options.merge(call_options)
|
478
|
-
else
|
479
|
-
options.dup
|
480
|
-
end
|
481
|
-
end
|
482
|
-
|
483
|
-
# Expand key to be a consistent string value. Invoke +cache_key+ if
|
484
|
-
# object responds to +cache_key+. Otherwise, to_param method will be
|
485
|
-
# called. If the key is a Hash, then keys will be sorted alphabetically.
|
486
|
-
def expanded_key(key) # :nodoc:
|
487
|
-
return key.cache_key.to_s if key.respond_to?(:cache_key)
|
488
|
-
|
489
|
-
case key
|
490
|
-
when Array
|
491
|
-
if key.size > 1
|
492
|
-
key = key.collect{|element| expanded_key(element)}
|
493
|
-
else
|
494
|
-
key = key.first
|
495
|
-
end
|
496
|
-
when Hash
|
497
|
-
key = key.sort_by { |k,_| k.to_s }.collect{|k,v| "#{k}=#{v}"}
|
498
|
-
end
|
499
|
-
|
500
|
-
key.to_param
|
501
|
-
end
|
502
|
-
|
503
|
-
# Prefix a key with the namespace. Namespace and key will be delimited with a colon.
|
504
|
-
def namespaced_key(key, options)
|
505
|
-
key = expanded_key(key)
|
506
|
-
namespace = options[:namespace] if options
|
507
|
-
prefix = namespace.is_a?(Proc) ? namespace.call : namespace
|
508
|
-
key = "#{prefix}:#{key}" if prefix
|
509
|
-
key
|
510
|
-
end
|
511
|
-
|
512
|
-
def instrument(operation, key, options = nil)
|
513
|
-
log(operation, key, options)
|
514
|
-
|
515
|
-
if self.class.instrument
|
516
|
-
payload = { :key => key }
|
517
|
-
payload.merge!(options) if options.is_a?(Hash)
|
518
|
-
ActiveSupport::Notifications.instrument("cache_#{operation}.active_support", payload){ yield(payload) }
|
519
|
-
else
|
520
|
-
yield(nil)
|
521
|
-
end
|
522
|
-
end
|
523
|
-
|
524
|
-
def log(operation, key, options = nil)
|
525
|
-
return unless logger && logger.debug? && !silence?
|
526
|
-
logger.debug("Cache #{operation}: #{key}#{options.blank? ? "" : " (#{options.inspect})"}")
|
527
|
-
end
|
528
|
-
end
|
529
|
-
|
530
|
-
# Entry that is put into caches. It supports expiration time on entries and can compress values
|
531
|
-
# to save space in the cache.
|
532
|
-
class Entry
|
533
|
-
attr_reader :created_at, :expires_in
|
534
|
-
|
535
|
-
DEFAULT_COMPRESS_LIMIT = 16.kilobytes
|
536
|
-
|
537
|
-
class << self
|
538
|
-
# Create an entry with internal attributes set. This method is intended to be
|
539
|
-
# used by implementations that store cache entries in a native format instead
|
540
|
-
# of as serialized Ruby objects.
|
541
|
-
def create(raw_value, created_at, options = {})
|
542
|
-
entry = new(nil)
|
543
|
-
entry.instance_variable_set(:@value, raw_value)
|
544
|
-
entry.instance_variable_set(:@created_at, created_at.to_f)
|
545
|
-
entry.instance_variable_set(:@compressed, options[:compressed])
|
546
|
-
entry.instance_variable_set(:@expires_in, options[:expires_in])
|
547
|
-
entry
|
548
|
-
end
|
549
|
-
end
|
550
|
-
|
551
|
-
# Create a new cache entry for the specified value. Options supported are
|
552
|
-
# +:compress+, +:compress_threshold+, and +:expires_in+.
|
553
|
-
def initialize(value, options = {})
|
554
|
-
@compressed = false
|
555
|
-
@expires_in = options[:expires_in]
|
556
|
-
@expires_in = @expires_in.to_f if @expires_in
|
557
|
-
@created_at = Time.now.to_f
|
558
|
-
if value.nil?
|
559
|
-
@value = nil
|
560
|
-
else
|
561
|
-
@value = Marshal.dump(value)
|
562
|
-
if should_compress?(@value, options)
|
563
|
-
@value = Zlib::Deflate.deflate(@value)
|
564
|
-
@compressed = true
|
565
|
-
end
|
566
|
-
end
|
567
|
-
end
|
568
|
-
|
569
|
-
# Get the raw value. This value may be serialized and compressed.
|
570
|
-
def raw_value
|
571
|
-
@value
|
572
|
-
end
|
573
|
-
|
574
|
-
# Get the value stored in the cache.
|
575
|
-
def value
|
576
|
-
# If the original value was exactly false @value is still true because
|
577
|
-
# it is marshalled and eventually compressed. Both operations yield
|
578
|
-
# strings.
|
579
|
-
if @value
|
580
|
-
# In rails 3.1 and earlier values in entries did not marshaled without
|
581
|
-
# options[:compress] and if it's Numeric.
|
582
|
-
# But after commit a263f377978fc07515b42808ebc1f7894fafaa3a
|
583
|
-
# all values in entries are marshalled. And after that code below expects
|
584
|
-
# that all values in entries will be marshaled (and will be strings).
|
585
|
-
# So here we need a check for old ones.
|
586
|
-
begin
|
587
|
-
Marshal.load(compressed? ? Zlib::Inflate.inflate(@value) : @value)
|
588
|
-
rescue TypeError
|
589
|
-
compressed? ? Zlib::Inflate.inflate(@value) : @value
|
590
|
-
end
|
591
|
-
end
|
592
|
-
end
|
593
|
-
|
594
|
-
def compressed?
|
595
|
-
@compressed
|
596
|
-
end
|
597
|
-
|
598
|
-
# Check if the entry is expired. The +expires_in+ parameter can override the
|
599
|
-
# value set when the entry was created.
|
600
|
-
def expired?
|
601
|
-
@expires_in && @created_at + @expires_in <= Time.now.to_f
|
602
|
-
end
|
603
|
-
|
604
|
-
# Set a new time when the entry will expire.
|
605
|
-
def expires_at=(time)
|
606
|
-
if time
|
607
|
-
@expires_in = time.to_f - @created_at
|
608
|
-
else
|
609
|
-
@expires_in = nil
|
610
|
-
end
|
611
|
-
end
|
612
|
-
|
613
|
-
# Seconds since the epoch when the entry will expire.
|
614
|
-
def expires_at
|
615
|
-
@expires_in ? @created_at + @expires_in : nil
|
616
|
-
end
|
617
|
-
|
618
|
-
# Returns the size of the cached value. This could be less than value.size
|
619
|
-
# if the data is compressed.
|
620
|
-
def size
|
621
|
-
if @value.nil?
|
622
|
-
0
|
623
|
-
else
|
624
|
-
@value.bytesize
|
625
|
-
end
|
626
|
-
end
|
627
|
-
|
628
|
-
private
|
629
|
-
def should_compress?(serialized_value, options)
|
630
|
-
if options[:compress]
|
631
|
-
compress_threshold = options[:compress_threshold] || DEFAULT_COMPRESS_LIMIT
|
632
|
-
return true if serialized_value.size >= compress_threshold
|
633
|
-
end
|
634
|
-
false
|
635
|
-
end
|
636
|
-
end
|
637
|
-
end
|
638
|
-
end
|