client-data-adapter 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 +4 -4
- data/README.md +9 -26
- data/client-data-adapter.gemspec +3 -1
- data/lib/client-data-adapter.rb +5 -0
- data/spec/adapter_spec.rb +1 -1
- data/spec/adapter_wrapper_spec.rb +1 -1
- data/spec/link_spec.rb +1 -1
- metadata +2 -3
- data/spec/demo_spec.rb +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5929dffa53704cde41c2ab3f5472f688678fa8de7a0383e638a3b52781176fa9
|
|
4
|
+
data.tar.gz: d1be7b858a73bdb311833b68cb9895d63855dbfc46ba0f6040ad5cd8ee018389
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 04bef8fde33f7b9107defcf0e13bfabaf25d35ee8dd7b7f106f13e70285cc21cb628ebb07cae95383e21cc0f4f3cb4b2794a9643065c0f20df27b3f4297304a7
|
|
7
|
+
data.tar.gz: '08624aa572e2e24c816eb57140c1357de7ef3a0201bbf8a8d0d506019abced4d65e6c1b6cd8805264ac874076c32c4b82179caaa49d9dd277bfd078304c7256f'
|
data/README.md
CHANGED
|
@@ -47,7 +47,8 @@ include ClientDataAdapter
|
|
|
47
47
|
|
|
48
48
|
define_adapter do
|
|
49
49
|
|
|
50
|
-
# define your adapter here
|
|
50
|
+
# define your adapter here.
|
|
51
|
+
# ...
|
|
51
52
|
|
|
52
53
|
end
|
|
53
54
|
|
|
@@ -55,7 +56,7 @@ end
|
|
|
55
56
|
|
|
56
57
|
### `adapter`
|
|
57
58
|
|
|
58
|
-
`adapter` method define the main adapter,
|
|
59
|
+
`adapter` method define the main adapter, should return a `Hash`.
|
|
59
60
|
|
|
60
61
|
```ruby
|
|
61
62
|
# ...
|
|
@@ -84,8 +85,8 @@ In elsewhere
|
|
|
84
85
|
|
|
85
86
|
### `with`
|
|
86
87
|
|
|
87
|
-
And you
|
|
88
|
-
they maybe need some cost and
|
|
88
|
+
And you probably need some complex calculation or related some other class,
|
|
89
|
+
they maybe need some cost and is unnecessary to load everywhere.
|
|
89
90
|
|
|
90
91
|
So we need use them *on-demand*.
|
|
91
92
|
|
|
@@ -165,8 +166,6 @@ end
|
|
|
165
166
|
or this
|
|
166
167
|
|
|
167
168
|
```ruby
|
|
168
|
-
# ...
|
|
169
|
-
|
|
170
169
|
with :foo do |*args|
|
|
171
170
|
args.join(',')
|
|
172
171
|
end
|
|
@@ -231,7 +230,7 @@ And you can read the adapter internal method via it.
|
|
|
231
230
|
@book.adapter_wrapper.my_method # => works
|
|
232
231
|
```
|
|
233
232
|
|
|
234
|
-
hmm... but i
|
|
233
|
+
hmm... but i'm not very recommend you to use it by this way,
|
|
235
234
|
if you need some method works alone,
|
|
236
235
|
maybe you should define it in the original class.
|
|
237
236
|
|
|
@@ -291,12 +290,13 @@ Then
|
|
|
291
290
|
```
|
|
292
291
|
|
|
293
292
|
Of course you can pass some arguments, and if you have several links,
|
|
294
|
-
|
|
293
|
+
can also used in nested.
|
|
295
294
|
|
|
296
295
|
```ruby
|
|
297
296
|
# ...
|
|
298
297
|
|
|
299
|
-
@book.adapter(book_shelf: [library: :
|
|
298
|
+
@book.adapter(book_shelf: [:foo, library: :bar])
|
|
299
|
+
# => { ..., book_shelf: { ..., foo: ..., library: { ..., bar: ... } } }
|
|
300
300
|
```
|
|
301
301
|
|
|
302
302
|
And can define many links once.
|
|
@@ -336,23 +336,6 @@ end
|
|
|
336
336
|
|
|
337
337
|
```
|
|
338
338
|
|
|
339
|
-
```ruby
|
|
340
|
-
# category.rb
|
|
341
|
-
|
|
342
|
-
define_adapter do
|
|
343
|
-
|
|
344
|
-
adapter do
|
|
345
|
-
{
|
|
346
|
-
id: id,
|
|
347
|
-
desc: desc,
|
|
348
|
-
}
|
|
349
|
-
end
|
|
350
|
-
|
|
351
|
-
end
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
Then
|
|
355
|
-
|
|
356
339
|
```ruby
|
|
357
340
|
@book.adapter(:categories)
|
|
358
341
|
# => { id: 1, title: 'My Book', categories: @book.categories.map(&:adapter) }
|
data/client-data-adapter.gemspec
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
lib = File.expand_path('../lib', __FILE__)
|
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
|
4
|
+
require_relative './lib/client-data-adapter/version'
|
|
5
|
+
|
|
4
6
|
Gem::Specification.new do |s|
|
|
5
7
|
|
|
6
8
|
s.name = 'client-data-adapter'
|
|
7
|
-
s.version =
|
|
9
|
+
s.version = ClientDataAdapter::VERSION
|
|
8
10
|
s.summary = 'client data adapter'
|
|
9
11
|
s.description = 'For unify data formats to transfer to clients.'
|
|
10
12
|
s.authors = ['shadow']
|
data/lib/client-data-adapter.rb
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
require_relative 'client-data-adapter/class_methods'
|
|
2
2
|
require_relative 'client-data-adapter/instance_methods'
|
|
3
3
|
|
|
4
|
+
# For unify data formats to transfer to clients.
|
|
5
|
+
#
|
|
6
|
+
# Homepage https://github.com/jinghua000/client-data-adapter
|
|
7
|
+
#
|
|
8
|
+
# @author shadow <https://github.com/jinghua000>
|
|
4
9
|
module ClientDataAdapter
|
|
5
10
|
|
|
6
11
|
def self.included(base)
|
data/spec/adapter_spec.rb
CHANGED
data/spec/link_spec.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: client-data-adapter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- shadow
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-12-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: For unify data formats to transfer to clients.
|
|
14
14
|
email:
|
|
@@ -37,7 +37,6 @@ files:
|
|
|
37
37
|
- lib/client-data-adapter/wrapper.rb
|
|
38
38
|
- spec/adapter_spec.rb
|
|
39
39
|
- spec/adapter_wrapper_spec.rb
|
|
40
|
-
- spec/demo_spec.rb
|
|
41
40
|
- spec/link_spec.rb
|
|
42
41
|
- spec/spec_helper.rb
|
|
43
42
|
- update.sh
|