introspection 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -4
- data/README.md +3 -1
- data/introspection.gemspec +6 -2
- data/lib/introspection/version.rb +1 -1
- data/test/class_snapshot_test.rb +2 -2
- data/test/instance_snapshot_test.rb +2 -2
- data/test/module_snapshot_test.rb +2 -2
- data/test/snapshot_test.rb +4 -3
- data/test/test_helper.rb +3 -3
- metadata +7 -8
- data/lib/introspection/change_detector.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afb8ef4c6bcb8be35677a3d3dddce8234ba879b6
|
4
|
+
data.tar.gz: 5421607cabb83bfba54ab7cd3b49c6746b220a07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b323e69730493ffc31498d7af9e97cf5da9e9a0c7b5a3bf0b8081ce6818a8ac24b56ea1aa6c1e94ca4131f3584ab9aea409149376b3b3e3515c4eb02ecf4cb4c
|
7
|
+
data.tar.gz: 728742a10d1a9c7aab776e0fdc9a595b50a1feb70acb1685ef36af23cf175dc166085d1e5145b2e97e0ab6faccaf3d00eb0d07d766ecb5164f40ce7328a0b5b4
|
data/.travis.yml
CHANGED
@@ -1,5 +1,16 @@
|
|
1
|
+
language: ruby
|
2
|
+
before_install:
|
3
|
+
- gem install bundler
|
4
|
+
- rvm list known
|
1
5
|
rvm:
|
2
|
-
- 1.8
|
3
|
-
- 1.9
|
4
|
-
- 2.0
|
5
|
-
- 2.1
|
6
|
+
- 1.8
|
7
|
+
- 1.9
|
8
|
+
- 2.0
|
9
|
+
- 2.1
|
10
|
+
- 2.2
|
11
|
+
- 2.3
|
12
|
+
- jruby-9.1.5.0
|
13
|
+
- rbx-3.9
|
14
|
+
matrix:
|
15
|
+
allow_failures:
|
16
|
+
- rvm: rbx-3.9
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
## Introspection [![Build Status](https://travis-ci.org/floehopper/introspection.svg?branch=master)](https://travis-ci.org/floehopper/introspection) [![Gem Version](https://badge.fury.io/rb/introspection.png)](http://badge.fury.io/rb/introspection)
|
2
|
+
|
1
3
|
Dynamic inspection of the hierarchy of method definitions on a Ruby object.
|
2
4
|
|
3
5
|
Motivations :-
|
4
6
|
|
5
7
|
* Extract code that may be generally useful from Mocha.
|
6
8
|
* Learn more about the Ruby's Object, Class & Module and the method receiver chain.
|
7
|
-
* Detect undesirable changes to classes made by other libraries.
|
9
|
+
* Detect undesirable changes to classes made by other libraries.
|
data/introspection.gemspec
CHANGED
@@ -24,8 +24,12 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.require_paths = ["lib"]
|
25
25
|
|
26
26
|
s.add_dependency "metaclass", "~> 0.0.1"
|
27
|
-
s.add_dependency "instantiator", "~> 0.0.3"
|
28
27
|
|
29
|
-
s.add_development_dependency "
|
28
|
+
s.add_development_dependency "minitest", "~> 5.0"
|
29
|
+
if RUBY_VERSION < '1.9.3'
|
30
|
+
s.add_development_dependency "rake", "~> 10.0"
|
31
|
+
else
|
32
|
+
s.add_development_dependency "rake"
|
33
|
+
end
|
30
34
|
s.add_development_dependency "blankslate"
|
31
35
|
end
|
data/test/class_snapshot_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
class ClassSnapshotTest < Test
|
3
|
+
class ClassSnapshotTest < Minitest::Test
|
4
4
|
|
5
5
|
def test_detect_class_method_on_class
|
6
6
|
for_all_method_visibilities do |visibility|
|
@@ -84,4 +84,4 @@ class ClassSnapshotTest < Test::Unit::TestCase
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
end
|
87
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
class InstanceSnapshotTest < Test
|
3
|
+
class InstanceSnapshotTest < Minitest::Test
|
4
4
|
|
5
5
|
def test_detect_instance_method_on_singleton_class
|
6
6
|
for_all_method_visibilities do |visibility|
|
@@ -119,4 +119,4 @@ class InstanceSnapshotTest < Test::Unit::TestCase
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
end
|
122
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
class ModuleSnapshotTest < Test
|
3
|
+
class ModuleSnapshotTest < Minitest::Test
|
4
4
|
|
5
5
|
def test_detect_module_method_on_module
|
6
6
|
for_all_method_visibilities do |visibility|
|
@@ -37,4 +37,4 @@ class ModuleSnapshotTest < Test::Unit::TestCase
|
|
37
37
|
assert_method_exists(mod, superdupermod, :foo, visibility)
|
38
38
|
end
|
39
39
|
end
|
40
|
-
end
|
40
|
+
end
|
data/test/snapshot_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
require "blankslate"
|
3
3
|
|
4
|
-
class SnapshotTest < Test
|
4
|
+
class SnapshotTest < Minitest::Test
|
5
5
|
|
6
6
|
include Introspection
|
7
7
|
|
@@ -49,7 +49,8 @@ class SnapshotTest < Test::Unit::TestCase
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_should_cope_with_blankslate_object
|
52
|
-
|
52
|
+
# Should not raise anything
|
53
|
+
Snapshot.new(BlankSlate.new)
|
53
54
|
end
|
54
55
|
|
55
|
-
end
|
56
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -2,7 +2,7 @@ require "rubygems"
|
|
2
2
|
require "bundler/setup"
|
3
3
|
|
4
4
|
require "introspection"
|
5
|
-
require "
|
5
|
+
require "minitest/autorun"
|
6
6
|
|
7
7
|
module Introspection
|
8
8
|
module TestHelper
|
@@ -23,8 +23,8 @@ module Introspection
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
class Test
|
26
|
+
class Minitest::Test
|
27
27
|
include Introspection::TestHelper
|
28
28
|
include Introspection::LocalAssertions
|
29
29
|
include Introspection::Assertions
|
30
|
-
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: introspection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Mead
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metaclass
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.0.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
type: :
|
33
|
+
version: '5.0'
|
34
|
+
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '5.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +82,6 @@ files:
|
|
82
82
|
- introspection.gemspec
|
83
83
|
- lib/introspection.rb
|
84
84
|
- lib/introspection/assertions.rb
|
85
|
-
- lib/introspection/change_detector.rb
|
86
85
|
- lib/introspection/core_ext.rb
|
87
86
|
- lib/introspection/core_ext/symbol.rb
|
88
87
|
- lib/introspection/method.rb
|
@@ -117,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
116
|
version: 1.3.6
|
118
117
|
requirements: []
|
119
118
|
rubyforge_project: introspection
|
120
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.5.1
|
121
120
|
signing_key:
|
122
121
|
specification_version: 4
|
123
122
|
summary: Dynamic inspection of the hierarchy of method definitions on a Ruby object.
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require "introspection"
|
2
|
-
require "instantiator"
|
3
|
-
|
4
|
-
before_class_snapshots = {}
|
5
|
-
before_instance_snapshots = {}
|
6
|
-
ObjectSpace.each_object do |object|
|
7
|
-
if Class === object
|
8
|
-
next if Instantiator.unsupported_class?(object)
|
9
|
-
object.instantiate
|
10
|
-
end
|
11
|
-
end
|
12
|
-
ObjectSpace.each_object do |object|
|
13
|
-
if Class === object
|
14
|
-
next if Instantiator.unsupported_class?(object)
|
15
|
-
before_class_snapshots[object] = Introspection::Snapshot.new(object)
|
16
|
-
before_instance_snapshots[object] = Introspection::Snapshot.new(object.instantiate)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class String
|
21
|
-
def foo
|
22
|
-
end
|
23
|
-
def self.bar
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
after_class_snapshots = {}
|
28
|
-
after_instance_snapshots = {}
|
29
|
-
ObjectSpace.each_object do |object|
|
30
|
-
if Class === object
|
31
|
-
next if Instantiator.unsupported_class?(object)
|
32
|
-
after_class_snapshots[object] = Introspection::Snapshot.new(object)
|
33
|
-
after_instance_snapshots[object] = Introspection::Snapshot.new(object.instantiate)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
before_instance_snapshots.each_key do |key|
|
38
|
-
if after_instance_snapshots[key]
|
39
|
-
if before_instance_snapshots[key].changed?(after_instance_snapshots[key])
|
40
|
-
p [key, :instance_method, before_instance_snapshots[key].diff(after_instance_snapshots[key])]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
before_class_snapshots.each_key do |key|
|
46
|
-
if after_class_snapshots[key]
|
47
|
-
if before_class_snapshots[key].changed?(after_class_snapshots[key])
|
48
|
-
p [key, :class_method, before_class_snapshots[key].diff(after_class_snapshots[key])]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# => [String, :instance_method, {:removed=>[], :added=>[String#foo (public)]}]
|
54
|
-
# => [String, :class_method, {:removed=>[], :added=>[#<Class:String>#bar (public)]}]
|