app/models/konacha/spec.rb in konacha-0.9.0 vs app/models/konacha/spec.rb in konacha-0.9.1
- old
+ new
@@ -1,25 +1,28 @@
module Konacha
class Spec
+ class NotFound < StandardError
+ end
+
def self.all
Konacha.spec_paths.map { |path| new(path) }
end
- def self.find(basename)
- all.find { |spec| spec.basename == basename }
+ def self.find(path)
+ all.select { |s| s.path.starts_with?(path) }.presence or raise NotFound
end
attr_accessor :path
def initialize(path)
@path = path
end
def url
- "/#{basename}"
+ "/#{asset_name}"
end
- def basename
- path[/.*(?=\.js.*$)/]
+ def asset_name
+ path.sub(/(\.js|\.coffee).*/, '')
end
end
end