ember-cli-rails 0.2.3 → 0.3.0

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: 8aa3abcfef9d6d58b294ce9bd564f43c36254773
4
- data.tar.gz: 439aa2140f65b265d8a0dfa306b5945662030b49
3
+ metadata.gz: 17234641f3cac538a57c2cf6bdacf0b691d24143
4
+ data.tar.gz: b506c5306a619e6f930c20665c70237f64a1f237
5
5
  SHA512:
6
- metadata.gz: 7be48d6ed2a100ef955f9ea7c9473dfbb46d4187b4865e5cca700cb16856980919ae48306992cb9cd9f2917f64e0916c5068a14796d396c082d4401fb4f9fda0
7
- data.tar.gz: f3791d09918c175737f48d5fb5fe3d8543f2801acd57e9aaeb57dac1b6812f65e4b5c65efd8ded2dfd64e85218faa3182a1f86f667298f9b8327371073e6918e
6
+ metadata.gz: d7067bf6bd90c4141896666325994ca3a853de4393ba96d1ceede011ae91341650141c9180c39e16c99ff8ced4991e9fdd9ad42ac0ded250f00e2e191a1ccf3d
7
+ data.tar.gz: 74093676f7a68a38f36853bb2c48e71ee3b6cf9f00c27016f9e7bbc411cad0b41649bbd56526b396a4aba78f2919ba1b2947f53df17a1e04a493bacaf5b7117e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.3.0
2
+ -----
3
+
4
+ * Add enable option to speficy what paths should have ember compiled [#145](https://github.com/rwz/ember-cli-rails/pull/145)
5
+ * Add Runner class to monitor ember deamon failures in development [#145](https://github.com/rwz/ember-cli-rails/pull/145)
6
+
1
7
  0.2.3
2
8
  -----
3
9
 
data/README.md CHANGED
@@ -51,10 +51,15 @@ end
51
51
  - path - the path, where your EmberCLI applications is located. The default
52
52
  value is the name of your app in the Rails root.
53
53
 
54
+ - enable - a lambda that accepts each requests' path. The default value is a
55
+ lambda that returns `true`.
56
+
54
57
  ```ruby
55
58
  EmberCLI.configure do |c|
56
59
  c.app :adminpanel # path is "<your-rails-root>/adminpanel"
57
- c.app :frontend, path: "/path/to/your/ember-cli-app/on/disk"
60
+ c.app :frontend,
61
+ path: "/path/to/your/ember-cli-app/on/disk",
62
+ enable: -> path { path.starts_with?("/app/") }
58
63
  end
59
64
  ```
60
65
 
@@ -240,7 +245,7 @@ found in both `node_modules` and `bower_components`.
240
245
 
241
246
  ember-cli-rails adds your ember apps' build process to the rails asset compilation process.
242
247
 
243
- Now you should be ready to deploy.
248
+ Now you should be ready to deploy.
244
249
 
245
250
  ## Additional Information
246
251
 
@@ -8,6 +8,7 @@ module EmberCLI
8
8
  autoload :Helpers, "ember-cli/helpers"
9
9
  autoload :Middleware, "ember-cli/middleware"
10
10
  autoload :PathSet, "ember-cli/path_set"
11
+ autoload :Runner, "ember-cli/runner"
11
12
 
12
13
  def configure
13
14
  yield configuration
@@ -47,27 +48,13 @@ module EmberCLI
47
48
  each_app &:install_dependencies
48
49
  end
49
50
 
50
- def run!
51
- prepare!
52
- each_app &:run
53
- end
54
-
55
51
  def run_tests!
56
52
  prepare!
57
53
  each_app &:run_tests
58
54
  end
59
55
 
60
- def compile!
61
- prepare!
62
- each_app &:compile
63
- end
64
-
65
- def stop!
66
- each_app &:stop
67
- end
68
-
69
- def wait!
70
- each_app &:wait
56
+ def process_path(path)
57
+ each_app{ |app| Runner.new(app, path).process }
71
58
  end
72
59
 
73
60
  def root
data/lib/ember-cli/app.rb CHANGED
@@ -17,9 +17,12 @@ module EmberCLI
17
17
  end
18
18
 
19
19
  def compile
20
- prepare
21
- silence_build { exec command }
22
- check_for_build_error!
20
+ @compiled ||= begin
21
+ prepare
22
+ silence_build{ exec command }
23
+ check_for_build_error!
24
+ true
25
+ end
23
26
  end
24
27
 
25
28
  def install_dependencies
@@ -29,9 +32,11 @@ module EmberCLI
29
32
 
30
33
  def run
31
34
  prepare
35
+ FileUtils.touch lockfile_path
32
36
  cmd = command(watch: true)
33
37
  @pid = exec(cmd, method: :spawn)
34
- at_exit{ stop }
38
+ Process.detach pid
39
+ set_on_exit_callback
35
40
  end
36
41
 
37
42
  def run_tests
@@ -40,7 +45,7 @@ module EmberCLI
40
45
  end
41
46
 
42
47
  def stop
43
- Process.kill "INT", pid if pid
48
+ Process.kill :INT, pid if pid
44
49
  @pid = nil
45
50
  end
46
51
 
@@ -100,6 +105,10 @@ module EmberCLI
100
105
 
101
106
  private
102
107
 
108
+ def set_on_exit_callback
109
+ @on_exit_callback ||= at_exit{ stop }
110
+ end
111
+
103
112
  def supported_path_method(original)
104
113
  path_method = original.to_s[/\A(.+)_path\z/, 1]
105
114
  path_method if path_method && paths.respond_to?(path_method)
@@ -140,7 +149,6 @@ module EmberCLI
140
149
  check_addon!
141
150
  check_ember_cli_version!
142
151
  reset_build_error!
143
- FileUtils.touch lockfile_path
144
152
  symlink_to_assets_root
145
153
  add_assets_to_precompile_list
146
154
  true
@@ -5,28 +5,14 @@ module EmberCLI
5
5
  end
6
6
 
7
7
  def call(env)
8
- enable_ember_cli
9
- EmberCLI.wait!
8
+ path = env["PATH_INFO"].to_s
10
9
 
11
- if env["PATH_INFO"] == "/testem.js"
10
+ if path == "/testem.js"
12
11
  [ 200, { "Content-Type" => "text/javascript" }, [""] ]
13
12
  else
13
+ EmberCLI.process_path path
14
14
  @app.call(env)
15
15
  end
16
16
  end
17
-
18
- private
19
-
20
- def enable_ember_cli
21
- @enabled ||= begin
22
- if EmberCLI.env.development?
23
- EmberCLI.run!
24
- else
25
- EmberCLI.compile!
26
- end
27
-
28
- true
29
- end
30
- end
31
17
  end
32
18
  end
@@ -0,0 +1,53 @@
1
+ module EmberCLI
2
+ class Runner
3
+ TRUE_PROC = ->(*){ true }
4
+
5
+ attr_reader :app, :path
6
+
7
+ def initialize(app, path)
8
+ @app, @path = app, path
9
+ end
10
+
11
+ def process
12
+ return if skip?
13
+
14
+ if EmberCLI.env.development?
15
+ start_or_restart!
16
+ else
17
+ compile!
18
+ end
19
+
20
+ wait!
21
+ end
22
+
23
+ private
24
+
25
+ def skip?
26
+ invoker = app.options.fetch(:enable, TRUE_PROC)
27
+ !invoker.call(path)
28
+ end
29
+
30
+ def start_or_restart!
31
+ run! unless app.pid && still_running?
32
+ end
33
+
34
+ def still_running?
35
+ Process.getpgid app.pid
36
+ true
37
+ rescue Errno::ESRCH # no such process
38
+ false
39
+ end
40
+
41
+ def wait!
42
+ app.wait
43
+ end
44
+
45
+ def compile!
46
+ app.compile
47
+ end
48
+
49
+ def run!
50
+ app.run
51
+ end
52
+ end
53
+ end
@@ -1,3 +1,3 @@
1
1
  module EmberCLI
2
- VERSION = "0.2.3".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  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.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pravosud
@@ -68,6 +68,7 @@ files:
68
68
  - lib/ember-cli/helpers.rb
69
69
  - lib/ember-cli/middleware.rb
70
70
  - lib/ember-cli/path_set.rb
71
+ - lib/ember-cli/runner.rb
71
72
  - lib/ember-cli/version.rb
72
73
  - lib/generators/ember-cli/init/USAGE
73
74
  - lib/generators/ember-cli/init/init_generator.rb