respond_for_helper 1.1.0 → 1.1.2

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
  SHA256:
3
- metadata.gz: 605ea6e5b57890e065931756614d979f3f131a6581525622feb96d51c56dc91b
4
- data.tar.gz: d7bd4702e2a3a0986b19b18361e39c24a8be69472e4c6f594ba51dae3971a3a0
3
+ metadata.gz: 8662ea79ffb98d16f4a82182e8837f1153a6b6dceeee39781b7750df0bb7209c
4
+ data.tar.gz: 209badd08e4669c9717406c8f92e1ecc9d65ac3de4fa507749b59c0a9c990e25
5
5
  SHA512:
6
- metadata.gz: ea3adad9460730c33cc318cdebe611c7ce76199241e5c83d6d6c885fdc665070aeabafefc7f1cfb5c4d2d8490c096a73d62a69a05423219e56cf35b10403b899
7
- data.tar.gz: a57499b403d33f4e844f73ce0faf495954922d4d21848ee3bf3dac69e7b62ffb5ef92d652149827b4269f346043e75a96f5e6293adbd23d6cf0b9f88622ae94d
6
+ metadata.gz: e797d9bb30f9399629de7c7cccbb4f1af93f6647521cd4c9617e38e6ac9ec2eb3aa42121890484d2df6a40d2b4d17f0a99df56853f9da343aea177ef0aa76a61
7
+ data.tar.gz: 16416c8c03b0332d0863368da138fdc377c551d92fc71be8ae8cdfc566b50c98221ff0a3665be42ce8eb838e1f4fb37418abd66b0e18d4af873834fd2c631c18
@@ -46,7 +46,7 @@ jobs:
46
46
  BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
47
47
 
48
48
  steps:
49
- - uses: actions/checkout@v2
49
+ - uses: actions/checkout@v3
50
50
  - uses: ruby/setup-ruby@v1
51
51
  with:
52
52
  ruby-version: ${{ matrix.ruby }}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.1.2
4
+
5
+ * Skip checking errors when request method is get.
6
+
7
+ ## 1.1.1
8
+
9
+ * Use `Time.zone.now` if possible.
10
+
3
11
  ## 1.1.0
4
12
 
5
13
  * Add `formats` option to `respond_for`.
@@ -5,7 +5,17 @@ module RespondForHelper
5
5
  class Timestamp < Base
6
6
  def initialize(type, options = {})
7
7
  super
8
- @options = options.reverse_merge(timestamp: I18n.l(Time.now))
8
+ @options = options.reverse_merge(timestamp: I18n.l(now))
9
+ end
10
+
11
+ private
12
+
13
+ def now
14
+ if Time.respond_to?(:zone)
15
+ Time.zone.now
16
+ else
17
+ Time.now
18
+ end
9
19
  end
10
20
  end
11
21
  end
@@ -8,13 +8,13 @@ module RespondForHelper
8
8
  attr_reader :controller, :item, :format, :result, :behaviour
9
9
  delegate :request, :render, :head, :redirect_to, :flash, :url_for, :action_name, to: :controller
10
10
 
11
- def initialize(controller, item, options)
11
+ def initialize(controller, item, success, options)
12
12
  @controller = controller
13
13
  @item = item
14
+ @result = success ? :success : :failure
14
15
  @options = options
15
16
 
16
17
  @format = self.class.format.to_sym
17
- @result = @options[:success] ? :success : :failure
18
18
  @behaviour = Behaviours.new(@controller, @format, @result, @options).call
19
19
  end
20
20
 
@@ -7,15 +7,22 @@ module RespondForHelper
7
7
  @item = item
8
8
  @options = options
9
9
 
10
- unless @options.key?(:success)
11
- @options[:success] = Array(item).all? { |item| item.errors.blank? }
12
- end
13
-
10
+ @success = check_success
14
11
  @callbacks = {}
15
12
  end
16
13
 
14
+ def check_success
15
+ if @options.key?(:success)
16
+ @options[:success]
17
+ elsif @controller.request.get?
18
+ true
19
+ else
20
+ Array(@item).all? { |item| item.errors.blank? }
21
+ end
22
+ end
23
+
17
24
  def success?
18
- @options[:success]
25
+ @success
19
26
  end
20
27
 
21
28
  def before_success(&block)
@@ -64,7 +71,7 @@ module RespondForHelper
64
71
 
65
72
  def formatters
66
73
  Lookups::Format.new(@controller, @options).call.map do |_, klass|
67
- klass.new(@controller, @item, @options)
74
+ klass.new(@controller, @item, @success, @options)
68
75
  end
69
76
  end
70
77
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RespondForHelper
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: respond_for_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshikazu Kaneta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-05 00:00:00.000000000 Z
11
+ date: 2022-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails