why_not 0.0.2 → 0.0.3

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.rdoc CHANGED
@@ -25,6 +25,9 @@ In general
25
25
  value.nil? # => true
26
26
  value.not_nil? # => false
27
27
 
28
+ [].is_not_a?(Array) # => false
29
+ [].isnt_a?(String) # => true
30
+
28
31
 
29
32
  == Dependencies
30
33
 
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ spec = Gem::Specification.new do |s|
13
13
  s.description = 'not_empty?, not_blank?, not_defined? ... why not? This is Ruby, come on.'
14
14
  s.summary = 'Comprehensive negation for all Ruby predicate methods.'
15
15
 
16
- s.add_dependency('meta_programming', '>= 0.0.3')
16
+ s.add_dependency('meta_programming', '>= 0.0.6')
17
17
 
18
18
  exclude_folders = '' # 'spec/rails/{doc,lib,log,nbproject,tmp,vendor,test}'
19
19
  exclude_files = [] # FileList['**/*.log'] + FileList[exclude_folders+'/**/*'] + FileList[exclude_folders]
@@ -49,11 +49,6 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
49
49
  rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'lib/**/*.rb')
50
50
  end
51
51
 
52
- desc 'Clean up gem build.'
53
- task :clean do
54
- FileUtils.rm_f Dir.glob('*.gem')
55
- end
56
-
57
52
  desc 'Generate a gemspec file.'
58
53
  task :gemspec do
59
54
  File.open("#{spec.name}.gemspec", 'w') do |f|
data/lib/why_not.rb CHANGED
@@ -6,6 +6,14 @@ class Object
6
6
  regular_method = $1.to_sym
7
7
  !object.__send__(regular_method, *args)
8
8
  end
9
+ define_ghost_method(/^is(nt|_not)_.+\?$/) do |object, symbol, *args|
10
+ (method = symbol.to_s) =~ /^is(nt|_not)_/
11
+ regular_method = case $1
12
+ when 'nt' then method.gsub(/^isnt_/, 'is_').to_sym
13
+ when '_not' then method.gsub(/^is_not_/, 'is_').to_sym
14
+ end
15
+ !object.__send__(regular_method, *args)
16
+ end
9
17
  end
10
18
 
11
19
 
data/spec/why_not_spec.rb CHANGED
@@ -2,6 +2,22 @@ require 'spec_helper'
2
2
  require 'lib/why_not'
3
3
 
4
4
  describe "WhyNot" do
5
+ describe "/^is(nt|_not)_.+\?$/ method" do
6
+ it "should work for isnt_a? method" do
7
+ [].isnt_a?(Array).should be_false
8
+ [].isnt_a?(String).should be_true
9
+ end
10
+ it "should work for is_not_a? method" do
11
+ [].is_not_a?(Array).should be_false
12
+ [].is_not_a?(String).should be_true
13
+ end
14
+ it "should raise error for is_not_azzz?" do
15
+ lambda { [].is_not_azzz?(Array) }.should raise_exception(NoMethodError)
16
+ end
17
+ it "should raise error for isnt_azzz?" do
18
+ lambda { [].isnt_azzz?(Array) }.should raise_exception(NoMethodError)
19
+ end
20
+ end
5
21
  describe "/^not_.*\?$/ method" do
6
22
  it "should work for empty? method on arrays" do
7
23
  array = []
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeff Patmon
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-29 00:00:00 -07:00
17
+ date: 2010-05-01 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -27,8 +27,8 @@ dependencies:
27
27
  segments:
28
28
  - 0
29
29
  - 0
30
- - 3
31
- version: 0.0.3
30
+ - 6
31
+ version: 0.0.6
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  description: not_empty?, not_blank?, not_defined? ... why not? This is Ruby, come on.