eyeballs 0.5.8.2 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,59 +1,36 @@
1
- ---
2
- dependencies:
3
- ruby-debug:
4
- group:
5
- - :test
6
- version: ">= 0"
7
- thor:
8
- group:
9
- - :default
10
- version: ">= 0"
11
- rspec:
12
- group:
13
- - :test
14
- version: ">= 0"
15
- sinatra:
16
- group:
17
- - :default
18
- version: ">= 0"
19
- jeweler:
20
- group:
21
- - :development
22
- version: ">= 0"
23
- activesupport:
24
- group:
25
- - :default
26
- version: ">= 0"
27
- specs:
28
- - activesupport:
29
- version: 2.3.8
30
- - columnize:
31
- version: 0.3.1
32
- - json_pure:
33
- version: 1.4.3
34
- - gemcutter:
35
- version: 0.5.0
36
- - git:
37
- version: 1.2.5
38
- - rubyforge:
39
- version: 2.0.4
40
- - jeweler:
41
- version: 1.4.0
42
- - linecache:
43
- version: "0.43"
44
- - rack:
45
- version: 1.2.1
46
- - rspec:
47
- version: 1.3.0
48
- - ruby-debug-base:
49
- version: 0.10.3
50
- - ruby-debug:
51
- version: 0.10.3
52
- - sinatra:
53
- version: "1.0"
54
- - thor:
55
- version: 0.13.8
56
- hash: 18ee2e0d3e9a46cd1d8e8c39951ba9414860f401
57
- sources:
58
- - Rubygems:
59
- uri: http://gemcutter.org
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.0.0)
5
+ columnize (0.3.1)
6
+ gemcutter (0.6.1)
7
+ git (1.2.5)
8
+ jeweler (1.4.0)
9
+ gemcutter (>= 0.1.0)
10
+ git (>= 1.2.5)
11
+ rubyforge (>= 2.0.0)
12
+ json_pure (1.4.6)
13
+ linecache (0.43)
14
+ rack (1.2.1)
15
+ rspec (1.3.0)
16
+ ruby-debug (0.10.3)
17
+ columnize (>= 0.1)
18
+ ruby-debug-base (~> 0.10.3.0)
19
+ ruby-debug-base (0.10.3)
20
+ linecache (>= 0.3)
21
+ rubyforge (2.0.4)
22
+ json_pure (>= 1.1.7)
23
+ sinatra (1.0)
24
+ rack (>= 1.0)
25
+ thor (0.14.1)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ activesupport
32
+ jeweler
33
+ rspec
34
+ ruby-debug
35
+ sinatra
36
+ thor
data/README.md CHANGED
@@ -43,7 +43,7 @@ At a very minimum, you should choose an adapter. There are a few to choose from:
43
43
  - **o\_O.dom** - a basic adapter without any persistence.
44
44
  - **o\_O.localstorage** - persist records to HTML5 local storage.
45
45
  - **o\_O.couchdb** - persist records to a local CouchDB instance, for building MVC CouchApps, for example.
46
- - **o\_O.rails** - An adapter for persisting models to a backend powered by Rails, or using Rails-style RESTful routing.
46
+ - **o\_O.rest** - An adapter for persisting models to a backend powered by Rails, or using Rails-style RESTful routing.
47
47
 
48
48
  Finally, you need a controller. The first release of eyeballs.js includes a controller as part of the jQuery driver. This adapter also depends on jQuery.livequery.
49
49
 
data/Rakefile CHANGED
@@ -27,7 +27,7 @@ begin
27
27
  require 'jeweler'
28
28
  Jeweler::Tasks.new do |s|
29
29
  s.name = "eyeballs"
30
- s.version = "0.5.8.2"
30
+ s.version = "0.5.9"
31
31
  s.author = "Paul Campbell"
32
32
  s.email = "paul@rslw.com"
33
33
  s.homepage = "http://www.github.com/paulca/eyeballs.js"
