symboltable 0.1 → 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/README +1 -1
- data/lib/symboltable.rb +2 -4
- data/symboltable.gemspec +1 -1
- data/test/symboltable.rb +2 -17
- metadata +2 -2
data/README
CHANGED
@@ -60,7 +60,7 @@ From a local copy:
|
|
60
60
|
|
61
61
|
== License
|
62
62
|
|
63
|
-
Copyright 2010 Michael
|
63
|
+
Copyright 2010 Michael Jackson
|
64
64
|
|
65
65
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
66
66
|
of this software and associated documentation files (the "Software"), to deal
|
data/lib/symboltable.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
# A Hash
|
2
|
-
#
|
3
|
-
# See http://github.com/mjijackson/symboltable for more information.
|
1
|
+
# A Symbols-only Hash for Ruby.
|
4
2
|
class SymbolTable < Hash
|
5
3
|
|
6
4
|
def initialize(hash=nil)
|
@@ -14,7 +12,7 @@ class SymbolTable < Hash
|
|
14
12
|
end
|
15
13
|
|
16
14
|
def key?(key)
|
17
|
-
|
15
|
+
valid_key?(key) && super(key.to_sym)
|
18
16
|
end
|
19
17
|
|
20
18
|
def [](key)
|
data/symboltable.gemspec
CHANGED
data/test/symboltable.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
$LOAD_PATH.unshift(
|
1
|
+
lib = File.dirname(File.dirname(__FILE__)) + '/lib'
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
|
4
4
|
require 'test/unit'
|
5
5
|
require 'symboltable'
|
@@ -23,9 +23,6 @@ class SymbolTableTest < Test::Unit::TestCase
|
|
23
23
|
t['b'] = 1
|
24
24
|
assert_equal(1, t[:b])
|
25
25
|
assert_equal(1, t['b'])
|
26
|
-
|
27
|
-
assert_equal([:a, :b], t.keys)
|
28
|
-
assert_equal([1, 1], t.values)
|
29
26
|
end
|
30
27
|
|
31
28
|
def test_store
|
@@ -38,9 +35,6 @@ class SymbolTableTest < Test::Unit::TestCase
|
|
38
35
|
t.store('b', 1)
|
39
36
|
assert_equal(1, t[:b])
|
40
37
|
assert_equal(1, t['b'])
|
41
|
-
|
42
|
-
assert_equal([:a, :b], t.keys)
|
43
|
-
assert_equal([1, 1], t.values)
|
44
38
|
end
|
45
39
|
|
46
40
|
def test_update
|
@@ -53,9 +47,6 @@ class SymbolTableTest < Test::Unit::TestCase
|
|
53
47
|
t.update('b' => 1)
|
54
48
|
assert_equal(1, t[:b])
|
55
49
|
assert_equal(1, t['b'])
|
56
|
-
|
57
|
-
assert_equal([:a, :b], t.keys)
|
58
|
-
assert_equal([1, 1], t.values)
|
59
50
|
end
|
60
51
|
|
61
52
|
def test_merge!
|
@@ -68,9 +59,6 @@ class SymbolTableTest < Test::Unit::TestCase
|
|
68
59
|
t.merge!('b' => 1)
|
69
60
|
assert_equal(1, t[:b])
|
70
61
|
assert_equal(1, t['b'])
|
71
|
-
|
72
|
-
assert_equal([:a, :b], t.keys)
|
73
|
-
assert_equal([1, 1], t.values)
|
74
62
|
end
|
75
63
|
|
76
64
|
def test_method_missing
|
@@ -80,9 +68,6 @@ class SymbolTableTest < Test::Unit::TestCase
|
|
80
68
|
assert_equal(1, t[:a])
|
81
69
|
assert_equal(1, t['a'])
|
82
70
|
assert_equal(1, t.a)
|
83
|
-
|
84
|
-
assert_equal([:a], t.keys)
|
85
|
-
assert_equal([1], t.values)
|
86
71
|
end
|
87
72
|
|
88
73
|
def test_nested_tables
|