Class: JsSpec::Resources::WebRoot
- Inherits:
-
Object
- Object
- JsSpec::Resources::WebRoot
- Defined in:
- lib/js_spec/resources/web_root.rb
Instance Attribute Summary collapse
-
#public_path ⇒ Object
readonly
Returns the value of attribute public_path.
Instance Method Summary collapse
-
#initialize(public_path) ⇒ WebRoot
constructor
A new instance of WebRoot.
- #locate(name) ⇒ Object
Constructor Details
#initialize(public_path) ⇒ WebRoot
Returns a new instance of WebRoot.
5 6 7 |
# File 'lib/js_spec/resources/web_root.rb', line 5 def initialize(public_path) @public_path = ::File.(public_path) end |
Instance Attribute Details
#public_path ⇒ Object (readonly)
Returns the value of attribute public_path.
4 5 6 |
# File 'lib/js_spec/resources/web_root.rb', line 4 def public_path @public_path end |
Instance Method Details
#locate(name) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/js_spec/resources/web_root.rb', line 9 def locate(name) case name when 'specs' Resources::Dir.new(JsSpec::Server.spec_root_path, "/specs") when 'core' Resources::Dir.new(JsSpec::Server.core_path, "/core") when 'implementations' Resources::Dir.new(JsSpec::Server.implementation_root_path, "/implementations") when 'suites' Resources::Suite when 'runners' Resources::Runners.new else potential_file_in_public_path = "#{public_path}/#{name}" if ::File.directory?(potential_file_in_public_path) Resources::Dir.new(potential_file_in_public_path, "/#{name}") elsif ::File.exists?(potential_file_in_public_path) Resources::File.new(potential_file_in_public_path, "/#{name}") else raise "Invalid path: #{name}" end end end |