Commit Graph

3752 Commits

Author SHA1 Message Date
Mike Moore
4894eef448 Create ActiveSupport::Testing::ConstantLookup
AS::TC::ConstantLookup walks the test's name to find the constant it is describing.
This additional lookup logic is needed to better support minitest's spec DSL.
2012-09-24 13:44:49 -06:00
Adam Stankiewicz
bc87712bc6 String.to_time documentation along examples. 2012-09-24 16:11:29 +02:00
Santiago Pastorino
008eaebb56 Raise the same exception the code is handling 2012-09-21 19:05:12 -03:00
José Corcuera
66bc017849 Update examples in AS::Concern to use correct scope syntax. [ci skip] 2012-09-21 12:29:44 -05:00
Vijay Dev
3b7947ea31 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	actionmailer/lib/action_mailer/base.rb
	activesupport/lib/active_support/configurable.rb
	activesupport/lib/active_support/core_ext/module/deprecation.rb
	guides/source/action_controller_overview.md
	guides/source/active_support_core_extensions.md
	guides/source/ajax_on_rails.textile
	guides/source/association_basics.textile
	guides/source/upgrading_ruby_on_rails.md

While resolving conflicts, I have chosen to ignore changes done in
docrails at some places - these will be most likely 1.9 hash syntax
changes.
2012-09-21 22:49:20 +05:30
Carlos Antonio da Silva
ed05e92239 Update delegate docs with new hash syntax [ci skip] 2012-09-20 18:51:14 -03:00
Carlos Antonio da Silva
1eef814e7a Add changelog entry and docs about class delegation using the symbol :class
See #7613. [ci skip]
2012-09-20 18:50:53 -03:00
Jeremy Kemper
0a7b1319d3 Merge pull request #7613 from marcandre/delegate_to_class
Nice and easy delegation to the class
2012-09-20 11:19:47 -07:00
Jo Liss
920abaa52d Fix indentation and update documentation for Array#wrap for Ruby 1.9 2012-09-20 18:29:12 +02:00
kennyj
105cb3d9e3 Fix #6962. AS::TimeWithZone#strftime responds incorrectly to %:z and %::z format strings. 2012-09-20 00:51:28 +09:00
Francesco Rodriguez
255cefbff4 fix Hash#slice code example [ci skip] 2012-09-18 22:13:49 -05:00
Jeremy Kemper
aebbd4bb4d No need to defensively work jobs in another thread 2012-09-18 15:22:24 -07:00
gregolsen
da26dfbefd Date.beginning_of_week thread local and beginning_of_week application config option added (default is Monday) 2012-09-18 17:18:19 +03:00
Jeremy Kemper
b881be7331 Always run jobs using a consumer, even in synchronous & test queues, to ensure shared behavior. 2012-09-16 22:37:47 -07:00
Francesco Rodriguez
d71d5ba71f update AS docs [ci skip] 2012-09-17 00:22:18 -05:00
Francesco Rodriguez
c1c9f1c7b9 fix AS::OrderedOptions documentation [ci skip] 2012-09-17 00:12:11 -05:00
Larry Lv
1efe30ebce set up config_accessor with a default value by block
* ActiveSupport::Configurable should allow config_accessor to take
  default value by block, just like cattr_accessor.

    class User
      include ActiveSupport::Configurable
      config_accessor :hair_colors do
        [:brown, :black, :blonde, :red]
      end
    end

    User.hair_colors # => [:brown, :black, :blonde, :red]

* remove trailing whitespaces in configurable.rb and its test file.

* Update ActiveSupport CHANGELOG.
2012-09-17 09:14:21 +08:00
Rafael Mendonça França
1b7894c95b Merge pull request #7643 from steveklabnik/deprecate_silence
Deprecate ActiveSupport::Benchmarkable#silence.
2012-09-15 05:57:08 -07:00
Steve Klabnik
afe9654297 Improve Process::Status#to_json
Because Process::Status has no instance_variables, the
ActiveSupport version of #to_json produces {}, which isn't good.

Therefore, we implement our own #as_json, which makes it useful
again.

Fixes #4857
2012-09-15 16:35:34 +04:00
Francesco Rodriguez
00fef0a76c update AS/values and AS/xml_mini docs [ci skip] 2012-09-14 23:02:37 -05:00
Francesco Rodriguez
b0e943381b update AS/notifications and AS/testing docs [ci skip] 2012-09-14 22:57:38 -05:00
Francesco Rodriguez
d48163c65d update AS/log_subscriber and AS/multibyte docs [ci skip] 2012-09-14 22:54:39 -05:00
Francesco Rodriguez
7ef21d80a3 update AS/json docs [ci skip] 2012-09-14 22:47:21 -05:00
Francesco Rodriguez
5ea3f284a4 update AS/inflector docs [ci skip] 2012-09-14 22:44:06 -05:00
Francesco Rodriguez
8673c2eefb update AS/deprecation docs [ci skip] 2012-09-14 22:28:56 -05:00
Francesco Rodriguez
f210a369d1 add :nodoc: to AS::Autoload#extended [ci skip] 2012-09-14 21:31:49 -05:00
Steve Klabnik
ed2fea908a Deprecate ActiveSupport::Benchmarkable#silence.
Due to its lack of thread safety, we're deprecating this, and it
will be removed in Rails 4.1.

