strict_struct 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/strict_struct.rb +3 -5
- data/lib/strict_struct/version.rb +1 -1
- data/spec/strict_struct_spec.rb +7 -0
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3116577a84563531a4392bcce1b8ac20fe4aa0b
|
4
|
+
data.tar.gz: 455f97ea2ff70b305cd0128574f65984c6cef07a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c526f693fd588d2276ed72ba0502a03bd88f96bbde7970dc8c6f49332099065690c9c27afea9a54cd9e6b6ffeb1c63eb6cd63ea6f39349bbe89d01b74d3089a2
|
7
|
+
data.tar.gz: b266b021735623a0f17ad29f43a64b8e8efe6a90d3494e46a8fbebc6ac4dd8d983cff165d760d618a5c695e8ad6de9f4d32c0f9153b8021e3af37a5908612b2d
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# StrictStruct [![Build Status](https://travis-ci.org/markijbema/strict_struct.png)](https://travis-ci.org/markijbema/strict_struct) [![Code Climate](https://codeclimate.com/github/markijbema/strict_struct.png)](https://codeclimate.com/github/markijbema/strict_struct) [![Gem Version](https://badge.fury.io/rb/strict_struct.png)](http://badge.fury.io/rb/strict_struct) [![
|
1
|
+
# StrictStruct [![Build Status](https://travis-ci.org/markijbema/strict_struct.png)](https://travis-ci.org/markijbema/strict_struct) [![Code Climate](https://codeclimate.com/github/markijbema/strict_struct.png)](https://codeclimate.com/github/markijbema/strict_struct) [![Gem Version](https://badge.fury.io/rb/strict_struct.png)](http://badge.fury.io/rb/strict_struct) [![Dependency Status](https://gemnasium.com/markijbema/strict_struct.png)](https://gemnasium.com/markijbema/strict_struct)
|
2
2
|
|
3
3
|
This gems aims to provide a modern version of Struct.
|
4
4
|
While Struct is a nice easy way to create a light-weight
|
data/lib/strict_struct.rb
CHANGED
@@ -21,10 +21,8 @@ module StrictStruct
|
|
21
21
|
|
22
22
|
def self.new(*attributes, &block)
|
23
23
|
klass = Class.new do
|
24
|
-
@@attributes = attributes
|
25
|
-
|
26
24
|
define_method :initialize do |hash={}|
|
27
|
-
Helper.validate_arguments(hash.keys,
|
25
|
+
Helper.validate_arguments(hash.keys, attributes)
|
28
26
|
@_strict_struct_hash = Hash[hash.to_a].freeze
|
29
27
|
end
|
30
28
|
|
@@ -38,8 +36,8 @@ module StrictStruct
|
|
38
36
|
Hash[@_strict_struct_hash.to_a]
|
39
37
|
end
|
40
38
|
|
41
|
-
|
42
|
-
|
39
|
+
define_method :== do |other|
|
40
|
+
attributes.all? {|name| self.send(name) == other.send(name)}
|
43
41
|
end
|
44
42
|
end
|
45
43
|
klass.class_eval(&block) if block_given?
|
data/spec/strict_struct_spec.rb
CHANGED
@@ -58,6 +58,13 @@ describe 'StrictStruct' do
|
|
58
58
|
foo.new(x: 'foo', w: 'baz')
|
59
59
|
end.to raise_error ArgumentError, "missing keyword: y"
|
60
60
|
end
|
61
|
+
|
62
|
+
it "doesn't influence initialisation of another class" do
|
63
|
+
first = StrictStruct.new(:x)
|
64
|
+
second = StrictStruct.new(:y)
|
65
|
+
|
66
|
+
x = first.new(x: 3)
|
67
|
+
end
|
61
68
|
end
|
62
69
|
|
63
70
|
describe 'defining one' do
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strict_struct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark IJbema
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01
|
11
|
+
date: 2014-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
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
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: Extremely simple value objects
|
@@ -59,8 +59,8 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- .gitignore
|
63
|
-
- .travis.yml
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
64
|
- Gemfile
|
65
65
|
- Gemfile.travis
|
66
66
|
- LICENSE.txt
|
@@ -81,21 +81,20 @@ require_paths:
|
|
81
81
|
- lib
|
82
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
|
-
- -
|
84
|
+
- - ">="
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: '0'
|
87
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- -
|
89
|
+
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
93
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
94
|
+
rubygems_version: 2.2.1
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: StrictStruct is an immutable, named parameters based, replacement for Struct
|
98
98
|
test_files:
|
99
99
|
- spec/spec_helper.rb
|
100
100
|
- spec/strict_struct_spec.rb
|
101
|
-
has_rdoc:
|