ember-rails 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 916d617e38b6defe34e9a4fda6e864399d699a44
4
+ data.tar.gz: f4cf0a357c14a700944c601a5ef20b433a471b46
5
+ SHA512:
6
+ metadata.gz: 3f1dd4bc588c9fe62bd10e04d19424cab5a28ed601e890d965f2be2b5a18b010113601e1f2058d688e71c49e20cd56b21ec302c6965040fb2ce01687b73fa9b6
7
+ data.tar.gz: d9614b02448d13537139e0f2bcbaec40dc7f7857252a6181ddcdd2cc40993a1e38a215f1fd66458c3a8c33e352a0466842501fb705fd92ca45cfb83dc58d95de
data/README.md CHANGED
@@ -1,42 +1,54 @@
1
1
  # ember-rails [![Build Status](https://secure.travis-ci.org/emberjs/ember-rails.png?branch=master)](http://travis-ci.org/emberjs/ember-rails) [![Dependency Status](https://gemnasium.com/emberjs/ember-rails.png)](https://gemnasium.com/emberjs/ember-rails)
2
2
 
3
- ember-rails allows you to include [Ember.JS](http://emberjs.com/) into your Rails 3.1+ application.
3
+ ember-rails makes developing an [Ember.JS](http://emberjs.com/) application much easier in Rails 3.1+.
4
4
 
5
- The gem will also pre-compile your handlebars templates when building your asset pipeline. It includes development and production copies of Ember.
5
+ The following functionalities are included in this gem:
6
+ - Pre-compiling of your handlebars templates when building your asset pipeline.
7
+ - Includes development and production copies of Ember, [Ember Data](https://github.com/emberjs/data) and [Handlebars](https://github.com/wycats/handlebars.js).
8
+ - Includes [ActiveModel::Serializer](https://github.com/rails-api/active_model_serializers) for integration with Ember Data.
6
9
 
7
10
  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
11
 
9
12
  ## Getting started
10
- 1. Add the gem to your application Gemfile:
13
+ * Add the gem to your application Gemfile:
14
+
11
15
  ```ruby
12
16
  gem 'ember-rails'
13
- gem 'ember-source', '1.0.0.rc5' # or the version you need
14
- gem 'handlebars-source', '1.0.0.rc4' # or the version you need
15
- ```
17
+ gem 'ember-source', '1.1.2' # or the version you need
16
18
 
17
- 2. Run `bundle install`
18
-
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
19
+ # optional since Handlebars 1.0.0 was released
20
+ #gem 'handlebars-source', '~> 1.0.12' # or the version you need
22
21
  ```
23
22
 
24
- 4. Next, generate the application structure:
23
+ * Run `bundle install`
24
+ * Next, generate the application structure:
25
+
25
26
  ```shell
26
27
  rails generate ember:bootstrap
27
28
  ```
28
29
 
29
- 5. Restart your server (if it's running)
30
+ * Restart your server (if it's running)
30
31
 
31
32
 
32
33
  Notes:
33
34
 
34
- To install the latest builds of ember and ember-data:
35
+
36
+ To install the latest builds of ember and ember-data. It should be noted that the
37
+ examples in the [getting started guide](http://emberjs.com/guides/getting-started/)
38
+ have been designed to use the released version of ember:
39
+
40
+ ```shell
41
+ rails generate ember:install
42
+ ```
43
+
44
+ You'll probably need to clear out your cache after doing this with
45
+
35
46
  ```shell
36
- rails generate ember:install --head
47
+ rake tmp:clear
37
48
  ```
38
49
 
39
50
  ## For CoffeeScript support
51
+
40
52
  1. Add coffee-rails to the Gemfile
41
53
  ```ruby
42
54
  gem 'coffee-rails'
@@ -47,6 +59,50 @@ gem 'coffee-rails'
47
59
  rails g ember:bootstrap -g --javascript-engine coffee
48
60
  ```
49
61
 
62
+ Note:
63
+
64
+ Ember-rails include some flags options for bootstrap generator:
65
+
66
+ ```
67
+ --ember-path or -d # custom ember path
68
+ --skip-git or -g # skip git keeps
69
+ --javascript-engine # engine for javascript (js or coffee)
70
+ --app-name or -n # custom ember app name
71
+ ```
72
+
73
+ ## For EmberScript support
74
+
75
+ [EmberScript](http://www.emberscript.com) is a dialect of CoffeeScript
76
+ with extra support for computed properties (which do not have to be
77
+ explicitly declared), the `class` / `extends` syntax, and extra syntax
78
+ to support observers and mixins.
79
+
80
+ To get EmberScript support, make sure you have the following in your
81
+ Gemfile:
82
+
83
+ ```ruby
84
+ gem 'ember_script-rails', :github => 'ghempton/ember-script-rails'
85
+ ```
86
+
87
+ You can now use the flag `--javascript-engine=em` to specify EmberScript
88
+ assets in your generators, but all of the generators will default to
89
+ using an EmberScript variant first.
90
+
91
+ ## Configuration Options
92
+
93
+ The following options are availabe for configuration in your application or environment level
94
+ config files (`config/application.rb`, `config/environments/development.rb`, etc.):
95
+
96
+ * `config.ember.variant` - Used to determine which Ember variant to use. Valid options: `:development`, `:production`.
97
+ * `config.ember.app_name` - Used to specify a default application name for all generators.
98
+ * `config.ember.ember_path` - Used to specify a default custom root path for all generators.
99
+ * `config.handlebars.precompile` - Used to enable or disable precompilation. Default value: `true`.
100
+ * `config.handlebars.templates_root` - Set the root path (under `app/assets/javascripts`) for templates
101
+ to be looked up in. Default value: `"templates"`.
102
+ * `config.handlebars.templates_path_separator` - The path separator to use for templates. Default value: `'/'`.
103
+ * `config.handlebars.output_type` - Configures the style of output (options are `:amd` and `:global`).
104
+ Default value: `:global`.
105
+
50
106
  ## Architecture
51
107
 
52
108
  Ember does not require an organized file structure. However, ember-rails allows you
@@ -54,9 +110,11 @@ to use `rails g ember:bootstrap` to create the following directory structure und
54
110
 
55
111
  controllers/
56
112
  helpers/
113
+ components/
57
114
  models/
58
115
  routes/
59
116
  templates/
117
+ templates/components
60
118
  views/
61
119
 
62
120
  Additionally, it will add the following lines to `app/assets/javascripts/application.js`.
@@ -82,8 +140,12 @@ file to setup application namespace and initial requires:
82
140
  create app/assets/javascripts/views/.gitkeep
83
141
  create app/assets/javascripts/helpers
84
142
  create app/assets/javascripts/helpers/.gitkeep
143
+ create app/assets/javascripts/components
144
+ create app/assets/javascripts/components/.gitkeep
85
145
  create app/assets/javascripts/templates
86
146
  create app/assets/javascripts/templates/.gitkeep
147
+ create app/assets/javascripts/templates/components
148
+ create app/assets/javascripts/templates/components/.gitkeep
87
149
  create app/assets/javascripts/app.js
88
150
 
89
151
  If you want to avoid `.gitkeep` files, use the `skip git` option like
@@ -133,9 +195,67 @@ It will be translated as :
133
195
  <button {{action anActionName}}>OK</button>
134
196
  </script>
135
197
 
198
+ ### Note about ember components
199
+
200
+ When necessary, ember-rails adheres to a conventional folder structure. To create an ember component you must define the handlebars file *inside* the *components* folder under the templates folder of your project to properly register your handlebars component file.
201
+
202
+ *Example*
203
+
204
+ With the following folder structure:
205
+
206
+ components/
207
+ controllers/
208
+ helpers/
209
+ models/
210
+ routes/
211
+ templates/
212
+ components/
213
+ my-component.handlebars
214
+ views/
215
+
216
+ and a *my-component.handlebars* file with the following contents
217
+
218
+ <h1>My Component</h1>
219
+
220
+ will produce the following handlebars output
221
+
222
+ <script type="text/x-handlebars" id="components/my-component">
223
+ <h1>My Component</h1>
224
+ </script>
225
+
226
+ You can reference your component inside your other handlebars template files by the handlebars file name:
227
+
228
+ {{ my-component }}
229
+
230
+ ### A note about upgrading ember-rails and components
231
+ The ember-rails project now includes generators for components. If you have an exisitng project and need
232
+ to compile component files you will need to include the components folder as part of the asset pipeline.
233
+ A typical project expects two folders for *components* related code:
234
+
235
+ * `assets/javascripts/components/` to hold the component javascript source
236
+ * `assets/javascripts/templates/components/` to hold the handlebars templates for your components
237
+
238
+ Your asset pipeline require statements should include reference to both e.g.
239
+
240
+ RailsAppName.js
241
+ ```
242
+ //= require_tree ./templates
243
+ //= require_tree ./components
244
+ ```
245
+
246
+ or
247
+
248
+ RailsAppName.js.coffee
249
+ ```
250
+ #= require_tree ./templates
251
+ #= require_tree ./components
252
+ ```
253
+
254
+ These are automatically generated for you in new projects you when you run the `ember:bootstrap` generator.
255
+
256
+
136
257
  ## Specifying Different Versions of Ember/Handlebars/Ember-Data
137
258
 
138
- ![Ember Data Warning](ember-data-in-progress.png)
139
259
  By default, ember-rails ships with the latest version of
140
260
  [Ember](https://rubygems.org/gems/ember-source/versions),
141
261
  [Handlebars](https://rubygems.org/gems/handlebars-source/versions),
@@ -145,7 +265,7 @@ To specify a different version that'll be used for both template
145
265
  precompilation and serving to the browser, you can specify the desired
146
266
  version of one of the above-linked gems in the Gemfile, e.g.:
147
267
 
148
- gem 'ember-source', '1.0.0.pre4.2'
268
+ gem 'ember-source', '1.0.0'
149
269
 
150
270
  You can also specify versions of 'handlebars-source' and
151
271
  'ember-data-source', but note that an appropriate 'handlebars-source'
@@ -163,11 +283,25 @@ you've specified in your app's configuration, e.g.:
163
283
 
164
284
  ## Updating Ember
165
285
 
166
- If at any point you need to update Ember.js from master, you can do that with
286
+ If at any point you need to update Ember.js from any of the release channels, you can do that with
287
+
288
+ rails generate ember:install --channel=<channel>
289
+
290
+ This will fetch both Ember.js and Ember Data from [http://builds.emberjs.com/](http://builds.emberjs.com/) and copy to the right directory. You can choose between the following channels:
291
+ * canary - This references the 'master' branch and is not recommended for production use.
292
+ * beta - This references the 'beta' branch, and will ultimately become the next stable version. It is not recommended for production use.
293
+ * release - This references the 'stable' branch, and is recommended for production use.
294
+
295
+ When you don't specify a channel, the release channel is used.
296
+
297
+ It is also possible to download a specific tagged release. To do this, use the following syntax:
298
+
299
+
300
+ rails generate ember:install --tag=v1.2.0-beta.2 --ember
167
301
 
168
- rails generate ember:install --head
302
+ or for ember-data
169
303
 
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.
304
+ rails generate ember:install --tag=v1.0.0-beta.2 --ember-data
171
305
 
172
306
  ## Note on Patches/Pull Requests
173
307
 
@@ -12,7 +12,6 @@ module Ember
12
12
  def prepare; end
13
13
 
14
14
  def evaluate(scope, locals, &block)
15
- target = template_target(scope)
16
15
  raw = handlebars?(scope)
17
16
 
18
17
  if raw
@@ -35,7 +34,15 @@ module Ember
35
34
  end
36
35
  end
37
36
 
38
- "#{target} = #{template}\n"
37
+ if configuration.output_type == :amd
38
+ target = amd_template_target(scope)
39
+
40
+ "define('#{target}', ['exports'], function(__exports__){ __exports__.default = #{template} });"
41
+ else
42
+ target = global_template_target(scope)
43
+
44
+ "#{target} = #{template}\n"
45
+ end
39
46
  end
40
47
 
41
48
  private
@@ -44,7 +51,11 @@ module Ember
44
51
  scope.pathname.to_s =~ /\.raw\.(handlebars|hjs|hbs)/
45
52
  end
46
53
 
47
- def template_target(scope)
54
+ def amd_template_target(scope)
55
+ "#{configuration.amd_namespace}/#{scope.logical_path.split(".").first}"
56
+ end
57
+
58
+ def global_template_target(scope)
48
59
  "Ember.TEMPLATES[#{template_path(scope.logical_path).inspect}]"
49
60
  end
50
61
 
@@ -1,5 +1,6 @@
1
1
  require 'ember/handlebars/template'
2
2
  require 'active_model_serializers'
3
+ require 'sprockets/railtie'
3
4
 
4
5
  module Ember
5
6
  module Rails
@@ -9,6 +10,7 @@ module Ember
9
10
  config.handlebars.precompile = true
10
11
  config.handlebars.templates_root = "templates"
11
12
  config.handlebars.templates_path_separator = '/'
13
+ config.handlebars.output_type = :global
12
14
 
13
15
  config.before_initialize do |app|
14
16
  Sprockets::Engines #force autoloading
@@ -1,5 +1,5 @@
1
1
  module Ember
2
2
  module Rails
3
- VERSION = '0.13.0'
3
+ VERSION = '0.14.0'
4
4
  end
5
5
  end
@@ -21,35 +21,24 @@ module Ember
21
21
  end
22
22
 
23
23
  initializer "ember_rails.setup_vendor", :after => "ember_rails.setup", :group => :all do |app|
24
- if variant = app.config.ember.variant || ::Rails.env.test?
25
- # test environments should default to development
26
- variant ||= :development
27
- # Copy over the desired ember, ember-data, and handlebars bundled in
28
- # ember-source, ember-data-source, and handlebars-source to a tmp folder.
29
- tmp_path = app.root.join("tmp/ember-rails")
30
- ext = variant == :production ? ".prod.js" : ".js"
31
- FileUtils.mkdir_p(tmp_path)
32
- FileUtils.cp(::Ember::Source.bundled_path_for("ember#{ext}"), tmp_path.join("ember.js"))
33
- FileUtils.cp(::Ember::Data::Source.bundled_path_for("ember-data#{ext}"), tmp_path.join("ember-data.js"))
34
- app.assets.append_path(tmp_path)
35
-
36
- # Make the handlebars.js and handlebars.runtime.js bundled
37
- # in handlebars-source available.
38
- app.assets.append_path(File.expand_path('../', ::Handlebars::Source.bundled_path))
39
-
40
- # Allow a local variant override
41
- ember_path = app.root.join("vendor/assets/ember/#{variant}")
42
- app.assets.prepend_path(ember_path.to_s) if ember_path.exist?
43
-
44
- else
45
- warn "No ember.js variant was specified in your config environment."
46
- warn "You can set a specific variant in your application config in "
47
- warn "order for sprockets to locate ember's assets:"
48
- warn ""
49
- warn " config.ember.variant = :development"
50
- warn ""
51
- warn "Valid values are :development and :production"
52
- end
24
+ variant = app.config.ember.variant || (::Rails.env.production? ? :production : :development)
25
+
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/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))
38
+
39
+ # Allow a local variant override
40
+ ember_path = app.root.join("vendor/assets/ember/#{variant}")
41
+ app.assets.prepend_path(ember_path.to_s) if ember_path.exist?
53
42
  end
54
43
 
55
44
  initializer "ember_rails.es5_default", :group => :all do |app|
@@ -11,7 +11,7 @@ module Ember
11
11
 
12
12
  class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
13
13
  class_option :skip_git, :type => :boolean, :aliases => "-g", :default => false, :desc => "Skip Git keeps"
14
- class_option :javascript_engine, :desc => "Engine for JavaScripts"
14
+ class_option :javascript_engine, :desc => "Engine for JavaScripts (js for JavaScript, coffee for CoffeeScript, etc)"
15
15
  class_option :app_name, :type => :string, :aliases => "-n", :default => false, :desc => "Custom ember app name"
16
16
 
17
17
  def inject_ember
@@ -24,7 +24,7 @@ module Ember
24
24
 
25
25
 
26
26
  def create_dir_layout
27
- %W{models controllers views routes helpers templates}.each do |dir|
27
+ %W{models controllers views routes helpers components templates templates/components mixins}.each do |dir|
28
28
  empty_directory "#{ember_path}/#{dir}"
29
29
  create_file "#{ember_path}/#{dir}/.gitkeep" unless options[:skip_git]
30
30
  end
@@ -43,12 +43,26 @@ module Ember
43
43
  end
44
44
 
45
45
  private
46
+
46
47
  def inject_into_application_file(safe_extension)
47
- application_file = "#{ember_path}/application.#{safe_extension}"
48
- inject_into_file( application_file, :before => /^.*require_tree.*$/) do
49
- context = instance_eval('binding')
50
- source = File.expand_path(find_in_source_paths("application.#{safe_extension}"))
51
- ERB.new(::File.binread(source), nil, '-', '@output_buffer').result(context)
48
+ application_file = "application.#{safe_extension}"
49
+ full_path = Pathname.new(destination_root).join(ember_path, application_file)
50
+
51
+ if full_path.exist?
52
+ contents = full_path.read
53
+ injection_options = if contents =~ regex = /^.*require_tree.*$/
54
+ {:before => regex}
55
+ elsif contents =~ regex = /^\s*$/
56
+ {:before => regex}
57
+ end
58
+
59
+ inject_into_file(full_path.to_s, injection_options) do
60
+ context = instance_eval('binding')
61
+ source = File.expand_path(find_in_source_paths(application_file))
62
+ ERB.new(::File.binread(source), nil, '-', '@output_buffer').result(context)
63
+ end
64
+ else
65
+ template application_file, full_path
52
66
  end
53
67
  end
54
68
  end
@@ -0,0 +1,28 @@
1
+ require 'generators/ember/generator_helpers'
2
+
3
+ module Ember
4
+ module Generators
5
+ class ComponentGenerator < ::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 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
+
12
+ class_option :javascript_engine, :desc => "Engine for JavaScripts"
13
+ class_option :ember_path, :type => :string, :aliases => "-d", :default => false, :desc => "Custom ember app path"
14
+ class_option :app_name, :type => :string, :aliases => "-n", :default => false, :desc => "Custom ember app name"
15
+
16
+ def create_component_files
17
+ dashed_file_name = file_name.gsub(/_/, '-')
18
+ comp_path = File.join(ember_path, 'components', class_path, "#{dashed_file_name}_component.#{engine_extension}")
19
+ template "component.#{engine_extension}", comp_path
20
+
21
+ templ_path = File.join(ember_path, 'templates/components', class_path, "#{dashed_file_name}.handlebars")
22
+ template "component.template.handlebars", templ_path
23
+
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -3,12 +3,32 @@ module Ember
3
3
  module GeneratorHelpers
4
4
 
5
5
  def ember_path
6
- options[:ember_path] || "app/assets/javascripts"
6
+ if options[:ember_path]
7
+ options[:ember_path]
8
+ elsif configuration.ember_path
9
+ configuration.ember_path
10
+ elsif rails_engine?
11
+ "app/assets/javascripts/#{engine_name}"
12
+ else
13
+ "app/assets/javascripts"
14
+ end
15
+ end
16
+
17
+ def rails_engine?
18
+ defined?(ENGINE_PATH)
19
+ end
20
+
21
+ def engine_name
22
+ ENGINE_PATH.split('/')[-2]
7
23
  end
8
24
 
9
25
  def application_name
10
26
  if options[:app_name]
11
27
  options[:app_name]
28
+ elsif configuration.app_name
29
+ configuration.app_name
30
+ elsif rails_engine?
31
+ engine_name
12
32
  elsif defined?(::Rails) && ::Rails.application
13
33
  ::Rails.application.class.name.split('::').first
14
34
  else
@@ -16,18 +36,21 @@ module Ember
16
36
  end
17
37
  end
18
38
 
19
-
20
39
  def class_name
21
40
  (class_path + [file_name]).map!{ |m| m.camelize }.join()
22
41
  end
23
42
 
24
43
  def handlebars_template_path
25
- File.join(class_path, file_name).gsub(/^\//, '')
44
+ File.join(class_path, file_name).gsub(/^\//, '')
26
45
  end
27
46
 
28
47
  def engine_extension
29
48
  @engine_extension ||= "js.#{options[:javascript_engine]}".sub('js.js','js')
30
49
  end
50
+
51
+ def configuration
52
+ ::Rails.configuration.ember
53
+ end
31
54
  end
32
55
  end
33
56
  end
@@ -3,39 +3,163 @@ require 'net/http'
3
3
  require 'uri'
4
4
  require 'fileutils'
5
5
 
6
+
6
7
  module Ember
7
8
  module Generators
8
9
  class InstallGenerator < ::Rails::Generators::Base
10
+
11
+ class InvalidChannel < ::Thor::Error; end
12
+ class ConflictingOptions < ::Thor::Error; end
13
+ class Deprecated < ::Thor::Error; end
14
+ class InsufficientOptions < ::Thor::Error; end
15
+
16
+ ::InvalidChannel = InvalidChannel
17
+ ::ConflictingOptions = ConflictingOptions
18
+ ::Deprecated = Deprecated
19
+ ::InsufficientOptions = InsufficientOptions
20
+
9
21
  desc "Install Ember.js into your vendor folder"
10
- class_option :head, :type => :boolean, :default => false, :desc => "Download latest Ember.js from GitHub and fetch it into your project"
22
+ class_option :head,
23
+ :type => :boolean,
24
+ :default => false,
25
+ :desc => "Download Ember.js & Ember data from canary channel. This is deprecated. Use channel instead."
26
+ class_option :channel,
27
+ :type => :string,
28
+ :required => false,
29
+ :desc => "Ember release channel Choose between 'release', 'beta' or 'canary'"
30
+ class_option :ember_only,
31
+ :type => :boolean,
32
+ :required => false,
33
+ :desc => "Only download Ember.",
34
+ :aliases => '--ember'
35
+ class_option :ember_data_only,
36
+ :type => :boolean,
37
+ :required => false,
38
+ :desc => "Only download ember-data",
39
+ :aliases => '--ember-data'
40
+ class_option :tag,
41
+ :type => :string,
42
+ :required => false,
43
+ :desc => "Download taged release use syntax v1.0.0-beta.3/ember-data & v1.0.0-rc.8/ember"
44
+
45
+ def initialize(args = [], options = {}, config = {})
46
+ super(args, options, config)
47
+ check_options
48
+ process_options
49
+ end
50
+
11
51
 
12
- def fetch_ember
13
- if options.head?
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'
52
+ def ember
53
+ begin
54
+ unless options.ember_data_only?
55
+ get_ember_js_for(:development)
56
+ get_ember_js_for(:production)
57
+ end
58
+ rescue Thor::Error
59
+ say('WARNING: no ember files on this channel or tag' , :yellow)
16
60
  end
17
61
  end
18
62
 
19
- def fetch_ember_data
20
- if options.head?
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'
63
+ def ember_data
64
+ begin
65
+ unless options.ember_only?
66
+ get_ember_data_for(:development)
67
+ get_ember_data_for(:production)
68
+ end
69
+ rescue Thor::Error
70
+ say('WARNING: no ember-data files on this channel or tag' , :yellow)
23
71
  end
24
72
  end
25
73
 
26
74
  private
27
75
 
76
+
77
+ def get_ember_data_for(environment)
78
+ create_file "vendor/assets/ember/#{environment}/ember-data.js" do
79
+ fetch "#{base_url}/#{channel}/#{file_name_for('ember-data', environment)}", "vendor/assets/ember/#{environment}/ember-data.js"
80
+ end
81
+ end
82
+
83
+ def get_ember_js_for(environment)
84
+
85
+ create_file "vendor/assets/ember/#{environment}/ember.js" do
86
+ fetch "#{base_url}/#{channel}/#{file_name_for('ember', environment)}", "vendor/assets/ember/#{environment}/ember.js"
87
+ end
88
+ end
89
+
90
+ def file_name_for(component,environment)
91
+ case environment
92
+ when :production
93
+ "#{component}.min.js"
94
+ when :development
95
+ "#{component}.js"
96
+ end
97
+ end
98
+
99
+ def check_options
100
+ if options.head?
101
+ say('WARNING: --head option is deprecated in favor of --channel=cannary' , :yellow)
102
+ end
103
+ if options.head? && options.channel?
104
+ say 'ERROR: conflicting options. --head and --channel. Use either --head or --channel=<channel>', :red
105
+ raise ConflictingOptions
106
+ end
107
+ if options.channel? && !%w(release beta canary).include?(options[:channel])
108
+ say 'ERROR: channel can either be release, beta or canary', :red
109
+ raise InvalidChannel
110
+ end
111
+ if options.channel? && options.tag?
112
+ say 'ERROR: conflicting options. --tag and --channel. --tag is incompatible with other options', :red
113
+ raise ConflictingOptions
114
+ end
115
+ if options.head? && options.tag?
116
+ say 'ERROR: conflicting options. --tag and --head. --tag is incompatible with other options', :red
117
+ raise ConflictingOptions
118
+ end
119
+ if options.tag? && !(options.ember_only? || options.ember_data_only?)
120
+ say 'ERROR: insufficient options. --tag needs to be combined with eithe --ember or --ember-data', :red
121
+ raise InsufficientOptions
122
+ end
123
+ end
124
+
125
+ def process_options
126
+ if options.head?
127
+ @channel = :canary
128
+ end
129
+ if options.tag?
130
+ @channel = "tags/#{options.tag}"
131
+ end
132
+ end
133
+
134
+ def base_url
135
+ 'http://builds.emberjs.com'
136
+ end
137
+
138
+ def channel
139
+ if options.channel
140
+ @channel ||= options[:channel]
141
+ else
142
+ @channel ||= :release
143
+ end
144
+ end
145
+
146
+
28
147
  def fetch(from, to)
29
148
  message = "#{from} -> #{to}"
30
149
  say_status("downloading:", message , :green)
31
150
 
32
151
  uri = URI(from)
33
-
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")
152
+ output = StringIO.new
153
+ output.puts "// Fetched from: " + uri.to_s
154
+ output.puts "// Fetched on: " + Time.now.utc.iso8601.to_s
155
+ output.puts Net::HTTP.get(uri).force_encoding("UTF-8")
156
+ output.rewind
157
+ content = output.read
158
+ if content.include?('404')
159
+ say "ERROR: Error reading the content from the channel with url #{from}." , :red
160
+ raise raise Thor::Error
38
161
  end
162
+ content
39
163
  end
40
164
  end
41
165
  end
@@ -9,10 +9,13 @@ module Ember
9
9
 
10
10
  desc "Creates a new Ember.js template"
11
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"
13
+
12
14
 
13
15
 
14
16
  def create_template_files
15
- template 'template.handlebars', File.join('app/assets/javascripts/templates', class_path, "#{file_name}.handlebars")
17
+ file_path = File.join(ember_path, 'templates', class_path, "#{file_name}.handlebars")
18
+ template 'template.handlebars', file_path
16
19
  end
17
20
 
18
21
  end
@@ -1,8 +1,10 @@
1
1
  //= require ./store
2
+ //= require_tree ./mixins
2
3
  //= require_tree ./models
3
4
  //= require_tree ./controllers
4
5
  //= require_tree ./views
5
6
  //= require_tree ./helpers
7
+ //= require_tree ./components
6
8
  //= require_tree ./templates
7
9
  //= require ./router
8
10
  //= require_tree ./routes
@@ -3,6 +3,7 @@
3
3
  #= require_tree ./controllers
4
4
  #= require_tree ./views
5
5
  #= require_tree ./helpers
6
+ #= require_tree ./components
6
7
  #= require_tree ./templates
7
8
  #= require_tree ./routes
8
9
  #= require ./router
@@ -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
@@ -1,3 +1,4 @@
1
+ //= require jquery
1
2
  //= require handlebars
2
3
  //= require ember
3
4
  //= require ember-data
@@ -0,0 +1,8 @@
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()
@@ -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,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,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.%s'" % [application_name.camelize, attribute[:name].camelize]
8
+ else
9
+ "DS.attr '%s'" % attribute[:type]
10
+ end
11
+ %>
12
+ <% end -%>
@@ -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.ObjectController
@@ -0,0 +1,3 @@
1
+ # For more information see: http://emberjs.com/guides/routing/
2
+
3
+ class <%= application_name.camelize %>.<%= class_name.camelize %>Route extends Ember.Route
@@ -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,6 +1,7 @@
1
- // http://emberjs.com/guides/models/defining-a-store/
1
+ // http://emberjs.com/guides/models/using-the-store/
2
2
 
3
3
  <%= application_name.camelize %>.Store = DS.Store.extend({
4
- revision: 11,
5
- adapter: DS.RESTAdapter.create()
4
+ // Override the default adapter with the `DS.ActiveModelAdapter` which
5
+ // is built to work nicely with the ActiveModel::Serializers gem.
6
+ adapter: '_ams'
6
7
  });
@@ -1,6 +1,6 @@
1
- # http://emberjs.com/guides/models/defining-a-store/
1
+ # http://emberjs.com/guides/models/using-the-store/
2
2
 
3
3
  <%= application_name.camelize %>.Store = DS.Store.extend
4
- revision: 11
5
- adapter: DS.RESTAdapter.create()
6
-
4
+ # Override the default adapter with the `DS.ActiveModelAdapter` which
5
+ # is built to work nicely with the ActiveModel::Serializers gem.
6
+ adapter: '_ams'
@@ -0,0 +1,7 @@
1
+ # http://emberjs.com/guides/models/using-the-store/
2
+
3
+ class <%= application_name.camelize %>.Store extends DS.Store
4
+ # Override the default adapter with the `DS.ActiveModelAdapter` which
5
+ # is built to work nicely with the ActiveModel::Serializers gem.
6
+ adapter: '_ams'
7
+
@@ -0,0 +1,4 @@
1
+ # for more details see: http://emberjs.com/guides/views/
2
+
3
+ class <%= application_name.camelize %>.<%= class_name.camelize %>View extends Ember.View
4
+ templateName: '<%= handlebars_template_path %>'
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
5
- prerelease:
4
+ version: 0.14.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Keith Pitt
@@ -12,200 +11,232 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2013-06-23 00:00:00.000000000 Z
14
+ date: 2013-11-04 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: execjs
19
18
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
19
  requirements:
22
- - - ! '>='
20
+ - - '>='
23
21
  - !ruby/object:Gem::Version
24
22
  version: '1.2'
25
23
  type: :runtime
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
- - - ! '>='
27
+ - - '>='
31
28
  - !ruby/object:Gem::Version
32
29
  version: '1.2'
33
30
  - !ruby/object:Gem::Dependency
34
31
  name: railties
35
32
  requirement: !ruby/object:Gem::Requirement
36
- none: false
37
33
  requirements:
38
- - - ! '>='
34
+ - - '>='
39
35
  - !ruby/object:Gem::Version
40
36
  version: '3.1'
41
37
  type: :runtime
42
38
  prerelease: false
43
39
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
40
  requirements:
46
- - - ! '>='
41
+ - - '>='
47
42
  - !ruby/object:Gem::Version
48
43
  version: '3.1'
49
44
  - !ruby/object:Gem::Dependency
50
45
  name: active_model_serializers
51
46
  requirement: !ruby/object:Gem::Requirement
52
- none: false
53
47
  requirements:
54
- - - ! '>='
48
+ - - '>='
55
49
  - !ruby/object:Gem::Version
56
50
  version: '0'
57
51
  type: :runtime
58
52
  prerelease: false
59
53
  version_requirements: !ruby/object:Gem::Requirement
60
- none: false
61
54
  requirements:
62
- - - ! '>='
55
+ - - '>='
63
56
  - !ruby/object:Gem::Version
64
57
  version: '0'
65
58
  - !ruby/object:Gem::Dependency
66
59
  name: barber
67
60
  requirement: !ruby/object:Gem::Requirement
68
- none: false
69
61
  requirements:
70
- - - ! '>='
62
+ - - '>='
71
63
  - !ruby/object:Gem::Version
72
64
  version: 0.4.1
73
65
  type: :runtime
74
66
  prerelease: false
75
67
  version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
68
  requirements:
78
- - - ! '>='
69
+ - - '>='
79
70
  - !ruby/object:Gem::Version
80
71
  version: 0.4.1
81
72
  - !ruby/object:Gem::Dependency
82
73
  name: ember-source
83
74
  requirement: !ruby/object:Gem::Requirement
84
- none: false
85
75
  requirements:
86
- - - ! '>='
76
+ - - '>='
87
77
  - !ruby/object:Gem::Version
88
78
  version: '0'
89
79
  type: :runtime
90
80
  prerelease: false
91
81
  version_requirements: !ruby/object:Gem::Requirement
92
- none: false
93
82
  requirements:
94
- - - ! '>='
83
+ - - '>='
95
84
  - !ruby/object:Gem::Version
96
85
  version: '0'
97
86
  - !ruby/object:Gem::Dependency
98
87
  name: handlebars-source
99
88
  requirement: !ruby/object:Gem::Requirement
100
- none: false
101
89
  requirements:
102
- - - ! '>='
90
+ - - '>='
103
91
  - !ruby/object:Gem::Version
104
92
  version: '0'
105
93
  type: :runtime
106
94
  prerelease: false
107
95
  version_requirements: !ruby/object:Gem::Requirement
108
- none: false
109
96
  requirements:
110
- - - ! '>='
97
+ - - '>='
111
98
  - !ruby/object:Gem::Version
112
99
  version: '0'
113
100
  - !ruby/object:Gem::Dependency
114
101
  name: ember-data-source
115
102
  requirement: !ruby/object:Gem::Requirement
116
- none: false
117
103
  requirements:
118
- - - ! '>='
104
+ - - '>='
119
105
  - !ruby/object:Gem::Version
120
106
  version: '0'
121
107
  type: :runtime
122
108
  prerelease: false
123
109
  version_requirements: !ruby/object:Gem::Requirement
124
- none: false
125
110
  requirements:
126
- - - ! '>='
111
+ - - '>='
127
112
  - !ruby/object:Gem::Version
128
113
  version: '0'
114
+ - !ruby/object:Gem::Dependency
115
+ name: jquery-rails
116
+ requirement: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>='
119
+ - !ruby/object:Gem::Version
120
+ version: 1.0.17
121
+ type: :runtime
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: 1.0.17
129
128
  - !ruby/object:Gem::Dependency
130
129
  name: bundler
131
130
  requirement: !ruby/object:Gem::Requirement
132
- none: false
133
131
  requirements:
134
- - - ! '>='
132
+ - - '>='
135
133
  - !ruby/object:Gem::Version
136
134
  version: 1.2.2
137
135
  type: :development
138
136
  prerelease: false
139
137
  version_requirements: !ruby/object:Gem::Requirement
140
- none: false
141
138
  requirements:
142
- - - ! '>='
139
+ - - '>='
143
140
  - !ruby/object:Gem::Version
144
141
  version: 1.2.2
145
142
  - !ruby/object:Gem::Dependency
146
143
  name: appraisal
147
144
  requirement: !ruby/object:Gem::Requirement
148
- none: false
149
145
  requirements:
150
- - - ! '>='
146
+ - - '>='
151
147
  - !ruby/object:Gem::Version
152
148
  version: '0'
153
149
  type: :development
154
150
  prerelease: false
155
151
  version_requirements: !ruby/object:Gem::Requirement
156
- none: false
157
152
  requirements:
158
- - - ! '>='
153
+ - - '>='
159
154
  - !ruby/object:Gem::Version
160
155
  version: '0'
161
156
  - !ruby/object:Gem::Dependency
162
157
  name: tzinfo
163
158
  requirement: !ruby/object:Gem::Requirement
164
- none: false
165
159
  requirements:
166
- - - ! '>='
160
+ - - '>='
167
161
  - !ruby/object:Gem::Version
168
162
  version: '0'
169
163
  type: :development
170
164
  prerelease: false
171
165
  version_requirements: !ruby/object:Gem::Requirement
172
- none: false
173
166
  requirements:
174
- - - ! '>='
167
+ - - '>='
175
168
  - !ruby/object:Gem::Version
176
169
  version: '0'
177
170
  - !ruby/object:Gem::Dependency
178
171
  name: ember-source
179
172
  requirement: !ruby/object:Gem::Requirement
180
- none: false
181
173
  requirements:
182
- - - '='
174
+ - - ~>
183
175
  - !ruby/object:Gem::Version
184
- version: 1.0.0.rc6
176
+ version: 1.1.0
185
177
  type: :development
186
178
  prerelease: false
187
179
  version_requirements: !ruby/object:Gem::Requirement
188
- none: false
189
180
  requirements:
190
- - - '='
181
+ - - ~>
191
182
  - !ruby/object:Gem::Version
192
- version: 1.0.0.rc6
183
+ version: 1.1.0
193
184
  - !ruby/object:Gem::Dependency
194
185
  name: handlebars-source
195
186
  requirement: !ruby/object:Gem::Requirement
196
- none: false
197
187
  requirements:
198
- - - '='
188
+ - - ~>
189
+ - !ruby/object:Gem::Version
190
+ version: 1.0.0
191
+ type: :development
192
+ prerelease: false
193
+ version_requirements: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - ~>
196
+ - !ruby/object:Gem::Version
197
+ version: 1.0.0
198
+ - !ruby/object:Gem::Dependency
199
+ name: sprockets-rails
200
+ requirement: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - '>='
203
+ - !ruby/object:Gem::Version
204
+ version: '0'
205
+ type: :development
206
+ prerelease: false
207
+ version_requirements: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - '>='
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ - !ruby/object:Gem::Dependency
213
+ name: vcr
214
+ requirement: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - '>='
217
+ - !ruby/object:Gem::Version
218
+ version: '0'
219
+ type: :development
220
+ prerelease: false
221
+ version_requirements: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - '>='
224
+ - !ruby/object:Gem::Version
225
+ version: '0'
226
+ - !ruby/object:Gem::Dependency
227
+ name: webmock
228
+ requirement: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - <
199
231
  - !ruby/object:Gem::Version
200
- version: 1.0.0.rc4
232
+ version: 1.14.0
201
233
  type: :development
202
234
  prerelease: false
203
235
  version_requirements: !ruby/object:Gem::Requirement
204
- none: false
205
236
  requirements:
206
- - - '='
237
+ - - <
207
238
  - !ruby/object:Gem::Version
208
- version: 1.0.0.rc4
239
+ version: 1.14.0
209
240
  description:
210
241
  email:
211
242
  - me@keithpitt.com
@@ -222,6 +253,7 @@ files:
222
253
  - lib/ember-rails.rb
223
254
  - lib/ember_rails.rb
224
255
  - lib/generators/ember/bootstrap_generator.rb
256
+ - lib/generators/ember/component_generator.rb
225
257
  - lib/generators/ember/controller_generator.rb
226
258
  - lib/generators/ember/generator_helpers.rb
227
259
  - lib/generators/ember/install_generator.rb
@@ -233,48 +265,61 @@ files:
233
265
  - lib/generators/ember/view_generator.rb
234
266
  - lib/generators/templates/app.js
235
267
  - lib/generators/templates/app.js.coffee
268
+ - lib/generators/templates/app.js.em
236
269
  - lib/generators/templates/application.handlebars
237
270
  - lib/generators/templates/application.js
238
271
  - lib/generators/templates/application.js.coffee
272
+ - lib/generators/templates/application.js.em
239
273
  - lib/generators/templates/array_controller.js
240
274
  - lib/generators/templates/array_controller.js.coffee
275
+ - lib/generators/templates/array_controller.js.em
276
+ - lib/generators/templates/component.js
277
+ - lib/generators/templates/component.js.coffee
278
+ - lib/generators/templates/component.js.em
279
+ - lib/generators/templates/component.template.handlebars
241
280
  - lib/generators/templates/controller.js
242
281
  - lib/generators/templates/controller.js.coffee
282
+ - lib/generators/templates/controller.js.em
243
283
  - lib/generators/templates/model.js
244
284
  - lib/generators/templates/model.js.coffee
285
+ - lib/generators/templates/model.js.em
245
286
  - lib/generators/templates/object_controller.js
246
287
  - lib/generators/templates/object_controller.js.coffee
288
+ - lib/generators/templates/object_controller.js.em
247
289
  - lib/generators/templates/route.js
248
290
  - lib/generators/templates/route.js.coffee
291
+ - lib/generators/templates/route.js.em
249
292
  - lib/generators/templates/router.js
250
293
  - lib/generators/templates/router.js.coffee
294
+ - lib/generators/templates/router.js.em
251
295
  - lib/generators/templates/store.js
252
296
  - lib/generators/templates/store.js.coffee
297
+ - lib/generators/templates/store.js.em
253
298
  - lib/generators/templates/template.handlebars
254
299
  - lib/generators/templates/view.js
255
300
  - lib/generators/templates/view.js.coffee
301
+ - lib/generators/templates/view.js.em
256
302
  homepage: https://github.com/emberjs/ember-rails
257
303
  licenses: []
304
+ metadata: {}
258
305
  post_install_message:
259
306
  rdoc_options: []
260
307
  require_paths:
261
308
  - lib
262
309
  required_ruby_version: !ruby/object:Gem::Requirement
263
- none: false
264
310
  requirements:
265
- - - ! '>='
311
+ - - '>='
266
312
  - !ruby/object:Gem::Version
267
313
  version: '0'
268
314
  required_rubygems_version: !ruby/object:Gem::Requirement
269
- none: false
270
315
  requirements:
271
- - - ! '>='
316
+ - - '>='
272
317
  - !ruby/object:Gem::Version
273
318
  version: '0'
274
319
  requirements: []
275
320
  rubyforge_project:
276
- rubygems_version: 1.8.25
321
+ rubygems_version: 2.1.9
277
322
  signing_key:
278
- specification_version: 3
323
+ specification_version: 4
279
324
  summary: Ember for Rails 3.1+
280
325
  test_files: []