ember-cli-rails 0.0.5 → 0.0.6

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: b747535336222c46f26a9fa8282fd431a8bc778b
4
- data.tar.gz: e5433c4e6c9aeee22d0ad7f2863905565812ad06
3
+ metadata.gz: e781eea1e9e1586408d6af0ffb8438989446554b
4
+ data.tar.gz: 5b40c7081f54e4a51447393c91bf6c8f1cdb0501
5
5
  SHA512:
6
- metadata.gz: 4a56a9ebfe129b41ae041a2fc5d701877a6fafc710b134ce8ce6788fe5d3d264b81c75c0ed8ae6dbbe6c2d0437e18fef00652d5655a522f34e13efbe08907375
7
- data.tar.gz: 2bb7bfeceb07c887d4c01da711484928f0ca95736ca2805da3d48cee79774b5ca49b994236bb819882a96ab43a9b67f283618eae55723853b604a4329c37d88a
6
+ metadata.gz: 21dfad6429f5ee62379deaed39cb33d09b570c1fd0796665b8c35e7b76a6edfeeb0805a203284b1aaeb6d7a598bf60fbd78f1ec67dfe325b34957fd4f59e9d6f
7
+ data.tar.gz: 42a6d2cd995a60ded8da52383bd8ce16ccdd9a3af0504c36ae0b2ea432eadce1657c97c5061046cb5d3aeaa6e03d87a15427a0e15c5eb04998885497d680b3c6
@@ -5,7 +5,6 @@ module EmberCLI
5
5
 
6
6
  autoload :App, "ember-cli/app"
7
7
  autoload :Configuration, "ember-cli/configuration"
8
- autoload :RackServer, "ember-cli/rack_server"
9
8
  autoload :ViewHelpers, "ember-cli/view_helpers"
10
9
  autoload :Helpers, "ember-cli/helpers"
11
10
 
@@ -26,15 +25,27 @@ module EmberCLI
26
25
  end
27
26
 
28
27
  def enable!
29
- if Rails.env.development?
30
- prepare!
31
- Rack::Server.send :prepend, RackServer
32
- else
33
- compile!
28
+ prepare!
29
+
30
+ Rails.application.instance_eval do
31
+ singleton_class.instance_eval do
32
+ alias_method :call_without_ember_cli, :call
33
+ end
34
+
35
+ def call(env)
36
+ @_ember_cli_enabled ||= begin
37
+ EmberCLI.compile!
38
+ EmberCLI.run! if Rails.env.development?
39
+ true
40
+ end
41
+
42
+ call_without_ember_cli(env)
43
+ end
34
44
  end
35
45
  end
36
46
 
37
47
  def run!
48
+ prepare!
38
49
  each_app &:run
39
50
  end
40
51
 
@@ -62,6 +73,6 @@ module EmberCLI
62
73
  end
63
74
 
64
75
  def each_app
65
- configuration.apps.values.each{ |a| yield a }
76
+ configuration.apps.each{ |name, app| yield app }
66
77
  end
67
78
  end
data/lib/ember-cli/app.rb CHANGED
@@ -2,20 +2,19 @@ module EmberCLI
2
2
  class App
3
3
  attr_reader :name, :options, :pid
4
4
 
5
- def initialize(name, **options)
5
+ def initialize(name, options={})
6
6
  @name, @options = name.to_s, options
7
7
  end
8
8
 
9
9
  def compile
10
- symlink_to_assets_root
11
- add_assets_to_precompile_list
10
+ prepare
12
11
  silence_stream STDOUT do
13
12
  system command, chdir: app_path, err: :out
14
13
  end
15
14
  end
16
15
 
17
16
  def run
18
- compile
17
+ prepare
19
18
  @pid = spawn(command(watch: true), chdir: app_path, err: :out)
20
19
  at_exit{ stop }
21
20
  end
@@ -35,6 +34,14 @@ module EmberCLI
35
34
  delegate :tee_path, to: :configuration
36
35
  delegate :configuration, to: :EmberCLI
37
36
 
37
+ def prepare
38
+ @prepared ||= begin
39
+ symlink_to_assets_root
40
+ add_assets_to_precompile_list
41
+ true
42
+ end
43
+ end
44
+
38
45
  def symlink_to_assets_root
39
46
  assets_path.join(name).make_symlink dist_path.join("assets")
40
47
  end
@@ -43,8 +50,8 @@ module EmberCLI
43
50
  Rails.configuration.assets.precompile << /(?:\/|\A)#{name}\//
