44 Commits

Author SHA1 Message Date
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Andrew Janke
e0a8a79921 Style fixes for Rubocop 0.57.1 2018-06-30 19:40:14 -04:00
Mike McQuaid
9fca172d03 Fix HOMEBREW_RUBY_WARNINGS="-w"
Fix various circular requirements, method redefinitions, etc.
2018-04-07 20:28:56 +01:00
Mike McQuaid
cf5fdeef1d Rubocop: manual rule fixes. 2017-09-24 21:23:59 +01:00
Markus Reiter
0ab750bf24 Use module_function for commands. 2016-10-02 00:24:47 +02:00
Markus Reiter
e851c9bf6c Style/Alias: Prefer alias. 2016-09-23 18:19:53 +02:00
Markus Reiter
52ff988530 Fix RuboCop CaseEquality. 2016-09-23 15:30:06 +02:00
Baptiste Fontaine
b7e98b129c cmd/options.rb: move common code in options.rb
Closes Homebrew/homebrew#47423.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
2015-12-27 22:16:46 +01:00
BrewTestBot
13d544e11e Core files style updates.
Closes Homebrew/homebrew#42354.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-03 13:22:35 +01:00
Elliot Saba
6a1f829cfa Ensure that equals options get parsed properly
Options such as --userimg=<path> should be parsed as an option with an
equals in its name ("userimg=") and without the path argument in
Option.name

Closes Homebrew/homebrew#34219.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2014-11-15 17:17:50 -06:00
Mike McQuaid
02e10beb7c Add deprecated_option to software_spec.
Allows remapping one option name to another and updates build options
and flags accordingly.
2014-10-19 13:58:52 +01:00
Mike McQuaid
da0a65356d Add DeprecatedOption class.
Used to capture options that are being renamed.
2014-10-19 13:58:52 +01:00
Jack Nagel
977ae5f27d Collapse iteration to a map 2014-08-29 19:38:32 -05:00
Jack Nagel
750d7bb2c8 Options internals no longer need to support switches 2014-08-29 19:38:32 -05:00
Jack Nagel
6885f588d0 Move handling of leading dashes to Options.create 2014-08-29 19:38:32 -05:00
Jack Nagel
f7f8ca45fc Remove to_str from Option
We no longer need implicit conversion of options to strings.
2014-08-27 14:08:14 -05:00
Jack Nagel
af3d551de7 Options no longer needs deep-copy semantics
Follow-up to 23d90a6a187a57fbdf4eeac146993e3b37c3d4d9.
2014-08-20 19:05:49 -05:00
Jack Nagel
ae4b9fffd4 Avoid hardcoding the class name 2014-08-13 23:45:48 -05:00
Jack Nagel
2311181b54 Remove Options#concat 2014-08-13 18:16:25 -05:00
Jack Nagel
268cd143be Replace Options.coerce with an alternate constructor 2014-08-13 11:09:57 -05:00
Jack Nagel
094c184b12 Remove unused branches from Options.coerce 2014-08-13 11:09:57 -05:00
Mike McQuaid
00d1bb8d12 Revert "Remove unused branches from Options.coerce"
This reverts commit cee42c339e7632eab15111e2c4e6c121ace6f9e2.
2014-08-13 08:45:07 +01:00
Mike McQuaid
a61c3615d2 Revert "Replace Options.coerce with an alternate constructor"
This reverts commit 8d2ef974a3a87bf4207f71ccb8a7b4776e16a016.
2014-08-13 08:45:06 +01:00
Jack Nagel
25395c6de6 Replace Options.coerce with an alternate constructor 2014-08-12 23:55:28 -05:00
Jack Nagel
0a2be32d80 Remove unused branches from Options.coerce 2014-08-12 23:55:28 -05:00
Jack Nagel
8039107afb Default to the empty string instead of nil 2014-08-07 00:48:13 -05:00
Jack Nagel
9e7f5dc261 Merge instead of calling << in a loop 2014-07-07 09:15:56 -05:00
Jack Nagel
aad09a5a63 Option does not need to be Comparable 2014-07-03 19:29:18 -05:00
Jack Nagel
3f6827374f Use to_a definition from Enumerable 2014-07-01 21:26:41 -05:00
Jack Nagel
fbefa76ce2 Always use class.name to build inspect strings 2014-07-01 18:39:15 -05:00
Jack Nagel
14aa1de33c Fix warning under Ruby 2.2 2014-06-09 15:04:15 -05:00
Jack Nagel
b2ccbfe6af Add set union to Options 2014-02-27 14:22:42 -06:00
Jack Nagel
95af184a0c Add an accessor to make the intent more clear here 2013-08-22 17:45:08 -05:00
Jack Nagel
9b2e04593f Options: ensure copies do not share the underlying collection 2013-08-22 11:49:24 -05:00
Jack Nagel
10949ad75d 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
d6929f96a5 Use OkJson directly 2013-06-22 21:34:03 -05:00
Jack Nagel
d596303199 Simplify Options#inspect 2013-06-07 20:36:13 -05:00
Jack Nagel
92857a7bd8 Define inspect on Option and Options 2013-05-24 10:56:02 -05:00
Jack Nagel
5bf652ecdd Avoid extra array allocations 2013-05-06 16:52:26 -05:00
Jack Nagel
0c27a8765e Don't shadow outer local variable 2013-02-17 20:57:10 -06:00
Jack Nagel
3414b4d689 Fix passing multiple switches as a single word to the build
Fixes Homebrew/homebrew#17434.
2013-01-30 11:09:33 -06:00
Jack Nagel
cf08b71bf8 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
70ff06c827 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