eyeballs 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +15 -0
- data/README.md +293 -0
- data/Rakefile +45 -0
- data/bin/eyeballs +9 -0
- data/config.ru +2 -0
- data/dist/jquery-1.4.2.min.js +154 -0
- data/dist/jquery.livequery.js +226 -0
- data/dist/mustache.js +324 -0
- data/eyeballs.gemspec +86 -0
- data/eyeballs.js.gemspec +83 -0
- data/lib/eyeballs.rb +11 -0
- data/lib/eyeballs/app_detector.rb +29 -0
- data/lib/eyeballs/app_generator.rb +30 -0
- data/lib/eyeballs/cli.rb +14 -0
- data/lib/eyeballs/controller_generator.rb +26 -0
- data/lib/eyeballs/model_generator.rb +26 -0
- data/lib/eyeballs/scaffold_generator.rb +66 -0
- data/spec/app_generator_spec.rb +51 -0
- data/spec/controller_generator_spec.rb +22 -0
- data/spec/model_generator_spec.rb +23 -0
- data/spec/rack_app_detector_spec.rb +25 -0
- data/spec/scaffold_generator_spec.rb +42 -0
- data/spec/spec_helper.rb +42 -0
- data/src/jquery.o_O.couchdb.js +107 -0
- data/src/jquery.o_O.dom.js +37 -0
- data/src/jquery.o_O.js +120 -0
- data/src/jquery.o_O.rails.js +68 -0
- data/src/o_O.js +286 -0
- data/src/o_O.localstorage.js +60 -0
- data/templates/app_root/index.html +26 -0
- data/templates/controller.js +3 -0
- data/templates/model.js +3 -0
- data/templates/scaffold_controller.js +75 -0
- data/templates/scaffold_edit.html.mustache +13 -0
- data/templates/scaffold_index.html +47 -0
- data/templates/scaffold_partial.html.mustache +12 -0
- data/test/unit/qunit.css +119 -0
- data/test/unit/qunit.js +1069 -0
- data/test/unit/test_controller.html +137 -0
- data/test/unit/test_dom.html +81 -0
- data/test/unit/test_dom_with_callbacks.html +121 -0
- data/test/unit/test_form.html +42 -0
- data/test/unit/test_localstorage.html +79 -0
- data/test/unit/test_model.html +136 -0
- data/test/unit/test_model_with_callbacks.html +118 -0
- data/test/unit/test_rails.html +97 -0
- metadata +117 -0
@@ -0,0 +1,136 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<script src="../../dist/jquery-1.4.2.min.js"></script>
|
6
|
+
<script src="../../src/o_O.js"></script>
|
7
|
+
<script src="../../src/jquery.o_O.js"></script>
|
8
|
+
<script src="../../src/jquery.o_O.dom.js"></script>
|
9
|
+
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
|
10
|
+
<script type="text/javascript" src="qunit.js"></script>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
|
14
|
+
o_O.model.adapter = o_O.dom;
|
15
|
+
|
16
|
+
o_O('Review', function(that){
|
17
|
+
that.validates_presence_of('title');
|
18
|
+
that.validates_presence_of('content');
|
19
|
+
that.validates_length_of('title', {min: 5, max: 15});
|
20
|
+
that.validates(function(review){
|
21
|
+
if(review.score != 99 && review.test === true)
|
22
|
+
{
|
23
|
+
review.errors.push({message: 'Score should be 99'})
|
24
|
+
}
|
25
|
+
})
|
26
|
+
that.methods.title_numbered = function(){
|
27
|
+
return '1. ' + this.title;
|
28
|
+
}
|
29
|
+
return that;
|
30
|
+
});
|
31
|
+
|
32
|
+
var MyApp = {};
|
33
|
+
o_O('TestModel', function(){}, MyApp);
|
34
|
+
|
35
|
+
$(document).ready(function(){
|
36
|
+
|
37
|
+
module("Models");
|
38
|
+
|
39
|
+
test('binding to a non-global object', 1, function(){
|
40
|
+
var test_model = MyApp.TestModel.initialize({title: 'Delicious'})
|
41
|
+
equals(test_model.title, 'Delicious', 'should just work as normal')
|
42
|
+
})
|
43
|
+
|
44
|
+
test('serialization',1, function(){
|
45
|
+
var myReview = Review.initialize({title: 'Groovy'})
|
46
|
+
equals(myReview.to_json(), '{"title":"Groovy","_model_name":"Review"}', 'should serialize nicely')
|
47
|
+
})
|
48
|
+
|
49
|
+
test('useful attributes',2, function(){
|
50
|
+
equals(Review.model_name, 'Review', 'should give me a model name');
|
51
|
+
equals(Review.table_name, 'reviews', 'should give me a table name');
|
52
|
+
})
|
53
|
+
|
54
|
+
test('multiple initialization', 1, function(){
|
55
|
+
a = Review.initialize()
|
56
|
+
b = Review.initialize()
|
57
|
+
equals(a.id == b.id, false, 'they should have different ids')
|
58
|
+
})
|
59
|
+
|
60
|
+
test('a valid review', 3, function(){
|
61
|
+
var myReview = Review.initialize({title: "Biscuit", content: "Some Content"});
|
62
|
+
myReview.save();
|
63
|
+
equals(myReview.title, 'Biscuit', 'Title should be Biscuit');
|
64
|
+
equals(myReview.valid(), true, 'valid() should return true');
|
65
|
+
equals(myReview.save().title, 'Biscuit', 'save() should return object');
|
66
|
+
});
|
67
|
+
|
68
|
+
test('an invalid review',1, function(){
|
69
|
+
var myReview = Review.initialize();
|
70
|
+
myReview.save();
|
71
|
+
equals(myReview.errors.length, 2, "should have 2 errors");
|
72
|
+
});
|
73
|
+
|
74
|
+
test('editing a review', 2, function(){
|
75
|
+
myReview = Review.find('paul');
|
76
|
+
equals(myReview.title, 'Yeah!', 'should pull in title');
|
77
|
+
equals(myReview.content, 'Paris', 'should pull in content');
|
78
|
+
})
|
79
|
+
|
80
|
+
test('updating a review', 2, function(){
|
81
|
+
myReview = Review.find('paul');
|
82
|
+
myReview.update_attributes({title: 'No!', content: 'Dublin'});
|
83
|
+
equals(myReview.title, 'No!', 'should update the title');
|
84
|
+
equals(myReview.content, 'Dublin', 'should update the content');
|
85
|
+
})
|
86
|
+
|
87
|
+
test('updating a review invalid', 1, function(){
|
88
|
+
myReview = Review.find('paul');
|
89
|
+
myReview.update_attributes({title: '', content: ''});
|
90
|
+
equals(myReview.errors.length, 2, "should have 2 errors");
|
91
|
+
})
|
92
|
+
|
93
|
+
test('defining methods should work',1, function(){
|
94
|
+
myReview = Review.initialize({title: 'Boom'})
|
95
|
+
equals(myReview.title_numbered(), '1. Boom', 'the method definition should work');
|
96
|
+
});
|
97
|
+
|
98
|
+
test('validates length of', 6, function(){
|
99
|
+
myReview = Review.initialize({title: "finger baby babylon babe face", content: "something"});
|
100
|
+
myReview.save();
|
101
|
+
equals(myReview.errors.length, 1, "should have an error");
|
102
|
+
equals(myReview.errors[0].field, 'title', 'should be on title');
|
103
|
+
equals(myReview.errors[0].type, 'length', 'should be length')
|
104
|
+
equals(myReview.errors[0].message, 'title should be less than 15 characters', 'should have an error message')
|
105
|
+
myReview.title = 'the'
|
106
|
+
myReview.save();
|
107
|
+
equals(myReview.errors.length, 1, "should still only have one error");
|
108
|
+
equals(myReview.errors[0].message, 'title should be greater than 5 characters', 'should have an error message')
|
109
|
+
});
|
110
|
+
|
111
|
+
test('custom validation', 3, function(){
|
112
|
+
myReview = Review.initialize({title: 'Badabing', content: 'Badaboom', score: 0, test: true})
|
113
|
+
myReview.save();
|
114
|
+
equals(myReview.errors.length, 1, "should have an error");
|
115
|
+
equals(myReview.errors[0].message, 'Score should be 99', "should give me my custom error message");
|
116
|
+
myReview.score = 99;
|
117
|
+
myReview.save()
|
118
|
+
equals(myReview.errors.length, 0, "should have no errors");
|
119
|
+
})
|
120
|
+
|
121
|
+
});
|
122
|
+
</script>
|
123
|
+
|
124
|
+
</head>
|
125
|
+
<body>
|
126
|
+
<h1 id="qunit-header">Model Tests</h1>
|
127
|
+
<h2 id="qunit-banner"></h2>
|
128
|
+
<h2 id="qunit-userAgent"></h2>
|
129
|
+
<ol id="qunit-tests"></ol>
|
130
|
+
|
131
|
+
<div data-model="Review" data-id="paul">
|
132
|
+
<h1 data-attribute="title">Yeah!</h1>
|
133
|
+
<p data-attribute="content">Paris</p>
|
134
|
+
</div>
|
135
|
+
</body>
|
136
|
+
</html>
|
@@ -0,0 +1,118 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<script src="../../dist/jquery-1.4.2.min.js"></script>
|
6
|
+
<script src="../../src/o_O.js"></script>
|
7
|
+
<script src="../../src/jquery.o_O.js"></script>
|
8
|
+
<script src="../../src/jquery.o_O.dom.js"></script>
|
9
|
+
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
|
10
|
+
<script type="text/javascript" src="qunit.js"></script>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
|
14
|
+
o_O('Review', function(that){
|
15
|
+
that.validates_presence_of('title');
|
16
|
+
that.validates_presence_of('content');
|
17
|
+
that.validates_length_of('title', {min: 5, max: 15});
|
18
|
+
that.validates(function(review){
|
19
|
+
if(review.score != 99 && review.test === true)
|
20
|
+
{
|
21
|
+
review.errors.push({message: 'Score should be 99'})
|
22
|
+
}
|
23
|
+
})
|
24
|
+
that.methods.title_numbered = function(){
|
25
|
+
return '1. ' + this.title;
|
26
|
+
}
|
27
|
+
return that;
|
28
|
+
});
|
29
|
+
|
30
|
+
$(document).ready(function(){
|
31
|
+
|
32
|
+
module("Models");
|
33
|
+
|
34
|
+
asyncTest('a valid, successful model', 2, function(){
|
35
|
+
var myReview = Review.initialize({title: "Biscuit", content: "Some Content"});
|
36
|
+
myReview.save({
|
37
|
+
loading: function(){
|
38
|
+
ok('should call the loading callback before success')
|
39
|
+
},
|
40
|
+
success: function(){
|
41
|
+
ok('should call the success callback')
|
42
|
+
start();
|
43
|
+
}
|
44
|
+
});
|
45
|
+
});
|
46
|
+
|
47
|
+
asyncTest('an invalid review',1, function(){
|
48
|
+
var myReview = Review.initialize();
|
49
|
+
myReview.save({
|
50
|
+
success:function(){
|
51
|
+
ok(false, 'should not call the success callback');
|
52
|
+
},
|
53
|
+
invalid: function(){
|
54
|
+
ok('should call the invalid callback');
|
55
|
+
start();
|
56
|
+
},
|
57
|
+
loading: function(){
|
58
|
+
ok(false, 'should not call the loading callback');
|
59
|
+
}
|
60
|
+
});
|
61
|
+
});
|
62
|
+
|
63
|
+
asyncTest('updating a review', 2, function(){
|
64
|
+
var myReview = Review.initialize({title: "Biscuit", content: "Some Content"});
|
65
|
+
myReview.update_attributes({title: 'No! is it', content: 'Dublin'}, {
|
66
|
+
success: function(){
|
67
|
+
ok('should call the success callback');
|
68
|
+
start();
|
69
|
+
},
|
70
|
+
invalid: function(){
|
71
|
+
ok(false, 'should not cal the invalid callback');
|
72
|
+
},
|
73
|
+
loading: function(){
|
74
|
+
ok('should call the loading callback');
|
75
|
+
}
|
76
|
+
});
|
77
|
+
})
|
78
|
+
|
79
|
+
asyncTest('updating an invalid review', 1, function(){
|
80
|
+
var myReview = Review.initialize();
|
81
|
+
myReview.update_attributes({}, {
|
82
|
+
success: function(){
|
83
|
+
ok(false, 'should not call the success callback');
|
84
|
+
},
|
85
|
+
invalid: function(){
|
86
|
+
ok(true, 'should call the invalid callback');
|
87
|
+
start();
|
88
|
+
},
|
89
|
+
loading: function(){
|
90
|
+
ok(false, 'should not call the loading callback');
|
91
|
+
}
|
92
|
+
});
|
93
|
+
})
|
94
|
+
|
95
|
+
test('destroying a review', 2, function(){
|
96
|
+
var myReview = Review.initialize();
|
97
|
+
myReview.destroy({
|
98
|
+
loading: function(){
|
99
|
+
ok('loading should be run');
|
100
|
+
},
|
101
|
+
success: function(){
|
102
|
+
ok('success should be run');
|
103
|
+
}
|
104
|
+
})
|
105
|
+
})
|
106
|
+
|
107
|
+
});
|
108
|
+
</script>
|
109
|
+
|
110
|
+
</head>
|
111
|
+
<body>
|
112
|
+
<h1 id="qunit-header">Model Tests (with callbacks)</h1>
|
113
|
+
<h2 id="qunit-banner"></h2>
|
114
|
+
<h2 id="qunit-userAgent"></h2>
|
115
|
+
<ol id="qunit-tests"></ol>
|
116
|
+
</div>
|
117
|
+
</body>
|
118
|
+
</html>
|
@@ -0,0 +1,97 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<script src="../../dist/jquery-1.4.2.min.js"></script>
|
6
|
+
<script src="../../dist/jquery.livequery.js"></script>
|
7
|
+
|
8
|
+
<script src="../../src/o_O.js"></script>
|
9
|
+
<script src="../../src/jquery.o_O.rails.js"></script>
|
10
|
+
<script src="../../src/jquery.o_O.js"></script>
|
11
|
+
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript" src="qunit.js"></script>
|
13
|
+
|
14
|
+
<script>
|
15
|
+
|
16
|
+
|
17
|
+
$(document).ready(function(){
|
18
|
+
|
19
|
+
o_O.model.adapter = o_O.rails;
|
20
|
+
|
21
|
+
module("Rails Test (with jQuery)");
|
22
|
+
|
23
|
+
o_O('Review', function(){})
|
24
|
+
|
25
|
+
asyncTest('storing a basic basic thing', 3, function(){
|
26
|
+
var review = Review.initialize({title: 'Magic!'})
|
27
|
+
review.save(function(saved_review){
|
28
|
+
equals(saved_review.title, review.title, 'title should match');
|
29
|
+
equals(saved_review.id, '1', "Rails should give back the ID");
|
30
|
+
equals(saved_review.model_name, 'Review', 'should save the model name');
|
31
|
+
start();
|
32
|
+
});
|
33
|
+
});
|
34
|
+
|
35
|
+
asyncTest('pulling something in', 2, function(){
|
36
|
+
var review = Review.initialize({title: 'More Magic!'});
|
37
|
+
review.save(function(){
|
38
|
+
found_review = Review.find(review.id, function(found_review){
|
39
|
+
equals(found_review.title, 'More Magic!', 'should be able to find stuff in local storage')
|
40
|
+
equals(found_review.id, '1', 'should persist the id')
|
41
|
+
start();
|
42
|
+
});
|
43
|
+
});
|
44
|
+
})
|
45
|
+
|
46
|
+
asyncTest('getting all', 2, function(){
|
47
|
+
var review = Review.initialize({title: 'Local, baby'});
|
48
|
+
review.save(function(saved_review){
|
49
|
+
Review.all(function(documents){
|
50
|
+
equals(documents[0].title, 'Local, baby', 'It should pull in everything')
|
51
|
+
equals(documents[0].id, '1', 'It should persist the id')
|
52
|
+
start();
|
53
|
+
})
|
54
|
+
});
|
55
|
+
})
|
56
|
+
|
57
|
+
asyncTest('setting new_record attribute', 2, function(){
|
58
|
+
var review = Review.initialize()
|
59
|
+
equals(review.new_record, true, 'should be a new record review');
|
60
|
+
review.save(function(saved_review){
|
61
|
+
console.log(saved_review)
|
62
|
+
equals(saved_review.new_record, false, 'should not be a new record after')
|
63
|
+
start();
|
64
|
+
});
|
65
|
+
})
|
66
|
+
|
67
|
+
asyncTest('updating', 1, function(){
|
68
|
+
var review = Review.initialize({title: 'Doomed!'});
|
69
|
+
review.save(function(saved_review){
|
70
|
+
saved_review.update_attributes({title: 'Tennessee'}, function(saved_review){
|
71
|
+
equals(saved_review.title, 'Tennessee', 'Title should have been updated');
|
72
|
+
start();
|
73
|
+
});
|
74
|
+
});
|
75
|
+
});
|
76
|
+
|
77
|
+
asyncTest('deleting', 1, function(){
|
78
|
+
var review = Review.initialize({title: 'Doomed!'});
|
79
|
+
review.save(function(saved_review){
|
80
|
+
saved_review.destroy(function(destroyed_review){
|
81
|
+
equals(destroyed_review.destroyed, true, 'It should have deleted the doc')
|
82
|
+
start()
|
83
|
+
});
|
84
|
+
});
|
85
|
+
})
|
86
|
+
|
87
|
+
});
|
88
|
+
</script>
|
89
|
+
|
90
|
+
</head>
|
91
|
+
<body>
|
92
|
+
<h1 id="qunit-header">Rails Tests (with jQuery)</h1>
|
93
|
+
<h2 id="qunit-banner"></h2>
|
94
|
+
<h2 id="qunit-userAgent"></h2>
|
95
|
+
<ol id="qunit-tests"></ol>
|
96
|
+
</body>
|
97
|
+
</html>
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eyeballs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Paul Campbell
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-06-09 00:00:00 -04:00
|
19
|
+
default_executable: eyeballs
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description:
|
23
|
+
email: paul@rslw.com
|
24
|
+
executables:
|
25
|
+
- eyeballs
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.md
|
30
|
+
files:
|
31
|
+
- CHANGELOG
|
32
|
+
- README.md
|
33
|
+
- Rakefile
|
34
|
+
- bin/eyeballs
|
35
|
+
- config.ru
|
36
|
+
- dist/jquery-1.4.2.min.js
|
37
|
+
- dist/jquery.livequery.js
|
38
|
+
- dist/mustache.js
|
39
|
+
- eyeballs.gemspec
|
40
|
+
- eyeballs.js.gemspec
|
41
|
+
- lib/eyeballs.rb
|
42
|
+
- lib/eyeballs/app_detector.rb
|
43
|
+
- lib/eyeballs/app_generator.rb
|
44
|
+
- lib/eyeballs/cli.rb
|
45
|
+
- lib/eyeballs/controller_generator.rb
|
46
|
+
- lib/eyeballs/model_generator.rb
|
47
|
+
- lib/eyeballs/scaffold_generator.rb
|
48
|
+
- src/jquery.o_O.couchdb.js
|
49
|
+
- src/jquery.o_O.dom.js
|
50
|
+
- src/jquery.o_O.js
|
51
|
+
- src/jquery.o_O.rails.js
|
52
|
+
- src/o_O.js
|
53
|
+
- src/o_O.localstorage.js
|
54
|
+
- templates/app_root/index.html
|
55
|
+
- templates/controller.js
|
56
|
+
- templates/model.js
|
57
|
+
- templates/scaffold_controller.js
|
58
|
+
- templates/scaffold_edit.html.mustache
|
59
|
+
- templates/scaffold_index.html
|
60
|
+
- templates/scaffold_partial.html.mustache
|
61
|
+
- test/unit/qunit.css
|
62
|
+
- test/unit/qunit.js
|
63
|
+
- test/unit/test_controller.html
|
64
|
+
- test/unit/test_dom.html
|
65
|
+
- test/unit/test_dom_with_callbacks.html
|
66
|
+
- test/unit/test_form.html
|
67
|
+
- test/unit/test_localstorage.html
|
68
|
+
- test/unit/test_model.html
|
69
|
+
- test/unit/test_model_with_callbacks.html
|
70
|
+
- test/unit/test_rails.html
|
71
|
+
- spec/app_generator_spec.rb
|
72
|
+
- spec/controller_generator_spec.rb
|
73
|
+
- spec/model_generator_spec.rb
|
74
|
+
- spec/rack_app_detector_spec.rb
|
75
|
+
- spec/scaffold_generator_spec.rb
|
76
|
+
- spec/spec_helper.rb
|
77
|
+
has_rdoc: false
|
78
|
+
homepage: http://www.github.com/paulca/eyeballs.js
|
79
|
+
licenses: []
|
80
|
+
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options:
|
83
|
+
- --charset=UTF-8
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
hash: 3
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
version: "0"
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
hash: 3
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
version: "0"
|
104
|
+
requirements: []
|
105
|
+
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 1.3.7
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: A lightweight javascript MVC framework.
|
111
|
+
test_files:
|
112
|
+
- spec/app_generator_spec.rb
|
113
|
+
- spec/controller_generator_spec.rb
|
114
|
+
- spec/model_generator_spec.rb
|
115
|
+
- spec/rack_app_detector_spec.rb
|
116
|
+
- spec/scaffold_generator_spec.rb
|
117
|
+
- spec/spec_helper.rb
|