modularity-rails 0.12.0 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Modularity::Rails [![Build Status](https://secure.travis-ci.org/kevgo/modularity-rails.png)](http://travis-ci.org/#!/kevgo/modularity-rails)
2
2
 
3
+ A lightweight, modular, object and component oriented frontend framework for Rails applications.
4
+
3
5
  Makes the [Modularity CoffeeScript](http://github.com/kevgo/modularity-coffeescript) library available to
4
6
  Rails 3.1 applications.
5
7
 
@@ -33,23 +33,6 @@ describe 'PersistenceManager', ->
33
33
  persistence_manager.key.should.equal 'id'
34
34
 
35
35
 
36
- describe 'clone', ->
37
-
38
- clone = null
39
- beforeEach ->
40
- clone = persistence_manager.clone entry_1
41
-
42
- it 'returns an object that has the same properties as the given object', ->
43
- clone.id.should.equal 1
44
- clone.value.should.equal 'one'
45
-
46
- it 'returns an object that can be changed independently from the given object', ->
47
- clone.id = 2
48
- clone.value = 'two'
49
- entry_1.id.should == 1
50
- entry_1.value.should == 'one'
51
-
52
-
53
36
  describe 'create', ->
54
37
  new_obj = {value: 'foo'}
55
38
 
@@ -1,6 +1,25 @@
1
1
  #= require spec_helper
2
2
  #= require modularity/tools/object_tools
3
3
 
4
+
5
+ describe 'clone', ->
6
+
7
+ clone = null
8
+ entry_1 = {id: 1, value: 'one'}
9
+ beforeEach ->
10
+ clone = modularity.clone_hash entry_1
11
+
12
+ it 'returns an object that has the same properties as the given object', ->
13
+ clone.id.should.equal 1
14
+ clone.value.should.equal 'one'
15
+
16
+ it 'returns an object that can be changed independently from the given object', ->
17
+ clone.id = 2
18
+ clone.value = 'two'
19
+ entry_1.id.should == 1
20
+ entry_1.value.should == 'one'
21
+
22
+
4
23
  describe 'object_tools', ->
5
24
 
6
25
  describe 'object_diff', ->
@@ -1,3 +1,3 @@
1
1
  module ModularityRails
2
- VERSION = "0.12.0"
2
+ VERSION = "0.12.1"
3
3
  end
@@ -1,3 +1,4 @@
1
+ #= require modularity/data/ajax_loader
1
2
  #= require modularity/data/indexed_cache
2
3
  #= require modularity/tools/object_tools
3
4
 
@@ -17,12 +18,8 @@ class modularity.PersistenceManager
17
18
 
18
19
  @key = params.key or 'id'
19
20
 
20
-
21
- # Returns a deep replica of the given object.
22
- clone: (obj) ->
23
- result = {}
24
- result[key] = value for own key, value of obj
25
- result
21
+ # For handling parallel requests to the server.
22
+ @loader = new modularity.AjaxLoader { cache: no }
26
23
 
27
24
 
28
25
  # Returns the URL to access the collection of objects.
@@ -73,15 +70,11 @@ class modularity.PersistenceManager
73
70
  return callback client_obj
74
71
 
75
72
  # No data on client at all --> load data from server.
76
- jQuery.ajax {
77
- url: "#{@base_url}/#{key}"
78
- cache: no
79
- success: (server_entry) =>
80
- @server_data.add server_entry
81
- client_entry = @clone server_entry
82
- @client_data.add client_entry
83
- callback client_entry
84
- }
73
+ @loader.get "#{@base_url}/#{key}", (server_entry) =>
74
+ @server_data.add server_entry
75
+ client_entry = @clone server_entry
76
+ @client_data.add client_entry
77
+ callback client_entry
85
78
 
86
79
 
87
80
  # Loads all objects from the server.
@@ -107,6 +100,9 @@ class modularity.PersistenceManager
107
100
  @create obj, callback
108
101
 
109
102
 
103
+ # Updates the given object.
104
+ # The given object must exist on the server already,
105
+ # and have a proper value in the key attribute.
110
106
  update: (obj, callback) ->
111
107
 
112
108
  # Create a new hash, containing only the changed attributes between obj and it's replica in @server_data.
@@ -128,4 +124,4 @@ class modularity.PersistenceManager
128
124
  @server_data.add server_obj
129
125
  callback server_obj if callback
130
126
  }
131
-
127
+
@@ -1,6 +1,16 @@
1
1
  # Returns an object that contains only the attributes
2
2
  # that are different between obj_1 and obj_2.
3
3
  # Only looks for changed attributes, not missing attributes.
4
+
5
+
6
+ # Returns a replica of the given hash.
7
+ # Don't use this method for real objects with superclasses, prototypes, and stuff.
8
+ modularity.clone_hash = (obj) ->
9
+ result = {}
10
+ result[key] = value for own key, value of obj
11
+ result
12
+
13
+
4
14
  modularity.object_diff = (obj_1, obj_2) ->
5
15
  result = {}
6
16
  for own key, value_2 of obj_2
@@ -13,3 +23,4 @@ modularity.object_diff = (obj_1, obj_2) ->
13
23
  modularity.object_length = (obj) ->
14
24
  # NOTE(KG): This doesn't work in IE8.
15
25
  Object.keys(obj).length
26
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modularity-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70234292434960 !ruby/object:Gem::Requirement
16
+ requirement: &70133478527080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70234292434960
24
+ version_requirements: *70133478527080
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: capybara-webkit
27
- requirement: &70234292434440 !ruby/object:Gem::Requirement
27
+ requirement: &70133478526560 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70234292434440
35
+ version_requirements: *70133478526560
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: evergreen
38
- requirement: &70234292433920 !ruby/object:Gem::Requirement
38
+ requirement: &70133478525980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70234292433920
46
+ version_requirements: *70133478525980
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rb-fsevent
49
- requirement: &70234292433260 !ruby/object:Gem::Requirement
49
+ requirement: &70133478525420 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70234292433260
57
+ version_requirements: *70133478525420
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-livereload
60
- requirement: &70234292432580 !ruby/object:Gem::Requirement
60
+ requirement: &70133478524900 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70234292432580
68
+ version_requirements: *70133478524900
69
69
  description: Description of ModularityRails.
70
70
  email:
71
71
  - kevin.goslar@gmail.com