data/eyeballs.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{eyeballs}
8
- s.version = "0.5.8.2"
8
+ s.version = "0.5.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Paul Campbell"]
12
- s.date = %q{2010-08-28}
12
+ s.date = %q{2010-09-25}
13
13
  s.default_executable = %q{eyeballs}
14
14
  s.email = %q{paul@rslw.com}
15
15
  s.executables = ["eyeballs"]
@@ -60,6 +60,7 @@ Gem::Specification.new do |s|
60
60
  "test/index.html",
61
61
  "test/unit/qunit.css",
62
62
  "test/unit/qunit.js",
63
+ "test/unit/test_binding.html",
63
64
  "test/unit/test_controller.html",
64
65
  "test/unit/test_dom.html",
65
66
  "test/unit/test_dom_with_callbacks.html",
@@ -21,6 +21,12 @@ o_O.routes = {
21
21
  namespace: function(prefix, callback){
22
22
  callback(o_O.routes.router(prefix));
23
23
  },
24
+ resources: function(name){
25
+ this.match(name, {to:name + '#index'});
26
+ this.match(name + '/new', {to:name + '#add'});
27
+ this.match(name + '/:id/edit', {to:name + '#edit'});
28
+ this.match(name + '/:id', {to:name + '#show'});
29
+ },
24
30
  match: function(route, options){
25
31
  var parsed_route = route.o_O_trim('/')
26
32
 
@@ -91,6 +97,7 @@ o_O.routes = {
91
97
  return params;
92
98
  }
93
99
  });
100
+ return;
94
101
  }
95
102
  }
96
103
  }
@@ -38,6 +38,10 @@ o_O.render = function(template, data, options){
38
38
  {
39
39
  $(options.replace).replaceWith(rendered);
40
40
  }
41
+ if(options.html)
42
+ {
43
+ $(options.html).replaceWith(rendered);
44
+ }
41
45
  }
42
46
  });
43
47
  }
@@ -63,33 +67,4 @@ o_O.get_template = function(template, data, callback){
63
67
  callback(data, response);
64
68
  });
65
69
  }
66
- }
67
-
68
- if(typeof String.prototype.capitalize === 'undefined')
69
- {
70
- String.prototype.capitalize = function(){
71
- return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
72
- }
73
- }
74
-
75
- if(typeof String.prototype.underscore === 'undefined')
76
- {
77
- String.prototype.underscore = function(){
78
- return this.replace(/::/g, '/')
79
- .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
80
- .replace(/([a-z\d])([A-Z])/g, '$1_$2')
81
- .replace(/-/g, '_')
82
- .toLowerCase();
83
- }
84
- }
85
-
86
- if(typeof String.prototype.blank === 'undefined')
87
- {
88
- String.prototype.blank = function(){
89
- return /^\s*$/.test(this);
90
- }
91
- }
92
-
93
- String.prototype.o_O_trim = function(chars) {
94
- return this.replace(new RegExp("(^[" + chars + "]+|[" + chars + "]+$)", "g"), '')
95
70
  }
