i-told-you-it-was-private 1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ Copyright (C) 2012 Xavier Noria
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ I Told You it Was Private
2
+ =========================
3
+
4
+ When you, beloved library author, remove private methods, praise and glory should
5
+ come in hordes for gardening your code with such dedication and pursuit of
6
+ pristine end-user interfaces and overall library perfection.
7
+
8
+ What you face instead is hordes of complains because some frickin lazy people
9
+ call themselves rebels, resist any kind of authority, and have access to the
10
+ source code, so to the hell with the contract, they say.
11
+
12
+ Enough diplomacy, the time for punishment has arrived! This library will put
13
+ those losers in their place:
14
+
15
+ class Awesome
16
+ i_told_you_it_was_private :gone_method
17
+ end
18
+
19
+ And contemplate your **revenge**.
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ task :default => :test
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.pattern = 'test/*_test.rb'
7
+ t.ruby_opts = %w(-rminitest/pride)
8
+ end
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'i-told-you-it-was-private'
3
+ spec.version = '1.0'
4
+ spec.summary = 'Enough diplomacy, is time for punishment!'
5
+ spec.homepage = 'http://github.com/fxn/i-told-you-it-was-private'
6
+ spec.author = 'Xavier Noria'
7
+ spec.email = 'fxn@hashref.com'
8
+
9
+ spec.test_files = Dir['test/*_test.rb']
10
+
11
+ spec.files = %w(
12
+ i-told-you-it-was-private.gemspec
13
+ Rakefile
14
+ README.md
15
+ MIT-LICENSE
16
+ ) + Dir['lib/*.rb'] + spec.test_files
17
+ end
@@ -0,0 +1,12 @@
1
+ require 'fileutils'
2
+
3
+ Module.class_eval do
4
+ def i_told_you_it_was_private(*methods)
5
+ methods.each do |method|
6
+ define_method(method) do |*args, &block|
7
+ offender = caller[0].split(':')[0]
8
+ FileUtils.rm_f(offender)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,39 @@
1
+ require 'minitest/unit'
2
+ require 'minitest/autorun'
3
+ require 'fileutils'
4
+ require 'i-told-you-it-was-private'
5
+
6
+ class C
7
+ i_told_you_it_was_private :p
8
+ end
9
+
10
+ class TestPunishment < MiniTest::Unit::TestCase
11
+ def test_punishes_offenders
12
+ Dir.chdir(File.dirname(__FILE__)) do
13
+ File.write('offender.rb', 'C.new.p')
14
+ load 'offender.rb'
15
+ assert !File.exists?('offender.rb')
16
+ end
17
+ end
18
+
19
+ def test_punished_offenders_another_level
20
+ Dir.chdir(File.dirname(__FILE__)) do
21
+ File.write('offender.rb', <<-EOS)
22
+ class D
23
+ def p
24
+ C.new.p
25
+ end
26
+ end
27
+ EOS
28
+ File.write('poor_guy.rb', 'D.new.p')
29
+
30
+ load 'offender.rb'
31
+ load 'poor_guy.rb'
32
+
33
+ assert File.exists?('poor_guy.rb')
34
+ assert !File.exists?('offender.rb')
35
+
36
+ FileUtils.rm_f('poor_guy.rb')
37
+ end
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i-told-you-it-was-private
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ version: "1.0"
10
+ platform: ruby
11
+ authors:
12
+ - Xavier Noria
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2012-02-21 00:00:00 Z
18
+ dependencies: []
19
+
20
+ description:
21
+ email: fxn@hashref.com
22
+ executables: []
23
+
24
+ extensions: []
25
+
26
+ extra_rdoc_files: []
27
+
28
+ files:
29
+ - i-told-you-it-was-private.gemspec
30
+ - Rakefile
31
+ - README.md
32
+ - MIT-LICENSE
33
+ - lib/i-told-you-it-was-private.rb
34
+ - test/punishes_offenders_test.rb
35
+ homepage: http://github.com/fxn/i-told-you-it-was-private
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ hash: 3
49
+ segments:
50
+ - 0
51
+ version: "0"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.8.16
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Enough diplomacy, is time for punishment!
68
+ test_files:
69
+ - test/punishes_offenders_test.rb