habject 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +40 -0
- data/init.rb +2 -0
- data/lib/habject.rb +16 -0
- metadata +68 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Julien Boyer
|
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.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
HABJECT
|
2
|
+
=======
|
3
|
+
|
4
|
+
Habject gives you object flavor syntax on ruby Hash.
|
5
|
+
|
6
|
+
|
7
|
+
Installation
|
8
|
+
------------
|
9
|
+
|
10
|
+
Install it with rubygems:
|
11
|
+
|
12
|
+
gem install habject
|
13
|
+
|
14
|
+
With bundler, add it to your `Gemfile`:
|
15
|
+
|
16
|
+
gem "habject", "~>0.1"
|
17
|
+
|
18
|
+
|
19
|
+
Usage
|
20
|
+
-----
|
21
|
+
|
22
|
+
Let's say we have this hash :
|
23
|
+
|
24
|
+
user = {'name' => 'chatgris'}
|
25
|
+
|
26
|
+
Habject gives you the possibility to call 'name' on 'user' :
|
27
|
+
|
28
|
+
user.name
|
29
|
+
# => "chatgris"
|
30
|
+
|
31
|
+
And also respond_to on user
|
32
|
+
|
33
|
+
user.respond_to? :name
|
34
|
+
# => true
|
35
|
+
|
36
|
+
|
37
|
+
Copyright
|
38
|
+
---------
|
39
|
+
|
40
|
+
See LICENSE for further details.
|
data/init.rb
ADDED
data/lib/habject.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Habject
|
3
|
+
module Hash
|
4
|
+
def method_missing(name)
|
5
|
+
return self[name.to_s] if key? name.to_s
|
6
|
+
return self[name.to_sym] if key? name.to_sym
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def respond_to?(method)
|
11
|
+
has_key?(method.to_s) || super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Hash.send(:include, Habject::Hash)
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: habject
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- chatgris
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-19 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "2.6"
|
24
|
+
type: :development
|
25
|
+
version_requirements: *id001
|
26
|
+
description: Add object type notation to ruby hash.
|
27
|
+
email: jboyer@af83.com
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- README.md
|
34
|
+
files:
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- Gemfile
|
38
|
+
- lib/habject.rb
|
39
|
+
- init.rb
|
40
|
+
homepage: http://github.com/chatgris/habject
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.8.1
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Add object type notation to ruby hash.
|
67
|
+
test_files: []
|
68
|
+
|