virtus 0.0.10 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +33 -7
- data/.travis.yml +4 -74
- data/Changelog.md +11 -2
- data/Gemfile +10 -9
- data/README.md +85 -1
- data/TODO +18 -0
- data/config/flay.yml +2 -2
- data/config/flog.yml +1 -1
- data/config/roodi.yml +3 -3
- data/config/site.reek +8 -3
- data/lib/virtus.rb +5 -0
- data/lib/virtus/attribute.rb +137 -30
- data/lib/virtus/attribute/array.rb +17 -1
- data/lib/virtus/attribute/boolean.rb +8 -13
- data/lib/virtus/attribute/collection.rb +96 -0
- data/lib/virtus/attribute/default_value.rb +11 -7
- data/lib/virtus/attribute/embedded_value.rb +70 -0
- data/lib/virtus/attribute/set.rb +25 -0
- data/lib/virtus/attribute_set.rb +18 -16
- data/lib/virtus/attributes_accessor.rb +66 -0
- data/lib/virtus/class_methods.rb +50 -28
- data/lib/virtus/coercion/array.rb +23 -0
- data/lib/virtus/coercion/string.rb +10 -4
- data/lib/virtus/instance_methods.rb +38 -31
- data/lib/virtus/support/options.rb +6 -8
- data/lib/virtus/support/type_lookup.rb +4 -11
- data/lib/virtus/version.rb +1 -1
- data/spec/integration/collection_member_coercion_spec.rb +75 -0
- data/spec/integration/custom_attributes_spec.rb +49 -0
- data/spec/integration/default_values_spec.rb +32 -0
- data/spec/integration/defining_attributes_spec.rb +79 -0
- data/spec/integration/embedded_value_spec.rb +50 -0
- data/spec/integration/overriding_virtus_spec.rb +46 -0
- data/spec/integration/virtus/instance_level_attributes_spec.rb +23 -0
- data/spec/rcov.opts +1 -0
- data/spec/shared/constants_helpers.rb +9 -0
- data/spec/shared/options_class_method.rb +19 -0
- data/spec/spec_helper.rb +20 -7
- data/spec/unit/virtus/attribute/array/coerce_spec.rb +13 -0
- data/spec/unit/virtus/attribute/boolean/coerce_spec.rb +85 -0
- data/spec/unit/virtus/attribute/boolean/define_reader_method_spec.rb +15 -0
- data/spec/unit/virtus/attribute/boolean/value_coerced_spec.rb +97 -0
- data/spec/unit/virtus/attribute/boolean_spec.rb +2 -81
- data/spec/unit/virtus/attribute/class/coerce_spec.rb +13 -0
- data/spec/unit/virtus/attribute/class_methods/accessor_spec.rb +12 -0
- data/spec/unit/virtus/attribute/class_methods/build_spec.rb +37 -0
- data/spec/unit/virtus/attribute/class_methods/coercion_method_spec.rb +9 -0
- data/spec/unit/virtus/attribute/class_methods/default_spec.rb +9 -0
- data/spec/unit/virtus/attribute/class_methods/determine_type_spec.rb +31 -1
- data/spec/unit/virtus/attribute/class_methods/merge_options_spec.rb +11 -0
- data/spec/unit/virtus/attribute/class_methods/primitive_spec.rb +9 -0
- data/spec/unit/virtus/attribute/class_methods/reader_spec.rb +9 -0
- data/spec/unit/virtus/attribute/class_methods/writer_spec.rb +9 -0
- data/spec/unit/virtus/attribute/coerce_spec.rb +30 -0
- data/spec/unit/virtus/attribute/coercion_method_spec.rb +12 -0
- data/spec/unit/virtus/attribute/collection/class_methods/merge_options_spec.rb +40 -0
- data/spec/unit/virtus/attribute/collection/coerce_spec.rb +26 -0
- data/spec/unit/virtus/attribute/date/coerce_spec.rb +47 -0
- data/spec/unit/virtus/attribute/date/value_coerced_spec.rb +46 -0
- data/spec/unit/virtus/attribute/date_time/coerce_spec.rb +68 -0
- data/spec/unit/virtus/attribute/decimal/coerce_spec.rb +117 -0
- data/spec/unit/virtus/attribute/default_spec.rb +32 -0
- data/spec/unit/virtus/attribute/default_value/attribute_spec.rb +11 -0
- data/spec/unit/virtus/attribute/default_value/class_methods/new_spec.rb +4 -2
- data/spec/unit/virtus/attribute/default_value/evaluate_spec.rb +51 -0
- data/spec/unit/virtus/attribute/default_value/instance_methods/evaluate_spec.rb +9 -6
- data/spec/unit/virtus/attribute/default_value/value_spec.rb +11 -0
- data/spec/unit/virtus/attribute/define_accessor_methods_spec.rb +26 -0
- data/spec/unit/virtus/attribute/define_reader_method_spec.rb +24 -0
- data/spec/unit/virtus/attribute/define_writer_method_spec.rb +24 -0
- data/spec/unit/virtus/attribute/embedded_value/class_methods/merge_options_spec.rb +17 -0
- data/spec/unit/virtus/attribute/embedded_value/coerce_spec.rb +50 -0
- data/spec/unit/virtus/attribute/float/coerce_spec.rb +117 -0
- data/spec/unit/virtus/attribute/get_spec.rb +80 -0
- data/spec/unit/virtus/attribute/inspect_spec.rb +27 -0
- data/spec/unit/virtus/attribute/instance_variable_name_spec.rb +12 -0
- data/spec/unit/virtus/attribute/integer/coerce_spec.rb +105 -0
- data/spec/unit/virtus/attribute/name_spec.rb +12 -0
- data/spec/unit/virtus/attribute/numeric/class_methods/descendants_spec.rb +1 -1
- data/spec/unit/virtus/attribute/numeric/class_methods/max_spec.rb +9 -0
- data/spec/unit/virtus/attribute/numeric/class_methods/min_spec.rb +9 -0
- data/spec/unit/virtus/attribute/object/class_methods/descendants_spec.rb +9 -7
- data/spec/unit/virtus/attribute/options_spec.rb +14 -0
- data/spec/unit/virtus/attribute/public_reader_spec.rb +24 -0
- data/spec/unit/virtus/attribute/public_writer_spec.rb +24 -0
- data/spec/unit/virtus/attribute/reader_visibility_spec.rb +24 -0
- data/spec/unit/virtus/attribute/set/coerce_spec.rb +13 -0
- data/spec/unit/virtus/attribute/set_spec.rb +49 -0
- data/spec/unit/virtus/attribute/string/coerce_spec.rb +11 -0
- data/spec/unit/virtus/attribute/time/coerce_spec.rb +67 -0
- data/spec/unit/virtus/attribute/value_coerced_spec.rb +19 -0
- data/spec/unit/virtus/attribute/writer_visibility_spec.rb +24 -0
- data/spec/unit/virtus/attribute_set/append_spec.rb +12 -0
- data/spec/unit/virtus/attribute_set/element_reference_spec.rb +4 -0
- data/spec/unit/virtus/attribute_set/element_set_spec.rb +29 -9
- data/spec/unit/virtus/attributes_accessor/inspect_spec.rb +9 -0
- data/spec/unit/virtus/class_methods/attribute_spec.rb +23 -5
- data/spec/unit/virtus/class_methods/attributes_spec.rb +3 -5
- data/spec/unit/virtus/class_methods/const_missing_spec.rb +27 -0
- data/spec/unit/virtus/class_methods/inherited_spec.rb +21 -0
- data/spec/unit/virtus/coercion/array/to_set_spec.rb +12 -0
- data/spec/unit/virtus/coercion/date/class_methods/to_date_spec.rb +10 -0
- data/spec/unit/virtus/coercion/date_time/class_methods/to_datetime_spec.rb +10 -0
- data/spec/unit/virtus/coercion/hash/class_methods/to_date_spec.rb +10 -3
- data/spec/unit/virtus/coercion/hash/class_methods/to_datetime_spec.rb +10 -3
- data/spec/unit/virtus/coercion/hash/class_methods/to_time_spec.rb +10 -3
- data/spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb +8 -8
- data/spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb +2 -2
- data/spec/unit/virtus/coercion/string/class_methods/to_constant_spec.rb +1 -1
- data/spec/unit/virtus/coercion/string/class_methods/to_date_spec.rb +1 -1
- data/spec/unit/virtus/coercion/string/class_methods/to_datetime_spec.rb +13 -13
- data/spec/unit/virtus/coercion/string/class_methods/to_decimal_spec.rb +25 -1
- data/spec/unit/virtus/coercion/string/class_methods/to_float_spec.rb +25 -1
- data/spec/unit/virtus/coercion/string/class_methods/to_integer_spec.rb +30 -1
- data/spec/unit/virtus/coercion/string/class_methods/to_time_spec.rb +13 -13
- data/spec/unit/virtus/coercion/time/class_methods/to_time_spec.rb +10 -0
- data/spec/unit/virtus/coercion/true_class/class_methods/to_string_spec.rb +1 -1
- data/spec/unit/virtus/instance_methods/attributes_spec.rb +77 -20
- data/spec/unit/virtus/instance_methods/element_reference_spec.rb +1 -1
- data/spec/unit/virtus/instance_methods/element_set_spec.rb +2 -2
- data/spec/unit/virtus/instance_methods/to_hash_spec.rb +23 -0
- data/spec/unit/virtus/options/accept_options_spec.rb +10 -11
- data/spec/unit/virtus/options/accepted_options_spec.rb +1 -1
- data/spec/unit/virtus/options/options_spec.rb +27 -4
- data/tasks/metrics/ci.rake +2 -1
- data/tasks/metrics/heckle.rake +207 -0
- data/tasks/spec.rake +14 -7
- data/virtus.gemspec +1 -1
- metadata +111 -97
- data/VERSION +0 -1
- data/examples/custom_coercion_spec.rb +0 -50
- data/examples/default_values_spec.rb +0 -21
- data/examples/override_attribute_methods_spec.rb +0 -40
- data/spec/integration/virtus/attributes/attribute/set_spec.rb +0 -36
- data/spec/integration/virtus/class_methods/attribute_spec.rb +0 -82
- data/spec/integration/virtus/class_methods/attributes_spec.rb +0 -22
- data/spec/integration/virtus/class_methods/const_missing_spec.rb +0 -44
- data/spec/unit/shared/attribute.rb +0 -7
- data/spec/unit/shared/attribute/accept_options.rb +0 -37
- data/spec/unit/shared/attribute/accepted_options.rb +0 -5
- data/spec/unit/shared/attribute/get.rb +0 -44
- data/spec/unit/shared/attribute/inspect.rb +0 -7
- data/spec/unit/shared/attribute/set.rb +0 -37
- data/spec/unit/virtus/attribute/array_spec.rb +0 -24
- data/spec/unit/virtus/attribute/class_spec.rb +0 -24
- data/spec/unit/virtus/attribute/date_spec.rb +0 -59
- data/spec/unit/virtus/attribute/date_time_spec.rb +0 -87
- data/spec/unit/virtus/attribute/decimal_spec.rb +0 -109
- data/spec/unit/virtus/attribute/float_spec.rb +0 -109
- data/spec/unit/virtus/attribute/hash_spec.rb +0 -11
- data/spec/unit/virtus/attribute/integer_spec.rb +0 -99
- data/spec/unit/virtus/attribute/string_spec.rb +0 -21
- data/spec/unit/virtus/attribute/time_spec.rb +0 -82
- data/spec/unit/virtus/class_methods/new_spec.rb +0 -41
data/tasks/spec.rake
CHANGED
@@ -1,14 +1,21 @@
|
|
1
1
|
begin
|
2
|
-
require 'rspec/core/rake_task'
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
begin
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
rescue LoadError
|
6
|
+
require 'spec/rake/spectask'
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
module RSpec
|
9
|
+
module Core
|
10
|
+
RakeTask = Spec::Rake::SpecTask
|
11
|
+
end
|
10
12
|
end
|
13
|
+
end
|
11
14
|
|
15
|
+
desc 'run all specs'
|
16
|
+
task :spec => %w[ spec:unit spec:integration ]
|
17
|
+
|
18
|
+
namespace :spec do
|
12
19
|
RSpec::Core::RakeTask.new(:integration) do |t|
|
13
20
|
t.pattern = 'spec/integration/**/*_spec.rb'
|
14
21
|
end
|
@@ -26,7 +33,7 @@ end
|
|
26
33
|
begin
|
27
34
|
desc "Generate code coverage"
|
28
35
|
RSpec::Core::RakeTask.new(:rcov) do |t|
|
29
|
-
t.rcov
|
36
|
+
t.rcov = true
|
30
37
|
t.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
|
31
38
|
end
|
32
39
|
rescue LoadError
|
data/virtus.gemspec
CHANGED
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
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 10
|
10
|
-
version: 0.0.10
|
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
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-11-21 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rake
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70295232216940 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 63
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 9
|
32
|
-
- 2
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 0.9.2
|
34
22
|
type: :development
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: backports
|
38
23
|
prerelease: false
|
39
|
-
|
24
|
+
version_requirements: *70295232216940
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: backports
|
27
|
+
requirement: &70295232216140 !ruby/object:Gem::Requirement
|
40
28
|
none: false
|
41
|
-
requirements:
|
29
|
+
requirements:
|
42
30
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
hash: 3
|
45
|
-
segments:
|
46
|
-
- 2
|
47
|
-
- 3
|
48
|
-
- 0
|
31
|
+
- !ruby/object:Gem::Version
|
49
32
|
version: 2.3.0
|
50
33
|
type: :development
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: rspec
|
54
34
|
prerelease: false
|
55
|
-
|
35
|
+
version_requirements: *70295232216140
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70295232215500 !ruby/object:Gem::Requirement
|
56
39
|
none: false
|
57
|
-
requirements:
|
40
|
+
requirements:
|
58
41
|
- - ~>
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
segments:
|
62
|
-
- 2
|
63
|
-
- 6
|
64
|
-
- 0
|
65
|
-
version: 2.6.0
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.3.2
|
66
44
|
type: :development
|
67
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70295232215500
|
68
47
|
description: Attributes on Steroids for Plain Old Ruby Objects
|
69
|
-
email:
|
48
|
+
email:
|
70
49
|
- piotr.solnica@gmail.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
|
- .gitignore
|
81
58
|
- .rvmrc
|
82
59
|
- .travis.yml
|
@@ -87,34 +64,35 @@ files:
|
|
87
64
|
- README.md
|
88
65
|
- Rakefile
|
89
66
|
- TODO
|
90
|
-
- VERSION
|
91
67
|
- config/flay.yml
|
92
68
|
- config/flog.yml
|
93
69
|
- config/roodi.yml
|
94
70
|
- config/site.reek
|
95
71
|
- config/yardstick.yml
|
96
|
-
- examples/custom_coercion_spec.rb
|
97
|
-
- examples/default_values_spec.rb
|
98
|
-
- examples/override_attribute_methods_spec.rb
|
99
72
|
- lib/virtus.rb
|
100
73
|
- lib/virtus/attribute.rb
|
101
74
|
- lib/virtus/attribute/array.rb
|
102
75
|
- lib/virtus/attribute/boolean.rb
|
103
76
|
- lib/virtus/attribute/class.rb
|
77
|
+
- lib/virtus/attribute/collection.rb
|
104
78
|
- lib/virtus/attribute/date.rb
|
105
79
|
- lib/virtus/attribute/date_time.rb
|
106
80
|
- lib/virtus/attribute/decimal.rb
|
107
81
|
- lib/virtus/attribute/default_value.rb
|
82
|
+
- lib/virtus/attribute/embedded_value.rb
|
108
83
|
- lib/virtus/attribute/float.rb
|
109
84
|
- lib/virtus/attribute/hash.rb
|
110
85
|
- lib/virtus/attribute/integer.rb
|
111
86
|
- lib/virtus/attribute/numeric.rb
|
112
87
|
- lib/virtus/attribute/object.rb
|
88
|
+
- lib/virtus/attribute/set.rb
|
113
89
|
- lib/virtus/attribute/string.rb
|
114
90
|
- lib/virtus/attribute/time.rb
|
115
91
|
- lib/virtus/attribute_set.rb
|
92
|
+
- lib/virtus/attributes_accessor.rb
|
116
93
|
- lib/virtus/class_methods.rb
|
117
94
|
- lib/virtus/coercion.rb
|
95
|
+
- lib/virtus/coercion/array.rb
|
118
96
|
- lib/virtus/coercion/date.rb
|
119
97
|
- lib/virtus/coercion/date_time.rb
|
120
98
|
- lib/virtus/coercion/decimal.rb
|
@@ -134,35 +112,72 @@ files:
|
|
134
112
|
- lib/virtus/support/options.rb
|
135
113
|
- lib/virtus/support/type_lookup.rb
|
136
114
|
- lib/virtus/version.rb
|
137
|
-
- spec/integration/
|
138
|
-
- spec/integration/
|
139
|
-
- spec/integration/
|
140
|
-
- spec/integration/
|
115
|
+
- spec/integration/collection_member_coercion_spec.rb
|
116
|
+
- spec/integration/custom_attributes_spec.rb
|
117
|
+
- spec/integration/default_values_spec.rb
|
118
|
+
- spec/integration/defining_attributes_spec.rb
|
119
|
+
- spec/integration/embedded_value_spec.rb
|
120
|
+
- spec/integration/overriding_virtus_spec.rb
|
121
|
+
- spec/integration/virtus/instance_level_attributes_spec.rb
|
141
122
|
- spec/rcov.opts
|
123
|
+
- spec/shared/constants_helpers.rb
|
142
124
|
- spec/shared/idempotent_method_behaviour.rb
|
125
|
+
- spec/shared/options_class_method.rb
|
143
126
|
- spec/spec_helper.rb
|
144
|
-
- spec/unit/
|
145
|
-
- spec/unit/
|
146
|
-
- spec/unit/
|
147
|
-
- spec/unit/
|
148
|
-
- spec/unit/shared/attribute/inspect.rb
|
149
|
-
- spec/unit/shared/attribute/set.rb
|
150
|
-
- spec/unit/virtus/attribute/array_spec.rb
|
127
|
+
- spec/unit/virtus/attribute/array/coerce_spec.rb
|
128
|
+
- spec/unit/virtus/attribute/boolean/coerce_spec.rb
|
129
|
+
- spec/unit/virtus/attribute/boolean/define_reader_method_spec.rb
|
130
|
+
- spec/unit/virtus/attribute/boolean/value_coerced_spec.rb
|
151
131
|
- spec/unit/virtus/attribute/boolean_spec.rb
|
132
|
+
- spec/unit/virtus/attribute/class/coerce_spec.rb
|
133
|
+
- spec/unit/virtus/attribute/class_methods/accessor_spec.rb
|
134
|
+
- spec/unit/virtus/attribute/class_methods/build_spec.rb
|
135
|
+
- spec/unit/virtus/attribute/class_methods/coercion_method_spec.rb
|
136
|
+
- spec/unit/virtus/attribute/class_methods/default_spec.rb
|
152
137
|
- spec/unit/virtus/attribute/class_methods/determine_type_spec.rb
|
153
|
-
- spec/unit/virtus/attribute/
|
154
|
-
- spec/unit/virtus/attribute/
|
155
|
-
- spec/unit/virtus/attribute/
|
156
|
-
- spec/unit/virtus/attribute/
|
138
|
+
- spec/unit/virtus/attribute/class_methods/merge_options_spec.rb
|
139
|
+
- spec/unit/virtus/attribute/class_methods/primitive_spec.rb
|
140
|
+
- spec/unit/virtus/attribute/class_methods/reader_spec.rb
|
141
|
+
- spec/unit/virtus/attribute/class_methods/writer_spec.rb
|
142
|
+
- spec/unit/virtus/attribute/coerce_spec.rb
|
143
|
+
- spec/unit/virtus/attribute/coercion_method_spec.rb
|
144
|
+
- spec/unit/virtus/attribute/collection/class_methods/merge_options_spec.rb
|
145
|
+
- spec/unit/virtus/attribute/collection/coerce_spec.rb
|
146
|
+
- spec/unit/virtus/attribute/date/coerce_spec.rb
|
147
|
+
- spec/unit/virtus/attribute/date/value_coerced_spec.rb
|
148
|
+
- spec/unit/virtus/attribute/date_time/coerce_spec.rb
|
149
|
+
- spec/unit/virtus/attribute/decimal/coerce_spec.rb
|
150
|
+
- spec/unit/virtus/attribute/default_spec.rb
|
151
|
+
- spec/unit/virtus/attribute/default_value/attribute_spec.rb
|
157
152
|
- spec/unit/virtus/attribute/default_value/class_methods/new_spec.rb
|
153
|
+
- spec/unit/virtus/attribute/default_value/evaluate_spec.rb
|
158
154
|
- spec/unit/virtus/attribute/default_value/instance_methods/evaluate_spec.rb
|
159
|
-
- spec/unit/virtus/attribute/
|
160
|
-
- spec/unit/virtus/attribute/
|
161
|
-
- spec/unit/virtus/attribute/
|
155
|
+
- spec/unit/virtus/attribute/default_value/value_spec.rb
|
156
|
+
- spec/unit/virtus/attribute/define_accessor_methods_spec.rb
|
157
|
+
- spec/unit/virtus/attribute/define_reader_method_spec.rb
|
158
|
+
- spec/unit/virtus/attribute/define_writer_method_spec.rb
|
159
|
+
- spec/unit/virtus/attribute/embedded_value/class_methods/merge_options_spec.rb
|
160
|
+
- spec/unit/virtus/attribute/embedded_value/coerce_spec.rb
|
161
|
+
- spec/unit/virtus/attribute/float/coerce_spec.rb
|
162
|
+
- spec/unit/virtus/attribute/get_spec.rb
|
163
|
+
- spec/unit/virtus/attribute/inspect_spec.rb
|
164
|
+
- spec/unit/virtus/attribute/instance_variable_name_spec.rb
|
165
|
+
- spec/unit/virtus/attribute/integer/coerce_spec.rb
|
166
|
+
- spec/unit/virtus/attribute/name_spec.rb
|
162
167
|
- spec/unit/virtus/attribute/numeric/class_methods/descendants_spec.rb
|
168
|
+
- spec/unit/virtus/attribute/numeric/class_methods/max_spec.rb
|
169
|
+
- spec/unit/virtus/attribute/numeric/class_methods/min_spec.rb
|
163
170
|
- spec/unit/virtus/attribute/object/class_methods/descendants_spec.rb
|
164
|
-
- spec/unit/virtus/attribute/
|
165
|
-
- spec/unit/virtus/attribute/
|
171
|
+
- spec/unit/virtus/attribute/options_spec.rb
|
172
|
+
- spec/unit/virtus/attribute/public_reader_spec.rb
|
173
|
+
- spec/unit/virtus/attribute/public_writer_spec.rb
|
174
|
+
- spec/unit/virtus/attribute/reader_visibility_spec.rb
|
175
|
+
- spec/unit/virtus/attribute/set/coerce_spec.rb
|
176
|
+
- spec/unit/virtus/attribute/set_spec.rb
|
177
|
+
- spec/unit/virtus/attribute/string/coerce_spec.rb
|
178
|
+
- spec/unit/virtus/attribute/time/coerce_spec.rb
|
179
|
+
- spec/unit/virtus/attribute/value_coerced_spec.rb
|
180
|
+
- spec/unit/virtus/attribute/writer_visibility_spec.rb
|
166
181
|
- spec/unit/virtus/attribute_set/append_spec.rb
|
167
182
|
- spec/unit/virtus/attribute_set/each_spec.rb
|
168
183
|
- spec/unit/virtus/attribute_set/element_reference_spec.rb
|
@@ -170,14 +185,19 @@ files:
|
|
170
185
|
- spec/unit/virtus/attribute_set/merge_spec.rb
|
171
186
|
- spec/unit/virtus/attribute_set/parent_spec.rb
|
172
187
|
- spec/unit/virtus/attribute_set/reset_spec.rb
|
188
|
+
- spec/unit/virtus/attributes_accessor/inspect_spec.rb
|
173
189
|
- spec/unit/virtus/class_methods/attribute_spec.rb
|
174
190
|
- spec/unit/virtus/class_methods/attributes_spec.rb
|
175
|
-
- spec/unit/virtus/class_methods/
|
191
|
+
- spec/unit/virtus/class_methods/const_missing_spec.rb
|
192
|
+
- spec/unit/virtus/class_methods/inherited_spec.rb
|
193
|
+
- spec/unit/virtus/coercion/array/to_set_spec.rb
|
176
194
|
- spec/unit/virtus/coercion/class_name_reference_spec.rb
|
195
|
+
- spec/unit/virtus/coercion/date/class_methods/to_date_spec.rb
|
177
196
|
- spec/unit/virtus/coercion/date/class_methods/to_datetime_spec.rb
|
178
197
|
- spec/unit/virtus/coercion/date/class_methods/to_string_spec.rb
|
179
198
|
- spec/unit/virtus/coercion/date/class_methods/to_time_spec.rb
|
180
199
|
- spec/unit/virtus/coercion/date_time/class_methods/to_date_spec.rb
|
200
|
+
- spec/unit/virtus/coercion/date_time/class_methods/to_datetime_spec.rb
|
181
201
|
- spec/unit/virtus/coercion/date_time/class_methods/to_string_spec.rb
|
182
202
|
- spec/unit/virtus/coercion/date_time/class_methods/to_time_spec.rb
|
183
203
|
- spec/unit/virtus/coercion/decimal/class_methods/to_float_spec.rb
|
@@ -205,12 +225,14 @@ files:
|
|
205
225
|
- spec/unit/virtus/coercion/string/class_methods/to_integer_spec.rb
|
206
226
|
- spec/unit/virtus/coercion/string/class_methods/to_time_spec.rb
|
207
227
|
- spec/unit/virtus/coercion/symbol/class_methods/to_string_spec.rb
|
228
|
+
- spec/unit/virtus/coercion/time/class_methods/to_time_spec.rb
|
208
229
|
- spec/unit/virtus/coercion/true_class/class_methods/to_string_spec.rb
|
209
230
|
- spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
|
210
231
|
- spec/unit/virtus/descendants_tracker/descendants_spec.rb
|
211
232
|
- spec/unit/virtus/instance_methods/attributes_spec.rb
|
212
233
|
- spec/unit/virtus/instance_methods/element_reference_spec.rb
|
213
234
|
- spec/unit/virtus/instance_methods/element_set_spec.rb
|
235
|
+
- spec/unit/virtus/instance_methods/to_hash_spec.rb
|
214
236
|
- spec/unit/virtus/options/accept_options_spec.rb
|
215
237
|
- spec/unit/virtus/options/accepted_options_spec.rb
|
216
238
|
- spec/unit/virtus/options/options_spec.rb
|
@@ -219,6 +241,7 @@ files:
|
|
219
241
|
- tasks/metrics/ci.rake
|
220
242
|
- tasks/metrics/flay.rake
|
221
243
|
- tasks/metrics/flog.rake
|
244
|
+
- tasks/metrics/heckle.rake
|
222
245
|
- tasks/metrics/metric_fu.rake
|
223
246
|
- tasks/metrics/reek.rake
|
224
247
|
- tasks/metrics/roodi.rake
|
@@ -228,36 +251,27 @@ files:
|
|
228
251
|
- virtus.gemspec
|
229
252
|
homepage: https://github.com/solnic/virtus
|
230
253
|
licenses: []
|
231
|
-
|
232
254
|
post_install_message:
|
233
255
|
rdoc_options: []
|
234
|
-
|
235
|
-
require_paths:
|
256
|
+
require_paths:
|
236
257
|
- lib
|
237
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
258
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
238
259
|
none: false
|
239
|
-
requirements:
|
240
|
-
- -
|
241
|
-
- !ruby/object:Gem::Version
|
242
|
-
|
243
|
-
|
244
|
-
- 0
|
245
|
-
version: "0"
|
246
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
260
|
+
requirements:
|
261
|
+
- - ! '>='
|
262
|
+
- !ruby/object:Gem::Version
|
263
|
+
version: '0'
|
264
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
247
265
|
none: false
|
248
|
-
requirements:
|
249
|
-
- -
|
250
|
-
- !ruby/object:Gem::Version
|
251
|
-
|
252
|
-
segments:
|
253
|
-
- 0
|
254
|
-
version: "0"
|
266
|
+
requirements:
|
267
|
+
- - ! '>='
|
268
|
+
- !ruby/object:Gem::Version
|
269
|
+
version: '0'
|
255
270
|
requirements: []
|
256
|
-
|
257
271
|
rubyforge_project:
|
258
272
|
rubygems_version: 1.8.11
|
259
273
|
signing_key:
|
260
274
|
specification_version: 3
|
261
275
|
summary: Attributes on Steroids for Plain Old Ruby Objects
|
262
276
|
test_files: []
|
263
|
-
|
277
|
+
has_rdoc:
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.9
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require './spec/spec_helper'
|
2
|
-
|
3
|
-
class Md5 < Virtus::Attribute::Object
|
4
|
-
primitive String
|
5
|
-
coercion_method :to_md5
|
6
|
-
end
|
7
|
-
|
8
|
-
module Virtus
|
9
|
-
class Coercion
|
10
|
-
class String < Virtus::Coercion::Object
|
11
|
-
def self.to_md5(value)
|
12
|
-
Digest::MD5.hexdigest(value)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class User
|
19
|
-
include Virtus
|
20
|
-
|
21
|
-
attribute :name, String
|
22
|
-
attribute :password, Md5
|
23
|
-
end
|
24
|
-
|
25
|
-
describe User do
|
26
|
-
it { should respond_to(:name) }
|
27
|
-
it { should respond_to(:name=) }
|
28
|
-
it { should respond_to(:password) }
|
29
|
-
it { should respond_to(:password=) }
|
30
|
-
|
31
|
-
describe '#name=' do
|
32
|
-
let(:value) { 'Piotr' }
|
33
|
-
|
34
|
-
before do
|
35
|
-
subject.name = value
|
36
|
-
end
|
37
|
-
|
38
|
-
its(:name) { should == value }
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#password=' do
|
42
|
-
let(:value) { 'foobar' }
|
43
|
-
|
44
|
-
before do
|
45
|
-
subject.password = value
|
46
|
-
end
|
47
|
-
|
48
|
-
its(:password) { should == Virtus::Coercion::String.to_md5(value) }
|
49
|
-
end
|
50
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require './spec/spec_helper'
|
2
|
-
|
3
|
-
class Page
|
4
|
-
include Virtus
|
5
|
-
|
6
|
-
attribute :title, String
|
7
|
-
attribute :slug, String, :default => lambda { |post, attribute| post.title.downcase.gsub(' ', '-') }
|
8
|
-
attribute :view_count, Integer, :default => 0
|
9
|
-
end
|
10
|
-
|
11
|
-
describe Page do
|
12
|
-
describe '#slug' do
|
13
|
-
before { subject.title = 'Virtus Is Awesome' }
|
14
|
-
|
15
|
-
its(:slug) { should eql('virtus-is-awesome') }
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#views_count' do
|
19
|
-
its(:view_count) { should eql(0) }
|
20
|
-
end
|
21
|
-
end
|