Fixes #4060.
2012-09-15 06:19:55 +04:00
Santiago Pastorino
8577687fcb Move queue classes to ActiveSupport 2012-09-14 14:10:00 -07:00
Arun Agrawal
948a055f23 warning removed: shadowing outer local variable - message 2012-09-14 10:19:10 +05:30
Pranas Kiziela
54575d8797 Allow passing block to deep_merge and deep_merge!
Hash#merge accepts block that you can use to customize how hash values
are merged. This change makes merge and deep_merge compatible.
2012-09-13 23:01:18 +03:00
Rafael Mendonça França
8692db59af Copy-edit deprecation relared documentation [ci skip] 2012-09-13 14:02:18 -03:00
Piotr Niełacny
71993c6f97 Change ActiveSupport::Deprecation to class.
ActiveSupport::Deprecation is now a class rather than a module. You can
get instance of ActiveSupport::Deprecation calling #instance method.

  ActiveSupport::Deprecation.instance

But when you need to get new object od ActiveSupport::Deprecation you
need to just call #new.

  @instance = ActiveSupport::Deprecation.new

Since you can create a new object, you can change the version and the
name of the library where the deprecator concerned.

  ActiveSupport::Deprecation.new('2.0', 'MyGem')

If you need use another deprecator instance you can select it in the
options of deprecate method.

  deprecate :method, :deprecator => deprecator_instance

Documentation has been updated.
2012-09-13 08:42:00 +02:00
Robert Pankowecki
2c690a0f5b extend ActiveSupport::Deprecation with self, allow other objects to extend/include it also.
test local deprecation

deprecator object

Test ActiveSupport::Deprecation when included
2012-09-13 08:42:00 +02:00
Francesco Rodriguez
68a8a298d6 fix AS/core_ext examples [ci skip] 2012-09-12 19:41:03 -05:00
Francesco Rodriguez
794a70f944 update AS/core_ext docs [ci skip] 2012-09-12 18:40:18 -05:00
Francesco Rodriguez
f4e180578c update some AS code examples to 1.9 hash syntax [ci skip] 2012-09-12 13:47:49 -05:00
Marc-Andre Lafortune
ad5f18e6e9 Nice and easy delegation to the class 2012-09-11 23:05:19 -04:00
Kalys Osmonov
6b2a24c3bd &#39 dates back to SGML when &#x27 was introduced in HTML 4.0 2012-09-09 19:48:32 +06:00
Bogdan Gusiev
6777f7b75d AS::Callbacks: deprecate monkey patch of object callbacks 2012-09-07 14:42:31 +03:00
Aaron Renner
8b0d5bfc77 Fixed around callback with lambda example
This is a follow up to issue #7535
2012-09-06 08:21:47 -06:00
Xavier Noria
2ed325a3e9 we already have the module objects, do not constantize
I have also chosen a variable name that matches the
parameter in the definition of load_missing_constant.
2012-09-06 14:11:04 +02:00
Xavier Noria
021cb85b95 restores awesome comment
Those who say source code should be without comments lie.
2012-09-06 13:43:49 +02:00
Xavier Noria
3ee191fd95 no more const_missing combinatorics
Basically, const_missing had a loop to try parent namespaces
if the constant lookup failed, but at the same time delegated
to load_missing_constant which in turn also walks up parent
namespaces calling const_missing by hand. In the case of missing
constants this results in repeated work in some funky nested way.
2012-09-06 13:39:23 +02:00
Leo Cassarani
edab820d9e Extend HashWithIndifferentAccess#update to take an optional block
When a block is passed into the method, it will be invoked for each
duplicated key, with the key in question and the two values as
arguments. The value for the duplicated key in the receiver will
be set to the return value of the block.

This behaviour matches Ruby's long-standing implementation of
Hash#update and is intended to provide a more consistent interface.

HashWithIndifferentAccess#merge is also affected by the change, as it
uses #update internally.
2012-09-05 00:59:29 +01:00
Xavier Noria
5388fee718 revised the exception message "Expected #{file_path} to define #{qualified_name}"
Users need to know the ultimate problem here is that AS was
trying to autoload a constant and it failed.
2012-09-04 01:24:09 +02:00
Vijay Dev
a667499103 Merge branch 'master' of github.com:lifo/docrails 2012-09-01 23:51:23 +05:30
Vijay Dev
831b814a87 copy edits [ci skip] 2012-09-01 23:49:55 +05:30
Jeff Shantz
67fa3e8ddf Expand documentation for change() method in Time, Date, and DateTime 2012-08-29 22:48:46 -04:00
Xavier Noria
3b2c42cb56 fixes a regexp
We need to anchor to remove the extension. In addition to
be the correct way to do that, files in ~/.rbenv get that
.rb removed, so it is a real source of bugs, as reported in

b33700f558 (commitcomment-1781840)
2012-08-29 17:42:43 +02:00
Xavier Noria
b33700f558 detect circular constant autoloading
Nowadays circular autoloads do not work, but the user gets a NameError
that says some constant is undefined. That's puzzling, because he is
normally trying to autoload a constant he knows can be autoloaded.
With this check we can give a better error message.
2012-08-28 20:34:39 +02:00
Xavier Noria
db8ff15a49 fixes a bug in dependencies.rb
loaded stores file names without the .rb extension, but search_for_file
returns file names with the extension.

