diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb index 43d8ea900f..80826237ac 100644 --- a/Library/Homebrew/compilers.rb +++ b/Library/Homebrew/compilers.rb @@ -6,19 +6,12 @@ end class CompilerFailure attr_reader :compiler + attr_rw :build, :cause def initialize compiler, &block @compiler = compiler instance_eval(&block) if block_given? - @build ||= 9999 - end - - def build val=nil - val.nil? ? @build.to_i : @build = val.to_i - end - - def cause val=nil - val.nil? ? @cause : @cause = val + @build = (@build || 9999).to_i end end diff --git a/Library/Homebrew/extend/module.rb b/Library/Homebrew/extend/module.rb new file mode 100644 index 0000000000..9210793f67 --- /dev/null +++ b/Library/Homebrew/extend/module.rb @@ -0,0 +1,11 @@ +class Module + def attr_rw(*attrs) + attrs.each do |attr| + module_eval <<-EOS, __FILE__, __LINE__ + 1 + def #{attr}(val=nil) + val.nil? ? @#{attr} : @#{attr} = val + end + EOS + end + end +end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 4a24552eff..ed251f6b01 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -688,16 +688,6 @@ class Formula class << self # The methods below define the formula DSL. - def self.attr_rw(*attrs) - attrs.each do |attr| - class_eval <<-EOS, __FILE__, __LINE__ + 1 - def #{attr}(val=nil) - val.nil? ? @#{attr} : @#{attr} = val - end - EOS - end - end - attr_rw :homepage, :keg_only_reason, :skip_clean_all, :cc_failures attr_rw :plist_startup, :plist_manual diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index 85f215adec..a36f5a3870 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -77,6 +77,7 @@ end class Bottle < SoftwareSpec attr_writer :url + attr_rw :root_url, :prefix, :cellar, :revision def initialize super @@ -103,22 +104,6 @@ class Bottle < SoftwareSpec end EOS end - - def root_url val=nil - val.nil? ? @root_url : @root_url = val - end - - def prefix val=nil - val.nil? ? @prefix : @prefix = val - end - - def cellar val=nil - val.nil? ? @cellar : @cellar = val - end - - def revision val=nil - val.nil? ? @revision : @revision = val - end end diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 46b48268a3..edfce9ac42 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -1,3 +1,4 @@ +require 'extend/module' require 'extend/fileutils' require 'extend/pathname' require 'extend/ARGV' diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index dcacf45e0b..03a3ffd391 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -88,18 +88,7 @@ class Requirement end class << self - # The default formula to install to satisfy this requirement. - def default_formula(val=nil) - val.nil? ? @default_formula : @default_formula = val.to_s - end - - def fatal(val=nil) - val.nil? ? @fatal : @fatal = val - end - - def build(val=nil) - val.nil? ? @build : @build = val - end + attr_rw :fatal, :build, :default_formula def satisfy(options={}, &block) @satisfied ||= Requirement::Satisfier.new(options, &block) diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index 817346beff..8e93884ebe 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -7,9 +7,11 @@ ABS__FILE__ = File.expand_path(__FILE__) $:.push(File.expand_path(__FILE__+'/../..')) +require 'extend/module' require 'extend/fileutils' require 'extend/pathname' require 'extend/string' +require 'extend/symbol' require 'exceptions' require 'utils' require 'rbconfig'