symboltable 0.2 → 1.0.0

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 CHANGED
@@ -56,6 +56,7 @@ Using RubyGems:
56
56
  From a local copy:
57
57
 
58
58
  $ git clone git://github.com/mjijackson/symboltable.git
59
+ $ cd symboltable
59
60
  $ rake package && sudo rake install
60
61
 
61
62
  == License
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 (in doc)"
18
- task :doc => FileList['lib/**/*.rb'] do |t|
19
- rm_rf 'doc'
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 doc
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.2'
4
- s.date = '2010-04-08'
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 J. I. Jackson'
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://github.com/mjijackson/symboltable'
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
- - 2
8
- version: "0.2"
8
+ - 0
9
+ version: 1.0.0
9
10
  platform: ruby
10
11
  authors:
11
- - Michael J. I. Jackson
12
+ - Michael Jackson
12
13
  autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
16
 
16
- date: 2010-04-08 00:00:00 -06:00
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://github.com/mjijackson/symboltable
47
+ homepage: http://mjijackson.com/symboltable
47
48
  licenses: []
48
49
 
49
50
  post_install_message: