activerecord-quiet_schema_version 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
+ SHA1:
3
+ metadata.gz: 074ac37067a082fba2f6159575e60501f6675a59
4
+ data.tar.gz: b0290eab271acb2106fbd756f5e2e8b4427460a8
5
+ SHA512:
6
+ metadata.gz: f753e3a49f7329d97201559ded1ec82c28a2fe4b16fbd8ea69c1ee21a1f4fc70e468fe177a873ce334c3198b4d995fd3d4b593f8c05f43ffea740ec15ef495b3
7
+ data.tar.gz: 46aa85d3c35ce3bc54fe577171693bd30bbb5f3d5a620ae318ee270bcc0bfc4ef6519551440f9ce83bd7192c9a882c3168bb0c2fe389d8c7c96c5724e6b361d8
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .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,13 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ - ruby-head
6
+ gemfile:
7
+ - gemfiles/activerecord_4_2.gemfile
8
+ - gemfiles/activerecord_5_0.gemfile
9
+ - gemfiles/activerecord_5_1.gemfile
10
+ - gemfiles/activerecord_master.gemfile
11
+ before_install: gem install bundler -v 1.14.6
12
+ script:
13
+ - bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in activerecord-quiet_schema_version.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Takafumi ONAKA
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,42 @@
1
+ # Activerecord::QuietSchemaVersion
2
+
3
+ ## What is this?
4
+
5
+ `ActiveRecord::Schema.define`'s `version` argument is frequently conflicts, so make it empty.
6
+
7
+ before:
8
+
9
+ ```
10
+ ActiveRecord::Schema.define(version: 2017_05_05_000000)
11
+ ```
12
+
13
+ after:
14
+
15
+ ```
16
+ ActiveRecord::Schema.define()
17
+ ```
18
+
19
+
20
+ ## Why can it be empty?
21
+
22
+ This `version` argument shows "Which migration files were executed" and
23
+ is used to insert into `schema_migrations` table when `rake db:schame:load` is executed.
24
+
25
+ If always commit `db/schema.rb` with `db/migrate/xxx`, `version` will be the maximum
26
+ version of migration files.
27
+
28
+ After using this gem, `version` is automatically set the maximum version if not specified.
29
+
30
+
31
+ ## Installation
32
+
33
+ Add this line to your application's Gemfile:
34
+
35
+ ```ruby
36
+ gem 'activerecord-quiet_schema_version'
37
+ ```
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
42
+
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
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'activerecord/quiet_schema_version/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "activerecord-quiet_schema_version"
8
+ spec.version = Activerecord::QuietSchemaVersion::VERSION
9
+ spec.authors = ["Takafumi ONAKA"]
10
+ spec.email = ["takafumi.onaka@gmail.com"]
11
+
12
+ spec.summary = "Turns off Rails DB schema version."
13
+ spec.description = "Turns off Rails DB schema version."
14
+ spec.homepage = "https://github.com/onk/activerecord-quiet_schema_version"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "activerecord"
25
+
26
+ spec.add_development_dependency "bundler"
27
+ spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency "sqlite3"
30
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "activerecord/quiet_schema_version"
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,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activerecord", "~> 4.2.0"
4
+
5
+ gemspec path: "../"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activerecord", "~> 5.0.0"
4
+
5
+ gemspec path: "../"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activerecord", "~> 5.1.0"
4
+
5
+ gemspec path: "../"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activerecord", github: "rails/rails"
4
+
5
+ gemspec path: "../"
@@ -0,0 +1 @@
1
+ require "activerecord/quiet_schema_version"
@@ -0,0 +1,4 @@
1
+ require "activerecord/quiet_schema_version/version"
2
+ require "active_record"
3
+ require "activerecord/quiet_schema_version/schema"
4
+ require "activerecord/quiet_schema_version/schema_dumper"
@@ -0,0 +1,29 @@
1
+ module Activerecord
2
+ module QuietSchemaVersion
3
+ module Schema
4
+ def self.prepended(base)
5
+ class << base
6
+ self.prepend(ClassMethods)
7
+ end
8
+ end
9
+
10
+ module ClassMethods
11
+ def define(info = {}, &block)
12
+ info[:version] ||= detect_maximum_version # <- monkeypatched this line
13
+ new.define(info, &block)
14
+ end
15
+
16
+ def detect_maximum_version
17
+ migrations_paths = ActiveRecord::Migrator.migrations_paths
18
+ paths = migrations_paths.map { |p| "#{p}/[0-9]*_*.rb" }
19
+ versions = Dir[*paths].map do |filename|
20
+ filename.split("/").last.split("_").first.to_i
21
+ end
22
+ versions.max
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ ActiveRecord::Schema.prepend Activerecord::QuietSchemaVersion::Schema
@@ -0,0 +1,16 @@
1
+ require "activerecord/quiet_schema_version/schema_dumper/ar_4_2"
2
+ require "activerecord/quiet_schema_version/schema_dumper/ar_5_0"
3
+ require "activerecord/quiet_schema_version/schema_dumper/ar_5_2"
4
+
5
+ if ActiveRecord.version < Gem::Version.new("5.0.0.beta1")
6
+ # ActiveRecord 4.2
7
+ # https://github.com/rails/rails/commit/9e4ed2f996d8dd7eaac0399f4efb5ce58aa593f8
8
+ ActiveRecord::SchemaDumper.prepend Activerecord::QuietSchemaVersion::SchemaDumper::AR42
9
+ elsif ActiveRecord.version < Gem::Version.create("5.2.0.alpha")
10
+ # ActiveRecord 5.0, 5.1
11
+ # https://github.com/rails/rails/commit/1d05e64b6dc5ba4ed1e21dd2975dcd7faf36795d
12
+ ActiveRecord::SchemaDumper.prepend Activerecord::QuietSchemaVersion::SchemaDumper::AR50
13
+ else
14
+ # >= ActiveRecord 5.2
15
+ ActiveRecord::SchemaDumper.prepend Activerecord::QuietSchemaVersion::SchemaDumper::AR52
16
+ end
@@ -0,0 +1,14 @@
1
+ module Activerecord
2
+ module QuietSchemaVersion
3
+ module SchemaDumper
4
+ module AR42
5
+ def initialize(connection, options = {})
6
+ @connection = connection
7
+ @types = @connection.native_database_types
8
+ @version = nil # <- monkeypatched this line
9
+ @options = options
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ module Activerecord
2
+ module QuietSchemaVersion
3
+ module SchemaDumper
4
+ module AR50
5
+ def initialize(connection, options = {})
6
+ @connection = connection
7
+ @version = nil # <- monkeypatched this line
8
+ @options = options
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module Activerecord
2
+ module QuietSchemaVersion
3
+ module SchemaDumper
4
+ module AR52
5
+ def define_params
6
+ ""
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module Activerecord
2
+ module QuietSchemaVersion
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-quiet_schema_version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Takafumi ONAKA
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Turns off Rails DB schema version.
84
+ email:
85
+ - takafumi.onaka@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - activerecord-quiet_schema_version.gemspec
98
+ - bin/console
99
+ - bin/setup
100
+ - gemfiles/activerecord_4_2.gemfile
101
+ - gemfiles/activerecord_5_0.gemfile
102
+ - gemfiles/activerecord_5_1.gemfile
103
+ - gemfiles/activerecord_master.gemfile
104
+ - lib/activerecord-quiet_schema_version.rb
105
+ - lib/activerecord/quiet_schema_version.rb
106
+ - lib/activerecord/quiet_schema_version/schema.rb
107
+ - lib/activerecord/quiet_schema_version/schema_dumper.rb
108
+ - lib/activerecord/quiet_schema_version/schema_dumper/ar_4_2.rb
109
+ - lib/activerecord/quiet_schema_version/schema_dumper/ar_5_0.rb
110
+ - lib/activerecord/quiet_schema_version/schema_dumper/ar_5_2.rb
111
+ - lib/activerecord/quiet_schema_version/version.rb
112
+ homepage: https://github.com/onk/activerecord-quiet_schema_version
113
+ licenses:
114
+ - MIT
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 2.6.11
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: Turns off Rails DB schema version.
136
+ test_files: []