ember-big_project 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +208 -0
  6. data/Rakefile +1 -0
  7. data/ember-big_project.gemspec +25 -0
  8. data/lib/ember/big_project.rb +7 -0
  9. data/lib/ember/big_project/version.rb +5 -0
  10. data/lib/generators/ember_proj/bootstrap_generator.rb +291 -0
  11. data/lib/generators/ember_proj/gem_helper.rb +48 -0
  12. data/lib/generators/ember_proj/templates/app/app_loader.js.coffee +16 -0
  13. data/lib/generators/ember_proj/templates/app/authentication.js.coffee +1 -0
  14. data/lib/generators/ember_proj/templates/app/config.js.coffee +1 -0
  15. data/lib/generators/ember_proj/templates/app/config/app.js.coffee +0 -0
  16. data/lib/generators/ember_proj/templates/app/config/display.js.coffee +0 -0
  17. data/lib/generators/ember_proj/templates/app/config/logging.js.coffee +0 -0
  18. data/lib/generators/ember_proj/templates/app/controllers.js.coffee +3 -0
  19. data/lib/generators/ember_proj/templates/app/helpers.js.coffee +1 -0
  20. data/lib/generators/ember_proj/templates/app/lib.js.coffee +1 -0
  21. data/lib/generators/ember_proj/templates/app/mixins.js.coffee +1 -0
  22. data/lib/generators/ember_proj/templates/app/models.js.coffee +3 -0
  23. data/lib/generators/ember_proj/templates/app/routes.js.coffee +4 -0
  24. data/lib/generators/ember_proj/templates/app/state_managers.js.coffee +1 -0
  25. data/lib/generators/ember_proj/templates/app/stores.js.coffee +1 -0
  26. data/lib/generators/ember_proj/templates/app/templates.js.coffee +1 -0
  27. data/lib/generators/ember_proj/templates/app/views.js.coffee +3 -0
  28. data/lib/generators/ember_proj/templates/application.js.coffee +20 -0
  29. data/vendor/assets/javascripts/ember-data-validations.js +68 -0
  30. data/vendor/assets/javascripts/ember-easyForm.js +290 -0
  31. data/vendor/assets/javascripts/ember-formBuilder.js +32 -0
  32. data/vendor/assets/javascripts/ember-validations.js +581 -0
  33. metadata +118 -0
