Class: Gumbo::AssetBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/gumbo/asset_builder.rb

Constant Summary collapse

DEFAULT_SOURCE_DIR =
"assets"
DEFAULT_OUTPUT_DIR =
"public"
DEFAULT_PACKAGES_FILE =
"packages.yml"
DEFAULT_MANIFEST_FILE =
"packages.json"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ AssetBuilder

Returns a new instance of AssetBuilder.



20
21
22
23
24
25
26
# File 'lib/gumbo/asset_builder.rb', line 20

def initialize(attrs={})
  self.clean = !!attrs[:clean]
  self.source_dir = attrs.fetch(:source_dir, DEFAULT_SOURCE_DIR)
  self.output_dir = attrs.fetch(:output_dir, DEFAULT_OUTPUT_DIR)
  self.packages_file = File.join(source_dir, attrs.fetch(:packages_file, DEFAULT_PACKAGES_FILE))
  self.manifest_file = File.join(output_dir, attrs.fetch(:manifest_file, DEFAULT_MANIFEST_FILE))
end

Instance Attribute Details

#cleanObject

Returns the value of attribute clean.



14
15
16
# File 'lib/gumbo/asset_builder.rb', line 14

def clean
  @clean
end

#manifest_fileObject

Returns the value of attribute manifest_file.



14
15
16
# File 'lib/gumbo/asset_builder.rb', line 14

def manifest_file
  @manifest_file
end

#output_dirObject

Returns the value of attribute output_dir.



14
15
16
# File 'lib/gumbo/asset_builder.rb', line 14

def output_dir
  @output_dir
end

#packages_fileObject

Returns the value of attribute packages_file.



14
15
16
# File 'lib/gumbo/asset_builder.rb', line 14

def packages_file
  @packages_file
end

#source_dirObject

Returns the value of attribute source_dir.



14
15
16
# File 'lib/gumbo/asset_builder.rb', line 14

def source_dir
  @source_dir
end

Class Method Details

.build(attrs = {}) ⇒ Object



16
17
18
# File 'lib/gumbo/asset_builder.rb', line 16

def self.build(attrs={})
  new(attrs).build
end

Instance Method Details

#buildObject



28
29
30
31
32
33
34
# File 'lib/gumbo/asset_builder.rb', line 28

def build
  clean_output_dir if clean
  create_output_dir
  build_package_files
  build_packages
  build_non_package_files
end