Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
Automate bottle update
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Sep 20, 2019
1 parent 2689be8 commit d900701
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
32 changes: 32 additions & 0 deletions utils/formula.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class Formula
class << self
def bottle(&block)
@bottle ||= Bottle.new
@bottle.instance_eval(&block)
end

def method_missing(method, *args); end

def to_hash
{
'bottle': @bottle.to_hash
}
end
end
class Bottle
def sha256(hash)
@sha256 ||= {}
hash.each do |k, v|
@sha256[v] = k
end
end

def method_missing(method, *args); end

def to_hash
{
'sha256': @sha256
}
end
end
end
20 changes: 20 additions & 0 deletions utils/replace_bottle_sha256.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require_relative "formula.rb"

formula_path = Dir.pwd + "/" + ARGV[0]
new_sha256 = ARGV[1]
os_version = ARGV[2]

require_relative formula_path

formulae = []
ObjectSpace.each_object(Formula.singleton_class) do |klass|
next if klass == Formula
formulae.push(klass)
end

formula = formulae[0]
old_sha256 = formula.to_hash[:bottle][:sha256][os_version.to_sym]

formula_content = File.read(formula_path)
formula_content.gsub!(old_sha256, new_sha256)
File.write(formula_path, formula_content)

0 comments on commit d900701

Please sign in to comment.