1
0
mirror of https://github.com/danbee/inny synced 2025-03-04 08:59:10 +00:00

Compare commits

..

No commits in common. "master" and "v2.0.0" have entirely different histories.

6 changed files with 35 additions and 42 deletions

View File

@ -4,7 +4,7 @@ require "rake/testtask"
Rake::TestTask.new(:test) do |t| Rake::TestTask.new(:test) do |t|
t.libs << "test" t.libs << "test"
t.libs << "lib" t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"] t.test_files = FileList['test/**/*_test.rb']
end end
task default: :test task :default => :test

View File

@ -1,35 +1,33 @@
# coding: utf-8 # coding: utf-8
lib = File.expand_path("../lib", __FILE__) lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "inny/version" require 'inny/version'
Gem::Specification.new do |spec| Gem::Specification.new do |spec|
spec.name = "inny" spec.name = "inny"
spec.version = Inny::VERSION spec.version = Inny::VERSION
spec.authors = ["Dan Barber"] spec.authors = ["Dan Barber"]
spec.email = ["github@danbarber.me"] spec.email = ["github@danbarber.me"]
spec.summary = "Better syntax for testing whether an object is in a list" spec.summary = %q{Better syntax for testing whether an object is in a list}
spec.description = "Better syntax for testing whether an object is in a list" spec.description = %q{Better syntax for testing whether an object is in a list}
spec.homepage = "https://github.com/danbee/inny" spec.homepage = "https://github.com/danbee/inny"
spec.license = "MIT" spec.license = "MIT"
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
# delete this section to allow pushing this gem to any host. # delete this section to allow pushing this gem to any host.
if spec.respond_to?(:metadata) if spec.respond_to?(:metadata)
spec.metadata["allowed_push_host"] = "https://rubygems.org" spec.metadata['allowed_push_host'] = "https://rubygems.org"
else else
raise "RubyGems 2.0 or newer is required to protect against public gem pushes." raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
end end
spec.files = spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
`git ls-files -z`.split("\x0") spec.bindir = "exe"
.reject { |f| f.match(%r{^(test|spec|features)/}) } spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"] spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 2.4" spec.add_development_dependency "bundler", "~> 1.10"
spec.add_development_dependency "rake", "~> 13.0" spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "minitest" spec.add_development_dependency "minitest"
end end

View File

@ -2,11 +2,11 @@ require "inny/version"
module Inny module Inny
def in?(object) def in?(object)
object.include?(self) begin
rescue NoMethodError object.include?(self)
raise ArgumentError.new( rescue NoMethodError
"The parameter passed to #in? must respond to #include?" raise ArgumentError.new("The parameter passed to #in? must respond to #include?")
) end
end end
end end

View File

@ -1,3 +1,3 @@
module Inny module Inny
VERSION = "3.0.0" VERSION = "2.0.0"
end end

View File

@ -1,4 +1,4 @@
require "test_helper" require 'test_helper'
class InnyTest < Minitest::Test class InnyTest < Minitest::Test
def test_that_it_has_a_version_number def test_that_it_has_a_version_number
@ -6,24 +6,19 @@ class InnyTest < Minitest::Test
end end
def test_it_finds_integers def test_it_finds_integers
assert 8.in?([7, 8, 9]) assert 8.in?(1, 2, 3) == false
refute 8.in?([1, 2, 3]) assert 8.in?(7, 8, 9) == true
end end
def test_it_finds_strings def test_it_finds_strings
assert "Egg".in?(%w[Bacon Sausage Egg]) assert 'Egg'.in?('Apple', 'Orange', 'Banana') == false
refute "Egg".in?(%w[Apple Orange Banana]) assert 'Egg'.in?('Bacon', 'Sausage', 'Egg') == true
end
def test_it_finds_substrings
assert "bar".in?("Foobar")
refute "egg".in?("Foobar")
end end
def test_it_finds_things_in_an_array def test_it_finds_things_in_an_array
list = %w[John Jimmy Robert] list = ['John', 'Jimmy', 'Robert']
assert "Jimmy".in?(list) assert 'John Paul'.in?(*list) == false
refute "John Paul".in?(list) assert 'Jimmy'.in?(*list) == true
end end
end end

View File

@ -1,4 +1,4 @@
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require "inny" require 'inny'
require "minitest/autorun" require 'minitest/autorun'