is_same 0.0.5 → 0.0.6
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/Gemfile +2 -1
- data/lib/is_same/core_ext.rb +24 -6
- metadata +20 -10
- data/README.rdoc +0 -36
data/Gemfile
CHANGED
data/lib/is_same/core_ext.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
class BasicObject
|
2
|
-
def is_same?
|
2
|
+
def is_same? object
|
3
3
|
self == object
|
4
4
|
end
|
5
5
|
end
|
6
6
|
|
7
7
|
class Class
|
8
|
-
def is_same?
|
8
|
+
def is_same? object
|
9
9
|
case object
|
10
10
|
when String
|
11
11
|
object == self.name
|
@@ -20,7 +20,7 @@ class Class
|
|
20
20
|
end
|
21
21
|
|
22
22
|
class Numeric
|
23
|
-
def is_same?
|
23
|
+
def is_same? object
|
24
24
|
case object
|
25
25
|
when String
|
26
26
|
object == self.to_s
|
@@ -35,7 +35,7 @@ class Numeric
|
|
35
35
|
end
|
36
36
|
|
37
37
|
class Regexp
|
38
|
-
def is_same?
|
38
|
+
def is_same? object
|
39
39
|
case object
|
40
40
|
when Class
|
41
41
|
!!self.match(object.name)
|
@@ -48,7 +48,7 @@ class Regexp
|
|
48
48
|
end
|
49
49
|
|
50
50
|
class String
|
51
|
-
def is_same?
|
51
|
+
def is_same? object
|
52
52
|
case object
|
53
53
|
when Class
|
54
54
|
self == object.name
|
@@ -63,7 +63,7 @@ class String
|
|
63
63
|
end
|
64
64
|
|
65
65
|
class Symbol
|
66
|
-
def is_same?
|
66
|
+
def is_same? object
|
67
67
|
case object
|
68
68
|
when Class
|
69
69
|
self == object.name.to_sym
|
@@ -79,3 +79,21 @@ class Symbol
|
|
79
79
|
|
80
80
|
end
|
81
81
|
end
|
82
|
+
|
83
|
+
class Array
|
84
|
+
# Check if any elements of an Array is same as argument
|
85
|
+
#
|
86
|
+
# @param Object
|
87
|
+
# @return Boolean
|
88
|
+
def include_same? object
|
89
|
+
include_same = false
|
90
|
+
self.each do |value|
|
91
|
+
if value.is_same? object
|
92
|
+
include_same = true
|
93
|
+
break
|
94
|
+
end
|
95
|
+
end
|
96
|
+
include_same
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: is_same
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &22119300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *22119300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec-core
|
27
|
-
requirement: &
|
27
|
+
requirement: &22118840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *22118840
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
37
|
+
name: yard
|
38
|
+
requirement: &22118420 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,18 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *22118420
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: yard-rdoc
|
49
|
+
requirement: &22118000 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *22118000
|
47
58
|
description: To evaluate if different kind of objects have the same value or meaning,
|
48
59
|
comparing objects without the need to worry about their type. Supports regexp.
|
49
60
|
email: margus@tione.eu
|
@@ -51,7 +62,6 @@ executables: []
|
|
51
62
|
extensions: []
|
52
63
|
extra_rdoc_files: []
|
53
64
|
files:
|
54
|
-
- README.rdoc
|
55
65
|
- Gemfile
|
56
66
|
- lib/is_same/core_ext.rb
|
57
67
|
- lib/is_same.rb
|
data/README.rdoc
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
== Installation
|
2
|
-
|
3
|
-
gem install is_same
|
4
|
-
|
5
|
-
|
6
|
-
== Why?
|
7
|
-
|
8
|
-
To evaluate if different kind of objects have the same value or meaning, comparing objects without the need to worry about their type.
|
9
|
-
|
10
|
-
Supports Regexp.
|
11
|
-
|
12
|
-
|
13
|
-
== Usage
|
14
|
-
|
15
|
-
require 'is_same'
|
16
|
-
|
17
|
-
|
18
|
-
# These evaluate to False:
|
19
|
-
|
20
|
-
"String".is_same?("tring") # Same as: "String" == "tring"
|
21
|
-
Object.new.is_same?(Object.new) # Same as: Object.new == Object.new
|
22
|
-
|
23
|
-
|
24
|
-
# These evaluate to True:
|
25
|
-
|
26
|
-
:String.is_same?("String") # Same as: :String.to_s == "String"
|
27
|
-
String.is_same?(/tring/) # Same as: /tring/.match(String.name)
|
28
|
-
"String".is_same?(String) # Same as: "String" == String.name
|
29
|
-
|
30
|
-
"1".is_same?(1) # Same as: "1" == 1.to_s
|
31
|
-
0.001.is_same?("0.001") # Same as: 0.001.to_s == "0.001"
|
32
|
-
123456.is_same?(/234/) # Same as: /234/.match(123456.to_s)
|
33
|
-
|
34
|
-
|
35
|
-
More examples can be seen in Rspec tests:
|
36
|
-
* https://github.com/tione/is_same/tree/master/spec
|