virtus 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ require 'backports'
1
2
  require 'pathname'
2
3
  require 'rubygems'
3
4
  require 'rspec'
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Virtus::Attribute, '.determine_type' do
4
+ let(:object) { described_class }
5
+
6
+ described_class.descendants.each do |attribute_class|
7
+ context "with class #{attribute_class.inspect}" do
8
+ subject { object.determine_type(attribute_class) }
9
+
10
+ it 'returns the corresponding attribute class' do
11
+ should be(attribute_class)
12
+ end
13
+ end
14
+
15
+ primitive = attribute_class.primitive
16
+ context "with primitive #{primitive.inspect}" do
17
+ subject { object.determine_type(primitive) }
18
+
19
+ it 'returns the corresponding attribute class' do
20
+ should be(attribute_class)
21
+ end
22
+ end
23
+
24
+ string = attribute_class.name['Virtus::Attribute::'.length..-1]
25
+ context "with string #{string.inspect}" do
26
+ subject { object.determine_type(string) }
27
+
28
+ it 'returns the corresponding attribute class' do
29
+ should be(attribute_class)
30
+ end
31
+ end
32
+ end
33
+
34
+ context 'when the primitive defaults to Object' do
35
+ subject { object.determine_type(primitive) }
36
+
37
+ let(:primitive) { Class.new }
38
+
39
+ it { should equal(Virtus::Attribute::Object) }
40
+ end
41
+
42
+ context 'when the string does not map to an Attribute' do
43
+ subject { object.determine_type(string) }
44
+
45
+ let(:string) { 'Unknown' }
46
+
47
+ it { should be_nil }
48
+ end
49
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Virtus::DescendantsTracker, '#inherited' do
4
- subject { object.inherited(descendant) }
3
+ describe Virtus::DescendantsTracker, '#add_descendant' do
4
+ subject { object.add_descendant(descendant) }
5
5
 
6
6
  let(:described_class) { Class.new { extend Virtus::DescendantsTracker } }
7
7
  let(:object) { Class.new(described_class) }
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{virtus}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Piotr Solnica"]
12
- s.date = %q{2011-07-08}
12
+ s.date = %q{2011-07-10}
13
13
  s.description = %q{Attributes for your plain ruby objects}
14
14
  s.email = ["piotr@rubyverse.com"]
15
15
  s.extra_rdoc_files = [
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
18
18
  "TODO"
19
19
  ]
