diff options
| author | Jack Nagel | 2015-02-21 18:32:52 -0500 |
|---|---|---|
| committer | Jack Nagel | 2015-02-21 18:44:04 -0500 |
| commit | 35860ac60fb8368fa6e05f9621f67a9c93313976 (patch) | |
| tree | 8e69458e39aa689277d48735edb7a3de1119fdc6 /Library | |
| parent | bb5f7739c7fd1d6351316fcd52020041538c3bf5 (diff) | |
| download | brew-35860ac60fb8368fa6e05f9621f67a9c93313976.tar.bz2 | |
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.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/tab.rb | 70 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_tab.rb | 20 |
2 files changed, 45 insertions, 45 deletions
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index f077f6451..14c3e93d8 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -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) diff --git a/Library/Homebrew/test/test_tab.rb b/Library/Homebrew/test/test_tab.rb index 1ffa7fbb0..e6116b057 100644 --- a/Library/Homebrew/test/test_tab.rb +++ b/Library/Homebrew/test/test_tab.rb @@ -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 |
