that_object_is_so_basic 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8be7b4a1087d0056cc8d2df54495cc2bb7cf48d6596882fc2caca31be68f50d9
4
- data.tar.gz: c7390074074b3c5731a7caf870b3de1a55d07930c6bc3f9b0bf17d4fa1ee49a0
3
+ metadata.gz: 684f1d9c560b6d9549f1625421ccfe97fb11fbe10f5fbdfdf74e6478050c1208
4
+ data.tar.gz: bb7efa230a19cf8853639d41fa36f215a83bcd140b6d25680f8b160a47482a3d
5
5
  SHA512:
6
- metadata.gz: 5868ebf2199362ea9b57c80a741930fa78f76569aad23c17facd9c96b93daa9c08ef9ff10e4db786117082003419f2171d2870e0d88e11f8e814f73e83234a1f
7
- data.tar.gz: 472d1a89f3cb15c5cf2df1fb973c43d085385216acd9f875a357cb38e1adc1c4853ba58697bba48933a3219302ed19fbe921c54cd9e9f0918307ff78372c68b8
6
+ metadata.gz: 0625d4f1db9df617b71fccdd629ee211e0677aa6c43482bfa5b5197047c02d904760f936ba845b9ba9f9f989f8d8434d6cebc82364341ae422515493d20a055e
7
+ data.tar.gz: 608677245d2af0a735cf7a23c8cf4a1052b2e9701a18a090b070c71af8830dbeb2739b96b6f0bede20195e3d4b473da1d84a26936f8e6b206d57aa6c55692050
@@ -1,3 +1,3 @@
1
1
  module TOISB
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -25,7 +25,7 @@ module TOISB; class Wrapper
25
25
  # show a nicely formated version of the class and its superclass
26
26
  # displays it in the style of a path, with the superclass as the parent directory
27
27
  def klassinfo
28
- [superklass, klass].compact.join "/"
28
+ [superklass, klass].compact.map(&:name).join "/"
29
29
  end
30
30
 
31
31
  # show a nicely formated version of the class and its superclass
@@ -44,19 +44,19 @@ module TOISB; class Wrapper
44
44
  @ancestors ||= singleton.ancestors
45
45
  end
46
46
 
47
- # Collects only the ancestors which are Classes
47
+ # Collects only the ancestors which are Classes and not Modules or singleton classes
48
48
  def ancestor_klasses
49
- @ancestor_klasses ||= ancestors.select {|a| Class === a }
49
+ @ancestor_klasses ||= ancestors.select {|a| Class === a && !a.singleton_class? }
50
50
  end
51
51
 
52
- # Returns the class of the object if it isn't already a class
52
+ # Returns the class of the object
53
53
  def klass
54
- @klass ||= singleton.superclass
54
+ @klass ||= ancestor_klasses[0]
55
55
  end
56
56
 
57
57
  # Returns the superclass of the object
58
58
  def superklass
59
- klass.superclass
59
+ @superklass ||= ancestor_klasses[1]
60
60
  end
61
61
 
62
62
  # Gets the object ID of an object
@@ -5,6 +5,9 @@ obj = ::TestObject.new
5
5
  toisb = TOISB.wrap obj
6
6
 
7
7
  bowrap = TOISB.wrap BasicObject.new
8
+ arraywrap = TOISB.wrap(Array)
9
+ anonwrap = TOISB.wrap(Class.new Class.new)
10
+ modwrap = TOISB.wrap(Module.new)
8
11
 
9
12
  spec "can inspect BasicObject subclasses" do
10
13
  expected = "BasicObject/TestObject"
@@ -85,3 +88,39 @@ spec "generates correct subklassinfo for BasicObject subclasses" do
85
88
  actual = toisb.subklassinfo
86
89
  actual == expected || actual
87
90
  end
91
+
92
+ spec "generates correct klassinfo for classes like Array" do
93
+ expected = "Module/Class"
94
+ actual = arraywrap.klassinfo
95
+ actual == expected || actual
96
+ end
97
+
98
+ spec "generates correct subklassinfo for classes like Array" do
99
+ expected = "Class < Module"
100
+ actual = arraywrap.subklassinfo
101
+ actual == expected || actual
102
+ end
103
+
104
+ spec "generates correct klassinfo for anonymous classes" do
105
+ expected = "Module/Class"
106
+ actual = anonwrap.klassinfo
107
+ actual == expected || actual
108
+ end
109
+
110
+ spec "generates correct subklassinfo for anonymous classes" do
111
+ expected = "Class < Module"
112
+ actual = anonwrap.subklassinfo
113
+ actual == expected || actual
114
+ end
115
+
116
+ spec "generates correct klassinfo for anonymous modules" do
117
+ expected = "Object/Module"
118
+ actual = modwrap.klassinfo
119
+ actual == expected || actual
120
+ end
121
+
122
+ spec "generates correct subklassinfo for anonymous modules" do
123
+ expected = "Module < Object"
124
+ actual = modwrap.subklassinfo
125
+ actual == expected || actual
126
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: that_object_is_so_basic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony M. Cook
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-19 00:00:00.000000000 Z
11
+ date: 2019-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uspec