mongo3 0.0.5 → 0.0.6

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.
Files changed (57) hide show
  1. data/README.rdoc +6 -2
  2. data/Rakefile +1 -0
  3. data/data/populate +13 -11
  4. data/lib/controllers/databases.rb +3 -3
  5. data/lib/controllers/explore.rb +7 -5
  6. data/lib/helpers/main_helper.rb +24 -0
  7. data/lib/mongo3/connection.rb +105 -59
  8. data/lib/mongo3/node.rb +35 -6
  9. data/lib/mongo3.rb +1 -1
  10. data/lib/public/javascripts/{Jit/jit.js → jit.js} +0 -0
  11. data/lib/views/databases/_results.erb +29 -12
  12. data/lib/views/explore/explore.erb +52 -31
  13. data/lib/views/layout.erb +2 -6
  14. data/spec/mongo3/connection_spec.rb +40 -6
  15. metadata +13 -45
  16. data/lib/public/javascripts/Jit/Examples/Hypertree/example1.html +0 -57
  17. data/lib/public/javascripts/Jit/Examples/Hypertree/example1.js +0 -427
  18. data/lib/public/javascripts/Jit/Examples/Hypertree/example2.html +0 -58
  19. data/lib/public/javascripts/Jit/Examples/Hypertree/example2.js +0 -310
  20. data/lib/public/javascripts/Jit/Examples/Hypertree/example3.html +0 -199
  21. data/lib/public/javascripts/Jit/Examples/Hypertree/example3.js +0 -615
  22. data/lib/public/javascripts/Jit/Examples/Other/example1.html +0 -58
  23. data/lib/public/javascripts/Jit/Examples/Other/example1.js +0 -566
  24. data/lib/public/javascripts/Jit/Examples/Other/example2.html +0 -58
  25. data/lib/public/javascripts/Jit/Examples/Other/example2.js +0 -304
  26. data/lib/public/javascripts/Jit/Examples/Other/example3.html +0 -58
  27. data/lib/public/javascripts/Jit/Examples/Other/example3.js +0 -304
  28. data/lib/public/javascripts/Jit/Examples/RGraph/example1.html +0 -57
  29. data/lib/public/javascripts/Jit/Examples/RGraph/example1.js +0 -475
  30. data/lib/public/javascripts/Jit/Examples/RGraph/example2.html +0 -58
  31. data/lib/public/javascripts/Jit/Examples/RGraph/example2.js +0 -356
  32. data/lib/public/javascripts/Jit/Examples/RGraph/example3.html +0 -199
  33. data/lib/public/javascripts/Jit/Examples/RGraph/example3.js +0 -622
  34. data/lib/public/javascripts/Jit/Examples/Spacetree/example1.html +0 -91
  35. data/lib/public/javascripts/Jit/Examples/Spacetree/example1.js +0 -890
  36. data/lib/public/javascripts/Jit/Examples/Spacetree/example2.html +0 -90
  37. data/lib/public/javascripts/Jit/Examples/Spacetree/example2.js +0 -213
  38. data/lib/public/javascripts/Jit/Examples/Spacetree/example3.html +0 -75
  39. data/lib/public/javascripts/Jit/Examples/Spacetree/example3.js +0 -863
  40. data/lib/public/javascripts/Jit/Examples/Treemap/example1.html +0 -56
  41. data/lib/public/javascripts/Jit/Examples/Treemap/example1.js +0 -95
  42. data/lib/public/javascripts/Jit/Examples/Treemap/example2.html +0 -61
  43. data/lib/public/javascripts/Jit/Examples/Treemap/example2.js +0 -750
  44. data/lib/public/javascripts/Jit/Examples/Treemap/example3.html +0 -62
  45. data/lib/public/javascripts/Jit/Examples/Treemap/example3.js +0 -775
  46. data/lib/public/javascripts/Jit/Examples/css/Hypertree.css +0 -0
  47. data/lib/public/javascripts/Jit/Examples/css/Other.css +0 -8
  48. data/lib/public/javascripts/Jit/Examples/css/RGraph.css +0 -0
  49. data/lib/public/javascripts/Jit/Examples/css/Spacetree.css +0 -0
  50. data/lib/public/javascripts/Jit/Examples/css/Treemap.css +0 -78
  51. data/lib/public/javascripts/Jit/Examples/css/base.css +0 -106
  52. data/lib/public/javascripts/Jit/Examples/css/col1.png +0 -0
  53. data/lib/public/javascripts/Jit/Examples/css/col2.png +0 -0
  54. data/lib/public/javascripts/Jit/Examples/css/gradient.png +0 -0
  55. data/lib/public/javascripts/Jit/Extras/excanvas.js +0 -35
  56. data/lib/public/javascripts/Jit/jit-yc.js +0 -1
  57. data/lib/public/javascripts/Jit-1.1.3.zip +0 -0
