entity_schema 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ae5d5a58cb59d7bc39c1461dcb1f6bed390d665ff00e2493234b5a4e1149b66
4
- data.tar.gz: 637d69c9e038d9080453f93b5cbe0b716ae40a59153657f73512d6961577b486
3
+ metadata.gz: 175e615c64727f0402ec59b48af5500e84138f10c545f1da46463329d877e538
4
+ data.tar.gz: 7333bf377c6e6027565d2ff7a1dbf0083f56043db6529e6127df3f7519bd972a
5
5
  SHA512:
6
- metadata.gz: 3dcd2b61052f0ceaa9b1fd815edb9762081ff6aca02abb1ab5096e03eebb911826d1424587246b7e26964c26f327f18d31ef2d3feea833c90267b32d5eb77abc
7
- data.tar.gz: d9224aa835f73858ef679c85c71bcfe79ea159cd0c91fbdab5c69a5bd9418a6ce08ff7e8ff25ad961a82935679fc564d519b1ee177addfd0f9f567abc16a01c6
6
+ metadata.gz: 20945880185e2307906a80acc9b20ab28e0b3510fcb984c0dd40f7e569166d7d1b8608df5393c645fe046f556f645ff4954ac720b14b183d1da7a31f7065aeb6
7
+ data.tar.gz: acaefb4a8fbe2d7cfd450e03354938a5022604822a3553e083434ac6041a5a46c8a9d44b018be073758226608a8a3fec3563478f57406598e7f630ffb95c1941
data/.travis.yml CHANGED
@@ -1,5 +1,3 @@
1
1
  sudo: false
2
2
  language: ruby
3
- rvm:
4
- - 2.5.0
5
3
  before_install: gem install bundler -v 1.16.2
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.1.1]
8
+ ### Added (development-only)
9
+ + SimpleCov
10
+ + CodeCov
11
+
7
12
  ## [0.1.0]
8
13
  ### Added
9
14
  + All base functionality with main specs (141 example)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- entity_schema (0.1.0)
