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.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/Rakefile +31 -6
  4. data/app/assets/javascripts/templates/application.hbs +7 -0
  5. data/app/controllers/landing_controller.rb +5 -0
  6. data/lib/ember-appkit-rails.rb +9 -0
  7. data/lib/ember/appkit.rb +5 -0
  8. data/lib/ember/appkit/rails.rb +4 -4
  9. data/lib/ember/appkit/rails/engine.rb +37 -9
  10. data/lib/ember/appkit/rails/resource_override.rb +14 -0
  11. data/lib/ember/appkit/rails/sprockets.rb +4 -0
  12. data/lib/ember/appkit/rails/sprockets/directive_processor.rb +9 -0
  13. data/lib/ember/appkit/rails/sprockets/processed_asset.rb +27 -0
  14. data/lib/ember/appkit/rails/version.rb +1 -1
  15. data/lib/generators/ember/bootstrap_generator.rb +58 -19
  16. data/lib/generators/ember/component_generator.rb +2 -4
  17. data/lib/generators/ember/controller_generator.rb +1 -3
  18. data/lib/generators/ember/generator_helpers.rb +18 -10
  19. data/lib/generators/ember/helper_generator.rb +17 -0
  20. data/lib/generators/ember/model_generator.rb +3 -4
  21. data/lib/generators/ember/resource_generator.rb +13 -1
  22. data/lib/generators/ember/route_generator.rb +1 -2
  23. data/lib/generators/ember/scaffold_generator.rb +52 -0
  24. data/lib/generators/ember/template_generator.rb +1 -2
  25. data/lib/generators/ember/view_generator.rb +1 -4
  26. data/lib/generators/templates/adapter.js +3 -0
  27. data/lib/generators/templates/application.js.erb +11 -0
  28. data/lib/generators/templates/array_controller.js.es6 +1 -3
  29. data/lib/generators/templates/component.js.es6 +1 -1
  30. data/lib/generators/templates/controller.js.es6 +1 -2
  31. data/{test/dummy/app/utils → lib/generators/templates}/csrf.js +0 -0
  32. data/lib/generators/templates/environment.js +12 -0
  33. data/{test/dummy/app/views/application/show.html → lib/generators/templates/environments/development.js} +0 -0
  34. data/lib/generators/templates/environments/production.js +0 -0
  35. data/lib/generators/templates/environments/test.js +0 -0
  36. data/lib/generators/templates/helper.js +2 -0
  37. data/lib/generators/templates/model.js.es6 +1 -1
  38. data/lib/generators/templates/object_controller.js.es6 +1 -3
  39. data/lib/generators/templates/route.js.es6 +1 -2
  40. data/lib/generators/templates/router.js.es6 +1 -2
  41. data/lib/generators/templates/scaffold/route/edit.js.es6 +22 -0
  42. data/lib/generators/templates/scaffold/route/index.js.es6 +5 -0
  43. data/lib/generators/templates/scaffold/route/new.js.es6 +23 -0
  44. data/lib/generators/templates/scaffold/route/show.js.es6 +14 -0
  45. data/lib/generators/templates/scaffold/template.hbs +3 -0
  46. data/lib/generators/templates/scaffold/template/edit.hbs +3 -0
  47. data/lib/generators/templates/scaffold/template/form.hbs +9 -0
  48. data/lib/generators/templates/scaffold/template/index.hbs +20 -0
  49. data/lib/generators/templates/scaffold/template/new.hbs +3 -0
  50. data/lib/generators/templates/scaffold/template/show.hbs +9 -0
  51. data/lib/generators/templates/template.hbs +0 -5
  52. data/lib/generators/templates/view.js.es6 +1 -2
  53. data/test/dummy/Gemfile +40 -0
  54. data/test/dummy/config/adapter.js +3 -0
  55. data/test/dummy/config/application.js +11 -0
  56. data/test/dummy/config/application.rb +24 -8
  57. data/test/dummy/config/boot.rb +1 -2
  58. data/test/dummy/config/environment.js +12 -0
  59. data/test/dummy/config/environments/development.js +0 -0
  60. data/test/dummy/config/environments/development.rb +1 -3
  61. data/test/dummy/config/environments/production.js +0 -0
  62. data/test/dummy/config/environments/test.js +0 -0
  63. data/test/dummy/config/environments/test.rb +1 -1
  64. data/test/dummy/config/initializers/csrf.js +9 -0
  65. data/test/dummy/config/initializers/secret_token.rb +1 -1
  66. data/test/dummy/config/initializers/wrap_parameters.rb +0 -5
  67. data/test/dummy/{app/assets/javascripts → config}/router.js.es6 +1 -2
  68. data/test/dummy/config/routes.rb +55 -2
  69. data/test/dummy/log/test.log +14 -175
  70. data/test/dummy/public/robots.txt +5 -0
  71. data/test/dummy/tmp/Gemfile +45 -0
  72. data/test/dummy/{app → tmp/app}/assets/javascripts/application.js +3 -1
  73. data/test/dummy/tmp/app/assets/javascripts/custom/application.js +16 -0
  74. data/test/dummy/tmp/app/templates/post.hbs +0 -0
  75. data/test/dummy/tmp/app/views/layouts/application.html.erb +14 -0
  76. data/test/dummy/tmp/cache/assets/test/sprockets/07afa5d8ceda557642e2330ab45eb203 +0 -0
  77. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  78. data/test/dummy/tmp/cache/assets/test/sprockets/1f15c49a05b13c3a7ee50d2ac3900f38 +0 -0
  79. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  80. data/test/dummy/tmp/cache/assets/test/sprockets/4a1d4e32cd7b9fd1c62bfd553ae56051 +0 -0
  81. data/test/dummy/tmp/cache/assets/test/sprockets/660bc633c8899c6c1b20514637fa0169 +0 -0
  82. data/test/dummy/tmp/cache/assets/test/sprockets/67afcba9807cd5e57b80b5fdf9f26758 +0 -0
  83. data/test/dummy/tmp/cache/assets/test/sprockets/6870da13c3305651063dc22ccce27d5c +0 -0
  84. data/test/dummy/tmp/cache/assets/test/sprockets/7ca4966e0a480430a858a7ab74518c75 +0 -0
  85. data/test/dummy/tmp/cache/assets/test/sprockets/827fafc13575b345cc572fd041ef1fba +0 -0
  86. data/test/dummy/tmp/cache/assets/test/sprockets/83af35bb6b852de883a26a9458fd4e3a +0 -0
  87. data/test/dummy/tmp/cache/assets/test/sprockets/8ebc8c58233ab12eee6edfc0feca2492 +0 -0
  88. data/test/dummy/tmp/cache/assets/test/sprockets/9160f792acb62d1f7721c714681fcfe6 +0 -0
  89. data/test/dummy/tmp/cache/assets/test/sprockets/a2f615309ade94c14ae81d7ebc94fd67 +0 -0
  90. data/test/dummy/tmp/cache/assets/test/sprockets/a9648a765fed0738b076bd24099109a3 +0 -0
  91. data/test/dummy/tmp/cache/assets/test/sprockets/ae884a1acda0e6f9bb27a856a22bb08d +0 -0
  92. data/test/dummy/tmp/cache/assets/test/sprockets/bb4a2293175928af3e23c47488077098 +0 -0
  93. data/test/dummy/tmp/cache/assets/test/sprockets/bf689240392e7355c0de5cfd47272146 +0 -0
  94. data/test/dummy/tmp/cache/assets/test/sprockets/c8c4c1b316845f30168739b5795846d6 +0 -0
  95. data/test/dummy/tmp/cache/assets/test/sprockets/{2f5173deea6c795b8fdde723bb4b63af → d5a48c6656341c56cac8a8e42bb925a5} +0 -0
  96. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  97. data/test/dummy/tmp/cache/assets/test/sprockets/{cffd775d018f68ce5dba1ee0d951a994 → de0932670a6c856bc6eda1586fd29061} +0 -0
  98. data/test/dummy/tmp/cache/assets/test/sprockets/de94a60b438eb5bf57653f3a220acd80 +0 -0
  99. data/test/dummy/tmp/cache/assets/test/sprockets/e22019b3c13c20bc08e899fb2b7248ea +0 -0
  100. data/test/dummy/tmp/cache/assets/test/sprockets/e9abb671d48f6ff2be6ffb463ea652bf +0 -0
  101. data/test/dummy/tmp/cache/assets/test/sprockets/eeb5bd38d1dad0d908461fd114f702bc +0 -0
  102. data/test/dummy/tmp/cache/assets/test/sprockets/fde9e78f8d55a70f4ef757638fc6cde0 +0 -0
  103. data/test/dummy/tmp/cache/assets/test/sprockets/fdfac6623944c5a23737724cbd90e58e +0 -0
  104. data/test/dummy/tmp/ember-rails/ember-data.js +3787 -5850
  105. data/test/dummy/tmp/generator_test_output/Gemfile +45 -0
  106. data/test/dummy/tmp/generator_test_output/app/assets/javascripts/application.js +16 -0
  107. data/test/dummy/tmp/generator_test_output/app/assets/javascripts/custom/application.js +16 -0
  108. data/test/dummy/tmp/generator_test_output/app/views/layouts/application.html.erb +14 -0
  109. data/test/dummy/tmp/generator_test_output/app/views/post.js.es6 +2 -0
  110. data/test/fixtures/rails_4-0-0_Gemfile +45 -0
  111. data/test/fixtures/rails_4-0-0_application.js +16 -0
  112. data/test/fixtures/rails_4-0-0_application_layout +14 -0
  113. data/test/generators/bootstrap_generator_test.rb +72 -17
  114. data/test/generators/component_generator_test.rb +13 -20
  115. data/test/generators/controller_generator_test.rb +7 -18
  116. data/test/generators/helper_generator_test.rb +16 -0
  117. data/test/generators/model_generator_test.rb +7 -14
  118. data/test/generators/resource_generator_test.rb +12 -11
  119. data/test/generators/resource_override_test.rb +29 -0
  120. data/test/generators/route_generator_test.rb +1 -9
  121. data/test/generators/scaffold_generator_test.rb +48 -0
  122. data/test/generators/template_generator_test.rb +4 -10
  123. data/test/generators/view_generator_test.rb +11 -18
  124. data/test/integration/navigation_test.rb +11 -3
  125. data/test/support/generator_test_support.rb +59 -18
  126. data/test/support/integration_test_support.rb +12 -0
  127. data/vendor/assets/javascripts/app.js.es6.erb +27 -0
  128. data/vendor/assets/javascripts/ember-appkit/index.js +1 -0
  129. data/vendor/assets/javascripts/ember-appkit/resolver.js +13 -9
  130. metadata +133 -90
  131. data/lib/generators/templates/application.js +0 -2
  132. data/lib/generators/templates/ember-app.js.es6 +0 -15
  133. data/test/dummy/app/assets/javascripts/components/my-component.js.es6 +0 -4
  134. data/test/dummy/app/assets/javascripts/controllers/index.js.es6 +0 -7
  135. data/test/dummy/app/assets/javascripts/ember-app.js +0 -9
  136. data/test/dummy/app/assets/javascripts/models/person.js.es6 +0 -3
  137. data/test/dummy/app/assets/javascripts/routes/index.js.es6 +0 -13
  138. data/test/dummy/app/assets/javascripts/templates/application.hbs +0 -2
  139. data/test/dummy/app/assets/javascripts/templates/components/my-component.hbs +0 -1
  140. data/test/dummy/app/assets/javascripts/templates/index.hbs +0 -6
  141. data/test/dummy/tmp/app/assets/javascripts/templates/post.hbs +0 -5
  142. data/test/dummy/tmp/cache/assets/test/sprockets/19c9bc7dbf67a891e93c7a663a62ff1c +0 -0
  143. data/test/dummy/tmp/cache/assets/test/sprockets/22d5df6f378a04858f2123ee6e176ff1 +0 -0
  144. data/test/dummy/tmp/cache/assets/test/sprockets/30e6b42a491dc4952ff020137405d502 +0 -0
  145. data/test/dummy/tmp/cache/assets/test/sprockets/331122f2f78d79778408023cf5bad1e3 +0 -0
  146. data/test/dummy/tmp/cache/assets/test/sprockets/34b3026e7f937c6a19a0aee7f8451aad +0 -0
  147. data/test/dummy/tmp/cache/assets/test/sprockets/36b770b8db4bb47ce9c524d7104be2e9 +0 -0
  148. data/test/dummy/tmp/cache/assets/test/sprockets/4bde569e155e5abfc2bc79bb61721688 +0 -0
  149. data/test/dummy/tmp/cache/assets/test/sprockets/720ee922899be7948cc2a8b27660ce0b +0 -0
  150. data/test/dummy/tmp/cache/assets/test/sprockets/7689ffe6d7c831ee178e07106482b2cc +0 -0
  151. data/test/dummy/tmp/cache/assets/test/sprockets/7bf1770d3a1c8bc1b59a4bc89d5c4bca +0 -0
  152. data/test/dummy/tmp/cache/assets/test/sprockets/7d008b32a16b10ea72ea849f47d9a095 +0 -0
  153. data/test/dummy/tmp/cache/assets/test/sprockets/8e9feb35d7e388f760d17aaf89b32731 +0 -0
  154. data/test/dummy/tmp/cache/assets/test/sprockets/b3a5b51571520b61f892c51e979b9f53 +0 -0
  155. data/test/dummy/tmp/cache/assets/test/sprockets/c0bb6b15bdd48873e96974816e18abe9 +0 -0
  156. data/test/dummy/tmp/cache/assets/test/sprockets/e2a67ad17895f7711966ca1a5ff7af86 +0 -0
  157. data/test/dummy/tmp/cache/assets/test/sprockets/e44f5ebcd8f42995512e64b96b63c9cf +0 -0
  158. data/test/dummy/tmp/cache/assets/test/sprockets/e8aa57b28c86586b8b7344feb891c43f +0 -0
  159. data/test/dummy/tmp/cache/assets/test/sprockets/ed5238112abbfd6a794a100804365903 +0 -0
  160. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  161. data/test/dummy/tmp/generator_test_output/app/assets/javascripts/views/post.js.es6 +0 -3
  162. data/vendor/assets/javascripts/app.js.es6 +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53d3da970fefe831da5e6face8a979d9e8ba502c
