Class: Konacha::Spec
- Inherits:
-
Object
- Object
- Konacha::Spec
- Defined in:
- app/models/konacha/spec.rb
Defined Under Namespace
Classes: NotFound
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #asset_name ⇒ Object
-
#initialize(path) ⇒ Spec
constructor
A new instance of Spec.
- #url ⇒ Object
Constructor Details
#initialize(path) ⇒ Spec
Returns a new instance of Spec.
20 21 22 |
# File 'app/models/konacha/spec.rb', line 20 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
18 19 20 |
# File 'app/models/konacha/spec.rb', line 18 def path @path end |
Class Method Details
.all ⇒ Object
6 7 8 9 10 11 12 |
# File 'app/models/konacha/spec.rb', line 6 def self.all paths = Konacha.spec_paths if ENV["SPEC"] paths = ENV["SPEC"].split(",") end paths.map {|path| new(path)} end |
.find(path) ⇒ Object
14 15 16 |
# File 'app/models/konacha/spec.rb', line 14 def self.find(path) all.select { |s| s.path.starts_with?(path) }.presence or raise NotFound end |
Instance Method Details
#asset_name ⇒ Object
28 29 30 |
# File 'app/models/konacha/spec.rb', line 28 def asset_name path.sub(/(\.js|\.coffee).*/, '') end |
#url ⇒ Object
24 25 26 |
# File 'app/models/konacha/spec.rb', line 24 def url "/#{asset_name}" end |