ember-appkit-rails 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/Rakefile +31 -6
- data/app/assets/javascripts/templates/application.hbs +7 -0
- data/app/controllers/landing_controller.rb +5 -0
- data/lib/ember-appkit-rails.rb +9 -0
- data/lib/ember/appkit.rb +5 -0
- data/lib/ember/appkit/rails.rb +4 -4
- data/lib/ember/appkit/rails/engine.rb +37 -9
- data/lib/ember/appkit/rails/resource_override.rb +14 -0
- data/lib/ember/appkit/rails/sprockets.rb +4 -0
- data/lib/ember/appkit/rails/sprockets/directive_processor.rb +9 -0
- data/lib/ember/appkit/rails/sprockets/processed_asset.rb +27 -0
- data/lib/ember/appkit/rails/version.rb +1 -1
- data/lib/generators/ember/bootstrap_generator.rb +58 -19
- data/lib/generators/ember/component_generator.rb +2 -4
- data/lib/generators/ember/controller_generator.rb +1 -3
- data/lib/generators/ember/generator_helpers.rb +18 -10
- data/lib/generators/ember/helper_generator.rb +17 -0
- data/lib/generators/ember/model_generator.rb +3 -4
- data/lib/generators/ember/resource_generator.rb +13 -1
- data/lib/generators/ember/route_generator.rb +1 -2
- data/lib/generators/ember/scaffold_generator.rb +52 -0
- data/lib/generators/ember/template_generator.rb +1 -2
- data/lib/generators/ember/view_generator.rb +1 -4
- data/lib/generators/templates/adapter.js +3 -0
- data/lib/generators/templates/application.js.erb +11 -0
- data/lib/generators/templates/array_controller.js.es6 +1 -3
- data/lib/generators/templates/component.js.es6 +1 -1
- data/lib/generators/templates/controller.js.es6 +1 -2
- data/{test/dummy/app/utils → lib/generators/templates}/csrf.js +0 -0
- data/lib/generators/templates/environment.js +12 -0
- data/{test/dummy/app/views/application/show.html → lib/generators/templates/environments/development.js} +0 -0
- data/lib/generators/templates/environments/production.js +0 -0
- data/lib/generators/templates/environments/test.js +0 -0
- data/lib/generators/templates/helper.js +2 -0
- data/lib/generators/templates/model.js.es6 +1 -1
- data/lib/generators/templates/object_controller.js.es6 +1 -3
- data/lib/generators/templates/route.js.es6 +1 -2
- data/lib/generators/templates/router.js.es6 +1 -2
- data/lib/generators/templates/scaffold/route/edit.js.es6 +22 -0
- data/lib/generators/templates/scaffold/route/index.js.es6 +5 -0
- data/lib/generators/templates/scaffold/route/new.js.es6 +23 -0
- data/lib/generators/templates/scaffold/route/show.js.es6 +14 -0
- data/lib/generators/templates/scaffold/template.hbs +3 -0
- data/lib/generators/templates/scaffold/template/edit.hbs +3 -0
- data/lib/generators/templates/scaffold/template/form.hbs +9 -0
- data/lib/generators/templates/scaffold/template/index.hbs +20 -0
- data/lib/generators/templates/scaffold/template/new.hbs +3 -0
- data/lib/generators/templates/scaffold/template/show.hbs +9 -0
- data/lib/generators/templates/template.hbs +0 -5
- data/lib/generators/templates/view.js.es6 +1 -2
- data/test/dummy/Gemfile +40 -0
- data/test/dummy/config/adapter.js +3 -0
- data/test/dummy/config/application.js +11 -0
- data/test/dummy/config/application.rb +24 -8
- data/test/dummy/config/boot.rb +1 -2
- data/test/dummy/config/environment.js +12 -0
- data/test/dummy/config/environments/development.js +0 -0
- data/test/dummy/config/environments/development.rb +1 -3
- data/test/dummy/config/environments/production.js +0 -0
- data/test/dummy/config/environments/test.js +0 -0
- data/test/dummy/config/environments/test.rb +1 -1
- data/test/dummy/config/initializers/csrf.js +9 -0
- data/test/dummy/config/initializers/secret_token.rb +1 -1
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -5
- data/test/dummy/{app/assets/javascripts → config}/router.js.es6 +1 -2
- data/test/dummy/config/routes.rb +55 -2
- data/test/dummy/log/test.log +14 -175
- data/test/dummy/public/robots.txt +5 -0
- data/test/dummy/tmp/Gemfile +45 -0
- data/test/dummy/{app → tmp/app}/assets/javascripts/application.js +3 -1
- data/test/dummy/tmp/app/assets/javascripts/custom/application.js +16 -0
- data/test/dummy/tmp/app/templates/post.hbs +0 -0
- data/test/dummy/tmp/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/07afa5d8ceda557642e2330ab45eb203 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1f15c49a05b13c3a7ee50d2ac3900f38 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4a1d4e32cd7b9fd1c62bfd553ae56051 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/660bc633c8899c6c1b20514637fa0169 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/67afcba9807cd5e57b80b5fdf9f26758 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6870da13c3305651063dc22ccce27d5c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7ca4966e0a480430a858a7ab74518c75 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/827fafc13575b345cc572fd041ef1fba +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/83af35bb6b852de883a26a9458fd4e3a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8ebc8c58233ab12eee6edfc0feca2492 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9160f792acb62d1f7721c714681fcfe6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a2f615309ade94c14ae81d7ebc94fd67 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a9648a765fed0738b076bd24099109a3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ae884a1acda0e6f9bb27a856a22bb08d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bb4a2293175928af3e23c47488077098 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bf689240392e7355c0de5cfd47272146 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c8c4c1b316845f30168739b5795846d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{2f5173deea6c795b8fdde723bb4b63af → d5a48c6656341c56cac8a8e42bb925a5} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{cffd775d018f68ce5dba1ee0d951a994 → de0932670a6c856bc6eda1586fd29061} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/de94a60b438eb5bf57653f3a220acd80 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e22019b3c13c20bc08e899fb2b7248ea +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e9abb671d48f6ff2be6ffb463ea652bf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/eeb5bd38d1dad0d908461fd114f702bc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fde9e78f8d55a70f4ef757638fc6cde0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fdfac6623944c5a23737724cbd90e58e +0 -0
- data/test/dummy/tmp/ember-rails/ember-data.js +3787 -5850
- data/test/dummy/tmp/generator_test_output/Gemfile +45 -0
- data/test/dummy/tmp/generator_test_output/app/assets/javascripts/application.js +16 -0
- data/test/dummy/tmp/generator_test_output/app/assets/javascripts/custom/application.js +16 -0
- data/test/dummy/tmp/generator_test_output/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/tmp/generator_test_output/app/views/post.js.es6 +2 -0
- data/test/fixtures/rails_4-0-0_Gemfile +45 -0
- data/test/fixtures/rails_4-0-0_application.js +16 -0
- data/test/fixtures/rails_4-0-0_application_layout +14 -0
- data/test/generators/bootstrap_generator_test.rb +72 -17
- data/test/generators/component_generator_test.rb +13 -20
- data/test/generators/controller_generator_test.rb +7 -18
- data/test/generators/helper_generator_test.rb +16 -0
- data/test/generators/model_generator_test.rb +7 -14
- data/test/generators/resource_generator_test.rb +12 -11
- data/test/generators/resource_override_test.rb +29 -0
- data/test/generators/route_generator_test.rb +1 -9
- data/test/generators/scaffold_generator_test.rb +48 -0
- data/test/generators/template_generator_test.rb +4 -10
- data/test/generators/view_generator_test.rb +11 -18
- data/test/integration/navigation_test.rb +11 -3
- data/test/support/generator_test_support.rb +59 -18
- data/test/support/integration_test_support.rb +12 -0
- data/vendor/assets/javascripts/app.js.es6.erb +27 -0
- data/vendor/assets/javascripts/ember-appkit/index.js +1 -0
- data/vendor/assets/javascripts/ember-appkit/resolver.js +13 -9
- metadata +133 -90
- data/lib/generators/templates/application.js +0 -2
- data/lib/generators/templates/ember-app.js.es6 +0 -15
- data/test/dummy/app/assets/javascripts/components/my-component.js.es6 +0 -4
- data/test/dummy/app/assets/javascripts/controllers/index.js.es6 +0 -7
- data/test/dummy/app/assets/javascripts/ember-app.js +0 -9
- data/test/dummy/app/assets/javascripts/models/person.js.es6 +0 -3
- data/test/dummy/app/assets/javascripts/routes/index.js.es6 +0 -13
- data/test/dummy/app/assets/javascripts/templates/application.hbs +0 -2
- data/test/dummy/app/assets/javascripts/templates/components/my-component.hbs +0 -1
- data/test/dummy/app/assets/javascripts/templates/index.hbs +0 -6
- data/test/dummy/tmp/app/assets/javascripts/templates/post.hbs +0 -5
- data/test/dummy/tmp/cache/assets/test/sprockets/19c9bc7dbf67a891e93c7a663a62ff1c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/22d5df6f378a04858f2123ee6e176ff1 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/30e6b42a491dc4952ff020137405d502 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/331122f2f78d79778408023cf5bad1e3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/34b3026e7f937c6a19a0aee7f8451aad +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/36b770b8db4bb47ce9c524d7104be2e9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4bde569e155e5abfc2bc79bb61721688 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/720ee922899be7948cc2a8b27660ce0b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7689ffe6d7c831ee178e07106482b2cc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7bf1770d3a1c8bc1b59a4bc89d5c4bca +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7d008b32a16b10ea72ea849f47d9a095 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8e9feb35d7e388f760d17aaf89b32731 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b3a5b51571520b61f892c51e979b9f53 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c0bb6b15bdd48873e96974816e18abe9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e2a67ad17895f7711966ca1a5ff7af86 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e44f5ebcd8f42995512e64b96b63c9cf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e8aa57b28c86586b8b7344feb891c43f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ed5238112abbfd6a794a100804365903 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/generator_test_output/app/assets/javascripts/views/post.js.es6 +0 -3
- data/vendor/assets/javascripts/app.js.es6 +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0874dea93db3fa11015b47e4ee86d134b53f7cc1
|
4
|
+
data.tar.gz: 6ccbb73644b1fcb4186f2c8d76c5bb9d2573b2eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10131da862cab1fd0244aa1867a51676b6f6f7adfd9adfefce09c28f77db5f69b94e894423b21922c4bfd18ac43f5c4e4e1681f10b4564465299028c9f255b75
|
7
|
+
data.tar.gz: f6c89b463d4cfbd0e5d2ede8978b0526b9dd4b653861d98db081164d39e747e9c290a3a89c94c854233171e9c52bc2c729e57851938544bf533691ed36fffd41
|
data/MIT-LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
require 'rdoc/task'
|
2
3
|
require 'net/http'
|
3
4
|
require 'uri'
|
@@ -16,16 +17,13 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
16
17
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
17
18
|
end
|
18
19
|
|
19
|
-
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
20
|
-
load 'rails/tasks/engine.rake'
|
21
|
-
|
22
20
|
desc "Update ember-resolver."
|
23
21
|
task :update_resolver do
|
24
22
|
uri = URI("https://raw.github.com/stefanpenner/ember-jj-abrams-resolver/master/dist/ember-resolver.js")
|
25
23
|
|
26
24
|
output = StringIO.new
|
27
25
|
output.puts "// Fetched from: " + uri.to_s
|
28
|
-
output.puts "// Fetched on: " + Time.now.utc.
|
26
|
+
output.puts "// Fetched on: " + Time.now.utc.strftime('%FT%T')
|
29
27
|
output.puts Net::HTTP.get(uri).force_encoding("UTF-8")
|
30
28
|
output.rewind
|
31
29
|
|
@@ -37,18 +35,45 @@ task :update_resolver_if_requested do
|
|
37
35
|
Rake::Task['update_resolver'].invoke if ENV['UPDATE_RESOLVER'] == 'true'
|
38
36
|
end
|
39
37
|
|
38
|
+
desc "Setup dummy application."
|
39
|
+
task :setup_dummy_app do
|
40
|
+
initial_path = Dir.pwd
|
41
|
+
|
42
|
+
require 'rails'
|
43
|
+
require 'rails/generators'
|
44
|
+
require 'rails/generators/rails/app/app_generator'
|
45
|
+
|
46
|
+
FileUtils.rm_rf 'test/dummy'
|
47
|
+
|
48
|
+
silence_stream(STDOUT) do
|
49
|
+
begin
|
50
|
+
Rails::Generators::AppGenerator.start ['test/dummy', '--skip-active-record', '--skip-bundle']
|
51
|
+
ensure
|
52
|
+
Dir.chdir initial_path
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
application_config_path = 'test/dummy/config/application.rb'
|
57
|
+
application_config = File.read(application_config_path)
|
58
|
+
|
59
|
+
File.write(application_config_path, application_config.sub('module Dummy', "require 'jquery-rails'\nrequire 'ember-appkit-rails'\nmodule Dummy"))
|
60
|
+
|
61
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
62
|
+
load 'rails/tasks/engine.rake'
|
63
|
+
end
|
64
|
+
|
40
65
|
Bundler::GemHelper.install_tasks
|
41
66
|
|
42
67
|
require 'rake/testtask'
|
43
68
|
|
44
|
-
Rake::TestTask.new(:integration_test) do |t|
|
69
|
+
Rake::TestTask.new(:integration_test => :setup_dummy_app) do |t|
|
45
70
|
t.libs << 'lib'
|
46
71
|
t.libs << 'test'
|
47
72
|
t.pattern = 'test/integration/**/*_test.rb'
|
48
73
|
t.verbose = false
|
49
74
|
end
|
50
75
|
|
51
|
-
Rake::TestTask.new(:generators_test) do |t|
|
76
|
+
Rake::TestTask.new(:generators_test => :setup_dummy_app) do |t|
|
52
77
|
t.libs << 'lib'
|
53
78
|
t.libs << 'test'
|
54
79
|
t.pattern = 'test/generators/**/*_test.rb'
|
data/lib/ember-appkit-rails.rb
CHANGED
@@ -1 +1,10 @@
|
|
1
|
+
# This is necessary because the generators live in `lib/generators`
|
2
|
+
# this path is on the Rubygems load path and the first wins. We need
|
3
|
+
# to ensure the ember-appkit-rails is always on the load path *before*
|
4
|
+
# ember-rails
|
5
|
+
|
6
|
+
$:.delete(File.expand_path('..', __FILE__))
|
7
|
+
$:.unshift(File.expand_path('..', __FILE__))
|
8
|
+
|
9
|
+
require 'ember/appkit'
|
1
10
|
require 'ember/appkit/rails'
|
data/lib/ember/appkit.rb
ADDED
data/lib/ember/appkit/rails.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Ember::Appkit::Rails; end
|
2
|
+
|
3
3
|
require 'ember/appkit/rails/engine'
|
4
|
-
require '
|
4
|
+
require 'ember/appkit/rails/sprockets'
|
5
5
|
|
6
|
-
|
6
|
+
Rails::WelcomeController.view_paths = File.expand_path('../rails/templates', __FILE__)
|
@@ -1,12 +1,40 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
require 'ember-rails'
|
2
|
+
|
3
|
+
class Ember::Appkit::Rails::Engine < ::Rails::Engine
|
4
|
+
config.ember.appkit = ActiveSupport::OrderedOptions.new
|
5
|
+
config.ember.appkit.paths = ActiveSupport::OrderedOptions.new
|
6
|
+
config.ember.appkit.namespaces = ActiveSupport::OrderedOptions.new
|
7
|
+
config.ember.appkit.prefix_patterns = ActiveSupport::OrderedOptions.new
|
8
|
+
|
9
|
+
config.ember.appkit.paths.app = 'app'
|
10
|
+
config.ember.appkit.paths.config = 'config'
|
11
|
+
config.ember.appkit.namespaces.app = 'app'
|
12
|
+
config.ember.appkit.namespaces.config = 'config'
|
13
|
+
|
14
|
+
config.ember.appkit.enable_logging = ::Rails.env.development?
|
15
|
+
|
16
|
+
initializer :appkit_transpiler do
|
17
|
+
config.ember.appkit.prefix_patterns.app ||= Regexp.new(File.join(::Rails.root, config.ember.appkit.namespaces.app))
|
18
|
+
config.ember.appkit.prefix_patterns.config ||= Regexp.new(File.join(::Rails.root, config.ember.appkit.namespaces.config))
|
19
|
+
|
20
|
+
ES6ModuleTranspiler.add_prefix_pattern config.ember.appkit.prefix_patterns.app, config.ember.appkit.namespaces.app
|
21
|
+
ES6ModuleTranspiler.add_prefix_pattern config.ember.appkit.prefix_patterns.config, config.ember.appkit.namespaces.config
|
22
|
+
end
|
23
|
+
|
24
|
+
initializer :appkit_handlebars do
|
25
|
+
config.handlebars ||= ActiveSupport::OrderedOptions.new
|
26
|
+
config.handlebars.output_type = :amd
|
27
|
+
config.handlebars.amd_namespace = config.ember.appkit.namespaces.app
|
28
|
+
end
|
29
|
+
|
30
|
+
initializer :appkit_router do |app|
|
31
|
+
app.routes.append do
|
32
|
+
get '/' => "landing#index"
|
10
33
|
end
|
11
34
|
end
|
35
|
+
|
36
|
+
initializer :appkit_sprockets do
|
37
|
+
Sprockets::Railtie.config.assets.paths.unshift(File.join(::Rails.root, config.ember.appkit.paths.config))
|
38
|
+
Sprockets::Railtie.config.assets.paths.unshift(File.join(::Rails.root, config.ember.appkit.paths.app))
|
39
|
+
end
|
12
40
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'generators/ember/resource_override'
|
2
|
+
|
3
|
+
module Ember::Appkit::Rails::ResourceOverride
|
4
|
+
def add_ember
|
5
|
+
if options.ember
|
6
|
+
super
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
Rails::Generators::ResourceGenerator.class_eval do
|
12
|
+
prepend Ember::Appkit::Rails::ResourceOverride
|
13
|
+
class_option :ember, aliases: '-e', desc: 'force ember resource to generate', optional: true, type: 'boolean', default: false, banner: '--ember'
|
14
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'sprockets/directive_processor'
|
2
|
+
|
3
|
+
module Ember::Appkit::Rails::Sprockets::DirectiveProcessor
|
4
|
+
def process_require_environment_from_directive(path)
|
5
|
+
context.require_asset(File.join(path, ::Rails.env))
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
Sprockets::DirectiveProcessor.send(:include, Ember::Appkit::Rails::Sprockets::DirectiveProcessor)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'sprockets/processed_asset'
|
2
|
+
|
3
|
+
module Ember::Appkit::Rails::Sprockets::ProcessedAsset
|
4
|
+
def initialize(environment, logical_path, pathname)
|
5
|
+
super
|
6
|
+
|
7
|
+
_make_ember_application_template_stale(pathname)
|
8
|
+
end
|
9
|
+
|
10
|
+
def init_with(environment, coder)
|
11
|
+
super
|
12
|
+
|
13
|
+
_make_ember_application_template_stale(coder['pathname'])
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def _make_ember_application_template_stale(pathname)
|
19
|
+
if pathname.to_s =~ /ember-appkit-rails.+\/app\/assets\/javascripts\/templates\/application.hbs/
|
20
|
+
def self.fresh?(environment)
|
21
|
+
false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Sprockets::ProcessedAsset.send(:prepend, Ember::Appkit::Rails::Sprockets::ProcessedAsset)
|
@@ -9,39 +9,78 @@ module Ember
|
|
9
9
|
|
10
10
|
desc "Creates a default Ember.js folder layout in app/assets/javascripts"
|
11
11
|
|
12
|
-
class_option :
|
12
|
+
class_option :app_path, :type => :string, :aliases => "-a", :default => false, :desc => "Custom ember app path"
|
13
|
+
class_option :config_path, :type => :string, :aliases => "-c", :default => false, :desc => "Custom ember config path"
|
13
14
|
class_option :app_name, :type => :string, :aliases => "-n", :default => false, :desc => "Custom ember app name"
|
14
15
|
|
15
|
-
def inject_ember
|
16
|
-
inject_into_application_file
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
16
|
def create_dir_layout
|
21
|
-
%W{
|
22
|
-
empty_directory "#{
|
23
|
-
create_file "#{
|
17
|
+
%W{routes components templates templates/components mixins}.each do |dir|
|
18
|
+
empty_directory "#{app_path}/#{dir}"
|
19
|
+
create_file "#{app_path}/#{dir}/.gitkeep" unless options[:skip_git]
|
24
20
|
end
|
25
21
|
end
|
26
22
|
|
23
|
+
def remove_javascript_assets_directory
|
24
|
+
remove_dir "app/assets/javascripts"
|
25
|
+
end
|
26
|
+
|
27
27
|
def create_router_file
|
28
|
-
template "router.js.es6", "#{
|
28
|
+
template "router.js.es6", "#{config_path}/router.js.es6"
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
template "
|
31
|
+
def create_application_file
|
32
|
+
template "application.js.erb", "#{config_path}/application.js"
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
def create_ember_adapter_file
|
36
|
+
template "adapter.js", "#{config_path}/adapter.js"
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_ember_environment_files
|
40
|
+
template "environment.js", "#{config_path}/environment.js"
|
41
|
+
template "environments/development.js", "#{config_path}/environments/development.js"
|
42
|
+
template "environments/production.js", "#{config_path}/environments/production.js"
|
43
|
+
template "environments/test.js", "#{config_path}/environments/test.js"
|
44
|
+
end
|
36
45
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
46
|
+
def create_utils_csrf_file
|
47
|
+
template "csrf.js", "#{config_path}/initializers/csrf.js"
|
48
|
+
end
|
49
|
+
|
50
|
+
def remove_turbolinks
|
51
|
+
remove_turbolinks_from_gemfile
|
52
|
+
remove_turbolinks_from_layout
|
53
|
+
end
|
54
|
+
|
55
|
+
def add_custom_paths
|
56
|
+
if app_path != configuration.paths.app
|
57
|
+
insert_into_file 'config/application.rb', before: /\s\send\nend/ do
|
58
|
+
" config.ember.appkit.paths.app = '#{app_path}'\n"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if config_path != configuration.paths.config
|
63
|
+
insert_into_file 'config/application.rb', before: /\s\send\nend/ do
|
64
|
+
" config.ember.appkit.paths.config = '#{config_path}'\n"
|
65
|
+
end
|
43
66
|
end
|
44
67
|
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def remove_turbolinks_from_layout
|
72
|
+
path = Pathname.new(destination_root).join('app','views','layouts','application.html.erb')
|
73
|
+
return unless path.exist?
|
74
|
+
|
75
|
+
gsub_file path, /(?:, "data-turbolinks-track" => true)/, ''
|
76
|
+
end
|
77
|
+
|
78
|
+
def remove_turbolinks_from_gemfile
|
79
|
+
path = Pathname.new(destination_root).join('Gemfile')
|
80
|
+
return unless path.exist?
|
81
|
+
|
82
|
+
gsub_file path, /(?:#.+$\n)?gem 'turbolinks'\n\n/, ''
|
83
|
+
end
|
45
84
|
end
|
46
85
|
end
|
47
86
|
end
|
@@ -9,14 +9,12 @@ module Ember
|
|
9
9
|
|
10
10
|
desc "Creates a new Ember.js component and component template\nCustom Ember Components require at least two descriptive names separated by a dash. Use CamelCase or dash-case to name your component.\n\nExample,\n\trails generate ember:component PostChart [options]\n\trails generate ember:component post-chart [options]"
|
11
11
|
|
12
|
-
class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
|
13
|
-
|
14
12
|
def create_component_files
|
15
13
|
dashed_file_name = file_name.gsub(/_/, '-')
|
16
|
-
component_path = File.join(
|
14
|
+
component_path = File.join(app_path, 'components', class_path, "#{dashed_file_name}_component.js.es6")
|
17
15
|
template "component.js.es6", component_path
|
18
16
|
|
19
|
-
template_path = File.join(
|
17
|
+
template_path = File.join(app_path, 'templates/components', class_path, "#{dashed_file_name}.hbs")
|
20
18
|
template "component.template.hbs", template_path
|
21
19
|
end
|
22
20
|
end
|
@@ -11,11 +11,9 @@ module Ember
|
|
11
11
|
|
12
12
|
class_option :array, :type => :boolean, :default => false, :desc => "Create an Ember.ArrayController to represent multiple objects."
|
13
13
|
class_option :object, :type => :boolean, :default => false, :desc => "Create an Ember.ObjectController to represent a single object."
|
14
|
-
class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path."
|
15
|
-
|
16
14
|
|
17
15
|
def create_controller_files
|
18
|
-
file_path = File.join(
|
16
|
+
file_path = File.join(app_path, 'controllers', class_path, "#{file_name}.js.es6")
|
19
17
|
|
20
18
|
if options.array?
|
21
19
|
template "array_controller.js.es6", file_path
|
@@ -4,15 +4,19 @@ module Ember
|
|
4
4
|
module Generators
|
5
5
|
module GeneratorHelpers
|
6
6
|
|
7
|
-
def
|
8
|
-
if options[:
|
9
|
-
options[:
|
10
|
-
elsif configuration.ember_path
|
11
|
-
configuration.ember_path
|
12
|
-
elsif rails_engine?
|
13
|
-
"app/assets/javascripts/#{engine_name}"
|
7
|
+
def app_path
|
8
|
+
if options[:app_path]
|
9
|
+
options[:app_path]
|
14
10
|
else
|
15
|
-
|
11
|
+
configuration.paths.app
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def config_path
|
16
|
+
if options[:config_path]
|
17
|
+
options[:config_path]
|
18
|
+
else
|
19
|
+
configuration.paths.config
|
16
20
|
end
|
17
21
|
end
|
18
22
|
|
@@ -32,7 +36,7 @@ module Ember
|
|
32
36
|
elsif rails_engine?
|
33
37
|
engine_name
|
34
38
|
else
|
35
|
-
|
39
|
+
'App'
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
@@ -44,8 +48,12 @@ module Ember
|
|
44
48
|
File.join(class_path, file_name).gsub(/^\//, '')
|
45
49
|
end
|
46
50
|
|
51
|
+
def javascript_assets_path
|
52
|
+
File.join(::Rails.root, 'app/assets/javascripts')
|
53
|
+
end
|
54
|
+
|
47
55
|
def configuration
|
48
|
-
::Rails.configuration.ember
|
56
|
+
::Rails.configuration.ember.appkit
|
49
57
|
end
|
50
58
|
end
|
51
59
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'generators/ember/generator_helpers'
|
2
|
+
|
3
|
+
module Ember
|
4
|
+
module Generators
|
5
|
+
class HelperGenerator < ::Rails::Generators::NamedBase
|
6
|
+
include Ember::Generators::GeneratorHelpers
|
7
|
+
|
8
|
+
source_root File.expand_path("../../templates", __FILE__)
|
9
|
+
argument :name, :type => :string, :desc => 'Create an Ember.Handlebars.helper'
|
10
|
+
|
11
|
+
def create_helper_files
|
12
|
+
file_path = File.join(app_path, 'helpers', class_path, "#{file_name}.js")
|
13
|
+
template 'helper.js', file_path
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|