Switch to string keys

The OpenStruct initializer accepts both symbols and strings, but any
nested hashes will only allow access via string keys, so let's always
construct the object with strings for consistency.
This commit is contained in:
Jack Nagel 2015-02-21 18:32:52 -05:00
parent bb5f7739c7
commit 35860ac60f
2 changed files with 45 additions and 45 deletions

View File

@ -12,18 +12,18 @@ class Tab < OpenStruct
def self.create(formula, compiler, stdlib, build)
attributes = {
:used_options => build.used_options.as_flags,
:unused_options => build.unused_options.as_flags,
:tabfile => formula.prefix.join(FILENAME),
:built_as_bottle => !!ARGV.build_bottle?,
:poured_from_bottle => false,
:tapped_from => formula.tap,
:time => Time.now.to_i,
:HEAD => Homebrew.git_head,
:compiler => compiler,
:stdlib => stdlib,
:source => {
:path => formula.path.to_s,
"used_options" => build.used_options.as_flags,
"unused_options" => build.unused_options.as_flags,
"tabfile" => formula.prefix.join(FILENAME),
"built_as_bottle" => !!ARGV.build_bottle?,
"poured_from_bottle" => false,
"tapped_from" => formula.tap,
"time" => Time.now.to_i,
"HEAD" => Homebrew.git_head,
"compiler" => compiler,
"stdlib" => stdlib,
"source" => {
"path" => formula.path.to_s,
},
}
@ -32,7 +32,7 @@ class Tab < OpenStruct
def self.from_file path
attributes = Utils::JSON.load(File.read(path))
attributes[:tabfile] = path
attributes["tabfile"] = path
new(attributes)
end
@ -86,7 +86,7 @@ class Tab < OpenStruct
else
tab = empty
tab.unused_options = f.options.as_flags
tab.source = { :path => f.path.to_s }
tab.source = { "path" => f.path.to_s }
end
tab
@ -94,17 +94,17 @@ class Tab < OpenStruct
def self.empty
attributes = {
:used_options => [],
:unused_options => [],
:built_as_bottle => false,
:poured_from_bottle => false,
:tapped_from => "",
:time => nil,
:HEAD => nil,
:stdlib => nil,
:compiler => "clang",
:source => {
:path => nil,
"used_options" => [],
"unused_options" => [],
"built_as_bottle" => false,
"poured_from_bottle" => false,
"tapped_from" => "",
"time" => nil,
"HEAD" => nil,
"stdlib" => nil,
"compiler" => "clang",
"source" => {
"path" => nil,
},
}
@ -157,16 +157,16 @@ class Tab < OpenStruct
def to_json
attributes = {
:used_options => used_options.as_flags,
:unused_options => unused_options.as_flags,
:built_as_bottle => built_as_bottle,
:poured_from_bottle => poured_from_bottle,
:tapped_from => tapped_from,
:time => time,
:HEAD => self.HEAD,
:stdlib => (stdlib.to_s if stdlib),
:compiler => (compiler.to_s if compiler),
:source => source || {},
"used_options" => used_options.as_flags,
"unused_options" => unused_options.as_flags,
"built_as_bottle" => built_as_bottle,
"poured_from_bottle" => poured_from_bottle,
"tapped_from" => tapped_from,
"time" => time,
"HEAD" => self.HEAD,
"stdlib" => (stdlib.to_s if stdlib),
"compiler" => (compiler.to_s if compiler),
"source" => source || {},
}
Utils::JSON.dump(attributes)

View File

@ -8,16 +8,16 @@ class TabTests < Homebrew::TestCase
@unused = Options.create(%w(--with-baz --without-qux))
@tab = Tab.new({
:used_options => @used.as_flags,
:unused_options => @unused.as_flags,
:built_as_bottle => false,
:poured_from_bottle => true,
:tapped_from => "Homebrew/homebrew",
:time => nil,
:HEAD => TEST_SHA1,
:compiler => "clang",
:stdlib => "libcxx",
:source => { :path => nil },
"used_options" => @used.as_flags,
"unused_options" => @unused.as_flags,
"built_as_bottle" => false,
"poured_from_bottle" => true,
"tapped_from" => "Homebrew/homebrew",
"time" => nil,
"HEAD" => TEST_SHA1,
"compiler" => "clang",
"stdlib" => "libcxx",
"source" => { "path" => nil },
})
end