@@ -6,26 +6,29 @@ o_O.model = {
6
6
  var validates_presence_of, validates_length_of;
7
7
  var table_name = model_name.underscore() + 's';
8
8
  var initial_class_methods = [];
9
-
10
- class_methods = {
11
- validations: {presence: [], lengthliness: [], custom: []},
12
- methods: {},
13
- validates_presence_of: function(field){
14
- this.validations.presence.push({field: field});
15
- },
16
- validates_length_of: function(field, options){
17
- options.field = field;
18
- this.validations.lengthliness.push(options);
19
- },
20
- validates: function(validation){
21
- this.validations.custom.push(validation)
22
- }
23
- }
24
- for(var method in class_methods)
9
+
10
+ var class_methods = {}
11
+ if(typeof o_O.validations === 'object')
25
12
  {
26
- initial_class_methods.push(method);
13
+ class_methods = {
14
+ validations: {presence: [], lengthliness: [], custom: []},
15
+ methods: {},
16
+ validates_presence_of: function(field){
17
+ this.validations.presence.push({field: field});
18
+ },
19
+ validates_length_of: function(field, options){
20
+ options.field = field;
21
+ this.validations.lengthliness.push(options);
22
+ },
23
+ validates: function(validation){
24
+ this.validations.custom.push(validation)
25
+ }
26
+ }
27
+ for(var method in o_O.validations.class_methods)
28
+ {
29
+ initial_class_methods.push(method);
30
+ }
27
31
  }
28
-
29
32
 
30
33
  var run_callback = function(callback, method, object, response){
31
34
  try{
@@ -114,8 +117,11 @@ o_O.model = {
114
117
  },
115
118
  valid: function(){
116
119
  this.errors.length = 0;
117
-
118
- o_O.validations.run(this);
120
+
121
+ if(typeof o_O.validations === 'object')
122
+ {
123
+ o_O.validations.run(this);
124
+ }
119
125
 
120
126
  if(this.errors.length == 0)
121
127
  {
@@ -41,5 +41,19 @@ o_O.validations = {
41
41
  object.errors.push({field: field, type: 'presence', message: message})
42
42
  }
43
43
  }
44
+ },
45
+ class_methods: {
46
+ validations: {presence: [], lengthliness: [], custom: []},
47
+ methods: {},
48
+ validates_presence_of: function(field){
49
+ this.validations.presence.push({field: field});
50
+ },
51
+ validates_length_of: function(field, options){
52
+ options.field = field;
53
+ this.validations.lengthliness.push(options);
54
+ },
55
+ validates: function(validation){
56
+ this.validations.custom.push(validation)
57
+ }
44
58
  }
45
59
  }
data/src/o_O.js CHANGED
@@ -2,7 +2,8 @@ var o_O = function(){
2
2
 
3
3
  var bind_to;
4
4
  var object_to_bind_to = arguments[2];
5
- bind_to = (object_to_bind_to) ? object_to_bind_to : window;
5
+
6
+ bind_to = (object_to_bind_to) ? object_to_bind_to : o_O.config.default_bind_to();
6
7
 
7
8
  if(typeof arguments[1] === 'object')
8
9
  {
@@ -10,12 +11,16 @@ var o_O = function(){
10
11
  bind_to[controller_name] = o_O.controller.initialize(controller_name, arguments[1]);
11
12
  return bind_to[controller_name];
12
13
  }
13
-
14
- if(typeof arguments[1] === 'function')
14
+ else
15
15
  {
16
-
17
16
  var model_name = arguments[0];
18
17
  var model_initializer = arguments[1];
18
+
19
+ if(typeof model_initializer != 'function')
20
+ {
21
+ model_initializer = function(){}
22
+ }
23
+
19
24
  bind_to[model_name] = o_O.model.initialize(model_name, model_initializer);
20
25
 
21
26
  if(typeof o_O.models !== 'object')
@@ -28,7 +33,11 @@ var o_O = function(){
28
33
  }
29
34
  }
30
35
 
31
- o_O.config = {}
36
+ o_O.config = {
37
+ default_bind_to: function(){
38
+ return (o_O.config.bind_to) ? o_O.config.bind_to : window
39
+ }
40
+ }
32
41
  o_O.templates = {}
33
42
 
34
43
  o_O._uuid_default_prefix = '';
@@ -53,4 +62,33 @@ o_O.alert_errors = function(object){
53
62
  error_message = error_message + object.errors[i].message + "\n";
54
63
  }
55
64
  alert(error_message);
65
+ }
66
+
67
+ if(typeof String.prototype.capitalize === 'undefined')
68
+ {
69
+ String.prototype.capitalize = function(){
70
+ return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
71
+ }
72
+ }
73
+
74
+ if(typeof String.prototype.underscore === 'undefined')
75
+ {
76
+ String.prototype.underscore = function(){
77
+ return this.replace(/::/g, '/')
78
+ .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
79
+ .replace(/([a-z\d])([A-Z])/g, '$1_$2')
80
+ .replace(/-/g, '_')
81
+ .toLowerCase();
82
+ }
83
+ }
84
+
85
+ if(typeof String.prototype.blank === 'undefined')
86
+ {
87
+ String.prototype.blank = function(){
88
+ return /^\s*$/.test(this);
89
+ }
90
+ }
91
+
92
+ String.prototype.o_O_trim = function(chars) {
93
+ return this.replace(new RegExp("(^[" + chars + "]+|[" + chars + "]+$)", "g"), '')
56
94
  }
@@ -13,16 +13,5 @@
13
13
 
14
14
  <p>As you add models and controllers, don't forget to include them!</p>
15
15
 
16
- <script src="<%= prefix %>vendor/jquery/jquery-1.4.2.min.js"></script>
17
- <script src="<%= prefix %>vendor/mustache/mustache.0.3.0.js"></script>
18
- <script src="<%= prefix %>vendor/eyeballs/o_O.js"></script>
19
- <script src="<%= prefix %>vendor/eyeballs/modules/o_O.model.js"></script>
20
- <script src="<%= prefix %>vendor/eyeballs/modules/o_O.validations.js"></script>
21
- <script src="<%= prefix %>vendor/eyeballs/drivers/jquery/modules/o_O.controller.js"></script>
22
- <script src="<%= prefix %>vendor/eyeballs/drivers/jquery/modules/o_O.routes.js"></script>
23
- <script src="<%= prefix %>vendor/eyeballs/drivers/jquery/modules/o_O.support.js"></script>
24
- <script src="<%= prefix %>vendor/eyeballs/adapters/o_O.localstorage.js"></script>
25
- <script src="<%= prefix %>config/initializer.js"></script>
26
- <script src="<%= prefix %>config/routes.js"></script>
27
- <script src="<%= prefix %>app/models/<%= name.downcase %>.js"></script> </body>
16
+ </body>
28
17
  </html>
@@ -0,0 +1,44 @@
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/jquery-1.4.2.min.js"></script>
6
+ <script src="../../src/o_O.js"></script>
7
+ <script src="../../src/modules/o_O.model.js"></script>
8
+
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
+ var MyApp = {};
15
+
16
+ o_O.config.bind_to = MyApp;
17
+
18
+ o_O('Review');
19
+
20
+ $(document).ready(function(){
21
+
22
+ module("Models");
23
+
24
+ test('binding to a non-global object', 1, function(){
25
+ var test_model = MyApp.Review.initialize({title: 'Delicious'})
26
+ equals(test_model.title, 'Delicious', 'should just work as normal')
27
+ })
28
+
29
+ });
30
+ </script>
31
+
32
+ </head>
33
+ <body>
34
+ <h1 id="qunit-header">Binding Tests</h1>
35
+ <h2 id="qunit-banner"></h2>
36
+ <h2 id="qunit-userAgent"></h2>
37
+ <ol id="qunit-tests"></ol>
38
+
39
+ <div data-model="Review" data-id="paul">
40
+ <h1 data-attribute="title">Yeah!</h1>
41
+ <p data-attribute="content">Paris</p>
42
+ </div>
43
+ </body>
44
+ </html>
@@ -3,7 +3,6 @@
3
3
  <html>
4
4
  <head>
5
5
  <script src="../../dist/jquery/jquery-1.4.2.min.js"></script>
6
- <script src="../../dist/jquery/jquery.livequery.js"></script>
7
6
  <script src="../../dist/jquery/jquery.ba-hashchange.js"></script>
8
7
  <script src="../../src/o_O.js"></script>
9
8
  <script src="../../src/modules/o_O.model.js"></script>
@@ -52,6 +51,22 @@
52
51
  }
53
52
  });
