version_bomb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in version_bomb.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 J. Andrew Marshall <http://johnandrewmarshall.com/>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # VersionBomb
2
+
3
+ Makes creating flexible version bombs dead simple.
4
+
5
+ ## Installation
6
+
7
+ Install as usual: `gem install version_bomb` or add `gem 'version_bomb'` to your Gemfile.
8
+
9
+ ## Why
10
+
11
+ Version bombs are necessary when monkey patching libraries, whether you’re afraid of it breaking in the future, or simply want to get reminded when you upgrade to check if a backport is now included (and your monkey patch removed). VersionBomb makes it easy to create flexible version bombs, and makes it easy to find all of them in your app (just search for “VersionBomb”!).
12
+
13
+ ## Usage
14
+
15
+ First, `require 'version_bomb'`, then add a bomb:
16
+
17
+ ```ruby
18
+ VersionBomb.bomb 'Rails', Rails::VERSION::STRING, '>= 3.2.1'
19
+ ```
20
+
21
+ The requirement specified accepts anything RubyGems does—which is the same as Bundler’s scheme.
22
+
23
+ You can also optionally specify a custom message:
24
+
25
+ ```ruby
26
+ VersionBomb.bomb 'Rails', Rails::VERSION::STRING, '>= 3.2.1', 'Check if pull request #42 has been merged'
27
+ ```
28
+
29
+ ## Contributing
30
+
31
+ Contributions are welcome. Please be sure that your pull requests are atomic so they can be considered and accepted separately.
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
38
+
39
+ ## Credits & License
40
+
41
+ Copyright © 2013 J. Andrew Marshall. License is available in the LICENSE file.
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc 'Run specs'
5
+ RSpec::Core::RakeTask.new
6
+
7
+ task :default => :spec
@@ -0,0 +1,11 @@
1
+ require 'version_bomb/version'
2
+
3
+ module VersionBomb
4
+ def self.bomb! name, version, requirement, message = nil
5
+ requirement = Gem::Requirement.create requirement
6
+ message = ["#{name} version is #{version} but #{requirement} required", message].compact.join(': ')
7
+ raise Bomb.new message unless requirement.satisfied_by? version
8
+ end
9
+
10
+ class Bomb < StandardError; end
11
+ end
@@ -0,0 +1,3 @@
1
+ module VersionBomb
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,36 @@
1
+ require './lib/version_bomb'
2
+
3
+ describe VersionBomb do
4
+ describe ".bomb" do
5
+ it "blows up when the version matches the requirement" do
6
+ version = double
7
+ requirement = Gem::Requirement.new
8
+ requirement.stub(:satisfied_by?).with(version).and_return(false)
9
+
10
+ expect do
11
+ VersionBomb.bomb! double, version, requirement
12
+ end.to raise_error VersionBomb::Bomb
13
+ end
14
+
15
+ it "does nothing when the version doesn't match the requirement" do
16
+ version = double
17
+ requirement = Gem::Requirement.new
18
+ requirement.stub(:satisfied_by?).with(version).and_return(true)
19
+
20
+ expect do
21
+ VersionBomb.bomb! double, version, requirement
22
+ end.to_not raise_error VersionBomb::Bomb
23
+ end
24
+
25
+ it "accepts a custom message" do
26
+ begin
27
+ message = 'Foo bar baz!'
28
+ requirement = Gem::Requirement.new
29
+ requirement.stub(:satisfied_by?).and_return(false)
30
+ VersionBomb.bomb! double, double, requirement, message
31
+ rescue => e
32
+ e.message.should include message
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'version_bomb/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'version_bomb'
8
+ gem.version = VersionBomb::VERSION
9
+ gem.authors = ['Andrew Marshall']
10
+ gem.email = ['andrew@johnandrewmarshall.com']
11
+ gem.description = %q{Makes creating flexible version bombs dead simple.}
12
+ gem.summary = %q{Makes creating flexible version bombs dead simple.}
13
+ gem.homepage = 'http://johnandrewmarshall.com/projects/version_bomb'
14
+ gem.license = 'MIT'
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ['lib']
20
+
21
+ gem.add_development_dependency 'rake'
22
+ gem.add_development_dependency 'rspec'
23
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: version_bomb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrew Marshall
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
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
+ description: Makes creating flexible version bombs dead simple.
47
+ email:
48
+ - andrew@johnandrewmarshall.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - .rspec
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - lib/version_bomb.rb
60
+ - lib/version_bomb/version.rb
61
+ - spec/version_bomb_spec.rb
62
+ - version_bomb.gemspec
63
+ homepage: http://johnandrewmarshall.com/projects/version_bomb
64
+ licenses:
65
+ - MIT
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 1.8.24
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Makes creating flexible version bombs dead simple.
88
+ test_files:
89
+ - spec/version_bomb_spec.rb
90
+ has_rdoc: