This repository has been archived by the owner on Dec 20, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor updates to core
- Loading branch information
Dimitrij Denissenko
committed
Sep 19, 2009
1 parent
bf369cc
commit 6111c30
Showing
5 changed files
with
31 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
require 'retrospectiva/core_ext' | |||
require 'retrospectiva/extension_manager/extension_installer' | |||
|
|||
Retrospectiva::ExtensionManager::ExtensionInstaller.installed_extension_names.each do |name| | |||
Dir["#{RAILS_ROOT}/extensions/#{name}/**/*.rake"].sort.each { |ext| load ext } | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,42 +1,43 @@ | |||
module Grit | module Grit | ||
@@result_cache = {} | |||
@@cache_enabled = false | |||
|
|
||
class << self | class << self | ||
|
|||
attr_accessor :result_cache, :cache_enabled | |||
|
|
||
def cache_enabled? | |||
@@cache_enabled == true | |||
end | |||
|
|||
def result_cache | |||
@@result_cache | |||
end | |||
|
|||
def cache | def cache | ||
old_value = self.cache_enabled | old_value = @@cache_enabled | ||
self.cache_enabled = true | @@cache_enabled = true | ||
yield | yield | ||
ensure | ensure | ||
self.cache_enabled = old_value | @@cache_enabled = old_value | ||
self.result_cache.clear | @@result_cache.clear | ||
end | end | ||
|
|
||
end | end | ||
|
|||
self.cache_enabled = false | |||
self.result_cache = {} | |||
|
|||
module ResultCache | |||
|
|
||
class Git | |||
|
|||
def execute_with_cache(call, timeout = nil) | def execute_with_cache(call, timeout = nil) | ||
return execute_without_cache(call, timeout) unless Grit.cache_enabled | return execute_without_cache(call, timeout) unless Grit.cache_enabled? | ||
|
|
||
result = Grit.result_cache[call] | result = Grit.result_cache[call] | ||
if result | if result | ||
Grit.logger.debug " Grit 0.0ms #{call}" | Grit.logger.debug " Grit (0.0ms CACHED) #{call}" | ||
result | result | ||
else | else | ||
Grit.result_cache[call] = execute_without_cache(call, timeout) | Grit.result_cache[call] = execute_without_cache(call, timeout) | ||
end | end | ||
end | end | ||
|
|||
end | |||
|
|||
class Git | |||
include ResultCache | |||
alias_method :execute_without_cache, :execute | alias_method :execute_without_cache, :execute | ||
alias_method :execute, :execute_with_cache | alias_method :execute, :execute_with_cache | ||
|
|||
end | end | ||
end | end |