54
53
 
54
+ var clicked_routes = []
55
+ o_O('SongsController', {
56
+ add: function(){
57
+ $('div#songs-add').html('ok')
58
+ },
59
+ index: function(){
60
+ $('div#songs-index').html('ok')
61
+ },
62
+ show: function(params){
63
+ $('div#songs-show').html('ok ' + params('id'))
64
+ },
65
+ edit: function(params){
66
+ $('div#songs-edit').html('ok ' + params('id'))
67
+ }
68
+ })
69
+
55
70
  o_O.routes.draw(function(map){
56
71
  map.root({to: "reviews#root"})
57
72
  map.match('/reviews/index/', {to: "reviews#index", with_args: 'test'});
@@ -59,6 +74,8 @@
59
74
  my.match('action', {to: "reviews#namespaced_index", with_args: 'test'})
60
75
  })
61
76
  map.match('/reviews/:test', {to: 'reviews#sending_params'})
77
+
78
+ map.resources('songs')
62
79
  })
63
80
 
64
81
  $(document).ready(function(){
@@ -105,13 +122,45 @@
105
122
  },100)
106
123
  })
107
124
 
125
+ asyncTest('resources new', function(){
126
+ $('a#add-song').click()
127
+ setTimeout(function(){
128
+ equals($('div#songs-add').text(), 'ok')
129
+ start();
130
+ }, 100)
131
+ })
132
+
133
+ asyncTest('resources index', function(){
134
+ $('a#index-song').click()
135
+ setTimeout(function(){
136
+ equals($('div#songs-index').text(), 'ok')
137
+ start();
138
+ }, 100)
139
+ })
140
+
141
+ asyncTest('resources edit', function(){
142
+ $('a#edit-song').click()
143
+ setTimeout(function(){
144
+ equals($('div#songs-edit').text(), 'ok 1')
145
+ start();
146
+ }, 100)
147
+ })
148
+
149
+ asyncTest('resources show', function(){
150
+ $('a#show-song').click()
151
+ setTimeout(function(){
152
+ equals($('div#songs-show').text(), 'ok 1')
153
+ start();
154
+ }, 100)
155
+ })
156
+
108
157
 
