mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Eliminate conditional
This commit is contained in:
parent
22cf99094f
commit
a6b16dfa18
@ -42,7 +42,7 @@ class Tab < OpenStruct
|
||||
if path.exist?
|
||||
from_file(path)
|
||||
else
|
||||
dummy_tab
|
||||
empty
|
||||
end
|
||||
end
|
||||
|
||||
@ -83,16 +83,19 @@ class Tab < OpenStruct
|
||||
tab = from_file(path)
|
||||
used_options = remap_deprecated_options(f.deprecated_options, tab.used_options)
|
||||
tab.used_options = used_options.as_flags
|
||||
tab
|
||||
else
|
||||
dummy_tab(f)
|
||||
end
|
||||
tab = empty
|
||||
tab.unused_options = f.options.as_flags
|
||||
tab.source = { :path => f.path.to_s }
|
||||
end
|
||||
|
||||
def self.dummy_tab f=nil
|
||||
tab
|
||||
end
|
||||
|
||||
def self.empty
|
||||
attributes = {
|
||||
:used_options => [],
|
||||
:unused_options => f ? f.options.as_flags : [],
|
||||
:unused_options => [],
|
||||
:built_as_bottle => false,
|
||||
:poured_from_bottle => false,
|
||||
:tapped_from => "",
|
||||
@ -101,7 +104,7 @@ class Tab < OpenStruct
|
||||
:stdlib => nil,
|
||||
:compiler => "clang",
|
||||
:source => {
|
||||
:path => f ? f.path.to_s : nil,
|
||||
:path => nil,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ class TabTests < Homebrew::TestCase
|
||||
end
|
||||
|
||||
def test_defaults
|
||||
tab = Tab.dummy_tab
|
||||
tab = Tab.empty
|
||||
assert_empty tab.unused_options
|
||||
assert_empty tab.used_options
|
||||
refute_predicate tab, :built_as_bottle
|
||||
|
Loading…
x
Reference in New Issue
Block a user