ember-rails 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -12,9 +12,7 @@ Add the gem to your application Gemfile:
12
12
 
13
13
  gem "ember-rails"
14
14
 
15
- Run `bundle install` and add the following line to `app/assets/javascripts/application.js`:
16
-
17
- //= require ember
15
+ Run `bundle install` and use the ember-rails generator to add the necessary dependencies.
18
16
 
19
17
  Ember-rails will use the production build of Ember.js when Rails is running in
20
18
  production mode, and the development build otherwise.
@@ -35,8 +33,12 @@ Additionally, it will add the following lines to `app/assets/javascripts/applica
35
33
  By default, it uses the Rails Application's name and creates an `rails_app_name.js`
36
34
  file to setup application namespace and initial requires:
37
35
 
36
+ //= require handlebars
38
37
  //= require ember
39
- //= require ember/app
38
+ //= require ember-data
39
+ //= require_self
40
+ //= require rails_app_name
41
+ RailsAppName = Ember.Application.create();
40
42
 
41
43
  *Example:*
42
44
 
@@ -64,28 +66,20 @@ and including the assets in your layout:
64
66
 
65
67
  <%= javascript_include_tag "templates/admin_panel" %>
66
68
 
67
- If you want to strip template root from template names, add `templates_root` option to your application configuration block :
68
-
69
- config.handlebars.templates_root = 'templates'
70
-
71
- The result will be like this :
72
-
73
- Ember.TEMPLATES['admin_panel'] = "...";
74
-
75
- If you want a different path separator in template names add `templates_path_separator` option to your application configuration block :
76
-
77
- config.handlebars.templates_path_separator = '-'
69
+ If you want to strip template root from template names, add `templates_root` option to your application configuration block.
70
+ By default, `templates_root` is `'templates'`.
78
71
 
79
- The result will be like this :
72
+ config.handlebars.templates_root = 'ember_templates'
80
73
 
81
- Ember.TEMPLATES['templates-admin_panel'] = "...";
74
+ If you store templates in a file like `app/assets/javascripts/ember_templates/admin_panel.handlebars` after setting the above config,
75
+ it will be made available to Ember as the `admin_panel` template.
82
76
 
83
- Default behavior for ember-rails is to precompile handlebars templates only in production environment.
84
- If you don't want this behavior you can turn it off in your application configuration block :
77
+ Default behavior for ember-rails is to precompile handlebars templates.
78
+ 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:
85
79
 
86
80
  config.handlebars.precompile = false
87
81
 
88
- (Remember to clear the local sprockets cache if you change the value of precompile, by default at `tmp/cache/assets`)
82
+ _(Note: you must clear the local sprockets cache if you disable precompilation, stored by default in `tmp/cache/assets`)_
89
83
 
90
84
  Bundle all templates together thanks to Sprockets,
91
85
  e.g create `app/assets/javascripts/templates/all.js` with:
@@ -107,6 +101,33 @@ It will be translated as :
107
101
  {{#view Ember.Button}}OK{{/view}}
108
102
  </script>
109
103
 
104
+ ## Specifying Different Versions of Ember/Handlebars/Ember-Data
105
+
106
+ By default, ember-rails ships with the latest version of
107
+ [Ember](https://rubygems.org/gems/ember-source/versions) (rc1),
108
+ [Handlebars](https://rubygems.org/gems/handlebars-source/versions) (rc3),
109
+ and [Ember-Data](https://rubygems.org/gems/ember-data-source/versions).
110
+
111
+ To specify a different version that'll be used for both template
112
+ precompilation and serving to the browser, you can specify the desired
113
+ version of one of the above-linked gems in the Gemfile, e.g.:
114
+
115
+ gem 'ember-source', '1.0.0.pre4.2'
116
+
117
+ You can also specify versions of 'handlebars-source' and
118
+ 'ember-data-source', but note that an appropriate 'handlebars-source'
119
+ will by automatically chosen depending on the version of 'ember-source'
120
+ that's specified.
121
+
122
+ You can also override the specific ember.js, handlebars.js, and
123
+ ember-data.js files that'll be `require`d by the Asset pipeline by
124
+ placing these files in `vendor/assets/ember/development` and
125
+ `vendor/assets/ember/production`, depending on the `config.ember.variant`
126
+ you've specified in your app's configuration, e.g.:
127
+
128
+ config.ember.variant = :production
129
+ #config.ember.variant = :development
130
+
110
131
  ## Note on Patches/Pull Requests
111
132
 
112
133
  1. Fork the project.
@@ -1,5 +1,5 @@
1
1
  module Ember
2
2
  module Rails
3
- VERSION = '0.10.0'
3
+ VERSION = '0.11.0'
4
4
  end
5
5
  end
@@ -1,8 +1,10 @@
1
1
  require 'rails'
2
2
  require 'ember/rails/version'
3
3
  require 'ember/version'
4
- require 'ember/handlebars/version'
5
4
  require 'ember/rails/engine'
5
+ require 'ember/source'
6
+ require 'ember/data/source'
7
+ require 'handlebars/source'
6
8
 
7
9
  module Ember
8
10
  module Rails
@@ -21,13 +23,23 @@ module Ember
21
23
 
22
24
  initializer "ember_rails.setup_vendor", :after => "ember_rails.setup", :group => :all do |app|
23
25
  if variant = app.config.ember.variant
24
- # Add the gem's vendored ember to the end of the asset search path
25
- ember_path = File.expand_path("../../vendor/ember/#{variant}", __FILE__)
26
- app.config.assets.paths.push(ember_path.to_s)
26
+ # Copy over the desired ember, ember-data, and handlebars bundled in
27
+ # ember-source, ember-data-source, and handlebars-source to a tmp folder.
28
+ tmp_path = app.root.join("tmp/cache/ember-rails")
29
+ ext = variant == :production ? ".prod.js" : ".js"
30
+ FileUtils.mkdir_p(tmp_path)
31
+ FileUtils.cp(::Ember::Source.bundled_path_for("ember#{ext}"), tmp_path.join("ember.js"))
32
+ FileUtils.cp(::Ember::Data::Source.bundled_path_for("ember-data#{ext}"), tmp_path.join("ember-data.js"))
33
+ app.assets.append_path(tmp_path)
34
+
35
+ # Make the handlebars.js and handlebars.runtime.js bundled
36
+ # in handlebars-source available.
37
+ app.assets.append_path(File.expand_path('../', ::Handlebars::Source.bundled_path))
27
38
 
28
39
  # Allow a local variant override
29
40
  ember_path = app.root.join("vendor/assets/ember/#{variant}")
30
- app.config.assets.paths.unshift(ember_path.to_s) if ember_path.exist?
41
+ app.assets.prepend_path(ember_path.to_s) if ember_path.exist?
42
+
31
43
  else
32
44
  warn "No ember.js variant was specified in your config environment."
33
45
  warn "You can set a specific variant in your application config in "
@@ -39,24 +51,11 @@ module Ember
39
51
  end
40
52
  end
41
53
 
42
- initializer "ember_rails.find_ember", :after => "ember_rails.setup_vendor", :group => :all do |app|
43
- config.ember.ember_location ||= location_for(app, "ember.js")
44
- config.ember.handlebars_location ||= location_for(app, "handlebars.js")
45
- end
46
-
47
54
  initializer "ember_rails.es5_default", :group => :all do |app|
48
55
  if defined?(Closure::Compiler) && app.config.assets.js_compressor == :closure
49
56
  Closure::Compiler::DEFAULT_OPTIONS[:language_in] = 'ECMASCRIPT5'
50
57
  end
51
58
  end
52
-
53
- def location_for(app, file)
54
- path = app.config.assets.paths.find do |dir|
55
- Pathname.new(dir).join(file).exist?
56
- end
57
-
58
- File.join(path, file) if path
59
- end
60
59
  end
61
60
  end
62
61
  end
@@ -1,3 +1,4 @@
1
+ require 'ember/version'
1
2
  require 'generators/ember/generator_helpers'
2
3
 
3
4
  module Ember
@@ -7,8 +8,9 @@ module Ember
7
8
 
8
9
  source_root File.expand_path("../../templates", __FILE__)
9
10
 
10
- desc "Creates a default Ember.js folder layout in app/assets/javascripts/ember"
11
+ desc "Creates a default Ember.js folder layout in app/assets/javascripts"
11
12
 
13
+ class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
12
14
  class_option :skip_git, :type => :boolean, :aliases => "-g", :default => false, :desc => "Skip Git keeps"
13
15
 
14
16
  def inject_ember
@@ -1,16 +1,20 @@
1
1
  require 'ember/version'
2
+ require 'generators/ember/generator_helpers'
2
3
 
3
4
  module Ember
4
5
  module Generators
5
6
  class ControllerGenerator < ::Rails::Generators::NamedBase
7
+ include Ember::Generators::GeneratorHelpers
8
+
6
9
  source_root File.expand_path("../../templates", __FILE__)
7
10
 
8
11
  desc "Creates a new Ember.js controller"
9
12
  class_option :array, :type => :boolean, :default => false, :desc => "Create an Ember.ArrayController to represent multiple objects"
13
+ class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
10
14
  class_option :object, :type => :boolean, :default => false, :desc => "Create an Ember.ObjectController to represent a single object"
11
15
 
12
16
  def create_controller_files
13
- file_path = File.join('app/assets/javascripts/controllers', class_path, "#{file_name}_controller.js")
17
+ file_path = File.join(ember_path, 'controllers', class_path, "#{file_name}_controller.js")
14
18
  if options.array?
15
19
  template 'array_controller.js', file_path
16
20
  elsif options.object?
@@ -3,7 +3,7 @@ module Ember
3
3
  module GeneratorHelpers
4
4
 
5
5
  def ember_path
6
- "app/assets/javascripts"
6
+ options[:ember_path] || "app/assets/javascripts"
7
7
  end
8
8
 
9
9
  def application_name
@@ -1,4 +1,5 @@
1
1
  require 'ember/version'
2
+ require 'generators/ember/generator_helpers'
2
3
 
3
4
  module Ember
4
5
  module Generators
@@ -1,33 +1,37 @@
1
1
  require 'ember/version'
2
+ require 'generators/ember/generator_helpers'
2
3
 
3
4
  module Ember
4
5
  module Generators
5
6
  class ModelGenerator < ::Rails::Generators::NamedBase
7
+ include Ember::Generators::GeneratorHelpers
8
+
6
9
  source_root File.expand_path("../../templates", __FILE__)
7
10
  argument :attributes, :type => :array, :default => [], :banner => "field[:type] field[:type] ..."
8
11
 
9
12
  desc "Creates a new Ember.js model"
13
+ class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
10
14
 
11
15
  def create_model_files
12
- template 'model.js', File.join('app/assets/javascripts/models', class_path, "#{file_name}.js")
16
+ template 'model.js', File.join(ember_path, 'models', class_path, "#{file_name}.js")
13
17
  end
14
18
 
15
19
  private
16
20
  EMBER_TYPE_LOOKUP = {
17
21
  nil => 'string',
18
22
 
19
- binary: 'string',
20
- string: 'string',
21
- text: 'string',
22
- boolean: 'boolean',
23
- date: 'date',
24
- datetime: 'date',
25
- time: 'date',
26
- timestamp: 'date',
27
- decimal: 'number',
28
- float: 'number',
29
- integer: 'number',
30
- primary_key: 'number'
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'
31
35
  }
32
36
 
33
37
  def parse_attributes!
@@ -36,7 +40,7 @@ module Ember
36
40
  key = type.try(:to_sym)
37
41
  ember_type = EMBER_TYPE_LOOKUP[key] || type
38
42
 
39
- { name: name, type: ember_type }
43
+ { :name => name, :type => ember_type }
40
44
  end
41
45
  end
42
46
  end
@@ -1,14 +1,18 @@
1
1
  require 'ember/version'
2
+ require 'generators/ember/generator_helpers'
2
3
 
3
4
  module Ember
4
5
  module Generators
5
6
  class RouteGenerator < ::Rails::Generators::NamedBase
7
+ include Ember::Generators::GeneratorHelpers
8
+
6
9
  source_root File.expand_path("../../templates", __FILE__)
7
10
 
8
11
  desc "Creates a new Ember.js route"
12
+ class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
9
13
 
10
14
  def create_route_files
11
- file_path = File.join('app/assets/javascripts/routes', class_path, "#{file_name}_route.js")
15
+ file_path = File.join(ember_path, 'routes', class_path, "#{file_name}_route.js")
12
16
  template 'route.js', file_path
13
17
  end
14
18
  end
@@ -1,17 +1,21 @@
1
1
  require 'ember/version'
2
+ require 'generators/ember/generator_helpers'
2
3
 
3
4
  module Ember
4
5
  module Generators
5
6
  class ViewGenerator < ::Rails::Generators::NamedBase
7
+ include Ember::Generators::GeneratorHelpers
8
+
6
9
  source_root File.expand_path("../../templates", __FILE__)
7
10
 
8
11
  desc "Creates a new Ember.js view and associated Handlebars template"
9
12
  class_option :array, :type => :boolean, :default => false, :desc => "Create an Ember.ArrayController to represent multiple objects"
13
+ class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
10
14
  class_option :object, :type => :boolean, :default => false, :desc => "Create an Ember.ObjectController to represent a single object"
11
15
 
12
16
  def create_view_files
13
- template 'view.js', File.join('app/assets/javascripts/views', class_path, "#{file_name}_view.js")
14
- template 'view.handlebars', File.join('app/assets/javascripts/templates', class_path, "#{file_name}.handlebars")
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")
15
19
  invoke('ember:controller', [ file_name ], options)
16
20
  invoke('ember:route', [ file_name ], options)
17
21
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ember-rails
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.10.0
5
+ version: 0.11.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Keith Pitt
@@ -12,120 +12,152 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-02-17 00:00:00.000000000 Z
15
+ date: 2013-02-28 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  type: :runtime
19
- version_requirements: !ruby/object:Gem::Requirement
20
- none: false
19
+ name: execjs
20
+ requirement: !ruby/object:Gem::Requirement
21
21
  requirements:
22
22
  - - ! '>='
23
23
  - !ruby/object:Gem::Version
24
24
  version: '1.2'
25
- name: execjs
26
- prerelease: false
27
- requirement: !ruby/object:Gem::Requirement
28
25
  none: false
26
+ version_requirements: !ruby/object:Gem::Requirement
29
27
  requirements:
30
28
  - - ! '>='
31
29
  - !ruby/object:Gem::Version
32
30
  version: '1.2'
31
+ none: false
32
+ prerelease: false
33
33
  - !ruby/object:Gem::Dependency
34
34
  type: :runtime
35
- version_requirements: !ruby/object:Gem::Requirement
36
- none: false
35
+ name: railties
36
+ requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.1'
41
- name: railties
42
- prerelease: false
43
- requirement: !ruby/object:Gem::Requirement
44
41
  none: false
42
+ version_requirements: !ruby/object:Gem::Requirement
45
43
  requirements:
46
44
  - - ! '>='
47
45
  - !ruby/object:Gem::Version
48
46
  version: '3.1'
47
+ none: false
48
+ prerelease: false
49
49
  - !ruby/object:Gem::Dependency
50
50
  type: :runtime
51
- version_requirements: !ruby/object:Gem::Requirement
51
+ name: active_model_serializers
52
+ requirement: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
52
57
  none: false
58
+ version_requirements: !ruby/object:Gem::Requirement
53
59
  requirements:
54
60
  - - ! '>='
55
61
  - !ruby/object:Gem::Version
56
62
  version: '0'
57
- name: active_model_serializers
63
+ none: false
58
64
  prerelease: false
65
+ - !ruby/object:Gem::Dependency
66
+ type: :runtime
67
+ name: barber
59
68
  requirement: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: 0.4.1
60
73
  none: false
74
+ version_requirements: !ruby/object:Gem::Requirement
61
75
  requirements:
62
76
  - - ! '>='
63
77
  - !ruby/object:Gem::Version
64
- version: '0'
78
+ version: 0.4.1
79
+ none: false
80
+ prerelease: false
65
81
  - !ruby/object:Gem::Dependency
66
82
  type: :runtime
67
- version_requirements: !ruby/object:Gem::Requirement
83
+ name: ember-source
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
68
89
  none: false
90
+ version_requirements: !ruby/object:Gem::Requirement
69
91
  requirements:
70
92
  - - ! '>='
71
93
  - !ruby/object:Gem::Version
72
94
  version: '0'
73
- name: barber
95
+ none: false
74
96
  prerelease: false
97
+ - !ruby/object:Gem::Dependency
98
+ type: :runtime
99
+ name: ember-data-source
75
100
  requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
76
105
  none: false
106
+ version_requirements: !ruby/object:Gem::Requirement
77
107
  requirements:
78
108
  - - ! '>='
79
109
  - !ruby/object:Gem::Version
80
110
  version: '0'
111
+ none: false
112
+ prerelease: false
81
113
  - !ruby/object:Gem::Dependency
82
114
  type: :development
83
- version_requirements: !ruby/object:Gem::Requirement
84
- none: false
115
+ name: bundler
116
+ requirement: !ruby/object:Gem::Requirement
85
117
  requirements:
86
118
  - - ! '>='
87
119
  - !ruby/object:Gem::Version
88
120
  version: 1.2.2
89
- name: bundler
90
- prerelease: false
91
- requirement: !ruby/object:Gem::Requirement
92
121
  none: false
122
+ version_requirements: !ruby/object:Gem::Requirement
93
123
  requirements:
94
124
  - - ! '>='
95
125
  - !ruby/object:Gem::Version
96
126
  version: 1.2.2
127
+ none: false
128
+ prerelease: false
97
129
  - !ruby/object:Gem::Dependency
98
130
  type: :development
99
- version_requirements: !ruby/object:Gem::Requirement
100
- none: false
131
+ name: appraisal
132
+ requirement: !ruby/object:Gem::Requirement
101
133
  requirements:
102
134
  - - ! '>='
103
135
  - !ruby/object:Gem::Version
104
136
  version: '0'
105
- name: appraisal
106
- prerelease: false
107
- requirement: !ruby/object:Gem::Requirement
108
137
  none: false
138
+ version_requirements: !ruby/object:Gem::Requirement
109
139
  requirements:
110
140
  - - ! '>='
111
141
  - !ruby/object:Gem::Version
112
142
  version: '0'
143
+ none: false
144
+ prerelease: false
113
145
  - !ruby/object:Gem::Dependency
114
146
  type: :development
115
- version_requirements: !ruby/object:Gem::Requirement
116
- none: false
147
+ name: tzinfo
148
+ requirement: !ruby/object:Gem::Requirement
117
149
  requirements:
118
150
  - - ! '>='
119
151
  - !ruby/object:Gem::Version
120
152
  version: '0'
121
- name: tzinfo
122
- prerelease: false
123
- requirement: !ruby/object:Gem::Requirement
124
153
  none: false
154
+ version_requirements: !ruby/object:Gem::Requirement
125
155
  requirements:
126
156
  - - ! '>='
127
157
  - !ruby/object:Gem::Version
128
158
  version: '0'
159
+ none: false
160
+ prerelease: false
129
161
  description:
130
162
  email:
131
163
  - me@keithpitt.com
@@ -162,14 +194,6 @@ files:
162
194
  - lib/generators/templates/store.js
163
195
  - lib/generators/templates/view.handlebars
164
196
  - lib/generators/templates/view.js
165
- - vendor/ember/development/ember-data.js
166
- - vendor/ember/development/ember.js
167
- - vendor/ember/development/handlebars-runtime.js
168
- - vendor/ember/development/handlebars.js
169
- - vendor/ember/production/ember-data.js
170
- - vendor/ember/production/ember.js
171
- - vendor/ember/production/handlebars-runtime.js
172
- - vendor/ember/production/handlebars.js
173
197
  homepage: https://github.com/emberjs/ember-rails
174
198
  licenses: []
175
199
  post_install_message:
@@ -177,23 +201,23 @@ rdoc_options: []
177
201
  require_paths:
178
202
  - lib
179
203
  required_ruby_version: !ruby/object:Gem::Requirement
180
- none: false
181
204
  requirements:
182
205
  - - ! '>='
183
206
  - !ruby/object:Gem::Version
207
+ hash: -4530447845607974325
184
208
  segments:
185
209
  - 0
186
- hash: -2889280930405183157
187
210
  version: '0'
188
- required_rubygems_version: !ruby/object:Gem::Requirement
189
211
  none: false
212
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
213
  requirements:
191
214
  - - ! '>='
192
215
  - !ruby/object:Gem::Version
216
+ hash: -4530447845607974325
193
217
  segments:
194
218
  - 0
195
- hash: -2889280930405183157
196
219
  version: '0'
220
+ none: false
197
221
  requirements: []
198
222
  rubyforge_project:
199
223
  rubygems_version: 1.8.23