virtus 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,11 +4,83 @@ rvm:
4
4
  - 1.8.7
5
5
  - 1.9.2
6
6
  - 1.9.3
7
- - rbx
8
- - rbx-2.0
7
+ - ruby-head
9
8
  - ree
10
9
  - jruby
11
- - ruby-head
10
+ - rbx
11
+ env:
12
+ -
13
+ - JRUBY_OPTS="--1.8"
14
+ - JRUBY_OPTS="--1.9"
15
+ - RBXOPT="-X18"
16
+ - RBXOPT="-X19"
17
+ matrix:
18
+ exclude:
19
+ # exclude 1.8.7
20
+ - rvm: 1.8.7
21
+ env: JRUBY_OPTS="--1.8"
22
+ - rvm: 1.8.7
23
+ env: JRUBY_OPTS="--1.9"
24
+ - rvm: 1.8.7
25
+ env: RBXOPT="-X18"
26
+ - rvm: 1.8.7
27
+ env: RBXOPT="-X19"
28
+
29
+ # exclude 1.9.2
30
+ - rvm: 1.9.2
31
+ env: JRUBY_OPTS="--1.8"
32
+ - rvm: 1.9.2
33
+ env: JRUBY_OPTS="--1.9"
34
+ - rvm: 1.9.2
35
+ env: RBXOPT="-X18"
36
+ - rvm: 1.9.2
37
+ env: RBXOPT="-X19"
38
+
39
+ # exclude 1.9.3
40
+ - rvm: 1.9.3
41
+ env: JRUBY_OPTS="--1.8"
42
+ - rvm: 1.9.3
43
+ env: JRUBY_OPTS="--1.9"
44
+ - rvm: 1.9.3
45
+ env: RBXOPT="-X18"
46
+ - rvm: 1.9.3
47
+ env: RBXOPT="-X19"
48
+
49
+ # exclude ruby-head
50
+ - rvm: ruby-head
51
+ env: JRUBY_OPTS="--1.8"
52
+ - rvm: ruby-head
53
+ env: JRUBY_OPTS="--1.9"
54
+ - rvm: ruby-head
55
+ env: RBXOPT="-X18"
56
+ - rvm: ruby-head
57
+ env: RBXOPT="-X19"
58
+
59
+ # exclude ree
60
+ - rvm: ree
61
+ env: JRUBY_OPTS="--1.8"
62
+ - rvm: ree
63
+ env: JRUBY_OPTS="--1.9"
64
+ - rvm: ree
65
+ env: RBXOPT="-X18"
66
+ - rvm: ree
67
+ env: RBXOPT="-X19"
68
+
69
+ # exclude jruby
70
+ - rvm: jruby
71
+ env:
72
+ - rvm: jruby
73
+ env: RBXOPT="-X18"
74
+ - rvm: jruby
75
+ env: RBXOPT="-X19"
76
+
77
+ # exclude rbx
78
+ - rvm: rbx
79
+ env:
80
+ - rvm: rbx
81
+ env: JRUBY_OPTS="--1.8"
82
+ - rvm: rbx
83
+ env: JRUBY_OPTS="--1.9"
12
84
  notifications:
13
85
  email:
14
86
  - piotr.solnica@gmail.com
data/History.md CHANGED
@@ -1,9 +1,15 @@
1
1
  # v0.0.8 to-be-released
2
2
 