109
158
  });
110
159
  </script>
111
160
 
112
161
  </head>
113
162
  <body>
114
- <h1 id="qunit-header">Controller Tests</h1>
163
+ <h1 id="qunit-header">Routing Tests</h1>
115
164
  <h2 id="qunit-banner"></h2>
116
165
  <h2 id="qunit-userAgent"></h2>
117
166
  <ol id="qunit-tests"></ol>
@@ -127,5 +176,18 @@
127
176
  </div>
128
177
  <div id="root"></div>
129
178
  <div id="with_params"></div>
179
+
180
+ <a id="add-song" href="/songs/new" data-ajax-history="true">New Song</a>
181
+ <div id="songs-add"></div>
182
+
183
+ <a id="edit-song" href="/songs/1/edit" data-ajax-history="true">Edit Song</a>
184
+ <div id="songs-edit"></div>
185
+
186
+ <a id="show-song" href="/songs/1" data-ajax-history="true">Show Song</a>
187
+ <div id="songs-show"></div>
188
+
189
+ <a id="index-song" href="/songs/" data-ajax-history="true">Songs Index</a>
190
+ <div id="songs-index"></div>
191
+
130
192
  </body>
131
193
  </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: 67
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 8
10
- - 2
11
- version: 0.5.8.2
9
+ - 9
10
+ version: 0.5.9
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-08-28 00:00:00 +01:00
18
+ date: 2010-09-25 00:00:00 +02:00
20
19
  default_executable: eyeballs
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
@@ -99,6 +98,7 @@ files:
99
98
  - test/index.html
100
99
  - test/unit/qunit.css
101
100
  - test/unit/qunit.js
101
+ - test/unit/test_binding.html
102
102
  - test/unit/test_controller.html
103
103
  - test/unit/test_dom.html
104
104
  - test/unit/test_dom_with_callbacks.html