symboltable 0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -0
- data/Rakefile +9 -7
- data/lib/symboltable.rb +11 -4
- data/symboltable.gemspec +4 -4
- metadata +6 -5
data/README
CHANGED
data/Rakefile
CHANGED
@@ -3,9 +3,6 @@ require 'rake/testtask'
|
|
3
3
|
|
4
4
|
task :default => :test
|
5
5
|
|
6
|
-
CLEAN.include %w< doc >
|
7
|
-
CLOBBER.include %w< dist >
|
8
|
-
|
9
6
|
# TESTS #######################################################################
|
10
7
|
|
11
8
|
Rake::TestTask.new(:test) do |t|
|
@@ -14,12 +11,13 @@ end
|
|
14
11
|
|
15
12
|
# DOCS ########################################################################
|
16
13
|
|
17
|
-
desc "Generate API documentation
|
18
|
-
task :
|
19
|
-
|
14
|
+
desc "Generate API documentation"
|
15
|
+
task :api => FileList['lib/**/*.rb'] do |t|
|
16
|
+
output_dir = ENV['OUTPUT_DIR'] || 'api'
|
17
|
+
rm_rf output_dir
|
20
18
|
sh((<<-SH).gsub(/[\s\n]+/, ' ').strip)
|
21
19
|
hanna
|
22
|
-
--op
|
20
|
+
--op #{output_dir}
|
23
21
|
--promiscuous
|
24
22
|
--charset utf8
|
25
23
|
--fmt html
|
@@ -32,6 +30,8 @@ task :doc => FileList['lib/**/*.rb'] do |t|
|
|
32
30
|
SH
|
33
31
|
end
|
34
32
|
|
33
|
+
CLEAN.include 'api'
|
34
|
+
|
35
35
|
# PACKAGING & INSTALLATION ####################################################
|
36
36
|
|
37
37
|
if defined?(Gem)
|
@@ -65,3 +65,5 @@ if defined?(Gem)
|
|
65
65
|
sh "gem push #{package('.gem')}"
|
66
66
|
end
|
67
67
|
end
|
68
|
+
|
69
|
+
CLOBBER.include 'dist'
|
data/lib/symboltable.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# A Symbols-only Hash for Ruby.
|
2
|
+
#
|
3
|
+
# http://mjijackson.com/symboltable
|
2
4
|
class SymbolTable < Hash
|
3
|
-
|
4
5
|
def initialize(hash=nil)
|
5
6
|
super()
|
6
7
|
merge!(hash) unless hash.nil?
|
@@ -11,22 +12,27 @@ class SymbolTable < Hash
|
|
11
12
|
key.respond_to?(:to_sym)
|
12
13
|
end
|
13
14
|
|
15
|
+
# Returns +true+ if this table contains the given +key+.
|
14
16
|
def key?(key)
|
15
17
|
valid_key?(key) && super(key.to_sym)
|
16
18
|
end
|
17
19
|
|
20
|
+
# Retrieves the value of the given +key+.
|
18
21
|
def [](key)
|
19
22
|
super(key.to_sym) if valid_key?(key)
|
20
23
|
end
|
21
24
|
|
25
|
+
# Sets the value of the given +key+ to +val+.
|
22
26
|
def store(key, val)
|
23
27
|
if valid_key?(key)
|
24
28
|
val = SymbolTable.new(val) if Hash === val && !(SymbolTable === val)
|
25
29
|
super(key.to_sym, val)
|
26
30
|
end
|
27
31
|
end
|
28
|
-
alias :[]= :store
|
29
32
|
|
33
|
+
alias []= store
|
34
|
+
|
35
|
+
# Merges the values from +other_hash+ into this table.
|
30
36
|
def merge!(other_hash)
|
31
37
|
raise ArgumentError unless Hash === other_hash
|
32
38
|
other_hash.each do |k, v|
|
@@ -37,8 +43,10 @@ class SymbolTable < Hash
|
|
37
43
|
end
|
38
44
|
end
|
39
45
|
end
|
40
|
-
alias :update :merge!
|
41
46
|
|
47
|
+
alias update merge!
|
48
|
+
|
49
|
+
# Allows values to be retrieved and set using Ruby's dot method syntax.
|
42
50
|
def method_missing(sym, *args)
|
43
51
|
if sym.to_s =~ /(.+)=$/
|
44
52
|
self[$1] = args[0]
|
@@ -48,5 +56,4 @@ class SymbolTable < Hash
|
|
48
56
|
super(sym, *args)
|
49
57
|
end
|
50
58
|
end
|
51
|
-
|
52
59
|
end
|
data/symboltable.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'symboltable'
|
3
|
-
s.version = '0.
|
4
|
-
s.date = '2010-
|
3
|
+
s.version = '1.0.0'
|
4
|
+
s.date = '2010-05-12'
|
5
5
|
|
6
6
|
s.summary = 'A Symbols-only Hash for Ruby'
|
7
7
|
s.description = 'A Symbols-only Hash for Ruby'
|
8
8
|
|
9
|
-
s.author = 'Michael
|
9
|
+
s.author = 'Michael Jackson'
|
10
10
|
s.email = 'mjijackson@gmail.com'
|
11
11
|
|
12
12
|
s.require_paths = %w< lib >
|
@@ -23,5 +23,5 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.rdoc_options = %w< --line-numbers --inline-source --title SymbolTable --main SymbolTable >
|
24
24
|
s.extra_rdoc_files = %w< README >
|
25
25
|
|
26
|
-
s.homepage = 'http://
|
26
|
+
s.homepage = 'http://mjijackson.com/symboltable'
|
27
27
|
end
|
metadata
CHANGED
@@ -3,17 +3,18 @@ name: symboltable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
|
+
- 1
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
version:
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
9
10
|
platform: ruby
|
10
11
|
authors:
|
11
|
-
- Michael
|
12
|
+
- Michael Jackson
|
12
13
|
autorequire:
|
13
14
|
bindir: bin
|
14
15
|
cert_chain: []
|
15
16
|
|
16
|
-
date: 2010-
|
17
|
+
date: 2010-05-12 00:00:00 -06:00
|
17
18
|
default_executable:
|
18
19
|
dependencies:
|
19
20
|
- !ruby/object:Gem::Dependency
|
@@ -43,7 +44,7 @@ files:
|
|
43
44
|
- Rakefile
|
44
45
|
- README
|
45
46
|
has_rdoc: true
|
46
|
-
homepage: http://
|
47
|
+
homepage: http://mjijackson.com/symboltable
|
47
48
|
licenses: []
|
48
49
|
|
49
50
|
post_install_message:
|