myrrha 3.0.0.rc1 → 3.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  group :runtime do
4
- gem "domain", "= 1.0.0.rc1"
4
+ gem "domain", "~> 1.0.0.rc2"
5
5
  end
6
6
 
7
7
  group :test do
data/Gemfile.lock CHANGED
@@ -3,7 +3,7 @@ GEM
3
3
  specs:
4
4
  bluecloth (2.2.0)
5
5
  diff-lcs (1.1.3)
6
- domain (1.0.0.rc1)
6
+ domain (1.0.0.rc2)
7
7
  rake (0.9.2.2)
8
8
  rspec (2.8.0)
9
9
  rspec-core (~> 2.8.0)
@@ -22,7 +22,7 @@ PLATFORMS
22
22
 
23
23
  DEPENDENCIES
24
24
  bluecloth (~> 2.2.0)
25
- domain (= 1.0.0.rc1)
25
+ domain (~> 1.0.0.rc2)
26
26
  rake (~> 0.9.2)
27
27
  rspec (~> 2.8.0)
28
28
  wlang (~> 0.10.2)
@@ -13,7 +13,7 @@ PosInt.new(10)
13
13
  begin
14
14
  PosInt.new(-10)
15
15
  raise "Unexpected case: PosInt.new(-10) succeeds"
16
- rescue ArgumentError => ex
16
+ rescue TypeError => ex
17
17
  puts ex.message
18
18
  end
19
19
 
@@ -9,6 +9,12 @@ module Domain
9
9
 
10
10
  def coerce(arg)
11
11
  coercions.coerce(arg, self)
12
+ rescue Myrrha::Error
13
+ domain_error!(arg)
14
+ end
15
+
16
+ def [](first, *args)
17
+ args.empty? ? coerce(first) : coerce(args.unshift(first))
12
18
  end
13
19
 
14
20
  end # module CoercionMethods
@@ -3,7 +3,7 @@ module Myrrha
3
3
 
4
4
  MAJOR = 3
5
5
  MINOR = 0
6
- TINY = "0.rc1"
6
+ TINY = "0.rc2"
7
7
 
8
8
  def self.to_s
9
9
  [ MAJOR, MINOR, TINY ].join('.')
data/myrrha.gemspec CHANGED
@@ -128,7 +128,7 @@ Gem::Specification.new do |s|
128
128
  s.add_development_dependency("yard", "~> 0.7.4")
129
129
  s.add_development_dependency("bluecloth", "~> 2.2.0")
130
130
  s.add_development_dependency("wlang", "~> 0.10.2")
131
- s.add_dependency("domain", "= 1.0.0.rc1")
131
+ s.add_dependency("domain", "~> 1.0.0.rc2")
132
132
 
133
133
  # The version of ruby required by this gem
134
134
  #
data/myrrha.noespec CHANGED
@@ -10,7 +10,7 @@ variables:
10
10
  upper:
11
11
  Myrrha
12
12
  version:
13
- 3.0.0.rc1
13
+ 3.0.0.rc2
14
14
  summary: |-
15
15
  Myrrha provides the coercion framework which is missing to Ruby.
16
16
  description: |-
@@ -26,12 +26,12 @@ variables:
26
26
  - http://github.com/blambeau/myrrha
27
27
  - http://rubygems.org/gems/myrrha
28
28
  dependencies:
29
- - {name: domain, version: "= 1.0.0.rc1", groups: [runtime] }
30
- - {name: rake, version: "~> 0.9.2", groups: [test, release]}
31
- - {name: rspec, version: "~> 2.8.0", groups: [test, release]}
32
- - {name: yard, version: "~> 0.7.4", groups: [doc ]}
33
- - {name: bluecloth, version: "~> 2.2.0", groups: [doc ]}
34
- - {name: wlang, version: "~> 0.10.2", groups: [release ]}
29
+ - {name: domain, version: "~> 1.0.0.rc2", groups: [runtime] }
30
+ - {name: rake, version: "~> 0.9.2", groups: [test, release]}
31
+ - {name: rspec, version: "~> 2.8.0", groups: [test, release]}
32
+ - {name: yard, version: "~> 0.7.4", groups: [doc ]}
33
+ - {name: bluecloth, version: "~> 2.2.0", groups: [doc ]}
34
+ - {name: wlang, version: "~> 0.10.2", groups: [release ]}
35
35
  rake_tasks:
36
36
  debug_mail:
37
37
  rx_changelog_sections: /^# /
@@ -3,14 +3,34 @@ describe Domain, "coerce" do
3
3
 
4
4
  let(:domain){ Domain.scalar(:x, :y) }
5
5
 
6
+ let(:expected){ domain.new(1, 2) }
7
+
6
8
  before do
7
9
  domain.coercions do |c|
8
- c.coercion(String){|v,_| domain.new(1,2) }
10
+ c.coercion(String){|v,_| expected }
11
+ c.coercion(Array) {|v,_| domain.new(*v) }
9
12
  end
10
13
  end
11
14
 
12
15
  it 'should delegate to coercions' do
13
- domain.coerce("blah").should eq(domain.new(1,2))
16
+ domain.coerce("blah").should be(expected)
17
+ end
18
+
19
+ it 'raises a TypeError if something goes wrong' do
20
+ lambda{
21
+ domain.coerce(12)
22
+ }.should raise_error(TypeError, /Can't convert `12`/)
23
+ end
24
+
25
+ describe "the [] alias" do
26
+
27
+ it 'delegates to coerce when one argument' do
28
+ domain["12"].should be(expected)
29
+ end
30
+
31
+ it 'supports Array literals' do
32
+ domain[1, 3].should eq(domain.new(1, 3))
33
+ end
14
34
  end
15
35
 
16
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myrrha
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc1
4
+ version: 3.0.0.rc2
5
5
  prerelease: 6
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: 2012-09-27 00:00:00.000000000 Z
12
+ date: 2012-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -96,17 +96,17 @@ dependencies:
96
96
  requirement: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
- - - '='
99
+ - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: 1.0.0.rc1
101
+ version: 1.0.0.rc2
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
- - - '='
107
+ - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 1.0.0.rc1
109
+ version: 1.0.0.rc2
110
110
  description: ! "Myrrha provides the coercion framework which is missing to Ruby. Coercions\nare
111
111
  simply defined as a set of rules for converting values from source to target\ndomains
112
112
  (in an abstract sense). As a typical and useful example, it comes with \na coerce()