ember-cli-rails 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a36210f5c5119e4b769cec1174106772deb7aaea
4
- data.tar.gz: 13161690fc11f87a3ec9786aa3a312eef18a5975
3
+ metadata.gz: c875893e377992ea0a7935ecff7b435f27f3dd8a
4
+ data.tar.gz: 20a40093eb23312813a4932a4471d4464e4c651e
5
5
  SHA512:
6
- metadata.gz: e0c12d193f95eecb0a39002e47504be22a688d44c539018fd9a4328dfe4501490d652e17619254f2ffc2189562d547aa863888e1bc5a1bde56140e674febba26
7
- data.tar.gz: 1eb93dd62ab7551dcf556c759aa50ce33d1d17f851bee689fb2826dc0ab168c3f47137da0edc52597dad890054f5ba767f3368ec022242d5040898e49edf6e36
6
+ metadata.gz: a39aafa84caed46cd0007c4214e73d68268066a6be1c10a9ed0a9f164c461c68f54600beecbae9c2b14703aaca02f29f25e0546335fc3a484089278468250fc7
7
+ data.tar.gz: a07e683152ffe4fb647baad272dda0535eabc8b2aaafb95468a31ca664d8d43ab2cb7ae4671ef57f41bef5171238610b1a3660300ddfddf3a67a4cfde7be587d
@@ -1,6 +1,17 @@
1
1
  master
2
2
  ------
3
3
 
