mongo3 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/lib/app.rb +1 -1
  2. data/lib/controllers/collections.rb +4 -2
  3. data/lib/controllers/explore.rb +5 -1
  4. data/lib/helpers/collection_helper.rb +6 -3
  5. data/lib/helpers/crumb_helper.rb +3 -3
  6. data/lib/helpers/database_helper.rb +6 -3
  7. data/lib/helpers/explore_helper.rb +6 -3
  8. data/lib/helpers/paths_helper.rb +6 -3
  9. data/lib/mongo3/connection.rb +5 -3
  10. data/lib/mongo3.rb +1 -1
  11. data/lib/views/explore/_node_info.erb +1 -1
  12. data/lib/views/explore/explore.erb +3 -2
  13. data/spec/landscape.yml +1 -1
  14. data/spec/mongo3/connection_spec.rb +10 -9
  15. data/spec/mongo3/node_spec.rb +1 -1
  16. data/spec/spec_helper.rb +1 -1
  17. metadata +2 -37
  18. data/.bnignore +0 -3
  19. data/.bnsignore +0 -16
  20. data/.gitignore +0 -1
  21. data/aa.rb +0 -17
  22. data/config/mongo3.yml +0 -33
  23. data/data/populate +0 -28
  24. data/lib/public/.DS_Store +0 -0
  25. data/lib/public/images/button_act.psd +0 -0
  26. data/lib/public/images/clear.psd +0 -0
  27. data/lib/public/images/close.psd +0 -0
  28. data/lib/public/images/cluster.psd +0 -0
  29. data/lib/public/images/db.psd +0 -0
  30. data/lib/public/images/delete_big.psd +0 -0
  31. data/lib/public/images/edit.psd +0 -0
  32. data/lib/public/images/header.psd +0 -0
  33. data/lib/public/images/li_select.psd +0 -0
  34. data/lib/public/images/lock.psd +0 -0
  35. data/lib/public/images/mongo.psd +0 -0
  36. data/lib/public/images/mongo3.psd +0 -0
  37. data/lib/public/images/mongo3_db.psd +0 -0
  38. data/lib/public/images/mongo_10.psd +0 -0
  39. data/lib/public/images/mongo_db.psd +0 -0
  40. data/lib/public/images/monkey.psd +0 -0
  41. data/lib/public/images/selected_bg.psd +0 -0
  42. data/lib/public/javascripts/.DS_Store +0 -0
data/lib/app.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'sinatra'
3
3
  require 'forwardable'
4
- require File.join( File.dirname(__FILE__), 'mongo3.rb' )
4
+ require File.expand_path( File.join( File.dirname(__FILE__), 'mongo3.rb' ) )
5
5
  require 'mongo'
6
6
  gem 'agnostic-will_paginate'
7
7
  require 'will_paginate'
@@ -59,7 +59,9 @@ module Collections
59
59
  json = params[:search].gsub( /'/, "\"" )
60
60
  if json.empty?
61
61
  @query = {}
62
- @sort = {}
62
+ @sort = []
63
+ session[:query_params] = [@query,@sort]
64
+ load_cltn
63
65
  else
64
66
  tokens = json.split( "|" )
65
67
  begin
@@ -106,7 +108,7 @@ module Collections
106
108
  # ===========================================================================
107
109
  helpers do
108
110
  def load_cltn( page=1 )
109
- query_params = session[:query_params] || [{},[]]
111
+ query_params = session[:query_params] || [Hash.new,[]]
110
112
  if ( !query_params.first or query_params.first.empty?) and ( !query_params.last or query_params.last.empty? )
111
113
  @query = nil
112
114
  else
@@ -26,6 +26,10 @@ module Explore
26
26
  erb :'explore/explore'
27
27
  end
28
28
 
29
+ get "/fred/:duh" do
30
+ "Hello World #{params[:duh]}"
31
+ end
32
+
29
33
  # -----------------------------------------------------------------------------
30
34
  get '/explore/back' do
31
35
  session[:selected_cols] = nil
@@ -58,7 +62,7 @@ module Explore
58
62
  end
59
63
 
60
64
  # -----------------------------------------------------------------------------
61
- get '/explore/more_data/:path_ids/:path_names/*' do
65
+ get '/explore/more_data/:path_ids/:path_names/' do
62
66
  path_ids = params[:path_ids]
63
67
  parent_id = path_ids.split("|").last
64
68
  path_names = params[:path_names]
@@ -27,9 +27,12 @@ module CollectionHelper
27
27
  def orientation( value )
28
28
  return "id" if value.is_a?(Mongo::ObjectID)
29
29
  case( value.to_i )
30
- when Mongo::ASCENDING : "asc"
31
- when Mongo::DESCENDING : "desc"
32
- else "n/a"
30
+ when Mongo::ASCENDING
31
+ "asc"
32
+ when Mongo::DESCENDING
33
+ "desc"
34
+ else
35
+ "n/a"
33
36
  end
34
37
  end
35
38
 
@@ -8,14 +8,14 @@ module CrumbHelper
8
8
  @crumbs = []
9
9
  count = 0
10
10
  path_name_tokens.each do |crumb|
11
- @crumbs << [crumb, "/explore/center/#{path_name_tokens[0..count].join( "|" )}/#{path_id_tokens[0..count].join( "|") }"]
11
+ @crumbs << [crumb, "/explore/center/#{CGI.escape(path_name_tokens[0..count].join( "|" ))}/#{CGI.escape(path_id_tokens[0..count].join( "|")) }"]
12
12
  count += 1
13
13
  end
14
14
  session[:crumbs] = @crumbs
15
15
  end
16
16
 
17
17
  def pop_crumb!( path_ids, path_names )
18
- path = "/explore/center/#{path_ids}/#{path_names}"
18
+ path = "/explore/center/#{CGI.escape(path_ids)}/#{CGI.escape(path_names)}"
19
19
  level = 0
20
20
  range = nil
21
21
  @crumbs.each do |pair|
@@ -38,7 +38,7 @@ module CrumbHelper
38
38
  titles = @crumbs.map{ |p| p.first }
39
39
  unless titles.include?( title )
40
40
  @crumbs.pop if @crumbs.size == 3
41
- @crumbs << [title, url]
41
+ @crumbs << [title, CGI.escape(url)]
42
42
  session[:crumbs] = @crumbs
43
43
  end
44
44
  end
@@ -8,9 +8,12 @@ module DatabaseHelper
8
8
 
9
9
  def context_for( paths )
10
10
  case paths.size
11
- when 2 : "zone"
12
- when 3 : "database"
13
- else "collection"
11
+ when 2
12
+ "zone"
13
+ when 3
14
+ "database"
15
+ else
16
+ "collection"
14
17
  end
15
18
  end
16
19
  end
@@ -15,9 +15,12 @@ module ExploreHelper
15
15
  def path_type( path )
16
16
  tokens = path.split( "|" )
17
17
  case tokens.length
18
- when 1 : "zone"
19
- when 2 : "database"
20
- else "collection"
18
+ when 1
19
+ "zone"
20
+ when 2
21
+ "database"
22
+ else
23
+ "collection"
21
24
  end
22
25
  end
23
26
 
@@ -28,9 +28,12 @@ module PathHelper
28
28
  def title_for( path_names )
29
29
  tokens = path_names.split( "|" )
30
30
  buff = case tokens.size
31
- when 2 : "zone"
32
- when 3 : "database"
33
- else "collection"
31
+ when 2
32
+ "zone"
33
+ when 3
34
+ "database"
35
+ else
36
+ "collection"
34
37
  end
35
38
  db = tokens.size > 3 ? "<span class=\"ctx\">#{tokens[2]}</span>." : ""
36
39
  "<p class=\"ctx\" style=\"text-align:center;font-size:0.8em\">#{db}#{tokens.last}</p>"
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+
1
3
  # BOZO !! Time to refact no?
2
4
  module Mongo3
3
5
  class Connection
@@ -186,7 +188,7 @@ module Mongo3
186
188
 
187
189
  list = WillPaginate::Collection.create( page, per_page, count ) do |pager|
188
190
  offset = (page-1)*per_page
189
- sort = query_params.last.empty? ? [ ['_id', Mongo::DESCENDING] ] : query_params.last
191
+ sort = query_params.last.empty? ? [ ['_id', Mongo::DESCENDING] ] : query_params.last
190
192
  results = cltn.find( query_params.first,
191
193
  :sort => sort,
192
194
  :skip => offset,
@@ -224,7 +226,7 @@ module Mongo3
224
226
  host, port = master.split( ":" )
225
227
  master_zone = zone_for( host, port )
226
228
  next unless master_zone
227
- master_node = root.find( "home|#{master_zone}")
229
+ master_node = root.find( master_zone )
228
230
  if master_node
229
231
  master_node.mark_master!
230
232
  master_node << node
@@ -281,7 +283,7 @@ module Mongo3
281
283
  host, port = master.split( ":" )
282
284
  master_zone = zone_for( host, port )
283
285
  next unless master_zone
284
- master_node = root.find( "home|#{master_zone}")
286
+ master_node = root.find( master_zone )
285
287
  if master_node
286
288
  master_node.mark_master!
287
289
  master_node << node
data/lib/mongo3.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Mongo3
2
2
 
3
3
  # :stopdoc:
4
- VERSION = '0.0.7' unless defined? Mongo3::VERSION
4
+ VERSION = '0.0.8' unless defined? Mongo3::VERSION
5
5
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR unless defined? Mongo3::LIBPATH
6
6
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR unless defined? Mongo3::LIBPATH
7
7
  # :startdoc:
@@ -25,7 +25,7 @@
25
25
  <% unless zone_path?( session[:path_names] ) %>
26
26
  <img id="<%=count%>" rel="div#confirm_drop" class="drop" href="/explore/database/<%=node.oid%>/<%=node.name%>/drop" title="drop <%=legend%>..." src="/images/delete.png"/>
27
27
  <% end %>
28
- <p rel="div#details" href="/explore/show/<%=node.data[:path_ids]%>/<%=node.data[:path_names]%>" class="info">
28
+ <p rel="div#details" href="/explore/show/<%=CGI.escape(node.data[:path_ids])%>/<%=CGI.escape(node.data[:path_names])%>" class="info">
29
29
  <%=truncate(node.name, 30)%>
30
30
  </p>
31
31
  </div>
@@ -106,7 +106,7 @@
106
106
  {
107
107
  Log.write( "fetching new data..." );
108
108
  var url = "/explore/more_data/";
109
- url += node.data.path_ids + "/" + node.data.path_names + "/";
109
+ url += escape(node.data.path_ids) + "/" + escape(node.data.path_names) + "/";
110
110
  $.ajax( {
111
111
  dataType: 'script',
112
112
  type: 'GET',
@@ -137,7 +137,8 @@
137
137
  onBeforePlotLine: function(adj) {
138
138
  var nodeTo = adj.nodeTo;
139
139
  var nodeFrom = adj.nodeFrom;
140
- if( nodeFrom.data.slave && nodeTo.data.master )
140
+ #console.log( "Node from " + nodeFrom.name + " " + nodeFrom.data.master + " -- " + nodeTo.data.)
141
+ if( (nodeFrom.data.slave && nodeTo.data.master) || (nodeFrom.data.master && nodeTo.data.slave) )
141
142
  {
142
143
  adj.data.$lineWidth = 3;
143
144
  adj.data.$color = "#f00";
data/spec/landscape.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  test:
2
2
  host: localhost
3
- port: 27017
3
+ port: 12345
@@ -1,12 +1,12 @@
1
- require File.join(File.dirname(__FILE__), %w[.. spec_helper])
1
+ require File.expand_path( File.join( File.dirname(__FILE__), %w[.. spec_helper] ) )
2
2
  require 'ostruct'
3
3
  require 'mongo'
4
4
 
5
5
  describe Mongo3::Connection do
6
6
 
7
7
  before( :all ) do
8
- @con = Mongo::Connection.new( 'localhost', 27017 )
9
- @db = @con.db( 'mongo3_test_db', :strict => true )
8
+ @con = Mongo::Connection.new( 'localhost', 12345 )
9
+ @db = @con.db( 'mongo3_test_db', :strict => true )
10
10
  @mongo3 = Mongo3::Connection.new( File.join(File.dirname(__FILE__), %w[.. landscape.yml]) )
11
11
  end
12
12
 
@@ -35,6 +35,7 @@ describe Mongo3::Connection do
35
35
  it "should clear out a cltn correctly" do
36
36
  @mongo3.clear_cltn( "home|test|mongo3_test_db|test1_cltn" )
37
37
  @db['test1_cltn'].count.should == 0
38
+ @db['test2_cltn'].count.should == 10
38
39
  end
39
40
 
40
41
  it "should delete a row correctly" do
@@ -60,7 +61,7 @@ describe Mongo3::Connection do
60
61
 
61
62
  test.should_not be_nil
62
63
  test['host'].should == 'localhost'
63
- test['port'].should == 27017
64
+ test['port'].should == 12345
64
65
  end
65
66
 
66
67
  it "should build a tree correctly" do
@@ -80,16 +81,16 @@ describe Mongo3::Connection do
80
81
  describe "#show" do
81
82
  it "should pull env info correctly" do
82
83
  info = @mongo3.show( "home|test" )
83
- info.size.should == 6
84
+ info.size.should == 8
84
85
  info[:title].should == "test"
85
86
  info[:databases].size.should > 1
86
87
  end
87
88
 
88
89
  it "should pull db info correctly" do
89
90
  info = @mongo3.show( "home|test|mongo3_test_db" )
90
- info.size.should == 7
91
- info[:collections].size.should == 4
92
- info[:title].should == "mongo3_test_db"
91
+ info.size.should == 7
92
+ info[:collections].should == 2
93
+ info[:title].should == "mongo3_test_db"
93
94
  end
94
95
 
95
96
  it "should pull cltn info correctly" do
@@ -119,7 +120,7 @@ describe Mongo3::Connection do
119
120
 
120
121
  it "should build a partial tree correctly" do
121
122
  root = @mongo3.build_partial_tree( "home|test|mongo3_test_db" )
122
- root.find( "test_2" ).children.should have(0).items
123
+ root.find( "test_0" ).children.should have(2).items
123
124
  end
124
125
  end
125
126
 
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), %w[.. spec_helper])
1
+ require File.expand_path( File.join( File.dirname(__FILE__), %w[.. spec_helper] ) )
2
2
  require 'ostruct'
3
3
 
4
4
  describe Mongo3::Node do
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,7 @@ require 'mongo'
5
5
  gem 'agnostic-will_paginate'
6
6
  require 'will_paginate/collection'
7
7
 
8
- require File.join(File.dirname(__FILE__), %w[.. lib mongo3])
8
+ require File.expand_path( File.join( File.dirname(__FILE__), %w[.. lib mongo3] ) )
9
9
 
10
10
  Spec::Runner.configure do |config|
11
11
  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.7
4
+ version: 0.0.8
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: 2010-01-03 00:00:00 -07:00
12
+ date: 2010-01-05 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -72,16 +72,6 @@ dependencies:
72
72
  - !ruby/object:Gem::Version
73
73
  version: 4.2.0
74
74
  version:
75
- - !ruby/object:Gem::Dependency
76
- name: bones
77
- type: :development
78
- version_requirement:
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: 2.5.1
84
- version:
85
75
  description: " Mongo3 allows you to manage your mongoDB clusters using a web based admin console.\n The console provides for getting an overview of your mongo landscape and drilldown to\n see various information about your databases. You will be able to manage your clusters\n by performing common database admin tasks directly from the web console.\n \n The initial release of Mongo3 will be a read only shallow mode. Further development\n still needs to take place to build up the functionality from the existing code base."
86
76
  email: fernand.galiana@gmail.com
87
77
  executables:
@@ -123,16 +113,10 @@ extra_rdoc_files:
123
113
  - lib/views/users/list.erb
124
114
  - lib/views/users/results.js.erb
125
115
  files:
126
- - .bnignore
127
- - .bnsignore
128
- - .gitignore
129
116
  - HISTORY
130
117
  - README.rdoc
131
118
  - Rakefile
132
- - aa.rb
133
119
  - bin/mongo3
134
- - config/mongo3.yml
135
- - data/populate
136
120
  - lib/app.rb
137
121
  - lib/controllers/collections.rb
138
122
  - lib/controllers/databases.rb
@@ -150,53 +134,35 @@ files:
150
134
  - lib/mongo3/node.rb
151
135
  - lib/mongo3/user.rb
152
136
  - lib/mongo3/zone.rb
153
- - lib/public/.DS_Store
154
137
  - lib/public/images/button.png
155
138
  - lib/public/images/button_act.png
156
- - lib/public/images/button_act.psd
157
139
  - lib/public/images/c292199_a.jpg
158
140
  - lib/public/images/clear.png
159
- - lib/public/images/clear.psd
160
141
  - lib/public/images/close.png
161
- - lib/public/images/close.psd
162
142
  - lib/public/images/cluster.png
163
- - lib/public/images/cluster.psd
164
143
  - lib/public/images/db.jpg
165
144
  - lib/public/images/db.png
166
- - lib/public/images/db.psd
167
145
  - lib/public/images/delete.png
168
146
  - lib/public/images/delete_big.png
169
- - lib/public/images/delete_big.psd
170
147
  - lib/public/images/edit.png
171
- - lib/public/images/edit.psd
172
148
  - lib/public/images/header.png
173
- - lib/public/images/header.psd
174
149
  - lib/public/images/li_select.png
175
- - lib/public/images/li_select.psd
176
150
  - lib/public/images/loading.gif
177
151
  - lib/public/images/lock.png
178
- - lib/public/images/lock.psd
179
152
  - lib/public/images/mongo.png
180
- - lib/public/images/mongo.psd
181
153
  - lib/public/images/mongo3.png
182
- - lib/public/images/mongo3.psd
183
154
  - lib/public/images/mongo3_db.png
184
- - lib/public/images/mongo3_db.psd
185
- - lib/public/images/mongo_10.psd
186
155
  - lib/public/images/mongo_db.jpg
187
156
  - lib/public/images/mongo_db.png
188
- - lib/public/images/mongo_db.psd
189
157
  - lib/public/images/mongo_db_1.jpg
190
158
  - lib/public/images/mongo_db_2
191
159
  - lib/public/images/mongo_db_4
192
160
  - lib/public/images/monkey.jpg
193
161
  - lib/public/images/monkey.png
194
- - lib/public/images/monkey.psd
195
162
  - lib/public/images/monkey_1.jpg
196
163
  - lib/public/images/monkey_10.jpg
197
164
  - lib/public/images/search.png
198
165
  - lib/public/images/selected_bg.png
199
- - lib/public/images/selected_bg.psd
200
166
  - lib/public/images/tooltip/black.png
201
167
  - lib/public/images/tooltip/black_arrow.png
202
168
  - lib/public/images/tooltip/black_arrow_big.png
@@ -205,7 +171,6 @@ files:
205
171
  - lib/public/images/tooltip/white_arrow.png
206
172
  - lib/public/images/tooltip/white_arrow_big.png
207
173
  - lib/public/images/tooltip/white_big.png
208
- - lib/public/javascripts/.DS_Store
209
174
  - lib/public/javascripts/application.js
210
175
  - lib/public/javascripts/jit.js
211
176
  - lib/public/javascripts/jit.min.js
data/.bnignore DELETED
@@ -1,3 +0,0 @@
1
- *.log
2
- *.psd
3
- .git
data/.bnsignore DELETED
@@ -1,16 +0,0 @@
1
- # The list of files that should be ignored by Mr Bones.
2
- # Lines that start with '#' are comments.
3
- #
4
- # A .gitignore file can be used instead by setting it as the ignore
5
- # file in your Rakefile:
6
- #
7
- # PROJ.ignore_file = '.gitignore'
8
- #
9
- # For a project with a C extension, the following would be a good set of
10
- # exclude patterns (uncomment them if you want to use them):
11
- # *.[oa]
12
- # *~
13
- announcement.txt
14
- coverage
15
- doc
16
- pkg
data/.gitignore DELETED
@@ -1 +0,0 @@
1
- *.psd
data/aa.rb DELETED
@@ -1,17 +0,0 @@
1
- require 'rubygems'
2
- require 'mongo'
3
-
4
- con = Mongo::Connection.new( 'localhost', 27019 )
5
- puts con.database_names.inspect
6
-
7
- admin = con.db('admin')
8
-
9
- users = admin[Mongo::DB::SYSTEM_USER_COLLECTION]
10
-
11
- puts users.count
12
-
13
- row = { :user => "fred", :pwd => admin.send( :hash_password, "fred", "duh" ) }
14
-
15
- users.save( row )
16
-
17
- puts users.find({}).inspect
data/config/mongo3.yml DELETED
@@ -1,33 +0,0 @@
1
- development:
2
- host: localhost
3
- port: 27017
4
-
5
- beta:
6
- host: dev8
7
- port: 27018
8
- user: "blee"
9
- password: "fred"
10
-
11
- # production:
12
- # :host: dev8
13
- # :port: 27018
14
- # :user: "blee"
15
- # :password: "fred"
16
- #
17
- # serv1:
18
- # :host: dev8
19
- # :port: 27018
20
- # :user: "blee"
21
- # :password: "fred"
22
- #
23
- # serv2:
24
- # :host: dev8
25
- # :port: 27018
26
- # :user: "blee"
27
- # :password: "fred"
28
- #
29
- # serv3:
30
- # :host: dev8
31
- # :port: 27018
32
- # :user: "blee"
33
- # :password: "fred"
data/data/populate DELETED
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'rubygems'
3
- require 'mongo'
4
-
5
- connection = Mongo::Connection.new( 'localhost', 27019 )
6
- # db = connection.db( 'admin' )
7
- # db.authenticate( 'admin', 'admin')
8
-
9
- db_name = "fernand_mdb"
10
- cltn_names = %w[blee bobo]
11
-
12
-
13
- db = connection.db( db_name )
14
-
15
- cltn_names.each do |cltn_name|
16
- cltn = db.create_collection( cltn_name )
17
- cltn.remove
18
-
19
- 20.times do |i|
20
- row = { :name => "#{cltn_name}_#{i}", :last_name => "#{db_name}.#{cltn_name}_#{i}" }
21
- puts "Inserting row #{row.inspect}"
22
- cltn.insert( row )
23
- end
24
-
25
- cltn = db[cltn_name]
26
- puts ""
27
- puts "Inserted `#{cltn.count} records in `#{cltn_name}"
28
- end
data/lib/public/.DS_Store DELETED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file