20
20
  s.files = [
21
- ".gitignore",
22
21
  ".rvmrc",
23
22
  ".travis.yml",
24
23
  "Gemfile",
@@ -72,6 +71,7 @@ Gem::Specification.new do |s|
72
71
  "spec/unit/virtus/attribute/array_spec.rb",
73
72
  "spec/unit/virtus/attribute/attribute_spec.rb",
74
73
  "spec/unit/virtus/attribute/boolean_spec.rb",
74
+ "spec/unit/virtus/attribute/class_methods/determine_type_spec.rb",
75
75
  "spec/unit/virtus/attribute/date_spec.rb",
76
76
  "spec/unit/virtus/attribute/date_time_spec.rb",
77
77
  "spec/unit/virtus/attribute/decimal_spec.rb",
@@ -91,9 +91,8 @@ Gem::Specification.new do |s|
91
91
  "spec/unit/virtus/attribute_set/reset_spec.rb",
92
92
  "spec/unit/virtus/class_methods/attribute_spec.rb",
93
93
  "spec/unit/virtus/class_methods/new_spec.rb",
94
+ "spec/unit/virtus/descendants_tracker/add_descendant_spec.rb",
94
95
  "spec/unit/virtus/descendants_tracker/descendants_spec.rb",
95
- "spec/unit/virtus/descendants_tracker/inherited_spec.rb",
96
- "spec/unit/virtus/determine_type_spec.rb",
97
96
  "spec/unit/virtus/instance_methods/attributes_spec.rb",
98
97
  "spec/unit/virtus/instance_methods/element_reference_spec.rb",
99
98
  "spec/unit/virtus/instance_methods/element_set_spec.rb",
@@ -113,19 +112,21 @@ Gem::Specification.new do |s|
113
112
  s.require_paths = ["lib"]
114
113
  s.rubygems_version = %q{1.6.2}
115
114
  s.summary = %q{Attributes for your plain ruby objects}
116
- s.test_files = ["spec/integration/virtus/attributes/attribute/typecast_spec.rb", "spec/integration/virtus/class_methods/attribute_spec.rb", "spec/integration/virtus/class_methods/attributes_spec.rb", "spec/integration/virtus/class_methods/const_missing_spec.rb", "spec/rcov.opts", "spec/shared/idempotent_method_behaviour.rb", "spec/spec_helper.rb", "spec/unit/shared/attribute.rb", "spec/unit/shared/attribute/accept_options.rb", "spec/unit/shared/attribute/accepted_options.rb", "spec/unit/shared/attribute/complex.rb", "spec/unit/shared/attribute/get.rb", "spec/unit/shared/attribute/options.rb", "spec/unit/shared/attribute/set.rb", "spec/unit/virtus/attribute/array_spec.rb", "spec/unit/virtus/attribute/attribute_spec.rb", "spec/unit/virtus/attribute/boolean_spec.rb", "spec/unit/virtus/attribute/date_spec.rb", "spec/unit/virtus/attribute/date_time_spec.rb", "spec/unit/virtus/attribute/decimal_spec.rb", "spec/unit/virtus/attribute/float_spec.rb", "spec/unit/virtus/attribute/hash_spec.rb", "spec/unit/virtus/attribute/integer_spec.rb", "spec/unit/virtus/attribute/numeric/class_methods/descendants_spec.rb", "spec/unit/virtus/attribute/object/class_methods/descendants_spec.rb", "spec/unit/virtus/attribute/string_spec.rb", "spec/unit/virtus/attribute/time_spec.rb", "spec/unit/virtus/attribute_set/append_spec.rb", "spec/unit/virtus/attribute_set/each_spec.rb", "spec/unit/virtus/attribute_set/element_reference_spec.rb", "spec/unit/virtus/attribute_set/element_set_spec.rb", "spec/unit/virtus/attribute_set/merge_spec.rb", "spec/unit/virtus/attribute_set/parent_spec.rb", "spec/unit/virtus/attribute_set/reset_spec.rb", "spec/unit/virtus/class_methods/attribute_spec.rb", "spec/unit/virtus/class_methods/new_spec.rb", "spec/unit/virtus/descendants_tracker/descendants_spec.rb", "spec/unit/virtus/descendants_tracker/inherited_spec.rb", "spec/unit/virtus/determine_type_spec.rb", "spec/unit/virtus/instance_methods/attributes_spec.rb", "spec/unit/virtus/instance_methods/element_reference_spec.rb", "spec/unit/virtus/instance_methods/element_set_spec.rb"]
117
115
 
118
116
  if s.respond_to? :specification_version then
119
117
  s.specification_version = 3
120
118
 
121
119
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
120
+ s.add_development_dependency(%q<backports>, ["~> 2.3.0"])
122
121
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
123
122
  s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
124
123
  else
124
+ s.add_dependency(%q<backports>, ["~> 2.3.0"])
125
125
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
126
126
  s.add_dependency(%q<rspec>, ["~> 2.6.0"])
127
127
  end
128
128
  else
129
+ s.add_dependency(%q<backports>, ["~> 2.3.0"])
129
130
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
130
131
  s.add_dependency(%q<rspec>, ["~> 2.6.0"])
131
132
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtus
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Piotr Solnica
@@ -15,12 +15,28 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-08 00:00:00 +02:00
18
+ date: 2011-07-10 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 2
31
+ - 3
32
+ - 0
33
+ version: 2.3.0
34
+ type: :development
35
+ name: backports
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
24
40
  none: false
25
41
  requirements:
26
42
  - - ~>
@@ -33,10 +49,10 @@ dependencies:
33
49
  version: 1.6.4
34
50
  type: :development
35
51
  name: jeweler
36
- version_requirements: *id001
52
+ version_requirements: *id002
37
53
  - !ruby/object:Gem::Dependency
38
54
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
55
+ requirement: &id003 !ruby/object:Gem::Requirement
40
56
  none: false
41
57
  requirements:
42
58
  - - ~>
@@ -49,7 +65,7 @@ dependencies:
49
65
  version: 2.6.0
50
66
  type: :development
51
67
  name: rspec
52
- version_requirements: *id002
68
+ version_requirements: *id003
53
69
  description: Attributes for your plain ruby objects
54
70
  email:
55
71
  - piotr@rubyverse.com
@@ -62,7 +78,6 @@ extra_rdoc_files:
62
78
  - README.markdown
63
79
  - TODO
64
80
  files:
65
- - .gitignore
66
81
  - .rvmrc
67
82
  - .travis.yml
68
83
  - Gemfile
@@ -116,6 +131,7 @@ files:
116
131
  - spec/unit/virtus/attribute/array_spec.rb
117
132
  - spec/unit/virtus/attribute/attribute_spec.rb
118
133
  - spec/unit/virtus/attribute/boolean_spec.rb
134
+ - spec/unit/virtus/attribute/class_methods/determine_type_spec.rb
119
135
  - spec/unit/virtus/attribute/date_spec.rb
120
136
  - spec/unit/virtus/attribute/date_time_spec.rb
121
137
  - spec/unit/virtus/attribute/decimal_spec.rb
@@ -135,9 +151,8 @@ files:
135
151
  - spec/unit/virtus/attribute_set/reset_spec.rb
136
152
  - spec/unit/virtus/class_methods/attribute_spec.rb
137
153
  - spec/unit/virtus/class_methods/new_spec.rb
154
+ - spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
138
155
  - spec/unit/virtus/descendants_tracker/descendants_spec.rb
139
- - spec/unit/virtus/descendants_tracker/inherited_spec.rb
140
- - spec/unit/virtus/determine_type_spec.rb
141
156
  - spec/unit/virtus/instance_methods/attributes_spec.rb
142
157
  - spec/unit/virtus/instance_methods/element_reference_spec.rb
143
158
  - spec/unit/virtus/instance_methods/element_set_spec.rb
@@ -186,46 +201,5 @@ rubygems_version: 1.6.2
186
201
  signing_key:
187
202
  specification_version: 3
188
203
  summary: Attributes for your plain ruby objects
189
- test_files:
190
- - spec/integration/virtus/attributes/attribute/typecast_spec.rb
191
- - spec/integration/virtus/class_methods/attribute_spec.rb
192
- - spec/integration/virtus/class_methods/attributes_spec.rb
193
- - spec/integration/virtus/class_methods/const_missing_spec.rb
194
- - spec/rcov.opts
195
- - spec/shared/idempotent_method_behaviour.rb
196
- - spec/spec_helper.rb
197
- - spec/unit/shared/attribute.rb
198
- - spec/unit/shared/attribute/accept_options.rb
199
- - spec/unit/shared/attribute/accepted_options.rb
200
- - spec/unit/shared/attribute/complex.rb
201
- - spec/unit/shared/attribute/get.rb
202
- - spec/unit/shared/attribute/options.rb
203
- - spec/unit/shared/attribute/set.rb
204
- - spec/unit/virtus/attribute/array_spec.rb
205
- - spec/unit/virtus/attribute/attribute_spec.rb
206
- - spec/unit/virtus/attribute/boolean_spec.rb
207
- - spec/unit/virtus/attribute/date_spec.rb
208
- - spec/unit/virtus/attribute/date_time_spec.rb
209
- - spec/unit/virtus/attribute/decimal_spec.rb
210
- - spec/unit/virtus/attribute/float_spec.rb
211
- - spec/unit/virtus/attribute/hash_spec.rb
212
- - spec/unit/virtus/attribute/integer_spec.rb
213
- - spec/unit/virtus/attribute/numeric/class_methods/descendants_spec.rb
214
- - spec/unit/virtus/attribute/object/class_methods/descendants_spec.rb
215
- - spec/unit/virtus/attribute/string_spec.rb
216
- - spec/unit/virtus/attribute/time_spec.rb
217
- - spec/unit/virtus/attribute_set/append_spec.rb
218
- - spec/unit/virtus/attribute_set/each_spec.rb
219
- - spec/unit/virtus/attribute_set/element_reference_spec.rb
220
- - spec/unit/virtus/attribute_set/element_set_spec.rb
221
- - spec/unit/virtus/attribute_set/merge_spec.rb
222
- - spec/unit/virtus/attribute_set/parent_spec.rb
223
- - spec/unit/virtus/attribute_set/reset_spec.rb
224
- - spec/unit/virtus/class_methods/attribute_spec.rb
225
- - spec/unit/virtus/class_methods/new_spec.rb
226
- - spec/unit/virtus/descendants_tracker/descendants_spec.rb
227
- - spec/unit/virtus/descendants_tracker/inherited_spec.rb
228
- - spec/unit/virtus/determine_type_spec.rb
229
- - spec/unit/virtus/instance_methods/attributes_spec.rb
230
- - spec/unit/virtus/instance_methods/element_reference_spec.rb
231
- - spec/unit/virtus/instance_methods/element_set_spec.rb
204
+ test_files: []
205
+
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
5
- measurements/
6
- tmp/
7
- profiling/
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Virtus, '.determine_type' do
4
- Virtus::Attribute.descendants.each do |attribute_class|
5
-
6
- context "with class #{attribute_class.inspect}" do
7
- subject { described_class.determine_type(attribute_class) }
8
-
9
- it 'returns the corresponding attribute class' do
10
- should be(attribute_class)
11
- end
12
- end
13
-
14
- primitive = attribute_class.primitive
15
- context "with primitive #{primitive.inspect}" do
16
- subject { described_class.determine_type(primitive) }
17
-
18
- it 'returns the corresponding attribute class' do
19
- should be(attribute_class)
20
- end
21
- end
22
-
23
- suffix = attribute_class.name['Virtus::Attribute::'.length..-1]
24
- context "with string #{suffix.inspect}" do
25
- subject { described_class.determine_type(suffix) }
26
-
27
- it 'returns the corresponding attribute class' do
28
- should be(attribute_class)
29
- end
30
- end
31
- end
32
- end