oval 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +5 -0
- data/Modulefile +1 -1
- data/README.md +11 -5
- data/lib/oval/class_decl_base.rb +7 -8
- data/oval.gemspec +1 -1
- data/spec/unit/oval/class_decl_base_spec.rb +14 -14
- data/spec/unit/oval/instance_of_spec.rb +1 -1
- data/spec/unit/oval/kind_of_spec.rb +1 -1
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
+
2014-02-03 Pawel Tomulik <ptomulik@meil.pw.edu.pl>
|
2
|
+
* release 0.0.4
|
1
3
|
2014-02-02 Pawel Tomulik <ptomulik@meil.pw.edu.pl>
|
4
|
+
* corrections to README.md
|
5
|
+
* small refactoring
|
6
|
+
* removed dead code from class_decl_base.rb
|
2
7
|
* release 0.0.3
|
3
8
|
* fixed dependencies in oval.gemspec
|
4
9
|
* release 0.0.2
|
data/Modulefile
CHANGED
data/README.md
CHANGED
@@ -126,11 +126,17 @@ end
|
|
126
126
|
A declaration of options consists entirely of what we call here
|
127
127
|
**declarators**. The [ov_options](#ov_options) should be used as a root of
|
128
128
|
every declaration (starting symbol in grammar terms). It accepts a Hash of the
|
129
|
-
form
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
129
|
+
form
|
130
|
+
|
131
|
+
```
|
132
|
+
{optname1 => optdecl1, optname2 => optdecl2, ... }
|
133
|
+
```
|
134
|
+
|
135
|
+
as an argument. The **optname#** is an option name, and **optdecl#** is a
|
136
|
+
declarator restricting the option's value. Each option name (key) must be
|
137
|
+
convertible to a `String`. Option value declarators are non-terminal
|
138
|
+
declarators (defined later in this section) or terminals (any other ruby
|
139
|
+
values). The simple declaration
|
134
140
|
|
135
141
|
```ruby
|
136
142
|
ov_options[ :foo => :bar ]
|
data/lib/oval/class_decl_base.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'oval/base'
|
2
2
|
class Oval::ClassDeclBase < Oval::Base
|
3
|
-
attr_reader :klass
|
4
3
|
def self.[](klass)
|
5
4
|
new(klass)
|
6
5
|
end
|
@@ -9,18 +8,18 @@ class Oval::ClassDeclBase < Oval::Base
|
|
9
8
|
self.klass = klass
|
10
9
|
end
|
11
10
|
|
11
|
+
attr_reader :klass
|
12
|
+
|
12
13
|
private
|
13
14
|
|
14
|
-
def klass=(
|
15
|
-
validate_class(
|
16
|
-
@klass =
|
15
|
+
def klass=(klass)
|
16
|
+
self.class.validate_class(klass, self.class)
|
17
|
+
@klass = klass
|
17
18
|
end
|
18
19
|
|
19
|
-
def self.
|
20
|
-
|
21
|
-
def validate_class(klass)
|
20
|
+
def self.validate_class(klass,receiver)
|
22
21
|
unless klass.is_a?(Class)
|
23
|
-
subject =
|
22
|
+
subject = receiver.name.sub(/^.*::/,'')
|
24
23
|
raise Oval::DeclError,
|
25
24
|
"Invalid class #{klass.inspect}#{for_subject(subject)}"
|
26
25
|
end
|
data/oval.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = 'oval'
|
6
|
-
gem.version = '0.0.
|
6
|
+
gem.version = '0.0.4'
|
7
7
|
gem.authors = ["Pawel Tomulik"]
|
8
8
|
gem.email = ["ptomulik@meil.pw.edu.pl"]
|
9
9
|
gem.description = %q{Validate options when passed to methods}
|
@@ -12,7 +12,7 @@ describe Oval::ClassDeclBase do
|
|
12
12
|
|
13
13
|
context "an instance" do
|
14
14
|
let(:subject) { described_class[:klass0] }
|
15
|
-
before { described_class.
|
15
|
+
before { described_class.stubs(:validate_class) }
|
16
16
|
it { should be_kind_of Oval::Base }
|
17
17
|
[
|
18
18
|
:klass,
|
@@ -22,26 +22,26 @@ describe Oval::ClassDeclBase do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
describe "#validate_class" do
|
25
|
-
let(:subject) { described_class.new(:klass0) }
|
26
|
-
before do
|
27
|
-
described_class.
|
28
|
-
subject
|
29
|
-
described_class.
|
30
|
-
end
|
25
|
+
## let(:subject) { described_class.new(:klass0) }
|
26
|
+
## before do
|
27
|
+
## described_class.stubs(:validate_class)
|
28
|
+
## subject
|
29
|
+
## described_class.unstub(:validate_class)
|
30
|
+
## end
|
31
31
|
context "validate_class(:symbol1)" do
|
32
32
|
let(:msg) { "Invalid class :symbol1 for ClassDeclBase" }
|
33
|
-
it { expect {
|
33
|
+
it { expect { described_class.send(:validate_class,:symbol1,Oval::ClassDeclBase) }.to raise_error Oval::DeclError, msg }
|
34
34
|
end
|
35
35
|
[ Array, String, NilClass ].each do |klass|
|
36
36
|
context "validate_class(#{klass.name})" do
|
37
37
|
let(:klass) { klass }
|
38
|
-
it { expect {
|
38
|
+
it { expect { described_class.send(:validate_class,klass,Oval::ClassDeclBase) }.to_not raise_error }
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe "klass" do
|
44
|
-
before { described_class.
|
44
|
+
before { described_class.stubs(:validate_class) }
|
45
45
|
context "new(:klass0).klass" do
|
46
46
|
it { described_class.new(:klass0).klass.should be :klass0 }
|
47
47
|
end
|
@@ -53,13 +53,13 @@ describe Oval::ClassDeclBase do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
describe "#klass=" do
|
56
|
-
before { described_class.
|
56
|
+
before { described_class.stubs(:validate_class) }
|
57
57
|
let(:subject) { described_class.new(:klass0) }
|
58
58
|
context "#klass = :klass1" do
|
59
|
-
it "should call self.class.validate_class(:klass1) once" do
|
59
|
+
it "should call self.class.validate_class(:klass1,Oval::ClassDeclBase) once" do
|
60
60
|
subject # reference before re-stubbing validate_class
|
61
|
-
|
62
|
-
|
61
|
+
described_class.stubs(:validate_class).never
|
62
|
+
described_class.stubs(:validate_class).once.with(:klass1,Oval::ClassDeclBase)
|
63
63
|
expect { subject.send(:klass=,:klass1) }.to_not raise_error
|
64
64
|
end
|
65
65
|
it "should assign @klass = :klass1" do
|
@@ -4,7 +4,7 @@ require 'oval/instance_of'
|
|
4
4
|
describe Oval::InstanceOf do
|
5
5
|
describe 'an instance' do
|
6
6
|
let(:subject) { described_class[:klass] }
|
7
|
-
before { described_class.
|
7
|
+
before { described_class.stubs(:validate_class) }
|
8
8
|
it { should respond_to :validate }
|
9
9
|
end
|
10
10
|
|
@@ -4,7 +4,7 @@ require 'oval/kind_of'
|
|
4
4
|
describe Oval::KindOf do
|
5
5
|
describe 'an instance' do
|
6
6
|
let(:subject) { described_class[:klass] }
|
7
|
-
before { described_class.
|
7
|
+
before { described_class.stubs(:validate_class) }
|
8
8
|
it { should respond_to :validate }
|
9
9
|
end
|
10
10
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oval
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -200,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
200
|
version: '0'
|
201
201
|
segments:
|
202
202
|
- 0
|
203
|
-
hash:
|
203
|
+
hash: 1914845513131623040
|
204
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
205
|
none: false
|
206
206
|
requirements:
|
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
209
|
version: '0'
|
210
210
|
segments:
|
211
211
|
- 0
|
212
|
-
hash:
|
212
|
+
hash: 1914845513131623040
|
213
213
|
requirements: []
|
214
214
|
rubyforge_project:
|
215
215
|
rubygems_version: 1.8.23
|