ignored_removed_columns 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 94cf8e7693b4499f771dc263977558adf09c9f9652bdfe6532b2090bef004a39
4
+ data.tar.gz: 16eb3b5646638a01ee3ab5f20d6dd7b4291fce0a6e6b2ba6418825ef66e7500a
5
+ SHA512:
6
+ metadata.gz: b65cc9ac2764586173b88a7c474a62c8c6d756ea4d39a87b01468a753e5287c6ea4281dd892122fb56c3bea2b77b42fa931b3ce3558b942698325b95157af107
7
+ data.tar.gz: d2f8386ba9f97e38603c96be1bd213cf34aa3f17124576af01f8ba2fe631d82bed7ad6cf2488a2fed3487137d648fa4b4218a62102250b57790c919521ab279a
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 1.16.4
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in ignored_removed_columns.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 meganemura
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # IgnoredRemovedColumns
2
+
3
+ ## Installation
4
+
5
+ ```ruby
6
+ gem 'ignored_removed_columns'
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ ```console
12
+ $ rake ignored_removed_columns:check
13
+ Found removed or typo columns defined in ignored_columns
14
+ --------------------------------------------------------
15
+ Post:
16
+ - published
17
+ - archived
18
+ ```
19
+
20
+ This means:
21
+
22
+ `Post` class defines `published` (maybe removed) and `archivedd` (maybe typo) ignored_columns, but the related table (commonly `posts`) does not have those columns. So, you can remove those from its ignored_columns.
23
+
24
+ ## Contributing
25
+
26
+ Bug reports and pull requests are welcome on GitHub at https://github.com/meganemura/ignored_removed_columns.
27
+
28
+ ## License
29
+
30
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ignored_removed_columns"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "ignored_removed_columns/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "ignored_removed_columns"
7
+ spec.version = IgnoredRemovedColumns::VERSION
8
+ spec.authors = ["meganemura"]
9
+ spec.email = ["meganemura@users.noreply.github.com"]
10
+
11
+ spec.summary = "Find removed or typo columns defined in ignored_columns"
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/meganemura/ignored_removed_columns"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ end
@@ -0,0 +1,7 @@
1
+ module IgnoredRemovedColumns
2
+ class Railtie < ::Rails::Railtie
3
+ rake_tasks do
4
+ load 'tasks/ignored_removed_columns_tasks.rake'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module IgnoredRemovedColumns
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "ignored_removed_columns/railtie" if defined?(Rails)
2
+ require "ignored_removed_columns/version"
3
+
4
+ module IgnoredRemovedColumns
5
+ end
@@ -0,0 +1,43 @@
1
+ namespace :ignored_removed_columns do
2
+ desc "Find removed or typo columns defined in ignored_columns"
3
+ task :check, [:klass_name] => :environment do |task, args|
4
+ args.with_defaults(klass_name: 'ActiveRecord::Base')
5
+ klass = args[:klass_name].safe_constantize
6
+ unless klass
7
+ exit 2
8
+ end
9
+
10
+ Rails.application.eager_load!
11
+ model_classes = ActiveSupport::DescendantsTracker.descendants(klass)
12
+
13
+ found_columns = false
14
+ model_classes.each do |model_class|
15
+ next if model_class.abstract_class?
16
+
17
+ ignored_columns = model_class.ignored_columns
18
+ actual_columns = model_class.connection.schema_cache.columns_hash(model_class.table_name).keys
19
+
20
+ removed_or_typo_columns = ignored_columns - actual_columns
21
+
22
+ next if removed_or_typo_columns.empty?
23
+
24
+ unless found_columns
25
+ puts "Found removed or typo columns defined in ignored_columns"
26
+ puts "--------------------------------------------------------"
27
+ found_columns = true
28
+ end
29
+
30
+ puts "#{model_class}:"
31
+ removed_or_typo_columns.each do |column|
32
+ puts " - #{column}"
33
+ end
34
+ end
35
+
36
+ if found_columns
37
+ exit 1
38
+ end
39
+
40
+ puts "ok"
41
+ exit 0
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ignored_removed_columns
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - meganemura
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Find removed or typo columns defined in ignored_columns
56
+ email:
57
+ - meganemura@users.noreply.github.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - ignored_removed_columns.gemspec
72
+ - lib/ignored_removed_columns.rb
73
+ - lib/ignored_removed_columns/railtie.rb
74
+ - lib/ignored_removed_columns/version.rb
75
+ - lib/tasks/ignored_removed_columns_tasks.rake
76
+ homepage: https://github.com/meganemura/ignored_removed_columns
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.7.6
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Find removed or typo columns defined in ignored_columns
100
+ test_files: []