Class: JBundle::Compiler
- Inherits:
-
Object
- Object
- JBundle::Compiler
- Defined in:
- lib/jbundle/builder.rb
Constant Summary collapse
- BUILDABLE_FILES =
['.js']
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#src_dir ⇒ Object
readonly
Returns the value of attribute src_dir.
Instance Method Summary collapse
- #buildable? ⇒ Boolean
- #ext ⇒ Object
- #filtered_licenses ⇒ Object
- #filtered_src ⇒ Object
-
#initialize(name, file_list, config) ⇒ Compiler
constructor
A new instance of Compiler.
- #licenses ⇒ Object
- #min ⇒ Object
- #min_name ⇒ Object
- #raw_src ⇒ Object
- #src ⇒ Object
-
#src_path ⇒ Object
This only makes sense for one-file objects.
Constructor Details
#initialize(name, file_list, config) ⇒ Compiler
Returns a new instance of Compiler.
11 12 13 14 |
# File 'lib/jbundle/builder.rb', line 11 def initialize(name, file_list, config) @config, @file_list, @src_dir = config, file_list, config.src_dir @name, @dir = parse_name(name) end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
9 10 11 |
# File 'lib/jbundle/builder.rb', line 9 def dir @dir end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/jbundle/builder.rb', line 9 def name @name end |
#src_dir ⇒ Object (readonly)
Returns the value of attribute src_dir.
9 10 11 |
# File 'lib/jbundle/builder.rb', line 9 def src_dir @src_dir end |
Instance Method Details
#buildable? ⇒ Boolean
20 21 22 |
# File 'lib/jbundle/builder.rb', line 20 def buildable? BUILDABLE_FILES.include?(ext) end |
#ext ⇒ Object
16 17 18 |
# File 'lib/jbundle/builder.rb', line 16 def ext @ext ||= ::File.extname(name) end |
#filtered_licenses ⇒ Object
37 38 39 |
# File 'lib/jbundle/builder.rb', line 37 def filtered_licenses @filtered_licenses ||= filter(licenses, :all) end |
#filtered_src ⇒ Object
41 42 43 |
# File 'lib/jbundle/builder.rb', line 41 def filtered_src @filtered_src ||= filter(raw_src, :all) end |
#licenses ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/jbundle/builder.rb', line 52 def licenses @licenses ||= if @file_list.respond_to?(:licenses) read_files @file_list.licenses else '' end end |
#min ⇒ Object
33 34 35 |
# File 'lib/jbundle/builder.rb', line 33 def min @min ||= filter(filtered_licenses, :min) + Closure::Compiler.new.compile(filter(filtered_src, :min)) end |
#min_name ⇒ Object
45 46 47 48 49 50 |
# File 'lib/jbundle/builder.rb', line 45 def min_name @min_name ||= ( ext = ::File.extname(name) name.sub(ext, '') + '.min' + ext ) end |
#raw_src ⇒ Object
60 61 62 |
# File 'lib/jbundle/builder.rb', line 60 def raw_src @raw_src ||= read_files(@file_list) end |
#src ⇒ Object
29 30 31 |
# File 'lib/jbundle/builder.rb', line 29 def src @src ||= filter(filtered_licenses + filtered_src, :src) end |
#src_path ⇒ Object
This only makes sense for one-file objects
25 26 27 |
# File 'lib/jbundle/builder.rb', line 25 def src_path ::File.join(@src_dir, @file_list.original_name) end |