4
- data.tar.gz: 5edd87c207fedee58fbae5dd4416f2c49c818a59
3
+ metadata.gz: 0874dea93db3fa11015b47e4ee86d134b53f7cc1
4
+ data.tar.gz: 6ccbb73644b1fcb4186f2c8d76c5bb9d2573b2eb
5
5
  SHA512:
6
- metadata.gz: 54fa1bfb857f043f8409c146d0e9220fedbb2b098aad721035474e1760f69327f6a2c24fc495c7e0acbcf8475f114149666e4415e90bc3e2a3ffdd6a86b6eed4
7
- data.tar.gz: 61aea37e7950bd8c6534513db09a1046b5d496835ace1f77479cf8db9590941012c70e13162bbaebe65ba2486753595a4a656e1f444ba7eb03a555954bcfc0f9
6
+ metadata.gz: 10131da862cab1fd0244aa1867a51676b6f6f7adfd9adfefce09c28f77db5f69b94e894423b21922c4bfd18ac43f5c4e4e1681f10b4564465299028c9f255b75
7
+ data.tar.gz: f6c89b463d4cfbd0e5d2ede8978b0526b9dd4b653861d98db081164d39e747e9c290a3a89c94c854233171e9c52bc2c729e57851938544bf533691ed36fffd41
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2013 YOURNAME
1
+ Copyright 2013 DockYard
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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.iso8601.to_s
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'
@@ -0,0 +1,7 @@
1
+ <h1>Welcome to Ember!</h1>
2
+
3
+ <div>
4
+ <p>Congratulations on building your first Ember application. That was easy, wasn't it?</p>
5
+ <p>Try some simple Ember magic: {{input value=someText name="sampleInput"}}</p>
6
+ <p>{{someText}}</p>
7
+ </div>
@@ -0,0 +1,5 @@
1
+ class LandingController < ApplicationController
2
+ def index
3
+ render inline: '', layout: 'application'
4
+ end
5
+ end
@@ -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'
@@ -0,0 +1,5 @@
1
+ require 'ember-rails'
2
+ require 'ember/source'
3
+ require 'es6_module_transpiler/rails'
4
+
5
+ module Ember::Appkit; end
@@ -1,6 +1,6 @@
1
- require 'ember-rails'
2
- require 'ember/source'
1
+ module Ember::Appkit::Rails; end
2
+
3
3
  require 'ember/appkit/rails/engine'
