popper 0.5.3 → 0.6.0

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: 8b808e5e8c4b22939a7f9aa38f929a48fe47cc99cf569f97149e168d77e5ab5b
4
- data.tar.gz: 13f1787819e224b2eeb96dd99cdfc0f210300e31decbe1752f133fc4520a5c81
3
+ metadata.gz: 3247fe4e78dc92357e74dbef91a27adad0f2b9fe93115aa6d5003b4a1888bd9a
4
+ data.tar.gz: bbeadd71ec4abfe61587f2181809a8f1a40786affd0ebf17526f884bb0aaa8cf
5
5
  SHA512:
6
- metadata.gz: 15e3d186627b15f17b14f57e6829d0fa534e6d3792dad0fc080a51a833e3584044a2dd94bfcdea6c3860868e624538f87654d462559b61b4d0c039db9a42eb1b
7
- data.tar.gz: e155391686166a6e6f24c498576fb523ad6bc0ccda98b5c293f9506649568d8a7fc6da488db32068da8a51f7ea537ca50ae1bef993fb03475e18b0e64a02ce94
6
+ metadata.gz: d2e3f30baf3d3739675d7d515b9efc5a9913350d8ffb19c01a53d7d579ceb3a5ff751ffbee638b21b07d773f4c163b415524b0e678aed6da0b8801eb97f89e41
7
+ data.tar.gz: 5a79445a2d2606b9943fdb3c7ca05888757edf6f109d6b5dea55ac90f722dd0a2a72a665753b016755366147fb9de8688e48b9484428aa9c716240d889cece5e
@@ -22,15 +22,12 @@ jobs:
22
22
  runs-on: ubuntu-latest
23
23
  strategy:
24
24
  matrix:
25
- ruby-version: ['2.6', '2.7', '3.0']
25
+ ruby-version: ['3.2', '3.3']
26
26
 
27
27
  steps:
28
- - uses: actions/checkout@v3
28
+ - uses: actions/checkout@v4
29
29
  - name: Set up Ruby
30
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
31
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
32
- # uses: ruby/setup-ruby@v1
33
- uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3
30
+ uses: ruby/setup-ruby@v1
34
31
  with:
35
32
  ruby-version: ${{ matrix.ruby-version }}
36
33
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
@@ -3,15 +3,17 @@ require 'shellwords'
3
3
  require 'tempfile'
4
4
  module Popper::Action
5
5
  class ExecCmd < Base
6
- def self.task(mail, params={})
7
- tmps = mail.attachments.map do |a|
8
- ::Tempfile.open(a.filename) do |f|
9
- f.write a.body.decoded
10
- f
6
+ def self.task(mail, params = {})
7
+ unless mail.attachments.empty?
8
+ tmps = mail.attachments.map do |a|
9
+ ::Tempfile.open(a.filename) do |f|
10
+ f.write a.body.decoded
11
+ f
12
+ end
11
13
  end
12
- end unless mail.attachments.empty?
13
- cmd = "#{@action_config.cmd} #{Shellwords.escape(mail.subject)} #{Shellwords.escape(mail.utf_body)} #{Shellwords.escape(mail.from.join(";"))} #{Shellwords.escape(mail.to.join(";"))}"
14
- cmd += " #{tmps.map {|t| Shellwords.escape(t.path) }.join(' ')}" if tmps && !tmps.empty?
14
+ end
15
+ cmd = "#{@action_config.cmd} #{Shellwords.escape(mail.subject)} #{Shellwords.escape(mail.utf_body)} #{Shellwords.escape(mail.from.join(';'))} #{Shellwords.escape(mail.to.join(';'))}"
16
+ cmd += " #{tmps.map { |t| Shellwords.escape(t.path) }.join(' ')}" if tmps && !tmps.empty?
15
17
  ::Bundler.with_clean_env do
16
18
  system(cmd)
17
19
  end
@@ -16,8 +16,8 @@ module Popper
16
16
  self.complete_list = current_list unless complete_list
17
17
  pop(conn)
18
18
  end
19
- rescue => e
20
- Popper.log.warn e
19
+ rescue StandardError => e
20
+ Popper.log.warn e
21
21
  end
22
22
 
23
23
  def pop(conn)
@@ -27,17 +27,15 @@ module Popper
27
27
  Popper.log.info "start popper #{config.name}"
28
28
 
29
29
  process_uidl_list(conn).each do |m|
