lib/embork/borkfile.rb in embork-0.0.4 vs lib/embork/borkfile.rb in embork-0.0.5
- old
+ new
@@ -11,11 +11,21 @@
attr_reader :sprockets_preprocessors
attr_reader :sprockets_engines
attr_reader :backend
attr_reader :html
attr_reader :frameworks
+ attr_reader :compressor
+ attr_reader :es6_transform
+ attr_reader :phrender_index_file
+ attr_reader :phrender_javascript_paths
+ attr_reader :phrender_raw_javascript
+ # request uri path to the index file.
+ def phrender_index_file(index_file_path = nil)
+ @phrender_index_file = index_file_path || @phrender_index_file
+ end
+
def keep_old_versions(number_to_keep = nil)
@keep_old_versions = number_to_keep || @keep_old_versions
end
def es6_namespace(namespace = nil)
@@ -25,13 +35,14 @@
class DSL
include Attributes
SUPPORTED_FRAMEWORKS = %w(bootstrap compass)
+ SUPPORTED_COMPRESSORS = %w(closure_compiler uglifier)
def initialize(environment, logger)
- Embork.env = @environment = environment
+ Embork.env = @environment = environment.to_sym
@asset_paths = []
@helpers = []
@sprockets_postprocessors = []
@sprockets_preprocessors = []
@sprockets_engines = []
@@ -40,15 +51,20 @@
@backend = :static_index
@keep_old_versions = 5
@es6_namespace = nil
@frameworks = []
@logger = logger
+ @compressor = nil
+ @es6_transform = nil
+ @phrender_javascript_paths = []
+ @phrender_raw_javascript = []
+ @phrender_index_file = nil
end
def use_framework(framework)
framework = framework.to_s
- if SUPPORTED_FRAMEWORKS.include? 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
@@ -81,24 +97,52 @@
def set_backend(app)
@backend = app
end
+ def phrender_add_javascript_file(path)
+ @phrender_javascript_paths.push path
+ end
+
+ def phrender_add_javascript(code)
+ @phrender_raw_javascript.push code
+ end
+
def configure(environment, &block)
if environment == @environment
self.instance_exec &block
end
end
def get_binding
- return binding
+ binding
end
def compile_html(files)
files = [ files ] unless files.kind_of? Array
@html.concat files
end
+
+ def compress_with(compressor)
+ if SUPPORTED_COMPRESSORS.include? compressor.to_s
+ @compressor = compressor
+ else
+ @logger.critical 'Compressor "%s" is not currently supported by embork.' % compressor.to_s
+ @logger.unknown ''
+ exit 1
+ end
+ end
+
+ 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
+
end
include Attributes
def initialize(path_to_borkfile, environment = :development)
@@ -121,11 +165,12 @@
end
def set_options(file)
# Setup paths
default_paths = [
- 'app',
'config/%s' % [ @environment.to_s ],
+ 'app',
+ 'app/styles',
'components'
]
@asset_paths = default_paths.concat file.asset_paths
# Setup root