Module: Catapult

Defined in:
lib/catapult.rb,
lib/catapult/cli.rb,
lib/catapult/version.rb,
lib/catapult/compressor.rb,
lib/catapult/try_static.rb

Defined Under Namespace

Modules: Compressor Classes: CLI, TryStatic

Constant Summary collapse

VERSION =
'0.0.4'

Class Method Summary collapse

Class Method Details

.appObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/catapult.rb', line 34

def self.app
  app = Rack::Builder.new do
    map '/assets' do
      run Catapult.environment
    end

    use Catapult::TryStatic,
        :root => Catapult.root.join('public'),
        :urls => %w[/],
        :try  => ['.html', 'index.html', '/index.html']

    use Rack::ContentType

    run lambda {|env|
      [404, {}, ['Not found']]
    }
  end
end

.environmentObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/catapult.rb', line 16

def self.environment
  @environment ||= begin
    env = Sprockets::Environment.new(root)

    env.append_path(root.join('assets', 'javascripts'))
    env.append_path(root.join('assets', 'stylesheets'))
    env.append_path(root.join('assets', 'images'))

    env.append_path(root.join('vendor', 'assets', 'javascripts'))
    env.append_path(root.join('vendor', 'assets', 'stylesheets'))

    env.append_path(root.join('browser_modules'))
    Stylus.setup(env)

    env
  end
end

.rootObject



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

def self.root
  @root ||= Pathname('.').expand_path
end