@@ -0,0 +1,48 @@
1
+ module EmberProj
2
+ module GemHelper
3
+ def bundle_gems!
4
+ bundle_command 'install'
5
+ end
6
+
7
+ # File railties/lib/rails/generators/app_base.rb, line 241
8
+ def bundle_command(command)
9
+ say_status :run, "bundle #{command}"
10
+
11
+ # We are going to shell out rather than invoking Bundler::CLI.new(command)
12
+ # because `rails new` loads the Thor gem and on the other hand bundler uses
13
+ # its own vendored Thor, which could be a different version. Running both
14
+ # things in the same process is a recipe for a night with paracetamol.
15
+ #
16
+ # We use backticks and #print here instead of vanilla #system because it
17
+ # is easier to silence stdout in the existing test suite this way. The
18
+ # end-user gets the bundler commands called anyway, so no big deal.
19
+ #
20
+ # Thanks to James Tucker for the Gem tricks involved in this call.
21
+ print %x[#{Gem.ruby} -rubygems "#{ruby_gems}" #{command}]
22
+ end
23
+
24
+ def ruby_gems
25
+ Gem.bin_path('bundler', 'bundle')
26
+ end
27
+
28
+ def has_any_gem? *names
29
+ names.flatten.any? {|name| has_gem? name }
30
+ end
31
+
32
+ def has_all_gems? *names
33
+ names.flatten.all? {|name| has_gem? name }
34
+ end
35
+
36
+ def has_gem? name
37
+ gemfile_content =~ /gem\s+('|")#{name}/
38
+ end
39
+
40
+ def gemfile_content
41
+ @gemfile_content ||= gemfile.read
42
+ end
43
+
44
+ def gemfile
45
+ @gemfile ||= File.open Rails.root.join('Gemfile'), 'r'
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,16 @@
1
+ #= require_self
2
+
3
+ #= require_tree lib
4
+ #= require_tree mixins
5
+ #= require_tree helpers
6
+ #= require_tree config
7
+
8
+ #= require stores
9
+ #= require models
10
+ #= require controllers
11
+ #= require views
12
+ #= require templates
13
+
14
+ #= require state_managers
15
+ #= require authentication
16
+ #= require router
@@ -0,0 +1 @@
1
+ #= require_tree authentication
@@ -0,0 +1 @@
1
+ # require_tree config
@@ -0,0 +1,3 @@
1
+ #= require_tree controllers/mixins
2
+ #= require_tree controllers
3
+ #= require_tree controllers/extensions
@@ -0,0 +1 @@
1
+ #= require_tree helpers
@@ -0,0 +1 @@
1
+ # require_tree lib
@@ -0,0 +1 @@
1
+ # require_tree mixins
@@ -0,0 +1,3 @@
1
+ #= require_tree models/mixins
2
+ #= require_tree models
3
+ #= require_tree models/extensions
@@ -0,0 +1,4 @@
1
+ #= require_tree routes/mixins
2
+ #= require_tree routes
3
+ #= require_tree routes/extensions
4
+ #= require_tree routes/shortcuts
@@ -0,0 +1 @@
1
+ #= require_tree state_managers
@@ -0,0 +1 @@
1
+ #= require_tree stores
@@ -0,0 +1 @@
1
+ #= require_tree templates
@@ -0,0 +1,3 @@
1
+ #= require_tree views/mixins
2
+ #= require_tree views
3
+ #= require_tree views/extensions
@@ -0,0 +1,20 @@
1
+ #= require modernizr
2
+ #= require jquery
3
+ #= require handlebars
4
+ #= require ruby
5
+ #= require ember
6
+ #= require ember-data
7
+ #= require ember-data-validations
8
+ #= require ember-formBuilder
9
+ #= require bootstrap
10
+
11
+ #= require app/app_loader
12
+
13
+ #= require rails.validations
14
+ #= require rails.validations.ember
15
+
16
+ window.App = Ember.Application.create LOG_TRANSITIONS: true
17
+
18
+ # Defer App readiness until it should be advanced for either
19
+ # testing or production.
20
+ App.deferReadiness()
@@ -0,0 +1,68 @@
1
+ var get = Ember.get;
2
+
3
+ DS.DefaultValidators = {
4
+ required: function (value, meta) {
5
+ if (meta.options.required == true) {
6
+ if (!value || 0 === value.length) {
7
+ return "'%@' attribute is required".fmt(meta.name);
8
+ }
9
+ } else return '';
10
+ }
11
+ };
12
+
13
+ DS.Validation = Ember.Object.create({
14
+ init: function () {
15
+ var defaults = DS.DefaultValidators;
16
+ this.validators = [];
17
+ for (var validator in defaults) {
18
+ if (defaults.hasOwnProperty(validator)) {
19
+ this.validators.push(defaults[validator]);
20
+ }
21
+ }
22
+ },
23
+ register: function (validator) {
24
+ this.validators.push(validator);
25
+ },
26
+ validate: function (value, meta) {
27
+ var length = this.validators.length;
28
+ for (var i = 0; i < length; i++) {
29
+ var validator = this.validators[i];
30
+ var error = validator(value, meta);
31
+ if (error) return error;
32
+ }
33
+ return '';
34
+ }
35
+ });
36
+
37
+ DS.Model.reopen({
38
+ staleValidation: false,
39
+
40
+ validateProperty: function (name) {
41
+ var meta = get(this.constructor, 'attributes').get(name);
42
+ var value = get(this, name);
43
+ var error = DS.Validation.validate(value, meta);
44
+ if (error) {
45
+ this.errors = this.errors || {};
46
+ this.errors[name] = error;
47
+ }
48
+ return error;
49
+ },
50
+
51
+ validate: function () {
52
+ this.eachAttribute(function (name) {
53
+ this.validateProperty(name);
54
+ }, this);
55
+ return this.errors;
56
+ },
57
+
58
+ didChangeState: function () {
59
+ var state = get(this, 'stateManager.currentState');
60
+ if (state.name == 'uncommitted') {
61
+ if (state.parentState.name == 'updated') {
62
+ if (this.validate()) {
63
+ this.send('becameInvalid');
64
+ }
65
+ }
66
+ }
67
+ }.observes('stateManager.currentPath')
68
+ });
@@ -0,0 +1,290 @@
1
+ // Last commit: 16f3486 (2013-03-04 21:19:48 -0500)
2
+
3
+
4
+ (function() {
5
+ Ember.EasyForm = Ember.Namespace.create({
6
+ VERSION: '0.3.0'
7
+ });
8
+
9
+ })();
10
+
11
+
12
+
13
+ (function() {
14
+ Ember.Handlebars.registerHelper('errorField', function(property, options) {
15
+ if (this.get('errors')) {
16
+ options.hash.property = property;
17
+ return Ember.Handlebars.helpers.view.call(this, Ember.EasyForm.Error, options);
18
+ }
19
+ });
20
+
21
+ })();
22
+
23
+
24
+
25
+ (function() {
26
+ Ember.Handlebars.registerBoundHelper('formFor', function(object, options) {
27
+ return Ember.Handlebars.helpers.view.call(object, Ember.EasyForm.Form, options);
28
+ });
29
+
30
+ })();
31
+
32
+
33
+
34
+ (function() {
35
+ Ember.Handlebars.registerHelper('input', function(property, options) {
36
+ options.hash.inputOptions = Ember.copy(options.hash);
37
+ options.hash.property = property;
38
+ options.hash.isBlock = !!(options.fn);
39
+ return Ember.Handlebars.helpers.view.call(this, Ember.EasyForm.Input, options);
40
+ });
41
+
42
+ })();
43
+
44
+
45
+
46
+ (function() {
47
+ Ember.Handlebars.registerHelper('inputField', function(property, options) {
48
+ var context = this,
49
+ propertyType = function(property) {
50
+ try {
51
+ return context.constructor.metaForProperty(property);
52
+ } catch(e) {
53
+ return null;
54
+ }
55
+ };
56
+
57
+ options.hash.valueBinding = property;
58
+
59
+ if (options.hash.as === 'text') {
60
+ return Ember.Handlebars.helpers.view.call(context, Ember.TextArea, options);
61
+ } else {
62
+ if (!options.hash.type) {
63
+ if (property.match(/password/)) {
64
+ options.hash.type = 'password';
65
+ } else if (property.match(/email/)) {
66
+ options.hash.type = 'email';
67
+ } else {
68
+ if (propertyType(context, property) === 'number' || typeof(context.get(property)) === 'number') {
69
+ options.hash.type = 'number';
70
+ } else if (propertyType(context, property) === 'date' || (context.get(property) !== undefined && context.get(property).constructor === Date)) {
71
+ options.hash.type = 'date';
72
+ }
73
+ }
74
+ }
75
+ return Ember.Handlebars.helpers.view.call(context, Ember.TextField, options);
76
+ }
77
+ });
78
+
79
+ })();
80
+
81
+
82
+
83
+ (function() {
84
+ Ember.Handlebars.registerHelper('labelField', function(property, options) {
85
+ options.hash.property = property;
86
+ return Ember.Handlebars.helpers.view.call(this, Ember.EasyForm.Label, options);
87
+ });
88
+
89
+ })();
90
+
91
+
92
+
93
+ (function() {
94
+ Ember.Handlebars.registerHelper('submit', function(value, options) {
95
+ if (typeof(value) === 'object') {
96
+ options = value;
97
+ value = undefined;
98
+ }
99
+ options.hash.context = this;
100
+ options.hash.value = value || 'Submit';
101
+ return Ember.Handlebars.helpers.view.call(this, Ember.EasyForm.Submit, options);
102
+ });
103
+
104
+ })();
105
+
106
+
107
+
108
+ (function() {
109
+
110
+ })();
111
+
112
+
113
+
114
+ (function() {
115
+ Ember.EasyForm.Error = Ember.View.extend({
116
+ tagName: 'span',
117
+ classNames: ['error'],
118
+ init: function() {
119
+ var watchFunc;
120
+ this._super();
121
+
122
+ // TODO: un-fuglify this
123
+ watchFunc = {};
124
+ watchFunc[''+this.property+'Watch'] = function() {
125
+ if (typeof(this.get('controller.errors.'+this.property)) === 'string') {
126
+ return (this.get('controller.errors.'+this.property));
127
+ } else {
128
+ return (this.get('controller.errors.'+this.property) || [])[0];
129
+ }
130
+ }.property('controller.content.errors.'+this.property);
131
+ this.reopen(watchFunc);
132
+
133
+ this.set('template', Ember.Handlebars.compile('{{view.'+this.property+'Watch}}'));
134
+ }
135
+ });
136
+
137
+ })();
138
+
139
+
140
+
141
+ (function() {
142
+ Ember.EasyForm.Form = Ember.View.extend({
143
+ tagName: 'form',
144
+ attributeBindings: ['novalidate'],
145
+ novalidate: 'novalidate',
146
+ submit: function(event) {
147
+ var object = this.get('context').get('content'), _this = this;
148
+
149
+ if (event) {
150
+ event.preventDefault();
151
+ }
152
+
153
+ if (object.validate === undefined) {
154
+ this.get('controller').send('submit');
155
+ } else {
156
+ object.validate().then(function() {
157
+ if (object.get('isValid') === true) {
158
+ _this.get('controller').send('submit');
159
+ }
160
+ });
161
+ }
162
+ }
163
+ });
164
+
165
+ })();
166
+
167
+
168
+
169
+ (function() {
170
+ Ember.EasyForm.Input = Ember.View.extend({
171
+ init: function() {
172
+ this._super();
173
+ if (!this.isBlock) {
174
+ this.set('template', Ember.Handlebars.compile(this.fieldsForInput()));
175
+ }
176
+ if(this.get('context').get('errors') !== undefined) {
177
+ this.reopen({
178
+ error: function() {
179
+ return this.get('context').get('errors').get(this.property) !== undefined;
180
+ }.property('context.errors.'+this.property)
181
+ });
182
+ }
183
+ },
184
+ tagName: 'div',
185
+ classNames: ['input', 'string'],
186
+ classNameBindings: ['error:fieldWithErrors'],
187
+ fieldsForInput: function() {
188
+ return this.labelField()+this.inputField()+this.errorField();
189
+ },
190
+ labelField: function() {
191
+ var options = this.label ? 'text="'+this.label+'"' : '';
192
+ return '{{labelField '+this.property+' '+options+'}}';
193
+ },
194
+ inputField: function() {
195
+ var options = '', key, inputOptions = ['type', 'placeholder'];
196
+ for (var i = 0; i < inputOptions.length; i++) {
197
+ key = inputOptions[i];
198
+ if (this[key]) {
199
+ if (typeof(this[key]) === 'boolean') {
200
+ this[key] = key;
201
+ }
202
+ options = options.concat(''+key+'="'+this[inputOptions[i]]+'"');
203
+ }
204
+ }
205
+
206
+ options.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
207
+
208
+ return '{{inputField '+this.property+' '+options+'}}';
209
+ },
210
+ errorField: function() {
211
+ var options = '';
212
+ return '{{errorField '+this.property+' '+options+'}}';
213
+ },
214
+ focusOut: function() {
215
+ if (this.get('context').get('content').validate) {
216
+ this.get('context').get('content').validate(this.property);
217
+ }
218
+ }
219
+ });
220
+
221
+ })();
222
+
223
+
224
+
225
+ (function() {
226
+ Ember.EasyForm.Label = Ember.View.extend({
227
+ tagName: 'label',
228
+ init: function() {
229
+ this.set('template', this.renderText());
230
+ },
231
+ renderText: function() {
232
+ return Ember.Handlebars.compile(this.text || this.property.underscore().split('_').join(' ').capitalize());
233
+ }
234
+ });
235
+
236
+ })();
237
+
238
+
239
+
240
+ (function() {
241
+ Ember.EasyForm.Submit = Ember.View.extend({
242
+ tagName: 'input',
243
+ attributeBindings: ['type', 'value'],
244
+ type: 'submit',
245
+ init: function() {
246
+ this.set('value', this.value);
247
+ },
248
+ onClick: function() {
249
+ if (this.get('context').validate()) {
250
+ this.get('controller').send('submit');
251
+ }
252
+ }
253
+ });
254
+
255
+ })();
256
+
257
+
258
+
259
+ (function() {
260
+
261
+ })();
262
+
263
+
264
+
265
+ (function() {
266
+ Ember.TEMPLATES['easyForm/input'] = Ember.Handlebars.compile('<label {{bindAttr for="labelFor"}}>{{labelText}}</label>');
267
+
268
+ })();
269
+
270
+
271
+
272
+ (function() {
273
+
274
+ })();
275
+
276
+
277
+
278
+ (function() {
279
+ Ember.EasyForm.objectNameFor = function(object) {
280
+ var constructorArray = object.constructor.toString().split('.');
281
+ return constructorArray[constructorArray.length - 1].underscore();
282
+ };
283
+
284
+ })();
285
+
286
+
287
+
288
+ (function() {
289
+
290
+ })();