transparent_proxy 0.0.1
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +18 -0
- data/lib/transparent_proxy.rb +50 -0
- data/spec/minitest_helper.rb +13 -0
- data/spec/transparent_proxy_spec.rb +38 -0
- data/transparent_proxy.gemspec +23 -0
- metadata +153 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bd3b5ca5adc860ad0156b3cc4b3aa2941b724d62
|
4
|
+
data.tar.gz: 1e070880da8790f4bc6410e092c6768370bfdfb0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6d1b9c41e350d71cbbea2fa3069e62a939a549b9e9fb5d5a14c95e41f866ac1b13fb1a66a046f3d03f7c4d2056e5b54f0ae425ea4f023b03575e54fc7beee6ea
|
7
|
+
data.tar.gz: 36b6c2f72356a338a27ac84cd16ffe9b674ff11e73e81eff84c74dbc8fb90f269cc0aa4541bfcf7c939becdfe07c80f4833ff47ac754f1b1978df089216f2298
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Gabriel Naiman
|
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,29 @@
|
|
1
|
+
# TransparentProxy
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'transparent_proxy'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install transparent_proxy
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
Rake::TestTask.new(:spec) do |t|
|
5
|
+
t.libs << 'spec'
|
6
|
+
t.pattern = 'spec/**/*_spec.rb'
|
7
|
+
t.verbose = false
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Run pry console'
|
11
|
+
task :console do
|
12
|
+
require 'pry'
|
13
|
+
require 'transparent_proxy'
|
14
|
+
ARGV.clear
|
15
|
+
Pry.start
|
16
|
+
end
|
17
|
+
|
18
|
+
task default: :spec
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class TransparentProxy
|
2
|
+
|
3
|
+
proxy_methods = [:class, :methods, :respond_to?]
|
4
|
+
|
5
|
+
proxy_methods.each { |m| alias_method "proxy_#{m}".to_sym, m }
|
6
|
+
|
7
|
+
safe_methods = [:__send__, :__id__, :object_id, :tap] + proxy_methods.map { |m| "proxy_#{m}".to_sym }
|
8
|
+
|
9
|
+
instance_methods.reject { |m| safe_methods.include? m }.
|
10
|
+
each { |m| undef_method m }
|
11
|
+
|
12
|
+
def inspect
|
13
|
+
__getobj__.inspect
|
14
|
+
end
|
15
|
+
|
16
|
+
def proxy_inspect
|
17
|
+
"#<#{proxy_class} @object=#{inspect}>"
|
18
|
+
end
|
19
|
+
|
20
|
+
def methods(*args)
|
21
|
+
proxy_methods(*args) | __getobj__.methods(*args)
|
22
|
+
end
|
23
|
+
|
24
|
+
def respond_to?(*args)
|
25
|
+
proxy_respond_to?(*args) || __getobj__.respond_to?(*args)
|
26
|
+
end
|
27
|
+
|
28
|
+
def proxy?
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def initialize(object)
|
35
|
+
__setobj__ object
|
36
|
+
end
|
37
|
+
|
38
|
+
def __getobj__
|
39
|
+
@object
|
40
|
+
end
|
41
|
+
|
42
|
+
def __setobj__(object)
|
43
|
+
@object = object
|
44
|
+
end
|
45
|
+
|
46
|
+
def method_missing(method, *args, &block)
|
47
|
+
__getobj__.send(method, *args, &block)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe TransparentProxy do
|
4
|
+
|
5
|
+
it 'Transparent' do
|
6
|
+
proxy = TransparentProxy.new 1
|
7
|
+
|
8
|
+
proxy.must_equal 1
|
9
|
+
(proxy + 1).must_equal 2
|
10
|
+
proxy.class.must_equal Fixnum
|
11
|
+
proxy.inspect.must_equal 1.inspect
|
12
|
+
proxy.methods.must_equal proxy.proxy_methods | 1.methods
|
13
|
+
proxy.respond_to?(:+).must_equal true
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'Proxy methods' do
|
17
|
+
proxy = TransparentProxy.new 1
|
18
|
+
|
19
|
+
proxy.proxy?.must_equal true
|
20
|
+
proxy.proxy_class.must_equal TransparentProxy
|
21
|
+
proxy.proxy_inspect.must_match /#<TransparentProxy @object=1>/
|
22
|
+
proxy.proxy_methods.must_include_all [:__send__, :__id__, :object_id, :tap]
|
23
|
+
proxy.proxy_respond_to?(:object_id).must_equal true
|
24
|
+
proxy.proxy_respond_to?(:+).must_equal false
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'Subclass' do
|
28
|
+
class NumberProxy < TransparentProxy
|
29
|
+
def to_letters
|
30
|
+
'one'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
proxy = NumberProxy.new 1
|
35
|
+
proxy.to_letters.must_equal 'one'
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'transparent_proxy'
|
3
|
+
spec.version = '0.0.1'
|
4
|
+
spec.authors = ['Gabriel Naiman']
|
5
|
+
spec.email = ['gabynaiman@gmail.com']
|
6
|
+
spec.description = 'Transparent proxy'
|
7
|
+
spec.summary = 'Transparent proxy'
|
8
|
+
spec.homepage = 'https://github.com/gabynaiman/transparent_proxy'
|
9
|
+
spec.license = 'MIT'
|
10
|
+
|
11
|
+
spec.files = `git ls-files`.split($/)
|
12
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
14
|
+
spec.require_paths = ['lib']
|
15
|
+
|
16
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
17
|
+
spec.add_development_dependency 'rake'
|
18
|
+
spec.add_development_dependency 'minitest', '~> 4.7'
|
19
|
+
spec.add_development_dependency 'minitest-great_expectations', '~> 0.0'
|
20
|
+
spec.add_development_dependency 'turn', '~> 0.9'
|
21
|
+
spec.add_development_dependency 'simplecov'
|
22
|
+
spec.add_development_dependency 'pry'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: transparent_proxy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gabriel Naiman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-26 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-great_expectations
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: turn
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.9'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.9'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Transparent proxy
|
112
|
+
email:
|
113
|
+
- gabynaiman@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- lib/transparent_proxy.rb
|
124
|
+
- spec/minitest_helper.rb
|
125
|
+
- spec/transparent_proxy_spec.rb
|
126
|
+
- transparent_proxy.gemspec
|
127
|
+
homepage: https://github.com/gabynaiman/transparent_proxy
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.1.10
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Transparent proxy
|
151
|
+
test_files:
|
152
|
+
- spec/minitest_helper.rb
|
153
|
+
- spec/transparent_proxy_spec.rb
|