Class: Rake::Minify::Source
- Inherits:
-
Object
- Object
- Rake::Minify::Source
- Defined in:
- lib/rake/minify/source.rb
Instance Attribute Summary collapse
-
#minify ⇒ Object
readonly
Returns the value of attribute minify.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #build ⇒ Object
- #coffee? ⇒ Boolean
-
#initialize(source, options = nil) ⇒ Source
constructor
A new instance of Source.
Constructor Details
#initialize(source, options = nil) ⇒ Source
Returns a new instance of Source.
4 5 6 7 8 9 10 |
# File 'lib/rake/minify/source.rb', line 4 def initialize(source, =nil) ||= {} @source = source @minify = optional_boolean([:minify], true) @coffee_bare = optional_boolean([:bare], false) @coffee = [:coffeescript] end |
Instance Attribute Details
#minify ⇒ Object (readonly)
Returns the value of attribute minify.
2 3 4 |
# File 'lib/rake/minify/source.rb', line 2 def minify @minify end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
2 3 4 |
# File 'lib/rake/minify/source.rb', line 2 def source @source end |
Instance Method Details
#build ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rake/minify/source.rb', line 12 def build coffee_script! if coffee? if source.respond_to? :call output = source.call else output = Kernel.open(source) { |input| input.read } end output = CoffeeScript.compile(output, :bare => @coffee_bare) if coffee? output = JSMin.minify(output).strip if minify output end |
#coffee? ⇒ Boolean
27 28 29 |
# File 'lib/rake/minify/source.rb', line 27 def coffee? source =~ /\.coffee$/ or @coffee end |