Sha256: f4a9f0cb95b1f637e9b7859a48c5bd3c77055858ae6a8eaecd32b03bd03cde46
Contents?: true
Size: 1.56 KB
Versions: 2
Compression:
Stored size: 1.56 KB
Contents
module JsTestCore module Resources class WebRoot LOCATIONS = [ ['core', lambda do Resources::Dir.new(JsTestCore::Server.core_path, "/core") end], ['implementations', lambda do Resources::Dir.new(JsTestCore::Server.implementation_root_path, "/implementations") end], ['suites', lambda do Resources::Suite end], ['runners', lambda do Resources::Runners.new end] ] class << self attr_accessor :dispatch_strategy def dispatch_specs self.dispatch_strategy = :specs end end attr_reader :public_path def initialize(public_path) @public_path = ::File.expand_path(public_path) end def locate(name) if self.class.dispatch_strategy == :specs && name == 'specs' return JsTestCore::Resources::Specs::SpecDir.new(JsTestCore::Server.spec_root_path, "/specs") end location, initializer = LOCATIONS.find do |location| location.first == name end if initializer initializer.call 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 end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
btakita-screw_unit-0.1.0 | vendor/js_test_core/lib/js_test_core/resources/web_root.rb |
js_test_core-0.1.1 | lib/js_test_core/resources/web_root.rb |