booster 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. data/.gitignore +5 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +106 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +174 -0
  6. data/Rakefile +7 -0
  7. data/booster.gemspec +24 -0
  8. data/booster.tmbundle/Snippets/untitled.tmSnippet +14 -0
  9. data/booster.tmbundle/Syntaxes/Booster.tmLanguage +46 -0
  10. data/booster.tmbundle/info.plist +10 -0
  11. data/lib/assets/javascripts/booster-core.js +5 -0
  12. data/lib/assets/javascripts/booster-support.js +1 -0
  13. data/lib/assets/javascripts/booster.js +2 -0
  14. data/lib/assets/javascripts/booster/collection.js.boost +1 -0
  15. data/lib/assets/javascripts/booster/model.js.boost +30 -0
  16. data/lib/assets/javascripts/booster/router.js.boost +107 -0
  17. data/lib/assets/javascripts/booster/support/binding.js.boost +1 -0
  18. data/lib/assets/javascripts/booster/support/helpers.js.boost +109 -0
  19. data/lib/assets/javascripts/booster/support/i18n.js.boost +136 -0
  20. data/lib/assets/javascripts/booster/support/observer.js.boost +81 -0
  21. data/lib/assets/javascripts/booster/support/schema.js.boost +117 -0
  22. data/lib/assets/javascripts/booster/view.js.boost +45 -0
  23. data/lib/assets/javascripts/booster/views/composite.js.boost +59 -0
  24. data/lib/assets/javascripts/booster/views/layout.js.boost +94 -0
  25. data/lib/booster.rb +7 -0
  26. data/lib/booster/engine.rb +8 -0
  27. data/lib/booster/handlebars.rb +50 -0
  28. data/lib/booster/template.rb +59 -0
  29. data/lib/booster/version.rb +3 -0
  30. data/test/booster/tilt_test.rb +35 -0
  31. data/test/dummy/Rakefile +7 -0
  32. data/test/dummy/app/assets/javascripts/application.js.boost +18 -0
  33. data/test/dummy/app/assets/javascripts/booster/support/helpers_spec.js.boost +69 -0
  34. data/test/dummy/app/assets/javascripts/booster/support/i18n_spec.js.boost +0 -0
  35. data/test/dummy/app/assets/javascripts/booster/support/observer_spec.js.boost +56 -0
  36. data/test/dummy/app/assets/javascripts/booster/support/router_spec.js.boost +19 -0
  37. data/test/dummy/app/assets/javascripts/booster/support/schema_spec.js.boost +79 -0
  38. data/test/dummy/app/assets/javascripts/booster/views/layout_spec.js.boost +30 -0
  39. data/test/dummy/app/controllers/application_controller.rb +7 -0
  40. data/test/dummy/app/views/layouts/application.html.erb +29 -0
  41. data/test/dummy/config.ru +4 -0
  42. data/test/dummy/config/application.rb +30 -0
  43. data/test/dummy/config/boot.rb +10 -0
  44. data/test/dummy/config/environment.rb +5 -0
  45. data/test/dummy/config/environments/development.rb +27 -0
  46. data/test/dummy/config/environments/production.rb +29 -0
  47. data/test/dummy/config/environments/test.rb +34 -0
  48. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  49. data/test/dummy/config/initializers/inflections.rb +10 -0
  50. data/test/dummy/config/initializers/mime_types.rb +5 -0
  51. data/test/dummy/config/initializers/secret_token.rb +7 -0
  52. data/test/dummy/config/initializers/session_store.rb +8 -0
  53. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  54. data/test/dummy/config/locales/en.yml +5 -0
  55. data/test/dummy/config/routes.rb +3 -0
  56. data/test/dummy/public/404.html +26 -0
  57. data/test/dummy/public/422.html +26 -0
  58. data/test/dummy/public/500.html +26 -0
  59. data/test/dummy/public/favicon.ico +0 -0
  60. data/test/dummy/script/rails +6 -0
  61. data/test/test_helper.rb +4 -0
  62. data/vendor/assets/javascripts/backbone.js +1158 -0
  63. data/vendor/assets/javascripts/handlebars-helpers.js +56 -0
  64. data/vendor/assets/javascripts/handlebars-vm.js +191 -0
  65. data/vendor/assets/javascripts/handlebars.js +1561 -0
  66. data/vendor/assets/javascripts/jasmine-html.js +190 -0
  67. data/vendor/assets/javascripts/jasmine-jquery.js +288 -0
  68. data/vendor/assets/javascripts/jasmine.js +2471 -0
  69. data/vendor/assets/javascripts/stitch.js +57 -0
  70. data/vendor/assets/javascripts/underscore.js +981 -0
  71. data/vendor/assets/stylesheets/jasmine.css +166 -0
  72. metadata +172 -0
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ pkg/*
4
+ test/dummy/tmp
5
+ test/dummy/log/*
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Gem dependencies specified in booster.gemspec
4
+ gemspec
5
+
6
+ # jquery-rails is used by the dummy application
7
+ gem 'jquery-rails'
@@ -0,0 +1,106 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ booster (0.0.1)
5
+ execjs
6
+ tilt
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.1.3)
12
+ actionpack (= 3.1.3)
13
+ mail (~> 2.3.0)
14
+ actionpack (3.1.3)
15
+ activemodel (= 3.1.3)
16
+ activesupport (= 3.1.3)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ i18n (~> 0.6)
20
+ rack (~> 1.3.5)
21
+ rack-cache (~> 1.1)
22
+ rack-mount (~> 0.8.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.0.3)
25
+ activemodel (3.1.3)
26
+ activesupport (= 3.1.3)
27
+ builder (~> 3.0.0)
28
+ i18n (~> 0.6)
29
+ activerecord (3.1.3)
30
+ activemodel (= 3.1.3)
31
+ activesupport (= 3.1.3)
32
+ arel (~> 2.2.1)
33
+ tzinfo (~> 0.3.29)
34
+ activeresource (3.1.3)
35
+ activemodel (= 3.1.3)
36
+ activesupport (= 3.1.3)
37
+ activesupport (3.1.3)
38
+ multi_json (~> 1.0)
39
+ arel (2.2.1)
40
+ builder (3.0.0)
41
+ erubis (2.7.0)
42
+ execjs (1.2.12)
43
+ multi_json (~> 1.0)
44
+ hike (1.2.1)
45
+ i18n (0.6.0)
46
+ jquery-rails (1.0.19)
47
+ railties (~> 3.0)
48
+ thor (~> 0.14)
49
+ json (1.6.3)
50
+ libv8 (3.3.10.4)
51
+ mail (2.3.0)
52
+ i18n (>= 0.4.0)
53
+ mime-types (~> 1.16)
54
+ treetop (~> 1.4.8)
55
+ mime-types (1.17.2)
56
+ multi_json (1.0.4)
57
+ polyglot (0.3.3)
58
+ rack (1.3.5)
59
+ rack-cache (1.1)
60
+ rack (>= 0.4)
61
+ rack-mount (0.8.3)
62
+ rack (>= 1.0.0)
63
+ rack-ssl (1.3.2)
64
+ rack
65
+ rack-test (0.6.1)
66
+ rack (>= 1.0)
67
+ rails (3.1.3)
68
+ actionmailer (= 3.1.3)
69
+ actionpack (= 3.1.3)
70
+ activerecord (= 3.1.3)
71
+ activeresource (= 3.1.3)
72
+ activesupport (= 3.1.3)
73
+ bundler (~> 1.0)
74
+ railties (= 3.1.3)
75
+ railties (3.1.3)
76
+ actionpack (= 3.1.3)
77
+ activesupport (= 3.1.3)
78
+ rack-ssl (~> 1.3.2)
79
+ rake (>= 0.8.7)
80
+ rdoc (~> 3.4)
81
+ thor (~> 0.14.6)
82
+ rake (0.9.2.2)
83
+ rdoc (3.11)
84
+ json (~> 1.4)
85
+ sprockets (2.0.3)
86
+ hike (~> 1.2)
87
+ rack (~> 1.0)
88
+ tilt (~> 1.1, != 1.3.0)
89
+ therubyracer (0.9.9)
90
+ libv8 (~> 3.3.10)
91
+ thor (0.14.6)
92
+ tilt (1.3.3)
93
+ treetop (1.4.10)
94
+ polyglot
95
+ polyglot (>= 0.3.1)
96
+ tzinfo (0.3.31)
97
+
98
+ PLATFORMS
99
+ ruby
100
+
101
+ DEPENDENCIES
102
+ booster!
103
+ jquery-rails
104
+ rails (~> 3.1.0)
105
+ rake
106
+ therubyracer
@@ -0,0 +1,20 @@
1
+ Copyright 2011 Redstone Handelsbolag
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,174 @@
1
+ > Note that this project is very new and hardly usable for anything.
2
+ > The documentation is just started and will be up-to-date before
3
+ > the end of 2011.
4
+
5
+ ## What is it?
6
+
7
+ Booster is a RubyGem with support for writing rich client applications using
8
+ Backbone.js and Handlebars.js. It integrates with the Rails Asset Pipeline
9
+ in a somewhat peculiar way:
10
+
11
+ * Booster assets have the `.boost` extension and can contain both
12
+ JavaScript and Handlebars markup __in the same file__. Handlebars templates
13
+ are compiled to JavaScript functions inline during processing. A TextMate
14
+ bundle supporting both languages in the same file is included.
15
+ * Each processed asset is wrapped in a CommonJS-like API inspired by
16
+ [this Gist](https://gist.github.com/1153919) so that each asset
17
+ essentially becomes a module closure that can be required by other modules.
18
+ * Booster assets support string interpolation as a language addon to JavaScript.
19
+
20
+ In addition to the Asset Pipeline processor, Booster supplies a set of
21
+ assets of its own that can be used in your applications. This includes
22
+ support functionality on top of Backbone.js and Handlebars.js that you
23
+ can choose to user or extend from rather than the stock Backbone types. This
24
+ is explained in more detail below, and can be opted out.
25
+
26
+ ## Usage
27
+
28
+ Include the Booster gem in your Gemfile:
29
+
30
+ **Gemfile:**
31
+
32
+ group :assets do
33
+ gem 'booster'
34
+ end
35
+
36
+ Require Booster in your application asset manifest which, in turn, will
37
+ include Underscore.js, Backbone.js, and Handlebars.js (only the runtime part),
38
+ on which Booster depends. You also need to require jQuery (supplied by Rails) before
39
+ requiring Booster (or have it included on page from CDN before including Booster).
40
+
41
+ **app/assets/javascript/application.js:**
42
+
43
+ //= require jquery
44
+ //= require booster
45
+
46
+ The `booster` asset is the full package, including additional functionality for Backbone
47
+ and Handlebars which you may not need. If you only need the core Booster functionality
48
+ which includes module support and the Backbone and Handlebars dependencies, require
49
+ the core asset instead:
50
+
51
+ **app/assets/javascript/application.js:**
52
+
53
+ //= require jquery
54
+ //= require booster-core
55
+
56
+ ## Example
57
+
58
+ The `app/assets/javascripts/views/user.js.boost` asset below exports
59
+ two Backbone views, `Show` and `Edit`, used for dealing with user models.
60
+ In this example, both views are defined in the same module and the templates used by the
61
+ views are defined in the same file, similar to what is
62
+ [possible in Sinatra](http://www.sinatrarb.com/intro#Inline%20Templates)
63
+
64
+ **app/assets/javascripts/views/user.js.boost:**
65
+
66
+ ```javascript
67
+ exports.Show = Backbone.View.extend({
68
+ /* ... */
69
+
70
+ render: function() {
71
+ $(this.el).html(show(this.model));
72
+ }
73
+
74
+ /* ... */
75
+ });
76
+
77
+ exports.Edit = Backbone.View.extend({
78
+ /* ... */
79
+
80
+ render: function() {
81
+ $(this.el).html(edit(this.model));
82
+ }
83
+
84
+ /* ... */
85
+ })
86
+
87
+ @@ show
88
+ <h2>{{firstName}} {{lastName}}</h2>
89
+ <pre>{{address}}</pre>
90
+ ...
91
+
92
+ @@ edit
93
+ <input name="firstName" value="{{firstName}}"/>
94
+ <textarea name="firstName">{{address}}</textarea>
95
+ ```
96
+
97
+ If templates are included in an asset they are to be placed at the bottom of the
98
+ file. Each template is compiled to a JavaScript function with the same name
99
+ as the `@@ identifier` and can be invoked directly from anywhere in the module as
100
+ can be seen in the `render()` functions above.
101
+
102
+ To use this module, say from a router, you require it like a regular CommonJS module.
103
+
104
+ **app/assets/javascripts/routers/user.js.boost:**
105
+
106
+ ```javascript
107
+ var views = require('../models/user');
108
+
109
+ exports = Backbone.Router.extend({
110
+ routes: {
111
+ '/users/:id': 'show',
112
+ '/users/:id/edit': 'edit'
113
+ }
114
+
115
+ show: function(id) {
116
+ var view = new views.Show({
117
+ model: /* load model */
118
+ });
119
+ /* add view to layout */
120
+ },
121
+
122
+ edit: function(id) {
123
+ var view = new views.Edit({
124
+ model: /* load model */
125
+ });
126
+ /* add view to layout */
127
+ }
128
+ });
129
+ ```
130
+
131
+ ## Support Functionality
132
+
133
+ Booster includes some support functionality that we often use in our own applications. In most cases
134
+ this comes in form of JavaScript mixins that you can use directly on your code as well as Handlebars
135
+ helpers that you can use from your templates.
136
+
137
+ This support is included by default in the `//= require booster` directive described in __Usage__ above.
138
+ So if you required the full Booster bundle you are set. If you have `//= require`'d `booster-core` which does
139
+ not include the extra support you can add the support on top of core:
140
+
141
+ **app/assets/javascript/application.js:**
142
+
143
+ //= require jquery
144
+ //= require booster-core
145
+ //= require booster-support
146
+
147
+ We might introduce additional Booster assets in the future which can be optionally required in the same way.
148
+
149
+ ### Schema
150
+
151
+ > To be described
152
+
153
+ ### I18N
154
+
155
+ > To be described
156
+
157
+ ## Rails 3 Generators
158
+
159
+ > To be described
160
+
161
+ We are working on a set of Rails 3 generators that can be used to speed up development. Using these
162
+ generators you can create models, views, and routers, or complete scaffolds using the following
163
+ commands:
164
+
165
+ > rails g booster:model Discussion
166
+ > rails g booster:view Discussion [index [show [edit]]]
167
+ > rails g booster:router Discussion
168
+ > rails g booster:scaffold Discussion
169
+
170
+ This will generate Booster modules for each type of artefact with a skeleton implementation to get
171
+ you going quickly. It will also generate specs based on the Jasmine BDD library. This not only gives
172
+ you a productivity boost but can also help establish a coding style in a project with many developers.
173
+ To customize the templates used when creating the artefacts, just fork Booster on GitHub and
174
+ edit the templates in `lib/generators` and include your updated Gem directly from GitHub in your Gemfile.
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ t.test_files = FileList['test/**/*_test.rb']
7
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'booster/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'booster'
7
+ s.version = Booster::VERSION.dup
8
+ s.authors = ['Redstone Handelsbolag']
9
+ s.email = ['support@redstone.eu']
10
+ s.homepage = 'http://github.com/gregerolsson/booster'
11
+ s.summary = 'Wrapper library for Backbone.js'
12
+ s.description = 'Integrates with Rails 3.x Asset Pipeline with some Backbone.js support'
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ['lib']
18
+
19
+ s.add_runtime_dependency 'execjs'
20
+ s.add_runtime_dependency 'tilt'
21
+ s.add_development_dependency 'rails', '~> 3.1.0'
22
+ s.add_development_dependency 'therubyracer'
23
+ s.add_development_dependency 'rake'
24
+ end
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>content</key>
6
+ <string>require('$1')</string>
7
+ <key>name</key>
8
+ <string>untitled</string>
9
+ <key>tabTrigger</key>
10
+ <string>re</string>
11
+ <key>uuid</key>
12
+ <string>6F743ED2-C24E-461D-937D-264A643D3724</string>
13
+ </dict>
14
+ </plist>
@@ -0,0 +1,46 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>fileTypes</key>
6
+ <array>
7
+ <string>boost</string>
8
+ </array>
9
+ <key>name</key>
10
+ <string>Booster</string>
11
+ <key>patterns</key>
12
+ <array>
13
+ <dict>
14
+ <key>begin</key>
15
+ <string>(@@\s*([A-Za-z0-9]*))\n</string>
16
+ <key>beginCaptures</key>
17
+ <dict>
18
+ <key>0</key>
19
+ <dict>
20
+ <key>name</key>
21
+ <string>storage</string>
22
+ </dict>
23
+ </dict>
24
+ <key>end</key>
25
+ <string>(?=@@)</string>
26
+ <key>name</key>
27
+ <string>source.js.booster.embedded.mustache</string>
28
+ <key>patterns</key>
29
+ <array>
30
+ <dict>
31
+ <key>include</key>
32
+ <string>text.html.mustache</string>
33
+ </dict>
34
+ </array>
35
+ </dict>
36
+ <dict>
37
+ <key>include</key>
38
+ <string>source.js</string>
39
+ </dict>
40
+ </array>
41
+ <key>scopeName</key>
42
+ <string>source.js.booster</string>
43
+ <key>uuid</key>
44
+ <string>A53A6C6F-4F49-41BE-B15C-B1165E1766FC</string>
45
+ </dict>
46
+ </plist>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>name</key>
6
+ <string>Booster</string>
7
+ <key>uuid</key>
8
+ <string>5E2B4915-CD6D-4394-8C53-95421BA02D63</string>
9
+ </dict>
10
+ </plist>
@@ -0,0 +1,5 @@
1
+ //= require stitch
2
+ //= require underscore
3
+ //= require backbone
4
+ //= require handlebars-vm
5
+ //= require handlebars-helpers
@@ -0,0 +1 @@
1
+ //= require_tree ./booster
@@ -0,0 +1,2 @@
1
+ //= require ./booster-core
2
+ //= require ./booster-support
@@ -0,0 +1 @@
1
+ // To be defined
@@ -0,0 +1,30 @@
1
+ var schema = require('./support/schema');
2
+
3
+ /**
4
+ * Extension of {Backbone.Model} which includes various Booster features
5
+ * functionality like schema support. An application can choose to extend
6
+ * its models from this constructor rather than {Backbone.Model} or it
7
+ * may use the corresponding mixins like this extension does.
8
+ *
9
+ * @extends {Backbone.Model}
10
+ * @constructor
11
+ */
12
+
13
+ exports.Model = Backbone.Model.extend({
14
+
15
+ });
16
+
17
+ _.extend(exports.Model.prototype, schema.mixin());
18
+
19
+ /**
20
+ * Although empty, it may be a good idea to extend from this type instead
21
+ * if we introduce functionality in the future which works together with
22
+ * {exports.Model}.
23
+ *
24
+ * @extends {Backbone.Collection}
25
+ * @constructor
26
+ */
27
+
28
+ exports.Collection = Backbone.Collection.extend({
29
+
30
+ });