Class: Konacha::Spec

Inherits:
Object
  • Object
show all
Defined in:
app/models/konacha/spec.rb

Defined Under Namespace

Classes: NotFound

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Spec

Returns a new instance of Spec.



16
17
18
# File 'app/models/konacha/spec.rb', line 16

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



14
15
16
# File 'app/models/konacha/spec.rb', line 14

def path
  @path
end

Class Method Details

.allObject



6
7
8
# File 'app/models/konacha/spec.rb', line 6

def self.all
  Konacha.spec_paths.map { |path| new(path) }
end

.find(path) ⇒ Object



10
11
12
# File 'app/models/konacha/spec.rb', line 10

def self.find(path)
  all.select { |s| s.path.starts_with?(path) }.presence or raise NotFound
end

Instance Method Details

#asset_nameObject



24
25
26
# File 'app/models/konacha/spec.rb', line 24

def asset_name
  path.sub(/(\.js|\.coffee).*/, '')
end

#urlObject



20
21
22
# File 'app/models/konacha/spec.rb', line 20

def url
  "/#{asset_name}"
end