Class: Shart::Source
- Inherits:
-
Object
- Object
- Shart::Source
- Defined in:
- lib/shart.rb
Overview
The Source represents where the content is coming from.
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #files(&block) ⇒ Object
-
#initialize(path) ⇒ Source
constructor
A new instance of Source.
- #sync(target) ⇒ Object
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
#root ⇒ Object (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 |