Add Cask::Cask#source to return cask's source code
This commit is contained in:
parent
99635bf3ae
commit
ea2e40c69a
@ -20,7 +20,7 @@ module Cask
|
||||
extend Searchable
|
||||
include Metadata
|
||||
|
||||
attr_reader :token, :sourcefile_path, :config, :default_config
|
||||
attr_reader :token, :sourcefile_path, :source, :config, :default_config
|
||||
|
||||
def self.each(&block)
|
||||
return to_enum unless block
|
||||
@ -38,9 +38,10 @@ module Cask
|
||||
@tap
|
||||
end
|
||||
|
||||
def initialize(token, sourcefile_path: nil, tap: nil, config: nil, &block)
|
||||
def initialize(token, sourcefile_path: nil, source: nil, tap: nil, config: nil, &block)
|
||||
@token = token
|
||||
@sourcefile_path = sourcefile_path
|
||||
@source = source
|
||||
@tap = tap
|
||||
@block = block
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ module Cask
|
||||
private
|
||||
|
||||
def cask(header_token, **options, &block)
|
||||
Cask.new(header_token, **options, config: @config, &block)
|
||||
Cask.new(header_token, source: content, **options, config: @config, &block)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -399,10 +399,10 @@ module Cask
|
||||
def save_caskfile
|
||||
old_savedir = @cask.metadata_timestamped_path
|
||||
|
||||
return unless @cask.sourcefile_path
|
||||
return if @cask.source.blank?
|
||||
|
||||
savedir = @cask.metadata_subdir("Casks", timestamp: :now, create: true)
|
||||
FileUtils.copy @cask.sourcefile_path, savedir
|
||||
(savedir/"#{@cask.token}.rb").write @cask.source
|
||||
old_savedir&.rmtree
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user