schemadoc 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f06e6c98d47ee913781b80f3c648d29fbb5a773b
4
- data.tar.gz: 491654a1965027fbb7505b76156c51cb32943e66
3
+ metadata.gz: 13f07f4218221279bd1bba7f357b5b98f2424e8a
4
+ data.tar.gz: 203e0161acb77b78e3e7a48b1b76397fd4d2f4d0
5
5
  SHA512:
6
- metadata.gz: 2620d6fff436224317dbd625c80780236dac30e5a9a451ba05d536687716e267d5aad198a18272189a01e32cee553fa1eb2afaf7fa52fe92a9f8ef39e0f12bea
7
- data.tar.gz: ff27127fa5f0e0f7347ce9da1f292db9fbc146b337f6ab57de7d4011ae46156bd0b312a5a68a81d1a59cbd15ad611b9b4175a97b1417b3191d0b0a2a30418803
6
+ metadata.gz: b5e50bf3b061b3a9c6914076328e660a3ab60e41c691c9e57f479bb6a44c1b09908b9d94da7858b2f03f98be82015359753a607c03f21ee2fccd4fef863953cc
7
+ data.tar.gz: aeee53a2ac4e8a0f8ea9d9bc624bef5bc6e1e6afa267b5b2b2385169f5bf3d084aafd64eb04ebd0efb2c6819631f332e2e3c7ae4502d9085c84349e0307b1d67
data/Manifest.txt CHANGED
@@ -8,4 +8,5 @@ lib/schemadoc/cli/opts.rb
8
8
  lib/schemadoc/cli/runner.rb
9
9
  lib/schemadoc/version.rb
10
10
  lib/schemadoc/worker.rb
11
+ test/config/beer.yml
11
12
  test/config/football.yml
