Commit Graph
11 Commits
Author SHA1 Message Date
Jack Nagel 24b603a287 Add an accessor to make the intent more clear here 2013-08-22 17:45:08 -05:00
Jack Nagel 94da753a73 Options: ensure copies do not share the underlying collection 2013-08-22 11:49:24 -05:00
Jack Nagel bc80b3d190 Fix some #eql? correctness issues
The implementation of #eql? and #hash should ensure that if a.eql?(b),
then a.hash == b.hash, but #eql? itself should not *depend* on #hash.

For example, given

  class Thingy
    def eql?
      instance_of?(other.class) && hash == other.hash
    end

    def hash
      [name, *tags].hash
    end
  end

if #hash produces a collision for different values of [name, *tags], two
Thingy objects will appear to be eql?, even though this is not the case.
Instead, #eql? should depend on the equality of name and tags directly.
2013-06-27 01:18:45 -05:00
Jack Nagel c7c8d6c02d Use OkJson directly 2013-06-22 21:34:03 -05:00
Jack Nagel 70b6c30e02 Simplify Options#inspect 2013-06-07 20:36:13 -05:00
Jack Nagel 7f0b73dbc5 Define inspect on Option and Options 2013-05-24 10:56:02 -05:00
Jack Nagel 8c8837ede5 Avoid extra array allocations 2013-05-06 16:52:26 -05:00
Jack Nagel 344c8d0d83 Don't shadow outer local variable 2013-02-17 20:57:10 -06:00
Jack Nagel 7bec7abecd Fix passing multiple switches as a single word to the build
Fixes #17434.
2013-01-30 11:09:33 -06:00
Jack Nagel 775184240d FormulaInstaller: construct new ARGV from an Options collection
The array of options that is passed to the spawned build process is a
combination of the current ARGV, options passed in by a dependent
formula, and an existing install receipt. The objects that are
interacting here each expect the resulting collection to have certain
properties, and the expectations are not consistent.

Clear up this confusing mess by only dealing with Options collections.
This keeps our representation of options uniform across the codebase.

We can remove BuildOptions dependency on HomebrewArgvExtension, which
allows us to pass any Array-like collection to Tab.create. The only
other site inside of FormulaInstaller that uses the array is the #exec
call, and there it is splatted and thus we can substitute our Options
collection there as well.
2013-01-26 12:14:47 -06:00
Jack Nagel 8f5ea8eea6 Refactor option handling internals
Currently we handle options in several ways, and it is hard to remember
what code needs an option string ("--foo"), what needs only the name
("foo") and what needs an Option object.

Now that Option objects can act as strings and be converted to JSON, we
can start using them instead of passing around strings between Formula
objects, Tab objects, and ARGV-style arrays.

The Options class is a special collection that can be queried for the
inclusion of options in any form: '--foo', 'foo', or Option.new("foo").
2013-01-26 11:37:01 -06:00