at 0.1.0
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.
- data/Gemfile.lock +31 -0
- data/LICENSE +20 -0
- data/VERSION +1 -0
- data/lib/at.rb +35 -0
- data/lib/at/core_ext.rb +6 -0
- data/spec/at_spec.rb +43 -0
- data/spec/spec_helper.rb +2 -0
- metadata +77 -0
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
at (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
fuubar (0.0.6)
|
11
|
+
rspec (~> 2.0)
|
12
|
+
rspec-instafail (~> 0.1.8)
|
13
|
+
ruby-progressbar (~> 0.0.10)
|
14
|
+
rspec (2.6.0)
|
15
|
+
rspec-core (~> 2.6.0)
|
16
|
+
rspec-expectations (~> 2.6.0)
|
17
|
+
rspec-mocks (~> 2.6.0)
|
18
|
+
rspec-core (2.6.4)
|
19
|
+
rspec-expectations (2.6.0)
|
20
|
+
diff-lcs (~> 1.1.2)
|
21
|
+
rspec-instafail (0.1.8)
|
22
|
+
rspec-mocks (2.6.0)
|
23
|
+
ruby-progressbar (0.0.10)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
at!
|
30
|
+
fuubar (~> 0.0.6)
|
31
|
+
rspec (~> 2.6.0)
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Ryan Scott Lewis, c00lryguy@gmail.com
|
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/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/at.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module At
|
4
|
+
VERSION ||= Pathname.new(__FILE__).dirname.join('..', 'VERSION').read
|
5
|
+
|
6
|
+
class MethodToInstanceVariableProxy
|
7
|
+
def initialize(parent)
|
8
|
+
@parent = parent
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(meth, *args, &blk)
|
12
|
+
@parent.instance_eval do
|
13
|
+
if match = meth.to_s.match(/(.*)\=$/)
|
14
|
+
instance_variable_set("@#{match[1]}", args)
|
15
|
+
else
|
16
|
+
if block_given?
|
17
|
+
instance_variable_set("@#{meth}", args.empty? ? args : blk.call)
|
18
|
+
else
|
19
|
+
if args.empty?
|
20
|
+
instance_variable_get("@#{meth}")
|
21
|
+
else
|
22
|
+
instance_variable_set("@#{meth}", value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def at
|
31
|
+
@_method_to_instance_variable_proxy ||= MethodToInstanceVariableProxy.new(self)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'at/core_ext'
|
data/lib/at/core_ext.rb
ADDED
data/spec/at_spec.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class User
|
4
|
+
def initialize(first_name=nil, last_name=nil)
|
5
|
+
@first_name, @last_name = first_name, last_name
|
6
|
+
end
|
7
|
+
|
8
|
+
def full_name
|
9
|
+
[@first_name, @last_name].compact.join(" ")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe User do
|
14
|
+
describe "#initialize" do
|
15
|
+
subject { User.new("John", "Doe") }
|
16
|
+
|
17
|
+
it "should correctly set the instance variables on the User instance" do
|
18
|
+
subject.at.first_name.should == "John"
|
19
|
+
subject.at.last_name.should == "Doe"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#full_name" do
|
24
|
+
it "should correctly output the full name" do
|
25
|
+
subject.at.first_name = "John"
|
26
|
+
subject.at.last_name = "Doe"
|
27
|
+
|
28
|
+
subject.full_name.should == "John Doe"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#first_name" do
|
33
|
+
it "should raise a NoMethodError" do
|
34
|
+
Proc.new { subject.first_name }.should raise_error(NoMethodError)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#last_name" do
|
39
|
+
it "should raise a NoMethodError" do
|
40
|
+
Proc.new { subject.last_name }.should raise_error(NoMethodError)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: at
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ryan Scott Lewis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-05 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70224830276840 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.6.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70224830276840
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: fuubar
|
27
|
+
requirement: &70224830276240 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.0.6
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70224830276240
|
36
|
+
description: Adds a proxy to set or get instance variables on an object.
|
37
|
+
email: c00lryguy@gmail.com
|
38
|
+
executables: []
|
39
|
+
extensions: []
|
40
|
+
extra_rdoc_files:
|
41
|
+
- LICENSE
|
42
|
+
- VERSION
|
43
|
+
files:
|
44
|
+
- LICENSE
|
45
|
+
- VERSION
|
46
|
+
- Gemfile.lock
|
47
|
+
- lib/at/core_ext.rb
|
48
|
+
- lib/at.rb
|
49
|
+
- spec/at_spec.rb
|
50
|
+
- spec/spec_helper.rb
|
51
|
+
homepage: http://github.com/c00lryguy/at
|
52
|
+
licenses: []
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.8.6
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Easily access instance variables on your objects as if they were attributes.
|
75
|
+
test_files:
|
76
|
+
- spec/at_spec.rb
|
77
|
+
- spec/spec_helper.rb
|