ember-cli-rails 0.1.13 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be18e685e2f0fd4283834765c0cd56694908f3d5
4
- data.tar.gz: 2a41cce40c3702d9bf1211abe9297e449db9625a
3
+ metadata.gz: e50b3fd7677a1c72893cb980a3b8dc9615cd6d11
4
+ data.tar.gz: 6c609d1c47ba13914e261f309538c59d20f5a223
5
5
  SHA512:
6
- metadata.gz: 30dfb8b4c37b172c65476c7a67fc08f648c4f85124f072f810897b80135158248ba945c37ade3a706154aee7220e71abb370c682415932bdebf9b71056bd3332
7
- data.tar.gz: 09b6593d5205cb5590cb23e9eeecac57d40916f7578e900fefd9dfca67b51959f5923d121351315d6dd10c7b9604ea8fea6d23954e7be95a0db7849b4c63c0a6
6
+ metadata.gz: d67e13a57cfb31bd7c142507cb675c3486f4fe9d7c14b44e1e394338125a23a3b01e114f911188c0977ef7ff4e14368ef4cc190c1b9e3030351e7c99ccfff58e
7
+ data.tar.gz: f74adc89fa5e52c9a078845ce7e2ed37d35181170bbb07935a4339b85808878b0e5af914ac5456c54eeb355f2f14c5390e95e345dc632b3a54c0ac203cb5d66c
@@ -1,3 +1,12 @@
1
+ 0.2.0
2
+ -----
3
+
4
+ * Rename rake namespace from ember-cli to ember [commit](https://github.com/rwz/ember-cli-rails/commit/3f5463835f05d21a34b5f8a9dfeb482b0501d8d4)
5
+ * Allow helpers to take optons for ember assets [commit](https://github.com/rwz/ember-cli-rails/commit/335d117a5bf4d3520730c9c421a25aee5274c2b3)
6
+ * Make EmberCLI.skip? predicate return boolean [commit](https://github.com/rwz/ember-cli-rails/commit/6f7cd58010aaf584e0810c44568008654bd1a764)
7
+ * Introduce EmberCLI.env and ember\_cli\_rails\_mode config option [commit](https://github.com/rwz/ember-cli-rails/commit/4ff9ea1a1a152bee9f909e4379f6f469650891b5)
8
+ * Rename EmberCLI.get\_app to .app and add .[] alias [commit](https://github.com/rwz/ember-cli-rails/commit/71b4c5cc97d9a410e2ef7acc536994e5d71175c6)
9
+
1
10
  0.1.13
2
11
  ------
3
12
 
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # EmberCLI Rails
2
2
 
3
3
  EmberCLI Rails is an integration story between (surprise suprise) EmberCLI and
4
- Rails. It is designed to provide an easy way to organize your Rails backed
4
+ Rails 3.1 and up. It is designed to provide an easy way to organize your Rails backed
5
5
  EmberCLI application with a specific focus on upgradeability. Rails and Ember
6
6
  [slash EmberCLI] are maintained by different teams with different goals. As
7
7
  such, we believe that it is important to ensure smooth upgrading of both
@@ -197,8 +197,7 @@ directories %w[app config lib spec your-appname/app]
197
197
 
198
198
  ## Heroku
199
199
 
200
- In order to deploy EmberCLI Rails app to Heroku you need to follow the steps
201
- below:
200
+ In order to deploy EmberCLI Rails app to Heroku:
202
201
 
203
202
  First, enable Heroku Multi Buildpack by running the following command:
204
203
 
@@ -206,7 +205,7 @@ First, enable Heroku Multi Buildpack by running the following command:
206
205
  heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-multi
207
206
  ```
208
207
 
209
- Next, check in `.buildpacks` file to specify which buildpacks to use:
208
+ Next, specify which buildpacks to use by creating a `.buildpacks` file in the project root containing:
210
209
 
211
210
  ```
212
211
  https://github.com/heroku/heroku-buildpack-nodejs
@@ -220,16 +219,10 @@ install`:
220
219
  gem "rails_12factor", group: :production
221
220
  ```
222
221
 
223
- Add a `package.json` to the root of your Rails project. This is to make sure
224
- it'll be detected by the NodeJS buildpack.
222
+ Add a `package.json` file containing `{}` to the root of your Rails project.
223
+ This is to make sure it'll be detected by the NodeJS buildpack.
225
224
 
226
- ```javascript
227
- {
228
- "dependencies": {
229
- "bower": "*"
230
- }
231
- }
232
- ```
225
+ Make sure you have `bower` as a npm dependency of your ember-cli app.
233
226
 
234
227
  Add a `postinstall` task to your EmberCLI app's `package.json`. This will
235
228
  ensure that during the deployment process, Heroku will install all dependencies
@@ -240,12 +233,14 @@ found in both `node_modules` and `bower_components`.
240
233
  # ...
241
234
  "scripts": {
242
235
  # ...
243
- "postinstall": "../../node_modules/bower/bin/bower install"
236
+ "postinstall": "node_modules/bower/bin/bower install"¬
244
237
  }
245
238
  }
246
239
  ```
247
240
 
248
- Now you should be ready to deploy.
241
+ ember-cli-rails adds your ember apps' build process to the rails asset compilation process.
242
+
243
+ Now you should be ready to deploy.
249
244
 
250
245
  ## Additional Information
251
246
 
@@ -18,7 +18,7 @@ class EmberTestsController < ActionController::Base
18
18
  end
19
19
 
20
20
  def app
21
- EmberCLI.get_app(app_name)
21
+ EmberCLI[app_name]
22
22
  end
23
23
 
24
24
  def app_name
@@ -0,0 +1,9 @@
1
+ module EmberCLIRailsHelper
2
+ def include_ember_script_tags(name, options={})
3
+ javascript_include_tag *EmberCLI[name].exposed_js_assets, options
4
+ end
5
+
6
+ def include_ember_stylesheet_tags(name, options={})
7
+ stylesheet_link_tag *EmberCLI[name].exposed_css_assets, options
8
+ end
9
+ end
@@ -5,9 +5,9 @@ module EmberCLI
5
5
 
6
6
  autoload :App, "ember-cli/app"
7
7
  autoload :Configuration, "ember-cli/configuration"
8
- autoload :ViewHelpers, "ember-cli/view_helpers"
9
8
  autoload :Helpers, "ember-cli/helpers"
10
9
  autoload :Middleware, "ember-cli/middleware"
10
+ autoload :PathSet, "ember-cli/path_set"
11
11
 
12
12
  def configure
13
13
  yield configuration
@@ -17,12 +17,16 @@ module EmberCLI
17
17
  Configuration.instance
18
18
  end
19
19
 
20
- def get_app(name)
21
- configuration.apps[name]
20
+ def app(name)
21
+ apps.fetch(name) do
22
+ fail KeyError, "#{name.inspect} app is not defined"
23
+ end
22
24
  end
23
25
 
26
+ alias_method :[], :app
27
+
24
28
  def skip?
25
- ENV["SKIP_EMBER"]
29
+ ENV["SKIP_EMBER"].present?
26
30
  end
27
31
 
28
32
  def prepare!
@@ -35,10 +39,7 @@ module EmberCLI
35
39
 
36
40
  def enable!
37
41
  prepare!
38
-
39
- if Helpers.use_middleware?
40
- Rails.configuration.middleware.use Middleware
41
- end
42
+ append_middleware unless env.production?
42
43
  end
43
44
 
44
45
  def install_dependencies!
@@ -73,6 +74,12 @@ module EmberCLI
73
74
  @root ||= Rails.root.join("tmp", "ember-cli-#{uid}")
74
75
  end
75
76
 
77
+ def env
78
+ @env ||= Helpers.current_environment.inquiry
79
+ end
80
+
81
+ delegate :apps, to: :configuration
82
+
76
83
  private
77
84
 
78
85
  def uid
@@ -84,6 +91,10 @@ module EmberCLI
84
91
  end
85
92
 
86
93
  def each_app
87
- configuration.apps.each{ |name, app| yield app }
94
+ apps.each{ |name, app| yield app }
95
+ end
96
+
97
+ def append_middleware
98
+ Rails.configuration.middleware.use Middleware
88
99
  end
89
100
  end
@@ -7,14 +7,13 @@ module EmberCLI
7
7
 
8
8
  class BuildError < StandardError; end
9
9
 
10
- attr_reader :name, :options, :pid
10
+ attr_reader :name, :options, :paths, :pid
11
+
12
+ delegate :root, to: :paths
11
13
 
12
14
  def initialize(name, options={})
13
15
  @name, @options = name.to_s, options
14
- end
15
-
16
- def tests_path
17
- dist_path.join("tests")
16
+ @paths = PathSet.new(self)
18
17
  end
19
18
 
20
19
  def compile
@@ -37,8 +36,7 @@ module EmberCLI
37
36
 
38
37
  def run_tests
39
38
  prepare
40
- tests_pass = exec("#{ember_path} test")
41
- exit 1 unless tests_pass
39
+ exit 1 unless exec("#{ember_path} test")
42
40
  end
43
41
 
44
42
  def stop
@@ -84,45 +82,34 @@ module EmberCLI
84
82
  MSG
85
83
  end
86
84
 
87
- def ember_path
88
- @ember_path ||= app_path.join("node_modules", ".bin", "ember").tap do |path|
89
- fail <<-MSG.strip_heredoc unless path.executable?
90
- No local ember executable found. You should run `npm install`
91
- inside the #{name} app located at #{app_path}
92
- MSG
85
+ def method_missing(method_name, *)
86
+ if path_method = supported_path_method(method_name)
87
+ paths.public_send(path_method)
88
+ else
89
+ super
93
90
  end
94
91
  end
95
92
 
96
- private
97
-
98
- delegate :match_version?, :non_production?, to: Helpers
99
- delegate :configuration, to: EmberCLI
100
- delegate :tee_path, :npm_path, :bundler_path, to: :configuration
101
-
102
- def default_app_path
103
- path = Rails.root.join("app", name)
104
-
105
- return name unless path.directory?
106
-
107
- ActiveSupport::Deprecation.warn <<-MSG.strip_heredoc
108
- We have found that placing your EmberCLI
109
- application inside Rails' app has negative performance implications.
110
-
111
- Please see, https://github.com/rwz/ember-cli-rails/issues/66 for more
112
- detailed information.
93
+ def respond_to_missing?(method_name, *)
94
+ if supported_path_method(method_name)
95
+ true
96
+ else
97
+ super
98
+ end
99
+ end
113
100
 
114
- It is now recommended to place your EmberCLI application into the Rails
115
- root path.
116
- MSG
101
+ private
117
102
 
118
- path
103
+ def supported_path_method(original)
104
+ path_method = original.to_s[/\A(.+)_path\z/, 1]
105
+ path_method if path_method && paths.respond_to?(path_method)
119
106
  end
120
107
 
121
108
  def silence_build(&block)
122
- if ENV.fetch("EMBER_CLI_RAILS_VERBOSE"){ !non_production? }
109
+ if ENV.fetch("EMBER_CLI_RAILS_VERBOSE"){ EmberCLI.env.production? }
123
110
  yield
124
111
  else
125
- silence_stream(STDOUT, &block)
112
+ silence_stream STDOUT, &block
126
113
  end
127
114
  end
128
115
 
@@ -130,29 +117,21 @@ module EmberCLI
130
117
  options.fetch(:build_timeout){ configuration.build_timeout }
131
118
  end
132
119
 
133
- def lockfile
134
- @lockfile ||= tmp_path.join("build.lock")
135
- end
136
-
137
120
  def check_for_build_error!
138
121
  raise_build_error! if build_error?
139
122
  end
140
123
 
141
- def build_error_file
142
- @build_error_file ||= tmp_path.join("error.txt")
143
- end
144
-
145
124
  def reset_build_error!
146
- build_error_file.delete if build_error?
125
+ build_error_file_path.delete if build_error?
147
126
  end
148
127
 
149
128
  def build_error?
150
- build_error_file.exist?
129
+ build_error_file_path.exist?
151
130
  end
152
131
 
153
132
  def raise_build_error!
154
133
  error = BuildError.new("EmberCLI app #{name.inspect} has failed to build")
155
- error.set_backtrace build_error_file.read.split(?\n)
134
+ error.set_backtrace build_error_file_path.read.split(?\n)
156
135
  fail error
157
136
  end
158
137
 
@@ -161,7 +140,7 @@ module EmberCLI
161
140
  check_addon!
162
141
  check_ember_cli_version!
163
142
  reset_build_error!
164
- FileUtils.touch lockfile
143
+ FileUtils.touch lockfile_path
165
144
  symlink_to_assets_root
166
145
  add_assets_to_precompile_list
167
146
  true
@@ -171,7 +150,7 @@ module EmberCLI
171
150
  def check_ember_cli_version!
172
151
  version = dev_dependencies.fetch("ember-cli").split(?-).first
173
152
 
174
- unless match_version?(version, EMBER_CLI_VERSION)
153
+ unless Helpers.match_version?(version, EMBER_CLI_VERSION)
175
154
  fail <<-MSG.strip_heredoc
176
155
  EmberCLI Rails require ember-cli NPM package version to be
177
156
  #{EMBER_CLI_VERSION} to work properly. From within your EmberCLI directory
@@ -192,7 +171,7 @@ module EmberCLI
192
171
 
193
172
  $ npm install --save-dev ember-cli-rails-addon@#{ADDON_VERSION}
194
173
 
195
- in you Ember application root: #{app_path}
174
+ in you Ember application root: #{root}
196
175
  MSG
197
176
  end
198
177
  end
@@ -221,36 +200,12 @@ module EmberCLI
221
200
  @ember_app_name ||= options.fetch(:name){ package_json.fetch(:name) }
222
201
  end
223
202
 
224
- def app_path
225
- @app_path ||= begin
226
- path = options.fetch(:path){ default_app_path }
227
- pathname = Pathname.new(path)
228
- pathname.absolute?? pathname : Rails.root.join(path)
229
- end
230
- end
231
-
232
- def tmp_path
233
- @tmp_path ||= app_path.join("tmp").tap(&:mkpath)
234
- end
235
-
236
- def log_path
237
- Rails.root.join("log", "ember-#{name}.#{Rails.env}.log")
238
- end
239
-
240
- def dist_path
241
- @dist_path ||= EmberCLI.root.join("apps", name).tap(&:mkpath)
242
- end
243
-
244
- def assets_path
245
- @assets_path ||= EmberCLI.root.join("assets").tap(&:mkpath)
246
- end
247
-
248
203
  def environment
249
- non_production?? "development" : "production"
204
+ EmberCLI.env.production?? "production" : "development"
250
205
  end
251
206
 
252
207
  def package_json
253
- @package_json ||= JSON.parse(app_path.join("package.json").read).with_indifferent_access
208
+ @package_json ||= JSON.parse(package_json_file_path.read).with_indifferent_access
254
209
  end
255
210
 
256
211
  def dev_dependencies
@@ -259,7 +214,7 @@ module EmberCLI
259
214
 
260
215
  def addon_present?
261
216
  dev_dependencies["ember-cli-rails-addon"] == ADDON_VERSION &&
262
- app_path.join("node_modules", "ember-cli-rails-addon", "package.json").exist?
217
+ addon_package_json_file_path.exist?
263
218
  end
264
219
 
265
220
  def excluded_ember_deps
@@ -274,14 +229,10 @@ module EmberCLI
274
229
  end
275
230
  end
276
231
 
277
- def gemfile_path
278
- app_path.join("Gemfile")
279
- end
280
-
281
232
  def exec(cmd, options={})
282
233
  method_name = options.fetch(:method, :system)
283
234
 
284
- Dir.chdir app_path do
235
+ Dir.chdir root do
285
236
  Kernel.public_send(method_name, env_hash, cmd, err: :out)
286
237
  end
287
238
  end
@@ -289,7 +240,7 @@ module EmberCLI
289
240
  def wait_for_build_complete_or_error
290
241
  loop do
291
242
  check_for_build_error!
292
- break unless lockfile.exist?
243
+ break unless lockfile_path.exist?
293
244
  sleep 0.1
294
245
  end
295
246
  end
@@ -1,9 +1,5 @@
1
1
  module EmberCLI
2
2
  class Engine < Rails::Engine
3
- initializer "ember-cli-rails.view_helpers" do
4
- ActionView::Base.send :include, ViewHelpers
5
- end
6
-
7
3
  initializer "ember-cli-rails.inflector" do
8
4
  ActiveSupport::Inflector.inflections do |inflect|
9
5
  inflect.acronym "CLI" if inflect.respond_to?(:acronym)
@@ -24,21 +24,25 @@ module EmberCLI
24
24
  nil
25
25
  end
26
26
 
27
- def non_production?
28
- !Rails.env.production? && rails_config_for(:consider_all_requests_local)
27
+ def current_environment
28
+ rails_config_for(:ember_cli_rails_mode){ default_environment }.to_s
29
29
  end
30
30
 
31
- def use_middleware?
32
- rails_config_for(:use_ember_middleware, non_production?)
33
- end
31
+ private
34
32
 
35
- def use_live_recompilation?
36
- rails_config_for(:use_ember_live_recompilation, Rails.env.development?)
33
+ def default_environment
34
+ if Rails.env.test?
35
+ "test"
36
+ elsif Rails.env.production? || !rails_config_for(:consider_all_requests_local)
37
+ "production"
38
+ else
39
+ "development"
40
+ end
37
41
  end
38
42
 
39
- def rails_config_for(key, default=false)
43
+ def rails_config_for(key)
40
44
  config = Rails.configuration
41
- config.respond_to?(key) ? config.public_send(key) : default
45
+ config.respond_to?(key) ? config.public_send(key) : yield
42
46
  end
43
47
  end
44
48
  end
@@ -19,7 +19,7 @@ module EmberCLI
19
19
 
20
20
  def enable_ember_cli
21
21
  @enabled ||= begin
22
- if Helpers.use_live_recompilation?
22
+ if EmberCLI.env.development?
23
23
  EmberCLI.run!
24
24
  else
25
25
  EmberCLI.compile!
@@ -0,0 +1,96 @@
1
+ module EmberCLI
2
+ class PathSet
3
+ def self.define_path(name, &definition)
4
+ define_method name do
5
+ ivar = "@_#{name}_path"
6
+ if instance_variable_defined?(ivar)
7
+ instance_variable_get(ivar)
8
+ else
9
+ instance_exec(&definition).tap{ |value| instance_variable_set ivar, value }
10
+ end
11
+ end
12
+ end
13
+
14
+ def initialize(app)
15
+ @app = app
16
+ end
17
+
18
+ define_path :root do
19
+ path = app_options.fetch(:path){ default_root }
20
+ pathname = Pathname.new(path)
21
+ pathname.absolute?? pathname : Rails.root.join(path)
22
+ end
23
+
24
+ define_path :tmp do
25
+ root.join("tmp").tap(&:mkpath)
26
+ end
27
+
28
+ define_path :log do
29
+ Rails.root.join("log", "ember-#{app_name}.#{Rails.env}.log")
30
+ end
31
+
32
+ define_path :dist do
33
+ EmberCLI.root.join("apps", app_name).tap(&:mkpath)
34
+ end
35
+
36
+ define_path :assets do
37
+ EmberCLI.root.join("assets").tap(&:mkpath)
38
+ end
39
+
40
+ define_path :gemfile do
41
+ root.join("Gemfile")
42
+ end
43
+
44
+ define_path :tests do
45
+ dist.join("tests")
46
+ end
47
+
48
+ define_path :package_json_file do
49
+ root.join("package.json")
50
+ end
51
+
52
+ define_path :ember do
53
+ root.join("node_modules", ".bin", "ember").tap do |path|
54
+ fail <<-MSG.strip_heredoc unless path.executable?
55
+ No local ember executable found. You should run `npm install`
56
+ inside the #{app_name} app located at #{root}
57
+ MSG
58
+ end
59
+ end
60
+
61
+ define_path :lockfile do
62
+ tmp.join("build.lock")
63
+ end
64
+
65
+ define_path :build_error_file do
66
+ tmp.join("error.txt")
67
+ end
68
+
69
+ define_path :tee do
70
+ app_options.fetch(:tee_path){ configuration.tee_path }
71
+ end
72
+
73
+ define_path :npm do
74
+ app_options.fetch(:npm_path){ configuration.npm_path }
75
+ end
76
+
77
+ define_path :bundler do
78
+ app_options.fetch(:bundler_path){ configuration.bundler_path }
79
+ end
80
+
81
+ define_path :addon_package_json_file do
82
+ root.join("node_modules", "ember-cli-rails-addon", "package.json")
83
+ end
84
+
85
+ private
86
+
87
+ attr_reader :app
88
+
89
+ delegate :name, :options, to: :app, prefix: true
90
+ delegate :configuration, to: EmberCLI
91
+
92
+ def default_root
93
+ Rails.root.join(app_name)
94
+ end
95
+ end
96
+ end
@@ -1,3 +1,3 @@
1
1
  module EmberCLI
2
- VERSION = "0.1.13".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
@@ -1,6 +1,6 @@
1
- namespace "ember-cli" do
1
+ namespace :ember do
2
2
  desc "Runs `ember build` for each App"
3
- task compile: :install_dependencies do
3
+ task compile: :install do
4
4
  EmberCLI.compile!
5
5
  end
6
6
 
@@ -10,9 +10,9 @@ namespace "ember-cli" do
10
10
  end
11
11
 
12
12
  desc "Installs each EmberCLI app's dependencies"
13
- task install_dependencies: :environment do
13
+ task install: :environment do
14
14
  EmberCLI.install_dependencies!
15
15
  end
16
16
  end
17
17
 
18
- task "assets:precompile" => "ember-cli:compile" unless EmberCLI.skip?
18
+ task "assets:precompile" => "ember:compile" unless EmberCLI.skip?
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.1.13
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pravosud
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-03-21 00:00:00.000000000 Z
13
+ date: 2015-04-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
@@ -59,6 +59,7 @@ files:
59
59
  - LICENSE.txt
60
60
  - README.md
61
61
  - app/controllers/ember_tests_controller.rb
62
+ - app/helpers/ember_cli_rails_helper.rb
62
63
  - config/routes.rb
63
64
  - lib/ember-cli-rails.rb
64
65
  - lib/ember-cli/app.rb
@@ -66,8 +67,8 @@ files:
66
67
  - lib/ember-cli/engine.rb
67
68
  - lib/ember-cli/helpers.rb
68
69
  - lib/ember-cli/middleware.rb
70
+ - lib/ember-cli/path_set.rb
69
71
  - lib/ember-cli/version.rb
70
- - lib/ember-cli/view_helpers.rb
71
72
  - lib/generators/ember-cli/init/USAGE
72
73
  - lib/generators/ember-cli/init/init_generator.rb
73
74
  - lib/generators/ember-cli/init/templates/initializer.rb
@@ -1,13 +0,0 @@
1
- module EmberCLI
2
- module ViewHelpers
3
- def include_ember_script_tags(app_name)
4
- app = EmberCLI.configuration.apps.fetch(app_name)
5
- javascript_include_tag *app.exposed_js_assets
6
- end
7
-
8
- def include_ember_stylesheet_tags(app_name)
9
- app = EmberCLI.configuration.apps.fetch(app_name)
10
- stylesheet_link_tag *app.exposed_css_assets
11
- end
12
- end
13
- end