diff options
| author | Markus Reiter | 2017-10-08 20:38:32 +0200 |
|---|---|---|
| committer | GitHub | 2017-10-08 20:38:32 +0200 |
| commit | b806a53d88938ab2d2aeb5e96651ed6d47efcdf9 (patch) | |
| tree | 067464b4c08f4c16ca3439b533f06669a78c370c /Library/Homebrew/tab.rb | |
| parent | 91ab116ace7f4f97d3440190463c93be9ec6d675 (diff) | |
| parent | 175ca909ee1a5b57aa0cae2c879920511f311b14 (diff) | |
| download | brew-b806a53d88938ab2d2aeb5e96651ed6d47efcdf9.tar.bz2 | |
Merge pull request #3278 from reitermarkus/code-style
Clean up code style and remove `.rubocop_todo.yml`.
Diffstat (limited to 'Library/Homebrew/tab.rb')
| -rw-r--r-- | Library/Homebrew/tab.rb | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index af19cabe6..aa0208d51 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -3,18 +3,16 @@ require "ostruct" require "options" require "json" require "development_tools" +require "extend/cachable" # Inherit from OpenStruct to gain a generic initialization method that takes a # hash and creates an attribute for each key and value. `Tab.new` probably # should not be called directly, instead use one of the class methods like # `Tab.create`. class Tab < OpenStruct - FILENAME = "INSTALL_RECEIPT.json".freeze - CACHE = {} + extend Cachable - def self.clear_cache - CACHE.clear - end + FILENAME = "INSTALL_RECEIPT.json".freeze # Instantiates a Tab for a new installation of a formula. def self.create(formula, compiler, stdlib) @@ -57,7 +55,7 @@ class Tab < OpenStruct # Returns the Tab for an install receipt at `path`. # Results are cached. def self.from_file(path) - CACHE.fetch(path) { |p| CACHE[p] = from_file_content(File.read(p), p) } + cache.fetch(path) { |p| cache[p] = from_file_content(File.read(p), p) } end # Like Tab.from_file, but bypass the cache. @@ -343,7 +341,7 @@ class Tab < OpenStruct # will no longer be valid. Formula.clear_installed_formulae_cache unless tabfile.exist? - CACHE[tabfile] = self + self.class.cache[tabfile] = self tabfile.atomic_write(to_json) end |
