basic_object 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.travis.yml +2 -0
- data/Gemfile +4 -0
- data/MIT-LICENCE +19 -0
- data/README.md +20 -0
- data/Rakefile +9 -0
- data/basic_object.gemspec +24 -0
- data/lib/basic_object.rb +5 -0
- data/lib/basic_object/version.rb +3 -0
- data/spec/lib/basic_object_spec.rb +32 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/.gitkeep +0 -0
- metadata +108 -0
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/MIT-LICENCE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2011 by Dmitriy Kiriyenko.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Basic Object #
|
2
|
+
|
3
|
+
[![Build Status](http://travis-ci.org/dmitriy-kiriyenko/basic_object.png)](http://travis-ci.org/dmitriy-kiriyenko/basic_object)
|
4
|
+
|
5
|
+
This is just a snippet to use Basic Object in ruby 1.8.7.
|
6
|
+
|
7
|
+
Sometimes we need to start from blank state instead of rich ruby object.
|
8
|
+
Most often this is when we implement a kind of decorator/delegator patten. Ruby 1.9.2+ provides us a special class `BasicObject`for this, but if you have to use 1.8.7 - use this gem. It provides (almost) the same `BasicObject` class, so you will use the same code for 1.8.7 and 1.9.2.
|
9
|
+
|
10
|
+
## Installation ##
|
11
|
+
|
12
|
+
In your Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'basic_object' unless defined?(BasicObject)
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage ##
|
19
|
+
|
20
|
+
Inherit from `BasicObject`. That's it.
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "basic_object/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "basic_object"
|
7
|
+
s.version = BasicObject::VERSION
|
8
|
+
s.authors = ["Dmitriy Kiriyenko"]
|
9
|
+
s.email = ["dmitriy.kiriyenko@anahoret.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Just a replacement of 1.9.2 BasicObject for 1.8.7}
|
12
|
+
s.description = %q{Just a replacement of 1.9.2 BasicObject for 1.8.7.
|
13
|
+
Use it to implement delegator or decorator pattern.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "basic_object"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_development_dependency "rspec"
|
23
|
+
s.add_development_dependency "rake"
|
24
|
+
end
|
data/lib/basic_object.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TestClass < BasicObject
|
4
|
+
end
|
5
|
+
|
6
|
+
describe TestClass do
|
7
|
+
subject {TestClass.new}
|
8
|
+
|
9
|
+
specify do
|
10
|
+
lambda { subject.object_id }.should_not raise_error
|
11
|
+
end
|
12
|
+
|
13
|
+
specify do
|
14
|
+
lambda { subject.instance_eval "1+1" }.should_not raise_error
|
15
|
+
end
|
16
|
+
|
17
|
+
specify do
|
18
|
+
lambda { subject.__send__ :object_id }.should_not raise_error
|
19
|
+
end
|
20
|
+
|
21
|
+
specify do
|
22
|
+
lambda { subject.to_s }.should raise_error
|
23
|
+
end
|
24
|
+
|
25
|
+
specify do
|
26
|
+
lambda { subject.respond_to? :to_s }.should raise_error
|
27
|
+
end
|
28
|
+
|
29
|
+
specify do
|
30
|
+
lambda { subject.methods }.should raise_error
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
Bundler.require(:default, :development)
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir[File.join(File.dirname(__FILE__), "support", "**", "*.rb")].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
# some (optional) config here
|
12
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: basic_object
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Dmitriy Kiriyenko
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-11-18 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
name: rspec
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
requirement: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
name: rake
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
requirement: *id002
|
48
|
+
description: |-
|
49
|
+
Just a replacement of 1.9.2 BasicObject for 1.8.7.
|
50
|
+
Use it to implement delegator or decorator pattern.
|
51
|
+
email:
|
52
|
+
- dmitriy.kiriyenko@anahoret.com
|
53
|
+
executables: []
|
54
|
+
|
55
|
+
extensions: []
|
56
|
+
|
57
|
+
extra_rdoc_files: []
|
58
|
+
|
59
|
+
files:
|
60
|
+
- .gitignore
|
61
|
+
- .travis.yml
|
62
|
+
- Gemfile
|
63
|
+
- MIT-LICENCE
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- basic_object.gemspec
|
67
|
+
- lib/basic_object.rb
|
68
|
+
- lib/basic_object/version.rb
|
69
|
+
- spec/lib/basic_object_spec.rb
|
70
|
+
- spec/spec_helper.rb
|
71
|
+
- spec/support/.gitkeep
|
72
|
+
homepage: ""
|
73
|
+
licenses: []
|
74
|
+
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project: basic_object
|
101
|
+
rubygems_version: 1.8.6
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: Just a replacement of 1.9.2 BasicObject for 1.8.7
|
105
|
+
test_files:
|
106
|
+
- spec/lib/basic_object_spec.rb
|
107
|
+
- spec/spec_helper.rb
|
108
|
+
- spec/support/.gitkeep
|