pronto-rails_data_schema 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +11 -0
- data/Rakefile +6 -0
- data/lib/pronto/rails_data_schema.rb +51 -0
- data/lib/pronto/rails_data_schema/version.rb +5 -0
- data/pronto-rails_schema.gemspec +30 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f756fa6f2c6d5ce6ea8019fdb5a096ce7c47033027561f87c3e4a9bdc7421aa9
|
4
|
+
data.tar.gz: 28a0d8a0fc91b16823581061e3e6d6bea7511f7c5dbdcd588db1230582a13e43
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8b0f2c74735020533184affcca92aba94a668a8a5be49ef9d81e114a7bfe6b4ed6767a83f166e8feab054f93596e6e159815369b3017cb246c1fb67a731c8ead
|
7
|
+
data.tar.gz: 967a18c6df14cc4196bc074bd02010f675ae8f419361cce48432f0499348dcd7e7186ba7d395df092fc3f20bc0b6d6d776e6836d5d1b6fdfdf344821e8bc3ed2
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Raimondas Valickas
|
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,11 @@
|
|
1
|
+
# Pronto::RailsDataSchema
|
2
|
+
|
3
|
+
Pronto runner for monitoring Rails data_schema.rb consistency.
|
4
|
+
Tool prints a warning message when data migration is present
|
5
|
+
but there are no modifications in data_schema.rb.
|
6
|
+
|
7
|
+
Based on [raimondasv/pronto-rails_schema](https://github.com/raimondasv/pronto-rails_schema)
|
8
|
+
|
9
|
+
[What is Pronto?](https://github.com/mmozuras/pronto)
|
10
|
+
|
11
|
+
[![Gem Version](https://badge.fury.io/rb/pronto-rails_data_schema.svg)](https://badge.fury.io/rb/pronto-rails_data_schema)
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'pronto'
|
2
|
+
|
3
|
+
module Pronto
|
4
|
+
class RailsDataSchema < Runner
|
5
|
+
def run
|
6
|
+
return [] unless migration_patches.any?
|
7
|
+
|
8
|
+
if schema_file_present?
|
9
|
+
schema_patch = @patches.find { |patch| detect_schema_file(patch.new_file_full_path) }
|
10
|
+
return generate_messages_for('data_schema.rb') unless changes_detected?(schema_patch)
|
11
|
+
end
|
12
|
+
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def schema_file_present?
|
19
|
+
File.exist?('db/data_schema.rb')
|
20
|
+
end
|
21
|
+
|
22
|
+
def migration_patches
|
23
|
+
return [] unless @patches
|
24
|
+
@migration_patches ||= @patches
|
25
|
+
.select { |patch| detect_added_migration_file(patch) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def generate_messages_for(target)
|
29
|
+
migration_patches.map do |patch|
|
30
|
+
first_line = patch.added_lines.first
|
31
|
+
Message.new(patch.delta.new_file[:path], first_line, :warning,
|
32
|
+
"Data migration file detected, but no changes in #{target}",
|
33
|
+
nil, self.class)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def detect_added_migration_file(patch)
|
38
|
+
return unless patch.delta.added?
|
39
|
+
/(.*)db[\\|\/]data[\\|\/](\d{14}_([_A-Za-z]+)\.rb)$/i =~
|
40
|
+
patch.delta.new_file[:path]
|
41
|
+
end
|
42
|
+
|
43
|
+
def detect_schema_file(path)
|
44
|
+
/db[\\|\/]data_schema.rb/i =~ path.to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
def changes_detected?(patch)
|
48
|
+
patch && (patch.additions > 0 || patch.deletions > 0)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -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 'pronto/rails_data_schema/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pronto-rails_data_schema"
|
8
|
+
spec.version = Pronto::RailsDataSchemaVersion::VERSION
|
9
|
+
spec.authors = ["mbajur"]
|
10
|
+
spec.email = ["mbajur@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Pronto runner for detection of Rails data-migrate
|
13
|
+
schema changes.}
|
14
|
+
spec.description = %q{Detects migration files and checks for changes in
|
15
|
+
data_schema.rb file}
|
16
|
+
spec.homepage = "https://github.com/mbajur/pronto-rails_data_schema"
|
17
|
+
spec.license = "MIT"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.required_ruby_version = '>= 2.3.0'
|
25
|
+
|
26
|
+
spec.add_dependency 'pronto', '~> 0.10.0 '
|
27
|
+
spec.add_development_dependency "bundler"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.3"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pronto-rails_data_schema
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mbajur
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pronto
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.10.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.10.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: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.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: '3.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.3'
|
69
|
+
description: |-
|
70
|
+
Detects migration files and checks for changes in
|
71
|
+
data_schema.rb file
|
72
|
+
email:
|
73
|
+
- mbajur@gmail.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".travis.yml"
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- lib/pronto/rails_data_schema.rb
|
86
|
+
- lib/pronto/rails_data_schema/version.rb
|
87
|
+
- pronto-rails_schema.gemspec
|
88
|
+
homepage: https://github.com/mbajur/pronto-rails_data_schema
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 2.3.0
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.7.7
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Pronto runner for detection of Rails data-migrate schema changes.
|
112
|
+
test_files: []
|