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.
@@ -0,0 +1 @@
1
+ pkg
data/README CHANGED
@@ -1,6 +1,7 @@
1
1
  This allows for better constant management. Use it like so:
2
2
  class MyClass
3
3
  include Unfickle
4
+ extend Unfickle
4
5
 
5
6
  self.add_item(:SOMECONST, 1)
6
7
  end
@@ -1,4 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
3
 
4
+ require 'forwardable'
4
5
  require 'unfickle/unfickle'
6
+
7
+ Object.extend(Unfickle)
@@ -1,28 +1,15 @@
1
1
  module Unfickle
2
- def add_item(key,value)
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
- def each
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 = {}
@@ -1,3 +1,3 @@
1
1
  module Unfickle
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -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.add_item(:BLAH, 'value')
12
+ subject.set_const(:BLAH, 'value')
15
13
  end
16
14
 
17
15
 
18
- describe '.add_item' do
16
+ describe '.set_const' do
19
17
  it "has a blah 'constant'" do
20
- subject.add_item(:YAHOO, 'sucks')
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.1
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-16 00:00:00 -06:00
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