pronto-rails_schema 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d6038f7919c7eae973accc3a6eba4cf011f28b06
4
+ data.tar.gz: a8b66c4ffb8c3a5f6679df637e50dd9ebf71a8de
5
+ SHA512:
6
+ metadata.gz: 55f829bc3cd45b02d99d47cdd6f166366a2062a8a3a091ae689717d0b810046027cb94765208d2f61ee63f76873adf8357e29540554496c2f05bde5078227602
7
+ data.tar.gz: bf837bb23eb562e402fd02936255c68cf1dcd3a9fe4c18256326230e17b35b606c432d6eec0a152e25a5d3fda85b4bb6abc5b72cbf5a0eccf0797089d5330f38
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.2.2
5
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pronto-rails_schema.gemspec
4
+ gemspec
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,6 @@
1
+ # Pronto::RailsSchema
2
+
3
+ Pronto runner for monitoring Rails schema.rb or structure.sql consistency.
4
+ Tool prints a warning message when migration is present
5
+ but there are no modifications in schema.rb or structure.sql.
6
+ [What is Pronto?](https://github.com/mmozuras/pronto)
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,58 @@
1
+ require 'pronto'
2
+
3
+ module Pronto
4
+ class RailsSchema < Runner
5
+ def run(patches, _)
6
+ return [] unless patches
7
+
8
+ migration_patches = patches
9
+ .select { |patch| detect_added_migration_file(patch) }
10
+ return [] unless migration_patches.any?
11
+
12
+ if schema_file_present?
13
+ schema_patch = patches.find { |patch| detect_schema_file(patch.new_file_full_path) }
14
+ return generate_messages_for(migration_patches, 'schema.rb') unless changes_detected?(schema_patch)
15
+ end
16
+
17
+ if structure_file_present?
18
+ structure_patch = patches.find { |patch| detect_structure_file(patch.new_file_full_path) }
19
+ return generate_messages_for(migration_patches, 'structure.sql') unless changes_detected?(structure_patch)
20
+ end
21
+ []
22
+ end
23
+
24
+ private
25
+
26
+ def schema_file_present?
27
+ File.exist?('db/schema.rb')
28
+ end
29
+
30
+ def structure_file_present?
31
+ File.exists?('db/structure.sql')
32
+ end
33
+
34
+ def generate_messages_for(patches, target)
35
+ patches.map do |patch|
36
+ Message.new(patch.delta.new_file[:path], nil, :warning,
37
+ "Migration file detected, but no changes in #{target}")
38
+ end
39
+ end
40
+
41
+ def detect_added_migration_file(patch)
42
+ return unless patch.delta.added?
43
+ /(.*)db[\\|\/]migrate[\\|\/](\d{14}_([_A-Za-z]+)\.rb)$/i =~ patch.delta.new_file[:path]
44
+ end
45
+
46
+ def detect_schema_file(path)
47
+ /db[\\|\/]schema.rb/i =~ path.to_s
48
+ end
49
+
50
+ def changes_detected?(patch)
51
+ patch && (patch.additions > 0 || patch.deletions > 0)
52
+ end
53
+
54
+ def detect_structure_file(path)
55
+ /db[\\|\/]structure.sql/i =~ path.to_s
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ module RailsSchemaVersion
3
+ VERSION = "0.4.0"
4
+ end
5
+ end
@@ -0,0 +1,27 @@
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_schema/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pronto-rails_schema"
8
+ spec.version = Pronto::RailsSchemaVersion::VERSION
9
+ spec.authors = ["Raimondas Valickas"]
10
+ spec.email = ["raimondas@vinted.com"]
11
+
12
+ spec.summary = %q{Pronto runner for detection of Rails schema changes.}
13
+ spec.description = %q{Detects migration files and checks for changes in
14
+ schema.rb or structure.sql files}
15
+ spec.homepage = "https://github.com/raimondasv/pronto-schema_check"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency 'pronto', '~> 0.4.0 '
24
+ spec.add_development_dependency "bundler", "~> 1.10"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.3"
27
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-rails_schema
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ platform: ruby
6
+ authors:
7
+ - Raimondas Valickas
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-01 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.4.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.4.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: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
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
+ schema.rb or structure.sql files
72
+ email:
73
+ - raimondas@vinted.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_schema.rb
86
+ - lib/pronto/rails_schema/version.rb
87
+ - pronto-rails_schema.gemspec
88
+ homepage: https://github.com/raimondasv/pronto-schema_check
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: '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.4.5
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Pronto runner for detection of Rails schema changes.
112
+ test_files: []