attribute_struct 0.4.4 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a111a3bd5eb4ca45c05040837630482f4f4e912955ab82fae427e1d2ee8a8c3
4
- data.tar.gz: 9ce85d249bd59542e2eaf5946d145ee8250b54dfa57244fa812143818eea615f
3
+ metadata.gz: 3c352a11063ef870f66e2fcf7ff1ac41e744b1c2ca3ebc624c90cef397d7fc07
4
+ data.tar.gz: bdc14c8037516cf494410fe84945f44582c4f0af3beb18c329a71e22376749aa
5
5
  SHA512:
6
- metadata.gz: 0563f2b735ec6484e54beabc58a7a39051f90d6cf3997426ad06c4f5d1a010a22a79d9a858104cbfb49df29b479d2c1459bc73cac980ff2ad668c24c0a611779
7
- data.tar.gz: ae4532589e7ba3136d342df0215ff35176b11a44d173e600521043788d9b66f3051a578d99402d1713945ee817c4c2934a8f4b9f2f2c3db08abe1f6fddf42fef
6
+ metadata.gz: 4a4a791483032581a0cc065d879bfad8e8aa97c7f09413c01a890a3504ecca4d22860d50b9674976d8e1a6b0c56b06ff3bfa59d7273f89bf9734ac2db47b8947
7
+ data.tar.gz: 889192d36b3f8714eaf36ebd9a00ac7c2eea71f1daf10f11a28ba8ac89825063cfd961bd47761d244eb529575d78f9ebf746910d3a430f026496cb9dc04c0dce
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # v0.5.1
2
+ * Update loading strategy to prevent type mismatches
3
+
4
+ # v0.5.0
5
+ * Clean up loading and nest constants
6
+
1
7
  # v0.4.4
2
8
  * Add `#key?` method to check for key existence
3
9
 
data/CONTRIBUTING.md CHANGED
@@ -1,22 +1,18 @@
1
1
  # Contributing
2
2
 
3
- ## Branches
3
+ ## Fixes
4
4
 
5
- ### `master` branch
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
- The master branch is the current stable released version.
10
+ ## New Features
8
11
 
9
- ### `develop` branch
10
-
11
- The develop branch is the current edge of development.
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 2016 Chris Roberts
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.
@@ -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", "~> 10"
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,4 +1,4 @@
1
- require "attribute_struct"
1
+ require "attribute_struct/base"
2
2
 
3
3
  class AttributeStruct
4
4
 
@@ -1,9 +1,10 @@
1
- require "attribute_struct"
1
+ require "attribute_struct/base"
2
2
 
3
- class AttributeStruct < BasicObject
4
- autoload :Augmented, "attribute_struct/augmented"
5
- autoload :Mash, "attribute_struct/attribute_hash"
3
+ require "attribute_struct/attribute_hash"
4
+ require "attribute_struct/augmented"
5
+ require "attribute_struct/monkey_camels"
6
6
 
7
+ class AttributeStruct
7
8
  class << self
8
9
 
9
10
  # @return [Hash] valid styles and mapped value
@@ -56,7 +57,7 @@ class AttributeStruct < BasicObject
56
57
 
57
58
  # Loads helpers for camel casing
58
59
  def load_the_camels
59
- unless (@camels_loaded)
60
+ unless defined?(@camels_loaded)
60
61
  require "attribute_struct/monkey_camels"
61
62
  @camels_loaded = true
62
63
  end
@@ -105,7 +106,10 @@ class AttributeStruct < BasicObject
105
106
  # @yield block to execute within struct context
106
107
  def initialize(init_hash = nil, &block)
107
108
  @_camel_keys = _klass.camel_keys
109
+ @_camel_keys_set = nil
110
+ @_parent = nil
108
111
  @_arg_state = __hashish.new
112
+ @_kernelified = false
109
113
  @_objectified = false
110
114
  @table = __hashish.new
111
115
  if (init_hash)
@@ -516,7 +520,7 @@ class AttributeStruct < BasicObject
516
520
  # @return [String, Symbol]
517
521
  def _process_key(key, *args)
518
522
  if (key.is_a?(::String) || key.is_a?(::Symbol))
519
- key = ::CamelString.new(key.to_s)
523
+ key = CamelString.new(key.to_s)
520
524
  if (_camel_keys && _camel_keys_action && !key._hump_format_requested?)
521
525
  case _camel_keys_action
522
526
  when :auto_disable
@@ -1,4 +1,4 @@
1
- require "attribute_struct"
1
+ require "attribute_struct/base"
2
2
 
3
3
  class AttributeStruct
4
4
  # AttributeStruct expanded class that include the Kernel module
@@ -0,0 +1,2 @@
1
+ # Core class for attribute structures
2
+ class AttributeStruct < BasicObject; end
@@ -1,13 +1,17 @@
1
+ require "attribute_struct/base"
2
+
1
3
  # Helper methods for IRB interactions
2
- module IrbCompat
4
+ class AttributeStruct
5
+ module IrbCompat
3
6
 
4
- # @return [String] object inspection
5
- def inspect
6
- "<[#{self._klass}:#{@table.object_id}] - table: #{@table.inspect}>"
7
- end
7
+ # @return [String] object inspection
8
+ def inspect
9
+ "<[#{self._klass}:#{@table.object_id}] - table: #{@table.inspect}>"
10
+ end
8
11
 
9
- # @return [String] string of instance
10
- def to_s
11
- "<#{self._klass}:#{@table.object_id}>"
12
+ # @return [String] string of instance
13
+ def to_s
14
+ "<#{self._klass}:#{@table.object_id}>"
15
+ end
12
16
  end
13
17
  end
@@ -1,6 +1,6 @@
1
- require "attribute_struct"
1
+ require "attribute_struct/base"
2
2
 
3
- unless (defined?(MonkeyCamels))
3
+ class AttributeStruct
4
4
  module MonkeyCamels
5
5
  class << self
6
6
  def included(klass)
@@ -36,15 +36,22 @@ unless (defined?(MonkeyCamels))
36
36
  end
37
37
 
38
38
  module Humps
39
-
40
39
  # @return [TrueClass, FalseClass] specific style requested
41
40
  def _hump_format_requested?
42
- @__not_camel != nil
41
+ if defined?(@__not_camel)
42
+ @__not_camel != nil
43
+ else
44
+ false
45
+ end
43
46
  end
44
47
 
45
48
  # @return [TrueClass, FalseClass] camelized
46
49
  def _camel?
47
- !@__not_camel
50
+ if defined?(@__not_camel)
51
+ !@__not_camel
52
+ else
53
+ true
54
+ end
48
55
  end
49
56
 
50
57
  # @return [self] disable camelizing
@@ -65,7 +72,9 @@ unless (defined?(MonkeyCamels))
65
72
 
66
73
  # @return [Symbol, NilClass] style of hump
67
74
  def _hump_style
68
- @__hump_style
75
+ if defined?(@__hump_style)
76
+ @__hump_style
77
+ end
69
78
  end
70
79
 
71
80
  alias_method :hump_style!, :_hump_style
@@ -97,16 +106,18 @@ unless (defined?(MonkeyCamels))
97
106
  end
98
107
 
99
108
  # Force some monkeys around
100
- String.send(:include, MonkeyCamels)
101
- Symbol.send(:include, MonkeyCamels)
109
+ ::String.send(:include, MonkeyCamels)
110
+ ::Symbol.send(:include, MonkeyCamels)
102
111
 
103
112
  # Specialized String type
104
- class CamelString < String
113
+ class CamelString < ::String
105
114
  def initialize(val = nil)
106
115
  super
107
116
  if (val.respond_to?(:_camel?))
108
117
  _no_hump unless val._camel?
109
118
  @__hump_style = val._hump_style
119
+ else
120
+ @__hump_style = nil
110
121
  end
111
122
  end
112
123
  end
@@ -1,4 +1,6 @@
1
- class AttributeStruct < BasicObject
1
+ require "attribute_struct/base"
2
+
3
+ class AttributeStruct
2
4
  # Current library version
3
- VERSION = ::Gem::Version.new("0.4.4")
5
+ VERSION = ::Gem::Version.new("0.5.1")
4
6
  end
@@ -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.4
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-18 00:00:00.000000000 Z
11
+ date: 2022-11-05 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: '10'
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: '10'
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
@@ -101,6 +87,7 @@ files:
101
87
  - lib/attribute_struct/attribute_hash.rb
102
88
  - lib/attribute_struct/attribute_struct.rb
103
89
  - lib/attribute_struct/augmented.rb
90
+ - lib/attribute_struct/base.rb
104
91
  - lib/attribute_struct/irb_compat.rb
105
92
  - lib/attribute_struct/monkey_camels.rb
106
93
  - lib/attribute_struct/version.rb
@@ -123,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
110
  - !ruby/object:Gem::Version
124
111
  version: '0'
125
112
  requirements: []
126
- rubyforge_project:
127
- rubygems_version: 2.7.6
113
+ rubygems_version: 3.4.0.dev
128
114
  signing_key:
129
115
  specification_version: 4
130
116
  summary: Attribute structures