Commit Graph

569 Commits

Author SHA1 Message Date
eileencodes
099ddfdefd Add CHANGELOG headers for Rails 5.0.0.beta1 2015-12-18 15:58:25 -05:00
David Heinemeier Hansson
b708a6050c Use consistent references 2015-12-17 14:30:21 +01:00
David Heinemeier Hansson
748b21db8f Add thread_m/cattr_accessor/reader/writer suite of methods for declaring class and module variables that live per-thread 2015-12-17 14:28:19 +01:00
Genadi Samokovarov
bb29fbc132 Don't leak Object constants in core_ext/module/qualified_const 2015-12-16 18:10:50 +01:00
Rafael França
b7a7e82207 Merge pull request #22598 from yui-knk/deprecate_string_callback
Deprecate passing string to define callback.
2015-12-16 13:54:02 -02:00
yui-knk
21f4017fd9 Deprecate passing string to define callback. 2015-12-16 19:56:20 +09:00
Xavier Noria
7223596259 let config.file_watcher be the way to enable the evented file watcher
Before this commit, the sole presence of the Listen constant
enabled the evented file watcher (unless listen resorted to
the polling backend).

This way, applications may depend on listen for other stuff
independently of this feature. Also, allows teams with mixed
setups to decide at boot time whether the evented watcher
should be enabled for each particular instance.
2015-12-13 18:47:42 +01:00
Michael Grosser
a8f773b057 add deprecations for a smooth transition after #22215 2015-11-19 20:49:37 -08:00
Tyler Hunt
ac568795e7 Use proper syntax for class method reference. 2015-11-16 09:42:18 -05:00
Xavier Noria
e42a5fd3d5 normalizes spacing in a CHANGELOG [ci skip] 2015-11-11 07:22:28 +01:00
Jon Pascoe
2f4f4d2cf1 Add days_in_year method 2015-11-11 07:08:49 +01:00
Xavier Noria
59be32b572 registers these changes in the CHANGELOGs 2015-11-11 06:24:29 +01:00
Swaathi K
c9143e15a1 Parameterize with options to preserve case of string
Added test cases

Using kwargs instead of three seperate functions

Updated parameterize in transliterate.rb

Updated parameterize in transliterate.rb

Added deprecation warnings and updating RDoc+Guide

Misspelled separtor. Fixed.

Deprecated test cases and added support to parameterize with keyword parameters

Squashing commits.

Fixed test cases and added deprecated test cases

Small changes to Gemfile.lock and CHANGELOG

Update Gemfile.lock
2015-11-07 16:57:04 +05:30
Sean Griffin
ddb886ef13 Merge pull request #16357 from gchan/hwia-respects-to-hash-default
`HashWithIndifferentAccess.new` respects the default value or proc on
objects that respond to `#to_hash`
2015-10-29 09:54:55 -06:00
Konstantinos Rousis
0d2ce9d723 Change Integer#year to return a Fixnum instead of a Float to improve consistency 2015-10-22 12:44:03 +02:00
Sean Griffin
d94ae72a52 Merge pull request #19992 from greysteil/handle-invalid-utf8-in-html-escape
Handle invalid UTF-8 strings when HTML escaping
2015-10-20 16:50:01 -06:00
Sean Griffin
b945de3662 Update #20737 to address feedback
Given that this pull request affects a mutable value, we need to test
for and document the affects on the receiver in this case.

