Module: Middleman::Jammit

Extended by:
Thor::Actions
Defined in:
lib/middleman-jammit.rb,
lib/middleman-jammit/version.rb

Defined Under Namespace

Modules: Helpers, InstanceMethods

Constant Summary collapse

VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object Also known as: included



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/middleman-jammit.rb', line 9

def registered(app)
  app.send :include, InstanceMethods

  app.after_configuration do
    full_build_dir = File.join(root, build_dir)

    FileUtils.mkdir_p File.join(full_build_dir, js_dir)
    FileUtils.mkdir_p File.join(full_build_dir, css_dir)

    jammit_config_file = File.join(root, 'config', 'assets.yml')
    raise ConfigurationNotFound, "could not find \"#{jammit_config_file}\" " unless File.exists?(jammit_config_file)
    jammit_conf = YAML.load(ERB.new(File.read(jammit_config_file)).result)

    touch_asset_files jammit_conf['javascripts']
    touch_asset_files jammit_conf['stylesheets']

    ::Jammit.load_configuration(jammit_config_file)
  end

  app.after_build "jammit" do |build|
    full_package_path = File.join(File.join(root, build_dir), ::Jammit.package_path)
    ::Jammit.packager.precache_all(full_package_path, root)
    build.say_status "Jammit", "build/assets"
  end

  app.helpers Helpers

end