Skip to content
Browse files

extract ember and handlebars versions from source

  • Loading branch information...
1 parent 74f055b commit bd00cf75a78eb816e35531e2101c6b4d250dce99 @tchak tchak committed Apr 10, 2012
View
27 lib/ember/handlebars/source.rb
@@ -8,25 +8,28 @@ def precompiler_path
File.expand_path(File.join(__FILE__, "../assets/ember-precompiler.js"))
end
- def bundled_path
- File.expand_path(File.join(__FILE__, "../../../../vendor/assets/javascripts/ember.js"))
- end
+ def vendor_path
+ path = ::Rails.root.nil? ? '' : ::Rails.root.join('vendor/assets/javascripts/ember.js')
- def path
- @path ||= ENV["EMBER_SOURCE_PATH"] || bundled_path
+ if !File.exists?(path)
+ path = File.expand_path(File.join(__FILE__, "../../../../vendor/assets/javascripts/ember.js"))
+ end
end
- def path=(path)
- @contents = @version = @context = nil
- @path = path
+ def path
+ @path ||= ENV["EMBER_SOURCE_PATH"] || vendor_path
end
def contents
@contents ||= [File.read(precompiler_path), File.read(path)].join("\n")
end
- def version
- @version ||= contents[/^Handlebars.VERSION = "([^"]*)"/, 1]
+ def handlebars_version
+ @handlebars_version ||= contents[/^Handlebars.VERSION = "([^"]*)"/, 1]
+ end
+
+ def ember_version
+ @ember_version ||= contents[/^Ember.VERSION = '([^']*)'/, 1]
end
def context
@@ -36,10 +39,6 @@ def context
end
class << self
- def version
- Source.version
- end
-
def compile(template)
template = template.read if template.respond_to?(:read)
Source.context.call("EmberRails.precompile", template)
View
4 lib/ember/handlebars/version.rb
@@ -1,5 +1,7 @@
+require 'ember/handlebars/source'
+
module Ember
module Handlebars
- VERSION = '1.0.beta.2'
+ VERSION = Ember::Handlebars::Source.handlebars_version
end
end
View
4 lib/ember/rails/engine.rb
@@ -1,4 +1,6 @@
-require "ember/handlebars/template"
+require 'ember/handlebars/template'
+require 'ember/handlebars/version'
+require 'ember/version'
module Ember
module Rails
View
4 lib/ember/version.rb
@@ -1,3 +1,5 @@
+require 'ember/handlebars/source'
+
module Ember
- VERSION = "0.9.6"
+ VERSION = Ember::Handlebars::Source.ember_version
end
View
4 lib/generators/ember/install_generator.rb
@@ -1,6 +1,8 @@
+require 'ember/version'
+
module Ember
module Generators
- class InstallGenerator < Rails::Generators::Base
+ class InstallGenerator < ::Rails::Generators::Base
EMBER_FILES = [ "ember.js", "ember-dev.js" ]
RUNTIME_FILES = [ "ember-runtime.js", "ember-runtime-dev.js" ]

0 comments on commit bd00cf7

Please sign in to comment.
Something went wrong with that request. Please try again.