class2 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49d91ca721e5cefa4ee9663e3e4ca8edbb584315300888561fa2b70e49eb7923
4
- data.tar.gz: 486025e1a89a034b49dc9a5c243d5bae341e4880d10d2a204e07898acd5a0e21
3
+ metadata.gz: 6bfd5b014d465ba372f6886d798d8a2e68eb233d4906b326302d77dceb331671
4
+ data.tar.gz: cd6aa6212aab92a1c32f64ef9e17de551cdb4e6ce68293efca155cc649520068
5
5
  SHA512:
6
- metadata.gz: 9d85ef46fefd99c440a1fe0aa92724a3b217c8d14a6473d2ff025705604a40e40f234a0d0cbc730921301783d28f6ac5cfa2435bf631994bfc714fe649907d97
7
- data.tar.gz: 46e2460f0924ce6c17413d7a15b0c6fc8685b0784e87a173ab6d51464a1b9a535e4d82f742c3c8b7c263a5ec7afe67c8514a12d7938dae549fa531c87b56142a
6
+ metadata.gz: 90dff1bc730f190875bfe3b72c1d8abde282a5a394d3c95ff8760bb79008b32e39c79baca7a3e67b8ae187a9de5bfa87adedc23837850f44cc9b58c049852568
7
+ data.tar.gz: 27326bddbefad990d43801f49b23885a97fbeda319329959933eaaca8a35d8e6692b5daa03d564795c60d54633703e1f4297b147edb77f68d13b98c9ebc38cf4
data/Changes CHANGED
@@ -1,3 +1,9 @@
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
+
1
7
  2020-04-24 v0.5.2
2
8
  --------------------
3
9
  * Bug fix: Fix NoMethodError in ActiveSupport 6's Module.parent
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
@@ -6,4 +6,4 @@ end
6
6
 
7
7
  source = $1
8
8
  namespace = source =~ %r{/lib/(.+?)(?:\.rb)?\z} ? $1 : File.basename(source, File.extname(source))
9
- Class2.autoload(namespace.camelize)
9
+ Class2.autoload(namespace.camelize, caller.unshift(caller[0]))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Class2
4
- VERSION = "0.5.2"
4
+ VERSION = "0.6.0"
5
5
  end
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]
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
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.5.2
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: 2020-04-25 00:00:00.000000000 Z
11
+ date: 2024-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -86,7 +86,7 @@ dependencies:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
- description:
89
+ description:
90
90
  email:
91
91
  - skye.shaw@gmail.com
92
92
  executables: []
@@ -94,7 +94,6 @@ extensions: []
94
94
  extra_rdoc_files: []
95
95
  files:
96
96
  - ".gitignore"
97
- - ".travis.yml"
98
97
  - Appraisals
99
98
  - Changes
100
99
  - Gemfile
@@ -113,7 +112,7 @@ homepage: https://github.com/sshaw/class2
113
112
  licenses:
114
113
  - MIT
115
114
  metadata: {}
116
- post_install_message:
115
+ post_install_message:
117
116
  rdoc_options: []
118
117
  require_paths:
119
118
  - lib
@@ -128,9 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
127
  - !ruby/object:Gem::Version
129
128
  version: '0'
130
129
  requirements: []
131
- rubyforge_project:
132
- rubygems_version: 2.7.6
133
- signing_key:
130
+ rubygems_version: 3.3.27
131
+ signing_key:
134
132
  specification_version: 4
135
133
  summary: Easily create hierarchies of classes that support nested attributes, type
136
134
  conversion, equality, and more.
data/.travis.yml DELETED
@@ -1,30 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - jruby-9
6
- - 2.3
7
- - 2.4
8
- - 2.5
9
- - 2.6
10
- - 2.7
11
-
12
- before_install:
13
- - gem install bundler
14
-
15
- gemfile:
16
- - gemfiles/as4.gemfile
17
- - gemfiles/as5.gemfile
18
- - gemfiles/as6.gemfile
19
-
20
- matrix:
21
- exclude:
22
- - rvm: 2.3
23
- gemfile: gemfiles/as6.gemfile
24
- - rvm: 2.4
25
- gemfile: gemfiles/as6.gemfile
26
- - rvm: 2.7
27
- gemfile: gemfiles/as4.gemfile
28
-
29
- notifications:
30
- email: false