servicesnapshot 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/bin/servicesnapshot CHANGED
@@ -7,6 +7,7 @@ require "helper_functions"
7
7
  require "Snapshot/Ssh"
8
8
  require "Snapshot/Beanstalk"
9
9
  require "Snapshot/Shell"
10
+ require "Snapshot/FluidDb"
10
11
 
11
12
  #Don't buffer stdout
12
13
  $stdout.sync = true
@@ -0,0 +1,49 @@
1
+ require "FluidDb"
2
+
3
+ def padStringWithWhiteSpace( string, length )
4
+ while string.length <= length+1
5
+ string = string + " "
6
+ end
7
+ return string
8
+ end
9
+
10
+ def fluiddb( params )
11
+ usage = "fluiddb :uri=><uri>, :sql=><sql>"
12
+ uri_string = get_param( params, :uri, usage )
13
+ sql_string = get_param( params, :sql, usage )
14
+
15
+ db = FluidDb::Db( URI.parse( uri_string ) )
16
+ list = db.queryForResultset( sql_string, [] )
17
+ content = ""
18
+ if list.count == 0 then
19
+ content = "No rows returned"
20
+ else
21
+
22
+ max_width = Array.new( list[0].keys.length, 0 )
23
+ list[0].keys.each_with_index do |k,idx|
24
+ max_width[idx] = k.length if max_width[idx] < k.length
25
+ list.each do |row|
26
+ max_width[idx] = row[k].to_s.length if max_width[idx] < row[k].to_s.length
27
+ end
28
+ end
29
+
30
+ fieldNames = ""
31
+ underLines = ""
32
+ list[0].keys.each_with_index do |fieldName, idx|
33
+ fieldNames = fieldNames + padStringWithWhiteSpace( fieldName, max_width[idx])
34
+ underLines = underLines + padStringWithWhiteSpace( "=" * max_width[idx], max_width[idx])
35
+ end
36
+
37
+ content = "#{fieldNames}\n#{underLines}\n"
38
+
39
+ list.each do |row|
40
+ row.values.each_with_index do |v,idx|
41
+ content = content + padStringWithWhiteSpace( v.to_s, max_width[idx])
42
+ end
43
+ content = content + "\n"
44
+ end
45
+ end
46
+
47
+ title = "fluiddb: #{uri_string} = #{sql_string}"
48
+ formatOutput( title, content )
49
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servicesnapshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-08 00:00:00.000000000 Z
12
+ date: 2014-01-09 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: The fastest way to get a snapshot of your system.
15
15
  email: guy@guyirvine.com
@@ -20,6 +20,7 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - lib/helper_functions.rb
22
22
  - lib/Snapshot/Beanstalk.rb
23
+ - lib/Snapshot/FluidDb.rb
23
24
  - lib/Snapshot/Shell.rb
24
25
  - lib/Snapshot/Ssh.rb
25
26
  - bin/servicesnapshot