border-patrol 0.0.4

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.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --colour
2
+ --format progress
3
+ --drb
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rake'
4
+ gem 'rdoc'
5
+
6
+ # Specify your gem's dependencies in rediska.gemspec
7
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,124 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ border-patrol (0.0.4)
5
+ rails (~> 3.2)
6
+ timers
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.2.15)
12
+ actionpack (= 3.2.15)
13
+ mail (~> 2.5.4)
14
+ actionpack (3.2.15)
15
+ activemodel (= 3.2.15)
16
+ activesupport (= 3.2.15)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ journey (~> 1.0.4)
20
+ rack (~> 1.4.5)
21
+ rack-cache (~> 1.2)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.2.1)
24
+ activemodel (3.2.15)
25
+ activesupport (= 3.2.15)
26
+ builder (~> 3.0.0)
27
+ activerecord (3.2.15)
28
+ activemodel (= 3.2.15)
29
+ activesupport (= 3.2.15)
30
+ arel (~> 3.0.2)
31
+ tzinfo (~> 0.3.29)
32
+ activeresource (3.2.15)
33
+ activemodel (= 3.2.15)
34
+ activesupport (= 3.2.15)
35
+ activesupport (3.2.15)
36
+ i18n (~> 0.6, >= 0.6.4)
37
+ multi_json (~> 1.0)
38
+ arel (3.0.2)
39
+ builder (3.0.4)
40
+ coderay (1.0.9)
41
+ columnize (0.3.6)
42
+ debugger (1.6.2)
43
+ columnize (>= 0.3.1)
44
+ debugger-linecache (~> 1.2.0)
45
+ debugger-ruby_core_source (~> 1.2.3)
46
+ debugger-linecache (1.2.0)
47
+ debugger-ruby_core_source (1.2.3)
48
+ diff-lcs (1.2.4)
49
+ erubis (2.7.0)
50
+ hike (1.2.3)
51
+ i18n (0.6.5)
52
+ journey (1.0.4)
53
+ json (1.8.1)
54
+ mail (2.5.4)
55
+ mime-types (~> 1.16)
56
+ treetop (~> 1.4.8)
57
+ method_source (0.8.2)
58
+ mime-types (1.25)
59
+ multi_json (1.8.2)
60
+ polyglot (0.3.3)
61
+ pry (0.9.12.2)
62
+ coderay (~> 1.0.5)
63
+ method_source (~> 0.8)
64
+ slop (~> 3.4)
65
+ pry-debugger (0.2.2)
66
+ debugger (~> 1.3)
67
+ pry (~> 0.9.10)
68
+ rack (1.4.5)
69
+ rack-cache (1.2)
70
+ rack (>= 0.4)
71
+ rack-ssl (1.3.3)
72
+ rack
73
+ rack-test (0.6.2)
74
+ rack (>= 1.0)
75
+ rails (3.2.15)
76
+ actionmailer (= 3.2.15)
77
+ actionpack (= 3.2.15)
78
+ activerecord (= 3.2.15)
79
+ activeresource (= 3.2.15)
80
+ activesupport (= 3.2.15)
81
+ bundler (~> 1.0)
82
+ railties (= 3.2.15)
83
+ railties (3.2.15)
84
+ actionpack (= 3.2.15)
85
+ activesupport (= 3.2.15)
86
+ rack-ssl (~> 1.3.2)
87
+ rake (>= 0.8.7)
88
+ rdoc (~> 3.4)
89
+ thor (>= 0.14.6, < 2.0)
90
+ rake (10.1.0)
91
+ rdoc (3.12.2)
92
+ json (~> 1.4)
93
+ rspec (2.14.1)
94
+ rspec-core (~> 2.14.0)
95
+ rspec-expectations (~> 2.14.0)
96
+ rspec-mocks (~> 2.14.0)
97
+ rspec-core (2.14.7)
98
+ rspec-expectations (2.14.3)
99
+ diff-lcs (>= 1.1.3, < 2.0)
100
+ rspec-mocks (2.14.4)
101
+ slop (3.4.6)
102
+ sprockets (2.2.2)
103
+ hike (~> 1.2)
104
+ multi_json (~> 1.0)
105
+ rack (~> 1.0)
106
+ tilt (~> 1.1, != 1.3.0)
107
+ thor (0.18.1)
108
+ tilt (1.4.1)
109
+ timers (1.1.0)
110
+ treetop (1.4.15)
111
+ polyglot
112
+ polyglot (>= 0.3.1)
113
+ tzinfo (0.3.38)
114
+
115
+ PLATFORMS
116
+ ruby
117
+
118
+ DEPENDENCIES
119
+ border-patrol!
120
+ pry
121
+ pry-debugger
122
+ rake
123
+ rdoc
124
+ rspec (~> 2.14)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Leonid Beder
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # Border Patrol
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/border-patrol.png)](http://badge.fury.io/rb/border-patrol)
4
+ [![Build Status](https://travis-ci.org/lbeder/border-patrol.png)](https://travis-ci.org/lbeder/border-patrol)
5
+ [![Dependency Status](https://gemnasium.com/lbeder/border-patrol.png)](https://gemnasium.com/lbeder/border-patrol)
6
+
7
+ Prevents your Rails server from starting and running, while there are pending DB migrations.
8
+
9
+ ## Setup
10
+
11
+ If you are using bundler add border-patrol to your Gemfile:
12
+
13
+ ``` ruby
14
+ gem 'border-patrol'
15
+ ```
16
+
17
+ Then run:
18
+
19
+ ```bash
20
+ $ bundle install
21
+ ```
22
+
23
+ Otherwise install the gem:
24
+
25
+ ```bash
26
+ $ gem install border-patrol
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ In order to start using this gem, you'd need to add an initializer in your up:
32
+
33
+ ``` ruby
34
+ BorderPatrol.configure do |config|
35
+ end if defined?(BorderPatrol)
36
+ ```
37
+
38
+ ## Configuration
39
+ The following parameters are supported:
40
+
41
+ * **terminate**: whether to terminate running server, when there's a new pending migration (default: false).
42
+ * **ignore_console**: whether to perform the tests, when running in the console, or ignore it (default: true).
43
+ * **polling_period**: pending migration polling time (in seconds). Only relevant if **terminate** was set to true (default: 30 seconds).
44
+
45
+ ## License
46
+
47
+ The MIT License (MIT)
48
+
49
+ Copyright (c) 2013
50
+
51
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
52
+ this software and associated documentation files (the "Software"), to deal in
53
+ the Software without restriction, including without limitation the rights to
54
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
55
+ the Software, and to permit persons to whom the Software is furnished to do so,
56
+ subject to the following conditions:
57
+
58
+ The above copyright notice and this permission notice shall be included in all
59
+ copies or substantial portions of the Software.
60
+
61
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
62
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
63
+ FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
64
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
65
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
66
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ task :default => :spec
@@ -0,0 +1,25 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+ require 'border_patrol/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'border-patrol'
6
+ s.version = BorderPatrol::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ['Leonid Beder']
9
+ s.email = ['leonid.beder@gmail.com']
10
+ s.license = 'MIT'
11
+ s.homepage = 'https://github.com/lbeder/border-patrol'
12
+ s.summary = 'Prevents your Rails server from starting and running, while there are pending DB migrations.'
13
+ s.description = 'Prevents your Rails server from starting and running, while there are pending DB migrations.'
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ['lib']
19
+
20
+ s.add_runtime_dependency 'rails', '~> 3.2'
21
+ s.add_runtime_dependency 'timers'
22
+ s.add_development_dependency 'rspec', '~> 2.14'
23
+ s.add_development_dependency 'pry'
24
+ s.add_development_dependency 'pry-debugger'
25
+ end
@@ -0,0 +1,65 @@
1
+ require 'active_record'
2
+ require 'timers'
3
+ require 'border_patrol/configuration'
4
+
5
+ module BorderPatrol
6
+ extend self
7
+
8
+ attr_accessor :configuration
9
+
10
+ def configure
11
+ self.configuration ||= Configuration.new
12
+ yield configuration if block_given?
13
+
14
+ # Don't perform the tests in console mode, unless requested.
15
+ return if console? && configuration.ignore_console
16
+
17
+ # Perform initial test.
18
+ abort_if_pending
19
+
20
+ # Unless requested otherwise, start polling for new migrations and if new migrations were pended
21
+ # indeed - terminate the server.
22
+ start if configuration.terminate
23
+ end
24
+
25
+ at_exit do
26
+ @thread.exit if @thread
27
+ end
28
+
29
+ private
30
+ def pending_migrations
31
+ ActiveRecord::Migrator.new(:up, ActiveRecord::Migrator.migrations_paths).pending_migrations
32
+ end
33
+
34
+ def abort_if_pending
35
+ if pending_migrations.any?
36
+ puts 'Border Patrol:'
37
+ puts "You have #{pending_migrations.size} pending migrations:"
38
+ pending_migrations.each do |pending_migration|
39
+ puts ' %4d %s' % [pending_migration.version, pending_migration.name]
40
+ end
41
+ puts 'Run `rake db:migrate` to update your database then try again.'
42
+
43
+ stop
44
+ end
45
+ end
46
+
47
+ def console?
48
+ defined?(Rails::Console)
49
+ end
50
+
51
+ def start
52
+ @thread = Thread.new do
53
+ @timers = Timers.new
54
+ @timers.every(configuration.polling_period) { abort_if_pending }
55
+
56
+ loop do
57
+ @timers.wait
58
+ end
59
+ end
60
+ end
61
+
62
+ def stop
63
+ abort
64
+ end
65
+ end
@@ -0,0 +1,13 @@
1
+ module BorderPatrol
2
+ class Configuration
3
+ POLLING_PERIOD = 30
4
+
5
+ attr_accessor :terminate, :ignore_console, :polling_period
6
+
7
+ def initialize
8
+ @terminate = false
9
+ @ignore_console = true
10
+ @polling_period = 30
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module BorderPatrol
2
+ VERSION = '0.0.4'
3
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'BorderPatrol' do
4
+ end
@@ -0,0 +1,12 @@
1
+ ENV['RACK_ENV'] = 'test'
2
+
3
+ require 'rubygems'
4
+ require 'pry'
5
+ require 'pry-debugger'
6
+ require 'border-patrol'
7
+
8
+ Dir['./spec/support/*.rb'].each { |f| require f }
9
+
10
+ RSpec.configure do |config|
11
+ config.order = 'random'
12
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: border-patrol
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Leonid Beder
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-10-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.2'
30
+ - !ruby/object:Gem::Dependency
31
+ name: timers
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.14'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.14'
62
+ - !ruby/object:Gem::Dependency
63
+ name: pry
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: pry-debugger
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Prevents your Rails server from starting and running, while there are
95
+ pending DB migrations.
96
+ email:
97
+ - leonid.beder@gmail.com
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - .gitignore
103
+ - .rspec
104
+ - .travis.yml
105
+ - Gemfile
106
+ - Gemfile.lock
107
+ - LICENSE
108
+ - README.md
109
+ - Rakefile
110
+ - border_patrol.gemspec
111
+ - lib/border-patrol.rb
112
+ - lib/border_patrol/configuration.rb
113
+ - lib/border_patrol/version.rb
114
+ - spec/border_patrol_spec.rb
115
+ - spec/spec_helper.rb
116
+ homepage: https://github.com/lbeder/border-patrol
117
+ licenses:
118
+ - MIT
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 1.8.25
138
+ signing_key:
139
+ specification_version: 3
140
+ summary: Prevents your Rails server from starting and running, while there are pending
141
+ DB migrations.
142
+ test_files:
143
+ - spec/border_patrol_spec.rb
144
+ - spec/spec_helper.rb
145
+ has_rdoc: