annotate-sequel 1.1.0 → 1.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 763bf4cfb746754ac1779570f90a208dcd7fa85d
4
- data.tar.gz: 4fef2f90136e7cff56650bc5cb3d000cf4eaa113
3
+ metadata.gz: 7adf0f0f1c3ded597dcbfcc5ed2ff4a7ff652825
4
+ data.tar.gz: 1a9fbb9511a13d59e8df47991e1110749271979d
5
5
  SHA512:
6
- metadata.gz: 5958ddf5d37e57309c38a075e27b0249901c7d6bbae15cc5b869b317a3f7a25fd17ac3db48154604adcb0b3fd2ee657714f242285baf632d77e3b4238bbfd322
7
- data.tar.gz: ef1887a9ca0d29849e42ac7c26c3862a6de941cb0068f2fa1f1de795bf013a34f29cda6de2b66271605306adc06f4c8c062d476841f0b1ca20a736c1de4be989
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
 
@@ -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.0 ruby lib
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.0"
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 = "2014-11-24"
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.2.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 @@ class AnnotateSequel
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 1
5
- PATCH = 0
5
+ PATCH = 1
6
6
  BUILD = 'final'
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
@@ -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}/annotate/model"
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.0
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: 2014-11-24 00:00:00.000000000 Z
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.2.2
163
+ rubygems_version: 2.4.8
164
164
  signing_key:
165
165
  specification_version: 4
166
166
  summary: Annotate Sequel models