44
51
  end
45
52
 
46
- def command(watch: nil)
47
- watch = "--watch" if watch
53
+ def command(options={})
54
+ watch = options[:watch] ? "--watch" : ""
48
55
  "#{ember_path} build #{watch} --environment #{environment} --output-path #{dist_path} #{log_pipe}"
49
56
  end
50
57
 
@@ -75,7 +82,7 @@ module EmberCLI
75
82
  end
76
83
 
77
84
  def environment
78
- Rails.env.in?(%w[development test]) ? Rails.env : "production"
85
+ Helpers.non_production?? "development" : "production"
79
86
  end
80
87
  end
81
88
  end
@@ -4,8 +4,8 @@ module EmberCLI
4
4
  class Configuration
5
5
  include Singleton
6
6
 
7
- def app(name, **options)
8
- apps.store name, App.new(name, **options)
7
+ def app(name, options={})
8
+ apps.store name, App.new(name, options)
9
9
  end
10
10
 
11
11
  def apps
@@ -15,10 +15,14 @@ module EmberCLI
15
15
  nil
16
16
  end
17
17
 
18
+ def non_production?
19
+ !Rails.env.production? && Rails.configuration.consider_all_requests_local
20
+ end
21
+
18
22
  def override_assets_precompile_task!
19
23
  Rake.application.instance_eval do
20
24
  @tasks["assets:precompile:original"] = @tasks.delete("assets:precompile")
21
- Rake::Task.define_task "assets:precompile", %i[assets precompile] => :environment do
25
+ Rake::Task.define_task "assets:precompile", [:assets, :precompile] => :environment do
22
26
  EmberCLI.compile!
23
27
  Rake::Task["assets:precompile:original"].execute
24
28
  end
@@ -5,21 +5,19 @@ module EmberCLI
5
5
  end
6
6
 
7
7
  initializer "ember-cli-rails.inflector" do
8
- ActiveSupport::Inflector.inflections(:en) do |inflect|
8
+ ActiveSupport::Inflector.inflections :en do |inflect|
9
9
  inflect.acronym "CLI"
10
10
  end
11
11
  end
12
12
 
13
- initializer "ember-cli-rails.rack-server" do
14
- EmberCLI.enable! if non_production?
13
+ initializer "ember-cli-rails.enable" do
14
+ EmberCLI.enable! if EmberCLI::Helpers.non_production?
15
15
  end
16
16
 
17
17
  rake_tasks do
18
- require "ember-cli/rake_task"
18
+ require "sprockets/rails/task"
19
+ EmberCLI::Helpers.override_assets_precompile_task!
19
20
  end
20
21
 
21
- def non_production?
22
- !Rails.env.production? && Rails.configuration.consider_all_requests_local
23
- end
24
22
  end
25
23
  end
@@ -1,3 +1,3 @@
1
1
  module EmberCLI
2
- VERSION = "0.0.5".freeze
2
+ VERSION = "0.0.6".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.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pravosud
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-08 00:00:00.000000000 Z
12
+ date: 2014-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -39,9 +39,7 @@ files:
39
39
  - lib/ember-cli/app.rb
40
40
  - lib/ember-cli/configuration.rb
41
41
  - lib/ember-cli/helpers.rb
42
- - lib/ember-cli/rack_server.rb
43
42
  - lib/ember-cli/railtie.rb
44
- - lib/ember-cli/rake_task.rb
45
43
  - lib/ember-cli/version.rb
46
44
  - lib/ember-cli/view_helpers.rb
47
45
  - lib/generators/ember-cli/init/USAGE
@@ -57,9 +55,9 @@ require_paths:
57
55
  - lib
58
56
  required_ruby_version: !ruby/object:Gem::Requirement
59
57
  requirements:
60
- - - "~>"
58
+ - - ">="
61
59
  - !ruby/object:Gem::Version
62
- version: '2.0'
60
+ version: 1.9.3
63
61
  required_rubygems_version: !ruby/object:Gem::Requirement
64
62
  requirements:
65
63
  - - ">="
@@ -1,10 +0,0 @@
1
- module EmberCLI
2
- module RackServer
3
- def start
4
- EmberCLI.run! if defined?(Rails.application) && app == Rails.application
5
- super
6
- ensure
7
- EmberCLI.stop!
8
- end
9
- end
10
- end
@@ -1,3 +0,0 @@
1
- require "sprockets/rails/task"
2
-
3
- EmberCLI::Helpers.override_assets_precompile_task!