booster 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +106 -0
- data/MIT-LICENSE +20 -0
- data/README.md +174 -0
- data/Rakefile +7 -0
- data/booster.gemspec +24 -0
- data/booster.tmbundle/Snippets/untitled.tmSnippet +14 -0
- data/booster.tmbundle/Syntaxes/Booster.tmLanguage +46 -0
- data/booster.tmbundle/info.plist +10 -0
- data/lib/assets/javascripts/booster-core.js +5 -0
- data/lib/assets/javascripts/booster-support.js +1 -0
- data/lib/assets/javascripts/booster.js +2 -0
- data/lib/assets/javascripts/booster/collection.js.boost +1 -0
- data/lib/assets/javascripts/booster/model.js.boost +30 -0
- data/lib/assets/javascripts/booster/router.js.boost +107 -0
- data/lib/assets/javascripts/booster/support/binding.js.boost +1 -0
- data/lib/assets/javascripts/booster/support/helpers.js.boost +109 -0
- data/lib/assets/javascripts/booster/support/i18n.js.boost +136 -0
- data/lib/assets/javascripts/booster/support/observer.js.boost +81 -0
- data/lib/assets/javascripts/booster/support/schema.js.boost +117 -0
- data/lib/assets/javascripts/booster/view.js.boost +45 -0
- data/lib/assets/javascripts/booster/views/composite.js.boost +59 -0
- data/lib/assets/javascripts/booster/views/layout.js.boost +94 -0
- data/lib/booster.rb +7 -0
- data/lib/booster/engine.rb +8 -0
- data/lib/booster/handlebars.rb +50 -0
- data/lib/booster/template.rb +59 -0
- data/lib/booster/version.rb +3 -0
- data/test/booster/tilt_test.rb +35 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js.boost +18 -0
- data/test/dummy/app/assets/javascripts/booster/support/helpers_spec.js.boost +69 -0
- data/test/dummy/app/assets/javascripts/booster/support/i18n_spec.js.boost +0 -0
- data/test/dummy/app/assets/javascripts/booster/support/observer_spec.js.boost +56 -0
- data/test/dummy/app/assets/javascripts/booster/support/router_spec.js.boost +19 -0
- data/test/dummy/app/assets/javascripts/booster/support/schema_spec.js.boost +79 -0
- data/test/dummy/app/assets/javascripts/booster/views/layout_spec.js.boost +30 -0
- data/test/dummy/app/controllers/application_controller.rb +7 -0
- data/test/dummy/app/views/layouts/application.html.erb +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +30 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +27 -0
- data/test/dummy/config/environments/production.rb +29 -0
- data/test/dummy/config/environments/test.rb +34 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/test_helper.rb +4 -0
- data/vendor/assets/javascripts/backbone.js +1158 -0
- data/vendor/assets/javascripts/handlebars-helpers.js +56 -0
- data/vendor/assets/javascripts/handlebars-vm.js +191 -0
- data/vendor/assets/javascripts/handlebars.js +1561 -0
- data/vendor/assets/javascripts/jasmine-html.js +190 -0
- data/vendor/assets/javascripts/jasmine-jquery.js +288 -0
- data/vendor/assets/javascripts/jasmine.js +2471 -0
- data/vendor/assets/javascripts/stitch.js +57 -0
- data/vendor/assets/javascripts/underscore.js +981 -0
- data/vendor/assets/stylesheets/jasmine.css +166 -0
- metadata +172 -0
File without changes
|
@@ -0,0 +1,56 @@
|
|
1
|
+
var observer = require('booster/support/observer');
|
2
|
+
|
3
|
+
describe('observer', function() {
|
4
|
+
var Subject = function() { };
|
5
|
+
var Observer = function() { };
|
6
|
+
|
7
|
+
_.extend(Subject.prototype, Backbone.Events);
|
8
|
+
_.extend(Observer.prototype, observer.mixin(), { test: function() {} });
|
9
|
+
|
10
|
+
beforeEach(function() {
|
11
|
+
this.subjects = [new Subject(), new Subject()];
|
12
|
+
this.observer = new Observer();
|
13
|
+
spyOn(this.observer, 'test');
|
14
|
+
});
|
15
|
+
|
16
|
+
it('should allow unobserving a single subject and event', function() {
|
17
|
+
var observer = this.observer;
|
18
|
+
|
19
|
+
_.each(this.subjects, function(subject) {
|
20
|
+
observer.observe(subject, 'change:one', observer.test);
|
21
|
+
observer.observe(subject, 'change:two', observer.test);
|
22
|
+
subject.trigger('change:one');
|
23
|
+
subject.trigger('change:two');
|
24
|
+
});
|
25
|
+
|
26
|
+
expect(observer.test.callCount).toEqual(4);
|
27
|
+
|
28
|
+
_.each(this.subjects, function(subject) {
|
29
|
+
observer.unobserve(subject, 'change:one', observer.test);
|
30
|
+
subject.trigger('change:one');
|
31
|
+
subject.trigger('change:two');
|
32
|
+
});
|
33
|
+
|
34
|
+
expect(observer.test.callCount).toEqual(6);
|
35
|
+
});
|
36
|
+
|
37
|
+
it('should allow unobserving all subjects', function() {
|
38
|
+
var subjects = [new Subject(), new Subject()];
|
39
|
+
var observer = new Observer();
|
40
|
+
spyOn(observer, 'test');
|
41
|
+
|
42
|
+
_.each(subjects, function(subject, index) {
|
43
|
+
observer.observe(subject, 'change', observer.test);
|
44
|
+
subject.trigger('change');
|
45
|
+
expect(observer.test.callCount).toEqual(index + 1);
|
46
|
+
});
|
47
|
+
|
48
|
+
observer.unobserve();
|
49
|
+
expect(observer._subjects).toEqual(undefined);
|
50
|
+
|
51
|
+
_.each(subjects, function(subject) {
|
52
|
+
subject.trigger('change');
|
53
|
+
expect(observer.test.callCount).toEqual(2);
|
54
|
+
});
|
55
|
+
});
|
56
|
+
})
|
@@ -0,0 +1,19 @@
|
|
1
|
+
var router = require('booster/router');
|
2
|
+
|
3
|
+
describe('router', function() {
|
4
|
+
|
5
|
+
var middleware = function(req, next) {
|
6
|
+
req.data = parseInt(req.params.number);
|
7
|
+
next();
|
8
|
+
}
|
9
|
+
|
10
|
+
it('should route paths through middleware', function() {
|
11
|
+
router.route('/test/:number', middleware, function(req) {
|
12
|
+
expect(req.data).toEqual(123);
|
13
|
+
});
|
14
|
+
|
15
|
+
Backbone.history.start();
|
16
|
+
window.location.hash = '#/test/123';
|
17
|
+
});
|
18
|
+
|
19
|
+
});
|
@@ -0,0 +1,79 @@
|
|
1
|
+
var schema = require('booster/support/schema');
|
2
|
+
|
3
|
+
describe('schema', function() {
|
4
|
+
var byref = function(collection) {
|
5
|
+
return collection.pluck('id');
|
6
|
+
}
|
7
|
+
|
8
|
+
// A no-op extension of `Backbone.Collection` type
|
9
|
+
var Collection = Backbone.Collection.extend({
|
10
|
+
model: Backbone.Model
|
11
|
+
});
|
12
|
+
|
13
|
+
// Extension of `Backbone.Model` with schema definition
|
14
|
+
var Model = Backbone.Model.extend({
|
15
|
+
schema: {
|
16
|
+
simpleNotation: Collection,
|
17
|
+
serialized: { type: Collection },
|
18
|
+
notSerialized: { type: Collection, serialize: false },
|
19
|
+
refSerialized: { type: Collection, serialize: byref },
|
20
|
+
number: { type: Number },
|
21
|
+
string: { type: String },
|
22
|
+
}
|
23
|
+
});
|
24
|
+
|
25
|
+
// Mixin the schema support we're about to test.
|
26
|
+
_.extend(Model.prototype, schema.mixin());
|
27
|
+
|
28
|
+
beforeEach(function() {
|
29
|
+
this.instance = new Model({
|
30
|
+
id: 1,
|
31
|
+
serialized: [{ id: 123, title: "Test-123" }],
|
32
|
+
notSerialized: [{ id: 123, title: "Test-123" }],
|
33
|
+
refSerialized: [{ id: 123, title: "Test-123" }],
|
34
|
+
simpleNotation: [{ id: 123, title: "Test-123" }],
|
35
|
+
number: 123,
|
36
|
+
string: '123'
|
37
|
+
})
|
38
|
+
});
|
39
|
+
|
40
|
+
describe('conversion', function() {
|
41
|
+
it('should convert attributes to the given Backbone type', function() {
|
42
|
+
expect(this.instance.get('serialized') instanceof Collection).toBeTruthy();
|
43
|
+
expect(this.instance.attributes.serialized).toEqual(undefined);
|
44
|
+
});
|
45
|
+
|
46
|
+
it('should memoize converted attributes', function() {
|
47
|
+
this.instance.get('serialized').add({id: 321});
|
48
|
+
expect(this.instance.get('serialized').get(321)).toBeTruthy();
|
49
|
+
});
|
50
|
+
|
51
|
+
it('should track the parent object when mapping attributes', function() {
|
52
|
+
expect(this.instance.get('serialized').parent.id).toEqual(1);
|
53
|
+
});
|
54
|
+
|
55
|
+
it('should allow a simpler notation if only type needs to be given', function() {
|
56
|
+
expect(this.instance.get('simpleNotation') instanceof Collection).toBeTruthy();
|
57
|
+
});
|
58
|
+
|
59
|
+
it('should match primitives against wrapper object type and skip conversion', function() {
|
60
|
+
expect(typeof this.instance.get('number')).toEqual('number'); // Not 'object'
|
61
|
+
expect(typeof this.instance.get('string')).toEqual('string'); // Not 'object'
|
62
|
+
});
|
63
|
+
});
|
64
|
+
|
65
|
+
describe('serialization', function() {
|
66
|
+
it('should delegate serialization to nested collection', function() {
|
67
|
+
this.instance.get('serialized'); // Perform type conversion.
|
68
|
+
expect(this.instance.toJSON().serialized).toEqual([{id: 123, title: "Test-123"}]);
|
69
|
+
});
|
70
|
+
|
71
|
+
it('should allow serialization through an external function', function() {
|
72
|
+
expect(this.instance.toJSON().refSerialized).toEqual([123]);
|
73
|
+
});
|
74
|
+
|
75
|
+
it('should allow serialization to be turned off for an attribute', function() {
|
76
|
+
expect(this.instance.toJSON().notSerialized).toEqual(undefined);
|
77
|
+
});
|
78
|
+
});
|
79
|
+
});
|
@@ -0,0 +1,30 @@
|
|
1
|
+
var layout = require('booster/views/layout'),
|
2
|
+
base = require('booster/view');
|
3
|
+
|
4
|
+
describe('layout', function() {
|
5
|
+
var View = base.View.extend({
|
6
|
+
initialize: function() {
|
7
|
+
$(this.el).html('<p>nested</p>');
|
8
|
+
}
|
9
|
+
});
|
10
|
+
|
11
|
+
beforeEach(function() {
|
12
|
+
this.layout = new layout.View({
|
13
|
+
template: template
|
14
|
+
});
|
15
|
+
});
|
16
|
+
|
17
|
+
it('allow yielding named sections of the layout to external views', function() {
|
18
|
+
this.layout.set({
|
19
|
+
sidebar: new View(),
|
20
|
+
content: new View()
|
21
|
+
});
|
22
|
+
|
23
|
+
expect(this.layout.$('aside')).toHaveHtml('<div><p>nested</p></div>');
|
24
|
+
expect(this.layout.$('section')).toHaveHtml('<div><p>nested</p></div>');
|
25
|
+
});
|
26
|
+
});
|
27
|
+
|
28
|
+
@@ template
|
29
|
+
<aside data-yield="sidebar"></aside>
|
30
|
+
<section data-yield="content"></aside>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Booster BDD Specs</title>
|
5
|
+
<%= stylesheet_link_tag 'jasmine' %>
|
6
|
+
<%= csrf_meta_tags %>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<%= javascript_include_tag 'jasmine', 'jasmine-html', 'jasmine-jquery', 'application' %>
|
10
|
+
|
11
|
+
<script>
|
12
|
+
require('application');
|
13
|
+
|
14
|
+
(function() {
|
15
|
+
var trivialReporter = new jasmine.TrivialReporter();
|
16
|
+
var jasmineEnv = jasmine.getEnv();
|
17
|
+
jasmineEnv.updateInterval = 1000;
|
18
|
+
jasmineEnv.addReporter(trivialReporter);
|
19
|
+
jasmineEnv.specFilter = function(spec) {
|
20
|
+
return trivialReporter.specFilter(spec);
|
21
|
+
};
|
22
|
+
|
23
|
+
window.onload = function() {
|
24
|
+
jasmineEnv.execute();
|
25
|
+
};
|
26
|
+
})();
|
27
|
+
</script>
|
28
|
+
</body>
|
29
|
+
</html>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails'
|
4
|
+
|
5
|
+
%w(action_controller sprockets).each do |framework|
|
6
|
+
begin
|
7
|
+
require "#{framework}/railtie"
|
8
|
+
rescue LoadError
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Bundler.require
|
13
|
+
require "booster"
|
14
|
+
|
15
|
+
module Dummy
|
16
|
+
class Application < Rails::Application
|
17
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
18
|
+
config.encoding = "utf-8"
|
19
|
+
|
20
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
21
|
+
config.filter_parameters += [:password]
|
22
|
+
|
23
|
+
# Enable the asset pipeline
|
24
|
+
config.assets.enabled = true
|
25
|
+
|
26
|
+
# Version of your assets, change this if you want to expire all your assets
|
27
|
+
config.assets.version = '1.0'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Print deprecation notices to the Rails logger
|
17
|
+
config.active_support.deprecation = :log
|
18
|
+
|
19
|
+
# Only use best-standards-support built into browsers
|
20
|
+
config.action_dispatch.best_standards_support = :builtin
|
21
|
+
|
22
|
+
# Do not compress assets
|
23
|
+
config.assets.compress = false
|
24
|
+
|
25
|
+
# Expands the lines which load the assets
|
26
|
+
config.assets.debug = true
|
27
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# Code is not reloaded between requests
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Full error reports are disabled and caching is turned on
|
8
|
+
config.consider_all_requests_local = false
|
9
|
+
config.action_controller.perform_caching = true
|
10
|
+
|
11
|
+
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
+
config.serve_static_assets = false
|
13
|
+
|
14
|
+
# Compress JavaScripts and CSS
|
15
|
+
config.assets.compress = true
|
16
|
+
|
17
|
+
# Don't fallback to assets pipeline if a precompiled asset is missed
|
18
|
+
config.assets.compile = false
|
19
|
+
|
20
|
+
# Generate digests for assets URLs
|
21
|
+
config.assets.digest = true
|
22
|
+
|
23
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
24
|
+
# the I18n.default_locale when a translation can not be found)
|
25
|
+
config.i18n.fallbacks = true
|
26
|
+
|
27
|
+
# Send deprecation notices to registered listeners
|
28
|
+
config.active_support.deprecation = :notify
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Configure static asset server for tests with Cache-Control for performance
|
11
|
+
config.serve_static_assets = true
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
13
|
+
|
14
|
+
# Log error messages when you accidentally call methods on nil
|
15
|
+
config.whiny_nils = true
|
16
|
+
|
17
|
+
# Show full error reports and disable caching
|
18
|
+
config.consider_all_requests_local = true
|
19
|
+
config.action_controller.perform_caching = false
|
20
|
+
|
21
|
+
# Raise exceptions instead of rendering exception templates
|
22
|
+
config.action_dispatch.show_exceptions = false
|
23
|
+
|
24
|
+
# Disable request forgery protection in test environment
|
25
|
+
config.action_controller.allow_forgery_protection = false
|
26
|
+
|
27
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
28
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
29
|
+
# like if you have constraints or database-specific column types
|
30
|
+
# config.active_record.schema_format = :sql
|
31
|
+
|
32
|
+
# Print deprecation notices to the stderr
|
33
|
+
config.active_support.deprecation = :stderr
|
34
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_token = 'c029618a876b1ccd9636bea369fb141ffb164c31ad5a1be9638e6b3b7710396b1180c87728251a6b2d4922fadb6f1684b2f061ab16f189af7e8512f70a8aa2fd'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Disable root element in JSON by default.
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
13
|
+
self.include_root_in_json = false
|
14
|
+
end
|