Additionally, this pull request was missing a CHANGELOG entry.
2015-10-20 16:05:16 -06:00
Sean Griffin
e8c29853ff Merge pull request #20872 from maxjacobson/more-humane-rounding
Round some numbers more humanely
2015-10-20 15:39:31 -06:00
Sean Griffin
7eb7d6f7c1 Update the changelog for #20872 to be a bit less confusing 2015-10-20 15:38:43 -06:00
Matthew Draper
833aef438d Merge pull request #21953 from bdunne/fix_dep_warn
Fix deprecation warning messages on deprecate_methods
2015-10-17 03:17:21 +10:30
Jeremy Daer
0450642c27 Merge pull request #21631 from RobinClowers/fix-cache-instrumentation
Fix cache fetch instrumentation
2015-10-09 13:58:49 -07:00
Roque Pinel
e2b3ccd1aa Refactor AS::Callbacks halt config and fix the documentation
Move from `AS::Callbacks::CallbackChain.halt_and_display_warning_on_return_false`
to `AS::Callbacks.halt_and_display_warning_on_return_false` base on
[this
discussion](https://github.com/rails/rails/pull/21218#discussion_r39354580)

Fix the documentation broken by 0a120a818d413c64ff9867125f0b03788fc306f8
2015-10-01 13:04:20 -04:00
Lucas Mazza
564b162015 Make assert_difference return the result of the yielded block.
With this we can perform new assertions on the returned value without having
to cache it with an outer variable or wrapping all subsequent assertions inside
the `assert_difference` block.

Before:

```
post = nil
assert_difference -> { Post.count }, 1 do
  Post.create
end

assert_predicate post, :persisted?
```

Now:

```
post = assert_difference -> { Post.count } do
  Post.create
end

assert_predicate post, :persisted?
```
2015-09-24 14:17:49 -03:00
Roque Pinel
35cd365621 Fix the AS::Callbacks terminator regression from 4.2.3
Rails 4.2.3 AS::Callbacks will not halt chain if `false` is returned.
That is the behavior of specific callbacks like AR::Callbacks and
AM::Callbacks.
2015-09-22 22:32:56 -04:00
Andrew White
b3eac82300 Short-circuit blank? on date and time values
The concept of a blank date or time doesn't make sense so we can short
circuit the calls for `blank?` on these classes to gain small speed boost.

Fixes #21657
2015-09-21 12:59:00 +01:00
Jerry D'Antonio
56ac6e4768 Replaced ThreadSafe::Map with successor Concurrent::Map.
The thread_safe gem is being deprecated and all its code has been merged
into the concurrent-ruby gem. The new class, Concurrent::Map, is exactly
the same as its predecessor except for fixes to two bugs discovered
during the merge.
2015-09-19 09:56:26 -04:00
Anshul Sharma
6cb7faf3a2 Update Unicode Version to 8.0.0 2015-09-04 00:16:03 +05:30
Rafael Mendonça França
ca32e61c2a No need CHANGELOG entry for #21421 [ci skip] 2015-09-01 00:11:58 -03:00
Leigh Halliday
7abbe137b7 ArrayInquirer to correctly find symbols or strings
The problem existed where if your ArrayInquirer values were
strings but you checked them using any? with a symbol, it would
not find the value. Now it will correctly check whether both
the String form or the Symbol form are included in the Array.

`
2015-08-28 16:20:02 -04:00
Vipul A M
7f23c5d524 - Extracted DELIMITED_REGEX to delimited_regex method and made use of user passed options[:delimited_regex] if available. Changed DELIMITED_REGEX to DEFAULT)DELIMITED_REGEX to signify what it means.
- Added tests for number to delimited and number to currency in both actionview and activesupport.

Changes

Changes
2015-08-28 11:34:17 +05:30
Jean Boussier
e96403bd5c Deprecate :si prefix in number_to_human_size without replacement 2015-08-10 23:35:05 -04:00
Max Jacobson
597a927667 Round some numbers more humanely
Fix #20869
2015-07-26 12:37:39 -04:00
Roque Pinel
46b5b8ef40 Fix TimeWithZone#eql? to handle TimeWithZone created from DateTime
Before:

```ruby
  twz = DateTime.now.in_time_zone
  twz.eql?(twz.dup) => false
```

Now:

```ruby
  twz = DateTime.now.in_time_zone
  twz.eql?(twz.dup) => true
```

Please notice that this fix the `TimeWithZone` comparison to itself,
not to `DateTime`. Based on #3725, `DateTime` should not be equal to
`TimeWithZone`.
2015-07-19 11:17:51 -04:00
Bernard Potocki
800d5ae36c ActiveSupport::HashWithIndifferentAccess select and reject should return enumerator if called without block 2015-07-17 17:17:23 -04:00
Jerry D'Antonio
284a9ba8ec Replaced ActiveSupport::Concurrency::Latch with concurrent-ruby.
The concurrent-ruby gem is a toolset containing many concurrency
utilities. Many of these utilities include runtime-specific
optimizations when possible. Rather than clutter the Rails codebase with
concurrency utilities separate from the core task, such tools can be
superseded by similar tools in the more specialized gem. This commit
replaces `ActiveSupport::Concurrency::Latch` with
`Concurrent::CountDownLatch`, which is functionally equivalent.
2015-07-13 15:44:21 -04:00
yuuji.yaginuma
0a483eba34 fix class name typo [ci skip] 2015-07-11 17:11:15 +09:00
Simon Eskildsen
fa30dd6d2e active_support/indifferent_hash: dont raise on to_hash when default_proc raises 2015-07-10 15:54:37 +00:00
Simon Eskildsen
4ff255a690 active_support/indifferent_hash: fix cloning default_proc on dup 2015-07-10 15:54:31 +00:00
Grey Baker
05a2a6a0c5 Handle invalid UTF-8 strings when HTML escaping
Use `ActiveSupport::Multibyte::Unicode.tidy_bytes` to handle invalid UTF-8
strings in `ERB::Util.unwrapped_html_escape` and `ERB::Util.html_escape_once`.
Prevents user-entered input passed from a querystring into a form field from
causing invalid byte sequence errors.
2015-06-08 18:50:38 +01:00
Aditya Sanghi
c26402cc97 Code fix in CHANGELOG
:nail: remove extraneous bracket
2015-06-08 13:08:08 +05:30
Nikolay Kondratyev
d98928019a Fix a range of values for parameters of the Time#change
Passing 999999000 < `:nsec` < 999999999 and 999999 < `:usec` < 1000000
to change a time with utc_offset doesn't throw an `ArgumentError`.
2015-06-01 13:25:09 +05:00
Kevin Deisz
d909211736 Add Enumerable#pluck.
Allows fetching the same values from arrays as from ActiveRecord associations.
2015-05-28 20:41:03 -04:00
Rafael Mendonça França
b1f6be9b5e Merge pull request #20208 from gaurish/raise_on_missing_ordered_options
Add bang version to OrderedOptions
2015-05-26 13:21:28 -03:00
Yves Senn
b8c31fd9b9 Merge pull request #16938 from akshay-vishnoi/remove-deprication
Remove `.superclass_delegating_accessor`.
2015-05-26 09:26:55 +02:00
Akshay Vishnoi
20c1484993 Remove .superclass_delegating_accessor. Refer #14271 2015-05-24 12:15:22 +05:30
Gaurish Sharma
e768c519fb Add bang version to OrderedOptions
By:
Aditya Sanghi(@asanghi)
Gaurish Sharma(gaurish)
2015-05-23 14:25:06 +05:30
Yves Senn
1ceeadad3b add missing punctuation in changelog. [ci skip] 2015-05-20 11:26:09 +02:00
Nate Smith
af53280a4b Patch Delegator to work with #try
`Delegator` inherits from `BasicObject`, which means that it will not
have `Object#try` defined. It will then delegate the call to the
underlying object, which will not (necessarily) respond to the method
defined in the enclosing `Delegator`.

This patches `Delegator` with the `#try` method to work around the
surprising behaviour.

Fixes #5790
2015-05-19 13:29:02 -07:00
karanarora
768db0fb10 Fix typos is CHANGELOG [ci skip] 2015-05-19 17:10:58 +05:30
Prathamesh Sonpatki
daba090dec Pass over CHANGELOGS [ci skip] 2015-05-16 11:00:17 +05:30
David Heinemeier Hansson
e54277a45d Add Integer#positive? and Integer#negative? query methods in the vein of Fixnum#zero? 2015-05-13 19:15:42 +02:00
Andrew White
3aa26cfb19 Improve ActiveSupport::TimeWithZone conversion to YAML
Previously when converting AS::TimeWithZone to YAML it would be output
as a UTC timestamp. Whilst this preserves the time information accurately
it loses the timezone information. This commit changes that so that it is
saved along with the time information. It also provides nicer encoding of
AS::TimeZone instances themselves which previously embedded all of the
data from the TZInfo records.

Fixes #9183.
2015-04-22 12:12:39 -04:00
Paul A Jungwirth
a5e507fa0b Add ActiveSupport::TimeZone#strptime.
This makes it easier to parse user-inputted times as from a given time zone.
2015-04-22 12:05:07 -04:00
Yves Senn
cdbf685994 pass over CHANGELOGs. [ci skip] 2015-04-22 14:44:30 +02:00
Iain Beeston
d2876141d0 Raise ArgumentError if an unrecognised callback is skipped
At present, if you skip a callback that hasn't been defined,
activesupport callbacks silently does nothing. However, it's easy to
mistype the name of a callback and mistakenly think that it's being
skipped, when it is not.

This problem even exists in the current test suite.
CallbacksTest::SkipCallbacksTest#test_skip_person attempts to skip
callbacks that were never set up.

This PR changes `skip_callback` to raise an `ArgumentError` if the
specified callback cannot be found.
2015-04-03 09:37:19 +01:00
Rafael Mendonça França
b5c35023bd Revert "Remove Array#inquiry"
This reverts commit 9420de59f5b7f5ceac77e28e6c326ec145f71f80.

Reason: Turns out we want to keep this method.
2015-03-30 13:38:13 -03:00
Rafael Mendonça França
9420de59f5 Remove Array#inquiry
We are promoting too much a feature that will not be widler used.
So for now lets keep just the ArrayInquirer constructor.
2015-03-27 16:25:13 -03:00
George Claghorn
c64b99ecc9 Add ActiveSupport::ArrayInquirer and Array#inquiry
Wrapping an array in an `ArrayInquirer` gives a friendlier way to check its
string-like contents. For example, `request.variant` returns an `ArrayInquirer`
object. To check a request's variants, you can call:

    request.variant.phone?
    request.variant.any?(:phone, :tablet)

...instead of:

    request.variant.include?(:phone)
    request.variant.any? { |v| v.in?([:phone, :tablet]) }

`Array#inquiry` is a shortcut for wrapping the receiving array in an
`ArrayInquirer`:

    pets = [:cat, :dog]
    pets.cat?    # => true
    pets.ferret? # => false
    pets.any?(:cat, :ferret} # => true
2015-03-24 13:33:01 -05:00
Kir Shatrov
a982a42d76 Deprecate alias_method_chain in favour of Module#prepend
…as discussed #19413
2015-03-22 23:11:19 +02:00
Andrew White
34b27701ee Revert "Take DST into account when locating TimeZone from Numeric."
Reverting this as it's not the implementation that we would like it to be.
This is being used inside of ActiveSUpport::TimeZone[] and it's unaware
of the context in which to find the timezone period so the timezone found
changes depending on whether DST is in effect for the current period.
This means that `'2001-01-01'.in_time_zone(-9)` changes from winter/summer
even though it's the same date that we're trying to convert.

Since finding timezones by numeric offsets is a bit hit and miss we should
introduce a new API for finding them which supplies the date context in
which we want to search and we should probably also deprecate the finding
of timezones via the [] method, though this needs further discussion.

This reverts commit 2cc2fa3633edd96773023c6b09d07c7b9d9b841d.
2015-03-09 13:48:55 +00:00
Robin Dupret
f927591611 Remove a duplicated changelog entry [ci skip]
This entry now lives in the Action View's changelog ; refs 8a3bd089.
2015-03-06 12:03:51 +01:00
Yves Senn
081a3963ea number_to_percentage and precision: 0 work with NAN and INFINITY.
Closes #19227.
2015-03-06 09:04:51 +01:00
Yasyf Mohamedali
2cc2fa3633 Take DST into account when locating TimeZone from Numeric.
When given a specific offset, use the first result found where the
total current offset (including any periodic deviations such as DST)
from UTC is equal.
2015-03-03 15:16:47 -05:00
Todd Bealmear
c7a37c10ad Add Enumerable#without 2015-03-01 18:45:45 -08:00
Henrik Nygren
ece0d25c2b Fix a backtracking problem in String#truncate_words
Fixes #19070.
2015-02-25 17:02:22 +02:00
Yves Senn
e71f5dad4e some indenting and punctuation fixes. [ci skip] 2015-02-23 16:54:40 +01:00
Godfrey Chan
debe7aedda Properly dump primitive-like AS::SafeBuffer strings as YAML
`coder.represent_scalar` means something along the lines of "Here is a quoted
string, you can just add it to the output", which is not the case here. It only
works for simple strings that can appear unquoted in YAML, but causes problems
for e.g. primitive-like strings ("1", "true").

`coder.represent_object` on the other hand, means that "This is the Ruby-object
representation for this thing suitable for use in YAML dumping", which is what
we want here.

Before:

   YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml  # => "Hello"
   YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml   # => true
   YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml  # => false
   YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml      # => 1
   YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml    # => 1.1

 After:

   YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml  # => "Hello"
   YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml   # => "true"
   YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml  # => "false"
   YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml      # => "1"
   YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml    # => "1.1"

If we ever want Ruby to behave more like PHP or JavaScript though, this is an
excellent trick to use ;)
2015-02-11 17:08:13 -08:00
Rafael Mendonça França
2d2bcde3cb Merge pull request #12067 from jackxxu/keep_precision
Enable number_to_percentage to keep the number's precision by allowing :precision option value to be nil