4
+ 0.6.1
5
+ -----
6
+
7
+ * Extract `include_ember_*_tags` and the associated code to the
8
+ `ember-cli-rails-assets` gem. Add `ember-cli-rails-assets` as a dependency.
9
+ [#363]
10
+ * Introduce `mount_ember_assets` to serve Ember assets in asset-helper style
11
+ projects.
12
+
13
+ [#363]: https://github.com/thoughtbot/ember-cli-rails/pull/363
14
+
4
15
  0.6.0
5
16
  -----
6
17
 
data/README.md CHANGED
@@ -13,9 +13,13 @@ EmberCLI-Rails is designed to give you the best of both worlds:
13
13
  stack through JavaScript-enabled Capybara tests
14
14
  * Deploy your entire suite of applications to Heroku with a single `git push`
15
15
 
16
- **EmberCLI-Rails Supports EmberCLI 1.13.x and later.**
16
+ If you're having trouble, checkout the [example project]!
17
17
 
18
- ## Installation
18
+ **EmberCLI-Rails Supports EmberCLI 1.13.13 and later.**
19
+
20
+ [example project]: https://github.com/seanpdoyle/ember-cli-rails-heroku-example
21
+
22
+ ## Install
19
23
 
20
24
  Add the following to your `Gemfile`:
21
25
 
@@ -29,7 +33,13 @@ Then run `bundle install`:
29
33
  $ bundle install
30
34
  ```
31
35
 
32
- ## Usage
36
+ If you haven't created an Ember application yet, generate a new one:
37
+
38
+ ```bash
39
+ $ ember new frontend --skip-git
40
+ ```
41
+
42
+ ## Setup
33
43
 
34
44
  First, generate the gem's initializer:
35
45
 
@@ -47,25 +57,19 @@ EmberCli.configure do |c|
47
57
  end
48
58
  ```
49
59
 
50
- The initializer assumes that your Ember application exists in
60
+ This initializer assumes that your Ember application exists in
51
61
  `Rails.root.join("frontend")`.
52
62
 
53
63
  If this is not the case, you could
54
64
 
55
65
  * move your existing Ember application into `Rails.root.join("frontend")`
56
- * configure `frontend` to look for the Ember application in its current
66
+ * configure `frontend` to reference the Ember application in its current
57
67
  directory:
58
68
 
59
69
  ```rb
60
70
  c.app :frontend, path: "~/projects/my-ember-app"
61
71
  ```
62
72
 
63
- * generate a new Ember project:
64
-
65
- ```bash
66
- $ ember new frontend --skip-git
67
- ```
68
-
69
73
  **Initializer options**
70
74
 
71
75
  - `name` - this represents the name of the Ember CLI application.
@@ -105,7 +109,9 @@ For instance, if you're using the `0.6.x` version of the gem, specify
105
109
  [addon]: https://github.com/rondale-sc/ember-cli-rails-addon/
106
110
  [semver]: http://semver.org/
107
111
 
108
- Next, configure Rails to route requests to the `frontend` Ember application:
112
+ ## Mount
113
+
114
+ Configure Rails to route requests to the `frontend` Ember application:
109
115
 
110
116
  ```rb
111
117
  # config/routes.rb
@@ -115,9 +121,6 @@ Rails.application.routes.draw do
115
121
  end
116
122
  ```
117
123
 
118
- Ember requests will be set `params[:ember_app]` to the name of the application.
119
- In the above example, `params[:ember_app] == :frontend`.
120
-
121
124
  **Routing options**
122
125
 
123
126
  * `to` - The path to handle as an Ember application. This will only apply to
@@ -136,7 +139,69 @@ $ rake ember:install
136
139
  Boot your Rails application, navigate to `"/"`, and view your EmberCLI
137
140
  application!
138
141
 
139
- ## Heroku
142
+ ## Develop
143
+
144
+ EmberCLI Rails exposes several useful rake tasks.
145
+
146
+ **`ember:install`**
147
+
148
+ Install the Ember applications' dependencies.
149
+
150
+ **`ember:compile`**
151
+
152
+ Compile the Ember applications.
153
+
154
+ **`ember:test`**
155
+
156
+ Execute Ember's test suite.
157
+
158
+ If you're using Rake to run the test suite, make sure to configure your test
159
+ task to depend on `ember:test`.
160
+
161
+ For example, to configure a bare `rake` command to run both RSpec and Ember test
162
+ suites, configure the `default` task to depend on both `spec` and `ember:test`.
163
+
164
+ ```rb
165
+ task default: [:spec, "ember:test"]
166
+ ```
167
+
168
+ ## Deploy
169
+
170
+ In production environments, assets should be served over a
171
+ Content Delivery Network.
172
+
173
+ Configuring an `ember-cli-rails` application to serve Ember's assets over a CDN
174
+ is very similar to [configuring an EmberCLI application to serve assets over a
175
+ CDN][ember-cli-cdn]:
176
+
177
+ [ember-cli-cdn]: http://ember-cli.com/user-guide/#fingerprinting-and-cdn-urls
178
+
179
+ ```js
180
+ var app = new EmberApp({
181
+ fingerprint: {
182
+ prepend: 'https://cdn.example.com/'
183
+ }
184
+ });
185
+ ```
186
+
187
+ If you're serving the Ember application from a path other than `"/"`, the
188
+ `prepend` URL must end with the mounted path:
189
+
190
+ ```js
191
+ var app = new EmberApp({
192
+ fingerprint: {
193
+ // for an Ember application mounted to `/admin_panel/`
194
+ prepend: 'https://cdn.example.com/admin_panel/',
195
+ }
196
+ });
197
+ ```
198
+
199
+ As long as your [CDN is configured to pull from your Rails application][dns-cdn]
200
+ , your assets will be served over the CDN.
201
+
202
+ [dns-cdn]: https://robots.thoughtbot.com/dns-cdn-origin
203
+
204
+ ### Heroku
140
205
 
141
206
  To configure your EmberCLI-Rails applications for Heroku:
142
207
 
@@ -163,7 +228,32 @@ applications into the project.
163
228
 
164
229
  [buildpack]: https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app#adding-a-buildpack
165
230
 
166
- ## Overriding the defaults
231
+ ### Capistrano
232
+
233
+ EmberCLI-Rails executes both `npm install` and `bower install` during EmberCLI's
234
+ compilation, triggered by the `asset:precompilation` rake task.
235
+
236
+ The `npm` and `bower` executables are required to be defined in the deployment
237
+ SSH session's `$PATH`. It is not sufficient to modify the session's `$PATH` in
238
+ a `.bash_profile`.
239
+
240
+ To resolve this issue, prepend the Node installation's `bin` directory to the
241
+ target system's `$PATH`:
242
+
243
+ ```ruby
244
+ #config/deploy/production.rb
245
+
246
+ set :default_env, {
247
+ "PATH" => "/home/deploy/.nvm/versions/node/v4.2.1/bin:$PATH"
248
+ }
249
+ ```
250
+
251
+ The system in this example is using `nvm` to configure the node version. If
252
+ you're not using `nvm`, make sure the string you prepend to the `$PATH` variable
253
+ contains the directory or directories that contain the `bower` and `npm`
254
+ executables.
255
+
256
+ ## Override
167
257
 
168
258
  By default, routes defined by `ember_app` will be rendered with the internal
169
259
  `EmberCli::EmberController`.
@@ -235,7 +325,7 @@ class ApplicationController < ActionController::Base
235
325
  end
236
326
  ```
237
327
 
238
- #### Rendering the EmberCLI generated JS and CSS
328
+ ### Rendering the EmberCLI generated JS and CSS
239
329
 
240
330
  Rendering EmberCLI applications with `render_ember_app` is the recommended,
241
331
  actively supported method of serving EmberCLI applications.
@@ -253,9 +343,9 @@ In the corresponding view, use the asset helpers:
253
343
  <%= include_ember_stylesheet_tags :frontend %>
254
344
  ```
255
345
 
256
- ### Mounting the Ember applications
346
+ ### Mounting multiple Ember applications
257
347
 
258
- Rendering Ember applications from routes other than `/` requires additional
348
+ Rendering Ember applications to paths other than `/` requires additional
259
349
  configuration.
260
350
 
261
351
  Consider a scenario where you had Ember applications named `frontend` and
@@ -339,6 +429,7 @@ and `include_ember_stylesheet_tags` helpers to a path other than `"/"`, a
339
429
  `<base>` tag must also be injected with a corresponding `href` value:
340
430
 
341
431
  ```erb
432
+ <base href="/">
342
433
  <%= include_ember_script_tags :frontend %>
343
434
  <%= include_ember_stylesheet_tags :frontend %>
344
435
 
@@ -347,6 +438,18 @@ and `include_ember_stylesheet_tags` helpers to a path other than `"/"`, a
347
438
  <%= include_ember_stylesheet_tags :admin_panel %>
348
439
  ```
349
440
 
441
+ If you're using the `include_ember` style helpers with a single-page Ember
442
+ application that defers routing to the Rails application, insert a call to
443
+ `mount_ember_assets` at the bottom of your routes file to serve the
444
+ EmberCLI-generated assets:
445
+
446
+ ```rb
447
+ # config/routes.rb
448
+ Rails.application.routes.draw do
449
+ mount_ember_assets :frontend, to: "/"
450
+ end
451
+ ```
452
+
350
453
  ## CSRF Tokens
351
454
 
352
455
  Your Rails controllers, by default, expect a valid authenticity token to
@@ -377,32 +480,6 @@ the CSRF tags to its view's `<head>`.
377
480
  [ember-cli-rails-addon][addon] configures your Ember application to make HTTP
378
481
  requests with the injected CSRF tokens in the `X-CSRF-TOKEN` header.
379
482
 
380
- ### Integrating with Rake
381
-
382
- EmberCLI Rails exposes several useful rake tasks.
383
-
384
- **`ember:install`**
385
-
386
- Install the Ember applications' dependencies.
387
-
388
- **`ember:compile`**
389
-
390
- Compile the Ember applications.
391
-
392
- **`ember:test`**
393
-
394
- Execute Ember's test suite.
395
-
396
- If you're using Rake to run the test suite, make sure to configure your test
397
- task to depend on `ember:test`.
398
-
399
- For example, to configure a bare `rake` command to run both RSpec and Ember test
400
- suites, configure the `default` task to depend on both `spec` and `ember:test`.
401
-
402
- ```rb
403
- task default: [:spec, "ember:test"]
404
- ```
405
-
406
483
  ## Serving from multi-process servers in development
407
484
 
408
485
  If you're using a multi-process server ([Puma], [Unicorn], etc.) in development,
@@ -415,7 +492,7 @@ EmberCLI runners to clobber each others' work][#94].
415
492
  [Unicorn]: https://rubygems.org/gems/unicorn
416
493
  [#94]: https://github.com/thoughtbot/ember-cli-rails/issues/94#issuecomment-77627453
417
494
 
418
- ### `RAILS_ENV`
495
+ ## `RAILS_ENV`
419
496
 
420
497
  While being managed by EmberCLI Rails, EmberCLI process will have
421
498
  access to the `RAILS_ENV` environment variable. This can be helpful to detect
@@ -441,6 +518,12 @@ if (environment === 'development') {
441
518
 
442
519
  [ember-cli-mirage]: http://ember-cli-mirage.com/docs/latest/
443
520
 
521
+ ## EmberCLI support
522
+
523
+ This project supports:
524
+
525
+ * EmberCLI versions `>= 1.13.13`
526
+
444
527
  ## Ruby and Rails support
445
528
 
446
529
  This project supports:
@@ -1,34 +1,13 @@
1
- require "ember_cli/capture"
2
- require "ember_cli/assets"
1
+ require "html_page/capture"
3
2
 
4
3
  module EmberRailsHelper
5
4
  def render_ember_app(name, &block)
6
5
  EmberCli[name].build
7
6
 
8
- markup_capturer = EmberCli::Capture.new(sprockets: self, &block)
7
+ markup_capturer = HtmlPage::Capture.new(self, &block)
9
8
 
10
9
  head, body = markup_capturer.capture
11
10
 
12
11
  render inline: EmberCli[name].index_html(head: head, body: body)
13
12
  end
14
-
15
- def include_ember_script_tags(name, **options)
16
- EmberCli[name].build
17
-
18
- assets = EmberCli::Assets.new(EmberCli[name])
19
-
20
- assets.javascript_assets.
21
- map { |src| %{<script src="#{src}"></script>}.html_safe }.
22
- reduce(&:+)
23
- end
24
-
25
- def include_ember_stylesheet_tags(name, **options)
26
- EmberCli[name].build
27
-
28
- assets = EmberCli::Assets.new(EmberCli[name])
29
-
30
- assets.stylesheet_assets.
31
- map { |src| %{<link rel="stylesheet" href="#{src}">}.html_safe }.
32
- reduce(&:+)
33
- end
34
13
  end
@@ -1,5 +1,6 @@
1
1
  require "fileutils"
2
- require "ember_cli/engine" if defined?(Rails)
2
+ require "ember_cli/engine"
3
+ require "ember-cli-rails-assets"
3
4
  require "ember_cli/errors"
4
5
 
5
6
  module EmberCli
@@ -1,5 +1,5 @@
1
1
  require "ember_cli/shell"
2
- require "ember_cli/html_page"
2
+ require "html_page/renderer"
3
3
  require "ember_cli/build_monitor"
4
4
 
5
5
  module EmberCli
@@ -24,10 +24,14 @@ module EmberCli
24
24
  @build = BuildMonitor.new(name, @paths)
25
25
  end
26
26
 
27
- def root
27
+ def root_path
28
28
  paths.root
29
29
  end
30
30
 
31
+ def dist_path
32
+ paths.dist
33
+ end
34
+
31
35
  def compile
32
36
  @compiled ||= begin
33
37
  prepare
@@ -49,7 +53,7 @@ module EmberCli
49
53
 
50
54
  def index_html(head:, body:)
51
55
  if index_file.exist?
52
- html = HtmlPage.new(
56
+ html = HtmlPage::Renderer.new(
53
57
  head: head,
54
58
  body: body,
55
59
  content: index_file.read,
@@ -34,22 +34,10 @@ module EmberCli
34
34
  @dist ||= ember_cli_root.join("apps", app_name).tap(&:mkpath)
35
35
  end
36
36
 
37
- def asset_map
38
- @asset_map ||= Pathname.glob(assets.join("assetMap*.json")).first
39
- end
40
-
41
- def assets
42
- @assets ||= dist.join("assets").tap(&:mkpath)
43
- end
44
-
45
37
  def gemfile
46
38
  @gemfile ||= root.join("Gemfile")
47
39
  end
48
40
 
49
- def package_json_file
50
- @package_json_file ||= root.join("package.json")
51
- end
52
-
53
41
  def ember
54
42
  @ember ||= begin
55
43
  root.join("node_modules", ".bin", "ember").tap do |path|
@@ -14,13 +14,13 @@ module ActionDispatch
14
14
  format: :html,
15
15
  )
16
16
 
17
- dist_directory = EmberCli[app_name].paths.dist
18
-
19
17
  Rails.application.routes.draw do
20
18
  scope constraints: EmberCli::HtmlConstraint.new do
21
19
  get("#{to}(*rest)", routing_options)
22
20
  end
23
21
 
22
+ dist_directory = EmberCli[app_name].paths.dist
23
+
24
24
  mount Rack::File.new(dist_directory.to_s) => to
25
25
  end
26
26
  end
@@ -1,3 +1,3 @@
1
1
  module EmberCli
2
- VERSION = "0.6.0".freeze
2
+ VERSION = "0.6.1".freeze
3
3
  end
@@ -19,7 +19,7 @@ module EmberCli
19
19
 
20
20
  def app_paths
21
21
  EmberCli.apps.values.map do |app|
22
- app.root.relative_path_from(Rails.root)
22
+ app.root_path.relative_path_from(Rails.root)
23
23
  end
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-cli-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pravosud
@@ -10,8 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-11 00:00:00.000000000 Z
13
+ date: 2015-12-19 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: ember-cli-rails-assets
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 0.6.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: 0.6.1
15
29
  - !ruby/object:Gem::Dependency
16
30
  name: railties
17
31
  requirement: !ruby/object:Gem::Requirement
@@ -46,6 +60,20 @@ dependencies:
46
60
  - - "~>"
47
61
  - !ruby/object:Gem::Version
48
62
  version: 0.5.8
63
+ - !ruby/object:Gem::Dependency
64
+ name: html_page
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 0.1.0
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: 0.1.0
49
77
  description:
50
78
  email:
51
79
  - pavel@pravosud.com
@@ -63,18 +91,13 @@ files:
63
91
  - app/views/ember_cli/ember/index.html.erb
64
92
  - lib/ember-cli-rails.rb
65
93
  - lib/ember_cli/app.rb
66
- - lib/ember_cli/asset_map.rb
67
- - lib/ember_cli/assets.rb
68
94
  - lib/ember_cli/build_monitor.rb
69
- - lib/ember_cli/capture.rb
70
95
  - lib/ember_cli/command.rb
71
96
  - lib/ember_cli/configuration.rb
72
- - lib/ember_cli/directory_asset_map.rb
73
97
  - lib/ember_cli/engine.rb
74
98
  - lib/ember_cli/errors.rb
75
99
  - lib/ember_cli/helpers.rb
76
100
  - lib/ember_cli/html_constraint.rb
77
- - lib/ember_cli/html_page.rb
78
101
  - lib/ember_cli/path_set.rb
79
102
  - lib/ember_cli/route_helpers.rb
80
103
  - lib/ember_cli/runner.rb
@@ -1,64 +0,0 @@
1
- require "ember_cli/errors"
2
-
3
- module EmberCli
4
- class AssetMap
5
- def initialize(ember_app_name:, asset_map:)
6
- @ember_app_name = ember_app_name
7
- @asset_map = asset_map
8
- end
9
-
10
- def javascripts
11
- assert_asset_map!
12
-
13
- [
14
- asset_matching(%r{vendor(.*)\.js\z}),
15
- asset_matching(%r{#{ember_app_name}(.*)\.js\z}),
16
- ]
17
- end
18
-
19
- def stylesheets
20
- assert_asset_map!
21
-
22
- [
23
- asset_matching(%r{vendor(.*)\.css\z}),
24
- asset_matching(%r{#{ember_app_name}(.*)\.css\z}),
25
- ]
26
- end
27
-
28
- private
29
-
30
- attr_reader :app_name, :ember_app_name, :asset_map
31
-
32
- def asset_matching(regex)
33
- matching_asset = files.detect { |asset| asset =~ regex }
34
-
35
- if matching_asset.blank?
36
- raise_missing_asset(regex)
37
- end
38
-
39
- prepend + matching_asset
40
- end
41
-
42
- def prepend
43
- asset_map["prepend"].to_s
44
- end
45
-
46
- def files
47
- Array(assets.values)
48
- end
49
-
50
- def assets
51
- asset_map["assets"] || {}
52
- end
53
-
54
- def raise_missing_asset(regex)
55
- raise BuildError.new("Failed to find assets matching `#{regex}`")
56
- end
57
-
58
- def assert_asset_map!
59
- if assets.empty?
60
- raise BuildError.new("Missing `#{ember_app_name}/assets/assetMap.json`")
61
- end
62
- end
63
- end
64
- end
@@ -1,51 +0,0 @@
1
- require "ember_cli/errors"
2
- require "ember_cli/asset_map"
3
- require "ember_cli/directory_asset_map"
4
-
5
- module EmberCli
6
- class Assets
7
- def initialize(app)
8
- @app = app
9
- end
10
-
11
- def javascript_assets
12
- asset_map.javascripts
13
- end
14
-
15
- def stylesheet_assets
16
- asset_map.stylesheets
17
- end
18
-
19
- private
20
-
21
- attr_reader :app
22
-
23
- def asset_map
24
- AssetMap.new(
25
- ember_app_name: ember_app_name,
26
- asset_map: asset_map_hash.to_h,
27
- )
28
- end
29
-
30
- def asset_map_file
31
- app.paths.asset_map
32
- end
33
-
34
- def asset_map_hash
35
- if asset_map_file.present? && asset_map_file.exist?
36
- JSON.parse(asset_map_file.read)
37
- else
38
- DirectoryAssetMap.new(app.paths.assets)
39
- end
40
- end
41
-
42
- def ember_app_name
43
- @ember_app_name ||= app.options.fetch(:name) { package_json.fetch(:name) }
44
- end
45
-
46
- def package_json
47
- @package_json ||=
48
- JSON.parse(app.paths.package_json_file.read).with_indifferent_access
49
- end
50
- end
51
- end
@@ -1,77 +0,0 @@
1
- module EmberCli
2
- class Capture
3
- def initialize(sprockets:, &block)
4
- @sprockets = sprockets
5
- @block = block || NullBlock.new
6
- end
7
-
8
- def capture
9
- if block.arity > 0
10
- block.call(*block_arguments)
11
- end
12
-
13
- [head.content, body.content]
14
- end
15
-
16
- private
17
-
18
- attr_reader :block, :sprockets
19
-
20
- def block_arguments
21
- [head, body].first(block.arity)
22
- end
23
-
24
- def body
25
- @body ||= Block.new(sprockets)
26
- end
27
-
28
- def head
29
- @head ||= begin
30
- if block.arity < 1
31
- BlockWithoutArguments.new(sprockets, &block)
32
- else
33
- Block.new(sprockets)
34
- end
35
- end
36
- end
37
-
38
- class BlockWithoutArguments
39
- def initialize(sprockets, &block)
40
- @sprockets = sprockets
41
- @block = block
42
- end
43
-
44
- def content
45
- @sprockets.with_output_buffer(&@block)
46
- end
47
- end
48
- private_constant :BlockWithoutArguments
49
-
50
- class Block
51
- def initialize(sprockets)
52
- @sprockets = sprockets
53
- @content = []
54
- end
55
-
56
- def append(&block)
57
- @content.push(@sprockets.with_output_buffer(&block))
58
- nil
59
- end
60
-
61
- def content
62
- @content.join
63
- end
64
- end
65
- private_constant :Block
66
-
67
- class NullBlock
68
- def arity
69
- 1
70
- end
71
-
72
- def call(*)
73
- end
74
- end
75
- private_constant :NullBlock
76
- end
77
- end
@@ -1,30 +0,0 @@
1
- module EmberCli
2
- class DirectoryAssetMap
3
- def initialize(directory)
4
- @directory = Pathname(directory)
5
- end
6
-
7
- def to_h
8
- {
9
- "assets" => files_with_data,
10
- "prepend" => "assets/",
11
- }
12
- end
13
-
14
- def files_with_data
15
- files.reduce({}) do |manifest, file|
16
- name = File.basename(file.path)
17
-
18
- manifest[name] = name
19
-
20
- manifest
21
- end
22
- end
23
-
24
- private
25
-
26
- def files
27
- @directory.children.map { |path| File.new(path) }
28
- end
29
- end
30
- end
@@ -1,49 +0,0 @@
1
- module EmberCli
2
- class HtmlPage
3
- def initialize(content:, head: "", body: "")
4
- @content = content
5
- @head = head
6
- @body = body
7
- end
8
-
9
- def render
10
- if has_head_tag?
11
- insert_head_content
12
- end
13
-
14
- if has_body_tag?
15
- insert_body_content
16
- end
17
-
18
- content
19
- end
20
-
21
- private
22
-
23
- attr_reader :content
24
-
25
- def has_head_tag?
26
- head_tag_index >= 0
27
- end
28
-
29
- def has_body_tag?
30
- body_tag_index >= 0
31
- end
32
-
33
- def insert_head_content
34
- content.insert(head_tag_index, @head.to_s)
35
- end
36
-
37
- def insert_body_content
38
- content.insert(body_tag_index, @body.to_s)
39
- end
40
-
41
- def head_tag_index
42
- content.index("</head") || -1
43
- end
44
-
45
- def body_tag_index
46
- content.index("</body") || -1
47
- end
48
- end
49
- end