unfickle 0.0.1 → 0.0.2
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/.gitignore +1 -0
- data/README +1 -0
- data/lib/unfickle.rb +3 -0
- data/lib/unfickle/unfickle.rb +4 -17
- data/lib/unfickle/version.rb +1 -1
- data/spec/lib/unfickle/unfickle_spec.rb +3 -42
- metadata +3 -2
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg
|
data/README
CHANGED
data/lib/unfickle.rb
CHANGED
data/lib/unfickle/unfickle.rb
CHANGED
@@ -1,28 +1,15 @@
|
|
1
1
|
module Unfickle
|
2
|
-
|
2
|
+
extend Forwardable
|
3
|
+
def set_const(key,value)
|
3
4
|
@hash ||= {}
|
4
|
-
@hash[key]=value
|
5
|
+
@hash[key.upcase.to_sym]=value
|
5
6
|
end
|
6
7
|
|
7
8
|
def const_missing(key)
|
8
9
|
@hash[key]
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
-
@hash.each {|key,value| yield(key,value)}
|
13
|
-
end
|
14
|
-
|
15
|
-
def values
|
16
|
-
@hash.values || []
|
17
|
-
end
|
18
|
-
|
19
|
-
def keys
|
20
|
-
@hash.keys || []
|
21
|
-
end
|
22
|
-
|
23
|
-
def [](key)
|
24
|
-
@hash[key]
|
25
|
-
end
|
12
|
+
def_delegators :@hash, :each, :values, :keys, :[]
|
26
13
|
|
27
14
|
def clear
|
28
15
|
@hash = {}
|
data/lib/unfickle/version.rb
CHANGED
@@ -3,21 +3,19 @@ require 'spec_helper'
|
|
3
3
|
describe Unfickle do
|
4
4
|
subject do
|
5
5
|
class TestClass
|
6
|
-
include Unfickle
|
7
|
-
extend Unfickle
|
8
6
|
end
|
9
7
|
TestClass
|
10
8
|
end
|
11
9
|
|
12
10
|
before(:each) do
|
13
11
|
subject.clear
|
14
|
-
subject.
|
12
|
+
subject.set_const(:BLAH, 'value')
|
15
13
|
end
|
16
14
|
|
17
15
|
|
18
|
-
describe '.
|
16
|
+
describe '.set_const' do
|
19
17
|
it "has a blah 'constant'" do
|
20
|
-
subject.
|
18
|
+
subject.set_const(:YAHOO, 'sucks')
|
21
19
|
subject::YAHOO.should == 'sucks'
|
22
20
|
end
|
23
21
|
end
|
@@ -28,43 +26,6 @@ describe Unfickle do
|
|
28
26
|
end
|
29
27
|
end
|
30
28
|
|
31
|
-
describe '.each' do
|
32
|
-
it 'iterates over all the keys' do
|
33
|
-
subject.each do |key, value|
|
34
|
-
key.should == :BLAH
|
35
|
-
value.should == 'value'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe 'values' do
|
41
|
-
context 'with values' do
|
42
|
-
its(:values) { should == ['value'] }
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'without values' do
|
46
|
-
before(:each) { subject.clear }
|
47
|
-
its(:values) { should == [] }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'keys' do
|
52
|
-
context 'with keys' do
|
53
|
-
its(:keys) { should == [:BLAH] }
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'without keys' do
|
57
|
-
before(:each) { subject.clear }
|
58
|
-
its(:keys) { should == [] }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe '[]' do
|
63
|
-
it 'response like an array' do
|
64
|
-
subject[:BLAH].should == 'value'
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
29
|
describe 'clear' do
|
69
30
|
it 'clears the constants' do
|
70
31
|
subject.clear
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: unfickle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tracey Eubanks
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-17 00:00:00 -06:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
|
48
48
|
files:
|
49
|
+
- .gitignore
|
49
50
|
- Gemfile
|
50
51
|
- Gemfile.lock
|
51
52
|
- README
|