Class: Raptest::Asset

Inherits:
Object
  • Object
show all
Defined in:
lib/raptest/asset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pathname) ⇒ Asset

Returns a new instance of Asset.



12
13
14
# File 'lib/raptest/asset.rb', line 12

def initialize(pathname)
  @pathname = pathname
end

Instance Attribute Details

#pathnameObject

Returns the value of attribute pathname.



11
12
13
# File 'lib/raptest/asset.rb', line 11

def pathname
  @pathname
end

Instance Method Details

#coffee?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/raptest/asset.rb', line 24

def coffee?
  pathname =~ /\.coffee\b/
end

#css?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/raptest/asset.rb', line 20

def css?
  pathname =~ /\.css\b/
end

#erb?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/raptest/asset.rb', line 36

def erb?
  coffee? || pathname =~ /\.erb\b/     
end

#js?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/raptest/asset.rb', line 16

def js?
  pathname =~ /\.js\b/
end

#resultObject



44
45
46
# File 'lib/raptest/asset.rb', line 44

def result
  @result
end

#sass?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/raptest/asset.rb', line 32

def sass?
  pathname =~ /\.sass\b/
end

#scss?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/raptest/asset.rb', line 28

def scss?
  pathname =~ /\.scss\b/ 
end

#sourceObject



40
41
42
# File 'lib/raptest/asset.rb', line 40

def source
  @source ||= File.read(pathname)
end

#test!Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/raptest/asset.rb', line 48

def test!
  reset!
  begin
    erb! if erb?

    if js?
      coffee! if coffee?
      uglify!
    elsif css?
      minify!
    end
  rescue Exception => e
    raise ::Raptest::TestError.new(@component, pathname, e.message)      
  end

end