4
+ entity_schema (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -9,8 +9,13 @@ GEM
9
9
  byebug (10.0.2)
10
10
  childprocess (0.9.0)
11
11
  ffi (~> 1.0, >= 1.0.11)
12
+ codecov (0.1.10)
13
+ json
14
+ simplecov
15
+ url
12
16
  coderay (1.1.2)
13
17
  diff-lcs (1.3)
18
+ docile (1.3.1)
14
19
  ffi (1.9.25)
15
20
  formatador (0.2.5)
16
21
  guard (2.14.2)
@@ -32,6 +37,7 @@ GEM
32
37
  guard-compat (~> 1.1)
33
38
  rspec (>= 2.99.0, < 4.0)
34
39
  iniparse (1.4.4)
40
+ json (2.1.0)
35
41
  listen (3.1.5)
36
42
  rb-fsevent (~> 0.9, >= 0.9.4)
37
43
  rb-inotify (~> 0.9, >= 0.9.7)
@@ -70,7 +76,13 @@ GEM
70
76
  rspec-support (3.8.0)
71
77
  ruby_dep (1.5.0)
72
78
  shellany (0.0.1)
79
+ simplecov (0.16.1)
80
+ docile (~> 1.1)
81
+ json (>= 1.8, < 3)
82
+ simplecov-html (~> 0.10.0)
83
+ simplecov-html (0.10.2)
73
84
  thor (0.20.0)
85
+ url (0.3.2)
74
86
 
75
87
  PLATFORMS
76
88
  ruby
@@ -78,6 +90,7 @@ PLATFORMS
78
90
  DEPENDENCIES
79
91
  bundler (~> 1.16)
80
92
  byebug
93
+ codecov
81
94
  entity_schema!
82
95
  guard
83
96
  guard-bundler
@@ -87,6 +100,7 @@ DEPENDENCIES
87
100
  pry-byebug
88
101
  rake (~> 10.0)
89
102
  rspec (~> 3.0)
103
+ simplecov
90
104
 
91
105
  BUNDLED WITH
92
106
  1.16.3
data/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # EntitySchema
2
- Class-level DSL for mapping Hash with object-like structure to Object (as Entity), and then return it into Hash.
2
+ [![Gem Version](https://badge.fury.io/rb/entity_schema.svg)](https://badge.fury.io/rb/entity_schema)
3
+ [![Build Status](https://travis-ci.org/CaptainPhilipp/entity_schema.svg?branch=master)](https://travis-ci.org/CaptainPhilipp/entity_schema)
4
+ [![codecov](https://codecov.io/gh/CaptainPhilipp/entity_schema/branch/master/graph/badge.svg)](https://codecov.io/gh/CaptainPhilipp/entity_schema)
3
5
 
4
- Focused on quick, minimal, lazy interaction with source Hash.
6
+ Class-level DSL for mapping Hash with object-like structure to Object (as Entity), and then return it into Hash.
5
7
 
6
- #### Describe entity structure:
7
8
  ```ruby
8
9
  class Product
9
10
  property :id
@@ -16,12 +17,29 @@ class Product
16
17
 
17
18
  object :size, map_to: Values::Size
18
19
 
19
- belongs_to :color, { color_uid: :uid }, map_to: Color
20
- has_many :seasons, map_to: Season
20
+ belongs_to :color, map_to: Color, pk: :color_uid, fk: :uid
21
+ has_many :seasons, map_to: Season
21
22
  end
22
23
  ```
23
24
 
24
- #### Create entity from hash:
25
+ ## Motivation
26
+
27
+ When you work with plain hashes (`Sequel`, `ROM`, `json`/`xml`-sourced data, etc), and want to describe some ___entities___ or ___value objects___ (DDD patterns).
28
+
29
+ Ok, if `ROM`, why not `ROM::Struct`?
30
+
31
+ If you using `ROM` with it's `ROM::Struct`, you may encounter some things that do not satisfy some needs: private attributes, value object mapping, may be something other.
32
+
33
+ ## Installation
34
+
35
+ in Gemfile add
36
+ ```
37
+ gem 'entity_schema'
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ### Create entity from hash:
25
43
  ```ruby
26
44
  raw_hash = {
27
45
  id: 42,
@@ -51,20 +69,20 @@ product.color_uid # => nil
51
69
 
52
70
  #### Return entity to hash:
53
71
  ```ruby
54
- product.to_h
55
- # => {
56
- # => id: 42,
57
- # => title: 'Perfect product',
58
- # => enabled: true,
59
- # => is_new: false,
60
- # => is_sale: false,
61
- # => is_bestseller: true,
62
- # => created_at: '2018-08-16 20:17:55 UTC',
63
- # => updated_at: '2018-08-16 20:17:55 UTC',
64
- # => size: { ... size params ... },
65
- # => color_uid: nil,
66
- # => seasons: [{ ... seasons params ... }, {...}, ...]
67
- # => }
72
+ product.to_h # =>
73
+ {
74
+ id: 42,
75
+ title: 'Perfect product',
76
+ enabled: true,
77
+ is_new: false,
78
+ is_sale: false,
79
+ is_bestseller: true,
80
+ created_at: '2018-08-16 20:17:55 UTC',
81
+ updated_at: '2018-08-16 20:17:55 UTC',
82
+ size: { ... size params ... },
83
+ color_uid: nil,
84
+ seasons: [{ ... seasons params ... }, {...}, ...]
85
+ }
68
86
  ```
69
87
 
70
88
  ## Validations, and coercions
@@ -73,42 +91,44 @@ No. Entity assumes that given data already validated and coerced.
73
91
 
74
92
  ## DSL
75
93
 
76
- #### property
94
+ ### `property`
77
95
 
78
- _TODO_
96
+ _TODO: description_
79
97
 
80
- #### property?
98
+ ### `property?`
81
99
 
82
- _TODO_
100
+ _TODO: description_
83
101
 
84
- #### timestamps
102
+ ### `timestamps`
85
103
 
86
- It is sugar, that expanded to:
104
+ _Not implemented_
105
+
106
+ Just sugar, same as:
87
107
  ```ruby
88
108
  property :created_at, **opts
89
109
  property :updated_at, **opts
90
110
  ```
91
111
 
92
- #### object
112
+ ### `object`
93
113
 
94
- _TODO_
114
+ _TODO: description_
95
115
 
96
- #### has_one
116
+ ### `collection`
97
117
 
98
- Just alias for `object`
118
+ _TODO: description_
99
119
 
100
- #### collection
120
+ ### `has_one`
101
121
 
102
- _TODO_
122
+ Just alias for `object`
103
123
 
104
- #### has_many
124
+ ### `has_many`
105
125
 
106
126
  Just alias for `collection`
107
127
 
108
- #### belongs_to
128
+ ### `belongs_to`
109
129
 
110
- _TODO_
130
+ _TODO: description_
111
131
 
112
132
  ## Instance methods
113
133
 
114
- _TODO_
134
+ _TODO: description_
@@ -12,8 +12,8 @@ Gem::Specification.new do |spec|
12
12
  spec.email = ['ph-s@mail.ru']
13
13
 
14
14
  spec.summary = 'DSL for describe Entities'
15
- spec.description = 'DSL for describe Entities that can have value objects, ' \
16
- 'associations and properties. Focused on performance and simplicity'
15
+ spec.description = 'Simple DSL for describe schema of mapping Hash to entity Object, ' \
16
+ 'and then vice-versa'
17
17
  spec.homepage = 'https://github.com/CaptainPhilipp/entity_schema'
18
18
  spec.license = 'MIT'
19
19
 
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
24
24
  else
25
25
  raise 'RubyGems 2.0 or newer is required to protect against ' \
26
- 'public gem pushes.'
26
+ 'public gem pushes.'
27
27
  end
28
28
 
29
29
  # Specify which files should be added to the gem when it is released.
@@ -43,6 +43,9 @@ Gem::Specification.new do |spec|
43
43
  spec.add_development_dependency 'rake', '~> 10.0'
44
44
  spec.add_development_dependency 'rspec', '~> 3.0'
45
45
 
46
+ spec.add_development_dependency 'codecov'
47
+ spec.add_development_dependency 'simplecov'
48
+
46
49
  spec.add_development_dependency 'guard'
47
50
  spec.add_development_dependency 'guard-bundler'
48
51
  spec.add_development_dependency 'guard-rspec'
@@ -41,9 +41,11 @@ module EntitySchema
41
41
  write(obj, value)
42
42
  end
43
43
 
44
+ # :nocov:
44
45
  def get(_obj)
45
46
  raise NotImplementedError
46
47
  end
48
+ # :nocov:
47
49
 
48
50
  def predicate?
49
51
  false
@@ -46,9 +46,11 @@ module EntitySchema
46
46
  end
47
47
  # rubocop:enable Metrics/AbcSize:
48
48
 
49
+ # :nocov:
49
50
  def field_klass
50
51
  raise NotImplementedError
51
52
  end
53
+ # :nocov:
52
54
 
53
55
  # Helpers
54
56
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EntitySchema
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entity_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Captain Philipp
@@ -108,6 +108,34 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: codecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
111
139
  - !ruby/object:Gem::Dependency
112
140
  name: guard
113
141
  requirement: !ruby/object:Gem::Requirement
@@ -150,8 +178,8 @@ dependencies:
150
178
  - - ">="
151
179
  - !ruby/object:Gem::Version
152
180
  version: '0'
153
- description: DSL for describe Entities that can have value objects, associations and
154
- properties. Focused on performance and simplicity
181
+ description: Simple DSL for describe schema of mapping Hash to entity Object, and
182
+ then vice-versa
155
183
  email:
156
184
  - ph-s@mail.ru
157
185
  executables: []