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.
Constructor Details
#initialize(path) ⇒ Spec
Returns a new instance of Spec.
22 23 24 |
# File 'app/models/konacha/spec.rb', line 22 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
20 21 22 |
# File 'app/models/konacha/spec.rb', line 20 def path @path end |
Class Method Details
.all(path = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'app/models/konacha/spec.rb', line 6 def self.all(path = nil) paths = Konacha.spec_paths paths = ENV["SPEC"].split(",") if ENV["SPEC"] paths = paths.map { |p| new(p) } if path.present? paths = paths.select { |s| s.path.starts_with?(path) }.presence or raise NotFound end paths end |
.find_by_name(name) ⇒ Object
16 17 18 |
# File 'app/models/konacha/spec.rb', line 16 def self.find_by_name(name) all.find { |s| s.asset_name == name } or raise NotFound end |
Instance Method Details
#asset_name ⇒ Object
26 27 28 |
# File 'app/models/konacha/spec.rb', line 26 def asset_name path.sub(/(\.js|\.coffee).*/, '') end |