screamers 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Rakefile +2 -2
- data/bin/console +4 -4
- data/lib/screamers/column_collector.rb +14 -7
- data/lib/screamers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd0e9b8fc326581ce6dab5bd8f1bff03eb560f23
|
4
|
+
data.tar.gz: 5fdc73674dd7f8dc098d0bca1c26c3952f36acad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6204650c8878ef05f94c87a3917ec25698f726c0355c1f84cbadc1e4e72839be88a5a217f213c943b1ba409a2ec9d88dac9a6a46e031397a731e99368a7b906f
|
7
|
+
data.tar.gz: 440a62c0f075d3c469393bf23b57c22908c9e2fa1a16ca74c0778e16329e836e56a5bc31bcadaed22fee53aaf659ef82cfe4864158a96e4dc963a07628ef75c6
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'screamers'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require
|
10
|
+
# require 'pry'
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
@@ -11,14 +11,9 @@ module Screamers
|
|
11
11
|
tables = ActiveRecord::Base.connection.tables
|
12
12
|
|
13
13
|
@target_tables = tables.each_with_object({}) {|table, target|
|
14
|
-
|
15
|
-
columns = Module.const_get(table.classify).columns
|
16
|
-
rescue
|
17
|
-
puts "An ActiveRecord model mapped to `#{table}` foo could not be found. Please check if you need handmade by yourself."
|
18
|
-
next
|
19
|
-
end
|
14
|
+
active_record_model = active_record_model_const_get(table.classify)
|
20
15
|
|
21
|
-
target_columns = columns.select {|column|
|
16
|
+
target_columns = active_record_model.columns.select {|column|
|
22
17
|
column.type == @old_column_type
|
23
18
|
}
|
24
19
|
|
@@ -27,5 +22,17 @@ module Screamers
|
|
27
22
|
end
|
28
23
|
}
|
29
24
|
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def active_record_model_const_get(class_name)
|
29
|
+
Module.const_get(class_name)
|
30
|
+
rescue
|
31
|
+
eval <<-EOS.strip_heredoc
|
32
|
+
class ::#{class_name} < ActiveRecord::Base
|
33
|
+
end
|
34
|
+
EOS
|
35
|
+
Module.const_get(class_name)
|
36
|
+
end
|
30
37
|
end
|
31
38
|
end
|
data/lib/screamers/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: screamers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi ITO
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|