Skip to content

Commit

Permalink
Load config variables from YAML file and not initializer to support m…
Browse files Browse the repository at this point in the history
…ultiple environments. Add Python path to config variables
  • Loading branch information
Matt committed Jan 5, 2010
1 parent dc3f5f7 commit 8403766
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
19 changes: 11 additions & 8 deletions lib/google_closure_compiler.rb
@@ -1,4 +1,6 @@
require "rexml/document"
require "yaml"

require "app/helpers/google_closure_helper"

require 'google_closure_compiler/javascript'
Expand Down Expand Up @@ -35,25 +37,26 @@ def join_asset_file_contents_with_compilation(files)

module GoogleClosureCompiler
class << self
attr_accessor :compilation_level, :compiler_application_path, :java_path, :closure_library_path
def configure
yield self
end
CONFIG = YAML.load_file(File.join(RAILS_ROOT, 'config', 'google_closure_compiler.yml'))[RAILS_ENV] || {}

def compiler_application_path
@compiler_application_path || File.join(File.dirname(__FILE__), '..', 'bin', 'compiler.jar')
CONFIG['compiler_application_path'] || File.join(File.dirname(__FILE__), '..', 'bin', 'compiler.jar')
end

def compilation_level
@compilation_level || 'SIMPLE_OPTIMIZATIONS'
CONFIG['compilation_level'] || 'SIMPLE_OPTIMIZATIONS'
end

def java_path
@java_path || 'java'
CONFIG['java_path'] || 'java'
end

def python_path
CONFIG['python_path'] || 'python'
end

def closure_library_path
@closure_library_path || 'closure'
CONFIG['closure_library_path'] || 'closure'
end

def closure_library_full_path
Expand Down
3 changes: 2 additions & 1 deletion lib/google_closure_compiler/javascript.rb
Expand Up @@ -72,10 +72,11 @@ def closure_require_statements_used?
end

def expand_closure_dependencies
`#{closure_expand_script} -i #{content_file_path} -p #{GoogleClosureCompiler.closure_library_full_path} -o script > #{expanded_content_file_path}`
`#{GoogleClosureCompiler.python_path} #{closure_expand_script} -i #{content_file_path} -p #{GoogleClosureCompiler.closure_library_full_path} -o script > #{expanded_content_file_path}`
if $?.success?
File.delete(content_file_path)
File.move(expanded_content_file_path, content_file_path)
@content = File.read(content_file_path)
else
File.delete(expanded_content_file_path)
end
Expand Down

0 comments on commit 8403766

Please sign in to comment.