aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Remove DateTime#to_time overrideAndrew White2012-07-011-14/+0
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Use strftime to convert DateTime to numericAndrew White2012-07-011-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-06-301-7/+0
|\ \ \ | | | | | | | | | | | | | | | | Conflicts: activemodel/lib/active_model/errors.rb
| * | | Remove mention of `convert_key` now that it's been taken out in ↵Alex Nisnevich2012-06-281-7/+0
| | | | | | | | | | | | | | | | 1eecd9483b0439ab4913beea36f0d0e2aa0518c7
* | | | Speed up Hash#transform_keys using Hash#each_keyGrant Hutchins2012-06-271-1/+1
| | | | | | | | | | | | See https://gist.github.com/3007749 for justification
* | | | Ensure Array#to_sentence does not modify given hashCarlos Antonio da Silva2012-06-261-8/+3
| | | | | | | | | | | | | | | | | | | | 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.
* | | | Add missing require.Rhett Sutphin2012-06-251-0/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | 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.
* | | Add prev_quarter and next_quarter method in Time/Date/DateTimeparanoiase Kang2012-06-202-0/+22
| | |
* | | Fix doc example for dasherizeMarc-Andre Lafortune2012-06-151-1/+1
| | |
* | | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-06-141-5/+1
|\ \ \
| * | | remove double hyphen that doesn't allow properly parsingFrancesco Rodriguez2012-06-041-5/+1
| | | |
* | | | fix method redefined warning in Ruby2.0Mitsutaka Mimura2012-06-121-5/+7
| | | | | | | | | | | | | | | | Ruby2.0 already has LoadError#path.
* | | | no need to to_s here. Both String and Symbol can be interpolated into StringAkira Matsuda2012-06-061-3/+0
| | | |
* | | | stop `to_s`ing method namesAkira Matsuda2012-06-061-1/+1
|/ / / | | | | | | | | | Module#methods are Symbols in Ruby >= 1.9
* | | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-05-304-27/+96
|\ \ \
| * | | some copy edits [ci skip]Vijay Dev2012-05-301-4/+4
| | | |
| * | | fix example format and add markup in Module#mattr_accessor documentation [ci ↵Francesco Rodriguez2012-05-291-10/+10
| | | | | | | | | | | | | | | | skip]
| * | | Updates Array conversions method documentations and clean upsAlvaro Pereyra2012-05-281-4/+0
| | | |
| * | | fix empty lines [ci skip]Francesco Rodriguez2012-05-282-2/+0
| | | |
| * | | Merge branch 'master' of github.com:lifo/docrailsAlvaro Pereyra2012-05-2826-61/+245
| |\ \ \
| | * | | remove :nodoc: from Class#subclasses [ci skip]Francesco Rodriguez2012-05-281-4/+10
| | | | |
| | * | | add :locale option to Array#to_sentence documentation [ci skip]Francesco Rodriguez2012-05-281-0/+27
| | | | |
| | * | | add examples to Array#to_sentence [ci skip]Francesco Rodriguez2012-05-281-4/+24
| | | | |
| | * | | update documentation of array/access methods [ci skip]Francesco Rodriguez2012-05-281-8/+16
| | | | |
| * | | | Updates documentation with cleaner examples and texts [ci skip]Alvaro Pereyra2012-05-282-1/+15
| | | | |
| * | | | Remove blank trailing commentsHenrik Hodne2012-05-2015-30/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For future reference, this is the regex I used: ^\s*#\s*\n(?!\s*#). Replace with the first match, and voilà! Note that the regex matches a little bit too much, so you probably want to `git add -i .` and go through every single diff to check if it actually should be changed.
* | | | | Review requires from number helperCarlos Antonio da Silva2012-05-281-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some of these requires are now only necessary in ActiveSupport::NumberHelper. Add hash/keys require due to symbolize_keys usage in number helpers. Also remove some whitespaces. Closes #6414
* | | | | remove unnecessary requireSergey Nartimov2012-05-282-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | AS::Multibyte are no longer required by access and filters string core extensions.
* | | | | Moving NumberHelpers from ActionView to ActiveSupportAndrew Mutz2012-05-273-2/+143
| |/ / / |/| | |
* | | | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-05-272-14/+32
|\ \ \ \
| * | | | update Module#mattr_accessor documentation [ci skip]Francesco Rodriguez2012-05-261-6/+6
| | | | |
| * | | | update Hash documentation with 1.9 syntax [ci skip]Francesco Rodriguez2012-05-261-8/+16
| | | | |
| * | | | add examples to Hash#deep_stringify_keys and Hash#deep_symbolize_keys [ci skip]Francesco Rodriguez2012-05-261-0/+10
| | | | |
* | | | | Update the documentation and add CHANGELOG entryRafael Mendonça França2012-05-261-1/+1
|/ / / /
* | | | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-05-263-12/+15
|\ \ \ \
| * | | | Fix unbalanced braces in Hash#typecast_xml_value internal commentAlexey Vakhov2012-05-251-1/+1
| | | | |
| * | | | Clean Date#beginning_of_month descriptionAlexey Vakhov2012-05-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Unnecessary peace of text was injected at 507da04a149b44e20c5a0ba72a218fe1762b6baf by mistake.
| * | | | Update examples of Array #in_groups and #in_groups_ofAlexey Vakhov2012-05-251-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | Examples should be not square to visually underline a difference between Array#in_groups and Array#in_groups_of.
* | | | | Reorder deep_symbolize_keys methodsMark McSpadden2012-05-251-7/+7
| | | | |
* | | | | Fix Range#sum optimized versionAlexey Vakhov2012-05-251-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At 1bd4d1c67459a91415ee73a8f55d2309c0d62a87 was added Range#sum optimized version for arithmetic progressions. This improvment injected a defect with not integer range boundaries. The defect was fixed by e0adfa82c05f9c975005f102b4bcaebfcd17d241. The second commit really disabled optimization at all because in Ruby integer-valued numbers are instances of Fixnum and Bignum classes. We should #use is_a? (#kind_of?) method instead #instance_of? to check if value is numerical: 1.class # => Fixnum 1.instance_of?(Integer) # => false 1.is_a?(Integer) # => true -100_000_000_000.class # => Bignum -100_000_000_000.instance_of?(Integer) # => false -100_000_000_000.is_a?(Integer) # => true Moreover original implementation of Range#sum has a defect with reverse range boundaries. If the first boundary is less than the second range is empty. Current commit fixes and tests this case too.
* | | | | Add missing requires for deep_dup and hash ext testCarlos Antonio da Silva2012-05-241-0/+2
| | | | |
* | | | | Add Hash#deep_transform_keys and Hash#deep_transform_keys! Also convert ↵Mark McSpadden2012-05-231-17/+26
|/ / / / | | | | | | | | | | | | deep_*_keys to use deep_transform_keys.
* | | | Adding deep versions of stringify_keys and symbolize_keys (plain and bang) ↵Lucas Húngaro2012-05-231-0/+44
| | | | | | | | | | | | | | | | for nested hashes
* | | | Add Hash#transform_keys and Hash#transform_keys! and refactor *_keys methods ↵Mark McSpadden2012-05-231-18/+25
| | | | | | | | | | | | | | | | to use them.
* | | | changed xml type datetime to dateTime, fixes #6328Angelo capilleri2012-05-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | XmlMini define the xml 'datatime', but according to http://www.w3.org/TR/xmlschema-2/#dateTime could be better change this to 'dateTime' with upper case letter 'T. So 'DateTime' and 'Time' are redefined from 'datetime' to 'dateTime' add the changing to the changelog
* | | | Add instance_accessor option to class_attributeAlexey Vakhov2012-05-221-2/+4
| | | |
* | | | Improve docs for `try` by adding note on `BasicObject`Piotr Sarnacki2012-05-201-0/+4
|/ / / | | | | | | | | | [ci skip] closes #5790
* | | Merge pull request #6376 from jgaskins/timestamp-microsecondsJeremy Kemper2012-05-181-0/+1
|\ \ \ | | | | | | | | Increase numeric-timestamp precision to nanoseconds
| * | | Increase `AR#cache_key` precision to nanosecondsJamie Gaskins2012-05-191-0/+1
| | | |
* | | | Merge pull request #6183 from nashby/fix-issue-6179Jeremy Kemper2012-05-181-4/+4
|\ \ \ \ | | | | | | | | | | wrap time ranges with timezones