Class: Embork::Borkfile::DSL
- Inherits:
-
Object
- Object
- Embork::Borkfile::DSL
show all
- Includes:
- Attributes
- Defined in:
- lib/embork/borkfile.rb
Constant Summary
collapse
- SUPPORTED_FRAMEWORKS =
%w(bootstrap compass)
- SUPPORTED_COMPRESSORS =
%w(closure_compiler uglify)
Instance Attribute Summary
Attributes included from Attributes
#asset_paths, #backend, #compressor, #es6_transform, #frameworks, #helpers, #html, #phrender_index_file, #phrender_javascript_paths, #phrender_raw_javascript, #project_root, #sprockets_engines, #sprockets_postprocessors, #sprockets_preprocessors
Instance Method Summary
collapse
Methods included from Attributes
#es6_namespace
Constructor Details
#initialize(environment, logger) ⇒ DSL
Returns a new instance of DSL.
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/embork/borkfile.rb', line 38
def initialize(environment, logger)
Embork.env = @environment = environment.to_sym
@asset_paths = []
@helpers = []
@sprockets_postprocessors = []
@sprockets_preprocessors = []
@sprockets_engines = []
@project_root = nil
@html = []
@backend = :static_index
@es6_namespace = nil
@frameworks = []
@logger = logger
@compressor = nil
@es6_transform = nil
@phrender_javascript_paths = []
@phrender_raw_javascript = []
@phrender_index_file = nil
end
|
Instance Method Details
#add_sprockets_helpers(&block) ⇒ Object
85
86
87
|
# File 'lib/embork/borkfile.rb', line 85
def add_sprockets_helpers(&block)
helpers.push block
end
|
#append_asset_path(path) ⇒ Object
81
82
83
|
# File 'lib/embork/borkfile.rb', line 81
def append_asset_path(path)
@asset_paths.push path
end
|
#compile_html(files) ⇒ Object
115
116
117
118
|
# File 'lib/embork/borkfile.rb', line 115
def compile_html(files)
files = [ files ] unless files.kind_of? Array
@html.concat files
end
|
#compress_with(compressor) ⇒ Object
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/embork/borkfile.rb', line 120
def compress_with(compressor)
if compressor.class == Symbol && SUPPORTED_COMPRESSORS.include?(compressor.to_s)
@compressor = compressor
elsif compressor.class != String
@compressor = compressor
else
@logger.critical 'Compressor "%s" is not currently supported by embork.' % compressor.to_s
@logger.unknown ''
exit 1
end
end
|
105
106
107
108
109
|
# File 'lib/embork/borkfile.rb', line 105
def configure(environment, &block)
if environment == @environment
self.instance_exec &block
end
end
|
#get_binding ⇒ Object
111
112
113
|
# File 'lib/embork/borkfile.rb', line 111
def get_binding
binding
end
|
#phrender_add_javascript(code) ⇒ Object
101
102
103
|
# File 'lib/embork/borkfile.rb', line 101
def phrender_add_javascript(code)
@phrender_raw_javascript.push code
end
|
#phrender_add_javascript_file(path) ⇒ Object
97
98
99
|
# File 'lib/embork/borkfile.rb', line 97
def phrender_add_javascript_file(path)
@phrender_javascript_paths.push path
end
|
#register_engine(extension, klass) ⇒ Object
77
78
79
|
# File 'lib/embork/borkfile.rb', line 77
def register_engine(extension, klass)
@sprockets_engines.push({ :extension => extension, :klass => klass })
end
|
#register_postprocessor(mime_type, klass) ⇒ Object
69
70
71
|
# File 'lib/embork/borkfile.rb', line 69
def register_postprocessor(mime_type, klass)
@sprockets_postprocessors.push({ :mime_type => mime_type, :klass => klass })
end
|
#register_preprocessor(mime_type, klass) ⇒ Object
73
74
75
|
# File 'lib/embork/borkfile.rb', line 73
def register_preprocessor(mime_type, klass)
@sprockets_preprocessors.push({ :mime_type => mime_type, :klass => klass })
end
|
#set_backend(app) ⇒ Object
93
94
95
|
# File 'lib/embork/borkfile.rb', line 93
def set_backend(app)
@backend = app
end
|
#set_project_root(path) ⇒ Object
89
90
91
|
# File 'lib/embork/borkfile.rb', line 89
def set_project_root(path)
@project_root = path
end
|
132
133
134
135
136
137
138
139
|
# File 'lib/embork/borkfile.rb', line 132
def transform_es6_module_names(transform_proc)
if transform_proc.respond_to?(:call) || transform_proc.nil?
@es6_transform = transform_proc
else
@logger.critical 'ES6 Module transform must respond to #call'
exit 1
end
end
|
#use_framework(framework) ⇒ Object
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/embork/borkfile.rb', line 58
def use_framework(framework)
framework = framework.to_s
if SUPPORTED_FRAMEWORKS.include? framework
@frameworks.push framework
else
@logger.critical 'Framework "%s" is not currently supported by embork.' % framework
@logger.unknown ''
exit 1
end
end
|