activesupport 2.3.5 → 3.0.0.beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +66 -9
- data/lib/active_support/all.rb +2 -7
- data/lib/active_support/backtrace_cleaner.rb +31 -9
- data/lib/active_support/base64.rb +9 -0
- data/lib/active_support/basic_object.rb +7 -10
- data/lib/active_support/benchmarkable.rb +60 -0
- data/lib/active_support/buffered_logger.rb +14 -9
- data/lib/active_support/cache/compressed_mem_cache_store.rb +2 -0
- data/lib/active_support/cache/file_store.rb +35 -17
- data/lib/active_support/cache/mem_cache_store.rb +32 -23
- data/lib/active_support/cache/memory_store.rb +17 -10
- data/lib/active_support/cache/strategy/local_cache.rb +9 -1
- data/lib/active_support/cache.rb +75 -55
- data/lib/active_support/callbacks.rb +490 -169
- data/lib/active_support/concern.rb +29 -0
- data/lib/active_support/configurable.rb +35 -0
- data/lib/active_support/core_ext/array/access.rb +39 -46
- data/lib/active_support/core_ext/array/conversions.rb +145 -182
- data/lib/active_support/core_ext/array/extract_options.rb +26 -17
- data/lib/active_support/core_ext/array/grouping.rb +87 -93
- data/lib/active_support/core_ext/array/random_access.rb +4 -10
- data/lib/active_support/core_ext/array/uniq_by.rb +17 -0
- data/lib/active_support/core_ext/array/wrap.rb +22 -0
- data/lib/active_support/core_ext/array.rb +2 -10
- data/lib/active_support/core_ext/big_decimal/conversions.rb +27 -0
- data/lib/active_support/core_ext/big_decimal.rb +1 -0
- data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +16 -20
- data/lib/active_support/core_ext/cgi.rb +0 -4
- data/lib/active_support/core_ext/class/attribute.rb +70 -0
- data/lib/active_support/core_ext/class/attribute_accessors.rb +40 -31
- data/lib/active_support/core_ext/class/delegating_attributes.rb +37 -40
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +100 -11
- data/lib/active_support/core_ext/class/subclasses.rb +55 -0
- data/lib/active_support/core_ext/class.rb +1 -1
- data/lib/active_support/core_ext/date/acts_like.rb +8 -0
- data/lib/active_support/core_ext/date/calculations.rb +218 -228
- data/lib/active_support/core_ext/date/conversions.rb +87 -96
- data/lib/active_support/core_ext/date/freeze.rb +31 -0
- data/lib/active_support/core_ext/date_time/acts_like.rb +13 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +97 -110
- data/lib/active_support/core_ext/date_time/conversions.rb +85 -85
- data/lib/active_support/core_ext/date_time/zones.rb +17 -0
- data/lib/active_support/core_ext/enumerable.rb +18 -13
- data/lib/active_support/core_ext/exception.rb +1 -43
- data/lib/active_support/core_ext/file/atomic.rb +35 -40
- data/lib/active_support/core_ext/file/path.rb +5 -0
- data/lib/active_support/core_ext/file.rb +0 -4
- data/lib/active_support/core_ext/float/rounding.rb +15 -20
- data/lib/active_support/core_ext/float.rb +0 -6
- data/lib/active_support/core_ext/hash/conversions.rb +255 -229
- data/lib/active_support/core_ext/hash/deep_merge.rb +12 -19
- data/lib/active_support/core_ext/hash/diff.rb +11 -17
- data/lib/active_support/core_ext/hash/except.rb +21 -22
- data/lib/active_support/core_ext/hash/indifferent_access.rb +8 -137
- data/lib/active_support/core_ext/hash/keys.rb +38 -45
- data/lib/active_support/core_ext/hash/reverse_merge.rb +25 -32
- data/lib/active_support/core_ext/hash/slice.rb +35 -37
- data/lib/active_support/core_ext/hash.rb +8 -14
- data/lib/active_support/core_ext/integer/inflections.rb +10 -16
- data/lib/active_support/core_ext/integer/multiple.rb +6 -0
- data/lib/active_support/core_ext/integer/time.rb +36 -42
- data/lib/active_support/core_ext/integer.rb +1 -7
- data/lib/active_support/core_ext/kernel/debugger.rb +1 -1
- data/lib/active_support/core_ext/kernel/reporting.rb +9 -7
- data/lib/active_support/core_ext/kernel/requires.rb +3 -1
- data/lib/active_support/core_ext/kernel/singleton_class.rb +13 -0
- data/lib/active_support/core_ext/kernel.rb +1 -1
- data/lib/active_support/core_ext/load_error.rb +16 -32
- data/lib/active_support/core_ext/logger.rb +3 -2
- data/lib/active_support/core_ext/module/aliasing.rb +64 -68
- data/lib/active_support/core_ext/module/anonymous.rb +24 -0
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
- data/lib/active_support/core_ext/module/attr_internal.rb +4 -4
- data/lib/active_support/core_ext/module/attribute_accessors.rb +48 -42
- data/lib/active_support/core_ext/module/delegation.rb +22 -11
- data/lib/active_support/core_ext/module/deprecation.rb +9 -0
- data/lib/active_support/core_ext/module/introspection.rb +77 -79
- data/lib/active_support/core_ext/module/method_names.rb +14 -0
- data/lib/active_support/core_ext/module/reachable.rb +10 -0
- data/lib/active_support/core_ext/module/remove_method.rb +6 -0
- data/lib/active_support/core_ext/module/synchronization.rb +4 -1
- data/lib/active_support/core_ext/module.rb +7 -18
- data/lib/active_support/core_ext/name_error.rb +3 -4
- data/lib/active_support/core_ext/numeric/bytes.rb +35 -41
- data/lib/active_support/core_ext/numeric/time.rb +70 -74
- data/lib/active_support/core_ext/numeric.rb +1 -8
- data/lib/active_support/core_ext/object/acts_like.rb +10 -0
- data/lib/active_support/core_ext/object/blank.rb +20 -2
- data/lib/active_support/core_ext/object/conversions.rb +4 -15
- data/lib/active_support/core_ext/object/duplicable.rb +65 -0
- data/lib/active_support/core_ext/object/extending.rb +8 -77
- data/lib/active_support/core_ext/object/instance_variables.rb +0 -7
- data/lib/active_support/core_ext/object/misc.rb +2 -90
- data/lib/active_support/core_ext/object/returning.rb +42 -0
- data/lib/active_support/core_ext/object/to_param.rb +49 -0
- data/lib/active_support/core_ext/object/to_query.rb +27 -0
- data/lib/active_support/core_ext/{try.rb → object/try.rb} +4 -4
- data/lib/active_support/core_ext/object/with_options.rb +24 -0
- data/lib/active_support/core_ext/object.rb +10 -2
- data/lib/active_support/core_ext/proc.rb +3 -1
- data/lib/active_support/core_ext/process/daemon.rb +17 -19
- data/lib/active_support/core_ext/range/blockless_step.rb +24 -27
- data/lib/active_support/core_ext/range/conversions.rb +17 -23
- data/lib/active_support/core_ext/range/include_range.rb +18 -27
- data/lib/active_support/core_ext/range/overlaps.rb +6 -13
- data/lib/active_support/core_ext/range.rb +2 -9
- data/lib/active_support/core_ext/regexp.rb +5 -0
- data/lib/active_support/core_ext/rexml.rb +12 -7
- data/lib/active_support/core_ext/string/access.rb +88 -95
- data/lib/active_support/core_ext/string/behavior.rb +6 -12
- data/lib/active_support/core_ext/string/conversions.rb +20 -21
- data/lib/active_support/core_ext/string/exclude.rb +6 -0
- data/lib/active_support/core_ext/string/filters.rb +17 -23
- data/lib/active_support/core_ext/string/inflections.rb +147 -154
- data/lib/active_support/core_ext/string/interpolation.rb +1 -0
- data/lib/active_support/core_ext/string/multibyte.rb +68 -74
- data/lib/active_support/core_ext/string/output_safety.rb +105 -44
- data/lib/active_support/core_ext/string/starts_ends_with.rb +3 -34
- data/lib/active_support/core_ext/string/xchar.rb +10 -3
- data/lib/active_support/core_ext/string.rb +6 -20
- data/lib/active_support/core_ext/time/acts_like.rb +8 -0
- data/lib/active_support/core_ext/time/calculations.rb +276 -299
- data/lib/active_support/core_ext/time/conversions.rb +79 -84
- data/lib/active_support/core_ext/time/marshal.rb +56 -0
- data/lib/active_support/core_ext/time/publicize_conversion_methods.rb +10 -0
- data/lib/active_support/core_ext/time/zones.rb +73 -81
- data/lib/active_support/core_ext/uri.rb +2 -1
- data/lib/active_support/core_ext.rb +2 -7
- data/lib/active_support/dependencies/autoload.rb +50 -0
- data/lib/active_support/dependencies.rb +168 -197
- data/lib/active_support/deprecation/behaviors.rb +38 -0
- data/lib/active_support/deprecation/method_wrappers.rb +29 -0
- data/lib/active_support/deprecation/proxy_wrappers.rb +74 -0
- data/lib/active_support/deprecation/reporting.rb +56 -0
- data/lib/active_support/deprecation.rb +9 -187
- data/lib/active_support/duration.rb +6 -2
- data/lib/active_support/hash_with_indifferent_access.rb +141 -0
- data/lib/active_support/i18n.rb +3 -0
- data/lib/active_support/inflections.rb +1 -1
- data/lib/active_support/inflector/inflections.rb +211 -0
- data/lib/active_support/inflector/methods.rb +141 -0
- data/lib/active_support/inflector/transliterate.rb +77 -0
- data/lib/active_support/inflector.rb +4 -403
- data/lib/active_support/json/backends/jsongem.rb +16 -10
- data/lib/active_support/json/backends/yajl.rb +40 -0
- data/lib/active_support/json/backends/yaml.rb +14 -8
- data/lib/active_support/json/decoding.rb +17 -1
- data/lib/active_support/json/encoding.rb +164 -35
- data/lib/active_support/json/variable.rb +4 -3
- data/lib/active_support/lazy_load_hooks.rb +17 -0
- data/lib/active_support/memoizable.rb +8 -5
- data/lib/active_support/message_encryptor.rb +1 -0
- data/lib/active_support/message_verifier.rb +12 -29
- data/lib/active_support/multibyte/chars.rb +88 -31
- data/lib/active_support/multibyte/unicode_database.rb +5 -5
- data/lib/active_support/multibyte/utils.rb +6 -7
- data/lib/active_support/multibyte.rb +11 -6
- data/lib/active_support/notifications/fanout.rb +83 -0
- data/lib/active_support/notifications/instrumenter.rb +50 -0
- data/lib/active_support/notifications.rb +81 -0
- data/lib/active_support/option_merger.rb +2 -0
- data/lib/active_support/ordered_hash.rb +28 -11
- data/lib/active_support/ordered_options.rb +9 -1
- data/lib/active_support/railtie.rb +64 -0
- data/lib/active_support/rescuable.rb +11 -6
- data/lib/active_support/ruby/shim.rb +21 -0
- data/lib/active_support/test_case.rb +10 -8
- data/lib/active_support/testing/assertions.rb +17 -0
- data/lib/active_support/testing/declarative.rb +31 -12
- data/lib/active_support/testing/deprecation.rb +8 -10
- data/lib/active_support/testing/isolation.rb +153 -0
- data/lib/active_support/testing/pending.rb +48 -0
- data/lib/active_support/testing/performance.rb +342 -339
- data/lib/active_support/testing/setup_and_teardown.rb +48 -31
- data/lib/active_support/time/autoload.rb +5 -0
- data/lib/active_support/time.rb +34 -0
- data/lib/active_support/time_with_zone.rb +18 -12
- data/lib/active_support/values/time_zone.rb +51 -68
- data/lib/active_support/version.rb +5 -4
- data/lib/active_support/whiny_nil.rb +5 -9
- data/lib/active_support/xml_mini/jdom.rb +13 -7
- data/lib/active_support/xml_mini/libxml.rb +38 -91
- data/lib/active_support/xml_mini/libxmlsax.rb +85 -0
- data/lib/active_support/xml_mini/nokogiri.rb +40 -31
- data/lib/active_support/xml_mini/nokogirisax.rb +83 -0
- data/lib/active_support/xml_mini/rexml.rb +30 -9
- data/lib/active_support/xml_mini.rb +2 -0
- data/lib/active_support.rb +46 -30
- metadata +136 -215
- data/lib/active_support/cache/drb_store.rb +0 -14
- data/lib/active_support/core_ext/array/wrapper.rb +0 -24
- data/lib/active_support/core_ext/base64/encoding.rb +0 -16
- data/lib/active_support/core_ext/base64.rb +0 -4
- data/lib/active_support/core_ext/bigdecimal/conversions.rb +0 -37
- data/lib/active_support/core_ext/bigdecimal.rb +0 -6
- data/lib/active_support/core_ext/blank.rb +0 -2
- data/lib/active_support/core_ext/class/removal.rb +0 -50
- data/lib/active_support/core_ext/date/behavior.rb +0 -42
- data/lib/active_support/core_ext/date.rb +0 -10
- data/lib/active_support/core_ext/date_time.rb +0 -12
- data/lib/active_support/core_ext/duplicable.rb +0 -43
- data/lib/active_support/core_ext/float/time.rb +0 -27
- data/lib/active_support/core_ext/integer/even_odd.rb +0 -29
- data/lib/active_support/core_ext/kernel/daemonizing.rb +0 -7
- data/lib/active_support/core_ext/module/inclusion.rb +0 -30
- data/lib/active_support/core_ext/module/loading.rb +0 -23
- data/lib/active_support/core_ext/module/model_naming.rb +0 -25
- data/lib/active_support/core_ext/numeric/conversions.rb +0 -19
- data/lib/active_support/core_ext/object/metaclass.rb +0 -13
- data/lib/active_support/core_ext/pathname/clean_within.rb +0 -14
- data/lib/active_support/core_ext/pathname.rb +0 -7
- data/lib/active_support/core_ext/string/bytesize.rb +0 -5
- data/lib/active_support/core_ext/string/iterators.rb +0 -23
- data/lib/active_support/core_ext/symbol.rb +0 -14
- data/lib/active_support/core_ext/time/behavior.rb +0 -13
- data/lib/active_support/core_ext/time.rb +0 -42
- data/lib/active_support/json/encoders/date.rb +0 -22
- data/lib/active_support/json/encoders/date_time.rb +0 -22
- data/lib/active_support/json/encoders/enumerable.rb +0 -17
- data/lib/active_support/json/encoders/false_class.rb +0 -7
- data/lib/active_support/json/encoders/hash.rb +0 -56
- data/lib/active_support/json/encoders/nil_class.rb +0 -7
- data/lib/active_support/json/encoders/numeric.rb +0 -21
- data/lib/active_support/json/encoders/object.rb +0 -10
- data/lib/active_support/json/encoders/regexp.rb +0 -9
- data/lib/active_support/json/encoders/string.rb +0 -9
- data/lib/active_support/json/encoders/symbol.rb +0 -5
- data/lib/active_support/json/encoders/time.rb +0 -22
- data/lib/active_support/json/encoders/true_class.rb +0 -7
- data/lib/active_support/vendor/builder-2.1.2/blankslate.rb +0 -113
- data/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +0 -20
- data/lib/active_support/vendor/builder-2.1.2/builder/css.rb +0 -250
- data/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +0 -115
- data/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +0 -139
- data/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +0 -63
- data/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +0 -328
- data/lib/active_support/vendor/builder-2.1.2/builder.rb +0 -13
- data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +0 -20
- data/lib/active_support/vendor/i18n-0.1.3/README.textile +0 -20
- data/lib/active_support/vendor/i18n-0.1.3/Rakefile +0 -5
- data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +0 -27
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +0 -214
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +0 -53
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +0 -199
- data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +0 -5
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +0 -99
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +0 -124
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +0 -1
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +0 -3
- data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +0 -567
- data/lib/active_support/vendor/memcache-client-1.7.4/memcache.rb +0 -1107
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb +0 -47
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb +0 -228
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb +0 -55
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb +0 -219
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb +0 -40
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb +0 -22
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +0 -166
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +0 -86
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb +0 -283
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb +0 -136
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb +0 -204
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb +0 -161
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb +0 -27
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb +0 -274
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb +0 -149
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb +0 -194
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb +0 -22
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb +0 -35
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb +0 -232
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb +0 -139
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb +0 -144
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb +0 -131
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb +0 -282
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb +0 -74
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb +0 -205
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb +0 -171
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb +0 -288
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb +0 -196
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb +0 -67
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb +0 -73
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb +0 -161
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb +0 -27
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb +0 -87
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb +0 -31
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb +0 -164
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb +0 -24
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb +0 -34
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb +0 -35
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb +0 -59
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb +0 -47
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb +0 -78
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb +0 -121
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb +0 -65
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb +0 -164
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb +0 -270
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb +0 -187
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb +0 -35
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb +0 -29
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb +0 -193
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb +0 -185
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb +0 -37
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb +0 -185
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb +0 -16
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb +0 -228
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb +0 -185
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb +0 -188
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb +0 -232
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb +0 -181
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb +0 -197
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb +0 -179
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb +0 -276
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb +0 -218
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb +0 -168
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb +0 -268
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb +0 -288
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb +0 -211
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb +0 -170
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb +0 -181
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb +0 -232
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb +0 -187
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb +0 -176
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb +0 -215
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb +0 -173
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb +0 -172
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb +0 -183
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb +0 -170
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb +0 -212
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb +0 -202
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb +0 -22
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb +0 -28
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb +0 -26
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb +0 -27
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb +0 -52
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb +0 -51
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb +0 -44
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb +0 -98
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb +0 -56
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb +0 -292
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb +0 -508
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb +0 -56
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb +0 -40
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb +0 -94
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb +0 -198
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb +0 -129
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb +0 -33
- data/lib/active_support/vendor.rb +0 -28
- data/lib/activesupport.rb +0 -2
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
class Time
|
|
2
|
-
# Coerces the time to a string for JSON encoding.
|
|
3
|
-
#
|
|
4
|
-
# ISO 8601 format is used if ActiveSupport::JSON::Encoding.use_standard_json_time_format is set.
|
|
5
|
-
#
|
|
6
|
-
# ==== Examples
|
|
7
|
-
#
|
|
8
|
-
# # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = true
|
|
9
|
-
# Time.utc(2005,2,1,15,15,10).to_json
|
|
10
|
-
# # => "2005-02-01T15:15:10Z"
|
|
11
|
-
#
|
|
12
|
-
# # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = false
|
|
13
|
-
# Time.utc(2005,2,1,15,15,10).to_json
|
|
14
|
-
# # => "2005/02/01 15:15:10 +0000"
|
|
15
|
-
def as_json(options = nil)
|
|
16
|
-
if ActiveSupport::JSON::Encoding.use_standard_json_time_format
|
|
17
|
-
xmlschema
|
|
18
|
-
else
|
|
19
|
-
%(#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)})
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
#--
|
|
3
|
-
# Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org).
|
|
4
|
-
# All rights reserved.
|
|
5
|
-
|
|
6
|
-
# Permission is granted for use, copying, modification, distribution,
|
|
7
|
-
# and distribution of modified versions of this work as long as the
|
|
8
|
-
# above copyright notice is included.
|
|
9
|
-
#++
|
|
10
|
-
|
|
11
|
-
######################################################################
|
|
12
|
-
# BlankSlate provides an abstract base class with no predefined
|
|
13
|
-
# methods (except for <tt>\_\_send__</tt> and <tt>\_\_id__</tt>).
|
|
14
|
-
# BlankSlate is useful as a base class when writing classes that
|
|
15
|
-
# depend upon <tt>method_missing</tt> (e.g. dynamic proxies).
|
|
16
|
-
#
|
|
17
|
-
class BlankSlate
|
|
18
|
-
class << self
|
|
19
|
-
|
|
20
|
-
# Hide the method named +name+ in the BlankSlate class. Don't
|
|
21
|
-
# hide +instance_eval+ or any method beginning with "__".
|
|
22
|
-
def hide(name)
|
|
23
|
-
if instance_methods.include?(name.to_s) and
|
|
24
|
-
name !~ /^(__|instance_eval)/
|
|
25
|
-
@hidden_methods ||= {}
|
|
26
|
-
@hidden_methods[name.to_sym] = instance_method(name)
|
|
27
|
-
undef_method name
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def find_hidden_method(name)
|
|
32
|
-
@hidden_methods ||= {}
|
|
33
|
-
@hidden_methods[name] || superclass.find_hidden_method(name)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Redefine a previously hidden method so that it may be called on a blank
|
|
37
|
-
# slate object.
|
|
38
|
-
def reveal(name)
|
|
39
|
-
bound_method = nil
|
|
40
|
-
unbound_method = find_hidden_method(name)
|
|
41
|
-
fail "Don't know how to reveal method '#{name}'" unless unbound_method
|
|
42
|
-
define_method(name) do |*args|
|
|
43
|
-
bound_method ||= unbound_method.bind(self)
|
|
44
|
-
bound_method.call(*args)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
instance_methods.each { |m| hide(m) }
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
######################################################################
|
|
53
|
-
# Since Ruby is very dynamic, methods added to the ancestors of
|
|
54
|
-
# BlankSlate <em>after BlankSlate is defined</em> will show up in the
|
|
55
|
-
# list of available BlankSlate methods. We handle this by defining a
|
|
56
|
-
# hook in the Object and Kernel classes that will hide any method
|
|
57
|
-
# defined after BlankSlate has been loaded.
|
|
58
|
-
#
|
|
59
|
-
module Kernel
|
|
60
|
-
class << self
|
|
61
|
-
alias_method :blank_slate_method_added, :method_added
|
|
62
|
-
|
|
63
|
-
# Detect method additions to Kernel and remove them in the
|
|
64
|
-
# BlankSlate class.
|
|
65
|
-
def method_added(name)
|
|
66
|
-
result = blank_slate_method_added(name)
|
|
67
|
-
return result if self != Kernel
|
|
68
|
-
BlankSlate.hide(name)
|
|
69
|
-
result
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
######################################################################
|
|
75
|
-
# Same as above, except in Object.
|
|
76
|
-
#
|
|
77
|
-
class Object
|
|
78
|
-
class << self
|
|
79
|
-
alias_method :blank_slate_method_added, :method_added
|
|
80
|
-
|
|
81
|
-
# Detect method additions to Object and remove them in the
|
|
82
|
-
# BlankSlate class.
|
|
83
|
-
def method_added(name)
|
|
84
|
-
result = blank_slate_method_added(name)
|
|
85
|
-
return result if self != Object
|
|
86
|
-
BlankSlate.hide(name)
|
|
87
|
-
result
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def find_hidden_method(name)
|
|
91
|
-
nil
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
######################################################################
|
|
97
|
-
# Also, modules included into Object need to be scanned and have their
|
|
98
|
-
# instance methods removed from blank slate. In theory, modules
|
|
99
|
-
# included into Kernel would have to be removed as well, but a
|
|
100
|
-
# "feature" of Ruby prevents late includes into modules from being
|
|
101
|
-
# exposed in the first place.
|
|
102
|
-
#
|
|
103
|
-
class Module
|
|
104
|
-
alias blankslate_original_append_features append_features
|
|
105
|
-
def append_features(mod)
|
|
106
|
-
result = blankslate_original_append_features(mod)
|
|
107
|
-
return result if mod != Object
|
|
108
|
-
instance_methods.each do |name|
|
|
109
|
-
BlankSlate.hide(name)
|
|
110
|
-
end
|
|
111
|
-
result
|
|
112
|
-
end
|
|
113
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
#--
|
|
3
|
-
# Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org).
|
|
4
|
-
# All rights reserved.
|
|
5
|
-
|
|
6
|
-
# Permission is granted for use, copying, modification, distribution,
|
|
7
|
-
# and distribution of modified versions of this work as long as the
|
|
8
|
-
# above copyright notice is included.
|
|
9
|
-
#++
|
|
10
|
-
|
|
11
|
-
require 'blankslate'
|
|
12
|
-
|
|
13
|
-
######################################################################
|
|
14
|
-
# BlankSlate has been promoted to a top level name and is now
|
|
15
|
-
# available as a standalone gem. We make the name available in the
|
|
16
|
-
# Builder namespace for compatibility.
|
|
17
|
-
#
|
|
18
|
-
module Builder
|
|
19
|
-
BlankSlate = ::BlankSlate
|
|
20
|
-
end
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
#--
|
|
3
|
-
# Copyright 2004, 2005 by Jim Weirich (jim@weirichhouse.org).
|
|
4
|
-
# Copyright 2005 by Scott Barron (scott@elitists.net).
|
|
5
|
-
# All rights reserved.
|
|
6
|
-
#
|
|
7
|
-
# Permission is granted for use, copying, modification, distribution,
|
|
8
|
-
# and distribution of modified versions of this work as long as the
|
|
9
|
-
# above copyright notice is included.
|
|
10
|
-
#
|
|
11
|
-
# Much of this is taken from Jim's work in xmlbase.rb and xmlmarkup.rb.
|
|
12
|
-
# Documentation has also been copied and pasted and modified to reflect
|
|
13
|
-
# that we're building CSS here instead of XML. Jim is conducting the
|
|
14
|
-
# orchestra here and I'm just off in the corner playing a flute.
|
|
15
|
-
#++
|
|
16
|
-
|
|
17
|
-
# Provide a flexible and easy to use Builder for creating Cascading
|
|
18
|
-
# Style Sheets (CSS).
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
require 'builder/blankslate'
|
|
22
|
-
|
|
23
|
-
module Builder
|
|
24
|
-
|
|
25
|
-
# Create a Cascading Style Sheet (CSS) using Ruby.
|
|
26
|
-
#
|
|
27
|
-
# Example usage:
|
|
28
|
-
#
|
|
29
|
-
# css = Builder::CSS.new
|
|
30
|
-
#
|
|
31
|
-
# text_color = '#7F7F7F'
|
|
32
|
-
# preferred_fonts = 'Helvetica, Arial, sans_serif'
|
|
33
|
-
#
|
|
34
|
-
# css.comment! 'This is our stylesheet'
|
|
35
|
-
# css.body {
|
|
36
|
-
# background_color '#FAFAFA'
|
|
37
|
-
# font_size 'small'
|
|
38
|
-
# font_family preferred_fonts
|
|
39
|
-
# color text_color
|
|
40
|
-
# }
|
|
41
|
-
#
|
|
42
|
-
# css.id!('navbar') {
|
|
43
|
-
# width '500px'
|
|
44
|
-
# }
|
|
45
|
-
#
|
|
46
|
-
# css.class!('navitem') {
|
|
47
|
-
# color 'red'
|
|
48
|
-
# }
|
|
49
|
-
#
|
|
50
|
-
# css.a :hover {
|
|
51
|
-
# text_decoration 'underline'
|
|
52
|
-
# }
|
|
53
|
-
#
|
|
54
|
-
# css.div(:id => 'menu') {
|
|
55
|
-
# background 'green'
|
|
56
|
-
# }
|
|
57
|
-
#
|
|
58
|
-
# css.div(:class => 'foo') {
|
|
59
|
-
# background 'red'
|
|
60
|
-
# }
|
|
61
|
-
#
|
|
62
|
-
# This will yield the following stylesheet:
|
|
63
|
-
#
|
|
64
|
-
# /* This is our stylesheet */
|
|
65
|
-
# body {
|
|
66
|
-
# background_color: #FAFAFA;
|
|
67
|
-
# font_size: small;
|
|
68
|
-
# font_family: Helvetica, Arial, sans_serif;
|
|
69
|
-
# color: #7F7F7F;
|
|
70
|
-
# }
|
|
71
|
-
#
|
|
72
|
-
# #navbar {
|
|
73
|
-
# width: 500px;
|
|
74
|
-
# }
|
|
75
|
-
#
|
|
76
|
-
# .navitem {
|
|
77
|
-
# color: red;
|
|
78
|
-
# }
|
|
79
|
-
#
|
|
80
|
-
# a:hover {
|
|
81
|
-
# text_decoration: underline;
|
|
82
|
-
# }
|
|
83
|
-
#
|
|
84
|
-
# div#menu {
|
|
85
|
-
# background: green;
|
|
86
|
-
# }
|
|
87
|
-
#
|
|
88
|
-
# div.foo {
|
|
89
|
-
# background: red;
|
|
90
|
-
# }
|
|
91
|
-
#
|
|
92
|
-
class CSS < BlankSlate
|
|
93
|
-
|
|
94
|
-
# Create a CSS builder.
|
|
95
|
-
#
|
|
96
|
-
# out:: Object receiving the markup.1 +out+ must respond to
|
|
97
|
-
# <tt><<</tt>.
|
|
98
|
-
# indent:: Number of spaces used for indentation (0 implies no
|
|
99
|
-
# indentation and no line breaks).
|
|
100
|
-
#
|
|
101
|
-
def initialize(indent=2)
|
|
102
|
-
@indent = indent
|
|
103
|
-
@target = []
|
|
104
|
-
@parts = []
|
|
105
|
-
@library = {}
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def +(part)
|
|
109
|
-
_join_with_op! '+'
|
|
110
|
-
self
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def >>(part)
|
|
114
|
-
_join_with_op! ''
|
|
115
|
-
self
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def >(part)
|
|
119
|
-
_join_with_op! '>'
|
|
120
|
-
self
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def |(part)
|
|
124
|
-
_join_with_op! ','
|
|
125
|
-
self
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
# Return the target of the builder
|
|
129
|
-
def target!
|
|
130
|
-
@target * ''
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
# Create a comment string in the output.
|
|
134
|
-
def comment!(comment_text)
|
|
135
|
-
@target << "/* #{comment_text} */\n"
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
def id!(arg, &block)
|
|
139
|
-
_start_container('#'+arg.to_s, nil, block_given?)
|
|
140
|
-
_css_block(block) if block
|
|
141
|
-
_unify_block
|
|
142
|
-
self
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def class!(arg, &block)
|
|
146
|
-
_start_container('.'+arg.to_s, nil, block_given?)
|
|
147
|
-
_css_block(block) if block
|
|
148
|
-
_unify_block
|
|
149
|
-
self
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def store!(sym, &block)
|
|
153
|
-
@library[sym] = block.to_proc
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def group!(*args, &block)
|
|
157
|
-
args.each do |arg|
|
|
158
|
-
if arg.is_a?(Symbol)
|
|
159
|
-
instance_eval(&@library[arg])
|
|
160
|
-
else
|
|
161
|
-
instance_eval(&arg)
|
|
162
|
-
end
|
|
163
|
-
_text ', ' unless arg == args.last
|
|
164
|
-
end
|
|
165
|
-
if block
|
|
166
|
-
_css_block(block)
|
|
167
|
-
_unify_block
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
def method_missing(sym, *args, &block)
|
|
172
|
-
sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol)
|
|
173
|
-
if block
|
|
174
|
-
_start_container(sym, args.first)
|
|
175
|
-
_css_block(block)
|
|
176
|
-
_unify_block
|
|
177
|
-
elsif @in_block
|
|
178
|
-
_indent
|
|
179
|
-
_css_line(sym, *args)
|
|
180
|
-
_newline
|
|
181
|
-
return self
|
|
182
|
-
else
|
|
183
|
-
_start_container(sym, args.first, false)
|
|
184
|
-
_unify_block
|
|
185
|
-
end
|
|
186
|
-
self
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
# "Cargo culted" from Jim who also "cargo culted" it. See xmlbase.rb.
|
|
190
|
-
def nil?
|
|
191
|
-
false
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
private
|
|
195
|
-
def _unify_block
|
|
196
|
-
@target << @parts * ''
|
|
197
|
-
@parts = []
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
def _join_with_op!(op)
|
|
201
|
-
rhs, lhs = @target.pop, @target.pop
|
|
202
|
-
@target << "#{lhs} #{op} #{rhs}"
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
def _text(text)
|
|
206
|
-
@parts << text
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
def _css_block(block)
|
|
210
|
-
_newline
|
|
211
|
-
_nested_structures(block)
|
|
212
|
-
_end_container
|
|
213
|
-
_end_block
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
def _end_block
|
|
217
|
-
_newline
|
|
218
|
-
_newline
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
def _newline
|
|
222
|
-
_text "\n"
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
def _indent
|
|
226
|
-
_text ' ' * @indent
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
def _nested_structures(block)
|
|
230
|
-
@in_block = true
|
|
231
|
-
self.instance_eval(&block)
|
|
232
|
-
@in_block = false
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
def _start_container(sym, atts = {}, with_bracket = true)
|
|
236
|
-
selector = sym.to_s
|
|
237
|
-
selector << ".#{atts[:class]}" if atts && atts[:class]
|
|
238
|
-
selector << '#' + "#{atts[:id]}" if atts && atts[:id]
|
|
239
|
-
@parts << "#{selector}#{with_bracket ? ' {' : ''}"
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
def _end_container
|
|
243
|
-
@parts << "}"
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
def _css_line(sym, *args)
|
|
247
|
-
_text("#{sym.to_s.gsub('_','-')}: #{args * ' '};")
|
|
248
|
-
end
|
|
249
|
-
end
|
|
250
|
-
end
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
# The XChar library is provided courtesy of Sam Ruby (See
|
|
4
|
-
# http://intertwingly.net/stories/2005/09/28/xchar.rb)
|
|
5
|
-
|
|
6
|
-
# --------------------------------------------------------------------
|
|
7
|
-
|
|
8
|
-
# If the Builder::XChar module is not currently defined, fail on any
|
|
9
|
-
# name clashes in standard library classes.
|
|
10
|
-
|
|
11
|
-
module Builder
|
|
12
|
-
def self.check_for_name_collision(klass, method_name, defined_constant=nil)
|
|
13
|
-
if klass.instance_methods.include?(method_name.to_s)
|
|
14
|
-
fail RuntimeError,
|
|
15
|
-
"Name Collision: Method '#{method_name}' is already defined in #{klass}"
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
if ! defined?(Builder::XChar)
|
|
21
|
-
Builder.check_for_name_collision(String, "to_xs")
|
|
22
|
-
Builder.check_for_name_collision(Fixnum, "xchr")
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
######################################################################
|
|
26
|
-
module Builder
|
|
27
|
-
|
|
28
|
-
####################################################################
|
|
29
|
-
# XML Character converter, from Sam Ruby:
|
|
30
|
-
# (see http://intertwingly.net/stories/2005/09/28/xchar.rb).
|
|
31
|
-
#
|
|
32
|
-
module XChar # :nodoc:
|
|
33
|
-
|
|
34
|
-
# See
|
|
35
|
-
# http://intertwingly.net/stories/2004/04/14/i18n.html#CleaningWindows
|
|
36
|
-
# for details.
|
|
37
|
-
CP1252 = { # :nodoc:
|
|
38
|
-
128 => 8364, # euro sign
|
|
39
|
-
130 => 8218, # single low-9 quotation mark
|
|
40
|
-
131 => 402, # latin small letter f with hook
|
|
41
|
-
132 => 8222, # double low-9 quotation mark
|
|
42
|
-
133 => 8230, # horizontal ellipsis
|
|
43
|
-
134 => 8224, # dagger
|
|
44
|
-
135 => 8225, # double dagger
|
|
45
|
-
136 => 710, # modifier letter circumflex accent
|
|
46
|
-
137 => 8240, # per mille sign
|
|
47
|
-
138 => 352, # latin capital letter s with caron
|
|
48
|
-
139 => 8249, # single left-pointing angle quotation mark
|
|
49
|
-
140 => 338, # latin capital ligature oe
|
|
50
|
-
142 => 381, # latin capital letter z with caron
|
|
51
|
-
145 => 8216, # left single quotation mark
|
|
52
|
-
146 => 8217, # right single quotation mark
|
|
53
|
-
147 => 8220, # left double quotation mark
|
|
54
|
-
148 => 8221, # right double quotation mark
|
|
55
|
-
149 => 8226, # bullet
|
|
56
|
-
150 => 8211, # en dash
|
|
57
|
-
151 => 8212, # em dash
|
|
58
|
-
152 => 732, # small tilde
|
|
59
|
-
153 => 8482, # trade mark sign
|
|
60
|
-
154 => 353, # latin small letter s with caron
|
|
61
|
-
155 => 8250, # single right-pointing angle quotation mark
|
|
62
|
-
156 => 339, # latin small ligature oe
|
|
63
|
-
158 => 382, # latin small letter z with caron
|
|
64
|
-
159 => 376, # latin capital letter y with diaeresis
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
# See http://www.w3.org/TR/REC-xml/#dt-chardata for details.
|
|
68
|
-
PREDEFINED = {
|
|
69
|
-
38 => '&', # ampersand
|
|
70
|
-
60 => '<', # left angle bracket
|
|
71
|
-
62 => '>', # right angle bracket
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
# See http://www.w3.org/TR/REC-xml/#charsets for details.
|
|
75
|
-
VALID = [
|
|
76
|
-
0x9, 0xA, 0xD,
|
|
77
|
-
(0x20..0xD7FF),
|
|
78
|
-
(0xE000..0xFFFD),
|
|
79
|
-
(0x10000..0x10FFFF)
|
|
80
|
-
]
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
######################################################################
|
|
87
|
-
# Enhance the Fixnum class with a XML escaped character conversion.
|
|
88
|
-
#
|
|
89
|
-
class Fixnum
|
|
90
|
-
XChar = Builder::XChar if ! defined?(XChar)
|
|
91
|
-
|
|
92
|
-
# XML escaped version of chr
|
|
93
|
-
def xchr
|
|
94
|
-
n = XChar::CP1252[self] || self
|
|
95
|
-
case n when *XChar::VALID
|
|
96
|
-
XChar::PREDEFINED[n] or (n<128 ? n.chr : "&##{n};")
|
|
97
|
-
else
|
|
98
|
-
'*'
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
######################################################################
|
|
105
|
-
# Enhance the String class with a XML escaped character version of
|
|
106
|
-
# to_s.
|
|
107
|
-
#
|
|
108
|
-
class String
|
|
109
|
-
# XML escaped version of to_s
|
|
110
|
-
def to_xs
|
|
111
|
-
unpack('U*').map {|n| n.xchr}.join # ASCII, UTF-8
|
|
112
|
-
rescue
|
|
113
|
-
unpack('C*').map {|n| n.xchr}.join # ISO-8859-1, WIN-1252
|
|
114
|
-
end
|
|
115
|
-
end
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'builder/blankslate'
|
|
4
|
-
|
|
5
|
-
module Builder
|
|
6
|
-
|
|
7
|
-
# Generic error for builder
|
|
8
|
-
class IllegalBlockError < RuntimeError; end
|
|
9
|
-
|
|
10
|
-
# XmlBase is a base class for building XML builders. See
|
|
11
|
-
# Builder::XmlMarkup and Builder::XmlEvents for examples.
|
|
12
|
-
class XmlBase < BlankSlate
|
|
13
|
-
|
|
14
|
-
# Create an XML markup builder.
|
|
15
|
-
#
|
|
16
|
-
# out:: Object receiving the markup. +out+ must respond to
|
|
17
|
-
# <tt><<</tt>.
|
|
18
|
-
# indent:: Number of spaces used for indentation (0 implies no
|
|
19
|
-
# indentation and no line breaks).
|
|
20
|
-
# initial:: Level of initial indentation.
|
|
21
|
-
#
|
|
22
|
-
def initialize(indent=0, initial=0)
|
|
23
|
-
@indent = indent
|
|
24
|
-
@level = initial
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# Create a tag named +sym+. Other than the first argument which
|
|
28
|
-
# is the tag name, the arguments are the same as the tags
|
|
29
|
-
# implemented via <tt>method_missing</tt>.
|
|
30
|
-
def tag!(sym, *args, &block)
|
|
31
|
-
method_missing(sym.to_sym, *args, &block)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Create XML markup based on the name of the method. This method
|
|
35
|
-
# is never invoked directly, but is called for each markup method
|
|
36
|
-
# in the markup block.
|
|
37
|
-
def method_missing(sym, *args, &block)
|
|
38
|
-
text = nil
|
|
39
|
-
attrs = nil
|
|
40
|
-
sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol)
|
|
41
|
-
args.each do |arg|
|
|
42
|
-
case arg
|
|
43
|
-
when Hash
|
|
44
|
-
attrs ||= {}
|
|
45
|
-
attrs.merge!(arg)
|
|
46
|
-
else
|
|
47
|
-
text ||= ''
|
|
48
|
-
text << arg.to_s
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
if block
|
|
52
|
-
unless text.nil?
|
|
53
|
-
raise ArgumentError, "XmlMarkup cannot mix a text argument with a block"
|
|
54
|
-
end
|
|
55
|
-
_indent
|
|
56
|
-
_start_tag(sym, attrs)
|
|
57
|
-
_newline
|
|
58
|
-
_nested_structures(block)
|
|
59
|
-
_indent
|
|
60
|
-
_end_tag(sym)
|
|
61
|
-
_newline
|
|
62
|
-
elsif text.nil?
|
|
63
|
-
_indent
|
|
64
|
-
_start_tag(sym, attrs, true)
|
|
65
|
-
_newline
|
|
66
|
-
else
|
|
67
|
-
_indent
|
|
68
|
-
_start_tag(sym, attrs)
|
|
69
|
-
text! text
|
|
70
|
-
_end_tag(sym)
|
|
71
|
-
_newline
|
|
72
|
-
end
|
|
73
|
-
@target
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# Append text to the output target. Escape any markup. May be
|
|
77
|
-
# used within the markup brackets as:
|
|
78
|
-
#
|
|
79
|
-
# builder.p { |b| b.br; b.text! "HI" } #=> <p><br/>HI</p>
|
|
80
|
-
def text!(text)
|
|
81
|
-
_text(_escape(text))
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
# Append text to the output target without escaping any markup.
|
|
85
|
-
# May be used within the markup brackets as:
|
|
86
|
-
#
|
|
87
|
-
# builder.p { |x| x << "<br/>HI" } #=> <p><br/>HI</p>
|
|
88
|
-
#
|
|
89
|
-
# This is useful when using non-builder enabled software that
|
|
90
|
-
# generates strings. Just insert the string directly into the
|
|
91
|
-
# builder without changing the inserted markup.
|
|
92
|
-
#
|
|
93
|
-
# It is also useful for stacking builder objects. Builders only
|
|
94
|
-
# use <tt><<</tt> to append to the target, so by supporting this
|
|
95
|
-
# method/operation builders can use other builders as their
|
|
96
|
-
# targets.
|
|
97
|
-
def <<(text)
|
|
98
|
-
_text(text)
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# For some reason, nil? is sent to the XmlMarkup object. If nil?
|
|
102
|
-
# is not defined and method_missing is invoked, some strange kind
|
|
103
|
-
# of recursion happens. Since nil? won't ever be an XML tag, it
|
|
104
|
-
# is pretty safe to define it here. (Note: this is an example of
|
|
105
|
-
# cargo cult programming,
|
|
106
|
-
# cf. http://fishbowl.pastiche.org/2004/10/13/cargo_cult_programming).
|
|
107
|
-
def nil?
|
|
108
|
-
false
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
private
|
|
112
|
-
|
|
113
|
-
require 'builder/xchar'
|
|
114
|
-
def _escape(text)
|
|
115
|
-
text.to_xs
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def _escape_quote(text)
|
|
119
|
-
_escape(text).gsub(%r{"}, '"') # " WART
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def _newline
|
|
123
|
-
return if @indent == 0
|
|
124
|
-
text! "\n"
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
def _indent
|
|
128
|
-
return if @indent == 0 || @level == 0
|
|
129
|
-
text!(" " * (@level * @indent))
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
def _nested_structures(block)
|
|
133
|
-
@level += 1
|
|
134
|
-
block.call(self)
|
|
135
|
-
ensure
|
|
136
|
-
@level -= 1
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
end
|