annotate-sequel 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +3 -1
- data/annotate-sequel.gemspec +4 -4
- data/lib/annotate_sequel/model.rb +29 -1
- data/lib/annotate_sequel/version.rb +1 -1
- data/lib/tasks/annotate_sequel.rake +1 -1
- data/spec/annotate_sequel/model_spec.rb +14 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7adf0f0f1c3ded597dcbfcc5ed2ff4a7ff652825
|
4
|
+
data.tar.gz: 1a9fbb9511a13d59e8df47991e1110749271979d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 886ae43b3f88a8044e190abadc12ead0df6de569b204fc5a6c490f2dbe781003876b90e9fe8baceb32500d1ee4ffce82cf834122c21cf22b558741ec3ad77935
|
7
|
+
data.tar.gz: bee6d3d2e96c7ff5a53a456241947567e608b0494a1d0dcdc7fe9ea814f08125ffe52496a52358404d4ee4bdce58f0bb3bb89049c4666e8071b98f26f3400bf1
|
data/README.rdoc
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
= annotate-sequel
|
2
2
|
|
3
|
+
*DEPRECATED*: Please use the fork https://github.com/jeremyevans/sequel-annotate instead.
|
4
|
+
|
3
5
|
A gem to annotate your Sequel models.
|
4
6
|
|
5
7
|
Currently only tested for Rails 3 and only supports Sequel 3.x as of right now.
|
@@ -57,6 +59,6 @@ That's it.
|
|
57
59
|
|
58
60
|
== Copyright
|
59
61
|
|
60
|
-
Copyright (c) 2013 Kenny Meyer. See LICENSE.txt for
|
62
|
+
Copyright (c) 2013-2016 Kenny Meyer. See LICENSE.txt for
|
61
63
|
further details.
|
62
64
|
|
data/annotate-sequel.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: annotate-sequel 1.1.
|
5
|
+
# stub: annotate-sequel 1.1.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "annotate-sequel"
|
9
|
-
s.version = "1.1.
|
9
|
+
s.version = "1.1.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Kenny Meyer"]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2016-02-01"
|
15
15
|
s.description = "Annotate Sequel models"
|
16
16
|
s.email = "kenny@kennymeyer.net"
|
17
17
|
s.executables = ["annotate"]
|
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
]
|
41
41
|
s.homepage = "http://github.com/kennym/annotate-sequel"
|
42
42
|
s.licenses = ["MIT"]
|
43
|
-
s.rubygems_version = "2.
|
43
|
+
s.rubygems_version = "2.4.8"
|
44
44
|
s.summary = "Annotate Sequel models"
|
45
45
|
|
46
46
|
if s.respond_to? :specification_version then
|
@@ -25,7 +25,7 @@ class AnnotateSequel
|
|
25
25
|
[ key,
|
26
26
|
value[:type],
|
27
27
|
value[:db_type],
|
28
|
-
value[:ruby_default]
|
28
|
+
value[:ruby_default].nil? ? '-' : value[:ruby_default] , # old style fails for default: false
|
29
29
|
value[:allow_null] ? 'Y' : 'N',
|
30
30
|
value[:primary_key] ? 'Y' : 'N',
|
31
31
|
fks.include?(key) ? 'Y' : 'N'
|
@@ -42,9 +42,37 @@ class AnnotateSequel
|
|
42
42
|
output = String.new
|
43
43
|
table.to_s.each_line { |line| output << "# #{line}" }
|
44
44
|
|
45
|
+
indexes = process_indexes(klass)
|
46
|
+
|
47
|
+
if indexes.any?
|
48
|
+
output << "\n"
|
49
|
+
index_tbl = Terminal::Table.new
|
50
|
+
index_tbl.title = "Indexes"
|
51
|
+
index_tbl.headings = ["Name", "Columns", "Unique?"]
|
52
|
+
index_tbl.rows = indexes
|
53
|
+
index_tbl.to_s.each_line { |line| output << "# #{line}" }
|
54
|
+
end
|
45
55
|
output << "\n\n"
|
46
56
|
end
|
47
57
|
|
58
|
+
def process_indexes(model)
|
59
|
+
model.db.indexes(model.table_name).map do |name, index|
|
60
|
+
[name, index[:columns].join(", "), index[:unique]]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# following this format from i think mysql
|
65
|
+
# UNIQUE KEY `country` (`country`,`tag`)
|
66
|
+
# KEY `index_histories_user` (`user_id`)
|
67
|
+
def process_index(name, index)
|
68
|
+
|
69
|
+
if index[:unique]
|
70
|
+
"UNIQUE INDEX '#{name}' ('#{index[:columns].join("', '")}')"
|
71
|
+
else
|
72
|
+
"INDEX '#{name}' ('#{index[:columns].join("', '")}')"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
48
76
|
def process_fks(model)
|
49
77
|
model.db.foreign_key_list(model.table_name).map do |x|
|
50
78
|
x[:columns]
|
@@ -2,7 +2,7 @@ annotate_lib = File.expand_path(File.dirname(File.dirname(__FILE__)))
|
|
2
2
|
|
3
3
|
desc "Add schema information (as comments) to model files"
|
4
4
|
task :annotate_models => :environment do
|
5
|
-
require "#{annotate_lib}/
|
5
|
+
require "#{annotate_lib}/annotate_sequel/model"
|
6
6
|
|
7
7
|
AnnotateSequel::Model.do_annotations
|
8
8
|
end
|
@@ -11,8 +11,12 @@ describe AnnotateSequel::Model do
|
|
11
11
|
|
12
12
|
String :manufacturer_name, size: 50
|
13
13
|
String :manufacturer_location
|
14
|
+
Boolean :in_stock, default: false
|
14
15
|
String :name, default: "John"
|
15
16
|
Float :price, default: 0
|
17
|
+
|
18
|
+
index [:manufacturer_name, :manufacturer_location], :name=>:name, :unique=>true
|
19
|
+
index [:manufacturer_name], :name=>:manufacturer_name
|
16
20
|
end
|
17
21
|
end
|
18
22
|
|
@@ -33,15 +37,25 @@ describe AnnotateSequel::Model do
|
|
33
37
|
# | category_id | integer | integer | - | N | N | Y |
|
34
38
|
# | manufacturer_name | string | varchar(50) | - | Y | N | Y |
|
35
39
|
# | manufacturer_location | string | varchar(255) | - | Y | N | Y |
|
40
|
+
# | in_stock | boolean | Boolean | false | Y | N | N |
|
36
41
|
# | name | string | varchar(255) | John | Y | N | N |
|
37
42
|
# | price | float | double precision | 0.0 | Y | N | N |
|
38
43
|
# +-----------------------+-----------+------------------+---------+-------+-----+-----+
|
44
|
+
# +-------------------+------------------------------------------+---------+
|
45
|
+
# | Indexes |
|
46
|
+
# +-------------------+------------------------------------------+---------+
|
47
|
+
# | Name | Columns | Unique? |
|
48
|
+
# +-------------------+------------------------------------------+---------+
|
49
|
+
# | manufacturer_name | manufacturer_name | false |
|
50
|
+
# | name | manufacturer_name, manufacturer_location | true |
|
51
|
+
# +-------------------+------------------------------------------+---------+
|
39
52
|
OUTPUT
|
40
53
|
|
41
54
|
AnnotateSequel::Model.schema_info(klass).should eq output
|
42
55
|
end
|
43
56
|
|
44
57
|
it "should support indexes" do
|
58
|
+
# currently adding tests to the main test itself..
|
45
59
|
pending
|
46
60
|
end
|
47
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: annotate-sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenny Meyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
162
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.
|
163
|
+
rubygems_version: 2.4.8
|
164
164
|
signing_key:
|
165
165
|
specification_version: 4
|
166
166
|
summary: Annotate Sequel models
|