active_record_schema_scrapper 0.1.0 → 0.1.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad8b72a1fd99a6cc14f70a87ec35f42870f26a2c
|
4
|
+
data.tar.gz: 8fd34f4c58f20e2678b9468e86f0a624afb11f22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f63130533253906f4b03f29ff7fad8c1f69db8d07b073e206e8d3de760c30f77d8939959282d6e4a40fa332db496576bd195c55b858b2b56aac7d9475261560
|
7
|
+
data.tar.gz: 0e49306e9cd3caf0b506dbe905ca80a771372e275c2e0b42e3181b1a1e144e06eada0bb7d2bbe7a1ad01ecfa7dfb943e0789e82bd5a5a001588b200ebc248216
|
@@ -11,30 +11,40 @@ class ActiveRecordSchemaScrapper
|
|
11
11
|
def each
|
12
12
|
types.each do |type|
|
13
13
|
model.reflect_on_all_associations(type).each do |a|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
14
|
+
begin
|
15
|
+
hash = if a.try(:delegate_reflection)
|
16
|
+
{ source: a.delegate_reflection.options[:source],
|
17
|
+
through: a.delegate_reflection.options[:through],
|
18
|
+
dependent: a.delegate_reflection.options[:dependent],
|
19
|
+
}
|
20
|
+
else
|
21
|
+
{ source: a.try(:delegate_reflection).try(:name),
|
22
|
+
through: a.try(:through),
|
23
|
+
dependent: a.options[:dependent] }
|
24
|
+
end.merge({
|
25
|
+
name: a.name,
|
26
|
+
foreign_key: a.foreign_key,
|
27
|
+
class_name: a.klass.name,
|
28
|
+
type: type,
|
29
|
+
})
|
30
|
+
|
31
|
+
yield(ActiveRecordSchemaScrapper::Association.new(hash))
|
32
|
+
rescue NameError => e
|
33
|
+
errors << "Missing model #{a.name.to_s.camelize} for association #{model.name}.belongs_to :#{a.name}"
|
34
|
+
end
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
33
38
|
|
34
39
|
def to_a
|
35
|
-
map {|v| v}
|
40
|
+
map { |v| v }
|
36
41
|
end
|
37
42
|
|
43
|
+
def errors
|
44
|
+
@errors ||= []
|
45
|
+
end
|
46
|
+
|
47
|
+
|
38
48
|
def self.types
|
39
49
|
[:has_and_belongs_to_many, :belongs_to, :has_one, :has_many]
|
40
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_schema_scrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Zeisler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|