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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODVjZmMxZDlmMjQ2MGYyMDM3NmQ2NTc4ZjA3MGIyMjc1M2QzYmFjMg==
4
+ MGM3Mzg3ZWMzNzI1OWZhYzNhZDZhMGVlZmNkODc1ZjQ3MDRlYWFlMQ==
5
5
  data.tar.gz: !binary |-
6
- ZDM4MzIxYjg3OTU2ZTI5Y2YzNDBjZGU5ODQ1N2RjZTg2N2IxYjg3Yw==
6
+ Mzk1NmQ0OTliODFmNzM3MTY2ZjY0ODhiNmNhNWYwMWI4MjRkOGMzNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTdiYTVmNjA2NjYwNDdkMzQ1ZjEwMDA4MjU5YWVjNTEyYjgzNjY4MTIzNjE0
10
- YWQ2MjI3NTBlY2RhNjU4MzQ3ZmIwZThmOGQyYTAwMmRlMjBhYjMxYzczMTFh
11
- M2QyYmNmZjdkNzc1MWFjNjFkZjU5OWIxYjZkZDVmNmU0NTQ4OTc=
9
+ YjBlNDhiZDAyYTc4MjNkYTZiMjE4YjA3ZjUxOTA2YTY0ZTU5ZDgxOTk1MGE2
10
+ Nzk0ZjViMmU4ZjBkMzJkNjNhMmI0MGE4YzJlMzBkODFkZjU4MzBjMzI3ZGM3
11
+ YzRkOGI5YTlmZTk2NmQ0MDQ2ZDM5ODFhNTMzMzU0MzE1ZjgzZDc=
12
12
  data.tar.gz: !binary |-
13
- YzkzYzgzMTRmODIzZGRiY2Q1OThiODA5OGMwODFlNTcwODU0ZjdjMDdiYWU2
14
- YjJiM2VlMzNhY2Q1N2QzZjNhOTViZWI4YWE4OGU3MzU4ZWVkNDA4YjUwZjYw
15
- M2VhYzI0NjAwZmU0OTZkZWZlMWMzNzlhOGIyODc4ZTkxNTQwYjk=
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
+
@@ -1,3 +1,3 @@
1
1
  module DocWrapper
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -1,5 +1,5 @@
1
-
2
- require 'doc_wrapper/base'
1
+ $:.push File.expand_path("../lib", __FILE__) unless $:.include? File.expand_path("../lib", __FILE__)
3
2
  module DocWrapper
3
+ require 'doc_wrapper/base'
4
4
  end
5
5
 
@@ -3,7 +3,7 @@ require File.expand_path('../boot', __FILE__)
3
3
  require 'rails/all'
4
4
 
5
5
  Bundler.require(*Rails.groups)
6
- require "doc_wrapper"
6
+ require "ds_doc_wrapper"
7
7
 
8
8
  module Dummy
9
9
  class Application < Rails::Application
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ds_doc_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - nardele salomon