crazy_pills 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +52 -2
- data/lib/crazy_pills.rb +8 -4
- data/lib/crazy_pills/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6282beffaf0e17f59175d1d9b0cdbacc335f72d
|
4
|
+
data.tar.gz: 5781036a182ca5d74bcb822537d48f56e0667a0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29f6aa4a4f086512ed4965694f646c17d22b095bb62641d5b6c5106e17c7143dd4de877af98dc622503997a2e51b377fdbf093e2efd585425942e05e4d395fe4
|
7
|
+
data.tar.gz: 57f1e3eb39760c433b5f8eadcdb476e02e654a5dd4b07806d63f7ad6a17bf591b8bf70afbe3c79d224c70fe4c7c4f68b9ec1a8b98850ea9a2288abd504a0e7b8
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# CrazyPills
|
2
2
|
|
3
|
-
|
3
|
+
You should never use CrazyPills in your application.
|
4
|
+
|
5
|
+
By requiring CrazyPills you are randomly removing and/or nil-ifying
|
6
|
+
a random method of one of many of the core classes of the Ruby
|
7
|
+
interpreter. It is really a bad idea to use it.
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
@@ -18,7 +22,53 @@ Or install it yourself as:
|
|
18
22
|
|
19
23
|
## Usage
|
20
24
|
|
21
|
-
|
25
|
+
If you want to know which method got "crazy-fied" then just ask crazy pills
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'crazy_pills'
|
29
|
+
|
30
|
+
CrazyPills.explain
|
31
|
+
# Made Object#is_a? just return nil
|
32
|
+
```
|
33
|
+
|
34
|
+
If you want to make it get realllllll crazy, just up the level of crazy
|
35
|
+
|
36
|
+
HOW_CRAZY=10 bundle exec irb
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
require 'crazy_pills'
|
40
|
+
|
41
|
+
CrazyPills.explain
|
42
|
+
# Made Float#to_enum just return nil
|
43
|
+
# Made String#capitalize just return nil
|
44
|
+
# Made Exception#untrust just return nil
|
45
|
+
# Aliased Float#coerce to Float#%
|
46
|
+
# Aliased Exception#define_singleton_method to Exception#method
|
47
|
+
# Aliased Hash#! to Hash#equal?
|
48
|
+
# Aliased Object#<=> to Object#nil?
|
49
|
+
# Aliased Object#taint to Object#gem
|
50
|
+
# Aliased Exception#public_method to Exception#class
|
51
|
+
# Aliased Exception#!= to Exception#protected_methods
|
52
|
+
```
|
53
|
+
|
54
|
+
And if you need to debug, then just pass a DEBUG flag
|
55
|
+
|
56
|
+
DEBUG=1 HOW_CRAZY=10 bundle exec irb
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
require 'crazy_pills'
|
60
|
+
|
61
|
+
# Nil-ify Exception#trust
|
62
|
+
# Aliased ["File#to_a", "File#grep"]
|
63
|
+
# Aliased ["String#chop!", "String#object_id"]
|
64
|
+
# Aliased ["Numeric#__send__", "Numeric#remove_instance_variable"]
|
65
|
+
# Nil-ify Hash#!
|
66
|
+
# Nil-ify File#methods
|
67
|
+
# Nil-ify Float#gem
|
68
|
+
# Nil-ify Object#define_singleton_method
|
69
|
+
# Nil-ify Numeric#zero?
|
70
|
+
# Nil-ify Exception#__id__
|
71
|
+
```
|
22
72
|
|
23
73
|
## Contributing
|
24
74
|
|
data/lib/crazy_pills.rb
CHANGED
@@ -23,6 +23,7 @@ module CrazyPills
|
|
23
23
|
def self.aliased(*args)
|
24
24
|
@aliased ||= []
|
25
25
|
@aliased.concat(args) if args
|
26
|
+
puts "Aliased #{args}" if ENV['DEBUG']
|
26
27
|
@aliased
|
27
28
|
end
|
28
29
|
|
@@ -45,11 +46,13 @@ module CrazyPills
|
|
45
46
|
|
46
47
|
method_to_crazy = class_to_crazy.instance_methods.sample
|
47
48
|
|
48
|
-
if
|
49
|
+
if [true, false].sample
|
49
50
|
self.made_nil("#{class_to_crazy}##{method_to_crazy}")
|
50
51
|
|
51
|
-
class_to_crazy.
|
52
|
-
|
52
|
+
class_to_crazy.class_eval do
|
53
|
+
define_method(method_to_crazy) do
|
54
|
+
nil
|
55
|
+
end
|
53
56
|
end
|
54
57
|
else
|
55
58
|
alias_to = class_to_crazy.instance_methods.sample
|
@@ -64,10 +67,11 @@ module CrazyPills
|
|
64
67
|
def self.made_nil(name = nil)
|
65
68
|
@made_nil ||= []
|
66
69
|
@made_nil << name if name
|
70
|
+
puts "Nil-ify #{name}" if ENV['DEBUG']
|
67
71
|
@made_nil
|
68
72
|
end
|
69
73
|
|
70
|
-
(ENV['HOW_CRAZY'] || ENV['CRAZY'] || 1).times do
|
74
|
+
(ENV['HOW_CRAZY'] || ENV['CRAZY'] || 1).to_i.times do
|
71
75
|
lets_get_crazy!(*THINGS_TO_CRAZY)
|
72
76
|
end
|
73
77
|
end
|
data/lib/crazy_pills/version.rb
CHANGED