Sha256: e01afc06c4751834da16d340a5c5963d8dbf5bfd01510c88d27f473c844d9c75

Contents?: true

Size: 891 Bytes

Versions: 1

Compression:

Stored size: 891 Bytes

Contents

require 'virtus'
require 'pathname'
require 'multi_sync/attributes/pathname'
require 'multi_sync/resources/local_resource'

module MultiSync
  class Source
    include Virtus.model(strict: true)

    attribute :source_dir, MultiSync::Attributes::Pathname

    attribute :targets, Array, default: []
    attribute :resource_options, Hash, default: {}
    attribute :include, String, default: '**/*'
    attribute :exclude, String, default: ''

    def initialize(*args)
      super
    rescue Virtus::CoercionError => e
      raise ArgumentError, e.message
    end

    private

    def path_to_local_resource(path, options = {})
      pathname = Pathname.new(path)
      path_options = { path_with_root: pathname, path_without_root: pathname.relative_path_from(source_dir).cleanpath }
      MultiSync::LocalResource.new(path_options.merge(options).merge(resource_options))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multi_sync-0.0.4 lib/multi_sync/source.rb