The solution is hackish, but this file needs a revamp.
2012-08-28 17:19:39 +02:00
Rafael Mendonça França
ea84b0c618 Remove unused variable 2012-08-26 03:56:19 -03:00
Rafael Mendonça França
a1d18ed9cf Merge pull request #7029 from panthomakos/date-and-time
Refactored common date and time calculations.
2012-08-25 18:26:07 -07:00
Xavier Noria
dfb5898b6d simplifies yet another regexp 2012-08-25 03:10:38 +02:00
Xavier Noria
4fbd350dca instead of returning $& if =~ succeeds, use String#[] 2012-08-25 03:08:45 +02:00
Xavier Noria
148e33058c simplifies a regexp
We simplify two things here: First since * is greedy it is enough to go
look for the rightmost ::, no need to ask the regexp engine to match the
rest of the string since we are not validating anything, only capturing.
The second simplification comes from using a look-ahead assertion, that
allows us to have the capture in $&, thus removing the need of a group.
2012-08-25 02:56:59 +02:00
Xavier Noria
6a70f2dd6b simplifies a regexp
The new regexp has less work to do, we anchor a fixed string at the end
and need no group.
2012-08-24 01:17:00 +02:00
José Valim
891043d5d0 Revert "Use join without default separator"
This reverts commit b0ab8dc0b2b0f580ffe5ac9ff57fd13152e18577
because it was removing the contents of the message when we
did not have any tag. A test case is also committed.
2012-08-23 11:01:55 -03:00
Xavier Noria
8b16ff64f2 revises a brittle test in Active Support
The revised test assumed that the default permissions of a file
matched the umask of the process, but in the general case that
depends also on the file system. This test was failing in the
/vagrant shared folder of Rails development boxes.
2012-08-22 23:10:33 +02:00
Rafael Mendonça França
d65a15dca6 Merge pull request #3578 from amatsuda/remove_j_alias_for_json_escape
Remove j alias for ERB::Util.json_escape
2012-08-21 14:18:38 -07:00
José Valim
2801786e1a Get rid of config.preload_frameworks in favor of config.eager_load_namespaces
The new option allows any Ruby namespace to be registered and set
up for eager load. We are effectively exposing the structure existing
in Rails since v3.0 for all developers in order to make their applications
thread-safe and CoW friendly.
2012-08-21 14:47:19 -03:00
José Valim
a1687e48cb Make ActiveSupport::Autoload local
Previously, ActiveSupport::Autoload was global and reserved
for usage inside Rails. This pull request makes it local,
fixes its test (they were not being run because its file
was named wrongly) and make it part of Rails public API.
2012-08-21 14:46:12 -03:00
Xavier Noria
f298481b36 Revert "removes unused optional argument in AS::Dependencies::Loadable#load"
This argument is there because that's the signature of Kernel#load.

This reverts commit bf3fa34ed0aa33bca3aac9c96165662fe864a7b4.
2012-08-20 23:59:36 +02:00
Xavier Noria
bf3fa34ed0 removes unused optional argument in AS::Dependencies::Loadable#load 2012-08-20 23:55:28 +02:00
Xavier Noria
937a825921 removes the second argument of the AS const_missing hook
Ruby does not pass the nesting to const_missing (unfortunately).
That second argument was there in case that changed, Yehuda
sent a patch to MRI

    http://bugs.ruby-lang.org/issues/2740

but there is not much movement there and Matz told me in
Amsterdam there was no immediate plan to pass the nesting.
So let's go back to implement what happens now, and if
in the future we get the nesting then we will adapt this.

Double-checked this with Mr Katz.
2012-08-19 23:55:54 +02:00
Xavier Noria
30f091b35a no need for AS::Dependencies.(hook!|unhook!) to return anything in particular 2012-08-19 21:33:58 +02:00
Guillermo Iguaran
82663306f4 Replace deprecated memcache-client gem with dalli in ActiveSupport::Cache::MemCacheStore
memcache-client was deprecated in favour of dalli in 2010.
2012-08-17 22:22:55 -05:00
Eric Saxby
6fe36ba585 Evented notifications take priority over Timed notifications
In cases where a notification subscriber includes methods to support
both Evented and Timed events, Evented should take priority over Timed.
This allows subscribers to be backwards compatible (older Rails only
allows Timed events) while defaulting to newer behavior.
2012-08-11 17:39:20 -07:00
Carlos Antonio da Silva
47b4d13c8d Ensure I18n format values always have precedence over defaults
Always merge I18n format values, namespaced or not, over the default
ones, to ensure I18n format defaults will have precedence over our
namespaced values.

Precedence should happen like this:

    default :format
    default :namespace :format
    i18n    :format
    i18n    :namespace :format

Because we cannot allow our namespaced default to override a I18n
:format config - ie precision in I18n :format should always have higher
precedence than our default precision for a particular :namespace.

Also simplify default format options logic.
2012-08-11 00:20:19 -03:00
Carlos Antonio da Silva
a9dccda936 Fallback to :en locale instead of handling a constant with defaults
Action Pack already comes with a default locale fine for :en, that is
always loaded. We can just fallback to this locale for defaults, if
values for the current locale cannot be found.

