Commit Graph

5678 Commits

Author SHA1 Message Date
Rishi Jain
06467ad7fe fixed typo [ci skip] 2014-11-04 09:13:12 +05:30
Rishi Jain
78d4f2bcfb added example for hash slice method [ci skip] 2014-11-04 09:08:57 +05:30
Rafael Mendonça França
af9702c015 Merge pull request #17487 from pabloh/avoid_allocations
Avoid unnecessary allocations and method calls
2014-11-03 12:14:53 -02: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
0488d00211 Avoid unnecessary allocations/calls 2014-11-02 21:40:47 -03:00
Pablo Herrero
861b70e92f Call gsub with a Regexp instead of a String for better performance 2014-11-01 20:23:29 -03:00
Godfrey Chan
4daebedcc4 Prepare for 4.2.0.beta4 release 2014-10-30 14:12:24 -07:00
claudiob
64b09823e6 Remove redundant to_s in interpolation 2014-10-30 08:48:32 -07:00
Pablo Herrero
c02a7e4f82 Do gsub with a regexp instead of a string 2014-10-29 16:20:52 -03:00
Xavier Noria
e595d91ac2 edit pass over all warnings
This patch uniformizes warning messages. I used the most common style
already present in the code base:

* Capitalize the first word.

* End the message with a full stop.

* "Rails 5" instead of "Rails 5.0".

* Backticks for method names and inline code.

Also, converted a few long strings into the new heredoc convention.
2014-10-28 17:47:32 -07:00
Ryunosuke SATO
44260581be Fix doc markup for NumberHelper [ci skip]
The character "*" is unnecessary in option candidates.
This incorrect markup was injected in e8c9aeca .
2014-10-29 00:32:43 +09:00
Pablo Herrero
1897d3a5d2 Optimize TimeWithZoneTest#strftime 2014-10-27 21:43:12 -03:00
Rafael Mendonça França
89397d09eb Prefix internal method with _
This will avoid naming clash with user defined methods
2014-10-25 17:12:19 -07:00
Pavel Pravosud
73ad151030 Make String#remove and String#remove! accept multiple arguments 2014-10-25 18:06:02 -04:00
Xavier Noria
ae07806858 fixes circularity check in dependencies
The check for circular loading should depend on a stack of files being
loaded at the moment, rather than the collection of loaded files.

This showed up indirectly in #16468, where a misspelled helper would
incorrectly result in a circularity error message.

References #16468
2014-10-25 14:06:33 +02:00
Akira Matsuda
c4767e13d4 instance_eval is evil 2014-10-25 12:59:37 +09:00
Akira Matsuda
ed03d4eaa8 Avoid creating range objects (take II) 2014-10-25 12:59:37 +09:00
Godfrey Chan
cd2d3664e3 Revert a change made to the example in 1ac4525
@carlosantoniodasilva pointed out that when `@person` is nil then this would blow up when you ended up calling `#first`on `nil`.

> "there’s no way to break a try chain when you enter it :D"

[ci skip]
2014-10-24 14:22:22 -07:00
Zachary Scott
ea3cd40554 Include return value in examples added in #17378 [ci skip] 2014-10-24 13:10:50 -07:00
Eugene Gilburg
df1dda8b71 Improved try documentation [ci skip]
- better `if` example
- Added chaining example to the try method description
- Documented the `respond_to?` check to the try method description
- Clearer wording to explain that argument error is raised on argument mismatch to responding method, rather than to non-responding method (which is handled without exception by `try`)
- `.any?` is more precise than `! .blank?`
 - Don't need to use `try` on `children` as (for regular associations) they will always be a collection or array that responds to `first`
- Fix typos/grammar
2014-10-24 13:09:05 -07:00
Godfrey Chan
016af48b86 Merge pull request #17377 from aripollak/dry-try-bang
DRY up try/try!
2014-10-23 19:05:46 -07:00
Guillermo Iguaran
1d9ebec0a9 Merge pull request #17369 from rails/secure_compare
Secure compare
2014-10-23 22:57:26 -03:00
Ari Pollak
22f6189a55 DRY up try/try! 2014-10-23 21:47:16 -04:00
Melanie Gilman
6c75a11199 Reword documentation for uncountable [ci skip] 2014-10-23 13:22:10 -05:00
Guillermo Iguaran
4b11dea391 Use AS secure_compare in AS::MessageVerifier 2014-10-23 14:54:17 -03:00
Guillermo Iguaran
c8c660002f Add AS::SecurityUtils.secure_compare for constant time string comparison 2014-10-23 14:54:06 -03:00
Godfrey Chan
04b40b3deb Update CHANGELOG and release notes for e98f2a7 2014-10-22 16:34:58 -07:00
Ari Pollak
e98f2a74eb Bring try! into parity with try.
Based on commit 5e51bdda.
2014-10-22 18:34:43 -04:00
Rafael Mendonça França
b9fcce3944 Merge pull request #17302 from claudiob/replace-slower-block-call-with-faster-yield
Replace (slower) block.call with (faster) yield
2014-10-18 17:08:24 -03:00
Zachary Scott
7b71d8cfab Revert "Replace (slower) block.call with (faster) yield"
This reverts commit 0ab075e75f58bf403f7ebe20546c7005f35db1f6.
2014-10-18 13:04:02 -07:00
Pramod Sharma
68fd1a3b23 [ci skip] Add Doc of with_options for the case when inherited default options and original options have same keys 2014-10-18 12:59:51 -07:00
claudiob
0ab075e75f Replace (slower) block.call with (faster) yield
Performance optimization: `yield` with an implicit `block` is faster than `block.call`.
See http://youtu.be/fGFM_UrSp70?t=10m35s and the following benchmark:

```ruby
require 'benchmark/ips'

def fast
 yield
end

def slow(&block)
 block.call
end

Benchmark.ips do |x|
 x.report('fast') { fast{} }
 x.report('slow') { slow{} }
end

# => fast    154095 i/100ms
# => slow     71454 i/100ms
# =>
# => fast  7511067.8 (±5.0%) i/s -   37445085 in   4.999660s
# => slow  1227576.9 (±6.8%) i/s -    6145044 in   5.028356s
```
2014-10-18 12:59:51 -07:00
claudiob
d43b1b0a9e Add necessary 'require reverse_merge' to HAWI.rb
Hashes with indifferent access should support `reverse_merge` out-of-the-box
but they don't; for instance the following code fails:

```ruby
require 'active_support'
require 'active_support/hash_with_indifferent_access'
hash = HashWithIndifferentAccess.new key: :old_value
hash.reverse_merge key: :new_value
```

This PR fixes the case above by simply requiring
`active_support/core_ext/hash/reverse_merge` in `hash_with_indifferent_access.rb`
and adding a test that confirms the fix.

---

Here are more details about the bugfix.
Currently, `reverse_merge` is [defined in HashWithIndifferentAccess](4e8ea13ba1/activesupport/lib/active_support/hash_with_indifferent_access.rb (L208))
by invoking `super`, that is by invoking `Hash#reverse_merge`:

```ruby
def reverse_merge(other_hash)
  super(self.class.new_from_hash_copying_default(other_hash))
end
```

However, Ruby's `Hash` does not have the `reverse_merge` by default: it must be
added by ActiveSupport, and that requires the following line of code to be
present:

```ruby
require 'active_support/core_ext/hash/reverse_merge'
```
2014-10-17 09:11:04 -07:00
Yves Senn
400b0818fa some changelog formatting. [ci skip] 2014-10-16 09:11:41 +02:00
Robin Neumann
61f157e11c specify protocol for external links
to ensure correct parsing result of rdoc
2014-10-15 16:15:20 +02:00
Rafael Mendonça França
664a0fa9cf Merge pull request #17230 from robertoz-01/master
atomic_write rescue also Errno::EACCES
2014-10-13 10:52:37 -03:00
Erik Michaels-Ober
8bb33e920a Replace Enumerable#reverse.each with Enumerable#reverse_each 2014-10-13 11:47:16 +01:00
Roberto Zanon
4d59832f29 atomic_write rescue also Errno::EACCES
atomic_write rescue also Errno::EACCES on changing file permission. It could be raised with some type of filesystem
2014-10-10 14:24:35 +02:00
Rafael Mendonça França
cc03ad756a Merge pull request #17184 from fillman/master
fix autoload tests
2014-10-07 12:11:09 -03:00
Rafael Mendonça França
fbfc4ac298 Merge pull request #17146 from divineforest/active-record-gsub-to-tr
Change `gsub` to `tr` where possible
2014-10-07 12:07:56 -03:00
Alexander Balashov
8764ef95dc Change gsub to tr where possible 2014-10-06 14:03:06 +04:00
fillman
1bf522084c fix autoload tests 2014-10-05 20:28:36 +03:00
Kuldeep Aggarwal
619f82bf18 doc added for writer method in alias_method_chain[ci skip] 2014-10-04 18:51:50 +05:30
Matthew Draper
cad635995c ❤️ 1.9 2014-10-04 08:41:03 +09:30
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
James Le Cuirot
6a8464fa4f Fix underscore inflector handling of adjacent acronyms
I suspect that positive lookbehind would have been used in the
original implementation had it been available in supported Ruby
versions at the time. Now that Rails requires Ruby 1.9.2 or above,
this is no longer an issue.

This fixes #14146 for acronyms such as APIRESTful. This technique also
addresses namespaced acronyms that are not entirely uppercased. This
was broken when the commit was originally written but has since been
fixed in ccbb481. The latter does not deal with adjacent acronyms so
this commit wins.
2014-10-03 22:45:40 +01:00
Ryan Selk
9ded108e84 fix typo in in define_model_callbacks comment [ci skip] 2014-10-03 15:31:14 -06:00
Kuldeep Aggarwal
f50430ee3e add notes for define_model_callbacks [ci skip] 2014-10-03 23:04:01 +05:30
lsylvester
6c57c78671 define hash on duration 2014-10-03 19:53:54 +10:00
Rafael Mendonça França
7b740f31cc Merge pull request #17088 from robin850/jruby-dev
Follow up to #16613
2014-10-01 22:56:08 -03:00