3
+ * [fixed] Fix in type lookup for anonymous classes (dkubb)
4
+
5
+ [Compare v0.0.8..master](https://github.com/solnic/virtus/compare/v0.0.8...master)
6
+
7
+ # v0.0.8 2011-08-25
8
+
3
9
  * [fixed] Fixed conflict with ActiveModel (RichGuk)
4
10
  * [changed] Renamed Coercion::String.to_class => Coercion::String.to_constant (emmanuel)
5
11
 
6
- [Compare v0.0.7..master](https://github.com/solnic/virtus/compare/v0.0.7...master)
12
+ [Compare v0.0.7..master](https://github.com/solnic/virtus/compare/v0.0.7...v0.0.8)
7
13
 
8
14
  # v0.0.7 2011-07-31
9
15
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.9
@@ -64,7 +64,14 @@ module Virtus
64
64
  #
65
65
  # @api private
66
66
  def determine_type_from_primitive(primitive)
67
- descendants.detect { |descendant| primitive <= descendant.primitive }
67
+ type = nil
68
+
69
+ descendants.reverse_each do |descendant|
70
+ next unless primitive <= descendant.primitive
71
+ type = descendant if type.nil? || type.primitive > descendant.primitive
72
+ end
73
+
74
+ type
68
75
  end
69
76
 
70
77
  # Return the class given a string
@@ -83,7 +90,7 @@ module Virtus
83
90
  end
84
91
  end
85
92
 
86
- if RUBY_VERSION < '1.9'
93
+ if RUBY_VERSION < '1.9' || RUBY_ENGINE == 'rbx'
87
94
  def determine_type_from_string(string)
88
95
  if string =~ TYPE_FORMAT && const_defined?(string)
89
96
  const_get(string)
@@ -3,21 +3,34 @@ require 'spec_helper'
3
3
  describe Virtus::TypeLookup, '#determine_type' do
4
4
  subject { object.determine_type(class_or_name) }
5
5
 
6
- let(:object) do
6
+ let!(:object) do
7
7
  Class.new do
8
8
  extend Virtus::DescendantsTracker
9
9
  extend Virtus::TypeLookup
10
10
  end
11
11
  end
12
12
 
13
- let(:descendant) do
14
- object.const_set :String, Class.new(object) {
15
- def self.primitive
16
- ::String
17
- end
13
+ let!(:default) do
14
+ object.const_set :Object, Class.new(object) {
15
+ def self.primitive() ::Object end
18
16
  }
19
17
  end
20
18
 
19
+ let!(:descendant) do
20
+ object.const_set :String, Class.new(default) {
21
+ def self.primitive() ::String end
22
+ }
23
+ end
24
+
25
+ # add a default subclass to the top of the stack
26
+ let!(:extra) { Class.new(default) }
27
+
28
+ # assert the classes are subclassed in a specific order that will trigger
29
+ # the bug that this commit fixes. Do not remove or change the order below.
30
+ it 'has the descendants in the expected order' do
31
+ object.descendants.should == [ extra, descendant, default ]
32
+ end
33
+
21
34
  context 'with a TypeLookup class' do
22
35
  context 'when the argument is a descendant of the object' do
23
36
  let(:class_or_name) { descendant }
@@ -42,7 +55,7 @@ describe Virtus::TypeLookup, '#determine_type' do
42
55
  context 'when the argument is an unknown class' do
43
56
  let(:class_or_name) { Class.new }
44
57
 
45
- it { should be_nil }
58
+ it { should equal(default) }
46
59
  end
47
60
  end
48
61
 
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{virtus}
8
- s.version = "0.0.8"
7
+ s.name = "virtus"
8
+ s.version = "0.0.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Piotr Solnica}]
12
- s.date = %q{2011-08-25}
13
- s.description = %q{Attributes for your plain ruby objects}
14
- s.email = [%q{piotr@rubyverse.com}]
11
+ s.authors = ["Piotr Solnica"]
12
+ s.date = "2011-10-11"
13
+ s.description = "Attributes for your plain ruby objects"
14
+ s.email = ["piotr@rubyverse.com"]
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.md",
@@ -166,10 +166,10 @@ Gem::Specification.new do |s|
166
166
  "tasks/yard.rake",
167
167
  "virtus.gemspec"
168
168
  ]
169
- s.homepage = %q{https://github.com/solnic/virtus}
170
- s.require_paths = [%q{lib}]
171
- s.rubygems_version = %q{1.8.6}
172
- s.summary = %q{Attributes for your plain ruby objects}
169
+ s.homepage = "https://github.com/solnic/virtus"
170
+ s.require_paths = ["lib"]
171
+ s.rubygems_version = "1.8.11"
172
+ s.summary = "Attributes for your plain ruby objects"
173
173
 
174
174
  if s.respond_to? :specification_version then
175
175
  s.specification_version = 3
metadata CHANGED
@@ -1,82 +1,59 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: virtus
3
- version: !ruby/object:Gem::Version
4
- hash: 15
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.9
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 8
10
- version: 0.0.8
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Piotr Solnica
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-08-25 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- version_requirements: &id001 !ruby/object:Gem::Requirement
12
+ date: 2011-10-11 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: backports
16
+ requirement: &70244296925160 !ruby/object:Gem::Requirement
22
17
  none: false
23
- requirements:
18
+ requirements:
24
19
  - - ~>
25
- - !ruby/object:Gem::Version
26
- hash: 3
27
- segments:
28
- - 2
29
- - 3
30
- - 0
20
+ - !ruby/object:Gem::Version
31
21
  version: 2.3.0
32
- name: backports
33
22
  type: :development
34
23
  prerelease: false
35
- requirement: *id001
36
- - !ruby/object:Gem::Dependency
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70244296925160
25
+ - !ruby/object:Gem::Dependency
26
+ name: jeweler
27
+ requirement: &70244296924200 !ruby/object:Gem::Requirement
38
28
  none: false
39
- requirements:
29
+ requirements:
40
30
  - - ~>
41
- - !ruby/object:Gem::Version
42
- hash: 7
43
- segments:
44
- - 1
45
- - 6
46
- - 4
31
+ - !ruby/object:Gem::Version
47
32
  version: 1.6.4
48
- name: jeweler
49
33
  type: :development
50
34
  prerelease: false
51
- requirement: *id002
52
- - !ruby/object:Gem::Dependency
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70244296924200
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70244296923000 !ruby/object:Gem::Requirement
54
39
  none: false
55
- requirements:
40
+ requirements:
56
41
  - - ~>
57
- - !ruby/object:Gem::Version
58
- hash: 23
59
- segments:
60
- - 2
61
- - 6
62
- - 0
42
+ - !ruby/object:Gem::Version
63
43
  version: 2.6.0
64
- name: rspec
65
44
  type: :development
66
45
  prerelease: false
67
- requirement: *id003
46
+ version_requirements: *70244296923000
68
47
  description: Attributes for your plain ruby objects
69
- email:
48
+ email:
70
49
  - piotr@rubyverse.com
71
50
  executables: []
72
-
73
51
  extensions: []
74
-
75
- extra_rdoc_files:
52
+ extra_rdoc_files:
76
53
  - LICENSE
77
54
  - README.md
78
55
  - TODO
79
- files:
56
+ files:
80
57
  - .rvmrc
81
58
  - .travis.yml
82
59
  - .yardopts
@@ -226,36 +203,29 @@ files:
226
203
  - virtus.gemspec
227
204
  homepage: https://github.com/solnic/virtus
228
205
  licenses: []
229
-
230
206
  post_install_message:
231
207
  rdoc_options: []
232
-
233
- require_paths:
208
+ require_paths:
234
209
  - lib
235
- required_ruby_version: !ruby/object:Gem::Requirement
210
+ required_ruby_version: !ruby/object:Gem::Requirement
236
211
  none: false
237
- requirements:
238
- - - ">="
239
- - !ruby/object:Gem::Version
240
- hash: 3
241
- segments:
212
+ requirements:
213
+ - - ! '>='
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ segments:
242
217
  - 0
243
- version: "0"
244
- required_rubygems_version: !ruby/object:Gem::Requirement
218
+ hash: 4092436988871240492
219
+ required_rubygems_version: !ruby/object:Gem::Requirement
245
220
  none: false
246
- requirements:
247
- - - ">="
248
- - !ruby/object:Gem::Version
249
- hash: 3
250
- segments:
251
- - 0
252
- version: "0"
221
+ requirements:
222
+ - - ! '>='
223
+ - !ruby/object:Gem::Version
224
+ version: '0'
253
225
  requirements: []
254
-
255
226
  rubyforge_project:
256
- rubygems_version: 1.8.6
227
+ rubygems_version: 1.8.11
257
228
  signing_key:
258
229
  specification_version: 3
259
230
  summary: Attributes for your plain ruby objects
260
231
  test_files: []
261
-