Class: Rack::SassC

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/sassc.rb,
lib/rack/sassc/version.rb

Constant Summary collapse

VERSION =
'0.1.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, opts = {}) ⇒ SassC

Returns a new instance of SassC.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rack/sassc.rb', line 8

def initialize app, opts={}
  @app = app

  @opts = {
    check: ENV['RACK_ENV'] != 'production',
    syntax: :scss,
    css_location: 'public/css',
    scss_location: 'public/scss',
    create_map_file: true,
  }.merge(opts)

  @opts[:css_location] = ::File.expand_path @opts[:css_location]
  @opts[:scss_location] = ::File.expand_path @opts[:scss_location]
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



6
7
8
# File 'lib/rack/sassc.rb', line 6

def opts
  @opts
end

Instance Method Details

#call(env) ⇒ Object



23
24
25
26
# File 'lib/rack/sassc.rb', line 23

def call env
  handle_path(env['PATH_INFO']) if must_check?(env)
  @app.call env
end

#filepath(filename, type) ⇒ Object



28
29
30
31
32
# File 'lib/rack/sassc.rb', line 28

def filepath filename, type
  location = @opts[type==:css ? :css_location : :scss_location]
  ext = type==:scss ? @opts[:syntax] : type
  ::File.join location, "#{filename}.#{ext}"
end