formula_creator: Remove dependency on args
This commit is contained in:
parent
c148396b98
commit
e2d2ea1d04
@ -140,7 +140,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_formula(args:)
|
def create_formula(args:)
|
||||||
fc = FormulaCreator.new(args, !args.no_fetch?)
|
fc = FormulaCreator.new(!args.no_fetch?, args.HEAD?)
|
||||||
fc.name = if args.set_name.blank?
|
fc.name = if args.set_name.blank?
|
||||||
stem = Pathname.new(args.named.first).stem.rpartition("=").last
|
stem = Pathname.new(args.named.first).stem.rpartition("=").last
|
||||||
print "Formula name [#{stem}]: "
|
print "Formula name [#{stem}]: "
|
||||||
|
|||||||
@ -9,12 +9,12 @@ module Homebrew
|
|||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
class FormulaCreator
|
class FormulaCreator
|
||||||
attr_reader :args, :url, :sha256, :desc, :homepage
|
attr_reader :url, :sha256, :desc, :homepage
|
||||||
attr_accessor :name, :version, :tap, :mode, :license
|
attr_accessor :name, :version, :tap, :mode, :license
|
||||||
|
|
||||||
def initialize(args, fetch=true)
|
def initialize(fetch=true, head=false)
|
||||||
@args = args
|
|
||||||
@fetch = fetch
|
@fetch = fetch
|
||||||
|
@head = head
|
||||||
end
|
end
|
||||||
|
|
||||||
def url=(url)
|
def url=(url)
|
||||||
@ -42,10 +42,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def head?
|
|
||||||
@head || args.HEAD?
|
|
||||||
end
|
|
||||||
|
|
||||||
def write_formula!
|
def write_formula!
|
||||||
raise ArgumentError, "name is blank!" if @name.blank?
|
raise ArgumentError, "name is blank!" if @name.blank?
|
||||||
raise ArgumentError, "tap is blank!" if @tap.blank?
|
raise ArgumentError, "tap is blank!" if @tap.blank?
|
||||||
@ -56,7 +52,7 @@ module Homebrew
|
|||||||
if version.nil? || version.null?
|
if version.nil? || version.null?
|
||||||
odie "Version cannot be determined from URL. Explicitly set the version with `--set-version` instead."
|
odie "Version cannot be determined from URL. Explicitly set the version with `--set-version` instead."
|
||||||
elsif @fetch
|
elsif @fetch
|
||||||
unless head?
|
unless @head
|
||||||
r = Resource.new
|
r = Resource.new
|
||||||
r.url(url)
|
r.url(url)
|
||||||
r.version(version)
|
r.version(version)
|
||||||
@ -100,7 +96,7 @@ module Homebrew
|
|||||||
<% end %>
|
<% end %>
|
||||||
desc "#{desc}"
|
desc "#{desc}"
|
||||||
homepage "#{homepage}"
|
homepage "#{homepage}"
|
||||||
<% unless head? %>
|
<% unless @head %>
|
||||||
url "#{url}"
|
url "#{url}"
|
||||||
<% unless version.detected_from_url? %>
|
<% unless version.detected_from_url? %>
|
||||||
version "#{version}"
|
version "#{version}"
|
||||||
@ -108,7 +104,7 @@ module Homebrew
|
|||||||
sha256 "#{sha256}"
|
sha256 "#{sha256}"
|
||||||
<% end %>
|
<% end %>
|
||||||
license "#{license}"
|
license "#{license}"
|
||||||
<% if head? %>
|
<% if @head %>
|
||||||
head "#{url}"
|
head "#{url}"
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user