13 Commits

Author SHA1 Message Date
Mike McQuaid
ecf46b841b utils/inreplace: fix Rubocop warnings. 2016-09-11 19:13:00 +01:00
Xu Cheng
a8566c9848 various: eliminate the usage of any? (#638)
`any?` is not the opposite of `empty?`. Besides the case that
`[false, nil].any?` will return false, `any?`(O(n)) has much worse
performance than `empty?`(O(1)).
2016-08-05 22:01:32 +08:00
ilovezfs
45bfd2b94a inreplace: support for audit arg in non-block form
Provides feature parity between the block and non-block forms of
inreplace by creating a four-argument version of the non-block form,
where the fourth argument is an optional Boolean value, defaulting to
true, which specifies whether a failed inreplace should cause an
InreplaceError error to be raised. The fourth argument is passed along
to StringInreplaceExtension#gsub!, which already supports an optional
audit_result argument.

This resolves the Catch-22 that single replacements aren't permissible
in the block form (in that they now cause `brew audit` to complain), but
the audit_result argument is not available in the non-block form.

Closes #552.

Signed-off-by: ilovezfs <ilovezfs@icloud.com>
2016-07-18 09:24:08 -07:00
Mike McQuaid
2c959a7d58 More API documentation.
And remove the documented stuff from the `example-formula.rb`.

Closes Homebrew/homebrew#43241.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-29 15:43:16 +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
Jack Nagel
aaaab946ec Make inreplace errors fatal
Closes Homebrew/homebrew#32649.
Closes Homebrew/homebrew#32703.
2014-09-28 01:11:31 -05:00
Jack Nagel
4fd63dc4f8 Expose inreplace as a class method 2014-06-18 19:25:35 -05:00
Jack Nagel
7b389fbfed Replace files atomically in inreplace 2014-03-26 16:07:49 -05:00
Jack Nagel
4fe0be37c0 Drop intermediate variable 2014-03-26 16:07:49 -05:00
Mike McQuaid
be3e60fc95 inreplace: odie for Homebrew developers. 2013-11-12 15:44:30 +00:00
Shaun Jackman
91e6c993f8 inreplace: Open the file as binary
Closes Homebrew/homebrew#22628.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2013-09-17 13:58:34 -05:00
Jason Whittle
2c23e71be3 let inreplace take a symbol
As discussed in https://github.com/mxcl/homebrew/pull/21936

Closes Homebrew/homebrew#21942.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2013-08-17 07:40:27 -07:00
Jack Nagel
c8e79c3309 Move inreplace off of Object
Closes Homebrew/homebrew#21163.
2013-07-12 16:23:06 -05:00