This repository has been archived by the owner on Feb 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2689be8
commit d900701
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |