ds_doc_wrapper 1.0.2 → 1.0.4
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 +8 -8
- data/README.rdoc +57 -1
- data/lib/doc_wrapper/version.rb +1 -1
- data/lib/ds_doc_wrapper.rb +2 -2
- data/test/dummy/config/application.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGM3Mzg3ZWMzNzI1OWZhYzNhZDZhMGVlZmNkODc1ZjQ3MDRlYWFlMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Mzk1NmQ0OTliODFmNzM3MTY2ZjY0ODhiNmNhNWYwMWI4MjRkOGMzNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjBlNDhiZDAyYTc4MjNkYTZiMjE4YjA3ZjUxOTA2YTY0ZTU5ZDgxOTk1MGE2
|
10
|
+
Nzk0ZjViMmU4ZjBkMzJkNjNhMmI0MGE4YzJlMzBkODFkZjU4MzBjMzI3ZGM3
|
11
|
+
YzRkOGI5YTlmZTk2NmQ0MDQ2ZDM5ODFhNTMzMzU0MzE1ZjgzZDc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWJhZjI4ZTI5NWVjMjgwMGUzODA1YzdlODAxYWE4YjZjODc5MTk4MTQ0Y2M3
|
14
|
+
NmY1M2Q5NGEwYzU0ZmQwM2YyN2JhZmE0MDllY2M5NjdjY2ZjZmYwODRjZWI3
|
15
|
+
OTVkZGRhMjExMGZjN2U4ZTYxNzk4ZTE0Y2E4MDE0NDkwNWNiZDk=
|
data/README.rdoc
CHANGED
@@ -1,3 +1,59 @@
|
|
1
1
|
= DocWrapper
|
2
2
|
|
3
|
-
This project rocks and uses MIT-LICENSE.
|
3
|
+
This project rocks and uses MIT-LICENSE.
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
Doc wrapper, convert a doc in another doc. Doc is some ruby data structure, like a Hash, Array or a simple String
|
8
|
+
|
9
|
+
The advantage is that the conversion engine is automatically identified, making the code cleaner
|
10
|
+
|
11
|
+
|
12
|
+
===== Example
|
13
|
+
|
14
|
+
:001 > DocWrapper.to_target_doc {origin: :sales, user_id: 1, account_id: 99 }
|
15
|
+
=> { user: 'John', account_name: 'xxxx' }
|
16
|
+
|
17
|
+
another example, only changes de origin key
|
18
|
+
:002 > DocWrapper.to_target_doc {owner: :billing, user_id: 1, account_id: 99 }
|
19
|
+
==> { user_name: 'john', amount: 100.87 }
|
20
|
+
|
21
|
+
== Install
|
22
|
+
|
23
|
+
$ gem install ds_doc_wrapper
|
24
|
+
|
25
|
+
== Usage
|
26
|
+
|
27
|
+
First you need define some doc wrappers
|
28
|
+
|
29
|
+
class DocWrapper:DocByTomCat
|
30
|
+
def self.to_target_doc a_doc
|
31
|
+
# -- here put you converter code
|
32
|
+
{
|
33
|
+
tom_cat_name: a_doc['name'],
|
34
|
+
tom_cat_eat: a_doc['food']
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
another doc wrapper:
|
40
|
+
|
41
|
+
class DocWrapper:DocByCook
|
42
|
+
def self.to_target_doc a_doc
|
43
|
+
# -- here put you converter code
|
44
|
+
{
|
45
|
+
name: a_doc['name'],
|
46
|
+
main: a_doc['food']
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
them:
|
52
|
+
:003 > DocWrapper::Base.to_target_doc( { owner: 'tom_cat', 'name' => 'Tom', 'food' => 'fish' } )
|
53
|
+
==> { tom_cat_name: 'Tom', tom_cat_eat: 'fish' }
|
54
|
+
|
55
|
+
:004 > DocWrapper::Base.to_target_doc( { owner: 'cook', 'name' => 'Tom', 'food' => 'fish' } )
|
56
|
+
==> { name: 'Tom', main: 'fish' }
|
57
|
+
|
58
|
+
|
59
|
+
|
data/lib/doc_wrapper/version.rb
CHANGED
data/lib/ds_doc_wrapper.rb
CHANGED