Commit Graph

1963 Commits

Author SHA1 Message Date
wycats
9cfeefb637 Reorganized initializers a bit to enable better hooks for common cases without the need for Railtie. Specifically, the following hooks were added:
* before_configuration: this hook is run immediately after the Application class 
  comes into existence, but before the user has added any configuration. This is
  the appropriate place to set configuration for your plugin
* before_initialize: This is run after all of the user's configuration has completed,
  but before any initializers have begun (in other words, it runs right after
  config/environments/{development,production,test}.rb)
* after_initialize: This is run after all of the initializers have run. It is an
  appropriate place for forking in a preforking setup

Each of these hooks may be used via ActiveSupport.on_load(name) { }. In all these cases, the context inside the block will be the Application object. This means that for simple cases, you can use these hooks without needing to create a Railtie.
2010-05-15 06:09:07 -07:00
Carlos Antonio da Silva
c77794a924 Add missing require to with_options [#4601 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-15 14:54:07 +02:00
Neeraj Singh
a0621c1086 Better code formatting and proper line numbers for stack traces
[#4596 state:resolved]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-05-14 12:24:01 -07:00
Xavier Noria
2203c781a7 defines prev_(month|year) in Date and Time to ease transition to 1.9, and deprecates last_(month|year) 2010-05-12 23:04:17 +02:00
Xavier Noria
df508bd970 aliases Date#sunday to Date#end_of_week, for symmetry with existing alias Date#monday -> Date#beginning_of_week 2010-05-09 11:16:34 +02:00
Xavier Noria
636ffa1f08 Backports Date#>> from 1.9 so that calculations do the right thing around the calendar reform
Our next_month gives November for some late dates in September of 1582.
Related methods, last_*, and in general advance have the same issues.
This commit fixes those, see the test suite for expected behavior, which
we still run in 1.9 to ensure it matches as we do with other methods
defined in Date in 1.9.
2010-05-09 01:20:23 +02:00
Xavier Noria
53c1cd6cde let Time.time_with_datetime_fallback handle properly years in the range 0..138 2010-05-05 00:35:06 +02:00
Xavier Noria
6704d8c994 date/conversions needs time/calculations for (utc|local)_time 2010-05-03 23:11:09 +02:00
Xavier Noria
9e085a9f33 adds a comment explaining why BigDecimal#as_json returns a JSON string 2010-05-03 22:04:47 +02:00
Xavier Noria
34d5725167 fixes colon in previous YAML example 2010-05-03 15:25:28 +02:00
Norman Clarke
756f762cdb Fix transliteration rule example in docs. [#4526 state:resolved]
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-05-03 15:22:52 +02:00
José Valim
a76c7e68d5 Event should be aware if yielded block failed or not. 2010-05-02 22:45:54 +02:00
Justin George
731d4392e4 Change event namespace ordering to most-significant first [#4504 state:resolved]
More work still needs to be done on some of these names
(render_template.action_view and render_template!.action_view particularly)
but this allows (for example) /^sql/ to subscribe to all
the various ORMs without further modification

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-02 22:45:54 +02:00
Justin George
109d3ee38d Make notifications go off even when an error is raised, so that we capture the underlying performance data [#4505 state:resolved]
This is important when trying to keep track of many layers of interrelated calls

i.e.:

ActiveRecord::Base.transaction do
  MyModel.find(1) #ActiveRecord::NotFound
end # should capture the full time until the error propagation

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-02 22:45:53 +02:00
Santiago Pastorino
02028e529c Missing require added make pass activesupport/test/json/encoding_test.rb in isolation
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-05-02 22:05:40 +02:00
Xavier Noria
7aaabea517 let Date.yesterday and Date.tomorrow be based on Date.current rather than Date.today 2010-05-02 01:12:31 +02:00
Norman Clarke
f0e754e713 Delegate Inflector.transliterate to i18n. [#4508 state:resolved]
Ancillary changes: Moved Chars#normalize into a class method; removed
unused UTF_PAT constant.

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-04-30 16:18:12 +02:00
José Valim
2e9af3638d Move several configuration values from Hash to ActiveSupport::XmlMini, which both Hash and Array depends on.
Also, refactored ActiveModel serializers to just use ActiveSupport::XmlMini.to_tag. As consequence, if a serialized attribute is an array or a hash, it's not encoded as yaml, but as a hash or array.
2010-04-29 12:42:42 +02:00
Neeraj Singh
580dd3b052 array.to_xml should be able to handle all types of data elements [#4490 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-04-29 09:04:34 +02:00
José Valim
1b816d5024 The rake task :environment now loads config/environment.rb instead of initializing the application on its own. This fixes [#4492 state:resolved] and also avoids the application being initialized twice in some rake tasks. 2010-04-29 08:39:52 +02:00
Jeremy Kemper
4e75cc59e7 object_id may be negative, producing an invalid symbol. h/t Markus Schirp 2010-04-28 15:20:35 -07:00
Brian Durand
ee51b51b60 ActiveSupport::Cache refactoring
All Caches

* Add default options to initializer that will be sent to all read, write, fetch, exist?, increment, and decrement
* Add support for the :expires_in option to fetch and write for all caches. Cache entries are stored with the create timestamp and a ttl so that expiration can be handled independently of the implementation.
* Add support for a :namespace option. This can be used to set a global prefix for cache entries.
* Deprecate expand_cache_key on ActiveSupport::Cache and move it to ActionController::Caching and ActionDispatch::Http::Cache since the logic in the method used some Rails specific environment variables and was only used by ActionPack classes. Not very DRY but there didn't seem to be a good shared spot and ActiveSupport really shouldn't be Rails specific.
* Add support for :race_condition_ttl to fetch. This setting can prevent race conditions on fetch calls where several processes try to regenerate a recently expired entry at once.
* Add support for :compress option to fetch and write which will compress any data over a configurable threshold.
* Nil values can now be stored in the cache and are distinct from cache misses for fetch.
* Easier API to create new implementations. Just need to implement the methods read_entry, write_entry, and delete_entry instead of overwriting existing methods.
* Since all cache implementations support storing objects, update the docs to state that ActiveCache::Cache::Store implementations should store objects. Keys, however, must be strings since some implementations require that.
* Increase test coverage.
* Document methods which are provided as convenience but which may not be universally available.

MemoryStore

* MemoryStore can now safely be used as the cache for single server sites.
* Make thread safe so that the default cache implementation used by Rails is thread safe. The overhead is minimal and it is still the fastest store available.
* Provide :size initialization option indicating the maximum size of the cache in memory (defaults to 32Mb).
* Add prune logic that removes the least recently used cache entries to keep the cache size from exceeding the max.
* Deprecated SynchronizedMemoryStore since it isn't needed anymore.

FileStore

* Escape key values so they will work as file names on all file systems, be consistent, and case sensitive
* Use a hash algorithm to segment the cache into sub directories so that a large cache doesn't exceed file system limits.
* FileStore can be slow so implement the LocalCache strategy to cache reads for the duration of a request.
* Add cleanup method to keep the disk from filling up with expired entries.
* Fix increment and decrement to use file system locks so they are consistent between processes.

MemCacheStore

* Support all keys. Previously keys with spaces in them would fail
* Deprecate CompressedMemCacheStore since it isn't needed anymore (use :compress => true)

[#4452 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-27 11:13:37 -07:00
Xavier Noria
1d63129eff use ordinary syntax for options to be well-formed in 1.8 2010-04-27 02:36:34 -07:00
Jeremy Kemper
c1d7327071 JSON: encode objects that don't have a native JSON representation using to_hash, if available, instead of instance_values (the old fallback) or to_s (other encoders' default). Encode BigDecimal and Regexp encode as strings to conform with other encoders. Try to transcode non-UTF-8 strings. 2010-04-26 19:55:39 -07:00
Santiago Pastorino
76d6a99364 Use explicit source encoding rather than forced UTF-8 from US-ASCII.
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-26 14:45:23 -07:00
Anil Wadghule
53c13f1aca Use Config::CONFIG['host_os'] instead of RUBY_PLATFORM [#4477 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-26 11:12:52 -07:00
Cezary Baginski
490a3335d5 Action Pack: fix tests with -K*, work around Ruby 1.9.1 constant lookup.
[#4473 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-25 17:00:20 -07:00
David Chelimsky
864bd9c21f allow unsubscribe by name or subscription [#4433 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-24 22:06:24 -07:00
Santiago Pastorino
19cecc907f HWIA relies on Hash#symbolize_keys and #stringify_keys extensions.
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-22 11:02:15 -07:00
Jeremy Kemper
c976784381 Change HWIA#stringify_keys to return a HWIA not a Hash 2010-04-22 10:07:33 -07:00
Jeremy Kemper
d692e6be30 Restore HWIA#stringify_keys! and update changelog 2010-04-22 10:00:23 -07:00
Santiago Pastorino
2472f1026a HWIA delegates to to_hash symbolize_keys and stringify_keys and bang methods are not in the api
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-22 09:06:44 -07:00
José Valim
4163ccec23 Clean up the config object in ActionPack. Create config_accessor which just delegates to the config object, reducing the number of deprecations and add specific tests. 2010-04-22 12:00:13 +02:00
Daniel Neighman
726b5d7984 updates String#to_(date|date_time|time) to return nil for blank strings 2010-04-21 16:54:33 -07:00
Santiago Pastorino
d1911a0707 TimeZones lazy load
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-20 21:40:24 -07:00
Jeremy Kemper
9934738ed5 Switch to TimezoneProxy for later support of deferred TZ loading 2010-04-20 10:54:37 -07:00
Santiago Pastorino
a90a076613 Missing requires added
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-04-20 07:45:54 -07:00
Xavier Noria
bb19f20876 much complete rdoc for String#ord 2010-04-19 05:04:18 -07:00
Xavier Noria
0f0b40d3b6 revises the rdoc of String#ord 2010-04-19 05:04:18 -07:00
Jeremy Kemper
03aa7877f7 MemoryStore#read_multi(*keys) for dev-mode compatibility with memcache store 2010-04-19 00:19:10 -07:00
Santiago Pastorino
b7ea64a86c remove code for Ruby < 1.8.7 2010-04-18 03:46:01 -03:00
Xavier Noria
afcd252205 removes code written for Ruby < 1.8.7 2010-04-17 15:16:38 -07:00
Sven Fuchs
9a3a4d6aef Make i18n fallbacks configurable and fallback to the default locale by default in production [#4428 state:resolved]
Allows to configure locale fallbacks through config.i18n.fallbacks. The default setting
config.i18n.fallbacks = true in production.rb will make I18n.t lookup fallback to the
I18n.default_locale if a translation could not be found for the current or given locale.

config.fallbacks = true

config.fallbacks.map = { :ca => :es }
config.fallbacks.defaults = [:'es-ES', :es]

config.fallbacks = [:'es-ES', :es]

config.fallbacks = { :ca => :es }

config.fallbacks = [:'es-ES', :es, { :ca => :es }]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2010-04-17 19:26:46 +01:00
Aaron Patterson
dc94d813e2 fixing invalid yaml [#4418 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-16 14:19:31 -07:00
Mislav Marohnić
8a91ccf976 add missing requires to Rescuable and RouteSet [#4415 state:committed]
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-04-16 06:11:38 -07:00
Santiago Pastorino
a0cc94b32e utc_offset returns nil for unknown zones
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-14 21:15:15 -07:00
Santiago Pastorino
7fa6c16b70 Added missing require and delete unused one on proc.rb 2010-04-13 13:33:16 -03:00
Norman Clarke
dceef0828a Improve reliability of Inflector.transliterate. [#4374 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-12 23:19:39 -07:00
Joe Van Dyk
ccf33660a1 Avoid unnecessary allocations in Inflector.underscore [#3626 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-04-12 11:09:49 +02:00
wycats
76e0a9eb5b Not using class_eval wasn't adding clarity here 2010-04-10 16:16:31 -07:00