lib/middleman/ember/extension.rb in middleman-ember-0.2.3 vs lib/middleman/ember/extension.rb in middleman-ember-0.2.4
- old
+ new
@@ -17,26 +17,48 @@
@@options = OpenStruct.new(default_options.merge(options_hash))
yield @@options if block_given?
app.after_configuration do
- ember_version =
+ # Create destination directory
+ FileUtils.mkdir_p(ember_asset_path)
+
+ # Generate ember source and destination paths
+ ember_source_path = "#{@@options.ember_path}/ember"
+ ember_destination_path = ember_asset_path.join("ember.js")
+
+ # Copy the relevant version of ember
+ if ember_variant == :production
+ FileUtils.cp("#{ember_source_path}.prod.js", ember_destination_path)
+ elsif FileTest.file?("#{ember_source_path}.debug.js")
+ FileUtils.cp("#{ember_source_path}.debug.js", ember_destination_path)
+ else
+ FileUtils.cp("#{ember_source_path}.js", ember_destination_path)
+ end
+
+
+ # Only copy ember_data_path if defined. Allows you to just use Ember.
+ if @@options.ember_data_path
+ # Generate ember-data source and destination paths
+ ember_data_source_path = "#{@@options.ember_data_path}/ember-data"
+ ember_data_destination_path = ember_asset_path.join("ember-data.js")
+
+ # Copy the relevant version of ember-data
if ember_variant == :production
- "prod."
+ FileUtils.cp("#{ember_data_source_path}.prod.js", ember_data_destination_path)
else
- ""
+ FileUtils.cp("#{ember_data_source_path}.js", ember_data_destination_path)
+ # Copy ember-data map file if it exists
+ if FileTest.file?("#{ember_data_source_path}.js.map")
+ FileUtils.cp("#{ember_data_source_path}.js.map", ember_asset_path.join("ember-data.js.map"))
+ end
end
-
- # copy in the relevant version of Ember
- FileUtils.mkdir_p(ember_asset_path)
- FileUtils.cp("#{@@options.ember_path}/ember.#{ember_version}js", ember_asset_path.join("ember.js"))
- # only copy ember_data_path if defined. Allows you to just use Ember.
- if @@options.ember_data_path
- FileUtils.cp("#{@@options.ember_data_path}/ember-data.#{ember_version}js", ember_asset_path.join("ember-data.js"))
end
+
+ # Register ember path with sprockets
sprockets.append_path(ember_asset_path)
- # add in Handlebars path
+ # Register handlebars path with sprockets
sprockets.append_path(handlebars_asset_path)
end
end
def ember_options