Conflicts:
	activesupport/CHANGELOG.md
	activesupport/lib/active_support/number_helper.rb
	activesupport/test/number_helper_test.rb
2015-02-06 16:21:28 -02:00
Akira Matsuda
c2bfe6cbc8 Privatize config_accessor as with attr_accessor 2015-02-06 01:12:07 +09:00
Yuki Nishijima
a57ddc58ac Change AS::Testing::TimeHelpers#travel_to to also stub DateTime.now 2015-02-03 05:23:23 -08:00
Yves Senn
d28e5b94a7 introduce ActiveSupport::Testing::FileFixtures.
It's a thin layer to provide easy access to sample files throughout
test-cases. This adds the directory `test/fixtures/files` to newly
generated applications.
2015-01-28 12:29:34 +01:00
Yves Senn
71a84206ab Merge pull request #18709 from ianks/atomic-write
Return value of yielded block in File.atomic_write
2015-01-28 08:58:16 +01:00
Aditya Kapoor
584931d749 Fix assignment for frozen value in HWIA 2015-01-17 00:53:17 +05:30
Andrey Novikov
f996dcf7ef Add missing time zone definitions for Russian Federation
Also sync Russian Federation time zones with `zone.tab` file from tzdata version 2014j.
2015-01-13 20:11:13 +03:00
Yves Senn
a7621d7d53 formatting pass over CHANGELOGs. [ci skip] 2015-01-10 12:17:57 +01:00
Guillermo Iguaran
b109397711 Add SecureRandom.base58 2015-01-09 17:51:46 -05:00
George Claghorn
4c53f58a0f Add #prev_day and #next_day as counterparts to #yesterday and #tomorrow for Date, Time, and DateTime 2015-01-06 05:43:41 -05:00
George Claghorn
b6d0d0d106 Add same_time option to #prev_week and #next_week for Date, Time, and DateTime 2015-01-06 05:43:06 -05:00
George Claghorn
adf5fc3b3c Add #on_weekend?, #next_weekday, and #prev_weekday methods to Date, Time, and DateTime
`#on_weekend?` returns true if the receiving date/time falls on a Saturday or
Sunday.

