ember-cli-rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +69 -10
- data/lib/ember-cli-rails.rb +3 -2
- data/lib/ember-cli/build_server.rb +24 -5
- data/lib/ember-cli/configuration.rb +16 -3
- data/lib/ember-cli/helpers.rb +18 -0
- data/lib/ember-cli/railtie.rb +6 -0
- data/lib/ember-cli/version.rb +1 -1
- data/lib/ember-cli/view_helpers.rb +2 -1
- data/lib/generators/ember-cli/init/init_generator.rb +1 -1
- data/lib/generators/ember-cli/init/templates/initializer.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f12888439a1006bc5360886a9a32ac5677676e1f
|
4
|
+
data.tar.gz: 783106a02bba7d4c2fca16e97a7057affcbdf645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e6ff496dae3d253e2e5b61589f31e7b871a3886259ef2db874fd402e2945599fb966f07c5920c9cbc09d70eefc908253a6472dd83b188b7204a4942a139c2d9
|
7
|
+
data.tar.gz: 5996e7bc18a1919c2f36fbc5ca509639366fb51a15c835b5fcdeb1dc396006ff9b5ea7862cbf7682e19735b3b44030b3323056d0b934a42717bda96776a1e437
|
data/README.md
CHANGED
@@ -1,30 +1,89 @@
|
|
1
|
-
#
|
1
|
+
# EmberCLI Rails
|
2
2
|
|
3
|
-
|
3
|
+
EmberCLI Rails is an integration story between (surprise suprise) EmberCLI and Rails. It is designed to provide an easy way to organize your Rails backed EmberCLI application with a specific focus on upgradeability. Rails and Ember [slash EmberCLI] are maintained by different teams with different goals. As such, we believe that it is important to ensure smooth upgrading of both aspects of your application.
|
4
|
+
|
5
|
+
A large contingent of Ember developers use Rails. And Rails is awesome. With the upcoming changes to Ember 2.0 and the Ember community's desire to unify around EmberCLI it is now more important than ever to ensure that Rails and EmberCLI can coexist and development still be fun!
|
6
|
+
|
7
|
+
To this end we have created a minimum set of features (which we will outline below) to allow you keep your Rails workflow while minimizing the risk of upgrade pain with your Ember build tools.
|
8
|
+
|
9
|
+
For example, end-to-end tests with frameworks like Cucumber should just work. You should still be able leverage the asset pipeline, and all the conveniences that Rails offers. And you should get all the new goodies like ES6 modules and EmberCLI addons too! Without further ado, let's get in there!
|
4
10
|
|
5
11
|
## Installation
|
6
12
|
|
7
|
-
|
13
|
+
Firstly, you'll have to include the gem in your `Gemfile` and `bundle install`
|
8
14
|
|
9
15
|
```ruby
|
10
|
-
gem
|
16
|
+
gem "ember-cli-rails"
|
17
|
+
```
|
18
|
+
|
19
|
+
Then you'll want to configure your installation by adding an `ember.rb` initializer. There is a generator to guide you, run:
|
20
|
+
|
21
|
+
```shell
|
22
|
+
rails generate ember_cli:init
|
11
23
|
```
|
12
24
|
|
13
|
-
|
25
|
+
This will generate an initializer that looks like the following:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
EmberCLI.configure do |c|
|
29
|
+
c.app :frontend
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
##### options
|
34
|
+
|
35
|
+
- app - this represents the name of the ember cli application. The presumed path of which would be `Rails.root.join('app', <your-appname>)`
|
36
|
+
|
37
|
+
- path - used if you need to override the default path (mentioned above) Example usage:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
EmberCLI.configure do |c|
|
41
|
+
c.app :frontend, path: "/path/to/your/ember-cli-app/on/disk"
|
42
|
+
end
|
43
|
+
```
|
14
44
|
|
15
|
-
|
45
|
+
Once you've updated your initializer to taste, you need to tell EmberCLI that you want the meta tag to be served in your javascript. Open up your `Brocfile` inside your EmberCLI app and add `{storeConfigInMeta: false}`.
|
16
46
|
|
17
|
-
|
47
|
+
It should look something like this (if you've left it unchanged):
|
18
48
|
|
19
|
-
|
49
|
+
```javascript
|
50
|
+
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
|
51
|
+
|
52
|
+
var app = new EmberApp({storeConfigInMeta: false});
|
53
|
+
|
54
|
+
// etc...
|
55
|
+
```
|
56
|
+
|
57
|
+
And that's it!
|
58
|
+
|
59
|
+
### Multiple EmberCLI apps
|
60
|
+
|
61
|
+
In the initializer you may specify multiple EmberCLI apps, each of which can be referenced with the view helper independently. You'd accomplish this like so:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
EmberCLI.configure do |c|
|
65
|
+
c.app :frontend
|
66
|
+
c.app :admin_panel, path: "/somewhere/else"
|
67
|
+
end
|
68
|
+
```
|
20
69
|
|
21
70
|
## Usage
|
22
71
|
|
23
|
-
|
72
|
+
In order to load your EmberCLI generated app you need only include the javscript tags on the page you'd like the Ember app to appear:
|
73
|
+
|
74
|
+
```erb
|
75
|
+
<%= ember_cli_script_tags :frontend %>
|
76
|
+
```
|
77
|
+
|
78
|
+
Your Ember application will be served now.
|
79
|
+
|
80
|
+
## Additional Information
|
81
|
+
|
82
|
+
EmberCLI Rails runs `ember build` with the `--output-path` and `--watch` flags on. The `--watch` flag sets tells EmberCLI to watch for file system events and rebuild when an EmberCLI file is changed. The `--output-path` flag specifies where the distribution files will be put. EmberCLI Rails does some fancy stuff to get it into your asset path without polluting your git history.
|
24
83
|
|
25
84
|
## Contributing
|
26
85
|
|
27
|
-
1. Fork it (
|
86
|
+
1. Fork it (https://github.com/rwz/ember-cli-rails/fork)
|
28
87
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
88
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
89
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/ember-cli-rails.rb
CHANGED
@@ -7,6 +7,7 @@ module EmberCLI
|
|
7
7
|
autoload :Configuration, "ember-cli/configuration"
|
8
8
|
autoload :RackServer, "ember-cli/rack_server"
|
9
9
|
autoload :ViewHelpers, "ember-cli/view_helpers"
|
10
|
+
autoload :Helpers, "ember-cli/helpers"
|
10
11
|
|
11
12
|
def configure
|
12
13
|
yield configuration
|
@@ -23,11 +24,11 @@ module EmberCLI
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def start!
|
26
|
-
configuration.
|
27
|
+
configuration.apps.values.each(&:start)
|
27
28
|
end
|
28
29
|
|
29
30
|
def stop!
|
30
|
-
configuration.
|
31
|
+
configuration.apps.values.each(&:stop)
|
31
32
|
end
|
32
33
|
|
33
34
|
def root
|
@@ -9,7 +9,7 @@ module EmberCLI
|
|
9
9
|
def start
|
10
10
|
symlink_to_assets_root
|
11
11
|
add_assets_to_precompile_list
|
12
|
-
@pid = spawn(command)
|
12
|
+
@pid = spawn(command, chdir: app_path, err: :out)
|
13
13
|
at_exit{ stop }
|
14
14
|
end
|
15
15
|
|
@@ -18,8 +18,16 @@ module EmberCLI
|
|
18
18
|
@pid = nil
|
19
19
|
end
|
20
20
|
|
21
|
+
def exposed_js_assets
|
22
|
+
%W[#{name}/vendor #{name}/#{ember_app_name}]
|
23
|
+
end
|
24
|
+
|
21
25
|
private
|
22
26
|
|
27
|
+
delegate :ember_path, to: :configuration
|
28
|
+
delegate :tee_path, to: :configuration
|
29
|
+
delegate :configuration, to: :EmberCLI
|
30
|
+
|
23
31
|
def symlink_to_assets_root
|
24
32
|
assets_path.join(name).make_symlink dist_path.join("assets")
|
25
33
|
end
|
@@ -29,16 +37,27 @@ module EmberCLI
|
|
29
37
|
end
|
30
38
|
|
31
39
|
def command
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
40
|
+
"#{ember_path} build --watch --output-path #{dist_path} #{log_pipe}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def log_pipe
|
44
|
+
"| #{tee_path} -a #{log_path}" if tee_path
|
45
|
+
end
|
46
|
+
|
47
|
+
def ember_app_name
|
48
|
+
@ember_app_name ||= options.fetch(:name) do
|
49
|
+
JSON.parse(app_path.join("package.json").read).fetch("name")
|
50
|
+
end
|
36
51
|
end
|
37
52
|
|
38
53
|
def app_path
|
39
54
|
options.fetch(:path){ Rails.root.join("app", name) }
|
40
55
|
end
|
41
56
|
|
57
|
+
def log_path
|
58
|
+
Rails.root.join("log", "ember-#{name}.#{Rails.env}.log")
|
59
|
+
end
|
60
|
+
|
42
61
|
def dist_path
|
43
62
|
@dist_path ||= EmberCLI.root.join("apps", name).tap(&:mkpath)
|
44
63
|
end
|
@@ -5,11 +5,24 @@ module EmberCLI
|
|
5
5
|
include Singleton
|
6
6
|
|
7
7
|
def app(name, **options)
|
8
|
-
|
8
|
+
apps.store name, BuildServer.new(name, **options)
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
@
|
11
|
+
def apps
|
12
|
+
@apps ||= HashWithIndifferentAccess.new
|
13
13
|
end
|
14
|
+
|
15
|
+
def tee_path
|
16
|
+
return @tee_path if defined?(@tee_path)
|
17
|
+
@tee_path = Helpers.which("tee")
|
18
|
+
end
|
19
|
+
|
20
|
+
def ember_path
|
21
|
+
@ember_path ||= Helpers.which("ember").tap do |path|
|
22
|
+
fail "ember-cli executable could not be found" unless path
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_writer :ember_path
|
14
27
|
end
|
15
28
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module EmberCLI
|
2
|
+
module Helpers
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def which(cmd)
|
6
|
+
exts = ENV.fetch("PATHEXT", ?;).split(?;, -1).uniq
|
7
|
+
|
8
|
+
ENV.fetch("PATH").split(File::PATH_SEPARATOR).each do |path|
|
9
|
+
exts.each do |ext|
|
10
|
+
exe = File.join(path, "#{cmd}#{ext}")
|
11
|
+
return exe if File.executable?(exe) && !File.directory?(exe)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/ember-cli/railtie.rb
CHANGED
@@ -8,6 +8,12 @@ module EmberCLI
|
|
8
8
|
ActionView::Base.include ViewHelpers
|
9
9
|
end
|
10
10
|
|
11
|
+
initializer "ember-cli-rails.inflector" do
|
12
|
+
ActiveSupport::Inflector.inflections(:en) do |inflect|
|
13
|
+
inflect.acronym "CLI"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
11
17
|
def development_mode?
|
12
18
|
!Rails.env.production? && Rails.configuration.consider_all_requests_local
|
13
19
|
end
|
data/lib/ember-cli/version.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module EmberCLI
|
2
2
|
module ViewHelpers
|
3
3
|
def include_ember_script_tags(app_name)
|
4
|
-
|
4
|
+
app = EmberCLI.configuration.apps.fetch(app_name)
|
5
|
+
javascript_include_tag *app.exposed_js_assets
|
5
6
|
end
|
6
7
|
end
|
7
8
|
end
|
@@ -2,7 +2,7 @@ module EmberCLI
|
|
2
2
|
class InitGenerator < Rails::Generators::Base
|
3
3
|
source_root File.expand_path("../templates", __FILE__)
|
4
4
|
|
5
|
-
namespace "
|
5
|
+
namespace "ember_cli:init"
|
6
6
|
|
7
7
|
def copy_initializer_file
|
8
8
|
copy_file "initializer.rb", "config/initializers/ember.rb"
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ember-cli-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Pravosud
|
8
|
+
- Jonathan Jackson
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
+
date: 2014-12-02 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: railties
|
@@ -27,6 +28,7 @@ dependencies:
|
|
27
28
|
description:
|
28
29
|
email:
|
29
30
|
- pavel@pravosud.com
|
31
|
+
- jonathan.jackson1@me.com
|
30
32
|
executables: []
|
31
33
|
extensions: []
|
32
34
|
extra_rdoc_files: []
|
@@ -36,6 +38,7 @@ files:
|
|
36
38
|
- lib/ember-cli-rails.rb
|
37
39
|
- lib/ember-cli/build_server.rb
|
38
40
|
- lib/ember-cli/configuration.rb
|
41
|
+
- lib/ember-cli/helpers.rb
|
39
42
|
- lib/ember-cli/rack_server.rb
|
40
43
|
- lib/ember-cli/railtie.rb
|
41
44
|
- lib/ember-cli/version.rb
|
@@ -66,5 +69,5 @@ rubyforge_project:
|
|
66
69
|
rubygems_version: 2.4.3
|
67
70
|
signing_key:
|
68
71
|
specification_version: 4
|
69
|
-
summary:
|
72
|
+
summary: Integration between Ember CLI and Rails
|
70
73
|
test_files: []
|