Closes #4420, #2802, #2890.
2012-08-11 00:20:19 -03:00
Carlos Antonio da Silva
b6e00c6764 Bring back changelog entries for Active Support
Removed in 0228a73b1094a3e19ad291d2ce4789890c09578a, pull request #7310.
2012-08-11 00:16:42 -03:00
Rafael Mendonça França
7ef56d6419 Add back missing require 2012-08-07 20:04:29 -03:00
Rafael Mendonça França
82fe116051 Fix the deprecation horizon. [ci skip] 2012-08-07 19:39:38 -03:00
Erich Menge
83f2ffcf43 Deprecate ActiveSupport::JSON::Variable
Reason: ActiveSupport::JSON::Variable is not used anymore internally. It
was deprecated in 3-2-stable but we reverted all the deprecation for
point releases.

See #6536 and #6546.
Conflicts:
	activesupport/lib/active_support/json/variable.rb
2012-08-07 19:36:08 -03:00
Xavier Noria
2f58795e78 defines String#indent [closes #7263] [Xavier Noria & Ace Suares] 2012-08-07 16:57:28 +02:00
Rafael Mendonça França
bf39026d56 Merge pull request #7272 from lexmag/string_inquirer
Add AS::StringInquirer#respond_to? method
2012-08-06 09:24:37 -07:00
Aaron Patterson
3a91d44eff let ruby decompose the tuples in the iterator 2012-08-06 08:26:45 -07:00
Aleksey Magusev
a1beec1de0 Add AS::StringInquirer#respond_to? method
Consistently with #method_missing
2012-08-06 16:59:12 +04:00
Xavier Noria
447b6a4e67 removes usage of Object#in? from the code base (the method remains defined by Active Support)
Selecting which key extensions to include in active_support/rails
made apparent the systematic usage of Object#in? in the code base.
After some discussion in

    5ea6b0df9a

we decided to remove it and use plain Ruby, which seems enough
for this particular idiom.

In this commit the refactor has been made case by case. Sometimes
include? is the natural alternative, others a simple || is the
way you actually spell the condition in your head, others a case
statement seems more appropriate. I have chosen the one I liked
the most in each case.
2012-08-06 00:30:02 +02:00
Pan Thomakos
b530fd1083 Refactored common date and time calculations.
* Added the `DateAndTime::Calculations` module that is included in Time
  and Date. It houses common calculations to reduce duplicated code.
* Simplified and cleaned-up the calculation code.
* Removed duplication in tests by adding a behavior module for shared
  tests. I also added some missing tests.
2012-08-04 16:13:03 -07:00
Vijay Dev
3d3fa165e4 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	activemodel/lib/active_model/secure_password.rb
	activerecord/lib/active_record/associations/collection_proxy.rb
2012-08-04 15:18:35 +05:30
Xavier Noria
077372b20d load active_support/deprecation in active_support/rails 2012-08-02 21:59:23 +02:00
Xavier Noria
4aee8dd486 load active_support/core_ext/module/delegation in active_support/rails 2012-08-02 21:59:23 +02:00
Xavier Noria
5e1b92044c load active_support/core_ext/class/attribute in active_support/rails 2012-08-02 21:59:23 +02:00
Xavier Noria
64bc8447c2 load active_support/concern in active_support/rails 2012-08-02 21:59:23 +02:00
Xavier Noria
47396a9db8 load active_support/dependencies/autoload in active_support/rails 2012-08-02 21:59:23 +02:00
Xavier Noria
5ea6b0df9a load active_support/core_ext/object/inclusion in active_support/rails 2012-08-02 21:59:22 +02:00
Xavier Noria
8f58d6e507 load active_support/core_ext/object/blank in active_support/rails 2012-08-02 21:59:22 +02:00
Xavier Noria
1a7b2e8fad defines a private require-hub active_support/rails
This is a private place to put those AS features that are used
by every component. Nowadays we cherry-pick individual files
wherever they are used, but that it is not worth the effort
for stuff that is going to be loaded for sure sooner or later,
like blank?, autoload, concern, etc.
2012-08-02 21:59:22 +02:00
Santiago Pastorino
b6ab441772 html_escape should escape single quotes
https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content
Closes #7215
2012-07-31 22:26:52 -03:00
José Valim
13af5aceff Merge pull request #7197 from davidcelis/i18n_inflector
Make ActiveSupport::Inflector locale aware and multilingual
2012-07-31 05:46:25 -07:00
David Celis
7db0b073fe Make ActiveSupport::Inflector locale aware and multilingual
The Inflector is currently not very supportive of internationalized
websites. If a user wants to singularize and/or pluralize words based on
any locale other than English, they must define each case in locale
files. Rather than create large locale files with mappings between
singular and plural words, why not allow the Inflector to accept a
locale?