30
- begin
31
- done_uidls << check_and_action(m)
32
- m.delete if config.login.respond_to?(:delete_after) && config.login.delete_after
33
- rescue Net::POPError => e
34
- self.complete_list += done_uidls
35
- Popper.log.warn "pop err write uidl"
36
- return
37
- rescue => e
38
- error_uidls << m.uidl
39
- Popper.log.warn e
40
- end
30
+ done_uidls << check_and_action(m)
31
+ m.delete if config.login.respond_to?(:delete_after) && config.login.delete_after
32
+ rescue Net::POPError => e
33
+ self.complete_list += done_uidls
34
+ Popper.log.warn 'pop err write uidl'
35
+ return
36
+ rescue StandardError => e
37
+ error_uidls << m.uidl
38
+ Popper.log.warn e
41
39
  end
42
40
 
43
41
  self.complete_list = current_list - error_uidls
@@ -46,7 +44,7 @@ module Popper
46
44
 
47
45
  def check_and_action(m)
48
46
  mail = EncodeMail.new(m.mail)
49
- Popper.log.info "check mail:#{mail.date.to_s} #{mail.subject}"
47
+ Popper.log.info "check mail:#{mail.date} #{mail.subject}"
50
48
  match_rules?(mail).each do |rule|
51
49
  Popper.log.info "do action:#{mail.subject}"
52
50
  Popper::Action::Webhook.run(config.action_by_rule(rule), mail) if config.action_by_rule(rule)
@@ -71,10 +69,10 @@ module Popper
71
69
 
72
70
  def set_pop_option(pop)
73
71
  pop.enable_ssl if config.login.respond_to?(:ssl) && config.login.ssl
74
- %w(
72
+ %w[
75
73
  open_timeout
76
74
  read_timeout
77
- ).each do |m|
75
+ ].each do |m|
78
76
  pop.instance_variable_set("@#{m}", ENV['POP_TIMEOUT'] || 120)
79
77
  end
80
78
  pop
@@ -82,11 +80,11 @@ module Popper
82
80
 
83
81
  def process_uidl_list(conn)
84
82
  uidl_list = current_list - complete_list
85
- conn.mails.select {|_m|uidl_list.include?(_m.uidl)}
83
+ conn.mails.select { |_m| uidl_list.include?(_m.uidl) }
86
84
  end
87
85
 
88
86
  def match_rules?(mail)
89
- config.rule_with_conditions_select do |rule,mail_header,conditions|
87
+ config.rule_with_conditions_select do |_rule, mail_header, conditions|
90
88
  conditions.all? do |condition|
91
89
  mail.respond_to?(mail_header) && mail.send(mail_header).to_s.match(/#{condition}/)
92
90
  end
@@ -97,12 +95,20 @@ end
97
95
 
98
96
  class ::Hash
99
97
  def deep_merge(second)
100
- merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : v2 }
101
- self.merge(second.to_h, &merger)
98
+ merger = proc { |_key, v1, v2|
99
+ if v1.is_a?(Hash) && v2.is_a?(Hash)
100
+ v1.merge(v2, &merger)
101
+ elsif v1.is_a?(Array) && v2.is_a?(Array)
102
+ v1 | v2
103
+ else
104
+ [:undefined, nil, :nil].include?(v2) ? v1 : v2
105
+ end
106
+ }
107
+ merge(second.to_h, &merger)
102
108
  end
103
109
 
104
110
  def deep_merge!(second)
105
- self.merge!(deep_merge(second))
111
+ merge!(deep_merge(second))
106
112
  end
107
113
  end
108
114
 
@@ -113,13 +119,11 @@ class EncodeMail < Mail::Message
113
119
 
114
120
  def utf_body
115
121
  if multipart?
116
- if text_part
117
- text_part.decoded.encode("UTF-8", charset)
118
- elsif html_part
119
- html_part.decoded.encode("UTF-8", charset)
120
- end
122
+ parts.map do |part|
123
+ part.body.decoded.encode('UTF-8', charset) unless part.attachment?
124
+ end.join
121
125
  else
122
- body.decoded.encode("UTF-8", charset)
126
+ body.decoded.encode('UTF-8', charset)
123
127
  end
124
128
  end
125
129
  end
@@ -1,3 +1,3 @@
1
1
  module Popper
2
- VERSION = '0.5.3'
2
+ VERSION = '0.6.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pyama86
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-17 00:00:00.000000000 Z
11
+ date: 2024-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
217
  - !ruby/object:Gem::Version
218
218
  version: '0'
219
219
  requirements: []
220
- rubygems_version: 3.2.33
220
+ rubygems_version: 3.4.10
221
221
  signing_key:
222
222
  specification_version: 4
223
223
  summary: email notification tool