Module: BEM::Actions

Included in:
CommandsTasks
Defined in:
lib/bem/actions.rb

Instance Method Summary collapse

Instance Method Details

#build_with(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/bem/actions.rb', line 3

def build_with(options = {})
  BEM.configuration.technologies.each do |tech|
    next puts("#{ tech[:group] } are omitted") unless build?(tech[:group], options)

    handle_bem(options, tech) if options[:block].present?

    handle_level(options, tech) unless options[:include_to_manifest]

    handle_manifest(options, tech) if options[:manifest].present? || options[:include_to_manifest]
  end
end

#destroy_with(options = {}) ⇒ Object



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

def destroy_with(options = {})
  BEM.configuration.technologies.each do |tech|
    path = build_path_for(tech[:extension], options, tech[:group])

    path_without_extension = path.split("#{ tech[:group] }/").last.sub(tech[:extension], '')

    remove_file File.expand_path('..', path)

    manifest_name = options[:manifest].present? ? options[:manifest] : 'application'

    manifest = File.join(Rails.root, 'app', 'assets', tech[:group], manifest_name + tech[:extension])

    path = options[:remove_from_manifest] ? manifest : level_path(options[:level], tech)

    gsub_file(path, string_to_append(tech, path_without_extension), '') if File.exist? path
  end
end