acts_as_hashable 1.0.5 → 1.1.0.pre.alpha
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile.lock +10 -2
- data/Guardfile +1 -1
- data/README.md +77 -4
- data/Rakefile +8 -0
- data/acts_as_hashable.gemspec +3 -0
- data/bin/console +2 -6
- data/lib/acts_as_hashable/factory.rb +55 -0
- data/lib/acts_as_hashable/hash_refinements.rb +20 -0
- data/lib/acts_as_hashable/hashable.rb +3 -1
- data/lib/acts_as_hashable/type_factory.rb +46 -0
- data/lib/acts_as_hashable/version.rb +1 -1
- data/lib/acts_as_hashable.rb +23 -1
- data/spec/examples.rb +18 -0
- data/spec/factory_spec.rb +49 -0
- data/spec/spec_helper.rb +12 -4
- metadata +53 -6
- data/lib/acts_as_hashable/acts_as_hashable.rb +0 -24
- data/lib/acts_as_hashable/utilities.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bfcbb15a9468d11fb85684f905f66f59bbeb3483d69bca332cc45e7c4ad5bf4
|
4
|
+
data.tar.gz: 555ebb09c100425427d23a228885b96d8d142f5b46ee350ab97edbbf90d5a8db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e041c6cc66f5cded7cf29f6ea0d5c1da08f9a8302bc92a4efacb8b79aac03c33bbc21534105101f1c402625eba7047734541063af870cd79d409cab1d68fd6cc
|
7
|
+
data.tar.gz: dc4a2825e441edee209913723ec1bf8ff8bbbbe4099694e4c0aa60bd556f288b7920c3f0236abca86ae66313e5c27935dc97fc0be318c25cabe3cc2685af4cb9
|
data/CHANGELOG.md
CHANGED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at oss@bluemarblepayroll.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
acts_as_hashable (1.0.
|
4
|
+
acts_as_hashable (1.1.0.pre.alpha)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ansi (1.5.0)
|
10
10
|
ast (2.4.0)
|
11
|
+
byebug (11.0.1)
|
11
12
|
coderay (1.1.2)
|
12
13
|
diff-lcs (1.3)
|
13
14
|
docile (1.3.1)
|
@@ -47,7 +48,11 @@ GEM
|
|
47
48
|
pry (0.12.2)
|
48
49
|
coderay (~> 1.1.0)
|
49
50
|
method_source (~> 0.9.0)
|
51
|
+
pry-byebug (3.7.0)
|
52
|
+
byebug (~> 11.0)
|
53
|
+
pry (~> 0.10)
|
50
54
|
rainbow (3.0.0)
|
55
|
+
rake (10.5.0)
|
51
56
|
rb-fsevent (0.10.3)
|
52
57
|
rb-inotify (0.10.0)
|
53
58
|
ffi (~> 1.0)
|
@@ -93,10 +98,13 @@ PLATFORMS
|
|
93
98
|
DEPENDENCIES
|
94
99
|
acts_as_hashable!
|
95
100
|
guard-rspec (~> 4.7)
|
101
|
+
pry
|
102
|
+
pry-byebug (~> 3)
|
103
|
+
rake (~> 10.0)
|
96
104
|
rspec
|
97
105
|
rubocop (~> 0.63.1)
|
98
106
|
simplecov (~> 0.16.1)
|
99
107
|
simplecov-console (~> 0.4.2)
|
100
108
|
|
101
109
|
BUNDLED WITH
|
102
|
-
1.17.
|
110
|
+
1.17.3
|
data/Guardfile
CHANGED
data/README.md
CHANGED
@@ -30,6 +30,8 @@ bundle add acts_as_hashable
|
|
30
30
|
|
31
31
|
## Examples
|
32
32
|
|
33
|
+
### Utilizing Classes on Hashabled Classes
|
34
|
+
|
33
35
|
Consider the following example:
|
34
36
|
|
35
37
|
````
|
@@ -125,6 +127,76 @@ class Pet
|
|
125
127
|
end
|
126
128
|
````
|
127
129
|
|
130
|
+
### Dynamic Factory Building
|
131
|
+
|
132
|
+
More complex relationships may contain objects with disparate types. In this case we can use the included factory
|
133
|
+
pattern to help us build these. Based on our examples above:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
class ExampleFactory
|
137
|
+
acts_as_hashable_factory
|
138
|
+
|
139
|
+
register 'Pet', Pet
|
140
|
+
|
141
|
+
register 'HeadOfHousehold', HeadOfHousehold
|
142
|
+
end
|
143
|
+
```
|
144
|
+
|
145
|
+
Now we can dynamically build these using:
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
objects = [
|
149
|
+
{
|
150
|
+
type: 'Pet',
|
151
|
+
name: 'Doug the dog',
|
152
|
+
toy: { squishy: true }
|
153
|
+
},
|
154
|
+
{
|
155
|
+
type: 'HeadOfHousehold',
|
156
|
+
person: {
|
157
|
+
name: 'Matt',
|
158
|
+
age: 109
|
159
|
+
},
|
160
|
+
partner: {
|
161
|
+
name: 'Katie',
|
162
|
+
age: 110
|
163
|
+
}
|
164
|
+
}
|
165
|
+
]
|
166
|
+
|
167
|
+
hydrated_objects = ExampleFactory.array(objects)
|
168
|
+
```
|
169
|
+
|
170
|
+
If the type key does not happen to be `type` then you can explicitly set this as:
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
class ExampleFactory
|
174
|
+
acts_as_hashable_factory
|
175
|
+
|
176
|
+
type_key 'object_type'
|
177
|
+
|
178
|
+
register 'Pet', Pet
|
179
|
+
|
180
|
+
register 'HeadOfHousehold', HeadOfHousehold
|
181
|
+
end
|
182
|
+
```
|
183
|
+
|
184
|
+
You can also choose to pass in a proc/lambda instead of a class constant:
|
185
|
+
|
186
|
+
```ruby
|
187
|
+
class ExampleFactory
|
188
|
+
acts_as_hashable_factory
|
189
|
+
|
190
|
+
type_key 'object_type'
|
191
|
+
|
192
|
+
register 'Pet', Pet
|
193
|
+
|
194
|
+
register 'HeadOfHousehold', ->(_key) { HeadOfHousehold }
|
195
|
+
end
|
196
|
+
```
|
197
|
+
|
198
|
+
In case you need full control of the registry you can also choose to simply override the class-level `registry` method which will simply return a hash of keys (names) and values (class constants).
|
199
|
+
|
128
200
|
## Contributing
|
129
201
|
|
130
202
|
### Development Environment Configuration
|
@@ -168,10 +240,11 @@ After code changes have successfully gone through the Pull Request review proces
|
|
168
240
|
3. Install dependencies: ```bundle```
|
169
241
|
4. Update ```CHANGELOG.md``` with release notes
|
170
242
|
5. Commit & push master to remote and ensure CI builds master successfully
|
171
|
-
6.
|
172
|
-
|
173
|
-
|
174
|
-
|
243
|
+
6. Run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
244
|
+
|
245
|
+
## Code of Conduct
|
246
|
+
|
247
|
+
Everyone interacting in this codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bluemarblepayroll/acts_as_hashable/blob/master/CODE_OF_CONDUCT.md).
|
175
248
|
|
176
249
|
## License
|
177
250
|
|
data/Rakefile
ADDED
data/acts_as_hashable.gemspec
CHANGED
@@ -24,6 +24,9 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.required_ruby_version = '>= 2.3.8'
|
25
25
|
|
26
26
|
s.add_development_dependency('guard-rspec', '~>4.7')
|
27
|
+
s.add_development_dependency('pry')
|
28
|
+
s.add_development_dependency('pry-byebug', '~> 3')
|
29
|
+
s.add_development_dependency 'rake', '~> 10.0'
|
27
30
|
s.add_development_dependency('rspec')
|
28
31
|
s.add_development_dependency('rubocop', '~> 0.63.1')
|
29
32
|
s.add_development_dependency('simplecov', '~>0.16.1')
|
data/bin/console
CHANGED
@@ -7,9 +7,5 @@ require 'acts_as_hashable'
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require 'irb'
|
15
|
-
IRB.start
|
10
|
+
require 'pry'
|
11
|
+
Pry.start
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2019-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
module ActsAsHashable
|
11
|
+
# This class serves as a singleton that can make mapped acts_as_hashable components.
|
12
|
+
# It is important to note that these components *must* he acts_as_hashable objects.
|
13
|
+
# In order to use you just have to subclass this class and implement
|
14
|
+
# and method called 'registry', such as:
|
15
|
+
# def registry
|
16
|
+
# {
|
17
|
+
# 'Table': Table,
|
18
|
+
# 'Text': Text
|
19
|
+
# }
|
20
|
+
# end
|
21
|
+
module Factory
|
22
|
+
extend Forwardable
|
23
|
+
|
24
|
+
def_delegators :factory, :array, :make
|
25
|
+
|
26
|
+
def register(key, value)
|
27
|
+
registry[key] = value
|
28
|
+
end
|
29
|
+
|
30
|
+
def registry
|
31
|
+
@registry ||= {}
|
32
|
+
end
|
33
|
+
|
34
|
+
def materialize_registry
|
35
|
+
@registry.map do |k, v|
|
36
|
+
value = v.is_a?(Proc) ? v.call(k) : v
|
37
|
+
[k, value]
|
38
|
+
end.to_h
|
39
|
+
end
|
40
|
+
|
41
|
+
def type_key(key)
|
42
|
+
@typed_with = key
|
43
|
+
end
|
44
|
+
|
45
|
+
def typed_with
|
46
|
+
@typed_with || TypeFactory::DEFAULT_TYPE_KEY
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def factory
|
52
|
+
@factory ||= TypeFactory.new(materialize_registry, typed_with)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2019-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
module ActsAsHashable
|
11
|
+
# Let's provide a refinenment instead of monkey-patching Hash. That way we can stop
|
12
|
+
# polluting other libraries and internalize our specific needs.
|
13
|
+
module HashRefinements
|
14
|
+
refine Hash do
|
15
|
+
def symbolize_keys
|
16
|
+
map { |k, v| [k.to_sym, v] }.to_h
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -11,11 +11,13 @@ module ActsAsHashable
|
|
11
11
|
# This class contains the main set of class-level methods that can be used by
|
12
12
|
# hashable classes.
|
13
13
|
module Hashable
|
14
|
+
using HashRefinements
|
15
|
+
|
14
16
|
HASHABLE_HYDRATORS = [
|
15
17
|
{
|
16
18
|
condition: ->(_context, object, _nullable) { object.is_a?(Hash) },
|
17
19
|
converter: lambda do |context, object, _nullable|
|
18
|
-
context.new(
|
20
|
+
context.new(**(object || {}).symbolize_keys)
|
19
21
|
end
|
20
22
|
},
|
21
23
|
{
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2019-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
module ActsAsHashable
|
11
|
+
# A TypeFactory object understands how to build objects using a special designated 'type' key.
|
12
|
+
class TypeFactory
|
13
|
+
using HashRefinements
|
14
|
+
|
15
|
+
DEFAULT_TYPE_KEY = :type
|
16
|
+
|
17
|
+
attr_reader :registry, :type_key
|
18
|
+
|
19
|
+
def initialize(registry = {}, type_key = DEFAULT_TYPE_KEY)
|
20
|
+
@registry = registry.symbolize_keys
|
21
|
+
@type_key = type_key.to_s.to_sym
|
22
|
+
|
23
|
+
freeze
|
24
|
+
end
|
25
|
+
|
26
|
+
def array(objects = [])
|
27
|
+
objects = objects.is_a?(Hash) ? [objects] : Array(objects)
|
28
|
+
|
29
|
+
objects.map do |object|
|
30
|
+
object.is_a?(Hash) ? make(object) : object
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def make(config = {})
|
35
|
+
config = (config || {}).symbolize_keys
|
36
|
+
type = config[type_key].to_s.to_sym
|
37
|
+
object_class = registry[type]
|
38
|
+
|
39
|
+
raise ArgumentError, "cannot find section from type: #{type}" unless object_class
|
40
|
+
|
41
|
+
config_without_type = config.reject { |k| k == type_key }
|
42
|
+
|
43
|
+
object_class.new(config_without_type)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/acts_as_hashable.rb
CHANGED
@@ -7,4 +7,26 @@
|
|
7
7
|
# LICENSE file in the root directory of this source tree.
|
8
8
|
#
|
9
9
|
|
10
|
-
|
10
|
+
require 'forwardable'
|
11
|
+
|
12
|
+
require_relative 'acts_as_hashable/factory'
|
13
|
+
require_relative 'acts_as_hashable/hash_refinements'
|
14
|
+
require_relative 'acts_as_hashable/type_factory'
|
15
|
+
require_relative 'acts_as_hashable/hashable'
|
16
|
+
|
17
|
+
module ActsAsHashable
|
18
|
+
# This module adds the class-level method that marks a class as hashable.
|
19
|
+
module DslHook
|
20
|
+
def acts_as_hashable
|
21
|
+
extend ::ActsAsHashable::Hashable
|
22
|
+
end
|
23
|
+
|
24
|
+
def acts_as_hashable_factory
|
25
|
+
extend ActsAsHashable::Factory
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Object.class_eval do
|
31
|
+
extend ::ActsAsHashable::DslHook
|
32
|
+
end
|
data/spec/examples.rb
CHANGED
@@ -60,3 +60,21 @@ class Family
|
|
60
60
|
@children = Person.array(children)
|
61
61
|
end
|
62
62
|
end
|
63
|
+
|
64
|
+
class ExampleFactory
|
65
|
+
acts_as_hashable_factory
|
66
|
+
|
67
|
+
type_key :object_type
|
68
|
+
|
69
|
+
register 'Person', Person
|
70
|
+
|
71
|
+
register 'Pet', Pet
|
72
|
+
|
73
|
+
register 'Toy', Toy
|
74
|
+
|
75
|
+
# These are examples of registering a proc instead of a class constant. It
|
76
|
+
# will send the key through the argument if you need
|
77
|
+
register 'Familiy', ->(_key) { Family }
|
78
|
+
|
79
|
+
register 'HeadOfHousehold', ->(_key) { HeadOfHousehold }
|
80
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2018-present, Blue Marble Payroll, LLC
|
5
|
+
#
|
6
|
+
# This source code is licensed under the MIT license found in the
|
7
|
+
# LICENSE file in the root directory of this source tree.
|
8
|
+
#
|
9
|
+
|
10
|
+
require './spec/spec_helper'
|
11
|
+
|
12
|
+
describe ActsAsHashable::Factory do
|
13
|
+
subject { ExampleFactory }
|
14
|
+
|
15
|
+
it 'should hydrate example objects' do
|
16
|
+
objects = [
|
17
|
+
{
|
18
|
+
object_type: 'Pet',
|
19
|
+
name: 'Doug the dog',
|
20
|
+
toy: { squishy: true }
|
21
|
+
},
|
22
|
+
{
|
23
|
+
object_type: 'HeadOfHousehold',
|
24
|
+
person: {
|
25
|
+
name: 'Matt',
|
26
|
+
age: 109
|
27
|
+
},
|
28
|
+
partner: {
|
29
|
+
name: 'Katie',
|
30
|
+
age: 110
|
31
|
+
}
|
32
|
+
}
|
33
|
+
]
|
34
|
+
|
35
|
+
hydrated_objects = subject.array(objects)
|
36
|
+
|
37
|
+
pet_obj = hydrated_objects.first
|
38
|
+
|
39
|
+
expect(pet_obj.name).to eq('Doug the dog')
|
40
|
+
expect(pet_obj.toy.squishy).to be true
|
41
|
+
|
42
|
+
head_of_household_obj = hydrated_objects.last
|
43
|
+
|
44
|
+
expect(head_of_household_obj.person.name).to eq('Matt')
|
45
|
+
expect(head_of_household_obj.person.age).to eq(109)
|
46
|
+
expect(head_of_household_obj.partner.name).to eq('Katie')
|
47
|
+
expect(head_of_household_obj.partner.age).to eq(110)
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,10 +7,18 @@
|
|
7
7
|
# LICENSE file in the root directory of this source tree.
|
8
8
|
#
|
9
9
|
|
10
|
-
require '
|
11
|
-
require '
|
12
|
-
|
13
|
-
|
10
|
+
require 'pry'
|
11
|
+
require 'pry-byebug'
|
12
|
+
|
13
|
+
unless ENV['DISABLE_SIMPLECOV'] == 'true'
|
14
|
+
require 'simplecov'
|
15
|
+
require 'simplecov-console'
|
16
|
+
|
17
|
+
SimpleCov.formatter = SimpleCov::Formatter::Console
|
18
|
+
SimpleCov.start do
|
19
|
+
add_filter %r{\A/spec/}
|
20
|
+
end
|
21
|
+
end
|
14
22
|
|
15
23
|
require './lib/acts_as_hashable'
|
16
24
|
require './spec/examples'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_hashable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.1.0.pre.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard-rspec
|
@@ -24,6 +24,48 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry-byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
27
69
|
- !ruby/object:Gem::Dependency
|
28
70
|
name: rspec
|
29
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,20 +139,24 @@ files:
|
|
97
139
|
- ".ruby-version"
|
98
140
|
- ".travis.yml"
|
99
141
|
- CHANGELOG.md
|
142
|
+
- CODE_OF_CONDUCT.md
|
100
143
|
- Gemfile
|
101
144
|
- Gemfile.lock
|
102
145
|
- Guardfile
|
103
146
|
- LICENSE
|
104
147
|
- README.md
|
148
|
+
- Rakefile
|
105
149
|
- acts_as_hashable.gemspec
|
106
150
|
- bin/console
|
107
151
|
- lib/acts_as_hashable.rb
|
108
|
-
- lib/acts_as_hashable/
|
152
|
+
- lib/acts_as_hashable/factory.rb
|
153
|
+
- lib/acts_as_hashable/hash_refinements.rb
|
109
154
|
- lib/acts_as_hashable/hashable.rb
|
110
|
-
- lib/acts_as_hashable/
|
155
|
+
- lib/acts_as_hashable/type_factory.rb
|
111
156
|
- lib/acts_as_hashable/version.rb
|
112
157
|
- spec/acts_as_hashable_spec.rb
|
113
158
|
- spec/examples.rb
|
159
|
+
- spec/factory_spec.rb
|
114
160
|
- spec/spec_helper.rb
|
115
161
|
homepage: https://github.com/bluemarblepayroll/acts_as_hashable
|
116
162
|
licenses:
|
@@ -127,9 +173,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
173
|
version: 2.3.8
|
128
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
175
|
requirements:
|
130
|
-
- - "
|
176
|
+
- - ">"
|
131
177
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
178
|
+
version: 1.3.1
|
133
179
|
requirements: []
|
134
180
|
rubygems_version: 3.0.1
|
135
181
|
signing_key:
|
@@ -138,4 +184,5 @@ summary: Simple hash-based factory methods for objects.
|
|
138
184
|
test_files:
|
139
185
|
- spec/acts_as_hashable_spec.rb
|
140
186
|
- spec/examples.rb
|
187
|
+
- spec/factory_spec.rb
|
141
188
|
- spec/spec_helper.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2018-present, Blue Marble Payroll, LLC
|
5
|
-
#
|
6
|
-
# This source code is licensed under the MIT license found in the
|
7
|
-
# LICENSE file in the root directory of this source tree.
|
8
|
-
#
|
9
|
-
|
10
|
-
require_relative 'utilities'
|
11
|
-
require_relative 'hashable'
|
12
|
-
|
13
|
-
module ActsAsHashable
|
14
|
-
# This module adds the class-level method that marks a class as hashable.
|
15
|
-
module DslHook
|
16
|
-
def acts_as_hashable
|
17
|
-
extend ::ActsAsHashable::Hashable
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
Object.class_eval do
|
23
|
-
extend ::ActsAsHashable::DslHook
|
24
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2018-present, Blue Marble Payroll, LLC
|
5
|
-
#
|
6
|
-
# This source code is licensed under the MIT license found in the
|
7
|
-
# LICENSE file in the root directory of this source tree.
|
8
|
-
#
|
9
|
-
|
10
|
-
module ActsAsHashable
|
11
|
-
# Some extra functions that are either ancillary to the main domain or polyfill other
|
12
|
-
# mainstream imnplementations.
|
13
|
-
class Utilities
|
14
|
-
class << self
|
15
|
-
# https://apidock.com/rails/Hash/symbolize_keys
|
16
|
-
def symbolize_keys(hash)
|
17
|
-
transform_keys(hash) { |key| key.to_sym rescue key }
|
18
|
-
end
|
19
|
-
|
20
|
-
# https://apidock.com/rails/v4.2.7/Hash/transform_keys
|
21
|
-
def transform_keys(hash)
|
22
|
-
return enum_for(:transform_keys) unless block_given?
|
23
|
-
|
24
|
-
result = {}
|
25
|
-
|
26
|
-
hash.keys.each do |key|
|
27
|
-
result[yield(key)] = hash[key]
|
28
|
-
end
|
29
|
-
|
30
|
-
result
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|