4
- require 'es6_module_transpiler/rails'
4
+ require 'ember/appkit/rails/sprockets'
5
5
 
6
- ES6ModuleTranspiler.prefix_pattern = [/^(controllers|models|views|helpers|routes|router|store)/, 'appkit']
6
+ Rails::WelcomeController.view_paths = File.expand_path('../rails/templates', __FILE__)
@@ -1,12 +1,40 @@
1
- module Ember
2
- module Appkit
3
- module Rails
4
- class Engine < ::Rails::Engine
5
- config.handlebars ||= ActiveSupport::OrderedOptions.new
6
-
7
- config.handlebars.output_type = :amd
8
- config.handlebars.amd_namespace = 'appkit'
9
- end
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,4 @@
1
+ module Ember::Appkit::Rails::Sprockets; end
2
+
3
+ require 'ember/appkit/rails/sprockets/processed_asset'
4
+ require 'ember/appkit/rails/sprockets/directive_processor'
@@ -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)
@@ -1,7 +1,7 @@
1
1
  module Ember
2
2
  module Appkit
3
3
  module Rails
4
- VERSION = '0.1.2'
4
+ VERSION = '0.2.0'
5
5
  end
6
6
  end
7
7
  end
@@ -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 :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
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{models controllers views routes helpers components templates templates/components mixins}.each do |dir|
22
- empty_directory "#{ember_path}/#{dir}"
23
- create_file "#{ember_path}/#{dir}/.gitkeep" unless options[:skip_git]
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", "#{ember_path}/router.js.es6"
28
+ template "router.js.es6", "#{config_path}/router.js.es6"
29
29
  end
30
30
 
31
- def create_ember_app_file
32
- template "ember-app.js.es6", "#{ember_path}/ember-app.js.es6"
31
+ def create_application_file
32
+ template "application.js.erb", "#{config_path}/application.js"
33
33
  end
34
34
 
35
- private
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 inject_into_application_file
38
- application_file = "#{ember_path}/application.js"
39
- inject_into_file( application_file, :before => /^.*require_tree.*$/) do
40
- context = instance_eval('binding')
41
- source = File.expand_path(find_in_source_paths("application.js"))
42
- ERB.new(::File.binread(source), nil, '-', '@output_buffer').result(context)
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(ember_path, 'components', class_path, "#{dashed_file_name}_component.js.es6")
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(ember_path, 'templates/components', class_path, "#{dashed_file_name}.hbs")
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(ember_path, 'controllers', class_path, "#{file_name}.js.es6")
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 ember_path
8
- if options[:ember_path]
9
- options[:ember_path]
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
- "app/assets/javascripts"
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
- "App"
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