ahnnotate 0.4.0 → 0.5.0
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/.github/workflows/ruby.yml +64 -0
- data/.gitignore +1 -1
- data/.travis.yml +1 -0
- data/Appraisals +10 -0
- data/Gemfile.lock +63 -0
- data/ahnnotate.gemspec +2 -2
- data/gemfiles/rails41.gemfile +2 -0
- data/gemfiles/rails42.gemfile +2 -0
- data/gemfiles/rails50.gemfile +1 -0
- data/gemfiles/rails60.gemfile +8 -0
- data/lib/ahnnotate/abilities.rb +20 -0
- data/lib/ahnnotate/column.rb +22 -3
- data/lib/ahnnotate/facet/models/module_node.rb +31 -6
- data/lib/ahnnotate/facet/models/processor.rb +1 -1
- data/lib/ahnnotate/facet/models/resolve_active_record_models.rb +3 -1
- data/lib/ahnnotate/facet/models/resolve_class_relationships.rb +4 -2
- data/lib/ahnnotate/foreign_key.rb +22 -0
- data/lib/ahnnotate/rspec.rb +62 -0
- data/lib/ahnnotate/table.rb +8 -0
- data/lib/ahnnotate/tables.rb +18 -2
- data/lib/ahnnotate/version.rb +1 -1
- data/lib/ahnnotate/vfs_driver/read_only_filesystem.rb +10 -1
- data/lib/ahnnotate.rb +2 -1
- metadata +18 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c932b95899f0bc90dfe57b0481f976ed98aeb4981e61bce5e03d4efaf3cb8c07
|
|
4
|
+
data.tar.gz: fcacaac6f5719affb613cd96028d77321bcc156fed75514c7414c5ba04002290
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f44bb30bf66d538f3e2416b4013354b8512f651cef5c07f3950aeae71063666a02a9638ba3e7b8edf01a2ef841e127dcca7dd7384acee81e7d2a81415043ef5
|
|
7
|
+
data.tar.gz: b81a860aa49609ee8942e3e9b17ede7891b75e5cbcb2938e64d231b3e8fb411acfb8d96f50109651f6c9123489d13354319024661efa2d16735ccf9ac7799fb2
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on: [push]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
|
|
9
|
+
services:
|
|
10
|
+
postgres:
|
|
11
|
+
image: postgres:11.5
|
|
12
|
+
env:
|
|
13
|
+
POSTGRES_USER: postgres
|
|
14
|
+
POSTGRES_PASSWORD: postgres
|
|
15
|
+
POSTGRES_DB: ahnnotate_test
|
|
16
|
+
ports:
|
|
17
|
+
- 5432/tcp
|
|
18
|
+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
|
19
|
+
|
|
20
|
+
strategy:
|
|
21
|
+
fail-fast: false
|
|
22
|
+
matrix:
|
|
23
|
+
gemfile:
|
|
24
|
+
- gemfiles/rails60.gemfile
|
|
25
|
+
- gemfiles/rails52.gemfile
|
|
26
|
+
- gemfiles/rails51.gemfile
|
|
27
|
+
- gemfiles/rails50.gemfile
|
|
28
|
+
- gemfiles/rails42.gemfile
|
|
29
|
+
- gemfiles/rails41.gemfile
|
|
30
|
+
include:
|
|
31
|
+
- gemfile: gemfiles/rails60.gemfile
|
|
32
|
+
ruby: 2.6.x
|
|
33
|
+
- gemfile: gemfiles/rails52.gemfile
|
|
34
|
+
ruby: 2.5.x
|
|
35
|
+
- gemfile: gemfiles/rails51.gemfile
|
|
36
|
+
ruby: 2.5.x
|
|
37
|
+
- gemfile: gemfiles/rails50.gemfile
|
|
38
|
+
ruby: 2.5.x
|
|
39
|
+
- gemfile: gemfiles/rails42.gemfile
|
|
40
|
+
ruby: 2.4.x
|
|
41
|
+
- gemfile: gemfiles/rails41.gemfile
|
|
42
|
+
ruby: 2.3.x
|
|
43
|
+
|
|
44
|
+
steps:
|
|
45
|
+
- uses: actions/checkout@v1
|
|
46
|
+
- name: Set up Ruby
|
|
47
|
+
uses: actions/setup-ruby@v1
|
|
48
|
+
with:
|
|
49
|
+
ruby-version: ${{ matrix.ruby }}
|
|
50
|
+
- name: Install build dependencies
|
|
51
|
+
run: |
|
|
52
|
+
sudo apt-get install -y sqlite3 libsqlite3-dev libpq-dev
|
|
53
|
+
- name: Install dependencies
|
|
54
|
+
env:
|
|
55
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
|
56
|
+
run: |
|
|
57
|
+
gem install bundler -v 1.17.3
|
|
58
|
+
bundle install --jobs 4 --retry 3
|
|
59
|
+
- name: Test
|
|
60
|
+
env:
|
|
61
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
|
62
|
+
AHNNOTATE_POSTGRES_DATABASE_URL: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/ahnnotate_test
|
|
63
|
+
run: |
|
|
64
|
+
bundle exec rake
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
appraise "rails60" do
|
|
2
|
+
gem "activerecord", "~> 6.0.0"
|
|
3
|
+
gem "sqlite3", ">= 1.4"
|
|
4
|
+
end
|
|
5
|
+
|
|
1
6
|
appraise "rails52" do
|
|
2
7
|
gem "activerecord", "~> 5.2.2"
|
|
3
8
|
end
|
|
@@ -8,14 +13,19 @@ end
|
|
|
8
13
|
|
|
9
14
|
appraise "rails50" do
|
|
10
15
|
gem "activerecord", "~> 5.0.7"
|
|
16
|
+
gem "sqlite3", "< 1.4"
|
|
11
17
|
end
|
|
12
18
|
|
|
13
19
|
appraise "rails42" do
|
|
14
20
|
gem "activerecord", "~> 4.2.11"
|
|
21
|
+
gem "pg", "~> 0.15"
|
|
22
|
+
gem "sqlite3", "< 1.4"
|
|
15
23
|
end
|
|
16
24
|
|
|
17
25
|
appraise "rails41" do
|
|
18
26
|
gem "activerecord", "~> 4.1.16"
|
|
27
|
+
gem "pg", "~> 0.15"
|
|
28
|
+
gem "sqlite3", "< 1.4"
|
|
19
29
|
end
|
|
20
30
|
|
|
21
31
|
# vim: syntax=ruby
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
ahnnotate (0.5.0)
|
|
5
|
+
activerecord (>= 4.0.0)
|
|
6
|
+
parser
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
activemodel (6.0.0)
|
|
12
|
+
activesupport (= 6.0.0)
|
|
13
|
+
activerecord (6.0.0)
|
|
14
|
+
activemodel (= 6.0.0)
|
|
15
|
+
activesupport (= 6.0.0)
|
|
16
|
+
activesupport (6.0.0)
|
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
18
|
+
i18n (>= 0.7, < 2)
|
|
19
|
+
minitest (~> 5.1)
|
|
20
|
+
tzinfo (~> 1.1)
|
|
21
|
+
zeitwerk (~> 2.1, >= 2.1.8)
|
|
22
|
+
appraisal (2.2.0)
|
|
23
|
+
bundler
|
|
24
|
+
rake
|
|
25
|
+
thor (>= 0.14.0)
|
|
26
|
+
ast (2.4.0)
|
|
27
|
+
coderay (1.1.2)
|
|
28
|
+
concurrent-ruby (1.1.5)
|
|
29
|
+
dotenv (2.7.1)
|
|
30
|
+
i18n (1.6.0)
|
|
31
|
+
concurrent-ruby (~> 1.0)
|
|
32
|
+
method_source (0.9.2)
|
|
33
|
+
minitest (5.11.3)
|
|
34
|
+
parser (2.6.5.0)
|
|
35
|
+
ast (~> 2.4.0)
|
|
36
|
+
pg (1.1.4)
|
|
37
|
+
pry (0.12.2)
|
|
38
|
+
coderay (~> 1.1.0)
|
|
39
|
+
method_source (~> 0.9.0)
|
|
40
|
+
rake (10.5.0)
|
|
41
|
+
sqlite3 (1.4.1)
|
|
42
|
+
thor (0.20.3)
|
|
43
|
+
thread_safe (0.3.6)
|
|
44
|
+
tzinfo (1.2.5)
|
|
45
|
+
thread_safe (~> 0.1)
|
|
46
|
+
zeitwerk (2.1.10)
|
|
47
|
+
|
|
48
|
+
PLATFORMS
|
|
49
|
+
ruby
|
|
50
|
+
|
|
51
|
+
DEPENDENCIES
|
|
52
|
+
ahnnotate!
|
|
53
|
+
appraisal
|
|
54
|
+
bundler (~> 1.17)
|
|
55
|
+
dotenv
|
|
56
|
+
minitest (~> 5.0)
|
|
57
|
+
pg
|
|
58
|
+
pry
|
|
59
|
+
rake (~> 10.0)
|
|
60
|
+
sqlite3
|
|
61
|
+
|
|
62
|
+
BUNDLED WITH
|
|
63
|
+
1.17.3
|
data/ahnnotate.gemspec
CHANGED
|
@@ -30,8 +30,8 @@ DESC
|
|
|
30
30
|
spec.add_development_dependency "pg"
|
|
31
31
|
spec.add_development_dependency "pry"
|
|
32
32
|
spec.add_development_dependency "appraisal"
|
|
33
|
+
spec.add_development_dependency "dotenv"
|
|
33
34
|
|
|
34
|
-
spec.add_runtime_dependency "activerecord", ">= 4.0.0"
|
|
35
|
+
spec.add_runtime_dependency "activerecord", ">= 4.0.0"
|
|
35
36
|
spec.add_runtime_dependency "parser"
|
|
36
|
-
spec.add_runtime_dependency "proc_party"
|
|
37
37
|
end
|
data/gemfiles/rails41.gemfile
CHANGED
data/gemfiles/rails42.gemfile
CHANGED
data/gemfiles/rails50.gemfile
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Ahnnotate
|
|
2
|
+
class Abilities
|
|
3
|
+
def initialize(connection)
|
|
4
|
+
@connection = connection
|
|
5
|
+
@adapter_name = connection.adapter_name.downcase
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def foreign_key?
|
|
9
|
+
if @adapter_name == "sqlite"
|
|
10
|
+
return false
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
if !@connection.respond_to?(:foreign_keys)
|
|
14
|
+
return false
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
true
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/lib/ahnnotate/column.rb
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
module Ahnnotate
|
|
2
2
|
class Column
|
|
3
3
|
attr_reader :name
|
|
4
|
-
attr_reader :type
|
|
5
4
|
|
|
6
|
-
def
|
|
5
|
+
def self.sql_type_map
|
|
6
|
+
@sql_type_map ||=
|
|
7
|
+
begin
|
|
8
|
+
map = Hash.new { |_self, k| k }
|
|
9
|
+
map["character varying"] = "varchar"
|
|
10
|
+
map["character"] = "char"
|
|
11
|
+
map["datetime"] = "timestamp"
|
|
12
|
+
map["double precision"] = "double"
|
|
13
|
+
map["time with time zone"] = "time"
|
|
14
|
+
map["time without time zone"] = "timetz"
|
|
15
|
+
map["timestamp with time zone"] = "timestamptz"
|
|
16
|
+
map["timestamp without time zone"] = "timestamp"
|
|
17
|
+
map
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def initialize(name:, sql_type:, nullable:, primary_key:, default:)
|
|
7
22
|
@name = name
|
|
8
|
-
@
|
|
23
|
+
@sql_type = sql_type.to_s.downcase.gsub(/\(.*?\)/, "")
|
|
9
24
|
@nullable = nullable
|
|
10
25
|
@primary_key = primary_key
|
|
11
26
|
@default = default
|
|
12
27
|
end
|
|
13
28
|
|
|
29
|
+
def type
|
|
30
|
+
self.class.sql_type_map[@sql_type]
|
|
31
|
+
end
|
|
32
|
+
|
|
14
33
|
def details
|
|
15
34
|
if @details
|
|
16
35
|
return @details
|
|
@@ -15,7 +15,7 @@ module Ahnnotate
|
|
|
15
15
|
# Named to fit the ModelSchema interface. This is basically `Class#name`
|
|
16
16
|
attr_accessor :name
|
|
17
17
|
# Named to fit the ModelSchema interface. This is the "outer class"
|
|
18
|
-
attr_accessor :
|
|
18
|
+
attr_accessor :module_parent
|
|
19
19
|
# Named to fit the ModelSchema interface. This is the class that the
|
|
20
20
|
# current class inherits from. This is computed, whereas
|
|
21
21
|
# `claimed_superclass` is what is parsed from the source
|
|
@@ -31,13 +31,13 @@ module Ahnnotate
|
|
|
31
31
|
attr_accessor :path
|
|
32
32
|
|
|
33
33
|
def initialize(name,
|
|
34
|
-
|
|
34
|
+
module_parent: nil,
|
|
35
35
|
is_a_kind_of_activerecord_base: false,
|
|
36
36
|
claimed_superclass: nil,
|
|
37
37
|
explicit_table_name: nil,
|
|
38
38
|
abstract_class: nil)
|
|
39
39
|
self.name = name
|
|
40
|
-
self.
|
|
40
|
+
self.module_parent = parent
|
|
41
41
|
self.is_a_kind_of_activerecord_base = is_a_kind_of_activerecord_base
|
|
42
42
|
self.claimed_superclass = claimed_superclass
|
|
43
43
|
self.explicit_table_name = explicit_table_name
|
|
@@ -80,11 +80,17 @@ module Ahnnotate
|
|
|
80
80
|
superclass.base_class
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
+
# Named to fit the ModelSchema interface. It was originally implemented
|
|
84
|
+
# in ActiveRecord::Inheritance in Rails 6.0.
|
|
85
|
+
def base_class?
|
|
86
|
+
base_class == self
|
|
87
|
+
end
|
|
88
|
+
|
|
83
89
|
# Named to fit the ModelSchema interface. It was originally implemented
|
|
84
90
|
# in ActiveSupport::Introspection
|
|
85
|
-
def
|
|
86
|
-
if
|
|
87
|
-
[
|
|
91
|
+
def module_parents
|
|
92
|
+
if module_parent
|
|
93
|
+
[module_parent, *module_parent.module_parent]
|
|
88
94
|
else
|
|
89
95
|
[]
|
|
90
96
|
end
|
|
@@ -132,7 +138,26 @@ module Ahnnotate
|
|
|
132
138
|
end
|
|
133
139
|
end
|
|
134
140
|
|
|
141
|
+
module ActiveRecord4And5Compatibility
|
|
142
|
+
# Named to fit the ModelSchema interface. It was originally implemented
|
|
143
|
+
# in ActiveSupport::CoreExt::Module::Introspection in Rails 6.0.
|
|
144
|
+
def parent
|
|
145
|
+
module_parent
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# def parent=(parent_)
|
|
149
|
+
# self.module_parent = parent_
|
|
150
|
+
# end
|
|
151
|
+
|
|
152
|
+
# Named to fit the ModelSchema interface. It was originally implemented
|
|
153
|
+
# in ActiveSupport::CoreExt::Module::Introspection in Rails 6.0.
|
|
154
|
+
def parents
|
|
155
|
+
module_parents
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
135
159
|
include ActiveRecord4Compatibility
|
|
160
|
+
include ActiveRecord4And5Compatibility
|
|
136
161
|
end
|
|
137
162
|
end
|
|
138
163
|
end
|
|
@@ -2,7 +2,9 @@ module Ahnnotate
|
|
|
2
2
|
module Facet
|
|
3
3
|
module Models
|
|
4
4
|
class ResolveClassRelationships
|
|
5
|
-
|
|
5
|
+
def to_proc
|
|
6
|
+
method(:call).to_proc
|
|
7
|
+
end
|
|
6
8
|
|
|
7
9
|
def call(extracted_classes)
|
|
8
10
|
object_space =
|
|
@@ -19,7 +21,7 @@ module Ahnnotate
|
|
|
19
21
|
object_space["::ActiveRecord::Base"] =
|
|
20
22
|
ModuleNode.new(
|
|
21
23
|
"ActiveRecord::Base",
|
|
22
|
-
|
|
24
|
+
module_parent: object_space[""],
|
|
23
25
|
abstract_class: nil
|
|
24
26
|
)
|
|
25
27
|
object_space["::ActiveRecord::Base"].is_active_record_base = true
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Ahnnotate
|
|
2
|
+
class ForeignKey
|
|
3
|
+
attr_accessor :name
|
|
4
|
+
attr_accessor :from_column
|
|
5
|
+
attr_accessor :to_table
|
|
6
|
+
attr_accessor :to_column
|
|
7
|
+
|
|
8
|
+
def initialize(**args)
|
|
9
|
+
args.each do |key, value|
|
|
10
|
+
public_send("#{key}=", value)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def from
|
|
15
|
+
from_column
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def to
|
|
19
|
+
"#{to_table}##{to_column}"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require "ahnnotate"
|
|
2
|
+
|
|
3
|
+
# This RSpec matcher only works for Rails. Here's a quick usage example:
|
|
4
|
+
#
|
|
5
|
+
# require "rails_helper"
|
|
6
|
+
# require "ahnnotate/rspec"
|
|
7
|
+
#
|
|
8
|
+
# RSpec.describe Ahnnotate do
|
|
9
|
+
# it { is_expected.to be_up_to_date }
|
|
10
|
+
# end
|
|
11
|
+
class AhnnotateUpToDateMatcher
|
|
12
|
+
attr_reader :actual
|
|
13
|
+
attr_reader :expected
|
|
14
|
+
|
|
15
|
+
def diffable?
|
|
16
|
+
true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def matches?(_)
|
|
20
|
+
options = Ahnnotate::Options.new(fix: false)
|
|
21
|
+
config = Ahnnotate::Config.load(root: Rails.root)
|
|
22
|
+
main = Ahnnotate::Function::Main.new(Rails.root, options, config)
|
|
23
|
+
|
|
24
|
+
main.call
|
|
25
|
+
|
|
26
|
+
writes = main.vfs.instance_variable_get(:@driver).changes
|
|
27
|
+
|
|
28
|
+
format = proc do |vfs_hash|
|
|
29
|
+
vfs_hash
|
|
30
|
+
.map { |path, contents| "~~~ #{path} ~~~\n#{contents}" }
|
|
31
|
+
.join("\n")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
expected = writes.map { |path, _content| [path, File.read(path)] }.to_h
|
|
35
|
+
@expected = format.call(expected)
|
|
36
|
+
@actual = format.call(writes)
|
|
37
|
+
|
|
38
|
+
@actual == @expected
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def description
|
|
42
|
+
"be up to date (you may need to run `rails db:test:prepare`)"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def failure_message
|
|
46
|
+
"expected Ahnnotate to be up to date"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def failure_message_when_negated
|
|
50
|
+
"expected Ahnnotate not to be up to date"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
module AhnnotateBeUpToDate
|
|
55
|
+
def be_up_to_date
|
|
56
|
+
AhnnotateUpToDateMatcher.new
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
RSpec.configure do |c|
|
|
61
|
+
c.include AhnnotateBeUpToDate
|
|
62
|
+
end
|
data/lib/ahnnotate/table.rb
CHANGED
|
@@ -3,6 +3,7 @@ module Ahnnotate
|
|
|
3
3
|
attr_accessor :name
|
|
4
4
|
attr_accessor :columns
|
|
5
5
|
attr_accessor :indexes
|
|
6
|
+
attr_accessor :foreign_keys
|
|
6
7
|
|
|
7
8
|
def initialize(**args)
|
|
8
9
|
args.each do |key, value|
|
|
@@ -32,6 +33,13 @@ module Ahnnotate
|
|
|
32
33
|
output.puts comment
|
|
33
34
|
end
|
|
34
35
|
|
|
36
|
+
if foreign_keys.any?
|
|
37
|
+
output.puts "#{comment} Foreign keys:"
|
|
38
|
+
output.puts comment
|
|
39
|
+
output.puts tabularizer.call(foreign_keys, [:from, :to, :name])
|
|
40
|
+
output.puts comment
|
|
41
|
+
end
|
|
42
|
+
|
|
35
43
|
output.string
|
|
36
44
|
end
|
|
37
45
|
|
data/lib/ahnnotate/tables.rb
CHANGED
|
@@ -4,6 +4,7 @@ module Ahnnotate
|
|
|
4
4
|
|
|
5
5
|
def initialize(connection = ActiveRecord::Base.connection)
|
|
6
6
|
@connection = connection
|
|
7
|
+
@abilities = Abilities.new(connection)
|
|
7
8
|
end
|
|
8
9
|
|
|
9
10
|
def to_h
|
|
@@ -28,7 +29,7 @@ module Ahnnotate
|
|
|
28
29
|
|
|
29
30
|
Column.new(
|
|
30
31
|
name: c.name,
|
|
31
|
-
|
|
32
|
+
sql_type: c.sql_type,
|
|
32
33
|
nullable: c.null,
|
|
33
34
|
primary_key: is_primary_key,
|
|
34
35
|
default: c.default
|
|
@@ -49,10 +50,25 @@ module Ahnnotate
|
|
|
49
50
|
)
|
|
50
51
|
end
|
|
51
52
|
|
|
53
|
+
foreign_keys =
|
|
54
|
+
if @abilities.foreign_key?
|
|
55
|
+
@connection.foreign_keys(table_name).map do |fk|
|
|
56
|
+
ForeignKey.new(
|
|
57
|
+
name: fk.name,
|
|
58
|
+
from_column: fk.column,
|
|
59
|
+
to_table: fk.to_table,
|
|
60
|
+
to_column: fk.primary_key
|
|
61
|
+
)
|
|
62
|
+
end
|
|
63
|
+
else
|
|
64
|
+
[]
|
|
65
|
+
end
|
|
66
|
+
|
|
52
67
|
yield Table.new(
|
|
53
68
|
name: table_name,
|
|
54
69
|
columns: columns,
|
|
55
|
-
indexes: indexes
|
|
70
|
+
indexes: indexes,
|
|
71
|
+
foreign_keys: foreign_keys,
|
|
56
72
|
)
|
|
57
73
|
end
|
|
58
74
|
end
|
data/lib/ahnnotate/version.rb
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
module Ahnnotate
|
|
2
2
|
module VfsDriver
|
|
3
3
|
class ReadOnlyFilesystem < Filesystem
|
|
4
|
-
|
|
4
|
+
attr_reader :changes
|
|
5
|
+
|
|
6
|
+
def initialize(root:)
|
|
7
|
+
super
|
|
8
|
+
@changes = {}
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def []=(path, content)
|
|
12
|
+
@changes[path] = content
|
|
13
|
+
nil
|
|
5
14
|
end
|
|
6
15
|
end
|
|
7
16
|
end
|
data/lib/ahnnotate.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
require "yaml"
|
|
2
2
|
require "active_record"
|
|
3
3
|
require "parser/current"
|
|
4
|
-
require "proc_party"
|
|
5
4
|
require "stringio"
|
|
6
5
|
|
|
7
6
|
require "ahnnotate/refinement/dig"
|
|
8
7
|
require "ahnnotate/refinement/pathname_glob"
|
|
9
8
|
require "ahnnotate/refinement/yield_self"
|
|
10
9
|
|
|
10
|
+
require "ahnnotate/abilities"
|
|
11
11
|
require "ahnnotate/active_record_version"
|
|
12
12
|
require "ahnnotate/column"
|
|
13
13
|
require "ahnnotate/command"
|
|
@@ -29,6 +29,7 @@ require "ahnnotate/facet/models/processor"
|
|
|
29
29
|
require "ahnnotate/facet/models/resolve_active_record_models"
|
|
30
30
|
require "ahnnotate/facet/models/resolve_class_relationships"
|
|
31
31
|
require "ahnnotate/facet/models/standin"
|
|
32
|
+
require "ahnnotate/foreign_key"
|
|
32
33
|
require "ahnnotate/index"
|
|
33
34
|
require "ahnnotate/options"
|
|
34
35
|
require "ahnnotate/table"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ahnnotate
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Zach Ahn
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-10-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -109,41 +109,35 @@ dependencies:
|
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name:
|
|
112
|
+
name: dotenv
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
|
115
115
|
- - ">="
|
|
116
116
|
- !ruby/object:Gem::Version
|
|
117
|
-
version:
|
|
118
|
-
|
|
119
|
-
- !ruby/object:Gem::Version
|
|
120
|
-
version: '6'
|
|
121
|
-
type: :runtime
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
122
119
|
prerelease: false
|
|
123
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
124
121
|
requirements:
|
|
125
122
|
- - ">="
|
|
126
123
|
- !ruby/object:Gem::Version
|
|
127
|
-
version:
|
|
128
|
-
- - "<"
|
|
129
|
-
- !ruby/object:Gem::Version
|
|
130
|
-
version: '6'
|
|
124
|
+
version: '0'
|
|
131
125
|
- !ruby/object:Gem::Dependency
|
|
132
|
-
name:
|
|
126
|
+
name: activerecord
|
|
133
127
|
requirement: !ruby/object:Gem::Requirement
|
|
134
128
|
requirements:
|
|
135
129
|
- - ">="
|
|
136
130
|
- !ruby/object:Gem::Version
|
|
137
|
-
version:
|
|
131
|
+
version: 4.0.0
|
|
138
132
|
type: :runtime
|
|
139
133
|
prerelease: false
|
|
140
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
141
135
|
requirements:
|
|
142
136
|
- - ">="
|
|
143
137
|
- !ruby/object:Gem::Version
|
|
144
|
-
version:
|
|
138
|
+
version: 4.0.0
|
|
145
139
|
- !ruby/object:Gem::Dependency
|
|
146
|
-
name:
|
|
140
|
+
name: parser
|
|
147
141
|
requirement: !ruby/object:Gem::Requirement
|
|
148
142
|
requirements:
|
|
149
143
|
- - ">="
|
|
@@ -159,7 +153,7 @@ dependencies:
|
|
|
159
153
|
description: 'Ahnnotate comments on your ActiveRecord models with their respective
|
|
160
154
|
schemas!
|
|
161
155
|
|
|
162
|
-
'
|
|
156
|
+
'
|
|
163
157
|
email:
|
|
164
158
|
- engineering@zachahn.com
|
|
165
159
|
executables:
|
|
@@ -167,10 +161,12 @@ executables:
|
|
|
167
161
|
extensions: []
|
|
168
162
|
extra_rdoc_files: []
|
|
169
163
|
files:
|
|
164
|
+
- ".github/workflows/ruby.yml"
|
|
170
165
|
- ".gitignore"
|
|
171
166
|
- ".travis.yml"
|
|
172
167
|
- Appraisals
|
|
173
168
|
- Gemfile
|
|
169
|
+
- Gemfile.lock
|
|
174
170
|
- LICENSE.txt
|
|
175
171
|
- README.md
|
|
176
172
|
- Rakefile
|
|
@@ -185,7 +181,9 @@ files:
|
|
|
185
181
|
- gemfiles/rails50.gemfile
|
|
186
182
|
- gemfiles/rails51.gemfile
|
|
187
183
|
- gemfiles/rails52.gemfile
|
|
184
|
+
- gemfiles/rails60.gemfile
|
|
188
185
|
- lib/ahnnotate.rb
|
|
186
|
+
- lib/ahnnotate/abilities.rb
|
|
189
187
|
- lib/ahnnotate/active_record_version.rb
|
|
190
188
|
- lib/ahnnotate/cli.rb
|
|
191
189
|
- lib/ahnnotate/column.rb
|
|
@@ -199,6 +197,7 @@ files:
|
|
|
199
197
|
- lib/ahnnotate/facet/models/resolve_active_record_models.rb
|
|
200
198
|
- lib/ahnnotate/facet/models/resolve_class_relationships.rb
|
|
201
199
|
- lib/ahnnotate/facet/models/standin.rb
|
|
200
|
+
- lib/ahnnotate/foreign_key.rb
|
|
202
201
|
- lib/ahnnotate/function/format.rb
|
|
203
202
|
- lib/ahnnotate/function/main.rb
|
|
204
203
|
- lib/ahnnotate/function/niam.rb
|
|
@@ -211,6 +210,7 @@ files:
|
|
|
211
210
|
- lib/ahnnotate/refinement/dig.rb
|
|
212
211
|
- lib/ahnnotate/refinement/pathname_glob.rb
|
|
213
212
|
- lib/ahnnotate/refinement/yield_self.rb
|
|
213
|
+
- lib/ahnnotate/rspec.rb
|
|
214
214
|
- lib/ahnnotate/table.rb
|
|
215
215
|
- lib/ahnnotate/tables.rb
|
|
216
216
|
- lib/ahnnotate/version.rb
|
|
@@ -237,8 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
237
237
|
- !ruby/object:Gem::Version
|
|
238
238
|
version: '0'
|
|
239
239
|
requirements: []
|
|
240
|
-
|
|
241
|
-
rubygems_version: 2.7.6
|
|
240
|
+
rubygems_version: 3.0.3
|
|
242
241
|
signing_key:
|
|
243
242
|
specification_version: 4
|
|
244
243
|
summary: Ahnnotate comments on your ActiveRecord models with their respective schemas!
|