Class: Shart::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/shart.rb

Overview

The Source represents where the content is coming from.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Source

Returns a new instance of Source.



34
35
36
# File 'lib/shart.rb', line 34

def initialize(path)
  @root = Pathname.new(path)
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



32
33
34
# File 'lib/shart.rb', line 32

def root
  @root
end

Instance Method Details

#files(&block) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/shart.rb', line 38

def files(&block)
  Dir.glob(@root + '**/*').reject{ |p| File.directory?(p) }.inject Hash.new do |hash, source_path|
    key = Pathname.new(source_path).relative_path_from(@root).to_s 
    hash[key] = File.new(source_path) # Give us the 'key' path that we'll publish to in the target.
    hash
  end
end

#sync(target) ⇒ Object



46
47
48
# File 'lib/shart.rb', line 46

def sync(target)
  Sync.new(self, target).run
end