Sha256: 500b6208d6d621a46ca635a8bcd4be963d6c439d12ee2e22f8e44ae85645b249

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

# Class name is Lono::Files because can represent a single file or a directory.
# Also, it avoids conflicting with the stdlib File class name.
# Files is like a "FileList". Using shorter Files name.
module Lono
  class Files < Lono::CLI::Base
    include Concerns::Registration
    include Concerns::PostProcessing

    attr_reader :path, :layer, :type
    def initialize(options={})
      super
      @path = options[:path]
      @layer = options[:layer]
      @type = @layer ? "layer" : "normal"
      @caller = options[:caller] # original caller stack at registration time
    end

    def full_path
      "#{@blueprint.root}/#{@path}"
    end

    class << self
      def register(options={})
        path = options[:path]
        layer = options[:layer]
        # Registration uniquess based on both path and layer option
        file = files.find { |f| f.path == path && f.layer == layer }
        unless file
          file = Files.new(options.merge(caller: caller))
          files << file
        end
        file.marker
      end

      delegate :empty?, :files, to: :files
      def files
        Registry.files
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lono-8.0.0.pre.rc6 lib/lono/files.rb
lono-8.0.0.pre.rc5 lib/lono/files.rb
lono-8.0.0.pre.rc4 lib/lono/files.rb