casting 0.6.2 → 0.6.3

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
  SHA1:
3
- metadata.gz: 83a70a78a12f99c533069a99925cd2fff9e7f1f9
4
- data.tar.gz: eb390d0896a0e88a266bbcc6ff7a638af357523e
3
+ metadata.gz: 41fa81d5c1ff0bf53479e39ac9f655156e405bb8
4
+ data.tar.gz: 82daadbcd47eff9a0a3cf570a362b621e4e7227d
5
5
  SHA512:
6
- metadata.gz: a6169cca406169f595e33fd5fe9fd85884c7a501e4369fc0c0d665f3a6da178a98c16c7d285d06998c3ab97958fff4d8a82e740ee39e726c0e412d48e9df349e
7
- data.tar.gz: 6378fe6a71115ac772e4d5b0b1d3c24924a1133d44ce778497476ff613a2784e7d994b9b2eece23c6dca9d28b8ea8a7d1b64e200f838578f7bded9a958bbff2c
6
+ metadata.gz: 61173fac0029519e94f9554eb0c167682da7becc73aea8e53ca83323871d8640ad13e43c2dab48961183886f4cf58151c566c7efacc870a3c9dd8c18f4582ac8
7
+ data.tar.gz: be0f1e72cf3267102c238cd11291169531b76ff867e42a4396ae98659507a5b10483b1236ac5006e61acc40abfa4ad1c7ec27603264758e4d1fb007fad934cf1
@@ -0,0 +1,19 @@
1
+ module Casting
2
+ module MethodConsolidator
3
+ def methods(all=true)
4
+ (super + delegated_methods(all)).uniq
5
+ end
6
+
7
+ def public_methods(include_super=true)
8
+ (super + delegated_public_methods(include_super)).uniq
9
+ end
10
+
11
+ def protected_methods(include_super=true)
12
+ (super + delegated_protected_methods(include_super)).uniq
13
+ end
14
+
15
+ def private_methods(include_super=true)
16
+ (super + delegated_private_methods(include_super)).uniq
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Casting
2
- VERSION = '0.6.2'
2
+ VERSION = '0.6.3'
3
3
  end
@@ -0,0 +1,81 @@
1
+ require 'test_helper'
2
+
3
+ describe Casting::MethodConsolidator, '#methods' do
4
+ let(:client){
5
+ object = test_person.extend(Casting::Client, Casting::MissingMethodClient, Casting::MethodConsolidator)
6
+ object.cast_as(TestPerson::Greeter)
7
+ object
8
+ }
9
+
10
+ it "returns all instance methods including private from the object and it's delegates" do
11
+ assert_includes(client.methods(true), :psst)
12
+ end
13
+
14
+ it "returns all public instance methods from the object and it's delegates" do
15
+ refute_includes(client.methods(false), :psst)
16
+ end
17
+
18
+ it "returns all protected instance methods from the object and it's delegates" do
19
+ assert_includes(client.methods(true), :hey)
20
+ end
21
+ end
22
+
23
+ describe Casting::MethodConsolidator, '#public_methods' do
24
+ let(:client){
25
+ object = test_person.extend(Casting::Client, Casting::MissingMethodClient, Casting::MethodConsolidator)
26
+ object.cast_as(TestPerson::Greeter)
27
+ object
28
+ }
29
+
30
+ it "returns all public_methods and those from it's delegates" do
31
+ assert_includes(client.public_methods, :greet)
32
+ end
33
+
34
+ it "excludes all protected_methods and those from it's delegates" do
35
+ refute_includes(client.public_methods, :hey)
36
+ end
37
+
38
+ it "excludes all private_methods from the object and it's delegates" do
39
+ refute_includes(client.public_methods, :psst)
40
+ end
41
+ end
42
+
43
+ describe Casting::MethodConsolidator, '#protected_methods' do
44
+ let(:client){
45
+ object = test_person.extend(Casting::Client, Casting::MissingMethodClient, Casting::MethodConsolidator)
46
+ object.cast_as(TestPerson::Greeter)
47
+ object
48
+ }
49
+
50
+ it "excludes all public_methods and those from it's delegates" do
51
+ refute_includes(client.protected_methods, :greet)
52
+ end
53
+
54
+ it "returns all protected_methods and those from it's delegates" do
55
+ assert_includes(client.protected_methods, :hey)
56
+ end
57
+
58
+ it "excludes all private_methods from the object and it's delegates" do
59
+ refute_includes(client.protected_methods, :psst)
60
+ end
61
+ end
62
+
63
+ describe Casting::MethodConsolidator, '#private_methods' do
64
+ let(:client){
65
+ object = test_person.extend(Casting::Client, Casting::MissingMethodClient, Casting::MethodConsolidator)
66
+ object.cast_as(TestPerson::Greeter)
67
+ object
68
+ }
69
+
70
+ it "excludes all public_methods and those from it's delegates" do
71
+ refute_includes(client.private_methods, :greet)
72
+ end
73
+
74
+ it "excludes all protected_methods and those from it's delegates" do
75
+ refute_includes(client.private_methods, :hey)
76
+ end
77
+
78
+ it "excludes all private_methods from the object and it's delegates" do
79
+ assert_includes(client.private_methods, :psst)
80
+ end
81
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: casting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Gay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-03 00:00:00.000000000 Z
11
+ date: 2013-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcard
@@ -35,12 +35,13 @@ extensions: []
35
35
  extra_rdoc_files: []
36
36
  files:
37
37
  - lib/casting.rb
38
- - lib/casting/version.rb
38
+ - lib/casting/client.rb
39
39
  - lib/casting/delegation.rb
40
+ - lib/casting/method_consolidator.rb
40
41
  - lib/casting/missing_method_client.rb
41
42
  - lib/casting/missing_method_client_class.rb
42
43
  - lib/casting/prepared_delegation.rb
43
- - lib/casting/client.rb
44
+ - lib/casting/version.rb
44
45
  - test/test_helper.rb
45
46
  - test/casting_19_test.rb
46
47
  - test/casting_20_test.rb
@@ -48,6 +49,7 @@ files:
48
49
  - test/class_refinement_test.rb
49
50
  - test/client_test.rb
50
51
  - test/delegation_test.rb
52
+ - test/method_consolidator_test.rb
51
53
  - test/missing_method_client_test.rb
52
54
  homepage: http://github.com/saturnflyer/casting
53
55
  licenses:
@@ -81,5 +83,6 @@ test_files:
81
83
  - test/class_refinement_test.rb
82
84
  - test/client_test.rb
83
85
  - test/delegation_test.rb
86
+ - test/method_consolidator_test.rb
84
87
  - test/missing_method_client_test.rb
85
88
  has_rdoc: