eyeballs 0.3.3.1 → 0.3.4
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.
- data/README.md +11 -0
- data/Rakefile +1 -1
- data/app.rb +6 -0
- data/lib/eyeballs/controller_generator.rb +1 -1
- data/lib/eyeballs/model_generator.rb +0 -1
- data/spec/controller_generator_spec.rb +2 -1
- data/spec/spec_helper.rb +19 -18
- data/src/o_O.js +13 -7
- data/templates/scaffold_controller.js +1 -1
- data/templates/scaffold_index.html +1 -1
- data/test/index.html +0 -0
- data/test/unit/test_model_with_callbacks.html +34 -15
- metadata +6 -6
- data/eyeballs.gemspec +0 -92
data/README.md
CHANGED
@@ -134,6 +134,17 @@ You can also add your own validations, again, similar to how Rails does things:
|
|
134
134
|
post.errors # => [{
|
135
135
|
# message: 'title should be present'}]
|
136
136
|
}) # yep, there's a save method too!
|
137
|
+
|
138
|
+
When you want to find things:
|
139
|
+
|
140
|
+
Post.find({
|
141
|
+
loading: function(){
|
142
|
+
console.log("I'm loading...")
|
143
|
+
},
|
144
|
+
success: function(post){
|
145
|
+
console.log("here I am")
|
146
|
+
}
|
147
|
+
})
|
137
148
|
|
138
149
|
And if you want to add your own methods:
|
139
150
|
|
data/Rakefile
CHANGED
data/app.rb
ADDED
@@ -6,7 +6,8 @@ describe Eyeballs::ControllerGenerator do
|
|
6
6
|
create_test_root
|
7
7
|
run_command("eyeballs generate controller Paul")
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
|
+
let(:controller_file) { file('app/controllers/paul_controller.js') }
|
10
11
|
|
11
12
|
it "should create my controller" do
|
12
13
|
controller_file.should exist
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'eyeballs'
|
2
2
|
require 'fileutils'
|
3
3
|
require 'ruby-debug'
|
4
|
+
require 'pathname'
|
4
5
|
Debugger.settings[:autoeval] = true
|
5
6
|
|
6
7
|
def create_test_root
|
@@ -16,27 +17,27 @@ def run_command(cmd)
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def file(*parts)
|
19
|
-
|
20
|
+
Pathname.new([test_root, *parts].join('/'))
|
20
21
|
end
|
21
22
|
|
22
23
|
def test_root
|
23
24
|
File.join(File.dirname(File.expand_path(__FILE__)), 'test_root')
|
24
25
|
end
|
25
26
|
|
26
|
-
class FileChecker
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
27
|
+
# class FileChecker
|
28
|
+
# def initialize(parts)
|
29
|
+
# @file = File.join(parts)
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# def exist?
|
33
|
+
# File.exists?(@file)
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# def read
|
37
|
+
# File.read(@file)
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# def to_s
|
41
|
+
# @file
|
42
|
+
# end
|
43
|
+
# end
|
data/src/o_O.js
CHANGED
@@ -190,16 +190,22 @@ o_O.model = {
|
|
190
190
|
find: function(id, callback){
|
191
191
|
if(this.adapter)
|
192
192
|
{
|
193
|
+
run_callback(callback, 'loading', this)
|
193
194
|
var model = this;
|
194
195
|
return this.adapter.find(this, id, function(returned_object){
|
195
|
-
|
196
|
+
found_object = model.initialize(returned_object);
|
197
|
+
if(!found_object['new_record'])
|
196
198
|
{
|
197
|
-
found_object =
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
callback
|
199
|
+
found_object['new_record'] = false;
|
200
|
+
}
|
201
|
+
if(found_object.id)
|
202
|
+
{
|
203
|
+
console.log(found_object)
|
204
|
+
run_callback(callback, 'success', found_object);
|
205
|
+
}
|
206
|
+
else
|
207
|
+
{
|
208
|
+
run_callback(callback, 'failure', found_object);
|
203
209
|
}
|
204
210
|
});
|
205
211
|
}
|
@@ -4,7 +4,7 @@ o_O('<%= name.capitalize.pluralize -%>Controller', {
|
|
4
4
|
for(var id in <%= name.downcase.pluralize %>)
|
5
5
|
{
|
6
6
|
var <%= name.downcase %> = <%= name.downcase.pluralize %>[id];
|
7
|
-
o_O.render('<%= name.downcase.pluralize %>/_<%= name.downcase %>', <%= name.downcase %>, {append: 'div#<%= name.pluralize %>'})
|
7
|
+
o_O.render('<%= name.downcase.pluralize %>/_<%= name.downcase %>', <%= name.downcase %>, {append: 'div#<%= name.downcase.pluralize %>'})
|
8
8
|
}
|
9
9
|
});
|
10
10
|
},
|
data/test/index.html
ADDED
File without changes
|
@@ -11,6 +11,8 @@
|
|
11
11
|
|
12
12
|
<script>
|
13
13
|
|
14
|
+
o_O.model.adapter = o_O.dom;
|
15
|
+
|
14
16
|
o_O('Review', function(that){
|
15
17
|
that.validates_presence_of('title');
|
16
18
|
that.validates_presence_of('content');
|
@@ -31,6 +33,21 @@
|
|
31
33
|
|
32
34
|
module("Models");
|
33
35
|
|
36
|
+
asyncTest('find() an existent object',2, function(){
|
37
|
+
Review.find('thing', {
|
38
|
+
loading: function(){
|
39
|
+
ok('this should be called')
|
40
|
+
},
|
41
|
+
success: function(){
|
42
|
+
ok('this should be called');
|
43
|
+
start();
|
44
|
+
},
|
45
|
+
failure: function(){
|
46
|
+
ok(false, 'this should not be called');
|
47
|
+
}
|
48
|
+
})
|
49
|
+
});
|
50
|
+
|
34
51
|
asyncTest('a valid, successful model', 2, function(){
|
35
52
|
var myReview = Review.initialize({title: "Biscuit", content: "Some Content"});
|
36
53
|
myReview.save({
|
@@ -76,21 +93,21 @@
|
|
76
93
|
});
|
77
94
|
})
|
78
95
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
96
|
+
asyncTest('updating an invalid review', 1, function(){
|
97
|
+
var myReview = Review.initialize();
|
98
|
+
myReview.update_attributes({}, {
|
99
|
+
success: function(){
|
100
|
+
ok(false, 'should not call the success callback');
|
101
|
+
},
|
102
|
+
invalid: function(){
|
103
|
+
ok(true, 'should call the invalid callback');
|
104
|
+
start();
|
105
|
+
},
|
106
|
+
loading: function(){
|
107
|
+
ok(false, 'should not call the loading callback');
|
108
|
+
}
|
109
|
+
});
|
110
|
+
})
|
94
111
|
|
95
112
|
test('destroying a review', 2, function(){
|
96
113
|
var myReview = Review.initialize();
|
@@ -114,5 +131,7 @@
|
|
114
131
|
<h2 id="qunit-userAgent"></h2>
|
115
132
|
<ol id="qunit-tests"></ol>
|
116
133
|
</div>
|
134
|
+
|
135
|
+
<div data-id="thing"></div>
|
117
136
|
</body>
|
118
137
|
</html>
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eyeballs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
|
11
|
-
version: 0.3.3.1
|
9
|
+
- 4
|
10
|
+
version: 0.3.4
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Paul Campbell
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-17 00:00:00 -07:00
|
20
19
|
default_executable: eyeballs
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
@@ -59,12 +58,12 @@ files:
|
|
59
58
|
- CHANGELOG
|
60
59
|
- README.md
|
61
60
|
- Rakefile
|
61
|
+
- app.rb
|
62
62
|
- bin/eyeballs
|
63
63
|
- config.ru
|
64
64
|
- dist/jquery-1.4.2.min.js
|
65
65
|
- dist/jquery.livequery.js
|
66
66
|
- dist/mustache.js
|
67
|
-
- eyeballs.gemspec
|
68
67
|
- eyeballs.js.gemspec
|
69
68
|
- lib/eyeballs.rb
|
70
69
|
- lib/eyeballs/app_detector.rb
|
@@ -86,6 +85,7 @@ files:
|
|
86
85
|
- templates/scaffold_edit.html.mustache
|
87
86
|
- templates/scaffold_index.html
|
88
87
|
- templates/scaffold_partial.html.mustache
|
88
|
+
- test/index.html
|
89
89
|
- test/unit/qunit.css
|
90
90
|
- test/unit/qunit.js
|
91
91
|
- test/unit/test_controller.html
|
data/eyeballs.gemspec
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{eyeballs}
|
8
|
-
s.version = "0.3.3.1"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Paul Campbell"]
|
12
|
-
s.date = %q{2010-06-10}
|
13
|
-
s.default_executable = %q{eyeballs}
|
14
|
-
s.email = %q{paul@rslw.com}
|
15
|
-
s.executables = ["eyeballs"]
|
16
|
-
s.extra_rdoc_files = [
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
"CHANGELOG",
|
21
|
-
"README.md",
|
22
|
-
"Rakefile",
|
23
|
-
"bin/eyeballs",
|
24
|
-
"config.ru",
|
25
|
-
"dist/jquery-1.4.2.min.js",
|
26
|
-
"dist/jquery.livequery.js",
|
27
|
-
"dist/mustache.js",
|
28
|
-
"eyeballs.gemspec",
|
29
|
-
"eyeballs.js.gemspec",
|
30
|
-
"lib/eyeballs.rb",
|
31
|
-
"lib/eyeballs/app_detector.rb",
|
32
|
-
"lib/eyeballs/app_generator.rb",
|
33
|
-
"lib/eyeballs/cli.rb",
|
34
|
-
"lib/eyeballs/controller_generator.rb",
|
35
|
-
"lib/eyeballs/model_generator.rb",
|
36
|
-
"lib/eyeballs/scaffold_generator.rb",
|
37
|
-
"src/jquery.o_O.couchdb.js",
|
38
|
-
"src/jquery.o_O.dom.js",
|
39
|
-
"src/jquery.o_O.js",
|
40
|
-
"src/jquery.o_O.rails.js",
|
41
|
-
"src/o_O.js",
|
42
|
-
"src/o_O.localstorage.js",
|
43
|
-
"templates/app_root/index.html",
|
44
|
-
"templates/controller.js",
|
45
|
-
"templates/model.js",
|
46
|
-
"templates/scaffold_controller.js",
|
47
|
-
"templates/scaffold_edit.html.mustache",
|
48
|
-
"templates/scaffold_index.html",
|
49
|
-
"templates/scaffold_partial.html.mustache",
|
50
|
-
"test/unit/qunit.css",
|
51
|
-
"test/unit/qunit.js",
|
52
|
-
"test/unit/test_controller.html",
|
53
|
-
"test/unit/test_dom.html",
|
54
|
-
"test/unit/test_dom_with_callbacks.html",
|
55
|
-
"test/unit/test_form.html",
|
56
|
-
"test/unit/test_localstorage.html",
|
57
|
-
"test/unit/test_model.html",
|
58
|
-
"test/unit/test_model_with_callbacks.html",
|
59
|
-
"test/unit/test_rails.html"
|
60
|
-
]
|
61
|
-
s.has_rdoc = false
|
62
|
-
s.homepage = %q{http://www.github.com/paulca/eyeballs.js}
|
63
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
64
|
-
s.require_paths = ["lib"]
|
65
|
-
s.rubygems_version = %q{1.3.7}
|
66
|
-
s.summary = %q{A lightweight javascript MVC framework.}
|
67
|
-
s.test_files = [
|
68
|
-
"spec/app_generator_spec.rb",
|
69
|
-
"spec/controller_generator_spec.rb",
|
70
|
-
"spec/model_generator_spec.rb",
|
71
|
-
"spec/rack_app_detector_spec.rb",
|
72
|
-
"spec/scaffold_generator_spec.rb",
|
73
|
-
"spec/spec_helper.rb"
|
74
|
-
]
|
75
|
-
|
76
|
-
if s.respond_to? :specification_version then
|
77
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
78
|
-
s.specification_version = 3
|
79
|
-
|
80
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
81
|
-
s.add_runtime_dependency(%q<thor>, [">= 0"])
|
82
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
83
|
-
else
|
84
|
-
s.add_dependency(%q<thor>, [">= 0"])
|
85
|
-
s.add_dependency(%q<activesupport>, [">= 0"])
|
86
|
-
end
|
87
|
-
else
|
88
|
-
s.add_dependency(%q<thor>, [">= 0"])
|
89
|
-
s.add_dependency(%q<activesupport>, [">= 0"])
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|