From 4f2725cde35e0a9f528a8aedd265c6ff85c8e067 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 4 Jul 2013 11:21:50 +0100 Subject: [PATCH] Move getting formula names from bottles to method. --- Library/Homebrew/bottles.rb | 7 +++++++ Library/Homebrew/formulary.rb | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index a15d65e85b..60a4dcca0a 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -89,3 +89,10 @@ def bottle_tag Hardware::CPU.type == :ppc ? Hardware::CPU.family : MacOS.cat end end + +def bottle_filename_formula_name filename + version = Version.parse(filename).to_s + path = Pathname.new filename + basename = path.basename.to_s + basename.rpartition("-#{version}").first +end diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 94d1679c39..34ce768223 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -59,9 +59,7 @@ class Formulary class BottleLoader < FormulaLoader def initialize bottle_name @bottle_filename = Pathname(bottle_name).realpath - version = Version.parse(@bottle_filename).to_s - bottle_basename = @bottle_filename.basename.to_s - name_without_version = bottle_basename.rpartition("-#{version}").first + name_without_version = bottle_filename_formula_name @bottle_filename if name_without_version.empty? if ARGV.homebrew_developer? opoo "Add a new version regex to version.rb to parse this filename."