diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 8e81d0b2ec7ab394e033b9acec6692550237ee17..9ffd65f6f93b77b2186a4ecad82234c824951df1 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -1822,25 +1822,7 @@ class Formula
         "revision" => stable.specs[:revision],
       }
 
-      if bottle_defined?
-        bottle_spec = stable.bottle_specification
-        bottle_info = {
-          "rebuild"  => bottle_spec.rebuild,
-          "cellar"   => (cellar = bottle_spec.cellar).is_a?(Symbol) ? cellar.inspect : cellar,
-          "prefix"   => bottle_spec.prefix,
-          "root_url" => bottle_spec.root_url,
-        }
-        bottle_info["files"] = {}
-        bottle_spec.collector.each_key do |os|
-          bottle_url = "#{bottle_spec.root_url}/#{Bottle::Filename.create(self, os, bottle_spec.rebuild).bintray}"
-          checksum = bottle_spec.collector[os][:checksum]
-          bottle_info["files"][os] = {
-            "url"    => bottle_url,
-            "sha256" => checksum.hexdigest,
-          }
-        end
-        hsh["bottle"]["stable"] = bottle_info
-      end
+      hsh["bottle"]["stable"] = bottle_hash if bottle_defined?
     end
 
     hsh["options"] = options.map do |opt|
@@ -1874,6 +1856,27 @@ class Formula
     hsh
   end
 
+  # Returns the bottle information for a formula
+  def bottle_hash
+    bottle_spec = stable.bottle_specification
+    hash = {
+      "rebuild"  => bottle_spec.rebuild,
+      "cellar"   => (cellar = bottle_spec.cellar).is_a?(Symbol) ? cellar.inspect : cellar,
+      "prefix"   => bottle_spec.prefix,
+      "root_url" => bottle_spec.root_url,
+      "files"    => {},
+    }
+    bottle_spec.collector.each_key do |os|
+      bottle_url = "#{bottle_spec.root_url}/#{Bottle::Filename.create(self, os, bottle_spec.rebuild).bintray}"
+      checksum = bottle_spec.collector[os][:checksum]
+      hash["files"][os] = {
+        "url"    => bottle_url,
+        "sha256" => checksum.hexdigest,
+      }
+    end
+    hash
+  end
+
   # @private
   def fetch(verify_download_integrity: true)
     active_spec.fetch(verify_download_integrity: verify_download_integrity)