@@ -91,41 +91,59 @@
91
91
  domElement.innerHTML = truncate( unescape(node.name), 15 );
92
92
 
93
93
  addEvent(domElement, 'click', function () {
94
- var children_count = 0;
95
- for( var i in node.adjacencies )
96
- children_count += 1;
94
+ var children_count = 0;
95
+ for( var i in node.adjacencies )
96
+ children_count += 1;
97
97
 
98
- if ( node.data && children_count == 1 && node.data.dyna )
99
- {
100
- Log.write( "fetching new data..." );
101
- var url = "/explore/more_data/";
102
- url += node.data.path_ids + "/" + node.data.path_names + "/";
103
- $.ajax( {
104
- dataType: 'script',
105
- type: 'GET',
106
- url: url
107
- });
108
- }
109
- else
110
- {
111
- if( node.data.path_ids.split( '|' ).length < 4 ) {
112
- Log.write( "centering..." );
113
- ht.onClick( node.id, {
114
- Move: { enable: true, offsetX: 30, offsetY: 5 },
115
- onComplete: function() {
116
- $.ajax( {
117
- dataType: 'script',
118
- type: 'GET',
119
- url: "/explore/update_crumb/" + node.data.path_ids + "/" + node.data.path_names });
120
- } });
121
- }
122
- else {
123
- Log.write( "no more data" );
124
- }
125
- }
98
+ // Bail if slave node
99
+ if ( node.data && node.data.slave )
100
+ {
101
+ Log.write( "Slave node detected. No action" );
102
+ return;
103
+ }
104
+
105
+ if ( node.data && node.data.dyna && (children_count == 1 || node.data.master) )
106
+ {
107
+ Log.write( "fetching new data..." );
108
+ var url = "/explore/more_data/";
109
+ url += node.data.path_ids + "/" + node.data.path_names + "/";
110
+ $.ajax( {
111
+ dataType: 'script',
112
+ type: 'GET',
113
+ url: url,
114
+ success: function() { node.data.dyna = false; }
115
+ });
116
+ }
117
+ else
118
+ {
119
+ if( node.data.path_ids.split( '|' ).length < 4 ) {
120
+ Log.write( "centering..." );
121
+ ht.onClick( node.id, {
122
+ Move: { enable: true, offsetX: 30, offsetY: 5 },
123
+ onComplete: function() {
124
+ $.ajax( {
125
+ dataType: 'script',
126
+ type: 'GET',
127
+ url: "/explore/update_crumb/" + node.data.path_ids + "/" + node.data.path_names });
128
+ } });
129
+ }
130
+ else {
131
+ Log.write( "no more data" );
132
+ }
133
+ }
126
134
  });
127
135
  },
128
136
 
