mimi-struct 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +39 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/examples/customer.rb +22 -0
- data/lib/mimi/struct.rb +224 -0
- data/lib/mimi/struct/version.rb +9 -0
- data/mimi-struct.gemspec +38 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4ce18d3926ef7a9a05740b35362bd3c8d285f6ea
|
4
|
+
data.tar.gz: 0b668e2e2e2424ccdc1b792aa6c83748a5e6ab54
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '0478d07e8a60c92362638ae261410d4cb96889958b192920d935ce0a5fa2cbdfd7907c27f0ae495273223bc143bb1850aa8490e3960dbd3f4864bb1baa70ba44'
|
7
|
+
data.tar.gz: 1523ca2197640b826f7b7a524ccd45763bc857c7e53d32620686de912bcc0bc3ebd711166fe5e7c5c33d5919a61a2d8b7ede0b64b73693b5327e18ff72053927
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
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 alex@kukushk.in. 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,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mimi-struct (0.1.0)
|
5
|
+
mimi-core (~> 1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
hashie (3.6.0)
|
12
|
+
mimi-core (1.0.0)
|
13
|
+
hashie (~> 3.6)
|
14
|
+
rake (10.5.0)
|
15
|
+
rspec (3.8.0)
|
16
|
+
rspec-core (~> 3.8.0)
|
17
|
+
rspec-expectations (~> 3.8.0)
|
18
|
+
rspec-mocks (~> 3.8.0)
|
19
|
+
rspec-core (3.8.1)
|
20
|
+
rspec-support (~> 3.8.0)
|
21
|
+
rspec-expectations (3.8.4)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.8.0)
|
24
|
+
rspec-mocks (3.8.1)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.8.0)
|
27
|
+
rspec-support (3.8.2)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
bundler (~> 2.0)
|
34
|
+
mimi-struct!
|
35
|
+
rake (~> 10.0)
|
36
|
+
rspec (~> 3.0)
|
37
|
+
|
38
|
+
BUNDLED WITH
|
39
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Alex Kukushkin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# WIP: Mimi::Struct
|
2
|
+
|
3
|
+
Object to Object mapper.
|
4
|
+
|
5
|
+
Allows you to map a PORO, Struct, OpenStruct or a Hash into a simple Ruby object
|
6
|
+
with predefined schema and transformation rules.
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
require "mimi/struct"
|
12
|
+
|
13
|
+
class Customer < Mimi::Struct
|
14
|
+
attribute :id
|
15
|
+
attribute :type, using: -> (o) { o.type.to_s.upcase }
|
16
|
+
|
17
|
+
group if: -> (o) { o.type == :person } do
|
18
|
+
attribute :first_name, from: :firstName
|
19
|
+
attribute :last_name, from: :lastName
|
20
|
+
end
|
21
|
+
|
22
|
+
group if: -> (o) { o.type == :company } do
|
23
|
+
attribute :company_name
|
24
|
+
end
|
25
|
+
|
26
|
+
attribute :created_at, default: -> { Time.now.utc }
|
27
|
+
attribute :updated_at, default: -> { Time.now.utc }
|
28
|
+
end
|
29
|
+
|
30
|
+
customer = Customer << { id: "person1", type: :person, firstName: "John", lastName: "Smith" }
|
31
|
+
|
32
|
+
puts customer.to_h
|
33
|
+
# {
|
34
|
+
# :id=>"person1", :type=>"PERSON", :first_name=>"John", :last_name=>"Smith",
|
35
|
+
# :created_at=>2019-06-23 16:07:30 UTC, :updated_at=>2019-06-23 16:07:30 UTC
|
36
|
+
# }
|
37
|
+
```
|
38
|
+
|
39
|
+
## Defining your Mimi::Struct schema
|
40
|
+
|
41
|
+
### :from
|
42
|
+
### :using
|
43
|
+
### :default
|
44
|
+
### :if
|
45
|
+
### :optional
|
46
|
+
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kukushkin/mimi-struct. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
55
|
+
|
56
|
+
## Code of Conduct
|
57
|
+
|
58
|
+
Everyone interacting in the Mimi::Struct project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kukushkin/mimi-struct/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "mimi/struct"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "mimi/struct"
|
2
|
+
|
3
|
+
class Customer < Mimi::Struct
|
4
|
+
attribute :id
|
5
|
+
attribute :type, using: -> (o) { o.type.to_s.upcase }
|
6
|
+
|
7
|
+
group if: -> (o) { o.type == :person } do
|
8
|
+
attribute :first_name, from: :firstName
|
9
|
+
attribute :last_name, from: :lastName
|
10
|
+
end
|
11
|
+
|
12
|
+
group if: -> (o) { o.type == :company } do
|
13
|
+
attribute :company_name
|
14
|
+
end
|
15
|
+
|
16
|
+
attribute :created_at, default: -> { Time.now.utc }
|
17
|
+
attribute :updated_at, default: -> { Time.now.utc }
|
18
|
+
end
|
19
|
+
|
20
|
+
customer = Customer << { id: "person1", type: :person, firstName: "John", lastName: "Smith" }
|
21
|
+
|
22
|
+
puts customer.to_h
|
data/lib/mimi/struct.rb
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mimi
|
4
|
+
#
|
5
|
+
# A Struct that can be initialized from a Hash or another Struct.
|
6
|
+
#
|
7
|
+
# A Struct declares its attributes and rules, which define how its attrubutes
|
8
|
+
# are mapped from input data.
|
9
|
+
#
|
10
|
+
class Struct < ::Struct
|
11
|
+
|
12
|
+
# Default attribute mapper
|
13
|
+
#
|
14
|
+
# Maps value of the source attribute to the target attribute.
|
15
|
+
# Calculates a default value if the source attribute is not set.
|
16
|
+
#
|
17
|
+
DEFAULT_ATTRIBUTE_MAPPER = -> (o, params) do
|
18
|
+
if params.key?(:default)
|
19
|
+
o.to_h.key?(params[:from]) || call_as_proc(params[:default], o, params)
|
20
|
+
else
|
21
|
+
o[params[:from]]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Default :if block for an optional attribute
|
26
|
+
#
|
27
|
+
# Skips the attribute if the source attribute is not set.
|
28
|
+
#
|
29
|
+
DEFAULT_IF_FOR_OPTIONAL = -> (o, params) do
|
30
|
+
o.to_h.key?(params[:from])
|
31
|
+
end
|
32
|
+
|
33
|
+
# Presents this Struct as a Hash, deeply converting nested Structs
|
34
|
+
#
|
35
|
+
# @return [Hash]
|
36
|
+
#
|
37
|
+
def to_h
|
38
|
+
super.map do |k, v|
|
39
|
+
[k, self.class.value_to_h(v)]
|
40
|
+
end.to_h
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns attributes of this Structs as a Hash
|
44
|
+
#
|
45
|
+
# @return [Hash]
|
46
|
+
#
|
47
|
+
def attributes
|
48
|
+
to_h
|
49
|
+
end
|
50
|
+
|
51
|
+
# An attribute definition
|
52
|
+
#
|
53
|
+
# Possible params:
|
54
|
+
# from: <Symbol>
|
55
|
+
# using: <proc,Mimi::Struct>
|
56
|
+
# if: <proc>
|
57
|
+
# default: <proc,Object>
|
58
|
+
# optional: <true,false>
|
59
|
+
#
|
60
|
+
# @param name [Symbol]
|
61
|
+
# @param params [Hash]
|
62
|
+
#
|
63
|
+
def self.attribute(name, params = {})
|
64
|
+
name = name.to_sym
|
65
|
+
raise "Attribute '#{name}' is already declared" if attribute_definitions.key?(name)
|
66
|
+
defaults = group_params.reduce(:merge).merge(
|
67
|
+
from: name,
|
68
|
+
using: DEFAULT_ATTRIBUTE_MAPPER
|
69
|
+
)
|
70
|
+
params = defaults.merge(params)
|
71
|
+
if params.key?(:if) && params.key?(:optional)
|
72
|
+
raise ArgumentError, "Keys :if and :optional cannot be used together"
|
73
|
+
end
|
74
|
+
params[:if] = DEFAULT_IF_FOR_OPTIONAL if params[:optional]
|
75
|
+
add_attribute_definition(name, params)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Declare a group of parameters with common options
|
79
|
+
#
|
80
|
+
# E.g.
|
81
|
+
# Class User < Mimi::Struct
|
82
|
+
# attribute :id
|
83
|
+
# attribute :type
|
84
|
+
# attribute :name
|
85
|
+
# group if: -> (o) { o.type == 'ADMIN' } do
|
86
|
+
# attribute :admin_role
|
87
|
+
# attribute :admin_domain
|
88
|
+
# end
|
89
|
+
# group default: -> { Time.now.utc } do
|
90
|
+
# attribute :created_at
|
91
|
+
# attribute :updated_at
|
92
|
+
# end
|
93
|
+
# end
|
94
|
+
#
|
95
|
+
# NOTE: Not reentrable.
|
96
|
+
#
|
97
|
+
# @param params [Hash]
|
98
|
+
#
|
99
|
+
def self.group(params, &block)
|
100
|
+
group_params << params
|
101
|
+
yield
|
102
|
+
group_params.pop
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
# Converts a single object or collection to Struct.
|
107
|
+
#
|
108
|
+
def self.<<(obj_or_collection)
|
109
|
+
if obj_or_collection.is_a?(Array)
|
110
|
+
obj_or_collection.map { |o| self << o }
|
111
|
+
else
|
112
|
+
transform(obj_or_collection)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Returns a Hash of attribute definitions
|
117
|
+
#
|
118
|
+
# @return [Hash]
|
119
|
+
#
|
120
|
+
private_class_method def self.attribute_definitions
|
121
|
+
@attribute_definitions ||= {}
|
122
|
+
# merge with base class
|
123
|
+
defined?(super) ? super.merge(@attribute_definitions) : @attribute_definitions
|
124
|
+
end
|
125
|
+
|
126
|
+
# Adds a new attribute definition
|
127
|
+
#
|
128
|
+
# @param name [Symbol]
|
129
|
+
# @param params [Hash]
|
130
|
+
#
|
131
|
+
private_class_method def self.add_attribute_definition(name, params)
|
132
|
+
@attribute_definitions ||= {}
|
133
|
+
@attribute_definitions[name] = params.dup
|
134
|
+
end
|
135
|
+
|
136
|
+
# Returns current stack of group parameters
|
137
|
+
#
|
138
|
+
# @return [Array<Hash>]
|
139
|
+
#
|
140
|
+
private_class_method def self.group_params
|
141
|
+
@group_params ||= [{}]
|
142
|
+
end
|
143
|
+
|
144
|
+
# Creates a Struct instance from given parameters
|
145
|
+
#
|
146
|
+
# @param source [Struct,Hash]
|
147
|
+
#
|
148
|
+
private_class_method def self.transform(source)
|
149
|
+
if source.is_a?(Struct)
|
150
|
+
# do nothing
|
151
|
+
elsif source.is_a?(Hash)
|
152
|
+
source = Struct.new(*source.to_h.keys).new(*source.to_h.values)
|
153
|
+
else
|
154
|
+
raise ArgumentError, "Struct or Hash is expected as source"
|
155
|
+
end
|
156
|
+
attributes = transform_attributes(source)
|
157
|
+
new(*attributes.keys).new(*attributes.values)
|
158
|
+
rescue StandardError => e
|
159
|
+
raise "Failed to construct #{self}: #{e}"
|
160
|
+
end
|
161
|
+
|
162
|
+
# Transform attributes according to rules
|
163
|
+
#
|
164
|
+
# @param source [Struct]
|
165
|
+
# @return [Hash] map of attribute name -> value
|
166
|
+
#
|
167
|
+
private_class_method def self.transform_attributes(source)
|
168
|
+
attribute_definitions.map do |k, params|
|
169
|
+
if params[:if].is_a?(Proc)
|
170
|
+
next unless call_as_proc(params[:if], source, params)
|
171
|
+
end
|
172
|
+
[k, transform_single_attribute(source, k, params)]
|
173
|
+
end.compact.to_h
|
174
|
+
end
|
175
|
+
|
176
|
+
# Transforms a single attribute value according to rules passed as params
|
177
|
+
#
|
178
|
+
# @param source [Struct]
|
179
|
+
# @param key [Symbol]
|
180
|
+
# @param params [Hash] transformation rules
|
181
|
+
# @return [Object]
|
182
|
+
#
|
183
|
+
private_class_method def self.transform_single_attribute(source, key, params)
|
184
|
+
return call_as_proc(params[:using], source, params) if params[:using].is_a?(Proc)
|
185
|
+
if params[:using].is_a?(Class) && params[:using] < Mimi::Struct
|
186
|
+
return params[:using] << source[params[:from]]
|
187
|
+
end
|
188
|
+
raise "unexpected :using type: #{params[:using].class}"
|
189
|
+
rescue StandardError => e
|
190
|
+
raise "Failed to transform attribute :#{key} : #{e}"
|
191
|
+
end
|
192
|
+
|
193
|
+
# Calls a lambda as a proc, not caring about the number of arguments
|
194
|
+
#
|
195
|
+
# @param proc_or_lambda [Proc]
|
196
|
+
# @param *args
|
197
|
+
#
|
198
|
+
private_class_method def self.call_as_proc(proc, *args)
|
199
|
+
raise ArgumentError, "Proc is expected as proc" unless proc.is_a?(Proc)
|
200
|
+
if proc.lambda?
|
201
|
+
proc.call(*args.first(proc.arity))
|
202
|
+
else
|
203
|
+
proc.call(*args)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
# Map value or values to Hash
|
208
|
+
#
|
209
|
+
# @param value [Object]
|
210
|
+
#
|
211
|
+
def self.value_to_h(value)
|
212
|
+
case value
|
213
|
+
when Struct
|
214
|
+
value.to_h
|
215
|
+
when Array
|
216
|
+
value.map { |v| value_to_h(v) }
|
217
|
+
else
|
218
|
+
value
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end # class Struct
|
222
|
+
end # module Mimi
|
223
|
+
|
224
|
+
require "mimi/struct/version"
|
data/mimi-struct.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "mimi/struct/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "mimi-struct"
|
7
|
+
spec.version = Mimi::Struct::VERSION
|
8
|
+
spec.authors = ["Alex Kukushkin"]
|
9
|
+
spec.email = ["alex@kukushk.in"]
|
10
|
+
|
11
|
+
spec.summary = %q{Simple Object-to-Object mapper}
|
12
|
+
spec.description = %q{Simple Object-to-Object mapper}
|
13
|
+
spec.homepage = "https://github.com/kukushkin/mimi-struct"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
if spec.respond_to?(:metadata)
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
|
+
else
|
19
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
20
|
+
end
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
25
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
26
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
27
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_dependency "mimi-core", "~> 1.0"
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mimi-struct
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Kukushkin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mimi-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: Simple Object-to-Object mapper
|
70
|
+
email:
|
71
|
+
- alex@kukushk.in
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CODE_OF_CONDUCT.md
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- examples/customer.rb
|
88
|
+
- lib/mimi/struct.rb
|
89
|
+
- lib/mimi/struct/version.rb
|
90
|
+
- mimi-struct.gemspec
|
91
|
+
homepage: https://github.com/kukushkin/mimi-struct
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata:
|
95
|
+
allowed_push_host: https://rubygems.org
|
96
|
+
homepage_uri: https://github.com/kukushkin/mimi-struct
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.6.14.4
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Simple Object-to-Object mapper
|
117
|
+
test_files: []
|