out_put 2.2.0 → 2.2.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/.gitignore +1 -0
- data/lib/out_put.rb +5 -4
- data/lib/out_put/version.rb +1 -1
- data/lib/out_put/view.rb +2 -5
- metadata +2 -3
- data/Gemfile.lock +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eb4abc2cead8a3b3f71d44018f0d4effc25229b
|
4
|
+
data.tar.gz: eebd9c033b8bab41a2c8f293b6b38cf281b84cfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b933aeeaf70c301eac67f472eb3380916d78d4799cd7868773f4632aebb8c2e4752ed32b5b9ec087bc356648283da316a16df007c4dfb78c5f8f74e034e5c8a8
|
7
|
+
data.tar.gz: ec751a39a1c4d5e8b6c85d763bf5e1dedd8e3053da4c41da7450ff6778bdd850e3584ab50126c3f35aedced4a9258eed44c56be2b5dae4f4195c1419d07a25dd
|
data/.gitignore
CHANGED
data/lib/out_put.rb
CHANGED
@@ -5,12 +5,13 @@ require 'out_put/view'
|
|
5
5
|
module OutPut
|
6
6
|
def output(code = 0, msg = '', only: nil, http: 200, cache: nil, **data, &block)
|
7
7
|
if !code.is_a?(Integer) && code.respond_to?(:info)
|
8
|
-
|
8
|
+
only = code.info[:only]
|
9
|
+
code, msg, http = code.info.slice(:code, :msg, :http).values
|
9
10
|
elsif cache && block_given?
|
10
11
|
data, only = _output_cache(cache, data: data, only: only, &block)
|
11
12
|
end
|
12
13
|
|
13
|
-
return render json: only, status: http if only.present?
|
14
|
+
return render json: only.except(:http), status: only[:http] || http if only.present?
|
14
15
|
|
15
16
|
code = code.zero? ? 0 : Config.project_code + code
|
16
17
|
msg = 'success' if msg.blank? && code.zero?
|
@@ -26,7 +27,7 @@ module OutPut
|
|
26
27
|
alias error_with output
|
27
28
|
|
28
29
|
def build_with(code = 0, msg = 'success', **data)
|
29
|
-
@view
|
30
|
+
(@view ||= View.new(code, msg)).merge!(data)
|
30
31
|
# Then jump to your view
|
31
32
|
end
|
32
33
|
|
@@ -44,6 +45,6 @@ module OutPut
|
|
44
45
|
instance_eval(&block)
|
45
46
|
end
|
46
47
|
|
47
|
-
[ data.merge(cached), only&.merge(
|
48
|
+
[ data.merge(cached), cached&.[](:only)&.merge(only || { }) ]
|
48
49
|
end
|
49
50
|
end
|
data/lib/out_put/version.rb
CHANGED
data/lib/out_put/view.rb
CHANGED
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.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zhandao
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -64,7 +64,6 @@ files:
|
|
64
64
|
- ".travis.yml"
|
65
65
|
- CODE_OF_CONDUCT.md
|
66
66
|
- Gemfile
|
67
|
-
- Gemfile.lock
|
68
67
|
- LICENSE.txt
|
69
68
|
- README.md
|
70
69
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
out_put (2.2.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.3)
|
10
|
-
rake (10.5.0)
|
11
|
-
rspec (3.7.0)
|
12
|
-
rspec-core (~> 3.7.0)
|
13
|
-
rspec-expectations (~> 3.7.0)
|
14
|
-
rspec-mocks (~> 3.7.0)
|
15
|
-
rspec-core (3.7.1)
|
16
|
-
rspec-support (~> 3.7.0)
|
17
|
-
rspec-expectations (3.7.0)
|
18
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.7.0)
|
20
|
-
rspec-mocks (3.7.0)
|
21
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.7.0)
|
23
|
-
rspec-support (3.7.1)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
bundler (~> 1.16)
|
30
|
-
out_put!
|
31
|
-
rake (~> 10.0)
|
32
|
-
rspec (~> 3.0)
|
33
|
-
|
34
|
-
BUNDLED WITH
|
35
|
-
1.16.6
|