module Borrower::DSL
Public Instance Methods
borrow(path, options={}) { |content| ... }
click to toggle source
borrow a file and put it somewhere by adding a merge: argument of true borrower will parse the contents for additional borrow statements to merge @example borrow source to destination
borrow "source/file", to: "destination/file"
@example borrow and merge source to destination
borrow "source/file", to: "file/destination", merge: true
@example borrow and gsub all exclamation marks
borrow "source/file", to: "file/destination" do |content| content.gsub("!", '.') end
@param [String] path @param [Hash] options @option options [String] :to the destination path @option options [Boolean] :merge wether to merge or not, defaults to `false` @return [Void]
# File lib/borrower.rb, line 37 def borrow path, options={}, &block destination = options.delete(:to) { raise ArgumentError, "missing 'to:' argument" } on_conflict = options.delete(:on_conflict) { nil } content = Borrower.take(path) if content.valid_encoding? content = Borrower.merge(content, options) if options.fetch(:merge) { false } content = yield content if block_given? end Borrower.put *[content, destination, on_conflict].compact end