Sha256: c621b959ff035b9a6c43bccffc1fac6609ad64eec855cdd30e2a126b92ad59c4

Contents?: true

Size: 577 Bytes

Versions: 2

Compression:

Stored size: 577 Bytes

Contents

require "copypasta/entry/base"

module Copypasta
  module Entry
    class Literal < Copypasta::Entry::Base
      attr_reader :data

      def initialize(filename, data:, only_if: nil)
        raise "filename must be a string." unless filename.is_a?(String)
        raise "only_if must be null or a Proc." if !only_if.nil? && !only_if.is_a?(Proc)

        @filename = filename
        @data = data
        @only_if = only_if
      end

      private

      def do_apply(destination, _parameters)
        IO.write(target_file(destination), data.to_s)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
copypasta-0.1.1 lib/copypasta/entry/literal.rb
copypasta-0.1.0 lib/copypasta/entry/literal.rb