forked from tricknotes/ember-cli-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 27c74d8
Showing
12 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/.bundle/ | ||
/.yardoc | ||
/Gemfile.lock | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
*.bundle | ||
*.so | ||
*.o | ||
*.a | ||
mkmf.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source "https://rubygems.org" | ||
|
||
gemspec | ||
|
||
gem "pry" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2014 Pavel Pravosud | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Ember::Cli::Rails | ||
|
||
TODO: Write a gem description | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
```ruby | ||
gem 'ember-cli-rails' | ||
``` | ||
|
||
And then execute: | ||
|
||
$ bundle | ||
|
||
Or install it yourself as: | ||
|
||
$ gem install ember-cli-rails | ||
|
||
## Usage | ||
|
||
TODO: Write usage instructions here | ||
|
||
## Contributing | ||
|
||
1. Fork it ( https://github.com/[my-github-username]/ember-cli-rails/fork ) | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Add some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create a new Pull Request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require "bundler/gem_tasks" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require_relative "./lib/ember-cli/version" | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "ember-cli-rails" | ||
spec.version = EmberCLI::VERSION | ||
spec.authors = ["Pavel Pravosud"] | ||
spec.email = ["pavel@pravosud.com"] | ||
spec.summary = "Helps integrate EmberCLI with Rails" | ||
spec.homepage = "https://github.com/rwz/ember-cli-rails" | ||
spec.license = "MIT" | ||
spec.files = Dir["README.md", "LICENSE.txt", "lib/**/*"] | ||
|
||
spec.required_ruby_version = "~> 2.0" | ||
spec.add_dependency "railties", "~> 4.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require "ember-cli/railtie" if defined?(Rails) | ||
|
||
module EmberCLI | ||
extend self | ||
|
||
autoload :BuildServer, "ember-cli/build_server" | ||
autoload :Configuration, "ember-cli/configuration" | ||
autoload :RackServer, "ember-cli/rack_server" | ||
|
||
def configure | ||
yield configuration | ||
end | ||
|
||
def configuration | ||
Configuration.instance | ||
end | ||
|
||
def prepare! | ||
Rack::Server.prepend RackServer | ||
Rails.configuration.assets.paths << root.join("assets").to_s | ||
at_exit{ cleanup } | ||
end | ||
|
||
def start! | ||
configuration.app_list.each(&:start) | ||
end | ||
|
||
def stop! | ||
configuration.app_list.each(&:stop) | ||
end | ||
|
||
def root | ||
@root ||= Rails.root.join("tmp", "ember-cli-#{uid}") | ||
end | ||
|
||
private | ||
|
||
def uid | ||
@uid ||= SecureRandom.uuid | ||
end | ||
|
||
def cleanup | ||
root.rmtree if root.exist? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module EmberCLI | ||
class BuildServer | ||
attr_reader :name, :options, :pid | ||
|
||
def initialize(name, **options) | ||
@name, @options = name.to_s, options | ||
end | ||
|
||
def start | ||
symlink_to_assets_root | ||
|
||
@pid = spawn(command).tap do |pid| | ||
at_exit{ stop } | ||
end | ||
end | ||
|
||
def stop | ||
Process.kill "INT", pid if pid | ||
@pid = nil | ||
end | ||
|
||
private | ||
|
||
def command | ||
<<-CMD.squish | ||
cd #{app_path}; | ||
ember build --watch --output-path #{dist_path} | ||
CMD | ||
end | ||
|
||
def app_path | ||
options.fetch(:path){ Rails.root.join("app", name) } | ||
end | ||
|
||
def symlink_to_assets_root | ||
assets_path.join(name).make_symlink dist_path.join("assets") | ||
end | ||
|
||
def dist_path | ||
@dist_path ||= EmberCLI.root.join("apps", name).tap(&:mkpath) | ||
end | ||
|
||
def assets_path | ||
@assets_path ||= EmberCLI.root.join("assets").tap(&:mkpath) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require "singleton" | ||
|
||
module EmberCLI | ||
class Configuration | ||
include Singleton | ||
|
||
def app(name, **options) | ||
app_list << BuildServer.new(name, options) | ||
end | ||
|
||
def app_list | ||
@app_list ||= [] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module EmberCLI | ||
module RackServer | ||
def start | ||
EmberCLI.start! if defined?(Rails.application) && app == Rails.application | ||
super | ||
ensure | ||
EmberCLI.stop! | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module EmberCLI | ||
class Railtie < Rails::Railtie | ||
initializer "ember-cli-rails.rack-server" do | ||
EmberCLI.prepare! if development_mode? | ||
end | ||
|
||
def development_mode? | ||
!Rails.env.production? && Rails.configuration.consider_all_requests_local | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module EmberCLI | ||
VERSION = "0.0.1".freeze | ||
end |