Commit Graph

3480 Commits

Author SHA1 Message Date
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