Class: CoffeeScriptRunner
- Inherits:
-
Object
- Object
- CoffeeScriptRunner
- Defined in:
- lib/tasks/coffeescript/coffeescript_runner.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(binary, dir, filter, dir_finder) ⇒ CoffeeScriptRunner
constructor
A new instance of CoffeeScriptRunner.
-
#is_configured?(all_files) ⇒ Boolean
TODO: Only return true if we can find the node binary.
- #name ⇒ Object
- #should_run?(modified_files) ⇒ Boolean
Constructor Details
#initialize(binary, dir, filter, dir_finder) ⇒ CoffeeScriptRunner
Returns a new instance of CoffeeScriptRunner.
3 4 5 6 7 8 9 10 |
# File 'lib/tasks/coffeescript/coffeescript_runner.rb', line 3 def initialize(binary, dir, filter, dir_finder) @binary = binary @dir = dir @filter = filter @coffeescript_dir_finder = dir_finder @js_dir = dir + '/src' end |
Instance Method Details
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tasks/coffeescript/coffeescript_runner.rb', line 16 def execute output = [] @coffee_dirs.each do |coffee_dir| js_dir = coffee_dir.sub '/coffee-', '/' output.push `#{@binary} --output "#{js_dir}" --compile "#{coffee_dir}" 2>&1` end return output.join "\n" end |
#is_configured?(all_files) ⇒ Boolean
TODO: Only return true if we can find the node binary
28 29 30 31 |
# File 'lib/tasks/coffeescript/coffeescript_runner.rb', line 28 def is_configured?(all_files) @coffee_dirs = (@coffeescript_dir_finder.find all_files).uniq return @coffee_dirs.length > 0 end |
#name ⇒ Object
12 13 14 |
# File 'lib/tasks/coffeescript/coffeescript_runner.rb', line 12 def name return 'CoffeeScript' end |
#should_run?(modified_files) ⇒ Boolean
33 34 35 |
# File 'lib/tasks/coffeescript/coffeescript_runner.rb', line 33 def should_run?(modified_files) return !(modified_files.detect { |file| @filter.filter(file) }).nil? || modified_files.include?(@config) end |