137
+ onBeforePlotLine: function(adj) {
138
+ var nodeTo = adj.nodeTo;
139
+ var nodeFrom = adj.nodeFrom;
140
+ if( nodeFrom.data.slave && nodeTo.data.master )
141
+ {
142
+ adj.data.$lineWidth = 3;
143
+ adj.data.$color = "#f00";
144
+ }
145
+ },
146
+
129
147
  onPlaceLabel: function(domElement, node){
130
148
  var item = $(domElement);
131
149
 
@@ -145,6 +163,9 @@
145
163
  onBeforePlotNode: function( node ) {
146
164
  level = node.data.path_ids.split("|").length;
147
165
 
166
+ if( node.data.slave || node.data.master )
167
+ return;
168
+
148
169
  if( level == 1 )
149
170
  {
150
171
  node.data.$dim = 10;
data/lib/views/layout.erb CHANGED
@@ -5,12 +5,8 @@
5
5
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
6
  <link rel="icon" href="/favicon.ico" type="image/x-icon"/>
7
7
  <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
8
- <link rel="stylesheet" href="/stylesheets/mongo3.css" type="text/css" media="screen" />
9
- <script src="/javascripts/jquery_min.js" type="text/javascript"></script>
10
- <script src="/javascripts/jquery_ui_min.js" type="text/javascript"></script>
11
- <script src="/javascripts/jquery.tools.min.js" type="text/javascript"></script>
12
- <script src="/javascripts/application.js" type="text/javascript"></script>
13
- <script src="/javascripts/jit.min.js" type="text/javascript"></script>
8
+ <%= stylesheets %w[mongo3] %>
9
+ <%= javascripts %w[jquery_min jquery_ui_min jquery.tools.min application jit.min] %>
14
10
  </head>
15
11
 
16
12
  <body id="body">
@@ -38,9 +38,10 @@ describe Mongo3::Connection do
38
38
  end
39
39
 
40
40
  it "should delete a row correctly" do
41
+ before = @cltn1.count
41
42
  obj = @cltn1.find_one()
42
43
  @mongo3.delete_row( "home|test|mongo3_test_db|test1_cltn", obj['_id'].to_s )
43
- @db['test1_cltn'].count.should == 9
44
+ @db['test1_cltn'].count.should == before-1
44
45
  end
45
46
 
46
47
  it "should drop a cltn correctly" do
@@ -110,23 +111,23 @@ describe Mongo3::Connection do
110
111
 
111
112
  it "should build a adjacencies from cltn correctly" do
112
113
  adjs = @mongo3.build_sub_tree( 200, "home|test|mongo3_test_db" ).to_adjacencies
113
- adjs.size.should == 4
114
+ adjs.size.should == 3
114
115
  adjs.first[:name].should == 'mongo3_test_db'
115
116
  adjs.first[:id].should == 200
116
- adjs.first[:adjacencies].should have(3).items
117
+ adjs.first[:adjacencies].should have(2).items
117
118
  end
118
119
 
119
120
  it "should build a partial tree correctly" do
120
121
  root = @mongo3.build_partial_tree( "home|test|mongo3_test_db" )
121
- root.find( "test_2" ).children.should have(3).items
122
+ root.find( "test_2" ).children.should have(0).items
122
123
  end
123
124
  end
124
125
 
125
126
  describe "paginate db" do
126
127
  it "should paginate a db correctly" do
127
128
  rows = @mongo3.paginate_db( "home|test|mongo3_test_db" )
128
- rows.size.should == 3
129
- rows.total_entries.should == 3
129
+ rows.size.should == 2
130
+ rows.total_entries.should == 2
130
131
  end
131
132
  end
132
133
 
@@ -143,4 +144,37 @@ describe Mongo3::Connection do
143
144
  rows.total_entries.should == 4
144
145
  end
145
146
  end
147
+
148
+ describe "indexes" do
149
+ it "should list indexes correctly" do
150
+ indexes = @mongo3.indexes_for( "home|test|mongo3_test_db|test1_cltn" )
151
+ indexes.should_not be_nil
152
+ indexes.keys.should have(1).item
153
+ indexes.keys.first.should == '_id_'
154
+ end
155
+
156
+ it "should add an index correctly" do
157
+ indexes = @mongo3.indexes_for( "home|test|mongo3_test_db|test1_cltn" )
158
+ before = indexes.size
159
+ @mongo3.create_index( "home|test|mongo3_test_db|test1_cltn", [[:name, Mongo::ASCENDING]], {:unique => 1} )
160
+ indexes = @mongo3.indexes_for( "home|test|mongo3_test_db|test1_cltn" )
161
+ indexes.size.should == before + 1
162
+ end
163
+
164
+ it "should add a compound index correctly" do
165
+ indexes = @mongo3.indexes_for( "home|test|mongo3_test_db|test1_cltn" )
166
+ before = indexes.size
167
+ @mongo3.create_index( "home|test|mongo3_test_db|test1_cltn", [[:name, Mongo::ASCENDING], [:_id, Mongo::DESCENDING]], {:unique => 1} )
168
+ indexes = @mongo3.indexes_for( "home|test|mongo3_test_db|test1_cltn" )
169
+ indexes.size.should == before + 1
170
+ end
171
+
172
+ it "should drop an index correctly" do
173
+ indexes = @mongo3.indexes_for( "home|test|mongo3_test_db|test1_cltn" )
174
+ before = indexes.size
175
+ @mongo3.drop_index( "home|test|mongo3_test_db|test1_cltn", "name_1" )
176
+ indexes = @mongo3.indexes_for( "home|test|mongo3_test_db|test1_cltn" )
177
+ indexes.size.should == before - 1
178
+ end
179
+ end
146
180
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernand Galiana
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-29 00:00:00 -07:00
12
+ date: 2009-12-30 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,6 +42,16 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 3.0.0
44
44
  version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: memcache-client
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.5.0
54
+ version:
45
55
  - !ruby/object:Gem::Dependency
46
56
  name: bones
47
57
  type: :development
@@ -168,50 +178,8 @@ files:
168
178
  - lib/public/images/tooltip/white_arrow_big.png
169
179
  - lib/public/images/tooltip/white_big.png
170
180
  - lib/public/javascripts/.DS_Store
171
- - lib/public/javascripts/Jit-1.1.3.zip
172
- - lib/public/javascripts/Jit/Examples/Hypertree/example1.html
173
- - lib/public/javascripts/Jit/Examples/Hypertree/example1.js
174
- - lib/public/javascripts/Jit/Examples/Hypertree/example2.html
175
- - lib/public/javascripts/Jit/Examples/Hypertree/example2.js
176
- - lib/public/javascripts/Jit/Examples/Hypertree/example3.html
177
- - lib/public/javascripts/Jit/Examples/Hypertree/example3.js
178
- - lib/public/javascripts/Jit/Examples/Other/example1.html
179
- - lib/public/javascripts/Jit/Examples/Other/example1.js
180
- - lib/public/javascripts/Jit/Examples/Other/example2.html
181
- - lib/public/javascripts/Jit/Examples/Other/example2.js
182
- - lib/public/javascripts/Jit/Examples/Other/example3.html
183
- - lib/public/javascripts/Jit/Examples/Other/example3.js
184
- - lib/public/javascripts/Jit/Examples/RGraph/example1.html
185
- - lib/public/javascripts/Jit/Examples/RGraph/example1.js
186
- - lib/public/javascripts/Jit/Examples/RGraph/example2.html
187
- - lib/public/javascripts/Jit/Examples/RGraph/example2.js
188
- - lib/public/javascripts/Jit/Examples/RGraph/example3.html
189
- - lib/public/javascripts/Jit/Examples/RGraph/example3.js
190
- - lib/public/javascripts/Jit/Examples/Spacetree/example1.html
191
- - lib/public/javascripts/Jit/Examples/Spacetree/example1.js
192
- - lib/public/javascripts/Jit/Examples/Spacetree/example2.html
193
- - lib/public/javascripts/Jit/Examples/Spacetree/example2.js
194
- - lib/public/javascripts/Jit/Examples/Spacetree/example3.html
195
- - lib/public/javascripts/Jit/Examples/Spacetree/example3.js
196
- - lib/public/javascripts/Jit/Examples/Treemap/example1.html
197
- - lib/public/javascripts/Jit/Examples/Treemap/example1.js
198
- - lib/public/javascripts/Jit/Examples/Treemap/example2.html
199
- - lib/public/javascripts/Jit/Examples/Treemap/example2.js
200
- - lib/public/javascripts/Jit/Examples/Treemap/example3.html
201
- - lib/public/javascripts/Jit/Examples/Treemap/example3.js
202
- - lib/public/javascripts/Jit/Examples/css/Hypertree.css
203
- - lib/public/javascripts/Jit/Examples/css/Other.css
204
- - lib/public/javascripts/Jit/Examples/css/RGraph.css
205
- - lib/public/javascripts/Jit/Examples/css/Spacetree.css
206
- - lib/public/javascripts/Jit/Examples/css/Treemap.css
207
- - lib/public/javascripts/Jit/Examples/css/base.css
208
- - lib/public/javascripts/Jit/Examples/css/col1.png
209
- - lib/public/javascripts/Jit/Examples/css/col2.png
210
- - lib/public/javascripts/Jit/Examples/css/gradient.png
211
- - lib/public/javascripts/Jit/Extras/excanvas.js
212
- - lib/public/javascripts/Jit/jit-yc.js
213
- - lib/public/javascripts/Jit/jit.js
214
181
  - lib/public/javascripts/application.js
182
+ - lib/public/javascripts/jit.js
215
183
  - lib/public/javascripts/jit.min.js
216
184
  - lib/public/javascripts/jquery.example.js
217
185
  - lib/public/javascripts/jquery.tools.min.js
@@ -1,57 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5
- <title>Hypertree - Tree Animation</title>
6
-
7
- <!-- CSS Files -->
8
- <link type="text/css" href="../css/base.css" rel="stylesheet" />
9
- <link type="text/css" href="../css/Hypertree.css" rel="stylesheet" />
10
-
11
- <!--[if IE]><script language="javascript" type="text/javascript" src="../../Extras/excanvas.js"></script><![endif]-->
12
-
13
- <!-- JIT Library File -->
14
- <script language="javascript" type="text/javascript" src="../../jit.js"></script>
15
-
16
- <!-- Example File -->
17
- <script language="javascript" type="text/javascript" src="example1.js"></script>
18
- </head>
19
-
20
- <body onload="init();">
21
- <div id="container">
22
-
23
- <div id="left-container">
24
-
25
-
26
-
27
- <div class="text">
28
- <h4>
29
- Tree Animation
30
- </h4>
31
-
32
- A static JSON Tree structure is used as input for this animation.<br /><br />
33
- Clicking on a node should move the tree and center that node.<br /><br />
34
- The centered node's children are displayed in a relations list in the right column.
35
-
36
- </div>
37
-
38
- <div id="id-list"></div>
39
-
40
-
41
- <div style="text-align:center;"><a href="example1.js">See the Example Code</a></div>
42
- </div>
43
-
44
- <div id="center-container">
45
- <div id="infovis"></div>
46
- </div>
47
-
48
- <div id="right-container">
49
-
50
- <div id="inner-details"></div>
51
-
52
- </div>
53
-
54
- <div id="log"></div>
55
- </div>
56
- </body>
57
- </html>