From b50bd49aa2d2d01ab05a58674557987386b13774 Mon Sep 17 00:00:00 2001 From: Matt Stopa Date: Tue, 9 Jul 2013 23:19:14 -0600 Subject: Update the filestore documentation for clear [ci skip] --- activesupport/lib/active_support/cache/file_store.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index 0c55aa8a32..f93f325012 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -22,6 +22,9 @@ module ActiveSupport extend Strategy::LocalCache end + # Deletes all items from the cache. In this case it deletes all the entries in the specified + # file store directory except for .gitkeep. Be careful which directory is specified in your + # config file when using +FileStore+ because everything in that directory will be deleted. def clear(options = nil) root_dirs = Dir.entries(cache_path).reject {|f| (EXCLUDED_DIRS + [".gitkeep"]).include?(f)} FileUtils.rm_r(root_dirs.collect{|f| File.join(cache_path, f)}) -- cgit v1.2.3 From d06a98b7d9d3a8717cbe42ad506a21dc48613149 Mon Sep 17 00:00:00 2001 From: Matt Stopa Date: Wed, 10 Jul 2013 00:02:21 -0600 Subject: Add documentation for #clear on certain Store classes [ci skip --- activesupport/lib/active_support/cache/file_store.rb | 1 + activesupport/lib/active_support/cache/memory_store.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index f93f325012..79fe84e6b6 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -30,6 +30,7 @@ module ActiveSupport FileUtils.rm_r(root_dirs.collect{|f| File.join(cache_path, f)}) end + # Premptively iterates through all stored keys and removes the ones which have expired. def cleanup(options = nil) options = merged_options(options) each_key(options) do |key| diff --git a/activesupport/lib/active_support/cache/memory_store.rb b/activesupport/lib/active_support/cache/memory_store.rb index 4d26fb7e42..e58b7be9f8 100644 --- a/activesupport/lib/active_support/cache/memory_store.rb +++ b/activesupport/lib/active_support/cache/memory_store.rb @@ -36,6 +36,7 @@ module ActiveSupport end end + # Premptively iterates through all stored keys and removes the ones which have expired. def cleanup(options = nil) options = merged_options(options) instrument(:cleanup, :size => @data.size) do -- cgit v1.2.3 From 3c90f7a25870524fc980d746e85c440e693c0a63 Mon Sep 17 00:00:00 2001 From: Matt Stopa Date: Wed, 10 Jul 2013 00:08:10 -0600 Subject: Add documentation for FileStore#increment and #decrement [ci skip] --- activesupport/lib/active_support/cache/file_store.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index 79fe84e6b6..472f23c1c5 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -39,6 +39,8 @@ module ActiveSupport end end + # Increments an already existing integer value that is stored in the cache. + # If the key is not found nothing is done. def increment(name, amount = 1, options = nil) file_name = key_file_path(namespaced_key(name, options)) lock_file(file_name) do @@ -53,6 +55,8 @@ module ActiveSupport end end + # Decrements an already existing integer value that is stored in the cache. + # If the key is not found nothing is done. def decrement(name, amount = 1, options = nil) file_name = key_file_path(namespaced_key(name, options)) lock_file(file_name) do -- cgit v1.2.3 From 5ff00fcd3d3c4229246bf8ef749b6bc27a5cdb13 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 11 Jul 2013 18:13:43 +0900 Subject: Array#to_formatted_s does not call each element's to_s anymore Array#to_s calls each element's inspect since ruby 1.9 --- .../lib/active_support/core_ext/array/conversions.rb | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb index 3807ee63b1..76ffd23ed1 100644 --- a/activesupport/lib/active_support/core_ext/array/conversions.rb +++ b/activesupport/lib/active_support/core_ext/array/conversions.rb @@ -82,23 +82,8 @@ class Array end end - # Converts a collection of elements into a formatted string by calling - # to_s on all elements and joining them. Having this model: - # - # class Blog < ActiveRecord::Base - # def to_s - # title - # end - # end - # - # Blog.all.map(&:title) #=> ["First Post", "Second Post", "Third post"] - # - # to_formatted_s shows us: - # - # Blog.all.to_formatted_s # => "First PostSecond PostThird Post" - # - # Adding in the :db argument as the format yields a comma separated - # id list: + # Extends Array#to_s to convert a collection of elements into a + # comma separated id list if :db argument is given as the format. # # Blog.all.to_formatted_s(:db) # => "1,2,3" def to_formatted_s(format = :default) -- cgit v1.2.3 From 2c07baf284268883b5a287ff341d361815e5e4df Mon Sep 17 00:00:00 2001 From: Rashmi Yadav Date: Sun, 14 Jul 2013 22:55:56 +0200 Subject: Using ruby 1.9 syntax [ci skip] --- guides/source/debugging_rails_applications.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md index 98f91c1ac6..77a2dd4b18 100644 --- a/guides/source/debugging_rails_applications.md +++ b/guides/source/debugging_rails_applications.md @@ -301,7 +301,7 @@ This command shows you where you are in the code by printing 10 lines centered a 7 8 respond_to do |format| 9 format.html # index.html.erb - 10 format.json { render :json => @posts } + 10 format.json { render json: @posts } ``` If you repeat the `list` command, this time using just `l`, the next ten lines of the file will be printed out. @@ -337,7 +337,7 @@ On the other hand, to see the previous ten lines you should type `list-` (or `l- 7 8 respond_to do |format| 9 format.html # index.html.erb - 10 format.json { render :json => @posts } + 10 format.json { render json: @posts } ``` This way you can move inside the file, being able to see the code above and over the line you added the `debugger`. -- cgit v1.2.3 From 9ed7013a3dc74a9701aa2591396f0944807cf432 Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Mon, 15 Jul 2013 10:35:00 +0200 Subject: Rack Sendfile is coming as default now --- guides/source/rails_on_rack.md | 1 + 1 file changed, 1 insertion(+) diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md index d144fba762..73f541bda4 100644 --- a/guides/source/rails_on_rack.md +++ b/guides/source/rails_on_rack.md @@ -119,6 +119,7 @@ $ rake middleware For a freshly generated Rails application, this might produce something like: ```ruby +use Rack::Sendfile use ActionDispatch::Static use Rack::Lock use # -- cgit v1.2.3 From 86fd83770ff07967b420085af2f496bc1d28678b Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Mon, 15 Jul 2013 11:51:51 +0200 Subject: Added Rack::Sendfile in rake about [ci skip] --- guides/source/command_line.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/command_line.md b/guides/source/command_line.md index 218b4dd39a..6eadbe8435 100644 --- a/guides/source/command_line.md +++ b/guides/source/command_line.md @@ -384,7 +384,7 @@ Active Record version 4.0.0 Action Pack version 4.0.0 Action Mailer version 4.0.0 Active Support version 4.0.0 -Middleware ActionDispatch::Static, Rack::Lock, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::EncryptedCookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag +Middleware Rack::Sendfile, ActionDispatch::Static, Rack::Lock, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::EncryptedCookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag Application root /home/foobar/commandsapp Environment development Database adapter sqlite3 -- cgit v1.2.3