attribute_struct 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTING.md +10 -14
- data/LICENSE +2 -2
- data/attribute_struct.gemspec +1 -2
- data/lib/attribute_struct/attribute_hash.rb +0 -2
- data/lib/attribute_struct/attribute_struct.rb +8 -6
- data/lib/attribute_struct/augmented.rb +0 -2
- data/lib/attribute_struct/irb_compat.rb +10 -8
- data/lib/attribute_struct/monkey_camels.rb +19 -10
- data/lib/attribute_struct/version.rb +1 -1
- data/lib/attribute_struct.rb +1 -5
- metadata +5 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a88c87931988bfa2b2e576583dbfb8ee6a8b1c5091cb1c62b58f39dddf7f89ec
|
4
|
+
data.tar.gz: 743c6adaaa2992229bcc42e5daf0cebd9a59c91a12f3f83c06a7a4eba672e02f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8df0dcb1c017726e1a2a3b698979fb1e257df3b18e02a7812a27ba7c7e7cfb50fe1fdbdc20625497d4b6eab339ef793d086c70504cc4ec3b7051cac9b75cdb1
|
7
|
+
data.tar.gz: fa93e5e6850bd7d3cb516b6d6e6ca770a6660b561a13c5abf0da15df5b86a3c81ca7c0644c84fcc07cea100225b80c686002a00d5051057da9981633fb5c4c53
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -1,22 +1,18 @@
|
|
1
1
|
# Contributing
|
2
2
|
|
3
|
-
##
|
3
|
+
## Fixes
|
4
4
|
|
5
|
-
|
5
|
+
Have a fix to some bug you want to submit? Well you're
|
6
|
+
awesome. Please just include a description of the bug
|
7
|
+
(or link to originating issue) and test coverage on the
|
8
|
+
modifications.
|
6
9
|
|
7
|
-
|
10
|
+
## New Features
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
## Pull requests
|
14
|
-
|
15
|
-
* https://github.com/chrisroberts/attribute_struct/pulls
|
16
|
-
|
17
|
-
Please base all pull requests off the `develop` branch. Merges to
|
18
|
-
`master` only occur through the `develop` branch. Pull requests
|
19
|
-
based on `master` will likely be cherry picked.
|
12
|
+
Have a new feature you want to add? Well you're awesome
|
13
|
+
too! It may be a good idea to submit an issue first to
|
14
|
+
describe the desired feature and get any feedback. Please
|
15
|
+
be sure to include tests.
|
20
16
|
|
21
17
|
## Issues
|
22
18
|
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright
|
1
|
+
Copyright 2022 Chris Roberts
|
2
2
|
|
3
3
|
Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
you may not use this file except in compliance with the License.
|
@@ -10,4 +10,4 @@
|
|
10
10
|
distributed under the License is distributed on an "AS IS" BASIS,
|
11
11
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
See the License for the specific language governing permissions and
|
13
|
-
limitations under the License.
|
13
|
+
limitations under the License.
|
data/attribute_struct.gemspec
CHANGED
@@ -12,8 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.require_path = "lib"
|
13
13
|
s.add_runtime_dependency "bogo", ">= 0.1.31", "< 0.3.0"
|
14
14
|
s.add_development_dependency "rspec", "~> 3.5"
|
15
|
-
s.add_development_dependency "rake", "~>
|
16
|
-
s.add_development_dependency "rufo", "~> 0.3.0"
|
15
|
+
s.add_development_dependency "rake", "~> 13"
|
17
16
|
s.add_development_dependency "minitest"
|
18
17
|
s.files = Dir["lib/**/*"] + %w(attribute_struct.gemspec README.md CHANGELOG.md CONTRIBUTING.md LICENSE)
|
19
18
|
end
|
@@ -1,9 +1,8 @@
|
|
1
|
-
require "attribute_struct"
|
1
|
+
require "attribute_struct/attribute_hash"
|
2
|
+
require "attribute_struct/augmented"
|
3
|
+
require "attribute_struct/monkey_camels"
|
2
4
|
|
3
5
|
class AttributeStruct < BasicObject
|
4
|
-
autoload :Augmented, "attribute_struct/augmented"
|
5
|
-
autoload :Mash, "attribute_struct/attribute_hash"
|
6
|
-
|
7
6
|
class << self
|
8
7
|
|
9
8
|
# @return [Hash] valid styles and mapped value
|
@@ -56,7 +55,7 @@ class AttributeStruct < BasicObject
|
|
56
55
|
|
57
56
|
# Loads helpers for camel casing
|
58
57
|
def load_the_camels
|
59
|
-
unless (@camels_loaded)
|
58
|
+
unless defined?(@camels_loaded)
|
60
59
|
require "attribute_struct/monkey_camels"
|
61
60
|
@camels_loaded = true
|
62
61
|
end
|
@@ -105,7 +104,10 @@ class AttributeStruct < BasicObject
|
|
105
104
|
# @yield block to execute within struct context
|
106
105
|
def initialize(init_hash = nil, &block)
|
107
106
|
@_camel_keys = _klass.camel_keys
|
107
|
+
@_camel_keys_set = nil
|
108
|
+
@_parent = nil
|
108
109
|
@_arg_state = __hashish.new
|
110
|
+
@_kernelified = false
|
109
111
|
@_objectified = false
|
110
112
|
@table = __hashish.new
|
111
113
|
if (init_hash)
|
@@ -516,7 +518,7 @@ class AttributeStruct < BasicObject
|
|
516
518
|
# @return [String, Symbol]
|
517
519
|
def _process_key(key, *args)
|
518
520
|
if (key.is_a?(::String) || key.is_a?(::Symbol))
|
519
|
-
key =
|
521
|
+
key = CamelString.new(key.to_s)
|
520
522
|
if (_camel_keys && _camel_keys_action && !key._hump_format_requested?)
|
521
523
|
case _camel_keys_action
|
522
524
|
when :auto_disable
|
@@ -1,13 +1,15 @@
|
|
1
1
|
# Helper methods for IRB interactions
|
2
|
-
module
|
2
|
+
module AttributeStruct
|
3
|
+
module IrbCompat
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
# @return [String] object inspection
|
6
|
+
def inspect
|
7
|
+
"<[#{self._klass}:#{@table.object_id}] - table: #{@table.inspect}>"
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
# @return [String] string of instance
|
11
|
+
def to_s
|
12
|
+
"<#{self._klass}:#{@table.object_id}>"
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
unless (defined?(MonkeyCamels))
|
1
|
+
class AttributeStruct
|
4
2
|
module MonkeyCamels
|
5
3
|
class << self
|
6
4
|
def included(klass)
|
@@ -36,15 +34,22 @@ unless (defined?(MonkeyCamels))
|
|
36
34
|
end
|
37
35
|
|
38
36
|
module Humps
|
39
|
-
|
40
37
|
# @return [TrueClass, FalseClass] specific style requested
|
41
38
|
def _hump_format_requested?
|
42
|
-
@__not_camel
|
39
|
+
if defined?(@__not_camel)
|
40
|
+
@__not_camel != nil
|
41
|
+
else
|
42
|
+
false
|
43
|
+
end
|
43
44
|
end
|
44
45
|
|
45
46
|
# @return [TrueClass, FalseClass] camelized
|
46
47
|
def _camel?
|
47
|
-
|
48
|
+
if defined?(@__not_camel)
|
49
|
+
!@__not_camel
|
50
|
+
else
|
51
|
+
true
|
52
|
+
end
|
48
53
|
end
|
49
54
|
|
50
55
|
# @return [self] disable camelizing
|
@@ -65,7 +70,9 @@ unless (defined?(MonkeyCamels))
|
|
65
70
|
|
66
71
|
# @return [Symbol, NilClass] style of hump
|
67
72
|
def _hump_style
|
68
|
-
@__hump_style
|
73
|
+
if defined?(@__hump_style)
|
74
|
+
@__hump_style
|
75
|
+
end
|
69
76
|
end
|
70
77
|
|
71
78
|
alias_method :hump_style!, :_hump_style
|
@@ -97,16 +104,18 @@ unless (defined?(MonkeyCamels))
|
|
97
104
|
end
|
98
105
|
|
99
106
|
# Force some monkeys around
|
100
|
-
String.send(:include, MonkeyCamels)
|
101
|
-
Symbol.send(:include, MonkeyCamels)
|
107
|
+
::String.send(:include, MonkeyCamels)
|
108
|
+
::Symbol.send(:include, MonkeyCamels)
|
102
109
|
|
103
110
|
# Specialized String type
|
104
|
-
class CamelString < String
|
111
|
+
class CamelString < ::String
|
105
112
|
def initialize(val = nil)
|
106
113
|
super
|
107
114
|
if (val.respond_to?(:_camel?))
|
108
115
|
_no_hump unless val._camel?
|
109
116
|
@__hump_style = val._hump_style
|
117
|
+
else
|
118
|
+
@__hump_style = nil
|
110
119
|
end
|
111
120
|
end
|
112
121
|
end
|
data/lib/attribute_struct.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
1
|
require "bogo"
|
2
|
-
require "attribute_struct/attribute_struct"
|
3
|
-
|
4
|
-
autoload :MonkeyCamels, "attribute_struct/monkey_camels"
|
5
|
-
autoload :CamelString, "attribute_struct/monkey_camels"
|
6
|
-
autoload :IrbCompat, "attribute_struct/irb_compat"
|
7
2
|
|
3
|
+
require "attribute_struct/attribute_struct"
|
8
4
|
require "attribute_struct/version"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attribute_struct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bogo
|
@@ -50,28 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '13'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: rufo
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: 0.3.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.3.0
|
60
|
+
version: '13'
|
75
61
|
- !ruby/object:Gem::Dependency
|
76
62
|
name: minitest
|
77
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,8 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: '0'
|
125
111
|
requirements: []
|
126
|
-
|
127
|
-
rubygems_version: 2.7.6
|
112
|
+
rubygems_version: 3.4.0.dev
|
128
113
|
signing_key:
|
129
114
|
specification_version: 4
|
130
115
|
summary: Attribute structures
|