This patch makes ActiveSupport::Inflector locale aware and uses `:en`` unless
otherwise specified. Users will still be provided a list of English (:en)
inflections, but they may additionally define inflection rules for other
locales. Each list is kept separately and permanently. There is no reason to
limit users to one list of inflections:

    ActiveSupport::Inflector.inflections(:es) do |inflect|
      inflect.plural(/$/, 's')
      inflect.plural(/([^aeéiou])$/i, '\1es')
      inflect.plural(/([aeiou]s)$/i, '\1')
      inflect.plural(/z$/i, 'ces')
      inflect.plural(/á([sn])$/i, 'a\1es')
      inflect.plural(/é([sn])$/i, 'e\1es')
      inflect.plural(/í([sn])$/i, 'i\1es')
      inflect.plural(/ó([sn])$/i, 'o\1es')
      inflect.plural(/ú([sn])$/i, 'u\1es')

      inflect.singular(/s$/, '')
      inflect.singular(/es$/, '')

      inflect.irregular('el', 'los')
    end

    'ley'.pluralize(:es)   # => "leyes"
    'ley'.pluralize(:en)   # => "leys"
    'avión'.pluralize(:es) # => "aviones"
    'avión'.pluralize(:en) # => "avións"

A multilingual Inflector should be of use to anybody that is tasked with
internationalizing their Rails application.

Signed-off-by: David Celis <david@davidcelis.com>
2012-07-30 21:49:18 -07:00
José Valim
8601f733af Revert "DRY class_attribute code"
class_attribute is a building block and using define_method
can be much slower for such basic method definitions.

This reverts commit d59208d7032e2be855a89ad8d4685cc08dd7cdb3.
2012-07-30 08:19:15 +02:00
Aaron Patterson
af0a9f9eef added live responses which can be written and read in separate threads 2012-07-29 21:43:05 -07:00
Aleksandr Zykov
d59208d703 DRY class_attribute code 2012-07-29 22:33:39 +06:00
Francesco Rodriguez
0340493694 update to_param docs [ci skip] 2012-07-27 21:02:08 -05:00
David Heinemeier Hansson
04998cd0c9 Add Object#try! with the old NoMethodError raising behavior 2012-07-27 12:33:02 -05:00
David Heinemeier Hansson
99ea1a875b will now return nil instead of raise a NoMethodError if the receiving object does not implement the method 2012-07-27 12:22:38 -05:00
Anatoly Makarevich
103a31391b fix typo in documentation 2012-07-26 22:44:36 +04:00
Francesco Rodriguez
12ae9d618e fixing :nodoc:s in AS::JSON::Encoding 2012-07-21 16:38:02 -05:00
Rafael Mendonça França
f5d0e3d760 +"foo"+ doesn't generate code tag [ci skip] 2012-07-21 14:12:01 -03:00
Rafael Mendonça França
f1a317b8e9 Lets be consistent with whitespaces at documentation 2012-07-21 14:05:19 -03:00
Xavier Noria
db4fdb58ef makes a pass over the API of ActiveSupport::HashWithIndifferentAccess 2012-07-21 13:03:19 +02:00
Xavier Noria
98f4aee8da Hash#fetch(fetch) is not the same as doing hash[key] 2012-07-21 08:04:37 +02:00
Piotr Niełacny
b0ab8dc0b2 Use join without default separator
Use lstrip method
2012-07-20 08:16:58 +02:00
Aaron Patterson
e482100d6e Revert "Merge pull request #7084 from LTe/logger_default_separator"
This reverts commit c08f30ff5fcda7e07cd9275a073acb2091e4b3f7, reversing
changes made to e243a8a32eb4c8777f07ca4b974bd7e38d9477d3.
2012-07-18 13:32:21 -07:00
Piotr Niełacny
dc97a9a9dd Don't use default separator
When the default separator is set logger will create incorrect output
2012-07-18 09:44:45 +02:00
Vijay Dev
a80e1e437e Merge branch 'master' of github.com:lifo/docrails 2012-07-15 19:36:19 +05:30
Xavier Noria
aa6f5120a7 adds a missing require [fixes #6896]
This file uses Time.zone, which is defined in
active_support/core_ext/time/zones.rb.
2012-07-15 00:44:30 +02:00
Aaron Cruz
4940dc2c50 Added time related req files to AS core_ext #6896
This way you can `require 'active_record/core_ext/time'` for example
I see these libs are available through `active_record/time` but not
individually
2012-07-14 14:29:46 +02:00
Jakub Kuźma
897f8f5453 use 'use_zone' method in example, instead of reimplementing it 2012-07-10 10:02:28 +02:00
Aaron Patterson
d481170251 deprecate describe without a block.
minitest/spec provides `describe`, so deprecate the rails version and
have people use the superclass version
2012-07-09 13:13:59 -07:00
Aaron Patterson
5921cf0b45 we still need describe as the implementation differs from minitest 2012-07-08 14:51:57 -07:00
Aaron Patterson
22bc12ec37 minitest provides "it" and "describe"
Remove rails implementation of describe, alias "test" to "it"
2012-07-08 10:54:21 -07:00
Aaron Patterson
3270156049 minitest is a gem dep, so remove this conditional 2012-07-08 10:50:21 -07:00
Aaron Patterson
6f74d36c42 activesupport gem dependencies should reflect the versions we actually use 2012-07-04 11:16:21 -07:00
Carlos Antonio da Silva
f3353895a0 Kill not used constant since removal of runner method
Runner method was removed in ada571bfcdbad669ae43a4dd18277ef227680a0b.
2012-07-03 21:02:49 -03:00
Aaron Patterson
ada571bfcd remove the runner method copied from minitest 2012-07-03 14:28:28 -07:00
Aaron Patterson
089da2e54d hook mocha in through m/t before_setup, after_teardown hooks 2012-07-03 14:28:28 -07:00
Xavier Noria
65dc45ea2d explains why the file update checker ignores mtimes in the future, plus a little refactor for the same price 2012-07-02 23:56:13 +02:00
Andrew White
822c858a1a Improve performance of DateTime#seconds_since_unix_epoch
Calculate the seconds since the UNIX epoch using the difference in
Julian day numbers from the epoch date. By reducing the Rational math
to just the offset component this gives a significant improvement.

Benchmark:

Calculating --------------------------------------------
       new     27733 i/100ms
   current     15031 i/100ms
       new     27737 i/100ms
   current     15549 i/100ms
--------------------------------------------------------
       new   548182.1 (±0.9%) i/s - 2745567 in 5.008943s
   current   216380.9 (±1.6%) i/s - 1082232 in 5.002781s
       new   510281.9 (±1.2%) i/s - 2551804 in 5.001525s
   current   219858.3 (±1.8%) i/s - 1103979 in 5.023039s
2012-07-02 07:05:17 +01:00
Andrew White
d441de3697 Revert "Use strftime to convert DateTime to numeric"
There appears to be a bug with DateTime#strftime("%s") on 32-bit platforms.
Bug report: http://bugs.ruby-lang.org/issues/6683

This reverts commit 210cd756a628cc19c0d6e44bee8c33dfb2d9d598.
2012-07-01 17:27:49 +01:00
Andrew White
98b46bf5e2 Make Time#change work with offsets other than UTC or local
Use Time.new to create times where the current offset is not zero or
not in the local time zone - closes #4847 and #6651.
2012-07-01 09:11:21 +01:00
Andrew White
73bddd12a4 Remove rescue clause from ActiveSupport::TimeZone#to_f
Time#at no longer raises an error for large values so we can remove
the rescue clause from ActiveSupport::TimeZone#to_f.
2012-07-01 08:48:40 +01:00
Andrew White
c685d12c19 Remove DateTime#to_time override
Currently if the offset is not zero then to_time returns self which
can lead to errors where a developer assumes that the value is a
Time. To solve this we can use the native implementation of
DateTime#to_time in Ruby 1.9.3 as it handles offsets properly and
is faster than our override.
2012-07-01 08:02:41 +01:00
Andrew White
210cd756a6 Use strftime to convert DateTime to numeric
The native implementation of the seconds since the UNIX epoch in
strftime is significantly faster than our method.

Benchmark:
----------
require 'benchmark/ips'
require 'date'
require 'time'

date = DateTime.civil(1253,7,6,20,4,0)

Benchmark.ips do |x|
  x.report("strftime.to_i") { date.strftime('%s').to_i }
  x.report("ssue.to_i") { ((date - DateTime.civil(1970)) * 86400).to_i }

  x.report("strftime.to_f") { date.strftime('%s').to_f }
  x.report("ssue.to_f") { ((date - DateTime.civil(1970)) * 86400).to_f }
end

Output:
-------
Calculating -------------------------------------
       strftime.to_i     26480 i/100ms
           ssue.to_i     13818 i/100ms
       strftime.to_f     26561 i/100ms
           ssue.to_f     14479 i/100ms
-------------------------------------------------
       strftime.to_i   616937.3 (±2.4%) i/s - 3098160 in 5.024749s
           ssue.to_i   200108.8 (±6.9%) i/s -  994896 in 4.999278s
       strftime.to_f   553581.3 (±2.2%) i/s - 2788905 in 5.040397s
           ssue.to_f   204260.3 (±4.3%) i/s - 1028009 in 5.043072s
2012-07-01 07:55:41 +01:00
Vijay Dev
6b9d1a0db2 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	activemodel/lib/active_model/errors.rb
2012-06-30 23:15:22 +05:30
Xavier Noria
58c83d4c61 make sure the inflection rules are loaded when cherry-picking active_support/core_ext/string/inflections.rb [fixes #6884] 2012-06-29 21:29:14 +02:00
abonec
20519efa6e fix FileUpdateChecker when file has wrong mtime (from future) 2012-06-29 19:43:33 +04:00
Alex Nisnevich
32c28e8214 Remove mention of convert_key now that it's been taken out in 1eecd9483b0439ab4913beea36f0d0e2aa0518c7 2012-06-28 20:10:58 -07:00
Grant Hutchins
f6bedc960d Speed up Hash#transform_keys using Hash#each_key
See https://gist.github.com/3007749 for justification
2012-06-27 20:09:30 -04:00
Carlos Antonio da Silva
60571b8539 Ensure Array#to_sentence does not modify given hash
Also simplify I18n logic for Array#to_sentence, doing only one lookup
for all keys and using merge!, instead of one lookup for each option key.
2012-06-26 22:05:56 -03:00
Bogdan Gusiev
88230b7cf7 AS::Callbacks: deprecate monkey patch code
Deprecate usage of filter object with #before and #after
methods as around callback
2012-06-26 09:21:36 +03:00
Rhett Sutphin
e6d4dc3ec4 Add missing require.
If you selectively require core_exts (e.g., require
'active_support/core_ext/string'), it is possible for
'active_support/core_ext/time/calculations' to be required when
`ActiveSupport::TimeWithZone` is not available. If this happens, the next call
to Time.=== will fail with a NameError.
2012-06-25 14:54:40 -05:00
Carlos Antonio da Silva
36d863ce51 Move constants to the top, remove freeze 2012-06-24 19:30:05 -03:00
Carlos Antonio da Silva
06d50b9d73 Remove some not used variables and improve code a bit 2012-06-24 19:30:05 -03:00
benolee
008023c29a correct line numbers for reader and writer methods 2012-06-24 14:39:49 -05:00
Francesco Rodriguez
bc7ac33846 add :nodoc: to internal implementations [ci skip] 2012-06-22 16:29:59 -05:00
Vijay Dev
35ee8fa3d8 Merge branch 'master' of github.com:lifo/docrails 2012-06-22 22:15:27 +05:30
Vijay Dev
6285675db1 fixes a few mistakes in api docs [ci skip] 2012-06-22 22:14:29 +05:30
Aaron Patterson
26a4e5e60e logger is a singleton, just flush the singleton 2012-06-20 14:21:23 -07:00
Aaron Patterson
b9f9951d5f use thread local queues.
Log listener is a singleton shared across threads, so make sure the
event queues are local to each thread.
2012-06-20 13:22:11 -07:00
paranoiase Kang
2773257ac6 Add prev_quarter and next_quarter method in Time/Date/DateTime 2012-06-20 11:39:11 -03:00
タコ焼き仮面
84403ae065 Correct the AP test。 2012-06-19 20:44:45 -07:00
Rafael Mendonça França
39dec69712 Run the logger tests in isolation 2012-06-19 23:21:00 -03:00
Rafael Mendonça França
453188568d CORES needs to be a integer 2012-06-19 23:13:47 -03:00
Aaron Patterson
265f13495f run railties tests in parallel, default to 2 cores 2012-06-19 17:08:23 -07:00
Aaron Patterson
056dbf4f11 Merge branch 'remote'
* remote:
  move fanout back to a global variable, add a mutex for safety
2012-06-19 15:33:40 -07:00
Aaron Patterson
bf8e20586b move fanout back to a global variable, add a mutex for safety 2012-06-19 15:33:14 -07:00
Aaron Patterson
a6fd462a80 make logger a singleton on the class 2012-06-19 14:41:31 -07:00
Aaron Patterson
c6af7646ad listeners are per thread, so remove nested hash 2012-06-19 14:41:31 -07:00
Francesco Rodriguez
7f66ee9ffe add documentation to AS::TestCase#assert_nothing_raised 2012-06-19 15:08:13 -05:00
Rafael Mendonça França
ceba010ea2 Add missing require 2012-06-19 17:04:07 -03:00
Francesco Rodriguez
b912bca9ac update AS::Testing::Assertions docs 2012-06-19 14:47:46 -05:00
Francesco Rodriguez
24587c26dd fix typo [ci skip] 2012-06-19 14:25:11 -05:00
Aaron Patterson
b2ca26a44c subscribers are per thread, so remove the nested hash access 2012-06-19 10:37:51 -07:00
Aaron Patterson
0b38152195 documenting concurrency rules for the Fanout class 2012-06-19 10:37:50 -07:00
Aaron Patterson
644a1796c6 remove global cache 2012-06-19 10:37:50 -07:00
Aaron Patterson
e4de78aec5 reduce thread locals 2012-06-19 10:37:50 -07:00
Aaron Patterson
a01d9dae1c make the fanout notifier local to the current thread 2012-06-19 10:37:50 -07:00
Carlos Antonio da Silva
808592bae2 Use map! instead of replace + map 2012-06-18 21:53:25 -03:00
Chris Zetter
8c07696f47 Fix lookup on HashWithIndifferentAccess for array values. 2012-06-18 21:49:43 -03:00
タコ焼き仮面
c6d86a5db4 make events not use date and time to determine parent_of. fixes #5932 2012-06-18 16:34:23 -07:00
Francesco Rodriguez
55f8b0d09e add example to AS::Deprecation#deprecate_methods [ci skip] 2012-06-18 15:00:58 -05:00
Francesco Rodríguez
824733612e bump AS deprecation_horizon to 4.1 2012-06-17 12:49:11 -05:00
Francesco Rodriguez
508538066c add example to AS::Deprecation#silence [ci skip] 2012-06-17 12:31:40 -05:00
Dylan Smith
c9891608aa Avoid unnecessary catching of Exception instead of StandardError. 2012-06-17 03:50:14 -04:00
Schnittchen
c779a47d01 Documentation: make it clearer that subscribers are not notified asynchronously, but saved for later use. 2012-06-16 14:35:55 +03:00
Marc-Andre Lafortune
fce1735a6e Fix doc example for dasherize 2012-06-15 15:50:08 -04:00
Vijay Dev
c1474ff2e7 Merge branch 'master' of github.com:lifo/docrails 2012-06-14 22:52:38 +05:30
Aaron Patterson
56a1bb2f10 raise the same exception in order to keep path info
Ruby 2.0.0 implements LoadError#path, but newly raised load errors will
not contain the path information.  Replace the error message, copy
blame, and rereaise the same exception object
2012-06-12 16:19:51 -07:00
José Valim
122f6de2e0 Merge pull request #6711 from takkanm/fix-warning-LoadError-path-method
fix method redefined warning in Ruby2.0
2012-06-12 02:34:07 -07:00
Mitsutaka Mimura
a599c034fd fix method redefined warning in Ruby2.0
Ruby2.0 already has LoadError#path.
2012-06-12 17:41:53 +09:00
José Valim
5ea2b11ad7 Stop relying on mutable structures in the FileUpdateChecker 2012-06-12 10:36:13 +02:00
takkanm
fa1ea34c5c fix warning in Ruby2.0.0
```
rails/activesupport/lib/active_support/multibyte/chars.rb:136: warning:
character class has duplicated range: /\b('?[\S])/
```
2012-06-11 13:25:46 +09:00
Xavier Noria
d3a99c32d1 removes the obsolete require_association method from dependencies
This is an obsolete method from the very early days,
apparently it was used circa 2004 because STI support
was not smart enough. This method is not public
interface, and we are heading a major version, so
removal seems right.
2012-06-10 00:38:40 +02:00
Carlos Antonio da Silva
b4fb80cbda Merge pull request #6645 from amatsuda/reduce_string_instance
Reduce number of String instance
2012-06-06 08:49:38 -07:00
Akira Matsuda
7fe6002793 MiniTest::Spec shipped with Ruby >= 1.9.3 always responds_to __name__ 2012-06-06 22:00:43 +09:00
Akira Matsuda
2635a29fec no need to to_s here. Both String and Symbol can be interpolated into String 2012-06-06 19:33:38 +09:00
Akira Matsuda
099639670a Symbol responds_to :upcase & :downcase in Ruby >= 1.9 2012-06-06 19:33:38 +09:00
Akira Matsuda
edee2c7b3b stop to_sing method names
Module#methods are Symbols in Ruby >= 1.9
2012-06-06 19:33:38 +09:00
Mark Rushakoff
5907b0b7f2 Document ActiveSupport::JSON.parse_error [ci skip] 2012-06-05 20:42:08 -07:00
Francesco Rodriguez
1790b234e4 add :nodoc: to AS::NumberHelper private methods [ci skip] 2012-06-05 15:53:20 -05:00
Andrew White
870310db6a Eliminate dependency on Rails::VERSION::STRING
To facilitate the use of ActiveSupport::Testing::Performance outside
of a Rails application conditionally check for the presence of
Rails::VERSION::STRING before including it in the environment string.
2012-06-05 20:43:41 +01:00
Francesco Rodriguez
5e1d40f773 add instance_accessor option to ActiveSupport::Configurable#config_accessor
Changes:

* Add `instance_accessor` option to opt out of the instance writer and
  instance reader methods.
* Raises a NameError if the name of the attribute is not valid.
* Update documentation and tests.
* Add CHANGELOG entry in activesupport.
2012-06-05 10:50:48 -05:00
Francesco Rodriguez
20ded911c0 add example to AS::Gzip 2012-06-04 23:43:43 -05:00
Francesco Rodriguez
4072de266a remove double hyphen that doesn't allow properly parsing 2012-06-04 23:21:48 -05:00
Vijay Dev
40d5303b4f Merge branch 'master' of github.com:lifo/docrails 2012-06-02 21:50:02 +05:30
Rafael Mendonça França
a769fe9db1 Revert some ActiveSupport::Callbacks changes.
This reverts commits 911a0859ac065aa8e8834ac985353d659c7c7b65 and
30b31f51af6f7094c4a27b086755fc66c368d6fa.

Reason: these changes make the Active Model tests fail randomly.

Some examples:
http://travis-ci.org/#!/rails/rails/jobs/1498992
http://travis-ci.org/#!/rails/rails/jobs/1496948
http://travis-ci.org/#!/rails/rails/jobs/1489985

This script was used to reproduce these breaks:
https://gist.github.com/f6828a03ee4d40bffbc3

200 times, 0 failures
2012-06-01 15:14:06 -03:00
Andrew White
67b94799c2 Reduce warning messages when running Active Support tests
Eliminate the warnings generated by redefining methods and constants.
2012-05-31 17:18:25 +01:00
Piotr Sarnacki
aab0d4e2c6 Merge pull request #6554 from erichmenge/remove-json-variable
Remove deprecated ActiveSupport::JSON::Variable.
2012-05-30 13:04:33 -07:00
Erich Menge
1f5dddcf2f Remove deprecated ActiveSupport::JSON::Variable. 2012-05-30 14:39:00 -05:00
Erich Menge
da0ef60d3b Fix typo [ci skip] 2012-05-30 12:48:57 -05:00
Vijay Dev
ec74763c39 Merge branch 'master' of github.com:lifo/docrails 2012-05-30 22:53:52 +05:30
Vijay Dev
e591b7b4e1 some copy edits [ci skip] 2012-05-30 22:28:58 +05:30
Erich Menge
1e335ad138 True, False, and Nil should be represented in as_json as themselves. 2012-05-29 21:13:03 -05:00
José Valim
6ba93ac6f6 Merge pull request #6525 from freerange/minitest-passthrough-exceptions
Exceptions like Interrupt & NoMemoryError should not be rescued in tests.
2012-05-29 01:35:40 -07:00
James Mead
7d8e5fac75 Avoid dependency on MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS. 2012-05-29 09:28:22 +01:00
Francesco Rodriguez
5487daba97 fix example format and add markup in Module#mattr_accessor documentation [ci skip] 2012-05-29 00:00:32 -05:00
Andrew Mutz
598f8bdda1 decoupling activesupport performance testing from actionview and adding tests 2012-05-28 21:09:20 -07:00