doofenshmirtz 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/doofenshmirtz.gemspec +23 -0
- data/lib/doofenshmirtz.rb +6 -0
- data/lib/doofenshmirtz/default_reporter.rb +27 -0
- data/lib/doofenshmirtz/self_destruct.rb +43 -0
- data/lib/doofenshmirtz/version.rb +3 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a0c0ef727db6d72693393f09c8edd7a67dc3c697
|
4
|
+
data.tar.gz: 8a1ac28a89a463818bd5dadc2befccb0f30eaa04
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9669c782f5b7188f3c7e80d66fb14abe7a386600df3eda837a4037a3d07851203ef3face1267931aec4a8c40ad97b1834f52a0e5a94178cd8d5b5bd8e195fea5
|
7
|
+
data.tar.gz: 47d6ea0bbcb34ecd8b96acd22bcaf976b7406c1d149d3c7dab895c81aacbcea873cfb434af30b0f1e390744c177316aba113a14f910f977b16f3e45ec6e0aeda
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 John Bohn
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Doofenshmirtz
|
2
|
+
|
3
|
+
Let your Rails code self destruct in tests.
|
4
|
+
|
5
|
+
Set an expiration date anywhere:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
Doofenshmirtz::SelfDestruct.on(“2015-05-09”)
|
9
|
+
```
|
10
|
+
|
11
|
+
and watch it explode if the code is still around on that date. You’ll also
|
12
|
+
get warning messages in you test output to let you know that that there
|
13
|
+
are self desctruction mechanisms in the code and when they will blow up.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'doofenshmirtz'
|
21
|
+
```
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
$ bundle
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
$ gem install doofenshmirtz
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
TODO: Write usage instructions here
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
1. Fork it ( https://github.com/[my-github-username]/doofenshmirtz/fork )
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
41
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'doofenshmirtz/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "doofenshmirtz"
|
8
|
+
spec.version = Doofenshmirtz::VERSION
|
9
|
+
spec.authors = ["John Bohn"]
|
10
|
+
spec.email = ["jjbohn@gmail.com"]
|
11
|
+
spec.summary = %q{Make your Rails code self destruct}
|
12
|
+
spec.description = %q{Set a date for your legacy code to explode, and it will!}
|
13
|
+
spec.homepage = "https://www.github.com/alphasights/doofenshmirtz"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Doofenshmirtz
|
2
|
+
class DefaultReporter
|
3
|
+
include ActionView::Helpers::DateHelper
|
4
|
+
|
5
|
+
attr_accessor :mechanisms
|
6
|
+
|
7
|
+
def initialize(mechanisms)
|
8
|
+
self.mechanisms = mechanisms
|
9
|
+
end
|
10
|
+
|
11
|
+
def report
|
12
|
+
return if mechanisms.empty?
|
13
|
+
|
14
|
+
puts
|
15
|
+
puts "Pending Self Destruct Mechanisms:"
|
16
|
+
|
17
|
+
mechanisms.each do |m|
|
18
|
+
next unless m.time > Time.zone.now
|
19
|
+
|
20
|
+
puts " #{m.location}".yellow
|
21
|
+
puts " will self destruct in #{time_ago_in_words(m.time)} ".light_red
|
22
|
+
puts " because: #{m.reason}".light_red unless m.reason.blank?
|
23
|
+
puts
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Doofenshmirtz
|
2
|
+
class SelfDestructError < RuntimeError; end
|
3
|
+
|
4
|
+
class SelfDestruct
|
5
|
+
Mechanism = Struct.new(:time, :location, :reason)
|
6
|
+
@mechanisms = Set.new
|
7
|
+
|
8
|
+
def self.on(time, reason = nil)
|
9
|
+
add(time.to_time, caller_locations.first, reason)
|
10
|
+
|
11
|
+
mechanisms.each { |m| destruct(m) if Time.now > m.time }
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.add(time, location, reason)
|
15
|
+
@mechanisms.add(Mechanism.new(time, location.to_s, reason))
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.mechanisms
|
19
|
+
@mechanisms
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.destruct(mechanism)
|
23
|
+
return unless enforce?
|
24
|
+
|
25
|
+
message = "Self destructed on #{mechanism.time}"
|
26
|
+
message += " because: #{mechanism.reason}" unless mechanism.reason.blank?
|
27
|
+
fail(SelfDestructError, message)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.report(reporter = DefaultReporter)
|
31
|
+
reporter.new(mechanisms).report
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.enforce?
|
35
|
+
Rails.env.test? && ENV["DISABLE_DOOFENSHMIRTZ"] != "true"
|
36
|
+
end
|
37
|
+
|
38
|
+
private_class_method :add
|
39
|
+
private_class_method :destruct
|
40
|
+
private_class_method :mechanisms
|
41
|
+
private_class_method :enforce?
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: doofenshmirtz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Bohn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Set a date for your legacy code to explode, and it will!
|
42
|
+
email:
|
43
|
+
- jjbohn@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- doofenshmirtz.gemspec
|
54
|
+
- lib/doofenshmirtz.rb
|
55
|
+
- lib/doofenshmirtz/default_reporter.rb
|
56
|
+
- lib/doofenshmirtz/self_destruct.rb
|
57
|
+
- lib/doofenshmirtz/version.rb
|
58
|
+
homepage: https://www.github.com/alphasights/doofenshmirtz
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.2.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Make your Rails code self destruct
|
82
|
+
test_files: []
|
83
|
+
has_rdoc:
|