peekdb 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/peekdb CHANGED
@@ -1,10 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
  require_relative '../lib/peekdb'
3
3
 
4
- begin
5
- PeekDB.new(ARGV).run
6
- rescue
7
- exit(1)
8
- else
9
- exit(0)
10
- end
4
+ PeekDB.new(ARGV).run
@@ -12,11 +12,12 @@ require_relative 'peekdb/database_sqlite'
12
12
  class PeekDB
13
13
 
14
14
  def initialize(argv)
15
- puts "PeekDB:"
16
15
  begin
16
+ puts "PeekDB:"
17
17
  parse_options(argv)
18
18
  rescue Exception => e
19
19
  puts "... Error FATAL: #{e}"
20
+ puts usage
20
21
  exit(1)
21
22
  end
22
23
  end
@@ -56,41 +57,26 @@ class PeekDB
56
57
  db = DatabaseSQLite.new @options.name
57
58
  else
58
59
  puts "... Error FATAL: Unknown database type #{@options.type}"
60
+ puts usage
59
61
  exit(1)
60
62
  end
61
63
 
62
- graph = Graph.new
63
- graph.build(db.name, db.tables, db.relations)
64
- graph.output(db.name, @options.format)
65
- else
66
- puts '... Error FATAL: missing arguments'
67
- exit(1)
64
+ begin
65
+ graph = Graph.new
66
+ graph.build(db.name, db.tables, db.relations)
67
+ graph.output(db.name, @options.format)
68
+ rescue
69
+ puts '... Error FATAL: missing arguments'
70
+ puts usage
71
+ exit(1)
72
+ else
73
+ exit(0)
74
+ end
68
75
  end
69
76
  end
70
77
 
71
- def self.usage
72
- puts <<-EOT
73
- Usage: rails COMMAND [ARGS]
74
-
75
- The most common rails commands are:
76
- generate Generate new code (short-cut alias: "g")
77
- console Start the Rails console (short-cut alias: "c")
78
- server Start the Rails server (short-cut alias: "s")
79
- dbconsole Start a console for the database specified in config/database.yml
80
- (short-cut alias: "db")
81
- new Create a new Rails application. "rails new my_app" creates a
82
- new application called MyApp in "./my_app"
83
-
84
- In addition to those, there are:
85
- application Generate the Rails application code
86
- destroy Undo code generated with "generate" (short-cut alias: "d")
87
- benchmarker See how fast a piece of code runs
88
- profiler Get profile information from a piece of code
89
- plugin new Generates skeleton for developing a Rails plugin
90
- runner Run a piece of code in the application environment (short-cut alias: "r")
91
-
92
- All commands can be run with -h (or --help) for more information.
93
- EOT
78
+ def usage
79
+ "Usage: peekdb -n DATABASE-NAME -t DATABASE-TYPE [psql | mysql | sqlite] -f FORMAT [pdf | dot]"
94
80
  end
95
81
 
96
82
  end
@@ -15,7 +15,7 @@ class Database
15
15
  find_relations
16
16
  puts "... Found #{@relations.size} relations"
17
17
  rescue Exception => e
18
- puts "... Error #{e}"
18
+ puts "... Error FATAL: #{e}"
19
19
  exit(1)
20
20
  end
21
21
  end
@@ -23,14 +23,14 @@ class Database
23
23
  private
24
24
 
25
25
  def open_connection(database_name)
26
- raise NotImplementedError
26
+ raise NotImplementedError.new("Feature Not Yet Implemented")
27
27
  end
28
28
 
29
29
  def find_tables
30
- raise NotImplementedError
30
+ raise NotImplementedError.new("Feature Not Yet Implemented")
31
31
  end
32
32
 
33
33
  def find_relations
34
- raise NotImplementedError
34
+ raise NotImplementedError.new("Feature Not Yet Implemented")
35
35
  end
36
36
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "peekdb"
3
- gem.version = "0.2.1"
3
+ gem.version = "0.3.0"
4
4
  gem.platform = Gem::Platform::RUBY
5
5
  gem.authors = ["Adrian Smith"]
6
6
  gem.email = ["adrian.smith@ennova.com.au"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: peekdb
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.1
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Adrian Smith
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-04-29 00:00:00 Z
13
+ date: 2012-04-30 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ruby-graphviz