Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Asset management code #363

Merged
merged 1 commit into from
Dec 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
master
------

* Extract `include_ember_*_tags` and the associated code to the
`ember-cli-rails-assets` gem. Add `ember-cli-rails-assets` as a dependency.
[#363]
* Introduce `mount_ember_assets` to serve Ember assets in asset-helper style
projects.

[#363]: https://github.com/thoughtbot/ember-cli-rails/pull/363

0.6.0
-----

Expand Down
21 changes: 0 additions & 21 deletions app/helpers/ember_rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "html_page/capture"
require "ember_cli/assets"

module EmberRailsHelper
def render_ember_app(name, &block)
Expand All @@ -11,24 +10,4 @@ def render_ember_app(name, &block)

render inline: EmberCli[name].index_html(head: head, body: body)
end

def include_ember_script_tags(name, **options)
EmberCli[name].build

assets = EmberCli::Assets.new(EmberCli[name])

assets.javascript_assets.
map { |src| %{<script src="#{src}"></script>}.html_safe }.
reduce(&:+)
end

def include_ember_stylesheet_tags(name, **options)
EmberCli[name].build

assets = EmberCli::Assets.new(EmberCli[name])

assets.stylesheet_assets.
map { |src| %{<link rel="stylesheet" href="#{src}">}.html_safe }.
reduce(&:+)
end
end
1 change: 1 addition & 0 deletions ember-cli-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = ">= 2.1.0"

spec.add_dependency "ember-cli-rails-assets", ">= 0.6.1"
spec.add_dependency "railties", ">= 3.2", "< 5"
spec.add_dependency "cocaine", "~> 0.5.8"
spec.add_dependency "html_page", "~> 0.1.0"
Expand Down
3 changes: 2 additions & 1 deletion lib/ember-cli-rails.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "fileutils"
require "ember_cli/engine" if defined?(Rails)
require "ember_cli/engine"
require "ember-cli-rails-assets"
require "ember_cli/errors"

module EmberCli
Expand Down
6 changes: 5 additions & 1 deletion lib/ember_cli/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ def initialize(name, **options)
@build = BuildMonitor.new(name, @paths)
end

def root
def root_path
paths.root
end

def dist_path
paths.dist
end

def compile
@compiled ||= begin
prepare
Expand Down
64 changes: 0 additions & 64 deletions lib/ember_cli/asset_map.rb

This file was deleted.

51 changes: 0 additions & 51 deletions lib/ember_cli/assets.rb

This file was deleted.

30 changes: 0 additions & 30 deletions lib/ember_cli/directory_asset_map.rb

This file was deleted.

12 changes: 0 additions & 12 deletions lib/ember_cli/path_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,10 @@ def dist
@dist ||= ember_cli_root.join("apps", app_name).tap(&:mkpath)
end

def asset_map
@asset_map ||= Pathname.glob(assets.join("assetMap*.json")).first
end

def assets
@assets ||= dist.join("assets").tap(&:mkpath)
end

def gemfile
@gemfile ||= root.join("Gemfile")
end

def package_json_file
@package_json_file ||= root.join("package.json")
end

def ember
@ember ||= begin
root.join("node_modules", ".bin", "ember").tap do |path|
Expand Down
10 changes: 3 additions & 7 deletions lib/ember_cli/route_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
module ActionDispatch
module Routing
class Mapper
def mount_ember_assets(app_name, to: "/")
dist_directory = EmberCli[app_name].paths.dist

mount Rack::File.new(dist_directory.to_s) => to
end

def mount_ember_app(app_name, to:, **options)
routing_options = options.deep_merge(
defaults: { ember_app: app_name },
Expand All @@ -25,7 +19,9 @@ def mount_ember_app(app_name, to:, **options)
get("#{to}(*rest)", routing_options)
end

mount_ember_assets app_name, to: to
dist_directory = EmberCli[app_name].paths.dist

mount Rack::File.new(dist_directory.to_s) => to
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/ember/heroku/heroku_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def inject_12factor_gem

def app_paths
EmberCli.apps.values.map do |app|
app.root.relative_path_from(Rails.root)
app.root_path.relative_path_from(Rails.root)
end
end
end
Expand Down
28 changes: 22 additions & 6 deletions spec/lib/ember_cli/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,33 @@
end
end

describe "#root" do
describe "#root_path" do
it "delegates to PathSet" do
root_path = Pathname(".")
allow_any_instance_of(EmberCli::PathSet).
to receive(:root).
and_return(root_path)
stub_paths(root: root_path)
app = EmberCli::App.new("foo")

root = app.root
root_path = app.root_path

expect(root).to eq root_path
expect(root_path).to eq root_path
end
end

describe "#dist_path" do
it "delegates to PathSet" do
dist_path = Pathname(".")
stub_paths(dist: dist_path)
app = EmberCli::App.new("foo")

dist_path = app.dist_path

expect(dist_path).to eq dist_path
end
end

def stub_paths(method_to_value)
allow_any_instance_of(EmberCli::PathSet).
to receive(method_to_value.keys.first).
and_return(method_to_value.values.first)
end
end
77 changes: 0 additions & 77 deletions spec/lib/ember_cli/asset_map_spec.rb

This file was deleted.

Loading