proxies 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -3
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -1
- data/Gemfile.lock +12 -7
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +5 -7
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/proxies.rb +0 -1
- data/lib/proxies/proxy.rb +4 -4
- data/lib/proxies/version.rb +1 -1
- data/proxies.gemspec +25 -19
- metadata +80 -88
- data/LICENSE +0 -20
- data/README.rdoc +0 -33
- data/test/helper.rb +0 -7
- data/test/test_proxy_extend.rb +0 -33
- data/test/test_proxy_owner.rb +0 -24
- data/test/test_proxy_respond_to.rb +0 -19
- data/test/test_proxy_target.rb +0 -61
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 58fac1011043a04e7da669753a6e216373298076ac6353681ffd0ed19cee1f90
|
4
|
+
data.tar.gz: 203825b08a774364f8f752cc9a8c4d9bd760b9a27adbbc9fa7270e5b3f536e3d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 84f55fdeedacfec7fc79c30403941d2a0d8a7a83a059a19f661b1b5db4035db573c58d5958cd24597bfa0d7d9a77c36cf199c04fbb29dfb0e3148c49cae14c79
|
7
|
+
data.tar.gz: f7253fc4150c6f8a711ceffe19be7078741a3f584f3472997259866948f3fff11319abf1de6e21fd74af9b8c635bb57c94b4c1a8a67bb5fbdf08d725703bcfaa
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at kuba@jah.pl. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,18 +4,23 @@ PATH
|
|
4
4
|
proxies (0.2.1)
|
5
5
|
|
6
6
|
GEM
|
7
|
-
remote:
|
7
|
+
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
metaclass (0.0.4)
|
10
|
+
minitest (5.11.1)
|
11
|
+
mocha (1.3.0)
|
12
|
+
metaclass (~> 0.0.1)
|
13
|
+
rake (10.5.0)
|
13
14
|
|
14
15
|
PLATFORMS
|
15
16
|
ruby
|
16
17
|
|
17
18
|
DEPENDENCIES
|
18
|
-
bundler (
|
19
|
+
bundler (~> 1.16)
|
20
|
+
minitest (~> 5.0)
|
19
21
|
mocha
|
20
22
|
proxies!
|
21
|
-
|
23
|
+
rake (~> 10.0)
|
24
|
+
|
25
|
+
BUNDLED WITH
|
26
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Kuba Kuźma
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Proxies
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/proxies`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'proxies'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install proxies
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/qoobaa/proxies. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Proxies project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/qoobaa/proxies/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
1
2
|
require "rake/testtask"
|
2
|
-
require "bundler"
|
3
|
-
Bundler::GemHelper.install_tasks
|
4
|
-
Bundler.setup
|
5
3
|
|
6
|
-
Rake::TestTask.new(:test) do |
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
10
8
|
end
|
11
9
|
|
12
10
|
task :default => :test
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "proxies"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/proxies.rb
CHANGED
data/lib/proxies/proxy.rb
CHANGED
@@ -10,7 +10,7 @@ module Proxies
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
class Proxy <
|
13
|
+
class Proxy < BasicObject
|
14
14
|
instance_methods.each { |m| undef_method(m) if m.to_s !~ /^__/ }
|
15
15
|
|
16
16
|
# Creates a new proxy for target. You can pass a block (anonymous
|
@@ -28,19 +28,19 @@ module Proxies
|
|
28
28
|
# end
|
29
29
|
# end
|
30
30
|
#
|
31
|
-
# Proxy.new(lambda { my_method }, :
|
31
|
+
# Proxy.new(lambda { my_method }, extend: MyExtension) do
|
32
32
|
# def add_owner_and_target_values
|
33
33
|
# proxy_target.value + proxy_owner.value
|
34
34
|
# end
|
35
35
|
# end
|
36
36
|
#
|
37
|
-
# Proxy.new(lambda { my_method }, :
|
37
|
+
# Proxy.new(lambda { my_method }, owner: self) do
|
38
38
|
# def do_something
|
39
39
|
# ...
|
40
40
|
# end
|
41
41
|
# end
|
42
42
|
#
|
43
|
-
# Proxy.new(lambda { something }, :
|
43
|
+
# Proxy.new(lambda { something }, extend: [FirstExtension, SecondExtension])
|
44
44
|
|
45
45
|
def initialize(lazy_target, options = {}, &block)
|
46
46
|
@lazy_target = lazy_target
|
data/lib/proxies/version.rb
CHANGED
data/proxies.gemspec
CHANGED
@@ -1,24 +1,30 @@
|
|
1
|
-
#
|
2
|
-
require File.expand_path("../lib/proxies/version", __FILE__)
|
1
|
+
# coding: utf-8
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
s.platform = Gem::Platform::RUBY
|
8
|
-
s.authors = ["Jakub Kuźma"]
|
9
|
-
s.email = ["qoobaa@gmail.com"]
|
10
|
-
s.homepage = "http://rubygems.org/gems/proxies"
|
11
|
-
s.summary = "Proxies can even proxy other proxies"
|
12
|
-
s.description = "Proxies can even proxy other proxies"
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "proxies/version"
|
13
6
|
|
14
|
-
|
15
|
-
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "proxies"
|
9
|
+
spec.version = Proxies::VERSION
|
10
|
+
spec.platform = Gem::Platform::RUBY
|
11
|
+
spec.authors = ["Kuba Kuźma"]
|
12
|
+
spec.email = ["kuba@kubakuzma.com"]
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
spec.summary = "Proxies can even proxy other proxies"
|
15
|
+
spec.description = "Proxies can even proxy other proxies"
|
16
|
+
spec.homepage = "http://rubygems.org/gems/proxies"
|
17
|
+
spec.license = "MIT"
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
+
spec.add_development_dependency "mocha"
|
24
30
|
end
|
metadata
CHANGED
@@ -1,122 +1,114 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxies
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 1
|
9
|
-
version: 0.2.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
12
|
-
-
|
6
|
+
authors:
|
7
|
+
- Kuba Kuźma
|
13
8
|
autorequire:
|
14
|
-
bindir:
|
9
|
+
bindir: exe
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2018-01-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: bundler
|
22
|
-
requirement:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
segments:
|
28
|
-
- 1
|
29
|
-
- 0
|
30
|
-
- 0
|
31
|
-
version: 1.0.0
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
32
20
|
type: :development
|
33
21
|
prerelease: false
|
34
|
-
version_requirements:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
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'
|
45
34
|
type: :development
|
46
35
|
prerelease: false
|
47
|
-
version_requirements:
|
48
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.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: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
49
56
|
name: mocha
|
50
|
-
requirement:
|
51
|
-
|
52
|
-
requirements:
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
53
59
|
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
- 0
|
57
|
-
version: "0"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
58
62
|
type: :development
|
59
63
|
prerelease: false
|
60
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
61
69
|
description: Proxies can even proxy other proxies
|
62
|
-
email:
|
63
|
-
-
|
70
|
+
email:
|
71
|
+
- kuba@kubakuzma.com
|
64
72
|
executables: []
|
65
|
-
|
66
73
|
extensions: []
|
67
|
-
|
68
74
|
extra_rdoc_files: []
|
69
|
-
|
70
|
-
|
71
|
-
- .
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- CODE_OF_CONDUCT.md
|
72
79
|
- Gemfile
|
73
80
|
- Gemfile.lock
|
74
|
-
- LICENSE
|
75
|
-
- README.
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
76
83
|
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
77
86
|
- lib/proxies.rb
|
78
87
|
- lib/proxies/proxy.rb
|
79
88
|
- lib/proxies/version.rb
|
80
89
|
- proxies.gemspec
|
81
|
-
- test/helper.rb
|
82
|
-
- test/test_proxy_extend.rb
|
83
|
-
- test/test_proxy_owner.rb
|
84
|
-
- test/test_proxy_respond_to.rb
|
85
|
-
- test/test_proxy_target.rb
|
86
|
-
has_rdoc: true
|
87
90
|
homepage: http://rubygems.org/gems/proxies
|
88
|
-
licenses:
|
89
|
-
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
90
94
|
post_install_message:
|
91
95
|
rdoc_options: []
|
92
|
-
|
93
|
-
require_paths:
|
96
|
+
require_paths:
|
94
97
|
- lib
|
95
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
-
|
97
|
-
requirements:
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
98
100
|
- - ">="
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
version: "0"
|
104
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
107
105
|
- - ">="
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
|
110
|
-
- 1
|
111
|
-
- 3
|
112
|
-
- 6
|
113
|
-
version: 1.3.6
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
114
108
|
requirements: []
|
115
|
-
|
116
|
-
|
117
|
-
rubygems_version: 1.3.7
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.7.3
|
118
111
|
signing_key:
|
119
|
-
specification_version:
|
112
|
+
specification_version: 4
|
120
113
|
summary: Proxies can even proxy other proxies
|
121
114
|
test_files: []
|
122
|
-
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2010 Jakub Kuźma
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
= Proxies
|
2
|
-
|
3
|
-
Proxies can even proxy other proxies. The gem is Ruby 1.8 and 1.9 compatible (on 1.9 uses BasicObject class).
|
4
|
-
|
5
|
-
== Installation
|
6
|
-
|
7
|
-
gem install proxies
|
8
|
-
|
9
|
-
== Usage
|
10
|
-
|
11
|
-
Proxies::Proxy.new(lambda { my_method }, :owner => self) do
|
12
|
-
def extension_method
|
13
|
-
proxy_target.length * 500
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
Proxies::Proxy.new(lambda { my_method }, :owner => self, :extend => MyExtension) do
|
18
|
-
def add_owner_and_target_values
|
19
|
-
proxy_target.value + proxy_owner.value
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
Proxies::Proxy.new(lambda { target_object }) do
|
24
|
-
def extension_method
|
25
|
-
proxy_target.length * 500
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
Proxies::Proxy.new(lambda { my_method }, :owner => self, :extend => [FirstExtension, SecondExtension])
|
30
|
-
|
31
|
-
== Copyright
|
32
|
-
|
33
|
-
Copyright (c) 2010 Jakub Kuźma. See LICENSE for details.
|
data/test/helper.rb
DELETED
data/test/test_proxy_extend.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
module One
|
4
|
-
def one; 1 end
|
5
|
-
end
|
6
|
-
|
7
|
-
module Two
|
8
|
-
def two; 2 end
|
9
|
-
end
|
10
|
-
|
11
|
-
module Three
|
12
|
-
def three; 3 end
|
13
|
-
end
|
14
|
-
|
15
|
-
class TestProxyExtend < Proxies::TestCase
|
16
|
-
def setup
|
17
|
-
@target = "target"
|
18
|
-
@object = mock
|
19
|
-
@object.expects(:target_method).at_most_once.returns(@target)
|
20
|
-
end
|
21
|
-
|
22
|
-
test "extend works properly with array" do
|
23
|
-
proxy = Proxy.new(lambda { @object.target_method }, :extend => [One, Two, Three])
|
24
|
-
assert_equal 1, proxy.one
|
25
|
-
assert_equal 2, proxy.two
|
26
|
-
assert_equal 3, proxy.three
|
27
|
-
end
|
28
|
-
|
29
|
-
test "extend works with single value" do
|
30
|
-
proxy = Proxy.new(lambda { @object.target_method }, :extend => Two)
|
31
|
-
assert_equal 2, proxy.two
|
32
|
-
end
|
33
|
-
end
|
data/test/test_proxy_owner.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
class TestProxyOwner < Proxies::TestCase
|
4
|
-
def setup
|
5
|
-
@target = "target"
|
6
|
-
@object = mock
|
7
|
-
@object.expects(:target_method).at_most_once.returns(@target)
|
8
|
-
end
|
9
|
-
|
10
|
-
test "proxy_owner is defined" do
|
11
|
-
proxy = Proxy.new(lambda { @object.target_method }, :owner => @object)
|
12
|
-
assert_equal @object, proxy.proxy_owner
|
13
|
-
end
|
14
|
-
|
15
|
-
test "proxy responds to proxy_owner" do
|
16
|
-
proxy = Proxy.new(lambda { @object.target_method }, :owner => @object)
|
17
|
-
assert proxy.proxy_respond_to?(:proxy_owner)
|
18
|
-
end
|
19
|
-
|
20
|
-
test "proxy does not respond to non_existing_method" do
|
21
|
-
proxy = Proxy.new(lambda { @object.target_method }, :owner => @object)
|
22
|
-
assert_false proxy.proxy_respond_to?(:non_existing_method)
|
23
|
-
end
|
24
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
class TestProxyRespondTo < Proxies::TestCase
|
4
|
-
def setup
|
5
|
-
@target = "target"
|
6
|
-
@object = mock
|
7
|
-
@object.expects(:target_method).at_most_once.returns(@target)
|
8
|
-
end
|
9
|
-
|
10
|
-
test "proxy_respond_to? returns true on existing method" do
|
11
|
-
proxy = Proxy.new(lambda { @object.target_method }, :owner => @object)
|
12
|
-
assert proxy.proxy_respond_to?(:proxy_owner)
|
13
|
-
end
|
14
|
-
|
15
|
-
test "proxy_respond_to? returns false on non-existing method" do
|
16
|
-
proxy = Proxy.new(lambda { @object.target_method }, :owner => @object)
|
17
|
-
assert_false proxy.proxy_respond_to?(:non_existing_method)
|
18
|
-
end
|
19
|
-
end
|
data/test/test_proxy_target.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
class TestProxyTarget < Proxies::TestCase
|
4
|
-
def setup
|
5
|
-
@target = "target"
|
6
|
-
@object = mock
|
7
|
-
end
|
8
|
-
|
9
|
-
test "non-existing proxy method call is passed to the target" do
|
10
|
-
@object.expects(:target_method).once.returns(@target)
|
11
|
-
proxy = Proxy.new(lambda { @object.target_method })
|
12
|
-
assert_equal @target.length, proxy.length
|
13
|
-
end
|
14
|
-
|
15
|
-
test "proxy method returns correct result" do
|
16
|
-
@object.expects(:target_method).once.returns(@target)
|
17
|
-
proxy = Proxy.new(lambda { @object.target_method }) do
|
18
|
-
def length_plus_one
|
19
|
-
proxy_target.length + 1
|
20
|
-
end
|
21
|
-
end
|
22
|
-
assert_equal @target.length + 1, proxy.length_plus_one
|
23
|
-
end
|
24
|
-
|
25
|
-
test "object_id method call is passed to proxy target" do
|
26
|
-
@object.expects(:target_method).once.returns(@target)
|
27
|
-
proxy = Proxy.new(lambda { @object.target_method })
|
28
|
-
assert_equal @target.object_id, proxy.object_id
|
29
|
-
end
|
30
|
-
|
31
|
-
test "send method call is passed to proxy target" do
|
32
|
-
@object.expects(:target_method).once.returns(@target)
|
33
|
-
proxy = Proxy.new(lambda { @object.target_method })
|
34
|
-
assert_equal @target.send(:length), proxy.send(:length)
|
35
|
-
end
|
36
|
-
|
37
|
-
test "== method is passed to proxy_target" do
|
38
|
-
@object.expects(:target_method).once.returns(@target)
|
39
|
-
proxy = Proxy.new(lambda { @object.target_method })
|
40
|
-
assert @target == proxy
|
41
|
-
assert proxy == @target
|
42
|
-
end
|
43
|
-
|
44
|
-
test "equal? method is passed to proxy_target" do
|
45
|
-
@object.expects(:target_method).once.returns(@target)
|
46
|
-
proxy = Proxy.new(lambda { @object.target_method })
|
47
|
-
assert proxy.equal?(@target)
|
48
|
-
end
|
49
|
-
|
50
|
-
test "target method is not called if not needed" do
|
51
|
-
proxy = Proxy.new(lambda { @object.target_method }, :owner => @object)
|
52
|
-
assert_equal @object, proxy.proxy_owner
|
53
|
-
end
|
54
|
-
|
55
|
-
test "lazy target is called once even if false returned" do
|
56
|
-
proxy = Proxy.new(lambda { @object.target_method }, :owner => @object)
|
57
|
-
@object.expects(:target_method).once.returns(false)
|
58
|
-
assert_equal "false", proxy.to_s
|
59
|
-
assert_equal "false", proxy.to_s
|
60
|
-
end
|
61
|
-
end
|