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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c758d59eefca8fe53f74f8b767551ab74ca28b22
4
- data.tar.gz: 4a75e01840b39476caacb21759d49f9ae40ce3a8
3
+ metadata.gz: dd0e9b8fc326581ce6dab5bd8f1bff03eb560f23
4
+ data.tar.gz: 5fdc73674dd7f8dc098d0bca1c26c3952f36acad
5
5
  SHA512:
6
- metadata.gz: e355ca06f9e67107698f923f9df8e15d0e104aa0486ecca68f7cee6a0ff2691191ddb9e8defbfaaa71dad336d6e5f2ef41313c5fe1ff11133890ae2330792949
7
- data.tar.gz: 9f3d9477e34c444e91c2488a688423313384b0f7c3ac4d570e947d7b0f9eb16d90f450367582660fa6be55d3671e13e8f82bb26c96aef88df7aa41fdbb34c23b
6
+ metadata.gz: 6204650c8878ef05f94c87a3917ec25698f726c0355c1f84cbadc1e4e72839be88a5a217f213c943b1ba409a2ec9d88dac9a6a46e031397a731e99368a7b906f
7
+ data.tar.gz: 440a62c0f075d3c469393bf23b57c22908c9e2fa1a16ca74c0778e16329e836e56a5bc31bcadaed22fee53aaf659ef82cfe4864158a96e4dc963a07628ef75c6
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in screamers.gemspec
4
4
  gemspec
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "screamers"
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 "pry"
10
+ # require 'pry'
11
11
  # Pry.start
12
12
 
13
- require "irb"
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
- begin
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
@@ -1,3 +1,3 @@
1
1
  module Screamers
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
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.2.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-01 00:00:00.000000000 Z
11
+ date: 2017-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord