class2 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Appraisals +11 -0
- data/Changes +10 -0
- data/README.md +5 -3
- data/class2.gemspec +3 -2
- data/gemfiles/as4.gemfile +7 -0
- data/gemfiles/as5.gemfile +7 -0
- data/gemfiles/as6.gemfile +7 -0
- data/lib/class2/autoload/namespaced.rb +1 -1
- data/lib/class2/version.rb +1 -1
- data/lib/class2.rb +8 -6
- metadata +35 -13
- data/.travis.yml +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6bfd5b014d465ba372f6886d798d8a2e68eb233d4906b326302d77dceb331671
|
4
|
+
data.tar.gz: cd6aa6212aab92a1c32f64ef9e17de551cdb4e6ce68293efca155cc649520068
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90dff1bc730f190875bfe3b72c1d8abde282a5a394d3c95ff8760bb79008b32e39c79baca7a3e67b8ae187a9de5bfa87adedc23837850f44cc9b58c049852568
|
7
|
+
data.tar.gz: 27326bddbefad990d43801f49b23885a97fbeda319329959933eaaca8a35d8e6692b5daa03d564795c60d54633703e1f4297b147edb77f68d13b98c9ebc38cf4
|
data/Appraisals
ADDED
data/Changes
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
2024-10-15 v0.6.0
|
2
|
+
--------------------
|
3
|
+
* Bug fix: autoloading in data section with namespace
|
4
|
+
* Add support for Time conversion
|
5
|
+
* Remove use of deprecated Fixnum
|
6
|
+
|
7
|
+
2020-04-24 v0.5.2
|
8
|
+
--------------------
|
9
|
+
* Bug fix: Fix NoMethodError in ActiveSupport 6's Module.parent
|
10
|
+
|
1
11
|
2018-06-26 v0.5.1
|
2
12
|
--------------------
|
3
13
|
* Bug fix: autoload backtrace search "improvemnts"
|
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
Easily create class hierarchies that support nested attributes, type conversion, equality, and more.
|
4
4
|
|
5
|
-
[![Build Status](https://travis-ci.org/sshaw/class2.svg?branch=master)](https://travis-ci.org/sshaw/class2)
|
6
|
-
|
7
5
|
## Usage
|
8
6
|
|
9
7
|
```rb
|
@@ -271,7 +269,6 @@ Now an `ArgumentError` will be raised if anything but `id`, `name`, or
|
|
271
269
|
|
272
270
|
Also see [Customizations](#customizations).
|
273
271
|
|
274
|
-
|
275
272
|
## See Also
|
276
273
|
|
277
274
|
The Perl modules that served as inspiration:
|
@@ -285,6 +282,11 @@ The Perl modules that served as inspiration:
|
|
285
282
|
|
286
283
|
Surely others I cannot remember...
|
287
284
|
|
285
|
+
And these Ruby modules:
|
286
|
+
|
287
|
+
* [`require3`](https://github.com/sshaw/require3)
|
288
|
+
* [`alias2`](https://github.com/sshaw/alias2)
|
289
|
+
|
288
290
|
## Author
|
289
291
|
|
290
292
|
Skye Shaw [sshaw AT gmail.com]
|
data/class2.gemspec
CHANGED
@@ -18,9 +18,10 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "activesupport", ">= 3.2"
|
21
|
+
spec.add_dependency "activesupport", ">= 3.2", "< 7"
|
22
22
|
|
23
|
-
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "bundler"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "appraisal"
|
25
26
|
spec.add_development_dependency "minitest"
|
26
27
|
end
|
data/lib/class2/version.rb
CHANGED
data/lib/class2.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "date"
|
4
|
+
require "time" # for parse()
|
4
5
|
require "json"
|
5
6
|
require "active_support/core_ext/module"
|
6
7
|
require "active_support/inflector"
|
@@ -32,13 +33,13 @@ class Class2
|
|
32
33
|
Hash => lambda { |v| sprintf "%s.respond_to?(:to_h) ? %s.to_h : %s", v, v, v },
|
33
34
|
Integer => lambda { |v| "#{v} && Integer(#{v})" },
|
34
35
|
String => lambda { |v| "#{v} && String(#{v})" },
|
36
|
+
Time => lambda { |v| "#{v} && Time.parse(#{v})" },
|
35
37
|
TrueClass => lambda do |v|
|
36
38
|
sprintf '["1", 1, 1.0, true].freeze.include?(%s.is_a?(String) ? %s.strip : %s)', v, v, v
|
37
39
|
end
|
38
40
|
}
|
39
41
|
|
40
42
|
CONVERSIONS[FalseClass] = CONVERSIONS[TrueClass]
|
41
|
-
CONVERSIONS[Fixnum] = CONVERSIONS[Integer] if defined?(Fixnum)
|
42
43
|
CONVERSIONS.default = lambda { |v| v }
|
43
44
|
|
44
45
|
class << self
|
@@ -58,9 +59,9 @@ class Class2
|
|
58
59
|
nil
|
59
60
|
end
|
60
61
|
|
61
|
-
def autoload(namespace = Object) # :nodoc:
|
62
|
+
def autoload(namespace = Object, stack = nil) # :nodoc:
|
62
63
|
failure = lambda { |message| abort "class2: cannot autoload class definitions: #{message}" }
|
63
|
-
failure["cannot find the right caller"] unless caller.find do |line|
|
64
|
+
failure["cannot find the right caller"] unless (stack || caller).find do |line|
|
64
65
|
# Ignore our autoload file and require()
|
65
66
|
line.index("/class2/autoload.rb:").nil? && line.index("/kernel_require.rb:").nil? && line =~ /(.+):\d+:in\s+`\S/
|
66
67
|
end
|
@@ -250,10 +251,11 @@ class Class2
|
|
250
251
|
|
251
252
|
name = key.to_s.classify
|
252
253
|
|
253
|
-
#
|
254
|
-
|
254
|
+
# parent is deprecated in ActiveSupport 6 and its warning uses Strong#squish! which they don't include!
|
255
|
+
parent = self.class.respond_to?(:module_parent) ? self.class.module_parent : self.class.parent
|
256
|
+
next unless parent.const_defined?(name)
|
255
257
|
|
256
|
-
klass =
|
258
|
+
klass = parent.const_get(name)
|
257
259
|
value = value.is_a?(Hash) ? klass.new(value) : value.map { |v| klass.new(v) }
|
258
260
|
end
|
259
261
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: class2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Skye Shaw
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,20 +27,23 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '3.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: bundler
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
39
|
+
version: '0'
|
34
40
|
type: :development
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - "
|
44
|
+
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
46
|
+
version: '0'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: rake
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +58,20 @@ dependencies:
|
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: '10.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: appraisal
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
55
75
|
- !ruby/object:Gem::Dependency
|
56
76
|
name: minitest
|
57
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +86,7 @@ dependencies:
|
|
66
86
|
- - ">="
|
67
87
|
- !ruby/object:Gem::Version
|
68
88
|
version: '0'
|
69
|
-
description:
|
89
|
+
description:
|
70
90
|
email:
|
71
91
|
- skye.shaw@gmail.com
|
72
92
|
executables: []
|
@@ -74,13 +94,16 @@ extensions: []
|
|
74
94
|
extra_rdoc_files: []
|
75
95
|
files:
|
76
96
|
- ".gitignore"
|
77
|
-
-
|
97
|
+
- Appraisals
|
78
98
|
- Changes
|
79
99
|
- Gemfile
|
80
100
|
- LICENSE.txt
|
81
101
|
- README.md
|
82
102
|
- Rakefile
|
83
103
|
- class2.gemspec
|
104
|
+
- gemfiles/as4.gemfile
|
105
|
+
- gemfiles/as5.gemfile
|
106
|
+
- gemfiles/as6.gemfile
|
84
107
|
- lib/class2.rb
|
85
108
|
- lib/class2/autoload.rb
|
86
109
|
- lib/class2/autoload/namespaced.rb
|
@@ -89,7 +112,7 @@ homepage: https://github.com/sshaw/class2
|
|
89
112
|
licenses:
|
90
113
|
- MIT
|
91
114
|
metadata: {}
|
92
|
-
post_install_message:
|
115
|
+
post_install_message:
|
93
116
|
rdoc_options: []
|
94
117
|
require_paths:
|
95
118
|
- lib
|
@@ -104,9 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
127
|
- !ruby/object:Gem::Version
|
105
128
|
version: '0'
|
106
129
|
requirements: []
|
107
|
-
|
108
|
-
|
109
|
-
signing_key:
|
130
|
+
rubygems_version: 3.3.27
|
131
|
+
signing_key:
|
110
132
|
specification_version: 4
|
111
133
|
summary: Easily create hierarchies of classes that support nested attributes, type
|
112
134
|
conversion, equality, and more.
|