out_put 2.1.2 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +11 -2
- data/lib/out_put/version.rb +1 -1
- data/lib/out_put/view.rb +10 -0
- data/lib/out_put.rb +4 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f0bbf9be68f7e714bb08b8a421ec1466399e769
|
4
|
+
data.tar.gz: d246c2858b54288aff98ae6ac12fc63aa46c239f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82b6913f4908c1c3ac71a8b2bfe07716cce4e2405a78a714a5bb9224b0f1788ba2acc2c8fbb16d83bdaf5626ff978a68d7f3ee48d1526c6c31a0a595bb712393
|
7
|
+
data.tar.gz: 189abd12eb85aa49b3ba77f92660c010fa4d8dec07aa87a3216aa83e75986e30268149186e6df250b6b35170baae5ca946ed21f9a8ef635c854a23ed2f7dbb43
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -123,8 +123,17 @@ output 0, list: [ 1, 2, 3 ]
|
|
123
123
|
#### 8.b use `build_with` to pass an variable `@view` to your view
|
124
124
|
|
125
125
|
```ruby
|
126
|
-
build_with
|
126
|
+
build_with key: 'val'
|
127
|
+
build_with code=0, msg='success', key: 'val'
|
127
128
|
|
128
129
|
# the in your .jbuilder
|
129
|
-
json.
|
130
|
+
json.result do
|
131
|
+
json.code @view[:code] || 0
|
132
|
+
json.msg @view[:msg] || 'success'
|
133
|
+
end
|
134
|
+
json.data do
|
135
|
+
json.merge! @view.data # => expect code and msg, for example { key: 'val' }
|
136
|
+
# or
|
137
|
+
json.key @view[:key]
|
138
|
+
end
|
130
139
|
```
|
data/lib/out_put/version.rb
CHANGED
data/lib/out_put/view.rb
ADDED
data/lib/out_put.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'out_put/version'
|
2
2
|
require 'out_put/config'
|
3
|
+
require 'out_put/view'
|
3
4
|
|
4
5
|
module OutPut
|
5
6
|
def output(code = 0, msg = '', only: nil, http: 200, **data)
|
@@ -24,15 +25,15 @@ module OutPut
|
|
24
25
|
|
25
26
|
def _output_data(data)
|
26
27
|
if data.key?(Config.pagination_for)
|
27
|
-
# TODO now is
|
28
|
+
# TODO now is only for AR
|
28
29
|
data.merge!(total: data[Config.pagination_for].try(:unscoped).count)
|
29
30
|
end
|
30
31
|
|
31
32
|
data
|
32
33
|
end
|
33
34
|
|
34
|
-
def build_with(**data)
|
35
|
-
@view = data
|
35
|
+
def build_with(code = 0, msg = 'success', **data)
|
36
|
+
@view = View.new(code, msg, **data)
|
36
37
|
# Then jump to your view
|
37
38
|
end
|
38
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: out_put
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zhandao
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/out_put.rb
|
74
74
|
- lib/out_put/config.rb
|
75
75
|
- lib/out_put/version.rb
|
76
|
+
- lib/out_put/view.rb
|
76
77
|
- out_put.gemspec
|
77
78
|
homepage: https://github.com/zhandao/out_put
|
78
79
|
licenses:
|