Permalink
Browse files

update gem structure

  • Loading branch information...
1 parent 9cd2fe9 commit 553bbe04aff97b0950481dc9d6882f707aa6012e Josh Hull committed Mar 10, 2011
Showing with 69 additions and 138 deletions.
  1. +0 −5 .document
  2. +3 −21 .gitignore
  3. +4 −0 Gemfile
  4. +0 −20 LICENSE
  5. +0 −14 README.rdoc
  6. +10 −43 Rakefile
  7. +0 −1 VERSION
  8. +11 −8 lib/respond_to.rb
  9. +3 −0 lib/respond_to/version.rb
  10. +21 −0 respond_to.gemspec
  11. +0 −16 spec/respond_to_spec.rb
  12. +0 −1 spec/spec.opts
  13. +0 −9 spec/spec_helper.rb
  14. +17 −0 test/test_respond_to.rb
View
@@ -1,5 +0,0 @@
-README.rdoc
-lib/**/*.rb
-bin/*
-features/**/*.feature
-LICENSE
View
@@ -1,21 +1,3 @@
-## MAC OS
-.DS_Store
-
-## TEXTMATE
-*.tmproj
-tmtags
-
-## EMACS
-*~
-\#*
-.\#*
-
-## VIM
-*.swp
-
-## PROJECT::GENERAL
-coverage
-rdoc
-pkg
-
-## PROJECT::SPECIFIC
+pkg/*
+*.gem
+.bundle
View
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in respond_to.gemspec
+gemspec
View
20 LICENSE
@@ -1,20 +0,0 @@
-Copyright (c) 2009 Joshua Hull
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,14 +0,0 @@
-= respond_to
-
-Easy way to make respond_to? matchers for case statements.
-
-== Usage
-
- require 'respond_to'
- str = 'my string'
- case str
- when RespondTo(:<<)
- str << 'new data'
- else
- raise
- end
View
@@ -1,44 +1,11 @@
-require 'rubygems'
-require 'rake'
-
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gem|
- gem.name = "respond_to"
- gem.description = gem.summary = %Q{Easy way to make respond_to? matchers for case statements.}
- gem.email = "joshbuddy@gmail.com"
- gem.homepage = "http://github.com/joshbuddy/respond_to"
- gem.authors = ["Joshua Hull"]
- gem.add_development_dependency "rspec", ">= 1.2.9"
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
- end
- Jeweler::GemcutterTasks.new
-rescue LoadError
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
-end
-
-require 'spec/rake/spectask'
-Spec::Rake::SpecTask.new(:spec) do |spec|
- spec.libs << 'lib' << 'spec'
- spec.spec_files = FileList['spec/**/*_spec.rb']
-end
-
-Spec::Rake::SpecTask.new(:rcov) do |spec|
- spec.libs << 'lib' << 'spec'
- spec.pattern = 'spec/**/*_spec.rb'
- spec.rcov = true
-end
-
-task :spec => :check_dependencies
-
-task :default => :spec
-
-require 'rake/rdoctask'
-Rake::RDocTask.new do |rdoc|
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
-
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = "respond_to #{version}"
- rdoc.rdoc_files.include('README*')
- rdoc.rdoc_files.include('lib/**/*.rb')
+require 'bundler'
+Bundler::GemHelper.install_tasks
+
+desc "Run tests"
+task :test do
+ $: << 'lib'
+ require 'respond_to'
+ require 'minitest/autorun'
+ require 'phocus'
+ Dir['test/test_*.rb'].each { |test| require test }
end
View
@@ -1 +0,0 @@
-0.0.1
View
@@ -1,24 +1,27 @@
def RespondTo(method)
-
RespondTo.create(method)
-
end
class RespondTo
-
- RespondTos = {}
+ Matchers = {}
def self.create(method)
- RespondTos[method] ||= new(method)
+ Matchers[method] ||= new(method)
end
-
+
attr_reader :method
-
+
def initialize(method)
@method = method
end
-
+
def ===(o)
o.respond_to?(method)
end
+end
+
+class Symbol
+ def ~@
+ RespondTo(self)
+ end
end
@@ -0,0 +1,3 @@
+class RespondTo
+ VERSION = "0.0.1"
+end
View
@@ -0,0 +1,21 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "respond_to/version"
+
+Gem::Specification.new do |s|
+ s.name = "respond_to"
+ s.version = RespondTo::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["TODO: Write your name"]
+ s.email = ["TODO: Write your email address"]
+ s.homepage = ""
+ s.summary = %q{TODO: Write a gem summary}
+ s.description = %q{TODO: Write a gem description}
+
+ s.rubyforge_project = "respond_to"
+
+ 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"]
+end
View
@@ -1,16 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-
-describe "RespondTo" do
- it "should return true for a method that exists through ===" do
- (RespondTo(:<<) === "testing").should be_true
- end
-
- it "should return false for a method that doesn't exist through ===" do
- (RespondTo(:crazytown) === ('testing')).should be_false
- end
-
- it "should only make one object for each method" do
- RespondTo(:crazytown).equal?(RespondTo(:crazytown)).should be_true
- end
-
-end
View
@@ -1 +0,0 @@
---color
View
@@ -1,9 +0,0 @@
-$LOAD_PATH.unshift(File.dirname(__FILE__))
-$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
-require 'respond_to'
-require 'spec'
-require 'spec/autorun'
-
-Spec::Runner.configure do |config|
-
-end
View
@@ -0,0 +1,17 @@
+class TestRespondTo < MiniTest::Unit::TestCase
+ def test_triple_eq
+ assert (RespondTo(:<<) === "testing")
+ end
+
+ def test_triple_eq_with_false
+ assert !(RespondTo(:crazytown) === ('testing'))
+ end
+
+ def test_only_one_object
+ assert RespondTo(:crazytown).equal?(RespondTo(:crazytown))
+ end
+
+ def test_with_symbol_tilde
+ assert (~:<< === "testing")
+ end
+end

0 comments on commit 553bbe0

Please sign in to comment.