out_put 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c39b950419b24b87b7be771a242866ca754b66d4
4
- data.tar.gz: e91476c98ce8e57c1f99f65ae5984adced45a407
3
+ metadata.gz: 5eb4abc2cead8a3b3f71d44018f0d4effc25229b
4
+ data.tar.gz: eebd9c033b8bab41a2c8f293b6b38cf281b84cfa
5
5
  SHA512:
6
- metadata.gz: b71f6421cbcf135c415fe436336d5bd9bcd4c904d2c22246714008c17b5471b78219fa93fa89efcc56c8ec9d236480e8568182abe1e0ee98b1d49819ecadab58
7
- data.tar.gz: 233b32f3cd0bad137225e799d3a68073975aa8458fcee54e7f6fda33eadeba538611850a7a28985496f86c8b6869593f5ba72418808e473e1fb667f4a9659bcc
6
+ metadata.gz: b933aeeaf70c301eac67f472eb3380916d78d4799cd7868773f4632aebb8c2e4752ed32b5b9ec087bc356648283da316a16df007c4dfb78c5f8f74e034e5c8a8
7
+ data.tar.gz: ec751a39a1c4d5e8b6c85d763bf5e1dedd8e3053da4c41da7450ff6778bdd850e3584ab50126c3f35aedced4a9258eed44c56be2b5dae4f4195c1419d07a25dd
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
 
13
13
  .idea/*
14
14
  .DS_Store
15
+ Gemfile.lock
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
- code, msg, http, only = code.info.slice(:code, :msg, :http, :only).values
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 = View.new(code, msg, **data)
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(cached[:only]) ]
48
+ [ data.merge(cached), cached&.[](:only)&.merge(only || { }) ]
48
49
  end
49
50
  end
@@ -1,3 +1,3 @@
1
1
  module OutPut
2
- VERSION = '2.2.0'
2
+ VERSION = '2.2.1'
3
3
  end
data/lib/out_put/view.rb CHANGED
@@ -1,10 +1,7 @@
1
1
  module OutPut
2
2
  class View < Hash
3
- attr_accessor :data
4
-
5
- def initialize(code, msg, **data)
6
- self.data = data
7
- self.merge!(code: code, msg: msg, **data)
3
+ def initialize(code, msg)
4
+ self.merge!(code: code, msg: msg)
8
5
  end
9
6
  end
10
7
  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.2.0
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-10-22 00:00:00.000000000 Z
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