aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
Commit message (Collapse)AuthorAgeFilesLines
* Wrong usage of 'a' in docs fixed [ci skip]Mehmet Emin İNAÇ2015-10-031-1/+1
|
* Merge pull request #20600 from ↵Andrew White2015-10-022-7/+6
|\ | | | | | | | | mtsmfm/xmlschema-should-display-more-than-6-digits TimeWithZone#xmlschema should be able to display more than 6 digits
| * TimeWithZone#xmlschema should be able to display more than 6 digitsFumiaki MATSUSHIMA2015-09-302-7/+6
| |
* | Regex fix for mattr_accessor validationAliaksandr Buhayeu2015-10-012-2/+16
| | | | | | | | | | Change ^ and $ operators to \A and \z to prevent code injection after the line breaks
* | Refactor AS::Callbacks halt config and fix the documentationRoque Pinel2015-10-014-17/+15
| | | | | | | | | | | | | | | | | | 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
* | make sure exceptions are marshalable when returning test resultsAaron Patterson2015-09-301-1/+17
|/ | | | | this should fix the error where isolation tests raise an exception and we just get a marshal error
* Fixed concurrent-ruby warnings.Jerry D'Antonio2015-09-291-1/+1
| | | | | Bumped version of concurrent-ruby to 1.0.0.pre3, which fixes all interpreter warnings.
* Improve readability of docs by using code tag [ci skip]Prakash Laxkar2015-09-294-4/+4
|
* Merge pull request #21807 from ronakjangir47/fix_formatted_offset_docsRafael Mendonça França2015-09-293-3/+10
|\ | | | | Update docs for `formatted_offset`
| * Update docs for `formatted_offset` Ronak Jangir2015-09-293-3/+10
| | | | | | Output of `formatted_offset` is depends on input so it’s not always in +HH:MM format. Possible outputs are “+5:30”, “+530” or provided alternate UTC string [ci skip]
* | Merge pull request #21782 from ronakjangir47/transform_values_docsRafael Mendonça França2015-09-282-8/+17
|\ \ | | | | | | Updated docs for transform_keys & transform_values
| * | Updated docs for transform_values [ci skip]Ronak Jangir2015-09-281-3/+8
| | |
| * | Updated docs for transform_keys [ci skip]Ronak Jangir2015-09-281-5/+9
| | |
* | | Speed up `Hash#transform_values` when emptySean Griffin2015-09-281-0/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We're calling this function on an empty hash as part of copying the attribute set during dirty checking initialization. The new structure caused a performance regression on loading records from the database. This causes `User.all.to_a` to perform about 10% faster w/ 10k records. Calculating ------------------------------------- User.all - master 9.000 i/100ms User.all - sg-fix-ar-regression 8.000 i/100ms ------------------------------------------------- User.all - master 81.236 (± 7.4%) i/s - 405.000 User.all - sg-fix-ar-regression 89.716 (± 7.8%) i/s - 448.000
* | minor typo fix [ci skip]Aditya Kapoor2015-09-261-1/+1
| |
* | Merge pull request #21767 from ronakjangir47/missing_transform_values_testRafael Mendonça França2015-09-251-0/+12
|\ \ | | | | | | Added missing tests for transform_values! which returns Enumerator
| * | Added missing tests for transform_values! which returns Enumerator without ↵Ronak Jangir2015-09-261-0/+12
| |/ | | | | | | blocks
* / Added missing tests for transform_keys! which returns Enumerator without blockRonak Jangir2015-09-261-0/+12
|/
* Make `assert_difference` return the result of the yielded block.Lucas Mazza2015-09-243-2/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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? ```
* Improve readability of docs by using code tag [ci skip]amitkumarsuroliya2015-09-242-3/+3
|
* Fix the AS::Callbacks terminator regression from 4.2.3Roque Pinel2015-09-223-35/+42
| | | | | | 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.
* Merge pull request #21678 from ronakjangir47/array_to_formatted_s_docsYves Senn2015-09-221-1/+3
|\ | | | | Added Examples in docs for internal behavior of Array#to_formatted_s [ci skip]
| * Added Examples in docs for internal behavior of Array#to_formatted_s [ci skip]Ronak Jangir2015-09-191-1/+3
| |
* | Correcting output of `number_to_percentage` example in `number_helper` [ci skip]amitkumarsuroliya2015-09-221-1/+1
| | | | | | Here is correct output of `number_to_percentage(100, format: "%n %”)`
* | Short-circuit `blank?` on date and time valuesAndrew White2015-09-217-1/+48
| | | | | | | | | | | | | | 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
* | Merge pull request #21684 from amitsuroliya/correct_resultAndrew White2015-09-211-6/+4
|\ \ | | | | | | Applying right result of examples in ActiveSupport Multibyte [ci skip]
| * | Applying right result of examples in ActiveSupport Multibyte [ci skip]amitkumarsuroliya2015-09-211-6/+4
| | |
* | | :hocho: TyposAkira Matsuda2015-09-211-1/+1
| | |
* | | :scissors: empty line at the top of filesAkira Matsuda2015-09-215-5/+0
|/ /
* | String#strip_heredocs doesn't need Object#tryVlado Cingel2015-09-191-2/+0
| | | | | | | | Call to Object#try was removed with this pull request https://github.com/rails/rails/pull/21596
* | s/seperator/separator/gAkira Matsuda2015-09-201-3/+3
| |
* | Merge pull request #21679 from jdantonio/replace-thread-safeKasper Timm Hansen2015-09-197-13/+17
|\ \ | | | | | | Replaced `ThreadSafe::Map` with successor `Concurrent::Map`.
| * | Replaced `ThreadSafe::Map` with successor `Concurrent::Map`.Jerry D'Antonio2015-09-197-13/+17
| | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge pull request #21669 from amitsuroliya/improve_docsYves Senn2015-09-191-2/+2
|\ \ \ | | | | | | | | Correcting `NameError` error message in `mattr_reader` method. [ci skip]
| * | | Correcting `NameError` error message in `mattr_reader` method. Since this ↵amitkumarsuroliya2015-09-191-2/+2
| | |/ | |/| | | | | | | | | | | | | commit https://github.com/rails/rails/commit/7dfbd91b0780fbd6a1dd9bfbc176e10894871d2d, `NameError` includes attribute_name also in error message [ci skip]
* | | Corrected numeric conversions output [ci skip]amitkumarsuroliya2015-09-191-2/+2
| |/ |/|
* | Replace `#=>` with `# =>` [ci skip]amitkumarsuroliya2015-09-191-2/+2
|/ | | | @rafaelfranca suggested in https://github.com/rails/rails/commit/f7c7bcd9c2a8b0e8c2840295d001d2d4dfd4cfae that code examples should display the result after `# =>` and not after `#=>`.
* Merge pull request #21662 from amitsuroliya/improve_docsKasper Timm Hansen2015-09-181-3/+3
|\ | | | | Corrected `to_time` output in ActiveSupport Date Conversion docs [ci …
| * Corrected `to_time` output in ActiveSupport Date Conversion docs.Since ↵amitkumarsuroliya2015-09-181-3/+3
| | | | | | | | | | https://github.com/rails/rails/commit/48583f8bf74d1cefefea3cd6591bd546a9eaff6c, to_time returns times formatted as YYYY-MM-DD HH:MM:SS UTC [ci skip] `to_time` method now returns in `YYYY-MM-DD HH:MM:SS UTC` format.
* | Merge branch 'master' of github.com:rails/docrailsVijay Dev2015-09-181-1/+1
|\ \
| * | s/JQuery/jQuery/Akira Matsuda2015-09-181-1/+1
| | | | | | | | | | | | [ci skip]
* | | File encoding is defaulted to utf-8 in Ruby >= 2.1Akira Matsuda2015-09-186-9/+0
| |/ |/|
* | Correct ArgumentError message in ActiveSupport conversions docs [ci skip]amitkumarsuroliya2015-09-181-1/+1
| | | | | | This was happened after this commit https://github.com/rails/rails/commit/2ebf47aea21ff8ac10681e53e78dd7a0e5c31c6e
* | Merge pull request #21625 from amitsuroliya/improve_docsAndrew White2015-09-171-2/+2
|\ \ | | | | | | Improve Docs of ActiveSupport::TimeZone [ci skip]
| * | Improve Docs of ActiveSupport::TimeZone [ci skip]amitkumarsuroliya2015-09-151-2/+2
| | | | | | | | | | | | | | | `TimeZone` class is a part of `ActiveSupport` module. For Accessing `TimeZone` class, we need to call `ActiveSupport::TimeZone` instead of `TimeZone`. individual `TimeZone` gives `NameError: uninitialized constant ‘TimeZone’ error
* | | Merge pull request #21616 from claudiob/fix-21122Rafael Mendonça França2015-09-141-68/+6
|\ \ \ | |/ / |/| | Remove methods that are never invoked
| * | Remove AS methods that are never invokedclaudiob2015-09-131-68/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #21122 - does not change any current behavior; simply reflects the fact that two conditions of the if/else statement are never reached. The reason is #17227 which adds a default terminator to AS::Callbacks. Therefore, even callback chains that do not define a terminator now have a terminator, and `chain_config.key?(:terminator)` is always true. Of course, if no terminator was defined, then we want this new default terminator not to do anything special. What the terminator actually does (or should do) is discussed in #21218 but the simple fact that a default terminator exists makes this current PR valid. *Note* that the conditional/simple methods have not been removed in AS::Conditionals::Filter::After because of `:skip_after_callbacks_if_terminated` which lets a user decide **not** to skip after callbacks even if the chain was terminated.
* | | Improving `in_time_zone` docs [ci skip]amitkumarsuroliya2015-09-131-2/+1
| | | | | | | | | `DateTime.utc` is not a valid method. It gives `NoMethodError: undefined method `utc` for DateTime:Class`. As we know that we can calculate `utc` time from `Time` Class, but we can’t calculate `utc` time from `DateTime` Class.
* | | Improve String#strip_heredocJuanito Fatas2015-09-121-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Saves about 6 MB, about 40% faster. **strip_heredoc.rb** ```ruby require "active_support/core_ext/object/try" require "get_process_mem" class String def strip_heredoc indent = scan(/^[ \t]*(?=\S)/).min.try(:size) || 0 gsub(/^[ \t]{#{indent}}/, '') end end if ENV["MEASURE_MEMORY"] == "yes" mem = GetProcessMem.new GC.start GC.disable 10000.times do <<-MSG.strip_heredoc xhr and xml_http_request methods are deprecated in favor of `get :index, xhr: true` and `post :create, xhr: true` MSG end before = mem.mb after = mem.mb GC.enable puts "Before: #{before} MiB" puts "After: #{after} MiB" puts "Diff: #{after - before} MiB" end ``` **patched_strip_heredoc.rb** ```ruby require "active_support/core_ext/object/try" require "get_process_mem" class String def patched_strip_heredoc gsub(/^#{scan(/^[ \t]*(?=\S)/).min}/, "".freeze) end end if ENV["MEASURE_MEMORY"] == "yes" mem = GetProcessMem.new GC.start GC.disable 10000.times do <<-MSG.patched_strip_heredoc xhr and xml_http_request methods are deprecated in favor of `get :index, xhr: true` and `post :create, xhr: true` MSG end before = mem.mb after = mem.mb GC.enable puts "Before: #{before} MiB" puts "After: #{after} MiB" puts "Diff: #{after - before} MiB" end ``` **Before** ``` $ MEASURE_MEMORY=yes ruby strip_heredoc.rb Before: 44.73828125 MiB After: 44.7734375 MiB Diff: 0.03515625 MiB ``` **After** ``` $ MEASURE_MEMORY=yes ruby patched_strip_heredoc.rb Before: 37.9765625 MiB After: 38.015625 MiB Diff: 0.0390625 MiB ``` `44.7734375 - 38.015625 = 6.75` => **Saves about 6.75 MiB** **benchmark.rb** ```ruby require "benchmark/ips" require_relative "./strip_heredoc" require_relative "./patched_strip_heredoc" def original <<-MSG.strip_heredoc xhr and xml_http_request methods are deprecated in favor of `get :index, xhr: true` and `post :create, xhr: true` MSG end def patched <<-MSG.patched_strip_heredoc xhr and xml_http_request methods are deprecated in favor of `get :index, xhr: true` and `post :create, xhr: true` MSG end Benchmark.ips do |x| x.report("original") { original } x.report(" patched") { patched } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14] Calculating ------------------------------------- original 5.652k i/100ms patched 6.477k i/100ms ------------------------------------------------- original 54.076k (± 5.7%) i/s - 271.296k patched 74.557k (± 6.2%) i/s - 375.666k Comparison: patched: 74557.0 i/s original: 54076.4 i/s - 1.38x slower ``` => **About 38% faster** 1. Clone rails project `git clone git@github.com:rails/rails.git` 2. Apply this patch to `activesupport/lib/active_support/core_ext/string/strip.rb` 3. `cd activesupport` 4. run `rake` 5. And tests passed: ``` ➜ activesupport $ rake /Users/Juan/.rubies/ruby-2.2.2/bin/ruby -w -I"lib:test" "/Users/Juan/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/rake_test_loader.rb" "test/**/*_test.rb" ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ........................................................................ ......................................................................S. SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS Finished in 15.343004s, 214.2344 runs/s, 24902.4898 assertions/s. 3287 runs, 382079 assertions, 0 failures, 0 errors, 48 skips You have skipped tests. Run with --verbose for details. ```
* | | Merge pull request #21567 from y-yagi/fix_inspect_docZachary Scott2015-09-091-1/+1
|\ \ \ | | | | | | | | fix wrong method used in the TimeWithZone#inspect method docs [ci skip]