Module: Hadupils::Assets
- Defined in:
- lib/hadupils/assets.rb
Defined Under Namespace
Constant Summary collapse
- SKIP_NAMES =
['.', '..']
Class Method Summary collapse
- .asset_for(path) ⇒ Object
-
.assets_in(directory) ⇒ Object
Walks the top-level members of the stated directory and returns an array containing appropriate an HadoopAsset::* instance for each.
Class Method Details
.asset_for(path) ⇒ Object
39 40 41 42 43 |
# File 'lib/hadupils/assets.rb', line 39 def self.asset_for(path) return Archive.new(path) if path[-7..-1] == '.tar.gz' return Jar.new(path) if path[-4..-1] == '.jar' return File.new(path) end |
.assets_in(directory) ⇒ Object
Walks the top-level members of the stated directory and returns an array containing appropriate an HadoopAsset::* instance for each.
50 51 52 53 54 55 56 |
# File 'lib/hadupils/assets.rb', line 50 def self.assets_in(directory) path = ::File.(directory) ::Dir.entries(path).sort.inject([]) do |accum, entry| accum << asset_for(::File.join(path, entry)) if not SKIP_NAMES.include? entry accum end end |