Skip to content

Commit

Permalink
Defer to EmberCLI build pipeline
Browse files Browse the repository at this point in the history
Closes [#30].

Depends on [rondale-sc/ember-cli-rails-addon#17][#17].

* Symlink `dist/` directly to Asset Pipeline
* Deletes `EmberCli::AssetResolver`
* Improve `bin/setup`, resolve errors.

[#30]: #30
[#17]: rondale-sc/ember-cli-rails-addon#17
  • Loading branch information
seanpdoyle committed Nov 8, 2015
1 parent 2c25935 commit cbe418b
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 161 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
master
------

* Symlink `dist/` directly to Asset Pipeline [#250]
* Merge EmberCLI-generated `manifest.json` into Sprocket's [#250]
* `manifest.json`. Since we now defer to EmberCLI, we no longer need to
manually resolve asset URLs. [#250]

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

0.4.3
-----

Expand Down
3 changes: 0 additions & 3 deletions bin/bundle

This file was deleted.

1 change: 1 addition & 0 deletions ember-cli-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = ">= 2.1.0"

spec.add_dependency "railties", ">= 3.2", "< 5"
spec.add_dependency "sprockets-redirect", "~> 0.3.0"
spec.add_dependency "sprockets", ">= 2.0"
end
15 changes: 4 additions & 11 deletions lib/ember-cli/app.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require "timeout"
require "ember-cli/html_page"
require "ember-cli/asset_resolver"

module EmberCli
class App
Expand Down Expand Up @@ -76,12 +75,7 @@ def stop
end

def index_html(sprockets:, head:, body:)
asset_resolver = AssetResolver.new(
app: self,
sprockets: sprockets,
)
html_page = HtmlPage.new(
asset_resolver: asset_resolver,
content: index_file.read,
head: head,
body: body,
Expand All @@ -96,11 +90,11 @@ def exposed_js_assets
alias exposed_css_assets exposed_js_assets

def vendor_assets
"#{name}/vendor"
"#{name}/assets/vendor"
end

def application_assets
"#{name}/#{ember_app_name}"
"#{name}/assets/#{ember_app_name}"
end

def wait
Expand Down Expand Up @@ -268,14 +262,14 @@ def index_file
end

def symlink_to_assets_root
assets_path.make_symlink dist_path.join("assets")
assets_path.make_symlink dist_path
rescue Errno::EEXIST
# Sometimes happens when starting multiple Unicorn workers.
# Ignoring...
end

def add_assets_to_precompile_list
Rails.configuration.assets.precompile << /\A#{name}\//
Rails.configuration.assets.precompile << %r{\A#{name}/}
end

def command(watch: false)
Expand Down Expand Up @@ -342,7 +336,6 @@ def excluded_ember_deps
def env_hash
ENV.to_h.tap do |vars|
vars["RAILS_ENV"] = Rails.env
vars["DISABLE_FINGERPRINTING"] = "true"
vars["EXCLUDE_EMBER_ASSETS"] = excluded_ember_deps
vars["BUNDLE_GEMFILE"] = gemfile_path.to_s if gemfile_path.exist?
end
Expand Down
54 changes: 0 additions & 54 deletions lib/ember-cli/asset_resolver.rb

This file was deleted.

23 changes: 8 additions & 15 deletions lib/ember-cli/html_page.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module EmberCli
class HtmlPage
def initialize(content:, asset_resolver:, head: "", body: "")
def initialize(content:, head: "", body: "")
@content = content
@asset_resolver = asset_resolver
@head = head
@body = body
end
Expand All @@ -16,11 +15,13 @@ def render
insert_body_content
end

html
content
end

private

attr_reader :content

def has_head_tag?
head_tag_index >= 0
end
Expand All @@ -30,27 +31,19 @@ def has_body_tag?
end

def insert_head_content
html.insert(head_tag_index, @head.to_s)
content.insert(head_tag_index, @head.to_s)
end

def insert_body_content
html.insert(body_tag_index, @body.to_s)
end

def html
@html ||= resolved_html
content.insert(body_tag_index, @body.to_s)
end

def head_tag_index
html.index("</head") || -1
content.index("</head") || -1
end

def body_tag_index
html.index("</body") || -1
end

def resolved_html
@asset_resolver.resolve_urls(@content)
content.index("</body") || -1
end
end
end
65 changes: 0 additions & 65 deletions spec/ember-cli/asset_resolver_spec.rb

This file was deleted.

13 changes: 0 additions & 13 deletions spec/ember-cli/html_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
it "injects into the <head>" do
content = valid_content
html_page = EmberCli::HtmlPage.new(
asset_resolver: build_asset_resolver(content),
content: content,
head: "injected!",
)
Expand All @@ -21,7 +20,6 @@
it "injects into the <body>" do
content = valid_content
html_page = EmberCli::HtmlPage.new(
asset_resolver: build_asset_resolver(content),
content: content,
body: "injected!",
)
Expand All @@ -38,7 +36,6 @@
it "does nothing" do
content = "<html></html>"
html_page = EmberCli::HtmlPage.new(
asset_resolver: build_asset_resolver(content),
content: content,
head: "injected!",
body: "injected!",
Expand All @@ -50,16 +47,6 @@
end
end

def build_asset_resolver(content)
resolver = double("EmberCli::AssetResolver")
allow(resolver).
to receive(:resolve_urls).
with(content).
and_return(content)

resolver
end

def valid_content
"<html><head><title></title></head><body><h1></h1></body></html>"
end
Expand Down

0 comments on commit cbe418b

Please sign in to comment.