objectable 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +8 -0
- data/.gitignore +5 -0
- data/.rubocop.yml +11 -0
- data/.ruby-version +1 -0
- data/.travis.yml +20 -0
- data/CHANGELOG.md +17 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +110 -0
- data/Guardfile +16 -0
- data/LICENSE +7 -0
- data/README.md +177 -0
- data/Rakefile +8 -0
- data/bin/console +11 -0
- data/lib/objectable.rb +20 -0
- data/lib/objectable/interface.rb +43 -0
- data/lib/objectable/resolver.rb +87 -0
- data/lib/objectable/version.rb +12 -0
- data/objectable.gemspec +31 -0
- data/spec/objectable/resolver_spec.rb +116 -0
- data/spec/objectable_spec.rb +137 -0
- data/spec/spec_helper.rb +23 -0
- metadata +181 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 013a205540d4adb9c25e8a33b48adff324b4148e4df2101e8ddb14f562d3f38e
|
4
|
+
data.tar.gz: 91c1df05393e5f4aa3aa9b0b088841d0d216f3e5cff5d187ae83410842f3a022
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 33bc889fb0d9cef7123e9e46b8b0e604a74ed19d6350993bcee452e5360f27ec67cc59942354b604d69991e20b06a90c8fef165d75186a05c26c394997c89c9e
|
7
|
+
data.tar.gz: 1fc615875100e850d1c32638a623ef2f7bd02853c12b19cab00d05c2a645c2a3e69f04d62b63f22d849eac00ec387a86d3227c7ca1eaeebf7e6d5a1cfef81639
|
data/.editorconfig
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.0
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
- CC_TEST_REPORTER_ID=a9355f1cf8d8baea41e5e58aec43984979a8ae508a99d80c15ae1dcd6232eb0b
|
4
|
+
language: ruby
|
5
|
+
rvm:
|
6
|
+
# Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
|
7
|
+
- 2.3.8
|
8
|
+
- 2.4.5
|
9
|
+
- 2.5.3
|
10
|
+
- 2.6.0
|
11
|
+
cache: bundler
|
12
|
+
before_script:
|
13
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
14
|
+
- chmod +x ./cc-test-reporter
|
15
|
+
- ./cc-test-reporter before-build
|
16
|
+
script:
|
17
|
+
- bundle exec rubocop
|
18
|
+
- bundle exec rspec
|
19
|
+
after_script:
|
20
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# 1.1.0 (May 3rd, 2019)
|
2
|
+
|
3
|
+
* Added objectable_factory to dynamically create objects.
|
4
|
+
|
5
|
+
# 1.0.5 (February 5th, 2019)
|
6
|
+
|
7
|
+
* Fixed equality bug in array reject block.
|
8
|
+
|
9
|
+
# 1.0.4 (January 30th, 2019)
|
10
|
+
|
11
|
+
Maintenance Release
|
12
|
+
|
13
|
+
* Added bin/console script
|
14
|
+
* Added CHANGELOG
|
15
|
+
* Updated README with publication steps, additional testing steps
|
16
|
+
* Bumped minimum Ruby to 2.3.8
|
17
|
+
* Added Guard
|
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
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
objectable (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ansi (1.5.0)
|
10
|
+
ast (2.4.0)
|
11
|
+
byebug (11.0.1)
|
12
|
+
coderay (1.1.2)
|
13
|
+
diff-lcs (1.3)
|
14
|
+
docile (1.3.1)
|
15
|
+
ffi (1.10.0)
|
16
|
+
formatador (0.2.5)
|
17
|
+
guard (2.15.0)
|
18
|
+
formatador (>= 0.2.4)
|
19
|
+
listen (>= 2.7, < 4.0)
|
20
|
+
lumberjack (>= 1.0.12, < 2.0)
|
21
|
+
nenv (~> 0.1)
|
22
|
+
notiffany (~> 0.0)
|
23
|
+
pry (>= 0.9.12)
|
24
|
+
shellany (~> 0.0)
|
25
|
+
thor (>= 0.18.1)
|
26
|
+
guard-compat (1.2.1)
|
27
|
+
guard-rspec (4.7.3)
|
28
|
+
guard (~> 2.1)
|
29
|
+
guard-compat (~> 1.1)
|
30
|
+
rspec (>= 2.99.0, < 4.0)
|
31
|
+
hirb (0.7.3)
|
32
|
+
jaro_winkler (1.5.2)
|
33
|
+
json (2.1.0)
|
34
|
+
listen (3.1.5)
|
35
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
36
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
37
|
+
ruby_dep (~> 1.2)
|
38
|
+
lumberjack (1.0.13)
|
39
|
+
method_source (0.9.2)
|
40
|
+
nenv (0.3.0)
|
41
|
+
notiffany (0.1.1)
|
42
|
+
nenv (~> 0.1)
|
43
|
+
shellany (~> 0.0)
|
44
|
+
parallel (1.13.0)
|
45
|
+
parser (2.6.0.0)
|
46
|
+
ast (~> 2.4.0)
|
47
|
+
powerpack (0.1.2)
|
48
|
+
pry (0.12.2)
|
49
|
+
coderay (~> 1.1.0)
|
50
|
+
method_source (~> 0.9.0)
|
51
|
+
pry-byebug (3.7.0)
|
52
|
+
byebug (~> 11.0)
|
53
|
+
pry (~> 0.10)
|
54
|
+
rainbow (3.0.0)
|
55
|
+
rake (10.5.0)
|
56
|
+
rb-fsevent (0.10.3)
|
57
|
+
rb-inotify (0.10.0)
|
58
|
+
ffi (~> 1.0)
|
59
|
+
rspec (3.8.0)
|
60
|
+
rspec-core (~> 3.8.0)
|
61
|
+
rspec-expectations (~> 3.8.0)
|
62
|
+
rspec-mocks (~> 3.8.0)
|
63
|
+
rspec-core (3.8.0)
|
64
|
+
rspec-support (~> 3.8.0)
|
65
|
+
rspec-expectations (3.8.1)
|
66
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
+
rspec-support (~> 3.8.0)
|
68
|
+
rspec-mocks (3.8.0)
|
69
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
+
rspec-support (~> 3.8.0)
|
71
|
+
rspec-support (3.8.0)
|
72
|
+
rubocop (0.63.1)
|
73
|
+
jaro_winkler (~> 1.5.1)
|
74
|
+
parallel (~> 1.10)
|
75
|
+
parser (>= 2.5, != 2.5.1.1)
|
76
|
+
powerpack (~> 0.1)
|
77
|
+
rainbow (>= 2.2.2, < 4.0)
|
78
|
+
ruby-progressbar (~> 1.7)
|
79
|
+
unicode-display_width (~> 1.4.0)
|
80
|
+
ruby-progressbar (1.10.0)
|
81
|
+
ruby_dep (1.5.0)
|
82
|
+
shellany (0.0.1)
|
83
|
+
simplecov (0.16.1)
|
84
|
+
docile (~> 1.1)
|
85
|
+
json (>= 1.8, < 3)
|
86
|
+
simplecov-html (~> 0.10.0)
|
87
|
+
simplecov-console (0.4.2)
|
88
|
+
ansi
|
89
|
+
hirb
|
90
|
+
simplecov
|
91
|
+
simplecov-html (0.10.2)
|
92
|
+
thor (0.20.3)
|
93
|
+
unicode-display_width (1.4.1)
|
94
|
+
|
95
|
+
PLATFORMS
|
96
|
+
ruby
|
97
|
+
|
98
|
+
DEPENDENCIES
|
99
|
+
guard-rspec (~> 4.7)
|
100
|
+
objectable!
|
101
|
+
pry
|
102
|
+
pry-byebug (~> 3)
|
103
|
+
rake (~> 10.0)
|
104
|
+
rspec
|
105
|
+
rubocop (~> 0.63.1)
|
106
|
+
simplecov (~> 0.16.1)
|
107
|
+
simplecov-console (~> 0.4.2)
|
108
|
+
|
109
|
+
BUNDLED WITH
|
110
|
+
1.17.3
|
data/Guardfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
guard :rspec, cmd: 'DISABLE_SIMPLECOV=true bundle exec rspec --format=documentation' do
|
4
|
+
require 'guard/rspec/dsl'
|
5
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
6
|
+
|
7
|
+
# RSpec files
|
8
|
+
rspec = dsl.rspec
|
9
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
10
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
11
|
+
watch(rspec.spec_files)
|
12
|
+
|
13
|
+
# Ruby files
|
14
|
+
ruby = dsl.ruby
|
15
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
16
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright 2018 Blue Marble Payroll, LLC
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
# Objectable
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/objectable.svg)](https://badge.fury.io/rb/objectable) [![Build Status](https://travis-ci.org/bluemarblepayroll/objectable.svg?branch=master)](https://travis-ci.org/bluemarblepayroll/objectable) [![Maintainability](https://api.codeclimate.com/v1/badges/047c45ae0016941706e1/maintainability)](https://codeclimate.com/github/bluemarblepayroll/objectable/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/047c45ae0016941706e1/test_coverage)](https://codeclimate.com/github/bluemarblepayroll/objectable/test_coverage) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
4
|
+
|
5
|
+
This library streamlines value setting and getting for any type of object. It can give an object a hash-like interface without modifying/changing the underlying object's implementation. It uses the following methodology:
|
6
|
+
|
7
|
+
* If the object is a hash and a string key exists then return the key's value.
|
8
|
+
* If the object is a hash and a symbol key exists then return the key's value.
|
9
|
+
* If the object publicly responds to the key then call key on the object.
|
10
|
+
|
11
|
+
This seems rather trivial but consider the following additional value propositions:
|
12
|
+
|
13
|
+
* It can handle dot-notation/key paths for nested objects.
|
14
|
+
* It can recursively traverse object graphs to set/get the desired value. This can be used to build up deep object graphs.
|
15
|
+
|
16
|
+
See the `examples` section for more information.
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
To install through Rubygems:
|
21
|
+
|
22
|
+
````
|
23
|
+
gem install install objectable
|
24
|
+
````
|
25
|
+
|
26
|
+
You can also add this to your Gemfile:
|
27
|
+
|
28
|
+
````
|
29
|
+
bundle add objectable
|
30
|
+
````
|
31
|
+
|
32
|
+
## Examples
|
33
|
+
|
34
|
+
Let's define a set of objects built using different constructs but all essentially represent the same graphs:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
Employee = Struct.new(:id, :demographics)
|
38
|
+
Demographics = Struct.new(:first)
|
39
|
+
|
40
|
+
symbol_based_hash = { id: 1, demographics: { first: 'Matt' } }
|
41
|
+
string_based_hash = { 'id' => 1, 'demographics' => { 'first' => 'Matt' } }
|
42
|
+
open_struct = OpenStruct.new(id: 1, demographics: OpenStruct.new(first: 'Matt'))
|
43
|
+
object = Employee.new(1, Demographics.new('Matt'))
|
44
|
+
```
|
45
|
+
|
46
|
+
### Getting Values
|
47
|
+
|
48
|
+
The following calls will all resolve to the same respective values:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
resolver = Objectable.resolver
|
52
|
+
|
53
|
+
# All resolve to the value of: 1
|
54
|
+
resolver.get(symbol_based_hash, :id)
|
55
|
+
resolver.get(symbol_based_hash, 'id')
|
56
|
+
resolver.get(string_based_hash, :id)
|
57
|
+
resolver.get(string_based_hash, 'id')
|
58
|
+
resolver.get(open_struct, :id)
|
59
|
+
resolver.get(open_struct, 'id')
|
60
|
+
resolver.get(object, :id)
|
61
|
+
resolver.get(object, 'id')
|
62
|
+
|
63
|
+
# All resolve to the value of: Matt
|
64
|
+
resolver.get(symbol_based_hash, :'demographics.first')
|
65
|
+
resolver.get(symbol_based_hash, 'demographics.first')
|
66
|
+
resolver.get(string_based_hash, :'demographics.first')
|
67
|
+
resolver.get(string_based_hash, 'demographics.first')
|
68
|
+
resolver.get(open_struct, :'demographics.first')
|
69
|
+
resolver.get(open_struct, 'demographics.first')
|
70
|
+
resolver.get(object, :'demographics.first')
|
71
|
+
resolver.get(object, 'demographics.first')
|
72
|
+
```
|
73
|
+
|
74
|
+
As you can see you do not have to worry about nested object traversal, dot-notation, or key type; this library gives you a unified interface when accessing values.
|
75
|
+
|
76
|
+
### Setting Values
|
77
|
+
|
78
|
+
Say we want to update a the `id` and `first` attributes from the objects:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
resolver = Objectable.resolver
|
82
|
+
|
83
|
+
# All calls will set the object's respective id attribute to: 999
|
84
|
+
resolver.set(symbol_based_hash, :id, 999)
|
85
|
+
resolver.set(symbol_based_hash, 'id', 999)
|
86
|
+
resolver.set(string_based_hash, :id, 999)
|
87
|
+
resolver.set(string_based_hash, 'id', 999)
|
88
|
+
resolver.set(open_struct, :id, 999)
|
89
|
+
resolver.set(open_struct, 'id', 999)
|
90
|
+
resolver.set(object, :id, 999)
|
91
|
+
resolver.set(object, 'id', 999)
|
92
|
+
|
93
|
+
# All calls will set the object's respective id attribute to: Nick
|
94
|
+
resolver.set(symbol_based_hash, :'demographics.first', 'Nick')
|
95
|
+
resolver.set(symbol_based_hash, 'demographics.first', 'Nick')
|
96
|
+
resolver.set(string_based_hash, :'demographics.first', 'Nick')
|
97
|
+
resolver.set(string_based_hash, 'demographics.first', 'Nick')
|
98
|
+
resolver.set(open_struct, :'demographics.first', 'Nick')
|
99
|
+
resolver.set(open_struct, 'demographics.first', 'Nick')
|
100
|
+
resolver.set(object, :'demographics.first', 'Nick')
|
101
|
+
resolver.set(object, 'demographics.first', 'Nick')
|
102
|
+
```
|
103
|
+
|
104
|
+
### Dot-Notation Customization
|
105
|
+
|
106
|
+
By default dot-notation is turned on and the path separator is set as a period. You can disable or customize this by passing in a separator option into `resolver`:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
resolver_without_dot_notation = Objectable.resolver(separator: nil)
|
110
|
+
resolver_with_custom_dot_notation = Objectable.resolver(separator: '$')
|
111
|
+
```
|
112
|
+
|
113
|
+
Also note that you can choose to pass in an array into the expression and it will be used for customized traversal but without using dot-notation. The following are equivalent:
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
Objectable.resolver.get([:demographics, :first], symbol_based_hash)
|
117
|
+
Objectable.resolver.get('demographics.first', symbol_based_hash)
|
118
|
+
```
|
119
|
+
|
120
|
+
### Gaps
|
121
|
+
|
122
|
+
When setting values of nested objects:
|
123
|
+
|
124
|
+
* If the parent object is null then the parent object will be initialized based on the preceding class. This is not ideal for complex object graphs but works quite lovely for Hash and OpenStruct objects. In the future this can be extended so the object type graph can be passed in and used as a blueprint for parent initialization.
|
125
|
+
|
126
|
+
## Contributing
|
127
|
+
|
128
|
+
### Development Environment Configuration
|
129
|
+
|
130
|
+
Basic steps to take to get this repository compiling:
|
131
|
+
|
132
|
+
1. Install [Ruby](https://www.ruby-lang.org/en/documentation/installation) (check objectable.gemspec for versions supported)
|
133
|
+
2. Install bundler (gem install bundler)
|
134
|
+
3. Clone the repository (git clone git@github.com:bluemarblepayroll/objectable.git)
|
135
|
+
4. Navigate to the root folder (cd objectable)
|
136
|
+
5. Install dependencies (bundle)
|
137
|
+
|
138
|
+
### Running Tests
|
139
|
+
|
140
|
+
To execute the test suite run:
|
141
|
+
|
142
|
+
````
|
143
|
+
bundle exec rspec spec --format documentation
|
144
|
+
````
|
145
|
+
|
146
|
+
Alternatively, you can have Guard watch for changes:
|
147
|
+
|
148
|
+
````
|
149
|
+
bundle exec guard
|
150
|
+
````
|
151
|
+
|
152
|
+
Also, do not forget to run Rubocop:
|
153
|
+
|
154
|
+
````
|
155
|
+
bundle exec rubocop
|
156
|
+
````
|
157
|
+
|
158
|
+
### Publishing
|
159
|
+
|
160
|
+
Note: ensure you have proper authorization before trying to publish new versions.
|
161
|
+
|
162
|
+
After code changes have successfully gone through the Pull Request review process then the following steps should be followed for publishing new versions:
|
163
|
+
|
164
|
+
1. Merge Pull Request into master
|
165
|
+
2. Update ```lib/objectable/version.rb``` using [semantic versioning](https://semver.org)
|
166
|
+
3. Install dependencies: ```bundle```
|
167
|
+
4. Update ```CHANGELOG.md``` with release notes
|
168
|
+
5. Commit & push master to remote and ensure CI builds master successfully
|
169
|
+
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).
|
170
|
+
|
171
|
+
## Code of Conduct
|
172
|
+
|
173
|
+
Everyone interacting in this codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bluemarblepayroll/objectable/blob/master/CODE_OF_CONDUCT.md).
|
174
|
+
|
175
|
+
## License
|
176
|
+
|
177
|
+
This project is MIT Licensed.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'objectable'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
require 'pry'
|
11
|
+
Pry.start
|
data/lib/objectable.rb
ADDED
@@ -0,0 +1,20 @@
|
|
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 'objectable/resolver'
|
11
|
+
|
12
|
+
# Top-level API
|
13
|
+
module Objectable
|
14
|
+
class << self
|
15
|
+
# Really just syntactic sugar that proxies a new Resolver instance creation.
|
16
|
+
def resolver(*args)
|
17
|
+
Resolver.new(*args)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,43 @@
|
|
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 Objectable
|
11
|
+
# This class defines the direct interface with an object. Unlike the resolver, this class
|
12
|
+
# cannot handle traversal or nesting, it can only deal with the immediate object interface.
|
13
|
+
class Interface
|
14
|
+
def get(object, key)
|
15
|
+
if object.is_a?(Hash)
|
16
|
+
indifferent_hash_get(object, key)
|
17
|
+
elsif object.respond_to?(key)
|
18
|
+
object.public_send(key)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def set(object, key, val)
|
23
|
+
object.tap do |o|
|
24
|
+
setter_method = "#{key}="
|
25
|
+
if o.respond_to?(setter_method)
|
26
|
+
o.send(setter_method, val)
|
27
|
+
elsif o.respond_to?(:[])
|
28
|
+
o[key] = val
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def indifferent_hash_get(hash, key)
|
36
|
+
if hash.key?(key.to_s)
|
37
|
+
hash[key.to_s]
|
38
|
+
elsif hash.key?(key.to_s.to_sym)
|
39
|
+
hash[key.to_s.to_sym]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,87 @@
|
|
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
|
+
require_relative 'interface'
|
11
|
+
|
12
|
+
module Objectable
|
13
|
+
# The main logic value proposition of this library. An instance of this class can act as
|
14
|
+
# a value-get and value-set arbiter for objects.
|
15
|
+
class Resolver
|
16
|
+
DEFAULT_SEPARATOR = '.'
|
17
|
+
|
18
|
+
attr_reader :separator
|
19
|
+
|
20
|
+
def initialize(separator: DEFAULT_SEPARATOR)
|
21
|
+
@interface = Interface.new
|
22
|
+
@separator = separator.to_s
|
23
|
+
|
24
|
+
freeze
|
25
|
+
end
|
26
|
+
|
27
|
+
def get(object, expression)
|
28
|
+
traverse(object, key_path(expression))
|
29
|
+
end
|
30
|
+
|
31
|
+
def set(object, expression, value)
|
32
|
+
build_up(object, key_path(expression), value)
|
33
|
+
end
|
34
|
+
|
35
|
+
def ==(other)
|
36
|
+
eql?(other)
|
37
|
+
end
|
38
|
+
|
39
|
+
def eql?(other)
|
40
|
+
return false unless other.is_a?(self.class)
|
41
|
+
|
42
|
+
separator == other.separator
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
attr_reader :interface
|
48
|
+
|
49
|
+
def key_path(expression)
|
50
|
+
return expression if expression.is_a?(Array)
|
51
|
+
return Array(expression) if separator.empty?
|
52
|
+
|
53
|
+
expression.to_s.split(separator)
|
54
|
+
end
|
55
|
+
|
56
|
+
def traverse(object, through)
|
57
|
+
pointer = object
|
58
|
+
|
59
|
+
through.each do |key|
|
60
|
+
next unless pointer
|
61
|
+
|
62
|
+
pointer = interface.get(pointer, key)
|
63
|
+
end
|
64
|
+
|
65
|
+
pointer
|
66
|
+
end
|
67
|
+
|
68
|
+
def build_up(object, through, value)
|
69
|
+
object.tap do |o|
|
70
|
+
pointer = o
|
71
|
+
|
72
|
+
preceding_keys = through[0..-2]
|
73
|
+
last_key = through.last
|
74
|
+
|
75
|
+
preceding_keys.each do |key|
|
76
|
+
pointer = interface.get(pointer, key) || build_and_set(pointer, key)
|
77
|
+
end
|
78
|
+
|
79
|
+
interface.set(pointer, last_key, value)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def build_and_set(pointer, key)
|
84
|
+
interface.get(interface.set(pointer, key, pointer.class.new), key)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,12 @@
|
|
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 Objectable
|
11
|
+
VERSION = '1.0.0'
|
12
|
+
end
|
data/objectable.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require './lib/objectable/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'objectable'
|
7
|
+
s.version = Objectable::VERSION
|
8
|
+
s.summary = 'Unified get/set interface for disparate objects'
|
9
|
+
|
10
|
+
s.description = <<-DESCRIPTION
|
11
|
+
DESCRIPTION
|
12
|
+
|
13
|
+
s.authors = ['Matthew Ruggio']
|
14
|
+
s.email = ['mruggio@bluemarblepayroll.com']
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
18
|
+
s.homepage = 'https://github.com/bluemarblepayroll/objectable'
|
19
|
+
s.license = 'MIT'
|
20
|
+
|
21
|
+
s.required_ruby_version = '>= 2.3.8'
|
22
|
+
|
23
|
+
s.add_development_dependency('guard-rspec', '~>4.7')
|
24
|
+
s.add_development_dependency('pry')
|
25
|
+
s.add_development_dependency('pry-byebug', '~> 3')
|
26
|
+
s.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
s.add_development_dependency('rspec')
|
28
|
+
s.add_development_dependency('rubocop', '~> 0.63.1')
|
29
|
+
s.add_development_dependency('simplecov', '~>0.16.1')
|
30
|
+
s.add_development_dependency('simplecov-console', '~>0.4.2')
|
31
|
+
end
|
@@ -0,0 +1,116 @@
|
|
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
|
+
require 'spec_helper'
|
11
|
+
|
12
|
+
describe Objectable::Resolver do
|
13
|
+
subject { described_class.new }
|
14
|
+
|
15
|
+
context 'when input is a hash' do
|
16
|
+
let(:input) do
|
17
|
+
{
|
18
|
+
'id' => 1,
|
19
|
+
demographics: {
|
20
|
+
'first' => 'Matt'
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#get' do
|
26
|
+
it 'resolves correct value' do
|
27
|
+
expect(subject.get(input, :id)).to eq(input['id'])
|
28
|
+
expect(subject.get(input, 'id')).to eq(input['id'])
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'resolves correct value for nested objects' do
|
32
|
+
expect(subject.get(input, 'demographics.first')).to eq(input.dig(:demographics, 'first'))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#set' do
|
37
|
+
it 'sets correct value' do
|
38
|
+
subject.set(input, :active, true)
|
39
|
+
expect(subject.get(input, :active)).to be true
|
40
|
+
expect(subject.get(input, 'active')).to be true
|
41
|
+
|
42
|
+
subject.set(input, 'super_power', :thunder)
|
43
|
+
expect(subject.get(input, 'super_power')).to eq(:thunder)
|
44
|
+
expect(subject.get(input, :super_power)).to eq(:thunder)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'sets correct value for nested objects' do
|
48
|
+
subject.set(input, :'statuses.active', true)
|
49
|
+
expect(subject.get(input, 'statuses.active')).to be true
|
50
|
+
expect(subject.get(input, :'statuses.active')).to be true
|
51
|
+
|
52
|
+
subject.set(input, 'powers.super_power', :thunder)
|
53
|
+
expect(subject.get(input, 'powers.super_power')).to eq(:thunder)
|
54
|
+
expect(subject.get(input, :'powers.super_power')).to eq(:thunder)
|
55
|
+
|
56
|
+
expect(subject.get(input, 'powers')).to eq('super_power' => :thunder)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when input is an OpenStruct' do
|
62
|
+
let(:input) do
|
63
|
+
OpenStruct.new(
|
64
|
+
id: 1,
|
65
|
+
demographics: OpenStruct.new(
|
66
|
+
first: 'Matt'
|
67
|
+
)
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#get' do
|
72
|
+
it 'resolves correct value' do
|
73
|
+
expect(subject.get(input, :id)).to eq(input.id)
|
74
|
+
expect(subject.get(input, 'id')).to eq(input.id)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'resolves correct value for nested objects' do
|
78
|
+
expect(subject.get(input, 'demographics.first')).to eq(input.demographics.first)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#set' do
|
83
|
+
it 'sets correct value' do
|
84
|
+
subject.set(input, :active, true)
|
85
|
+
expect(subject.get(input, :active)).to be true
|
86
|
+
expect(subject.get(input, 'active')).to be true
|
87
|
+
|
88
|
+
subject.set(input, 'super_power', :thunder)
|
89
|
+
expect(subject.get(input, 'super_power')).to eq(:thunder)
|
90
|
+
expect(subject.get(input, :super_power)).to eq(:thunder)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'sets overrides existing value' do
|
94
|
+
subject.set(input, :id, 999)
|
95
|
+
expect(subject.get(input, :id)).to eq(999)
|
96
|
+
expect(subject.get(input, 'id')).to eq(999)
|
97
|
+
|
98
|
+
subject.set(input, 'id', 123)
|
99
|
+
expect(subject.get(input, :id)).to eq(123)
|
100
|
+
expect(subject.get(input, 'id')).to eq(123)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'set correct value for nested objects' do
|
104
|
+
subject.set(input, :'statuses.active', true)
|
105
|
+
expect(subject.get(input, 'statuses.active')).to be true
|
106
|
+
expect(subject.get(input, :'statuses.active')).to be true
|
107
|
+
|
108
|
+
subject.set(input, 'powers.super_power', :thunder)
|
109
|
+
expect(subject.get(input, 'powers.super_power')).to eq(:thunder)
|
110
|
+
expect(subject.get(input, :'powers.super_power')).to eq(:thunder)
|
111
|
+
|
112
|
+
expect(subject.get(input, 'powers')).to eq(OpenStruct.new('super_power' => :thunder))
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,137 @@
|
|
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 Objectable do
|
13
|
+
describe '#resolver' do
|
14
|
+
specify 'with no arguments' do
|
15
|
+
resolver = described_class.resolver
|
16
|
+
|
17
|
+
expect(resolver).to be_a(Objectable::Resolver)
|
18
|
+
expect(resolver.separator).to eq('.')
|
19
|
+
end
|
20
|
+
|
21
|
+
specify 'with arguments' do
|
22
|
+
resolver1 = described_class.resolver(separator: '$')
|
23
|
+
resolver2 = described_class.resolver(separator: '$')
|
24
|
+
|
25
|
+
expect(resolver1).to eq(resolver2)
|
26
|
+
expect(resolver1.separator).to eq('$')
|
27
|
+
expect(resolver2.separator).to eq('$')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'README examples' do
|
32
|
+
Employee = Struct.new(:id, :demographics)
|
33
|
+
Demographics = Struct.new(:first)
|
34
|
+
|
35
|
+
let(:symbol_based_hash) do
|
36
|
+
{ id: 1, demographics: { first: 'Matt' } }
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:string_based_hash) do
|
40
|
+
{ 'id' => 1, 'demographics' => { 'first' => 'Matt' } }
|
41
|
+
end
|
42
|
+
|
43
|
+
let(:open_struct) do
|
44
|
+
OpenStruct.new(id: 1, demographics: OpenStruct.new(first: 'Matt'))
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:object) do
|
48
|
+
Employee.new(1, Demographics.new('Matt'))
|
49
|
+
end
|
50
|
+
|
51
|
+
specify 'getting examples' do
|
52
|
+
resolver = Objectable.resolver
|
53
|
+
|
54
|
+
expect(resolver.get(symbol_based_hash, :id)).to eq(1)
|
55
|
+
expect(resolver.get(symbol_based_hash, 'id')).to eq(1)
|
56
|
+
expect(resolver.get(string_based_hash, :id)).to eq(1)
|
57
|
+
expect(resolver.get(string_based_hash, 'id')).to eq(1)
|
58
|
+
expect(resolver.get(open_struct, :id)).to eq(1)
|
59
|
+
expect(resolver.get(open_struct, 'id')).to eq(1)
|
60
|
+
expect(resolver.get(object, :id)).to eq(1)
|
61
|
+
expect(resolver.get(object, 'id')).to eq(1)
|
62
|
+
|
63
|
+
expect(resolver.get(symbol_based_hash, :'demographics.first')).to eq('Matt')
|
64
|
+
expect(resolver.get(symbol_based_hash, 'demographics.first')).to eq('Matt')
|
65
|
+
expect(resolver.get(string_based_hash, :'demographics.first')).to eq('Matt')
|
66
|
+
expect(resolver.get(string_based_hash, 'demographics.first')).to eq('Matt')
|
67
|
+
expect(resolver.get(open_struct, :'demographics.first')).to eq('Matt')
|
68
|
+
expect(resolver.get(open_struct, 'demographics.first')).to eq('Matt')
|
69
|
+
expect(resolver.get(object, :'demographics.first')).to eq('Matt')
|
70
|
+
expect(resolver.get(object, 'demographics.first')).to eq('Matt')
|
71
|
+
end
|
72
|
+
|
73
|
+
specify 'setting examples using symbols' do
|
74
|
+
resolver = Objectable.resolver
|
75
|
+
|
76
|
+
resolver.set(symbol_based_hash, :id, 999)
|
77
|
+
resolver.set(string_based_hash, :id, 999)
|
78
|
+
resolver.set(open_struct, :id, 999)
|
79
|
+
resolver.set(object, :id, 999)
|
80
|
+
|
81
|
+
expect(resolver.get(symbol_based_hash, :id)).to eq(999)
|
82
|
+
expect(resolver.get(symbol_based_hash, 'id')).to eq(999)
|
83
|
+
expect(resolver.get(string_based_hash, :id)).to eq(999)
|
84
|
+
expect(resolver.get(string_based_hash, 'id')).to eq(999)
|
85
|
+
expect(resolver.get(open_struct, :id)).to eq(999)
|
86
|
+
expect(resolver.get(open_struct, 'id')).to eq(999)
|
87
|
+
expect(resolver.get(object, :id)).to eq(999)
|
88
|
+
expect(resolver.get(object, 'id')).to eq(999)
|
89
|
+
|
90
|
+
resolver.set(symbol_based_hash, :'demographics.first', 'Nick')
|
91
|
+
resolver.set(string_based_hash, :'demographics.first', 'Nick')
|
92
|
+
resolver.set(open_struct, :'demographics.first', 'Nick')
|
93
|
+
resolver.set(object, :'demographics.first', 'Nick')
|
94
|
+
|
95
|
+
expect(resolver.get(symbol_based_hash, :'demographics.first')).to eq('Nick')
|
96
|
+
expect(resolver.get(symbol_based_hash, 'demographics.first')).to eq('Nick')
|
97
|
+
expect(resolver.get(string_based_hash, :'demographics.first')).to eq('Nick')
|
98
|
+
expect(resolver.get(string_based_hash, 'demographics.first')).to eq('Nick')
|
99
|
+
expect(resolver.get(open_struct, :'demographics.first')).to eq('Nick')
|
100
|
+
expect(resolver.get(open_struct, 'demographics.first')).to eq('Nick')
|
101
|
+
expect(resolver.get(object, :'demographics.first')).to eq('Nick')
|
102
|
+
expect(resolver.get(object, 'demographics.first')).to eq('Nick')
|
103
|
+
end
|
104
|
+
|
105
|
+
specify 'setting examples using strings' do
|
106
|
+
resolver = Objectable.resolver
|
107
|
+
|
108
|
+
resolver.set(symbol_based_hash, 'id', 999)
|
109
|
+
resolver.set(string_based_hash, 'id', 999)
|
110
|
+
resolver.set(open_struct, 'id', 999)
|
111
|
+
resolver.set(object, 'id', 999)
|
112
|
+
|
113
|
+
expect(resolver.get(symbol_based_hash, :id)).to eq(999)
|
114
|
+
expect(resolver.get(symbol_based_hash, 'id')).to eq(999)
|
115
|
+
expect(resolver.get(string_based_hash, :id)).to eq(999)
|
116
|
+
expect(resolver.get(string_based_hash, 'id')).to eq(999)
|
117
|
+
expect(resolver.get(open_struct, :id)).to eq(999)
|
118
|
+
expect(resolver.get(open_struct, 'id')).to eq(999)
|
119
|
+
expect(resolver.get(object, :id)).to eq(999)
|
120
|
+
expect(resolver.get(object, 'id')).to eq(999)
|
121
|
+
|
122
|
+
resolver.set(symbol_based_hash, 'demographics.first', 'Nick')
|
123
|
+
resolver.set(string_based_hash, 'demographics.first', 'Nick')
|
124
|
+
resolver.set(open_struct, 'demographics.first', 'Nick')
|
125
|
+
resolver.set(object, 'demographics.first', 'Nick')
|
126
|
+
|
127
|
+
expect(resolver.get(symbol_based_hash, :'demographics.first')).to eq('Nick')
|
128
|
+
expect(resolver.get(symbol_based_hash, 'demographics.first')).to eq('Nick')
|
129
|
+
expect(resolver.get(string_based_hash, :'demographics.first')).to eq('Nick')
|
130
|
+
expect(resolver.get(string_based_hash, 'demographics.first')).to eq('Nick')
|
131
|
+
expect(resolver.get(open_struct, :'demographics.first')).to eq('Nick')
|
132
|
+
expect(resolver.get(open_struct, 'demographics.first')).to eq('Nick')
|
133
|
+
expect(resolver.get(object, :'demographics.first')).to eq('Nick')
|
134
|
+
expect(resolver.get(object, 'demographics.first')).to eq('Nick')
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
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 '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
|
22
|
+
|
23
|
+
require './lib/objectable'
|
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: objectable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matthew Ruggio
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: guard-rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
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'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.63.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.63.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.16.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.16.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov-console
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.4.2
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.4.2
|
125
|
+
description: ''
|
126
|
+
email:
|
127
|
+
- mruggio@bluemarblepayroll.com
|
128
|
+
executables:
|
129
|
+
- console
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".editorconfig"
|
134
|
+
- ".gitignore"
|
135
|
+
- ".rubocop.yml"
|
136
|
+
- ".ruby-version"
|
137
|
+
- ".travis.yml"
|
138
|
+
- CHANGELOG.md
|
139
|
+
- CODE_OF_CONDUCT.md
|
140
|
+
- Gemfile
|
141
|
+
- Gemfile.lock
|
142
|
+
- Guardfile
|
143
|
+
- LICENSE
|
144
|
+
- README.md
|
145
|
+
- Rakefile
|
146
|
+
- bin/console
|
147
|
+
- lib/objectable.rb
|
148
|
+
- lib/objectable/interface.rb
|
149
|
+
- lib/objectable/resolver.rb
|
150
|
+
- lib/objectable/version.rb
|
151
|
+
- objectable.gemspec
|
152
|
+
- spec/objectable/resolver_spec.rb
|
153
|
+
- spec/objectable_spec.rb
|
154
|
+
- spec/spec_helper.rb
|
155
|
+
homepage: https://github.com/bluemarblepayroll/objectable
|
156
|
+
licenses:
|
157
|
+
- MIT
|
158
|
+
metadata: {}
|
159
|
+
post_install_message:
|
160
|
+
rdoc_options: []
|
161
|
+
require_paths:
|
162
|
+
- lib
|
163
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 2.3.8
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
requirements: []
|
174
|
+
rubygems_version: 3.0.1
|
175
|
+
signing_key:
|
176
|
+
specification_version: 4
|
177
|
+
summary: Unified get/set interface for disparate objects
|
178
|
+
test_files:
|
179
|
+
- spec/objectable/resolver_spec.rb
|
180
|
+
- spec/objectable_spec.rb
|
181
|
+
- spec/spec_helper.rb
|