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.



22
23
24
# File 'app/models/konacha/spec.rb', line 22

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject

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_nameObject



26
27
28
# File 'app/models/konacha/spec.rb', line 26

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