method_struct 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +4 -2
- data/CHANGELOG +4 -0
- data/lib/method_struct/version.rb +1 -1
- data/lib/method_struct.rb +11 -1
- data/spec/method_struct_spec.rb +24 -0
- metadata +60 -81
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fd51f5aba65faaa0c6cb612239de739383ad873e
|
4
|
+
data.tar.gz: b527ef867dccbbfebf2987b6dbfaa3a7690fde24
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 24aaef918e536af629c2e6dfb6a429557fcb4e9c12a41c3758f4a3be20fd12988c104e16d4247c833a5f523afe0752a28b33c0c33ed9d3dce80f5f57b5fd9a52
|
7
|
+
data.tar.gz: 9f9c06625c1a5c9e3cd2b8af0f210223e93a1789e3fdcf37a633a90ceaad06f12d25d3c1ec0a129cdca67bc651862437597b932ea8b7b30ab6f293e300d79097
|
data/.travis.yml
CHANGED
data/CHANGELOG
ADDED
data/lib/method_struct.rb
CHANGED
@@ -30,7 +30,17 @@ module MethodStruct
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
define_method(:==) do |other|
|
34
|
+
self.class == other.class && fields.all? do |field|
|
35
|
+
send(field) == other.send(field)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
define_method(:hash) do
|
40
|
+
fields.map { |field| send(field).hash }.inject(&:^)
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
34
44
|
fields.each do |field|
|
35
45
|
attr_reader(field)
|
36
46
|
end
|
data/spec/method_struct_spec.rb
CHANGED
@@ -41,6 +41,30 @@ describe MethodStruct do
|
|
41
41
|
poker.something(argument1, argument2)
|
42
42
|
end
|
43
43
|
|
44
|
+
describe "equality" do
|
45
|
+
let(:struct) { MethodStruct.new(:a, :b) }
|
46
|
+
|
47
|
+
it "is equal for equal arguments" do
|
48
|
+
expect(struct.new(argument1, argument2) == struct.new(argument1, argument2)).to be_true
|
49
|
+
end
|
50
|
+
|
51
|
+
it "has equal hashes for equal arguments" do
|
52
|
+
expect(struct.new(1, 2).hash).to eq(struct.new(1, 2).hash)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "is unequal for unequal arguments" do
|
56
|
+
expect(struct.new(argument1, argument2) == struct.new(argument2, argument1)).to be_false
|
57
|
+
end
|
58
|
+
|
59
|
+
it "is unequal for different MethodsStruct classes" do
|
60
|
+
expect(MethodStruct.new(:a, :b).new(1, 2)).not_to eq(struct.new(1, 2))
|
61
|
+
end
|
62
|
+
|
63
|
+
it "has unequal hashes for unequal arguments (most of the time)" do
|
64
|
+
expect(struct.new("something", "something else").hash).not_to eq(struct.new("more", "stuff").hash)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
44
68
|
context "when arguments are hashes" do
|
45
69
|
let(:argument1) { { :things => true } }
|
46
70
|
let(:argument2) { { :stuff => true } }
|
metadata
CHANGED
@@ -1,78 +1,67 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: method_struct
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 5
|
10
|
-
version: 0.0.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
6
|
+
authors:
|
7
|
+
- Paweł Obrok
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: bundler
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 9
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 3
|
33
|
-
version: "1.3"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
34
20
|
type: :development
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: rake
|
38
21
|
prerelease: false
|
39
|
-
|
40
|
-
|
41
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
42
31
|
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
version: "0"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
48
34
|
type: :development
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: rspec
|
52
35
|
prerelease: false
|
53
|
-
|
54
|
-
|
55
|
-
requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
56
38
|
- - ">="
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
62
48
|
type: :development
|
63
|
-
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
64
55
|
description: Facilitates extracting methods into separate objects
|
65
|
-
email:
|
56
|
+
email:
|
66
57
|
- pawel.obrok@gmail.com
|
67
58
|
executables: []
|
68
|
-
|
69
59
|
extensions: []
|
70
|
-
|
71
60
|
extra_rdoc_files: []
|
72
|
-
|
73
|
-
|
74
|
-
- .
|
75
|
-
-
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- CHANGELOG
|
76
65
|
- Gemfile
|
77
66
|
- LICENSE.txt
|
78
67
|
- README.md
|
@@ -81,39 +70,29 @@ files:
|
|
81
70
|
- lib/method_struct/version.rb
|
82
71
|
- method_struct.gemspec
|
83
72
|
- spec/method_struct_spec.rb
|
84
|
-
has_rdoc: true
|
85
73
|
homepage: https://github.com/basecrm/method_struct
|
86
|
-
licenses:
|
74
|
+
licenses:
|
87
75
|
- MIT
|
76
|
+
metadata: {}
|
88
77
|
post_install_message:
|
89
78
|
rdoc_options: []
|
90
|
-
|
91
|
-
require_paths:
|
79
|
+
require_paths:
|
92
80
|
- lib
|
93
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
-
|
95
|
-
requirements:
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
96
83
|
- - ">="
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
version: "0"
|
102
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
-
none: false
|
104
|
-
requirements:
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
105
88
|
- - ">="
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
|
108
|
-
segments:
|
109
|
-
- 0
|
110
|
-
version: "0"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
111
91
|
requirements: []
|
112
|
-
|
113
92
|
rubyforge_project:
|
114
|
-
rubygems_version:
|
93
|
+
rubygems_version: 2.2.2
|
115
94
|
signing_key:
|
116
|
-
specification_version:
|
95
|
+
specification_version: 4
|
117
96
|
summary: Facilitates extracting methods into separate objects
|
118
|
-
test_files:
|
97
|
+
test_files:
|
119
98
|
- spec/method_struct_spec.rb
|