attr_required 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/attr_required.gemspec +2 -2
- data/lib/attr_optional.rb +4 -4
- data/lib/attr_required.rb +4 -4
- data/spec/attr_optional_spec.rb +10 -10
- data/spec/attr_required_spec.rb +16 -16
- data/spec/spec_helper.rb +6 -0
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc25145c748bd59e355ea14f090b54f43506995a
|
4
|
+
data.tar.gz: 942a90f96fa116ccb9555ee6cd3525fd901b07d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60b933b1b210ad9283201c32e07cb735c747f8e11d7dd5894e1767a025af4f6784bd9b57545b7a0f46b2ec0613c79ea093b1b00734f2f6e8d27f4219b34ed4c1
|
7
|
+
data.tar.gz: 2bfd757221781bfbf398aafbd96da60f834f25f04cb313b81e7bbb8e9860db60646955be07d0700427434226f11da028e1ea8b24c1c8bdd7749f76468a82d1c3
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/attr_required.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
-
s.add_development_dependency "rake"
|
17
|
+
s.add_development_dependency "rake"
|
18
18
|
s.add_development_dependency "simplecov"
|
19
|
-
s.add_development_dependency "rspec"
|
19
|
+
s.add_development_dependency "rspec"
|
20
20
|
end
|
data/lib/attr_optional.rb
CHANGED
@@ -9,16 +9,16 @@ module AttrOptional
|
|
9
9
|
def inherited(klass)
|
10
10
|
super
|
11
11
|
unless optional_attributes.empty?
|
12
|
-
klass.attr_optional
|
12
|
+
klass.attr_optional(*optional_attributes)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
def attr_optional(*keys)
|
17
17
|
if defined? undef_required_attributes
|
18
|
-
undef_required_attributes
|
18
|
+
undef_required_attributes(*keys)
|
19
19
|
end
|
20
20
|
optional_attributes.concat(keys)
|
21
|
-
attr_accessor
|
21
|
+
attr_accessor(*keys)
|
22
22
|
end
|
23
23
|
|
24
24
|
def attr_optional?(key)
|
@@ -48,4 +48,4 @@ module AttrOptional
|
|
48
48
|
self.class.attr_optional? key
|
49
49
|
end
|
50
50
|
|
51
|
-
end
|
51
|
+
end
|
data/lib/attr_required.rb
CHANGED
@@ -11,16 +11,16 @@ module AttrRequired
|
|
11
11
|
def inherited(klass)
|
12
12
|
super
|
13
13
|
unless required_attributes.empty?
|
14
|
-
klass.attr_required
|
14
|
+
klass.attr_required(*required_attributes)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
def attr_required(*keys)
|
19
19
|
if defined? undef_optional_attributes
|
20
|
-
undef_optional_attributes
|
20
|
+
undef_optional_attributes(*keys)
|
21
21
|
end
|
22
22
|
required_attributes.concat keys
|
23
|
-
attr_accessor
|
23
|
+
attr_accessor(*keys)
|
24
24
|
end
|
25
25
|
|
26
26
|
def attr_required?(key)
|
@@ -71,4 +71,4 @@ module AttrRequired
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
end
|
74
|
+
end
|
data/spec/attr_optional_spec.rb
CHANGED
@@ -20,8 +20,8 @@ describe AttrOptional do
|
|
20
20
|
|
21
21
|
context 'when already required' do
|
22
22
|
it 'should be optional' do
|
23
|
-
@c.attr_required?(:attr_required_b).should
|
24
|
-
@c.attr_optional?(:attr_required_b).should
|
23
|
+
@c.attr_required?(:attr_required_b).should == false
|
24
|
+
@c.attr_optional?(:attr_required_b).should == true
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -34,19 +34,19 @@ describe AttrOptional do
|
|
34
34
|
|
35
35
|
describe '.attr_optional?' do
|
36
36
|
it 'should answer whether the attributes is optional or not' do
|
37
|
-
A.attr_optional?(:attr_optional_a).should
|
38
|
-
B.attr_optional?(:attr_optional_a).should
|
39
|
-
B.attr_optional?(:attr_optional_b).should
|
40
|
-
B.attr_optional?(:to_s).should
|
37
|
+
A.attr_optional?(:attr_optional_a).should == true
|
38
|
+
B.attr_optional?(:attr_optional_a).should == true
|
39
|
+
B.attr_optional?(:attr_optional_b).should == true
|
40
|
+
B.attr_optional?(:to_s).should == false
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe '#attr_optional?' do
|
45
45
|
it 'should answer whether the attributes is optional or not' do
|
46
|
-
@a.attr_optional?(:attr_optional_a).should
|
47
|
-
@b.attr_optional?(:attr_optional_a).should
|
48
|
-
@b.attr_optional?(:attr_optional_b).should
|
49
|
-
@b.attr_optional?(:to_s).should
|
46
|
+
@a.attr_optional?(:attr_optional_a).should == true
|
47
|
+
@b.attr_optional?(:attr_optional_a).should == true
|
48
|
+
@b.attr_optional?(:attr_optional_b).should == true
|
49
|
+
@b.attr_optional?(:to_s).should == false
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
data/spec/attr_required_spec.rb
CHANGED
@@ -20,8 +20,8 @@ describe AttrRequired do
|
|
20
20
|
|
21
21
|
context 'when already optional' do
|
22
22
|
it 'should be optional' do
|
23
|
-
@c.attr_required?(:attr_optional_b).should
|
24
|
-
@c.attr_optional?(:attr_optional_b).should
|
23
|
+
@c.attr_required?(:attr_optional_b).should == true
|
24
|
+
@c.attr_optional?(:attr_optional_b).should == false
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -34,33 +34,33 @@ describe AttrRequired do
|
|
34
34
|
|
35
35
|
describe '.attr_required?' do
|
36
36
|
it 'should answer whether the attributes is required or not' do
|
37
|
-
A.attr_required?(:attr_required_a).should
|
38
|
-
B.attr_required?(:attr_required_a).should
|
39
|
-
B.attr_required?(:attr_required_b).should
|
40
|
-
B.attr_required?(:to_s).should
|
37
|
+
A.attr_required?(:attr_required_a).should == true
|
38
|
+
B.attr_required?(:attr_required_a).should == true
|
39
|
+
B.attr_required?(:attr_required_b).should == true
|
40
|
+
B.attr_required?(:to_s).should == false
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe '#attr_required?' do
|
45
45
|
it 'should answer whether the attributes is required or not' do
|
46
|
-
@a.attr_required?(:attr_required_a).should
|
47
|
-
@b.attr_required?(:attr_required_a).should
|
48
|
-
@b.attr_required?(:attr_required_b).should
|
49
|
-
@a.attr_required?(:attr_required_b).should
|
50
|
-
@b.attr_required?(:to_s).should
|
46
|
+
@a.attr_required?(:attr_required_a).should == true
|
47
|
+
@b.attr_required?(:attr_required_a).should == true
|
48
|
+
@b.attr_required?(:attr_required_b).should == true
|
49
|
+
@a.attr_required?(:attr_required_b).should == false
|
50
|
+
@b.attr_required?(:to_s).should == false
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
describe '#attr_missing?' do
|
55
55
|
it 'should answer whether any attributes are missing' do
|
56
|
-
@a.attr_missing?.should
|
57
|
-
@b.attr_missing?.should
|
56
|
+
@a.attr_missing?.should == true
|
57
|
+
@b.attr_missing?.should == true
|
58
58
|
@a.attr_required_a = 'attr_required_a'
|
59
59
|
@b.attr_required_a = 'attr_required_a'
|
60
|
-
@a.attr_missing?.should
|
61
|
-
@b.attr_missing?.should
|
60
|
+
@a.attr_missing?.should == false
|
61
|
+
@b.attr_missing?.should == true
|
62
62
|
@b.attr_required_b = 'attr_required_b'
|
63
|
-
@b.attr_missing?.should
|
63
|
+
@b.attr_missing?.should == false
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attr_required
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nov matake
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0
|
19
|
+
version: '0'
|
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
|
-
version: '0
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: simplecov
|
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
|
-
version: '
|
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
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
description: attr_required and attr_optional
|
56
56
|
email: nov@matake.jp
|
57
57
|
executables: []
|
@@ -60,9 +60,9 @@ extra_rdoc_files:
|
|
60
60
|
- LICENSE
|
61
61
|
- README.rdoc
|
62
62
|
files:
|
63
|
-
- .gitignore
|
64
|
-
- .rspec
|
65
|
-
- .travis.yml
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
66
|
- Gemfile
|
67
67
|
- LICENSE
|
68
68
|
- README.rdoc
|
@@ -80,22 +80,22 @@ licenses:
|
|
80
80
|
metadata: {}
|
81
81
|
post_install_message:
|
82
82
|
rdoc_options:
|
83
|
-
- --charset=UTF-8
|
83
|
+
- "--charset=UTF-8"
|
84
84
|
require_paths:
|
85
85
|
- lib
|
86
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- -
|
93
|
+
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: 1.3.6
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.5.1
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: attr_required and attr_optional
|