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.



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

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



18
19
20
# File 'app/models/konacha/spec.rb', line 18

def path
  @path
end

Class Method Details

.allObject



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_nameObject



28
29
30
# File 'app/models/konacha/spec.rb', line 28

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

#urlObject



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

def url
  "/#{asset_name}"
end