ember-cli-rails 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ece29a97e8866156fbec8a2d9158473759df1981
4
+ data.tar.gz: 134a2168bd52ab0c360a72f8f46714bf9327a4b6
5
+ SHA512:
6
+ metadata.gz: 2c4dfd6a42b7eaa7cd0b27f57bca34d32a5969f53cfc6f60136868a86c67e160b4a2b12d25d5a1be7589a68bf61b49313be2c50aa542018eba0c50175cf5a53a
7
+ data.tar.gz: 130aedaf0177a43812e4022810d8fbf0da98b653145dd1b95463c842b29b57a6d2c70e25d71058cb4e7855f2dca806244759b9e804fb265846c1a3e5747fa012
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Pavel Pravosud
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Ember::Cli::Rails
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ember-cli-rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ember-cli-rails
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/ember-cli-rails/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,46 @@
1
+ require "ember-cli/railtie" if defined?(Rails)
2
+
3
+ module EmberCLI
4
+ extend self
5
+
6
+ autoload :BuildServer, "ember-cli/build_server"
7
+ autoload :Configuration, "ember-cli/configuration"
8
+ autoload :RackServer, "ember-cli/rack_server"
9
+ autoload :ViewHelpers, "ember-cli/view_helpers"
10
+
11
+ def configure
12
+ yield configuration
13
+ end
14
+
15
+ def configuration
16
+ Configuration.instance
17
+ end
18
+
19
+ def prepare!
20
+ Rack::Server.prepend RackServer
21
+ Rails.configuration.assets.paths << root.join("assets").to_s
22
+ at_exit{ cleanup }
23
+ end
24
+
25
+ def start!
26
+ configuration.app_list.each(&:start)
27
+ end
28
+
29
+ def stop!
30
+ configuration.app_list.each(&:stop)
31
+ end
32
+
33
+ def root
34
+ @root ||= Rails.root.join("tmp", "ember-cli-#{uid}")
35
+ end
36
+
37
+ private
38
+
39
+ def uid
40
+ @uid ||= SecureRandom.uuid
41
+ end
42
+
43
+ def cleanup
44
+ root.rmtree if root.exist?
45
+ end
46
+ end
@@ -0,0 +1,50 @@
1
+ module EmberCLI
2
+ class BuildServer
3
+ attr_reader :name, :options, :pid
4
+
5
+ def initialize(name, **options)
6
+ @name, @options = name.to_s, options
7
+ end
8
+
9
+ def start
10
+ symlink_to_assets_root
11
+ add_assets_to_precompile_list
12
+ @pid = spawn(command)
13
+ at_exit{ stop }
14
+ end
15
+
16
+ def stop
17
+ Process.kill "INT", pid if pid
18
+ @pid = nil
19
+ end
20
+
21
+ private
22
+
23
+ def symlink_to_assets_root
24
+ assets_path.join(name).make_symlink dist_path.join("assets")
25
+ end
26
+
27
+ def add_assets_to_precompile_list
28
+ Rails.configuration.assets.precompile << /(?:\/|\A)#{name}\//
29
+ end
30
+
31
+ def command
32
+ <<-CMD.squish
33
+ cd #{app_path};
34
+ ember build --watch --output-path #{dist_path}
35
+ CMD
36
+ end
37
+
38
+ def app_path
39
+ options.fetch(:path){ Rails.root.join("app", name) }
40
+ end
41
+
42
+ def dist_path
43
+ @dist_path ||= EmberCLI.root.join("apps", name).tap(&:mkpath)
44
+ end
45
+
46
+ def assets_path
47
+ @assets_path ||= EmberCLI.root.join("assets").tap(&:mkpath)
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,15 @@
1
+ require "singleton"
2
+
3
+ module EmberCLI
4
+ class Configuration
5
+ include Singleton
6
+
7
+ def app(name, **options)
8
+ app_list << BuildServer.new(name, options)
9
+ end
10
+
11
+ def app_list
12
+ @app_list ||= []
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ module EmberCLI
2
+ module RackServer
3
+ def start
4
+ EmberCLI.start! if defined?(Rails.application) && app == Rails.application
5
+ super
6
+ ensure
7
+ EmberCLI.stop!
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ module EmberCLI
2
+ class Railtie < Rails::Railtie
3
+ initializer "ember-cli-rails.rack-server" do
4
+ EmberCLI.prepare! if development_mode?
5
+ end
6
+
7
+ initializer "ember-cli-rails.view_helpers" do
8
+ ActionView::Base.include ViewHelpers
9
+ end
10
+
11
+ def development_mode?
12
+ !Rails.env.production? && Rails.configuration.consider_all_requests_local
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module EmberCLI
2
+ VERSION = "0.0.1".freeze
3
+ end
@@ -0,0 +1,7 @@
1
+ module EmberCLI
2
+ module ViewHelpers
3
+ def include_ember_script_tags(app_name)
4
+ javascript_include_tag "#{app_name}/vendor", "#{app_name}/#{app_name}"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generates ember cli initializer. The initializer sets up where the EmberCli application will live (by default in app/frontend)
3
+
4
+ Example:
5
+ rails generate ember-cli:init
6
+
7
+ This will create:
8
+ config/initializers/ember.rb
@@ -0,0 +1,11 @@
1
+ module EmberCLI
2
+ class InitGenerator < Rails::Generators::Base
3
+ source_root File.expand_path("../templates", __FILE__)
4
+
5
+ namespace "ember-cli:init"
6
+
7
+ def copy_initializer_file
8
+ copy_file "initializer.rb", "config/initializers/ember.rb"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ EmberCLI.configure do |c|
2
+ c.app 'frontend'
3
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ember-cli-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pavel Pravosud
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ description:
28
+ email:
29
+ - pavel@pravosud.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE.txt
35
+ - README.md
36
+ - lib/ember-cli-rails.rb
37
+ - lib/ember-cli/build_server.rb
38
+ - lib/ember-cli/configuration.rb
39
+ - lib/ember-cli/rack_server.rb
40
+ - lib/ember-cli/railtie.rb
41
+ - lib/ember-cli/version.rb
42
+ - lib/ember-cli/view_helpers.rb
43
+ - lib/generators/ember-cli/init/USAGE
44
+ - lib/generators/ember-cli/init/init_generator.rb
45
+ - lib/generators/ember-cli/init/templates/initializer.rb
46
+ homepage: https://github.com/rwz/ember-cli-rails
47
+ licenses:
48
+ - MIT
49
+ metadata: {}
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - "~>"
57
+ - !ruby/object:Gem::Version
58
+ version: '2.0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 2.4.3
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: Helps integrate EmberCLI with Rails
70
+ test_files: []