ember-rails-lite 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/README.md +54 -15
  2. data/lib/ember/rails/engine.rb +5 -10
  3. data/lib/ember/rails/version.rb +1 -1
  4. data/lib/ember_rails.rb +0 -1
  5. data/lib/generators/ember/bootstrap_generator.rb +16 -30
  6. data/lib/generators/ember/controller_generator.rb +10 -5
  7. data/lib/generators/ember/generator_helpers.rb +12 -0
  8. data/lib/generators/ember/install_generator.rb +20 -73
  9. data/lib/generators/ember/model_generator.rb +17 -18
  10. data/lib/generators/ember/resource_generator.rb +28 -0
  11. data/lib/generators/ember/route_generator.rb +3 -3
  12. data/lib/generators/ember/template_generator.rb +20 -0
  13. data/lib/generators/ember/view_generator.rb +5 -7
  14. data/lib/generators/templates/app.js.coffee +9 -0
  15. data/lib/generators/templates/application.js +9 -0
  16. data/lib/generators/templates/application.js.coffee +9 -0
  17. data/lib/generators/templates/array_controller.js +2 -0
  18. data/lib/generators/templates/array_controller.js.coffee +5 -0
  19. data/lib/generators/templates/controller.js +2 -0
  20. data/lib/generators/templates/controller.js.coffee +6 -0
  21. data/lib/generators/templates/model.js +3 -1
  22. data/lib/generators/templates/model.js.coffee +12 -0
  23. data/lib/generators/templates/object_controller.js +2 -0
  24. data/lib/generators/templates/object_controller.js.coffee +5 -0
  25. data/lib/generators/templates/route.js +3 -1
  26. data/lib/generators/templates/route.js.coffee +5 -0
  27. data/lib/generators/templates/router.js +3 -1
  28. data/lib/generators/templates/router.js.coffee +5 -0
  29. data/lib/generators/templates/store.js +4 -1
  30. data/lib/generators/templates/store.js.coffee +6 -0
  31. data/lib/generators/templates/{view.handlebars → template.handlebars} +0 -0
  32. data/lib/generators/templates/view.js +3 -0
  33. data/lib/generators/templates/view.js.coffee +4 -0
  34. metadata +65 -13
  35. data/lib/ember-rails-lite.rb +0 -1
  36. data/lib/ember/version.rb +0 -3
