Make some constant strings into actual constants

We only need one copy of each of these strings, not ~7500.
This commit is contained in:
Jack Nagel 2014-05-27 21:14:59 -05:00
parent 28fa5b0261
commit 33cdff99ba
2 changed files with 8 additions and 4 deletions

View File

@ -9,7 +9,7 @@ require 'extend/pathname'
BOTTLE_ERB = <<-EOS BOTTLE_ERB = <<-EOS
bottle do bottle do
<% if root_url != BottleSpecification.new.root_url %> <% if root_url != BottleSpecification::DEFAULT_ROOT_URL %>
root_url "<%= root_url %>" root_url "<%= root_url %>"
<% end %> <% end %>
<% if prefix.to_s != "/usr/local" %> <% if prefix.to_s != "/usr/local" %>

View File

@ -148,14 +148,18 @@ class Bottle
end end
class BottleSpecification class BottleSpecification
DEFAULT_PREFIX = "/usr/local".freeze
DEFAULT_CELLAR = "/usr/local/Cellar".freeze
DEFAULT_ROOT_URL = "https://downloads.sf.net/project/machomebrew/Bottles".freeze
attr_rw :root_url, :prefix, :cellar, :revision attr_rw :root_url, :prefix, :cellar, :revision
attr_reader :checksum, :collector attr_reader :checksum, :collector
def initialize def initialize
@revision = 0 @revision = 0
@prefix = '/usr/local' @prefix = DEFAULT_PREFIX
@cellar = '/usr/local/Cellar' @cellar = DEFAULT_CELLAR
@root_url = 'https://downloads.sf.net/project/machomebrew/Bottles' @root_url = DEFAULT_ROOT_URL
@collector = BottleCollector.new @collector = BottleCollector.new
end end