Sha256: 9dc585c840327d81d18479e55ffa631e877a17a9be4b9df4493c78d9ec0bbef8

Contents?: true

Size: 854 Bytes

Versions: 3

Compression:

Stored size: 854 Bytes

Contents

module Overapp
  module Load
    class Instance
      include FromHash
      attr_accessor :path, :overlays

      fattr(:starting_files) do
        raise "path doesn't exist #{path}" unless FileTest.exist?(path)
        if Overapp.dir_files(path).empty?
          Overapp::Files.new
        else
          RawDir.new(:descriptor => path).load(nil,{})
        end
      end

      fattr(:combined_files) do
        files = starting_files
        
        overlays.each do |overlay|
          files = apply_overlay(files,overlay)
        end

        files
      end

      def apply_overlay(base,overlay)
        Overapp::Git.commit(path,overlay.commit_message) do
          overlay.apply_to(base, :path => path).tap do |res|
            res.write_to! path
          end
        end.tap { |res| raise "nil return" unless res }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
overapp-0.4.2 lib/overapp/load/instance.rb
overapp-0.4.1 lib/overapp/load/instance.rb
overapp-0.4.0 lib/overapp/load/instance.rb