Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit e4e6a6a2bb88be1ac9983ceadc9e356a2ea3cbdf @brentsnook committed Dec 16, 2011
Showing with 84 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +3 −0 CHANGELOG.md
  3. +7 −0 Gemfile
  4. +20 −0 README.md
  5. +1 −0 Rakefile
  6. +24 −0 dive.gemspec
  7. +5 −0 lib/dive.rb
  8. +3 −0 lib/dive/version.rb
  9. +17 −0 todo.txt
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
@@ -0,0 +1,3 @@
+## 0.0.1 (DATE)
+
+ - Initial release
@@ -0,0 +1,7 @@
+source "http://rubygems.org"
+
+gemspec
+
+group :test, :development do
+ gem "rspec", "~> 2.7"
+end
@@ -0,0 +1,20 @@
+# Dive: for deep hash access
+
+Dive is a gem for accessing values within nested Hashes.
+
+Check out the specs for how it behaves.
+
+### Installation and usage
+
+ gem install dive
+
+ require 'dive'
+ foods {:sausages => {:pork_and_fennel => 'DELICIOUS'}}
+ foods['sausages[pork_and_fennel]']
+
+Or if you become squeamish at the idea of overriding Hash's [] method:
+
+ require 'dive/noninvasive'
+ foods.dive 'sausages[pork_and_fennel]'
+
+Wuss.
@@ -0,0 +1 @@
+require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "dive/version"
+
+Gem::Specification.new do |s|
+ s.name = "dive"
+ s.version = Dive::VERSION
+ s.authors = ["Brent Snook"]
+ s.email = ["brent@fuglylogic.com"]
+ s.homepage = ""
+ s.summary = %q{TODO: Write a gem summary}
+ s.description = %q{TODO: Write a gem description}
+
+ s.rubyforge_project = "dive"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ # specify any dependencies here; for example:
+ # s.add_development_dependency "rspec"
+ # s.add_runtime_dependency "rest-client"
+end
@@ -0,0 +1,5 @@
+require "dive/version"
+
+module Dive
+ # Your code goes here...
+end
@@ -0,0 +1,3 @@
+module Dive
+ VERSION = "0.0.1"
+end
@@ -0,0 +1,17 @@
+- if there is no key, treat it as a deep key
+ - snap off start of key and use it to retrieve value
+ - first look for string, if key not there look for symbol, otherwise nil
+ - if there is any key left and object responds to dive, pass on remainder of key
+ - else return nil
+- add dive method with require 'dive/noninvasive' - doesn't override []
+- allow override of Hash [] by require 'dive'
+- finish readme
+- test with 1.8.7
+- update change log
+- publish to gem repo
+
+-- LATER --
+
+- allow setting of key with hash.dive('thing[x]') = 'value'
+- add can_dive? method - checks if there is a key
+- normal override overrides has_key? also

0 comments on commit e4e6a6a

Please sign in to comment.