Class: JsTestCore::Resources::Dir

Inherits:
File
  • Object
show all
Defined in:
lib/js_test_core/resources/dir.rb

Direct Known Subclasses

Specs::SpecDirSuperclass

Constant Summary

Constants inherited from File

File::MIME_TYPES

Instance Method Summary collapse

Methods inherited from File

#==

Instance Method Details

#getObject



14
15
16
17
18
19
20
# File 'lib/js_test_core/resources/dir.rb', line 14

def get
  connection.send_head
  connection.send_body(::Dir.glob("#{absolute_path}/*").inject("") do |html, file|
    file_basename = ::File.basename(file)
    html << %Q|<a href="#{file_basename}">#{file_basename}</a>\n|
  end)
end

#glob(pattern) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/js_test_core/resources/dir.rb', line 22

def glob(pattern)
  expanded_pattern = absolute_path + pattern
  ::Dir.glob(expanded_pattern).map do |absolute_globbed_path|
    relative_globbed_path = absolute_globbed_path.gsub(absolute_path, relative_path)
    File.new(env.merge(
      :absolute_path => absolute_globbed_path,
      :relative_path => relative_globbed_path
    ))
  end
end