`#next_weekday` returns a new date/time representing the next day that does
not fall on a Saturday or Sunday.

`#prev_weekday` returns a new date/time representing the previous day that
does not fall on a Saturday or Sunday.
2015-01-06 05:42:37 -05:00
Rafael Mendonça França
5f777e4b5e Change the default test order from :sorted to :random 2015-01-04 11:58:41 -03:00
Rafael Mendonça França
d6e06ea827 Remove deprecated ActiveSupport::JSON::Encoding::CircularReferenceError. 2015-01-04 11:58:41 -03:00
Rafael Mendonça França
c8019c0611 Remove deprecated ActiveSupport::JSON::Encoding.encode_big_decimal_as_string= 2015-01-04 11:58:40 -03:00
Rafael Mendonça França
e1c8b9f688 Remove deprecated ActiveSupport::SafeBuffer#prepend 2015-01-04 11:58:40 -03:00
Rafael Mendonça França
481e49c64f Remove deprecated methods at Kernel.
`silence_stderr`, `silence_stream`, `capture` and `quietly`.
2015-01-04 11:58:40 -03:00
Rafael Mendonça França
98ea19925d Remove deprecated core_ext/big_decimal/yaml_conversions file 2015-01-04 11:58:40 -03:00
Rafael Mendonça França
a3ce6ca30e Remove deprecated ActiveSupport::Cache::Store.instrument 2015-01-04 11:58:40 -03:00
claudiob
9c65c539e2 Add config to halt callback chain on return false
This stems from [a comment](rails#17227 (comment)) by @dhh.
In summary:

* New Rails 5.0 apps will not accept `return false` as a way to halt callback chains, and will not display a deprecation warning.
* Existing apps ported to Rails 5.0 will still accept `return false` as a way to halt callback chains, albeit with a deprecation warning.

For this purpose, this commit introduces a Rails configuration option:

```ruby
config.active_support.halt_callback_chains_on_return_false
```

For new Rails 5.0 apps, this option will be set to `false` by a new initializer
`config/initializers/callback_terminator.rb`:

```ruby
Rails.application.config.active_support.halt_callback_chains_on_return_false = false
```

For existing apps ported to Rails 5.0, the initializers above will not exist.
Even running `rake rails:update` will not create this initializer.

Since the default value of `halt_callback_chains_on_return_false` is set to
`true`, these apps will still accept `return true` as a way to halt callback
chains, displaying a deprecation warning.

Developers will be able to switch to the new behavior (and stop the warning)
by manually adding the line above to their `config/application.rb`.

A gist with the suggested release notes to add to Rails 5.0 after this
commit is available at https://gist.github.com/claudiob/614c59409fb7d11f2931
2015-01-02 15:31:56 -08:00
claudiob
d217daf6a7 Deprecate false as the way to halt AS callbacks
After this commit, returning `false` in a callback will display a deprecation
warning to make developers aware of the fact that they need to explicitly
`throw(:abort)` if their intention is to halt a callback chain.

This commit also patches two internal uses of AS::Callbacks (inside
ActiveRecord and ActionDispatch) which sometimes return `false` but whose
returned value is not meaningful for the purpose of execution.

In both cases, the returned value is set to `true`, which does not affect the
execution of the callbacks but prevents unrequested deprecation warnings from
showing up.
2015-01-02 15:31:55 -08:00
claudiob
2386daabe7 Throw :abort halts default CallbackChains
This commit changes arguments and default value of CallbackChain's :terminator
option.

After this commit, Chains of callbacks defined **without** an explicit
`:terminator` option will be halted as soon as a `before_` callback throws
`:abort`.

Chains of callbacks defined **with** a `:terminator` option will maintain their
existing behavior of halting as soon as a `before_` callback matches the
terminator's expectation. For instance, ActiveModel's callbacks will still
halt the chain when a `before_` callback returns `false`.
2015-01-02 15:31:55 -08:00
Rafael Mendonça França
734d97d292 Deprecate MissingSourceFile in favor of LoadError.
`MissingSourceFile` was just an alias to `LoadError` and was not
being raised inside the framework.
2015-01-02 19:44:39 -03:00
Robin Dupret
ae08bef428 Changelog edits [ci skip] 2014-12-31 17:35:41 +01:00
Yves Senn
0587070391 cleanup CHANGELOGs. [ci skip] 2014-12-23 08:56:17 +01:00
Genadi Samokovarov
dd96e8e333 Add class level case operator support for error dispatching in Rescuable 2014-12-10 02:34:59 +02:00
claudiob
999603c17f Fix MessageVerifier's #verified in CHANGELOG
[ci skip]

As confirmed by @lleger (the author of `verified`) [in this comment](https://github.com/rails/rails/pull/17727#issuecomment-65488743):

> Actually, it no longer returns false explicitly (bc8cc56), so I guess the CHANGELOG isn't totally accurate. It returns nil instead (but the functionality isn't practically different).
2014-12-04 08:13:22 -08:00
Logan Leger
7ad541f955 Add #verified and #valid_message? to MessageVerifier
This commit adds a `#verified` method to
`ActiveSupport::MessageVerifier` which will return either `false` when
it encounters an error or the message. `#verify` continues to raise an
`InvalidSignature` exception on error.

This commit also adds a convenience boolean method on `MessageVerifier`
as a way to check if a message is valid without performing the
decoding.
2014-12-01 21:43:16 -06:00
Rafael Mendonça França
f25ad07f5a Start Rails 5 development 🎉
We will support only Ruby >= 2.1.

But right now we don't accept pull requests with syntax changes to drop
support to Ruby 1.9.
2014-11-28 15:00:06 -02:00
Xavier Noria
0ed6ebcf90 dependencies.rb: keep the decorated #load and #require private [closes #17553] 2014-11-10 14:29:29 -08:00
Yves Senn
5dd3c3b2a0 docs, synchronize 4.2. release notes. [ci skip]
/cc @chancancode
2014-11-06 12:16:11 +01:00
Rafael Mendonça França
4259cc0c50 Merge pull request #17383 from rwz/string-remove
Make `String#remove` and `String#remove!` accept multiple arguments

Conflicts:
	activesupport/CHANGELOG.md
2014-11-03 12:09:26 -02:00
Pablo Herrero
1897d3a5d2 Optimize TimeWithZoneTest#strftime 2014-10-27 21:43:12 -03:00
Pavel Pravosud
73ad151030 Make String#remove and String#remove! accept multiple arguments 2014-10-25 18:06:02 -04:00
Godfrey Chan
04b40b3deb Update CHANGELOG and release notes for e98f2a7 2014-10-22 16:34:58 -07:00
Yves Senn
400b0818fa some changelog formatting. [ci skip] 2014-10-16 09:11:41 +02:00
Matthew Draper
cf66278301 Merge pull request #14146 from chewi/fix-underscore-acronyms-regex
Fix underscore inflector handling of namespaced and adjacent acronyms
2014-10-04 08:16:55 +09:30
Xavier Noria
c935d6f9b5 fixes typo in AS CHANGELOG [ci skip]
References f92ac24.
2014-09-29 23:06:43 +02:00
Agis-
1a787ebb7e Delegation works with reserved words passed to :to
Fixes #16956.
2014-09-19 11:41:41 +03:00
Abdelkader Boudih
46d168e957 Merge pull request #16950 from akshay-vishnoi/docs-rails-4point2
Grammar correction in ActiveSupport CHANGELOG [ci skip]
2014-09-17 21:59:46 +01:00
Akshay Vishnoi
f92ac245bd Grammar correction in ActiveSupport CHANGELOG [ci skip] 2014-09-18 02:27:18 +05:30
Rafael Mendonça França
026289e28e Merge pull request #16948 from akshay-vishnoi/docs-rails-4point2
[ci skip] ActiveSupport CHANGELOG fixes
2014-09-17 17:28:50 -03:00
Akshay Vishnoi
7a8fb281d8 [ci skip] ActiveSupport CHANGELOG fixes
1. spacing issues
2. spelling correction
3. grammar correction
4. Add missing docs
2014-09-18 01:55:29 +05:30
Rafael Mendonça França
acda46d081 Merge pull request #11794 from yoazt/duration-eql
Added method `#eql?` to `ActiveSupport::Duration`, in addition to `#==`.

Conflicts:
	activesupport/CHANGELOG.md
	activesupport/lib/active_support/duration.rb
	activesupport/test/core_ext/duration_test.rb
2014-09-17 16:15:25 -03:00
Agis-
7a3e5ac298 Time#change can now change nanoseconds (:nsec)
Closes #16392.
2014-09-14 02:24:12 +03:00
Kostiantyn Kahanskyi
4bf9d1938b MessageVerifier raises an appropriate exception if the secret is nil
Otherwise this will lead to another error later on 
when generating a signature:
TypeError (no implicit conversion of nil into String).
2014-09-12 15:09:00 +02:00
Godfrey Chan
2b41343c34 Default to sorting user's test cases for now
Goals:

1. Default to :random for newly generated applications
2. Default to :sorted for existing applications with a warning
3. Only show the warning once
4. Only show the warning if the app actually uses AS::TestCase

Fixes #16769
2014-09-08 05:32:16 -07:00
Matthew Draper
ccbb48196e Fix for inflector's incorrect camelCase replacement for acronyms
Fixes #8015, #9756.

[Fred Wu & Matthew Draper]
2014-09-06 04:56:25 +09:30
Agis-
57b2c371f0 Time#change throws exception with an out-of-range :usec
98b46bf5e2
did not properly handled out-of-range `:usec`s.

Passing a `:usec` that's out of range now throws an `ArgumentError` as it
should.

Fixes #16759.
2014-09-04 22:21:38 +03:00
Peter Jaros
fdc5e768ca Methods are not duplicable. 2014-09-03 16:09:15 -04:00
Yves Senn
97e689a0d7 Merge pull request #16450 from tgxworld/dont_swallow_error_when_identifying_constant_from_test_name
Do not swallow exception on NameError within constant.
2014-09-02 08:44:55 +02:00
Yves Senn
3579120367 remove trailing whitespace. [ci skip] 2014-09-02 08:42:44 +02:00
David Heinemeier Hansson
5e51bdda59 We tenderized the wrong method! Object#try already had the yield option, just needed some tenderloving instance_eval to fit the bill 2014-08-29 15:32:24 -07:00
David Heinemeier Hansson
9619450468 Use instance_eval on @tenderlove's suggestion :trollface: 2014-08-29 15:19:32 -07:00
David Heinemeier Hansson
cc0d8fbec9 Update examples to show real worth 2014-08-29 15:04:37 -07:00
David Heinemeier Hansson
141d864e0e Added yield to Object#presence 2014-08-29 14:58:36 -07:00
Robin Dupret
d5578cd177 Follow-up to #16560
For the sake of backward-compatibility, we need to make #instance_of?
return true for Fixnum. On the other hand, the method should still
give true for ActiveSupport::Duration itself which was not the case
before.
2014-08-24 18:17:46 +02:00
Robin Dupret
eb73d7dafa Define the Duration#instance_of? method
Since Duration is extending from ProxyObject which extends itself from
BasicObject, the Duration object doesn't respond to the #instance_of?
method. Thus, the #method_missing hook get triggered, delegating the
method to its `value` attribute.

However, Rubinius' #eql? definition relies on #instance_of?, thus this
will equal to true with a Fixnum (since its `value` attribute is a
Fixnum) while it should not.

The previous behavior was wrong anyway, no matter the implementation.
2014-08-18 15:43:49 +02:00
David Heinemeier Hansson
9f6e82ee47 Fix rounding errors with #travel_to by resetting the usec on any passed time to zero, so we only travel with per-second precision, not anything deeper than that. 2014-08-17 12:52:54 -07:00
Rafael Mendonça França
e81f3c210e Nobody sucks so nobody should call this awful method name 2014-08-12 10:51:41 -03:00
Akira Matsuda
9424b48d39 CHANGELOG entry for TestCase.i_suck_and_my_tests_are_order_dependent! fix 2014-08-12 19:54:23 +09:00
Rafael Mendonça França
ca9736e78c Fix DateTime comparison with DateTime::Infinity object
Fixes #16406
2014-08-06 22:43:37 -03:00
Carlos Antonio da Silva
ab2a35878b Fix AS docs / changelog with wrong method [ci skip] 2014-08-05 10:19:00 -03:00
David Heinemeier Hansson
64d9112222 Rename Object#self to Object#itself to have parity with matz sanctioned method name for Ruby 2.2 2014-08-01 10:30:13 -07:00
David Heinemeier Hansson
702ad710b5 Added Object#self which returns the object itself 2014-08-01 10:07:38 -07:00
Gordon Chan
6e574e8a11 HashWithIndifferentAccess.new respects the default value or proc on objects that respond to #to_hash.
Builds on the work of #12550 where `.new` will convert the object (that respond to `#to_hash`) to a hash and
add that hash's keys and values to itself.

This change will also make `.new` respect the default value or proc of objects that respond to `#to_hash`.
In other words, this `.new` behaves exactly like `.new_from_hash_copying_default`.

`.new_from_hash_copying_default` now simply invokes `.new` and any references to `.new_from_hash_copying_default`
are replaced with `.new`.

Added tests confirm behavior.
2014-07-31 19:14:12 +12:00
Pavel Pravosud
0cb3cc4ff7 Add implicit receiver support to Object#with_options 2014-07-29 16:11:48 -04:00
Godfrey Chan
bf7fbe64f7 Fixed a compatibility issue with the Oj gem
`Time#as_json`, `Date#as_json` and `DateTime#as_json` incorrectly depends on a
delegation that is set up in `active_support/json/encoding`. We cannot simply
require that file in `core_ext/object/json` because it would cause a circular
dependency problem (see #12203 for background). We should instead rely on AS's
autoload to load that file for us on-demand.

To trigger autoload correctly, we need to reference the `AS::JSON::Encoding`
constant instead of using the delegated version.

Fixes #16131.
2014-07-29 00:04:45 -07:00
Arthur Neves
c17c262cfc
Make HWIA copy the default proc too.
[fixes #16279]
2014-07-24 11:48:24 -04:00
Matthew Draper
41679b2b31 Merge pull request #16190 from oss92/word_truncation
Word truncation
2014-07-17 04:31:53 +09:30
root
a9d3b77e49 Added truncate_words method to activesupport strings 2014-07-16 19:48:07 +02:00
Rafael Mendonça França
19fae86fe0 Move uuid_v5 and uuid_v3 to Digest::UUID
These methods are not random so they should not belings to SecureRandom
module.
2014-07-15 19:51:33 -03:00
Rafael Mendonça França
2b2e041506 Add CHANGELOG entry for #13392 [ci skip] 2014-07-15 18:03:12 -03:00
John Paul Ashenfelter
d75992b0b2 DateTime#to_f now preserves fractional seconds.
Previously this method always returns `.0` in the fractional part. This commit
changes it to preserve the fractional seconds instead.

Fixes #15994.
2014-07-02 15:01:35 -07:00
Sean Griffin
b2cf8b251a Add Hash#map_values to ActiveSupport
Didn't get a chance to convert existing code, I'll skim through the code
base to make use of this later this afternoon.
2014-06-29 13:31:43 -06:00
Robin Dupret
d93ae4fca8 Quick pass through Active Support and guides CHANGELOG
[ci skip]
2014-06-29 20:13:49 +02:00
Rafael Mendonça França
3c19402fc3 Merge pull request #15943 from wagenet/cache-instrumentation
Always instrument ActiveSupport::Cache
2014-06-27 18:24:01 -03:00
Robin Dupret
643409dcb0 Make the apply_inflections method case-sensitive
Since d3071db1, the apply_inflections method check if the downcased
version of a string is contained inside the "whitelist" of uncountable
words. However, if the word is composed of capital letters, it won't be
matched in the list while it should.

We can't simply revert to the previous behavior as there is a
performance concern (benchmarked over /usr/share/dict/words):

Before d3071db1  135.610000   0.290000  135.900000 (137.807081)
Since d3071db1   22.170000    0.020000  22.190000  ( 22.530005)
With the patch   22.060000    0.020000  22.080000  ( 22.125771)

Benchmarked with http://git.io/aFnWig

This way, the solution is to put the down-case version of words inside
the @uncountables array.
2014-06-26 14:03:56 +02:00
Arthur Neves
b36df0f6c8
Make dependencies.rb add a name to NameError 2014-06-20 09:44:45 -04:00
Juanjo Bazán
2c515b337f Formatting fix in AS changelog [ci skip] 2014-06-16 20:30:26 -03:00
Adam Panzer
9010274627 fix error with long keys in ActiveSupport::Cache::FileStore 2014-06-10 10:53:48 -07:00
Matthew Draper
b2d070ddf6 Merge pull request #15421 from gchan/time_with_zone_precision
Fixed `ActiveSupport::TimeWithZone#-` so precision is not unnecessarily lost
2014-06-05 16:23:47 +09:30
Juanjo Bazán
60062cf39a Fix AS::NumberHelper results with rationals
:precision was incorrectly being applied to Rationals

before:
  ActiveSupport::NumberHelper.number_to_rounded Rational(10, 3), precision: 2
  => "3.3"
after:
  ActiveSupport::NumberHelper.number_to_rounded Rational(10, 3), precision: 2
  => "3.33"
2014-05-31 20:07:47 +02:00