wrappable 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'minitest'
6
+ gem 'wrong'
7
+ gem 'rr'
8
+ gem 'rake'
@@ -0,0 +1,58 @@
1
+ module Wrappable
2
+ def self.included(base)
3
+ base.class_eval do
4
+ extend ClassMethods
5
+ end
6
+ end
7
+
8
+ module ClassMethods
9
+ def wrap(o)
10
+ case o
11
+ when self
12
+ o
13
+ else
14
+ new(o)
15
+ end
16
+ end
17
+
18
+ alias [] wrap
19
+
20
+ def wraps(m)
21
+ alias_method m, :wrapped
22
+ end
23
+
24
+ # by default, delegate to :@wrapped, so you don't have
25
+ # to pass the :to => ... option
26
+ def delegate(*args)
27
+ args = args.dup
28
+
29
+ if args.last.is_a? Hash
30
+ opts = args.pop
31
+ else
32
+ opts = {}
33
+ end
34
+
35
+ opts[:to] ||= :wrapped
36
+
37
+ super(*args << opts)
38
+ end
39
+ end
40
+
41
+ attr_reader :wrapped
42
+ def initialize(wrapped, opts={})
43
+ @wrapped = wrapped
44
+ set!(opts)
45
+ end
46
+
47
+ def set!(opts={})
48
+ opts.each do |k, v|
49
+ send("#{k}=", v)
50
+ end
51
+
52
+ self
53
+ end
54
+
55
+ class Base
56
+ include Wrappable
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ module Wrappable
2
+ def self.version
3
+ '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ require './lib/wrappable/version'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "wrappable"
5
+ s.version = Wrappable.version
6
+ s.authors = ["Jay Adkisson"]
7
+ s.email = ["jay@goodguide.com"]
8
+ s.summary = "Wrap all of the things"
9
+ s.description = "a generic module that provides an idempotent wrapper."
10
+ s.homepage = "http://github.com/jayferd/wrappable"
11
+ s.rubyforge_project = "wrappable"
12
+ s.files = Dir['Gemfile', 'wrappable.gemspec', 'lib/**/*.rb']
13
+
14
+ # no dependencies
15
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wrappable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jay Adkisson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-08 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: a generic module that provides an idempotent wrapper.
15
+ email:
16
+ - jay@goodguide.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - Gemfile
22
+ - wrappable.gemspec
23
+ - lib/wrappable/version.rb
24
+ - lib/wrappable.rb
25
+ homepage: http://github.com/jayferd/wrappable
26
+ licenses: []
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ none: false
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ segments:
38
+ - 0
39
+ hash: 1646359388263042767
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ segments:
47
+ - 0
48
+ hash: 1646359388263042767
49
+ requirements: []
50
+ rubyforge_project: wrappable
51
+ rubygems_version: 1.8.10
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: Wrap all of the things
55
+ test_files: []