data/README.md CHANGED
@@ -7,19 +7,49 @@ The gem will also pre-compile your handlebars templates when building your asset
7
7
  You can see an example of how to use the gem [here](https://github.com/keithpitt/ember-rails-example). There is also a great tutorial by [Dan Gebhardt](https://twitter.com/#!/dgeb) called "[Beginning Ember.js on Rails](http://www.cerebris.com/blog/2012/01/24/beginning-ember-js-on-rails-part-1/)" which is a great read if you're just starting out with Rails and Ember.js
8
8
 
9
9
  ## Getting started
10
+ 1. Add the gem to your application Gemfile:
11
+ ```ruby
12
+ gem 'ember-rails'
13
+ gem 'ember-source', '1.0.0.rc4' # or the version you need
14
+ gem 'handlebars-source', '1.0.0.rc4' # or the version you need
15
+ ```
10
16
 
11
- Add the gem to your application Gemfile:
17
+ 2. Run `bundle install`
12
18
 
13
- gem "ember-rails"
19
+ 3. [Optional] Configure the ember variant in your environment files (i.e. development.rb, production.rb). If you don't configure this, the version of Ember used defaults to development when the Rails environment is development, and similarly for production.
20
+ ```ruby
21
+ config.ember.variant = :development # or :production
22
+ ```
14
23
 
15
- Run `bundle install` and use the ember-rails generator to add the necessary dependencies.
24
+ 4. Next, generate the application structure:
25
+ ```shell
26
+ bundle exec rails generate ember:bootstrap
27
+ ```
16
28
 
17
- Ember-rails will use the production build of Ember.js when Rails is running in
18
- production mode, and the development build otherwise.
29
+ 5. Restart your server (if it's running)
30
+
31
+
32
+ Notes:
33
+
34
+ To install the latest builds of ember and ember-data:
35
+ ```shell
36
+ bundle exec rails generate ember:install --head
37
+ ```
38
+
39
+ ## For CoffeeScript support
40
+ 1. Add coffee-rails to the Gemfile
41
+ ```ruby
42
+ gem 'coffee-rails'
43
+ ```
44
+
45
+ 2. Run the bootstrap generator in step 4 with an extra flag instead:
46
+ ```sh
47
+ rails g ember:bootstrap -g --javascript-engine coffee
48
+ ```
19
49
 
20
50
  ## Architecture
21
51
 
22
- Ember does not require an organized file structure. However, ember-rails allows you
52
+ Ember does not require an organized file structure. However, ember-rails allows you
23
53
  to use `rails g ember:bootstrap` to create the following directory structure under `app/assets/javascripts`:
24
54
 
25
55
  controllers/
@@ -30,7 +60,7 @@ to use `rails g ember:bootstrap` to create the following directory structure und
30
60
  views/
31
61
 
32
62
  Additionally, it will add the following lines to `app/assets/javascripts/application.js`.
33
- By default, it uses the Rails Application's name and creates an `rails_app_name.js`
63
+ By default, it uses the Rails Application's name and creates an `rails_app_name.js`
34
64
  file to setup application namespace and initial requires:
35
65
 
36
66
  //= require handlebars
@@ -80,7 +110,7 @@ Default behavior for ember-rails is to precompile handlebars templates.
80
110
  If you don't want this behavior you can turn it off in your application configuration (or per environment in: `config/environments/development.rb`) block:
81
111
 
82
112
  config.handlebars.precompile = false
83
-
113
+
84
114
  _(Note: you must clear the local sprockets cache if you disable precompilation, stored by default in `tmp/cache/assets`)_
85
115
 
86
116
  Bundle all templates together thanks to Sprockets,
@@ -95,20 +125,21 @@ Now a single line in the layout loads everything:
95
125
  If you use Slim or Haml templates, you can use handlebars filter :
96
126
 
97
127
  handlebars:
98
- {{#view Ember.Button}}OK{{/view}}
128
+ <button {{action anActionName}}>OK</button>
99
129
 
100
130
  It will be translated as :
101
131
 
102
132
  <script type="text/x-handlebars">
103
- {{#view Ember.Button}}OK{{/view}}
133
+ <button {{action anActionName}}>OK</button>
104
134
  </script>
105
135
 
106
136
  ## Specifying Different Versions of Ember/Handlebars/Ember-Data
107
137
 
108
- By default, ember-rails ships with the latest version of
109
- [Ember](https://rubygems.org/gems/ember-source/versions) (rc1),
110
- [Handlebars](https://rubygems.org/gems/handlebars-source/versions) (rc3),
111
- and [Ember-Data](https://rubygems.org/gems/ember-data-source/versions).
138
+ ![Ember Data Warning](ember-data-in-progress.png)
139
+ By default, ember-rails ships with the latest version of
140
+ [Ember](https://rubygems.org/gems/ember-source/versions),
141
+ [Handlebars](https://rubygems.org/gems/handlebars-source/versions),
142
+ and [Ember-Data](https://rubygems.org/gems/ember-data-source/versions).
112
143
 
113
144
  To specify a different version that'll be used for both template
114
145
  precompilation and serving to the browser, you can specify the desired
@@ -119,7 +150,7 @@ version of one of the above-linked gems in the Gemfile, e.g.:
119
150
  You can also specify versions of 'handlebars-source' and
120
151
  'ember-data-source', but note that an appropriate 'handlebars-source'
121
152
  will be automatically chosen depending on the version of 'ember-source'
122
- that's specified.
153
+ that's specified.
123
154
 
124
155
  You can also override the specific ember.js, handlebars.js, and
125
156
  ember-data.js files that'll be `require`d by the Asset pipeline by
@@ -130,6 +161,14 @@ you've specified in your app's configuration, e.g.:
130
161
  config.ember.variant = :production
131
162
  #config.ember.variant = :development
132
163
 
164
+ ## Updating Ember
165
+
166
+ If at any point you need to update Ember.js from master, you can do that with
167
+
168
+ rails generate ember:install --head
169
+
170
+ This will fetch both Ember.js and Ember Data from [http://builds.emberjs.com/](http://builds.emberjs.com/) and copy to the right directory.
171
+
133
172
  ## Note on Patches/Pull Requests
134
173
 
135
174
  1. Fork the project.
@@ -9,16 +9,11 @@ module Ember
9
9
  config.handlebars.templates_root = "templates"
10
10
  config.handlebars.templates_path_separator = '/'
11
11
 
12
- initializer "ember_rails.setup", :after => :append_assets_path, :group => :all do |app|
13
- sprockets = if ::Rails::VERSION::MAJOR == 4
14
- Sprockets.respond_to?('register_engine') ? Sprockets : app.assets
15
- else
16
- app.assets
17
- end
18
-
19
- sprockets.register_engine '.handlebars', Ember::Handlebars::Template
20
- sprockets.register_engine '.hbs', Ember::Handlebars::Template
21
- sprockets.register_engine '.hjs', Ember::Handlebars::Template
12
+ config.before_initialize do |app|
13
+ Sprockets::Engines #force autoloading
14
+ Sprockets.register_engine '.handlebars', Ember::Handlebars::Template
15
+ Sprockets.register_engine '.hbs', Ember::Handlebars::Template
16
+ Sprockets.register_engine '.hjs', Ember::Handlebars::Template
22
17
  end
23
18
  end
24
19
  end
@@ -1,5 +1,5 @@
1
1
  module Ember
2
2
  module Rails
3
- VERSION = '0.11.1'
3
+ VERSION = '0.12.0'
4
4
  end
5
5
  end
@@ -1,6 +1,5 @@
1
1
  require 'rails'
2
2
  require 'ember/rails/version'
3
- require 'ember/version'
4
3
  require 'ember/rails/engine'
5
4
  require 'ember/source'
6
5
  require 'ember/data/source'
@@ -1,4 +1,3 @@
1
- require 'ember/version'
2
1
  require 'generators/ember/generator_helpers'
3
2
 
4
3
  module Ember
@@ -12,35 +11,16 @@ module Ember
12
11
 
13
12
  class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
14
13
  class_option :skip_git, :type => :boolean, :aliases => "-g", :default => false, :desc => "Skip Git keeps"
15
- class_option :skip_ams, :type => :boolean, :aliases => "-a", :default => false, :desc => "Skip ActiveModelSerializers"
14
+ class_option :javascript_engine, :desc => "Engine for JavaScripts"
16
15
 
17
16
  def inject_ember
18
- application_file = "app/assets/javascripts/application.js"
19
-
20
- inject_into_file(application_file, :before => "//= require_tree") do
21
- dependencies = [
22
- # this should eventually become handlebars-runtime when we remove
23
- # the runtime dependency on compilation
24
- "//= require handlebars",
25
- "//= require ember",
26
- "//= require ember-data",
27
- "//= require_self",
28
- "//= require #{application_name.underscore}",
29
- "#{application_name.camelize} = Ember.Application.create();"
30
- ]
31
- dependencies.join("\n").concat("\n")
17
+ begin
18
+ inject_into_application_file(engine_extension)
19
+ rescue Exception => e
20
+ inject_into_application_file('js')
32
21
  end
33
22
  end
34
23
 
35
- def inject_ams
36
- return if options[:skip_ams]
37
- gem_file = ENV['BUNDLE_GEMFILE'] || 'Gemfile'
38
- append_to_file(gem_file, "\n" + [
39
- '# Learn how to build an Ember-compatible Rails API at',
40
- '# https://github.com/rails-api/active_model_serializers',
41
- 'gem "active_model_serializers"'
42
- ].join("\n"))
43
- end
44
24
 
45
25
  def create_dir_layout
46
26
  %W{models controllers views routes helpers templates}.each do |dir|
@@ -50,19 +30,25 @@ module Ember
50
30
  end
51
31
 
52
32
  def create_app_file
53
- template "app.js", "#{ember_path}/#{application_name.underscore}.js"
33
+ template "app.#{engine_extension}", "#{ember_path}/#{application_name.underscore}.#{engine_extension}"
54
34
  end
55
35
 
56
36
  def create_router_file
57
- template "router.js", "#{ember_path}/router.js"
37
+ template "router.#{engine_extension}", "#{ember_path}/router.#{engine_extension}"
58
38
  end
59
39
 
60
40
  def create_store_file
61
- template "store.js", "#{ember_path}/store.js"
41
+ template "store.#{engine_extension}", "#{ember_path}/store.#{engine_extension}"
62
42
  end
63
43
 
64
- def create_app_stubs
65
- invoke "ember:view", ["application", "-d #{ember_path}"]
44
+ private
45
+ def inject_into_application_file(safe_extension)
46
+ application_file = "#{ember_path}/application.#{safe_extension}"
47
+ inject_into_file( application_file, :before => /^.*require_tree.*$/) do
48
+ context = instance_eval('binding')
49
+ source = File.expand_path(find_in_source_paths("application.#{safe_extension}"))
50
+ ERB.new(::File.binread(source), nil, '-', '@output_buffer').result(context)
51
+ end
66
52
  end
67
53
  end
68
54
  end
@@ -1,4 +1,3 @@
1
- require 'ember/version'
2
1
  require 'generators/ember/generator_helpers'
3
2
 
4
3
  module Ember
@@ -9,20 +8,26 @@ module Ember
9
8
  source_root File.expand_path("../../templates", __FILE__)
10
9
 
11
10
  desc "Creates a new Ember.js controller"
11
+
12
+ class_option :javascript_engine, :desc => "Engine for JavaScripts"
12
13
  class_option :array, :type => :boolean, :default => false, :desc => "Create an Ember.ArrayController to represent multiple objects"
13
14
  class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
14
15
  class_option :object, :type => :boolean, :default => false, :desc => "Create an Ember.ObjectController to represent a single object"
15
16
 
17
+
16
18
  def create_controller_files
17
- file_path = File.join(ember_path, 'controllers', class_path, "#{file_name}_controller.js")
19
+ file_path = File.join(ember_path, 'controllers', class_path, "#{file_name}_controller.#{engine_extension}")
20
+
18
21
  if options.array?
19
- template 'array_controller.js', file_path
22
+ template "array_controller.#{engine_extension}", file_path
20
23
  elsif options.object?
21
- template 'object_controller.js', file_path
24
+ template "object_controller.#{engine_extension}", file_path
22
25
  else
23
- template 'controller.js', file_path
26
+ template "controller.#{engine_extension}", file_path
24
27
  end
25
28
  end
29
+
30
+
26
31
  end
27
32
  end
28
33
  end
@@ -14,6 +14,18 @@ module Ember
14
14
  end
15
15
  end
16
16
 
17
+
18
+ def class_name
19
+ (class_path + [file_name]).map!{ |m| m.camelize }.join()
20
+ end
21
+
22
+ def handlebars_template_path
23
+ File.join(class_path, file_name).gsub(/^\//, '')
24
+ end
25
+
26
+ def engine_extension
27
+ @engine_extension ||= "js.#{options[:javascript_engine]}".sub('js.js','js')
28
+ end
17
29
  end
18
30
  end
19
31
  end
@@ -1,95 +1,42 @@
1
- require 'ember/version'
2
1
  require 'generators/ember/generator_helpers'
2
+ require 'net/http'
3
+ require 'uri'
4
+ require 'fileutils'
3
5
 
4
6
  module Ember
5
7
  module Generators
6
8
  class InstallGenerator < ::Rails::Generators::Base
7
9
  desc "Install Ember.js into your vendor folder"
8
- class_option :head, :type => :boolean, :default => false, :desc => "Download latest Ember.js from GitHub and copy it into your project"
10
+ class_option :head, :type => :boolean, :default => false, :desc => "Download latest Ember.js from GitHub and fetch it into your project"
9
11
 
10
- def copy_ember
12
+ def fetch_ember
11
13
  if options.head?
12
-
13
- git_root = File.expand_path "~/.ember"
14
- gem_file = File.join git_root, "Gemfile"
15
-
16
- # If it doesn't exist yet
17
- unless File.exist?(git_root)
18
- command = %{git clone git://github.com/emberjs/ember.js.git "#{git_root}"}
19
- say_status("downloading", command, :green)
20
-
21
- cmd command
22
- else
23
- Dir.chdir git_root do
24
- command = "git fetch origin && git reset origin/master --hard"
25
- say_status("updating", command, :green)
26
-
27
- cmd command
28
- end
29
- end
30
-
31
- Dir.chdir git_root do
32
- say_status("building", "bundle && bundle exec rake clean dist", :green)
33
- Bundler.with_clean_env do
34
- cmd "bundle --gemfile #{gem_file}"
35
- cmd %{BUNDLE_GEMFILE="#{gem_file}" bundle exec rake clean dist}
36
- end
37
- end
38
-
39
- source_paths << File.join(git_root, "dist")
40
-
41
- copy_file "ember.js", "vendor/assets/ember/development/ember.js"
42
- copy_file "ember.min.js", "vendor/assets/ember/production/ember.js"
14
+ fetch 'http://builds.emberjs.com/ember-latest.js', 'vendor/assets/ember/development/ember.js'
15
+ fetch 'http://builds.emberjs.com/ember-latest.min.js', 'vendor/assets/ember/production/ember.js'
43
16
  end
44
17
  end
45
18
 
46
- def copy_ember_data
19
+ def fetch_ember_data
47
20
  if options.head?
48
-
49
- git_root = File.expand_path "~/.ember-data"
50
- gem_file = File.join git_root, "Gemfile"
51
-
52
- # If it doesn't exist yet
53
- unless File.exist?(git_root)
54
- command = %{git clone git://github.com/emberjs/data.git "#{git_root}"}
55
- say_status("downloading", command, :green)
56
-
57
- cmd command
58
- else
59
- Dir.chdir git_root do
60
- command = "git fetch origin && git reset origin/master --hard"
61
- say_status("updating", command, :green)
62
-
63
- cmd command
64
- end
65
- end
66
-
67
- Dir.chdir git_root do
68
- say_status("building", "bundle && bundle exec rake clean dist", :green)
69
- Bundler.with_clean_env do
70
- cmd "bundle --gemfile #{gem_file}"
71
- cmd %{BUNDLE_GEMFILE="#{gem_file}" bundle exec rake clean dist}
72
- end
73
- end
74
-
75
- source_paths << File.join(git_root, "dist")
76
-
77
- copy_file "ember-data.js", "vendor/assets/ember/development/ember-data.js"
78
- copy_file "ember-data.min.js", "vendor/assets/ember/production/ember-data.js"
21
+ fetch 'http://builds.emberjs.com/ember-data-latest.js', 'vendor/assets/ember/development/ember-data.js'
22
+ fetch 'http://builds.emberjs.com/ember-data-latest.min.js', 'vendor/assets/ember/production/ember-data.js'
79
23
  end
80
24
  end
81
25
 
82
- private
26
+ private
27
+
28
+ def fetch(from, to)
29
+ message = "#{from} -> #{to}"
30
+ say_status("downloading:", message , :green)
83
31
 
84
- def cmd(command)
85
- out = `#{command}`
32
+ uri = URI(from)
86
33
 
87
- if $?.exitstatus != 0
88
- raise "Command error: command `#{command}` in directory #{Dir.pwd} has failed."
34
+ FileUtils.mkdir_p File.dirname(to)
35
+
36
+ open(to, 'w+') do |output|
37
+ output.puts Net::HTTP.get(uri).force_encoding("UTF-8")
89
38
  end
90
- out
91
39
  end
92
-
93
40
  end
94
41
  end
95
42
  end
@@ -1,4 +1,3 @@
1
- require 'ember/version'
2
1
  require 'generators/ember/generator_helpers'
3
2
 
4
3
  module Ember
@@ -7,30 +6,30 @@ module Ember
7
6
  include Ember::Generators::GeneratorHelpers
8
7
 
9
8
  source_root File.expand_path("../../templates", __FILE__)
9
+ desc "creates a new ember.js model"
10
10
  argument :attributes, :type => :array, :default => [], :banner => "field[:type] field[:type] ..."
11
-
12
- desc "Creates a new Ember.js model"
13
- class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
11
+ class_option :javascript_engine, :desc => "engine for javascripts"
12
+ class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "custom ember app path"
14
13
 
15
14
  def create_model_files
16
- template 'model.js', File.join(ember_path, 'models', class_path, "#{file_name}.js")
15
+ file_path = File.join(ember_path, 'models', class_path, "#{file_name}.#{engine_extension}")
16
+ template "model.#{engine_extension}", file_path
17
17
  end
18
18
 
19
19
  private
20
20
  EMBER_TYPE_LOOKUP = {
21
- nil => 'string',
22
-
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',
21
+ nil => 'string',
22
+ :binary => 'string',
23
+ :string => 'string',
24
+ :text => 'string',
25
+ :boolean => 'boolean',
26
+ :date => 'date',
27
+ :datetime =>'date',
28
+ :time => 'date',
29
+ :timestamp => 'date',
30
+ :decimal => 'number',
31
+ :float => 'number',
32
+ :integer => 'number',
34
33
  :primary_key => 'number'
35
34
  }
36
35
 
@@ -0,0 +1,28 @@
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.ObjectController to represent a single object"
16
+
17
+
18
+ def create_resource_files
19
+
20
+ invoke('ember:route', [ name ], options) unless options[:skip_route]
21
+ invoke('ember:controller', [ name ], options)
22
+ invoke('ember:view', [ name ], options)
23
+ invoke('ember:template', [ name ], options)
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -1,4 +1,3 @@
1
- require 'ember/version'
2
1
  require 'generators/ember/generator_helpers'
3
2
 
4
3
  module Ember
@@ -10,10 +9,11 @@ module Ember
10
9
 
11
10
  desc "Creates a new Ember.js route"
12
11
  class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
12
+ class_option :javascript_engine, :desc => "Engine for JavaScripts"
13
13
 
14
14
  def create_route_files
15
- file_path = File.join(ember_path, 'routes', class_path, "#{file_name}_route.js")
16
- template 'route.js', file_path
15
+ file_path = File.join(ember_path, 'routes', class_path, "#{file_name}_route.#{engine_extension}")
16
+ template "route.#{engine_extension}", file_path
17
17
  end
18
18
  end
19
19
  end
@@ -0,0 +1,20 @@
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
+
13
+
14
+ def create_template_files
15
+ template 'template.handlebars', File.join('app/assets/javascripts/templates', class_path, "#{file_name}.handlebars")
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -1,4 +1,3 @@
1
- require 'ember/version'
2
1
  require 'generators/ember/generator_helpers'
3
2
 
4
3
  module Ember
@@ -9,15 +8,14 @@ module Ember
9
8
  source_root File.expand_path("../../templates", __FILE__)
10
9
 
11
10
  desc "Creates a new Ember.js view and associated Handlebars template"
12
- class_option :array, :type => :boolean, :default => false, :desc => "Create an Ember.ArrayController to represent multiple objects"
11
+ class_option :javascript_engine, :desc => "Engine for JavaScripts"
13
12
  class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
14
- class_option :object, :type => :boolean, :default => false, :desc => "Create an Ember.ObjectController to represent a single object"
13
+ class_option :with_template, :type => :boolean, :default => false, :desc => "Create template for this view"
15
14
 
16
15
  def create_view_files
17
- template 'view.js', File.join(ember_path, 'views', class_path, "#{file_name}_view.js")
18
- template 'view.handlebars', File.join(ember_path, 'templates', class_path, "#{file_name}.handlebars")
19
- invoke('ember:controller', [ file_name ], options)
20
- invoke('ember:route', [ file_name ], options)
16
+ file_path = File.join(ember_path, 'views', class_path, "#{file_name}_view.#{engine_extension}")
17
+ template "view.#{engine_extension}", file_path
18
+ invoke('ember:template', [ name ], options) if options[:with_template]
21
19
  end
22
20
 
23
21
  end
@@ -0,0 +1,9 @@
1
+ #= require ./store
2
+ #= require_tree ./models
3
+ #= require_tree ./controllers
4
+ #= require_tree ./views
5
+ #= require_tree ./helpers
6
+ #= require_tree ./templates
7
+ #= require_tree ./routes
8
+ #= require ./router
9
+ #= require_self
@@ -0,0 +1,9 @@
1
+ //= require handlebars
2
+ //= require ember
3
+ //= require ember-data
4
+ //= require_self
5
+ //= require <%= application_name.underscore %>
6
+
7
+ // for more details see: http://emberjs.com/guides/application/
8
+ <%= application_name.camelize %> = Ember.Application.create();
9
+
@@ -0,0 +1,9 @@
1
+ #= require handlebars
2
+ #= require ember
3
+ #= require ember-data
4
+ #= require_self
5
+ #= require <%= application_name.underscore %>
6
+
7
+ # for more details see: http://emberjs.com/guides/application/
8
+ window.<%= application_name.camelize %> = Ember.Application.create()
9
+
@@ -1,3 +1,5 @@
1
+ // for more details see: http://emberjs.com/guides/controllers/
2
+
1
3
  <%= application_name.camelize %>.<%= class_name %>Controller = Ember.ArrayController.extend({
2
4
 
3
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
+ })
@@ -1,3 +1,5 @@
1
+ // for more details see: http://emberjs.com/guides/controllers/
2
+
1
3
  <%= application_name.camelize %>.<%= class_name %>Controller = Ember.Controller.extend({
2
4
 
3
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
+
@@ -1,3 +1,5 @@
1
+ // for more details see: http://emberjs.com/guides/models/defining-models/
2
+
1
3
  <%= application_name.camelize %>.<%= class_name %> = DS.Model.extend({
2
4
  <% attributes.each_with_index do |attribute, idx| -%>
3
5
  <%= attribute[:name].camelize(:lower) %>: <%=
@@ -8,4 +10,4 @@
8
10
  end
9
11
  %><% if (idx < attributes.length-1) %>,<% end %>
10
12
  <% end -%>
11
- });
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.%s'" % [application_name.camelize, attribute[:name].camelize]
8
+ else
9
+ "DS.attr '%s'" % attribute[:type]
10
+ end
11
+ %>
12
+ <% end -%>
@@ -1,3 +1,5 @@
1
+ // for more details see: http://emberjs.com/guides/controllers/
2
+
1
3
  <%= application_name.camelize %>.<%= class_name %>Controller = Ember.ObjectController.extend({
2
4
 
3
5
  });
@@ -0,0 +1,5 @@
1
+ # for more details see: http://emberjs.com/guides/controllers/
2
+
3
+ <%= application_name.camelize %>.<%= class_name %>Controller = Ember.ObjectController.extend({
4
+
5
+ })
@@ -1,3 +1,5 @@
1
- <%= application_name.camelize %>.<%= class_name %>Route = Ember.Route.extend({
1
+ // For more information see: http://emberjs.com/guides/routing/
2
+
3
+ <%= application_name.camelize %>.<%= class_name.camelize %>Route = Ember.Route.extend({
2
4
 
3
5
  });
@@ -0,0 +1,5 @@
1
+ # For more information see: http://emberjs.com/guides/routing/
2
+
3
+ <%= application_name.camelize %>.<%= class_name.camelize %>Route = Ember.Route.extend({
4
+
5
+ })
@@ -1,3 +1,5 @@
1
- <%= application_name.camelize %>.Router.map(function() {
1
+ // For more information see: http://emberjs.com/guides/routing/
2
2
 
3
+ <%= application_name.camelize %>.Router.map(function() {
4
+ // this.resource('posts');
3
5
  });
@@ -0,0 +1,5 @@
1
+ # For more information see: http://emberjs.com/guides/routing/
2
+
3
+ <%= application_name.camelize %>.Router.map ()->
4
+ # @resource('posts')
5
+
@@ -1,3 +1,6 @@
1
+ // http://emberjs.com/guides/models/defining-a-store/
2
+
1
3
  <%= application_name.camelize %>.Store = DS.Store.extend({
2
- revision: 11
4
+ revision: 11,
5
+ adapter: DS.RESTAdapter.create()
3
6
  });
@@ -0,0 +1,6 @@
1
+ # http://emberjs.com/guides/models/defining-a-store/
2
+
3
+ <%= application_name.camelize %>.Store = DS.Store.extend
4
+ revision: 11
5
+ adapter: DS.RESTAdapter.create()
6
+
@@ -1,2 +1,5 @@
1
+ // for more details see: http://emberjs.com/guides/views/
2
+
1
3
  <%= application_name.camelize %>.<%= class_name.camelize %>View = Ember.View.extend({
4
+ templateName: '<%= handlebars_template_path %>'
2
5
  });
@@ -0,0 +1,4 @@
1
+ # for more details see: http://emberjs.com/guides/views/
2
+
3
+ <%= application_name.camelize %>.<%= class_name.camelize %>View = Ember.View.extend
4
+ templateName: '<%= handlebars_template_path %>'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-rails-lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-03-07 00:00:00.000000000 Z
15
+ date: 2013-05-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: execjs
@@ -78,6 +78,22 @@ dependencies:
78
78
  - - ! '>='
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: handlebars-source
83
+ requirement: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :runtime
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
81
97
  - !ruby/object:Gem::Dependency
82
98
  name: ember-data-source
83
99
  requirement: !ruby/object:Gem::Requirement
@@ -142,6 +158,38 @@ dependencies:
142
158
  - - ! '>='
143
159
  - !ruby/object:Gem::Version
144
160
  version: '0'
161
+ - !ruby/object:Gem::Dependency
162
+ name: ember-source
163
+ requirement: !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - '='
167
+ - !ruby/object:Gem::Version
168
+ version: 1.0.0.rc4
169
+ type: :development
170
+ prerelease: false
171
+ version_requirements: !ruby/object:Gem::Requirement
172
+ none: false
173
+ requirements:
174
+ - - '='
175
+ - !ruby/object:Gem::Version
176
+ version: 1.0.0.rc4
177
+ - !ruby/object:Gem::Dependency
178
+ name: handlebars-source
179
+ requirement: !ruby/object:Gem::Requirement
180
+ none: false
181
+ requirements:
182
+ - - '='
183
+ - !ruby/object:Gem::Version
184
+ version: 1.0.0.rc4
185
+ type: :development
186
+ prerelease: false
187
+ version_requirements: !ruby/object:Gem::Requirement
188
+ none: false
189
+ requirements:
190
+ - - '='
191
+ - !ruby/object:Gem::Version
192
+ version: 1.0.0.rc4
145
193
  description:
146
194
  email:
147
195
  - me@keithpitt.com
@@ -156,8 +204,6 @@ files:
156
204
  - lib/ember/handlebars/version.rb
157
205
  - lib/ember/rails/engine.rb
158
206
  - lib/ember/rails/version.rb
159
- - lib/ember/version.rb
160
- - lib/ember-rails-lite.rb
161
207
  - lib/ember-rails.rb
162
208
  - lib/ember_rails.rb
163
209
  - lib/generators/ember/bootstrap_generator.rb
@@ -165,30 +211,36 @@ files:
165
211
  - lib/generators/ember/generator_helpers.rb
166
212
  - lib/generators/ember/install_generator.rb
167
213
  - lib/generators/ember/model_generator.rb
214
+ - lib/generators/ember/resource_generator.rb
168
215
  - lib/generators/ember/resource_override.rb
169
216
  - lib/generators/ember/route_generator.rb
217
+ - lib/generators/ember/template_generator.rb
170
218
  - lib/generators/ember/view_generator.rb
171
219
  - lib/generators/templates/app.js
220
+ - lib/generators/templates/app.js.coffee
172
221
  - lib/generators/templates/application.handlebars
222
+ - lib/generators/templates/application.js
223
+ - lib/generators/templates/application.js.coffee
173
224
  - lib/generators/templates/array_controller.js
225
+ - lib/generators/templates/array_controller.js.coffee
174
226
  - lib/generators/templates/controller.js
227
+ - lib/generators/templates/controller.js.coffee
175
228
  - lib/generators/templates/model.js
229
+ - lib/generators/templates/model.js.coffee
176
230
  - lib/generators/templates/object_controller.js
231
+ - lib/generators/templates/object_controller.js.coffee
177
232
  - lib/generators/templates/route.js
233
+ - lib/generators/templates/route.js.coffee
178
234
  - lib/generators/templates/router.js
235
+ - lib/generators/templates/router.js.coffee
179
236
  - lib/generators/templates/store.js
180
- - lib/generators/templates/view.handlebars
237
+ - lib/generators/templates/store.js.coffee
238
+ - lib/generators/templates/template.handlebars
181
239
  - lib/generators/templates/view.js
240
+ - lib/generators/templates/view.js.coffee
182
241
  homepage: https://github.com/emberjs/ember-rails
183
242
  licenses: []
184
- post_install_message: ! "# Ember-Rails Release Notes #\n\nIf you're upgrading from
185
- ember-rails 0.11.1 or earlier, please be aware of the\nActiveModelSerializers changes
186
- that are part of this update:\n\nActiveModelSerializers will no longer be a hard
187
- dependency of ember-rails and\nwill not be require'd automatically. Please add
188
- the following line to your\nGemfile to continue using ActiveModelSerializers with
189
- ember-rails:\n\n gem \"active_model_serializers\"\n\nIn new applications, running
190
- the bootstrap generator will append this\ndependency statement to your Gemfile for
191
- you:\n\n rails g ember:bootstrap\n\nRead more about using ember-rails at https://github.com/emberjs/ember-rails\n"
243
+ post_install_message:
192
244
  rdoc_options: []
193
245
  require_paths:
194
246
  - lib
@@ -1 +0,0 @@
1
- require 'ember_rails'
@@ -1,3 +0,0 @@
1
- module Ember
2
- VERSION = "1.0.0-rc.1"
3
- end