annotate_models 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/lib/annotate_models/model_annotation_generator.rb +5 -3
- data/lib/annotate_models/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67f11e008832b25c83aed3b235810e118793aeae
|
4
|
+
data.tar.gz: 04fe40992cdc385ca0aa7b65eadc18c527bdfd95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54172c43dc2e1de8cbc817cef2eb73dc1b21d7b99312afe4b0fe6c4f71d4d57d49ee62333f0d11b8210836e59810fc2ee595f7f77f5cfd0533edf90649559da8
|
7
|
+
data.tar.gz: ad3f9059ded6240f1ae5090fb49e75221d448f0630d9c0fd662067e2717ff0a94b0226cc213d579f27ddf241f7d94ee8dd2d9c4407cfde4c5c81f4451261c48a
|
@@ -82,15 +82,17 @@ module AnnotateModels
|
|
82
82
|
# @param model [Class] An ActiveRecord model class.
|
83
83
|
|
84
84
|
def generate_annotation(model)
|
85
|
+
max_column_length = model.columns.collect { |c| c.name.length }.max
|
85
86
|
annotation = []
|
86
87
|
annotation << "#-#{'--' * 38}-"
|
87
88
|
annotation << "# #{model.name}"
|
88
89
|
annotation << "#"
|
89
|
-
annotation << "#
|
90
|
-
annotation << "#
|
90
|
+
annotation << sprintf("# %-#{max_column_length}s SQL Type Null Default Primary", "Name")
|
91
|
+
annotation << sprintf("# %s -------------------- ------- ------- -------", "-" * max_column_length)
|
92
|
+
format = "# %-#{max_column_length}s %-20s %-7s %-7s %-7s"
|
91
93
|
model.columns.each do |column|
|
92
94
|
annotation << sprintf(
|
93
|
-
|
95
|
+
format,
|
94
96
|
column.name,
|
95
97
|
column.sql_type,
|
96
98
|
column.null,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: annotate_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Brazil
|
@@ -9,7 +9,21 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-02-08 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: yard
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: |-
|
14
28
|
This is my own re-write of an earlier version https://github.com/ctran/annotate_models when work on it waned.
|
15
29
|
This work started out as an old-style Rails plugin; I am now re-bundling it as a gem-ified plugin.
|