discourse-ember-rails 0.18.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +19 -0
  3. data/README.md +341 -0
  4. data/lib/ember-rails.rb +1 -0
  5. data/lib/ember/rails/engine.rb +25 -0
  6. data/lib/ember/rails/version.rb +5 -0
  7. data/lib/ember_rails.rb +96 -0
  8. data/lib/generators/ember/adapter_generator.rb +21 -0
  9. data/lib/generators/ember/bootstrap_generator.rb +76 -0
  10. data/lib/generators/ember/component_generator.rb +28 -0
  11. data/lib/generators/ember/controller_generator.rb +34 -0
  12. data/lib/generators/ember/generator_helpers.rb +58 -0
  13. data/lib/generators/ember/initializer_generator.rb +23 -0
  14. data/lib/generators/ember/install_generator.rb +194 -0
  15. data/lib/generators/ember/instance_initializer_generator.rb +23 -0
  16. data/lib/generators/ember/model_generator.rb +48 -0
  17. data/lib/generators/ember/resource_generator.rb +29 -0
  18. data/lib/generators/ember/resource_override.rb +38 -0
  19. data/lib/generators/ember/route_generator.rb +21 -0
  20. data/lib/generators/ember/service_generator.rb +23 -0
  21. data/lib/generators/ember/template_generator.rb +23 -0
  22. data/lib/generators/ember/view_generator.rb +24 -0
  23. data/lib/generators/templates/adapter.js +5 -0
  24. data/lib/generators/templates/adapter.js.coffee +5 -0
  25. data/lib/generators/templates/adapter.js.em +3 -0
  26. data/lib/generators/templates/app.js +11 -0
  27. data/lib/generators/templates/app.js.coffee +11 -0
  28. data/lib/generators/templates/app.js.em +11 -0
  29. data/lib/generators/templates/application.hbs +3 -0
  30. data/lib/generators/templates/application.js +11 -0
  31. data/lib/generators/templates/application.js.coffee +11 -0
  32. data/lib/generators/templates/application.js.em +10 -0
  33. data/lib/generators/templates/application_adapter.js +5 -0
  34. data/lib/generators/templates/application_adapter.js.coffee +5 -0
  35. data/lib/generators/templates/application_adapter.js.em +3 -0
  36. data/lib/generators/templates/array_controller.js +5 -0
  37. data/lib/generators/templates/array_controller.js.coffee +5 -0
  38. data/lib/generators/templates/array_controller.js.em +3 -0
  39. data/lib/generators/templates/component.js +4 -0
  40. data/lib/generators/templates/component.js.coffee +6 -0
  41. data/lib/generators/templates/component.js.em +6 -0
  42. data/lib/generators/templates/component.template.hbs +2 -0
  43. data/lib/generators/templates/controller.js +5 -0
  44. data/lib/generators/templates/controller.js.coffee +6 -0
  45. data/lib/generators/templates/controller.js.em +3 -0
  46. data/lib/generators/templates/model.js +13 -0
  47. data/lib/generators/templates/model.js.coffee +12 -0
  48. data/lib/generators/templates/model.js.em +12 -0
  49. data/lib/generators/templates/object_controller.js +5 -0
  50. data/lib/generators/templates/object_controller.js.coffee +5 -0
  51. data/lib/generators/templates/object_controller.js.em +3 -0
  52. data/lib/generators/templates/route.js +5 -0
  53. data/lib/generators/templates/route.js.coffee +5 -0
  54. data/lib/generators/templates/route.js.em +3 -0
  55. data/lib/generators/templates/router.js +5 -0
  56. data/lib/generators/templates/router.js.coffee +5 -0
  57. data/lib/generators/templates/router.js.em +5 -0
  58. data/lib/generators/templates/template.hbs +5 -0
  59. data/lib/generators/templates/view.js +5 -0
  60. data/lib/generators/templates/view.js.coffee +4 -0
  61. data/lib/generators/templates/view.js.em +4 -0
  62. metadata +329 -0
@@ -0,0 +1,48 @@
1
+ require 'generators/ember/generator_helpers'
2
+
3
+ module Ember
4
+ module Generators
5
+ class ModelGenerator < ::Rails::Generators::NamedBase
6
+ include Ember::Generators::GeneratorHelpers
7
+
8
+ source_root File.expand_path("../../templates", __FILE__)
9
+ desc "creates a new ember.js model"
10
+ argument :attributes, :type => :array, :default => [], :banner => "field[:type] field[:type] ..."
11
+ class_option :javascript_engine, :desc => "engine for javascripts"
12
+ class_option :ember_path, :type => :string, :aliases => "-d", :desc => "custom ember app path"
13
+ class_option :app_name, :type => :string, :aliases => "-n", :desc => "Custom ember app name"
14
+
15
+ def create_model_files
16
+ file_path = File.join(ember_path, 'models', class_path, "#{file_name}.#{engine_extension}")
17
+ template "model.#{engine_extension}", file_path
18
+ end
19
+
20
+ private
21
+ EMBER_TYPE_LOOKUP = {
22
+ nil => 'string',
23
+ :binary => 'string',
24
+ :string => 'string',
25
+ :text => 'string',
26
+ :boolean => 'boolean',
27
+ :date => 'date',
28
+ :datetime =>'date',
29
+ :time => 'date',
30
+ :timestamp => 'date',
31
+ :decimal => 'number',
32
+ :float => 'number',
33
+ :integer => 'number',
34
+ :primary_key => 'number'
35
+ }
36
+
37
+ def parse_attributes!
38
+ self.attributes = (attributes || []).map do |attr|
39
+ name, type = attr.split(':')
40
+ key = type.try(:to_sym)
41
+ ember_type = EMBER_TYPE_LOOKUP[key] || type
42
+
43
+ { :name => name, :type => ember_type }
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,29 @@
1
+ require 'generators/ember/generator_helpers'
2
+
3
+ module Ember
4
+ module Generators
5
+ class ResourceGenerator < ::Rails::Generators::NamedBase
6
+ include Ember::Generators::GeneratorHelpers
7
+
8
+ source_root File.expand_path("../../templates", __FILE__)
9
+
10
+ desc "Creates a new Ember.js router, controller, view and template"
11
+
12
+ class_option :javascript_engine, :desc => "Engine for JavaScripts"
13
+ class_option :skip_route, :type => :boolean, :default => false, :desc => "Don't create route"
14
+ class_option :array, :type => :boolean, :default => false, :desc => "Create an Ember.ArrayController to represent multiple objects"
15
+ class_option :object, :type => :boolean, :default => false, :desc => "Create an Ember.Controller to represent a single object"
16
+ class_option :app_name, :type => :string, :aliases => "-n", :desc => "Custom ember app name"
17
+
18
+
19
+ def create_resource_files
20
+
21
+ invoke('ember:route', [ name ], options) unless options[:skip_route]
22
+ invoke('ember:controller', [ name ], options)
23
+ invoke('ember:view', [ name ], options)
24
+ invoke('ember:template', [ name ], options)
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,38 @@
1
+ require "rails/generators"
2
+ require "rails/generators/rails/resource/resource_generator"
3
+ require "generators/ember/controller_generator"
4
+ require "generators/ember/view_generator"
5
+
6
+ module Rails
7
+ module Generators
8
+ ResourceGenerator.class_eval do
9
+
10
+ class_option :javascript_engine, :desc => "Engine for JavaScripts"
11
+ class_option :ember_path, :type => :string, :aliases => "-d", :desc => "Custom ember app path"
12
+ class_option :with_template, :type => :boolean, :default => false, :desc => "Create template for this view"
13
+ class_option :app_name, :type => :string, :aliases => "-n", :desc => "Custom ember app name"
14
+
15
+ def add_ember
16
+ say_status :invoke, "ember:model", :white
17
+ with_padding do
18
+ invoke "ember:model"
19
+ end
20
+
21
+ say_status :invoke, "ember controller and view (singular)", :white
22
+ with_padding do
23
+ invoke "ember:view", [singular_name], options.merge(:object => true)
24
+ end
25
+
26
+ @_invocations[Ember::Generators::ControllerGenerator].delete "create_controller_files"
27
+ @_invocations[Ember::Generators::ViewGenerator].delete "create_view_files"
28
+
29
+ say_status :invoke, "ember controller and view (plural)", :white
30
+ with_padding do
31
+ invoke "ember:view", [plural_name], options.merge(:array => true)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+
@@ -0,0 +1,21 @@
1
+ require 'generators/ember/generator_helpers'
2
+
3
+ module Ember
4
+ module Generators
5
+ class RouteGenerator < ::Rails::Generators::NamedBase
6
+ include Ember::Generators::GeneratorHelpers
7
+
8
+ source_root File.expand_path("../../templates", __FILE__)
9
+
10
+ desc "Creates a new Ember.js route"
11
+ class_option :ember_path, :type => :string, :aliases => "-d", :desc => "Custom ember app path"
12
+ class_option :javascript_engine, :desc => "Engine for JavaScripts"
13
+ class_option :app_name, :type => :string, :aliases => "-n", :desc => "Custom ember app name"
14
+
15
+ def create_route_files
16
+ file_path = File.join(ember_path, 'routes', class_path, "#{file_name}_route.#{engine_extension}")
17
+ template "route.#{engine_extension}", file_path
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ require 'generators/ember/generator_helpers'
2
+
3
+ module Ember
4
+ module Generators
5
+ class ServiceGenerator < ::Rails::Generators::NamedBase
6
+ include Ember::Generators::GeneratorHelpers
7
+
8
+ source_root File.expand_path("../../templates", __FILE__)
9
+
10
+ desc "Creates a new Ember.js service"
11
+
12
+ class_option :javascript_engine, :desc => "Engine for JavaScripts"
13
+ class_option :ember_path, :type => :string, :aliases => "-d", :desc => "Custom ember app path"
14
+ class_option :app_name, :type => :string, :aliases => "-n", :desc => "Custom ember app name"
15
+
16
+ def create_service_files
17
+ file_path = File.join(ember_path, 'services', class_path, "#{file_name.dasherize}.#{engine_extension}")
18
+
19
+ template "service.#{engine_extension}", file_path
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ require 'generators/ember/generator_helpers'
2
+
3
+ module Ember
4
+ module Generators
5
+ class TemplateGenerator < ::Rails::Generators::NamedBase
6
+ include Ember::Generators::GeneratorHelpers
7
+
8
+ source_root File.expand_path("../../templates", __FILE__)
9
+
10
+ desc "Creates a new Ember.js template"
11
+ class_option :javascript_engine, :desc => "Engine for JavaScripts"
12
+ class_option :ember_path, :type => :string, :aliases => "-d", :desc => "Custom ember app path"
13
+
14
+
15
+
16
+ def create_template_files
17
+ file_path = File.join(ember_path, 'templates', class_path, "#{file_name}.hbs")
18
+ template 'template.hbs', file_path
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ require 'generators/ember/generator_helpers'
2
+
3
+ module Ember
4
+ module Generators
5
+ class ViewGenerator < ::Rails::Generators::NamedBase
6
+ include Ember::Generators::GeneratorHelpers
7
+
8
+ source_root File.expand_path("../../templates", __FILE__)
9
+
10
+ desc "Creates a new Ember.js view and associated Handlebars template"
11
+ class_option :javascript_engine, :desc => "Engine for JavaScripts"
12
+ class_option :ember_path, :type => :string, :aliases => "-d", :desc => "Custom ember app path"
13
+ class_option :with_template, :type => :boolean, :default => false, :desc => "Create template for this view"
14
+ class_option :app_name, :type => :string, :aliases => "-n", :desc => "Custom ember app name"
15
+
16
+ def create_view_files
17
+ file_path = File.join(ember_path, 'views', class_path, "#{file_name}_view.#{engine_extension}")
18
+ template "view.#{engine_extension}", file_path
19
+ invoke('ember:template', [ name ], options) if options[:with_template]
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ // For more information see: http://emberjs.com/guides/models/customizing-adapters/
2
+
3
+ <%= application_name.camelize %>.<%= class_name.camelize %>Adapter = DS.ActiveModelAdapter.extend({
4
+
5
+ });
@@ -0,0 +1,5 @@
1
+ # For more information see: http://emberjs.com/guides/models/customizing-adapters/
2
+
3
+ <%= application_name.camelize %>.<%= class_name.camelize %>Adapter = DS.ActiveModelAdapter.extend({
4
+
5
+ })
@@ -0,0 +1,3 @@
1
+ # For more information see: http://emberjs.com/guides/models/customizing-adapters/
2
+
3
+ class <%= application_name.camelize %>.<%= class_name.camelize %>Adapter extends DS.ActiveModelAdapter
@@ -0,0 +1,11 @@
1
+ //= require_tree ./adapters
2
+ //= require_tree ./mixins
3
+ //= require_tree ./models
4
+ //= require_tree ./controllers
5
+ //= require_tree ./views
6
+ //= require_tree ./helpers
7
+ //= require_tree ./components
8
+ //= require_tree ./templates
9
+ //= require_tree ./routes
10
+ //= require ./router
11
+ //= require_self
@@ -0,0 +1,11 @@
1
+ #= require_tree ./adapters
2
+ #= require_tree ./mixins
3
+ #= require_tree ./models
4
+ #= require_tree ./controllers
5
+ #= require_tree ./views
6
+ #= require_tree ./helpers
7
+ #= require_tree ./components
8
+ #= require_tree ./templates
9
+ #= require_tree ./routes
10
+ #= require ./router
11
+ #= require_self
@@ -0,0 +1,11 @@
1
+ #= require_tree ./adapters
2
+ #= require_tree ./mixins
3
+ #= require_tree ./models
4
+ #= require_tree ./controllers
5
+ #= require_tree ./views
6
+ #= require_tree ./helpers
7
+ #= require_tree ./components
8
+ #= require_tree ./templates
9
+ #= require_tree ./routes
10
+ #= require ./router
11
+ #= require_self
@@ -0,0 +1,3 @@
1
+ <h1><%= application_name %></h1>
2
+
3
+ {{outlet}}
@@ -0,0 +1,11 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ <%= "//= require handlebars\n" if ::Rails.configuration.handlebars.ember_template == 'Handlebars' -%>
4
+ //= require ember
5
+ //= require ember-data
6
+ //= require_self
7
+ //= require ./<%= application_name.underscore %>
8
+
9
+ // for more details see: http://emberjs.com/guides/application/
10
+ <%= application_name.camelize %> = Ember.Application.create();
11
+
@@ -0,0 +1,11 @@
1
+ #= require jquery
2
+ #= require jquery_ujs
3
+ <%= "#= require handlebars\n" if ::Rails.configuration.handlebars.ember_template == 'Handlebars' -%>
4
+ #= require ember
5
+ #= require ember-data
6
+ #= require_self
7
+ #= require <%= application_name.underscore %>
8
+
9
+ # for more details see: http://emberjs.com/guides/application/
10
+ window.<%= application_name.camelize %> = Ember.Application.create()
11
+
@@ -0,0 +1,10 @@
1
+ #= require jquery
2
+ #= require jquery_ujs
3
+ <%= "#= require handlebars\n" if ::Rails.configuration.handlebars.ember_template == 'Handlebars' -%>
4
+ #= require ember
5
+ #= require ember-data
6
+ #= require_self
7
+ #= require <%= application_name.underscore %>
8
+
9
+ # for more details see: http://emberjs.com/guides/application/
10
+ window.<%= application_name.camelize %> = Ember.Application.create()
@@ -0,0 +1,5 @@
1
+ // Override the default adapter with the `DS.ActiveModelAdapter` which
2
+ // is built to work nicely with the ActiveModel::Serializers gem.
3
+ <%= application_name.camelize %>.ApplicationAdapter = DS.ActiveModelAdapter.extend({
4
+
5
+ });
@@ -0,0 +1,5 @@
1
+ # Override the default adapter with the `DS.ActiveModelAdapter` which
2
+
3
+ <%= application_name.camelize %>.ApplicationAdapter = DS.ActiveModelAdapter.extend({
4
+
5
+ })
@@ -0,0 +1,3 @@
1
+ # Override the default adapter with the `DS.ActiveModelAdapter` which
2
+ # is built to work nicely with the ActiveModel::Serializers gem.
3
+ class <%= application_name.camelize %>.ApplicationAdapter extends DS.ActiveModelAdapter
@@ -0,0 +1,5 @@
1
+ // for more details see: http://emberjs.com/guides/controllers/representing-multiple-models-with-arraycontroller/
2
+
3
+ <%= application_name.camelize %>.<%= class_name %>Controller = Ember.ArrayController.extend({
4
+
5
+ });
@@ -0,0 +1,5 @@
1
+ # for more details see: http://emberjs.com/guides/controllers/
2
+
3
+ <%= application_name.camelize %>.<%= class_name %>Controller = Ember.ArrayController.extend({
4
+
5
+ })
@@ -0,0 +1,3 @@
1
+ # for more details see: http://emberjs.com/guides/controllers/
2
+
3
+ class <%= application_name.camelize %>.<%= class_name %>Controller extends Ember.ArrayController
@@ -0,0 +1,4 @@
1
+ // for more details see: http://emberjs.com/guides/components/
2
+
3
+ <%= application_name.camelize %>.<%= class_name %>Component = Ember.Component.extend({
4
+ });
@@ -0,0 +1,6 @@
1
+ # for more details see: http://emberjs.com/guides/components/
2
+
3
+ <%= application_name.camelize %>.<%= class_name %>Component = Ember.Component.extend({
4
+
5
+ })
6
+
@@ -0,0 +1,6 @@
1
+ # for more details see: http://emberjs.com/guides/components/
2
+
3
+ <%= application_name.camelize %>.<%= class_name %>Component = Ember.Component.extend({
4
+
5
+ })
6
+
@@ -0,0 +1,2 @@
1
+ <div>
2
+ </div>
@@ -0,0 +1,5 @@
1
+ // for more details see: http://emberjs.com/guides/controllers/
2
+
3
+ <%= application_name.camelize %>.<%= class_name %>Controller = Ember.Controller.extend({
4
+
5
+ });
@@ -0,0 +1,6 @@
1
+ # for more details see: http://emberjs.com/guides/controllers/
2
+
3
+ <%= application_name.camelize %>.<%= class_name %>Controller = Ember.Controller.extend({
4
+
5
+ })
6
+
@@ -0,0 +1,3 @@
1
+ # for more details see: http://emberjs.com/guides/controllers/
2
+
3
+ class <%= application_name.camelize %>.<%= class_name %>Controller extends Ember.Controller
@@ -0,0 +1,13 @@
1
+ // for more details see: http://emberjs.com/guides/models/defining-models/
2
+
3
+ <%= application_name.camelize %>.<%= class_name %> = DS.Model.extend({
4
+ <% attributes.each_with_index do |attribute, idx| -%>
5
+ <%= attribute[:name].camelize(:lower) %>: <%=
6
+ if %w(references belongs_to).member?(attribute[:type])
7
+ "DS.belongsTo('%s')" % attribute[:name].camelize(:lower)
8
+ else
9
+ "DS.attr('%s')" % attribute[:type]
10
+ end
11
+ %><% if (idx < attributes.length-1) %>,<% end %>
12
+ <% end -%>
13
+ });
@@ -0,0 +1,12 @@
1
+ # for more details see: http://emberjs.com/guides/models/defining-models/
2
+
3
+ <%= application_name.camelize %>.<%= class_name %> = DS.Model.extend<%= "()" if attributes.length == 0 %>
4
+ <% attributes.each do |attribute| -%>
5
+ <%= attribute[:name].camelize(:lower) %>: <%=
6
+ if %w(references belongs_to).member?(attribute[:type])
7
+ "DS.belongsTo '%s'" % attribute[:name].camelize(:lower)
8
+ else
9
+ "DS.attr '%s'" % attribute[:type]
10
+ end
11
+ %>
12
+ <% end -%>
@@ -0,0 +1,12 @@
1
+ # for more details see: http://emberjs.com/guides/models/defining-models/
2
+
3
+ class <%= application_name.camelize %>.<%= class_name %> extends DS.Model
4
+ <% attributes.each do |attribute| -%>
5
+ <%= attribute[:name].camelize(:lower) %>: <%=
6
+ if %w(references belongs_to).member?(attribute[:type])
7
+ "DS.belongsTo '%s'" % attribute[:name].camelize(:lower)
8
+ else
9
+ "DS.attr '%s'" % attribute[:type]
10
+ end
11
+ %>
12
+ <% end -%>
@@ -0,0 +1,5 @@
1
+ // for more details see: http://emberjs.com/guides/controllers/
2
+
3
+ <%= application_name.camelize %>.<%= class_name %>Controller = Ember.Controller.extend({
4
+
5
+ });