lib/middleman/ember/extension.rb in middleman-ember-0.0.2 vs lib/middleman/ember/extension.rb in middleman-ember-0.1.0

- old
+ new

@@ -5,45 +5,54 @@ class << self def registered(app, options_hash={}, &block) app.send :include, InstanceMethods app.set :ember_variant, :development + @@options = OpenStruct.new(default_options.merge(options_hash)) + yield @@options if block_given? + app.after_configuration do ember_version = if app.ember_variant == :production "prod." else "" end + # copy in the relevant version of Ember FileUtils.mkdir_p(ember_asset_path) - FileUtils.cp(::Ember::Source.bundled_path_for("ember.#{ember_version}js"), ember_asset_path.join("ember.js")) - FileUtils.cp(::Ember::Data::Source.bundled_path_for("ember-data.#{ember_version}js"), ember_asset_path.join("ember-data.js")) + FileUtils.cp("#{@@options.ember_path}/ember.#{ember_version}js", ember_asset_path.join("ember.js")) + FileUtils.cp("#{@@options.ember_data_path}/ember-data.#{ember_version}js", ember_asset_path.join("ember-data.js")) sprockets.append_path(ember_asset_path) - # allow for a local Ember variant - sprockets.prepend_path(ember_local_path) unless ember_local_path.nil? - # add in Handlebars path sprockets.append_path(handlebars_asset_path) end end + + def ember_options + @@options + end + + private + + def default_options + { + ember_path: ::Ember::Source.bundled_path_for(""), + ember_data_path: ::Ember::Data::Source.bundled_path_for(""), + handlebars_path: File.dirname(::Handlebars::Source.bundled_path) + } + end alias :included :registered end module InstanceMethods def ember_asset_path Pathname.new(File.join("#{root}/tmp/middleman-ember")) end def handlebars_asset_path - File.dirname(::Handlebars::Source.bundled_path) + ::Middleman::Ember.ember_options.handlebars_path end - - def ember_local_path - local_path = "#{root}/vendor/assets/ember" - File.directory?(local_path) ? local_path : nil - end end - end end \ No newline at end of file