data/README.md CHANGED
@@ -8,9 +8,127 @@ schemadoc gem - document your database schemas (tables, columns, etc.)
8
8
  * rdoc :: [rubydoc.info/gems/schemadoc](http://rubydoc.info/gems/schemadoc)
9
9
 
10
10
 
11
- ## Usage
11
+ ## Usage Command Line
12
12
 
13
- To be done
13
+ The `schemadoc` gem includes a command line tool
14
+ named - surprise, surprise - `schemadoc`. Try:
15
+
16
+ ~~~
17
+ $ schemadoc --help
18
+ ~~~
19
+
20
+ resulting in:
21
+
22
+ ~~~
23
+ schemadoc 1.0.0 - Lets you document your database tables, columns, etc.
24
+
25
+ Usage: schemadoc [options]
26
+ -o, --output PATH Output path (default is '.')
27
+ -v, --verbose Show debug trace
28
+
29
+ Examples:
30
+ schemadoc # defaults to ./schemadoc.yml
31
+ schemadoc football.yml
32
+ ~~~
33
+
34
+
35
+ ## Configuration
36
+
37
+ The `schemadoc` command line tool
38
+ requires a configuration file (defaults to `./schemadoc.yml` if not
39
+ passed along).
40
+
41
+ **Database Connection Settings - `database` Section**
42
+
43
+ Use the `database` section to configure you database connection settings.
44
+ Example:
45
+
46
+ ~~~
47
+ database:
48
+ adapter: sqlite3
49
+ database: ./football.db
50
+ ~~~
51
+
52
+ **Schema Sections**
53
+
54
+ All other sections are interpreted as database schemas.
55
+ The first section is the "default" schema,
56
+ that is, all tables not listed in other schemas will get auto-added
57
+ to the "default" schema.
58
+
59
+
60
+ **Example - `schemadoc.yml`**
61
+
62
+ ~~~
63
+ ## connection spec
64
+
65
+ database:
66
+ adapter: sqlite3
67
+ database: ./football.db
68
+
69
+
70
+ ## main tables
71
+
72
+ football:
73
+ name: Football
74
+
75
+
76
+ ## world tables
77
+
78
+ world:
79
+ name: World
80
+ tables:
81
+ - continents
82
+ - countries
83
+ - regions
84
+ - cities
85
+ - places
86
+ - names
87
+ - langs
88
+ - usages
89
+
90
+ ## support tables
91
+
92
+ support:
93
+ name: Support
94
+ tables:
95
+ - logs
96
+ - props
97
+ - tags
98
+ - taggings
99
+ ~~~
100
+
101
+
102
+
103
+ ## Outputs
104
+
105
+ The `schemadoc` tool writes out two json files:
106
+
107
+ - `database.json` - includes all schemas, tables, columns, etc.
108
+ - `symbols.json` - includes all symbols from a to z
109
+
110
+
111
+ ## Reports 'n' Templates
112
+
113
+ To generate web pages from you json files use a static site generator and
114
+ a template pack (theme). For example, to use the `book-templates/schema` theme
115
+ copy your json files in the `_data/` folder and rebuild the site (e.g. $ `jekyll build`).
116
+ That's it. Enjoy your database schema docu.
117
+
118
+
119
+
120
+ ## Install
121
+
122
+ Just install the gem:
123
+
124
+ ~~~
125
+ $ gem install schemadoc
126
+ ~~~
127
+
128
+
129
+ ## Free Schemadoc Template Packs / Themes
130
+
131
+ - [`book-templates/schema`](https://github.com/book-templates/schema) - free schemadoc theme; works w/ Jekyll (and GitHub Pages) static site generator
14
132
 
15
133
 
16
134
  ## License
@@ -5,23 +5,6 @@ module SchemaDoc
5
5
 
6
6
  class Opts
7
7
 
8
- def config_name=(value)
9
- @config_name = value
10
- end
11
-
12
- def config_name
13
- @config_name || 'schemadoc.yml'
14
- end
15
-
16
- def config_path=(value)
17
- @config_path = value
18
- end
19
-
20
- def config_path
21
- @config_path || '.'
22
- end
23
-
24
-
25
8
  def output_path=( value )
26
9
  @output_path = value
27
10
  end
@@ -33,3 +16,4 @@ module SchemaDoc
33
16
  end # class Opts
34
17
 
35
18
  end # module SchemaDoc
19
+
@@ -27,16 +27,6 @@ module SchemaDoc
27
27
 
28
28
  cmd.banner = "Usage: schemadoc [options]"
29
29
 
30
- ### use -c and --config / why? why not??
31
- ### use -n and --name / why? why not??
32
-
33
- cmd.on( '-f', '--file NAME', "Configuration name (default is '#{opts.config_name}')" ) do |s|
34
- opts.config_name = s
35
- end
36
- cmd.on( '-d', '--dir PATH', "Configuration path (default is '#{opts.config_path}')" ) do |s|
37
- opts.config_path = s
38
- end
39
-
40
30
  cmd.on( '-o', '--output PATH', "Output path (default is '#{opts.output_path}')" ) do |s|
41
31
  opts.output_path = s
42
32
  end
@@ -73,10 +63,11 @@ EOS
73
63
 
74
64
  puts SchemaDoc.banner
75
65
 
76
- config = YAML.load_file( "#{opts.config_path}/#{opts.config_name}" )
66
+ arg = args[0] || './schemadoc.yml'
67
+ config = YAML.load_file( arg )
77
68
  pp config
78
69
 
79
- worker = Worker.new( config ).run()
70
+ worker = Worker.new( config ).run
80
71
 
81
72
  puts 'Done.'
82
73
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  module SchemaDoc
4
4
 
5
- MAJOR = 0
6
- MINOR = 1
5
+ MAJOR = 1
6
+ MINOR = 0
7
7
  PATCH = 0
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
@@ -23,4 +23,3 @@ end # module SchemaDoc
23
23
 
24
24
  Schemadoc = SchemaDoc # add alias for all lower-case
25
25
 
26
-
@@ -66,7 +66,7 @@ class Worker
66
66
  @con.columns( name ).each do |col|
67
67
  t[:columns] << {
68
68
  name: col.name,
69
- type: col.sql_type,
69
+ type: col.sql_type.downcase, # note: use integer (instead of INTEGER)
70
70
  default: col.default,
71
71
  null: col.null
72
72
  }
@@ -115,13 +115,30 @@ class Worker
115
115
 
116
116
  table_key = name[0].upcase
117
117
  symbols[table_key][:tables] << name
118
-
118
+
119
119
  @con.columns( name ).each do |col|
120
120
  col_key = col.name[0].upcase
121
- symbols[col_key][:columns] << "#{col.name} in #{name}"
121
+ cols_ary = symbols[col_key][:columns]
122
+
123
+ ## search for column name
124
+ col_hash = cols_ary.find { |item| item[:name] == col.name }
125
+ if col_hash.nil?
126
+ col_hash = { name: col.name, tables: [] }
127
+ cols_ary << col_hash
128
+ end
129
+
130
+ col_hash[:tables] << name
122
131
  end
123
132
  end
124
133
 
134
+ ## sort tables, cols and (in tables)
135
+ symbols.each do |k,h|
136
+ h[:tables] = h[:tables].sort
137
+
138
+ h[:columns] = h[:columns].sort { |l,r| l[:name] <=> r[:name] }
139
+ h[:columns].each { |col| col[:tables] = col[:tables].sort }
140
+ end
141
+
125
142
  data = []
126
143
  symbols.each do |k,v|
127
144
  data << v # turn data json into an array of letters (ever letter is a hash w/ name,tables,columns,etc.)
@@ -0,0 +1,43 @@
1
+ ###################
2
+ # connection spec
3
+
4
+ database:
5
+ adapter: sqlite3
6
+ database: ./beer.db
7
+
8
+
9
+ ###############
10
+ # main tables
11
+
12
+ beer:
13
+ name: Beer
14
+
15
+
16
+ ############
17
+ # world tables
18
+
19
+ world:
20
+ name: World
21
+ tables:
22
+ - continents
23
+ - countries
24
+ - regions
25
+ - cities
26
+ - places
27
+ - names
28
+ - langs
29
+ - usages
30
+ - country_codes
31
+
32
+ ##########
33
+ # support tables
34
+
35
+ support:
36
+ name: Support
37
+ tables:
38
+ - logs
39
+ - props
40
+ - tags
41
+ - taggings
42
+
43
+
@@ -27,6 +27,7 @@ world:
27
27
  - names
28
28
  - langs
29
29
  - usages
30
+ - country_codes
30
31
 
31
32
  ##########
32
33
  # support tables
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schemadoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logutils
@@ -87,6 +87,7 @@ files:
87
87
  - lib/schemadoc/cli/runner.rb
88
88
  - lib/schemadoc/version.rb
89
89
  - lib/schemadoc/worker.rb
90
+ - test/config/beer.yml
90
91
  - test/config/football.yml
91
92
  homepage: https://github.com/rubylibs/schemadoc
92
93
  licenses: