class RugularBowerComponents

Public Class Methods

compile() click to toggle source
# File lib/rugular/tasks/server/guards/rugular_bower_components.rb, line 5
def self.compile
  new.compile
end
new() click to toggle source
# File lib/rugular/tasks/server/guards/rugular_bower_components.rb, line 9
def initialize; end

Public Instance Methods

compile() click to toggle source
# File lib/rugular/tasks/server/guards/rugular_bower_components.rb, line 11
def compile
  ::Guard::UI.info 'Beginning to create a manifest bower files'

  File.open('.tmp/vendor.css', 'w') do |file|
    file.write bower_css
  end
  File.open('.tmp/vendor.js', 'w') do |file|
    file.write bower_javascript
  end

  'Successfully created manifest bower files'
end

Private Instance Methods

bower_css() click to toggle source
# File lib/rugular/tasks/server/guards/rugular_bower_components.rb, line 26
def bower_css
  bower_yaml.fetch('css').reduce('', &read_bower_component_files)
end
bower_javascript() click to toggle source
# File lib/rugular/tasks/server/guards/rugular_bower_components.rb, line 30
def bower_javascript
  Uglifier.compile(
    bower_yaml.fetch('js').reduce('', &read_bower_component_files)
  )
end
bower_yaml() click to toggle source
# File lib/rugular/tasks/server/guards/rugular_bower_components.rb, line 36
def bower_yaml
  YAML.load(File.read('bower_components.yaml'))
end
read_bower_component_files() click to toggle source
# File lib/rugular/tasks/server/guards/rugular_bower_components.rb, line 40
def read_bower_component_files
  lambda do |accumulator, filename|
    bower_component_file = 'bower_components/' + filename

    fail "#{filename} does not exist" unless File.file? bower_component_file

    accumulator += File.read bower_component_file
  end
end