popper 0.1.2 → 0.1.3

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: d4d3573cf92aaac10f752e63d0c82e3dad9201cd
4
- data.tar.gz: 148797fb3219c862a66be540cab7fa4493fba856
3
+ metadata.gz: 95a2425b9e515ca0ee9d1aa86f438fce874368d6
4
+ data.tar.gz: ab1d06fb1f4b9cb9991cf0d016ff288dc2f7698e
5
5
  SHA512:
6
- metadata.gz: c4f70fa38af7830fdc85d226f8dcb2a59b4f649433ca59ce61988615b272786131811a858acb759c59a2ef82aa99191d575ba9038534a957936e78ce0119f1d5
7
- data.tar.gz: a95e921e1e04e8300cd61574704810d771589486aa1059a2ce8ea1c126c17874dfa420b5e9aee945d4b30c2eb296a82504b328b36862e2edb5971b79bbfb561b
6
+ metadata.gz: dbb98e0eb5f33a12c170d33caed4854482c08d83efa2a419bfcaea68c9eb5e2f4665c42d12f0c3b46e6f010a36b08a9f6d33058b777b5812e7c758e9bf44f3a0
7
+ data.tar.gz: edb360136ee5069d57bdec446914002865436f8c1b42a4c2a0ef76f9f5c8078250d7f75499b916cc206f7794789f268efc187f1bac9479ad9cd50826d8dacc6c
data/lib/popper.rb CHANGED
@@ -8,9 +8,9 @@ require "popper/init"
8
8
  require "popper/sync"
9
9
 
10
10
  module Popper
11
- def self.init_logger(options)
11
+ def self.init_logger(options, stdout=nil)
12
12
  log_path = options[:log] || File.join(Dir.home, "popper", "popper.log")
13
- log_path = STDOUT if ENV["POPPER_TEST"]
13
+ log_path = STDOUT if ENV["POPPER_TEST"] || stdout
14
14
  @_logger = Logger.new(log_path)
15
15
  end
16
16
 
data/lib/popper/cli.rb CHANGED
@@ -19,6 +19,7 @@ module Popper
19
19
  desc "prepop", "get current mailbox all uidl"
20
20
  def prepop
21
21
  Popper.load_config(options)
22
+ Popper.init_logger(options, true)
22
23
  Popper::Pop.prepop
23
24
  end
24
25
 
data/lib/popper/pop.rb CHANGED
@@ -17,11 +17,11 @@ module Popper
17
17
  end
18
18
 
19
19
  def self.pop(account)
20
- uidls = []
20
+ current_uidls = []
21
+ error_uidls = []
21
22
  Popper.log.info "start popper #{account.name}"
22
-
23
23
  connection(account) do |pop|
24
- pop.mails.reject {|m| last_uidl(account.name).include?(m.uidl) }.each do |m|
24
+ pop.mails.reject {|m| current_uidls << m.uidl; last_uidl(account.name).include?(m.uidl) }.each do |m|
25
25
  begin
26
26
  mail = EncodeMail.new(m.mail)
27
27
  Popper.log.info "check mail:#{mail.date.to_s} #{mail.subject}"
@@ -29,14 +29,14 @@ module Popper
29
29
  Popper.log.info "do action:#{mail.subject}"
30
30
  Popper::Action::Git.run(account.action_by_rule(rule), mail) if account.action_by_rule(rule)
31
31
  end
32
- uidls << m.uidl
33
- rescue Net::POPError => e
32
+ rescue => e
33
+ error_uidls << m.uidl
34
34
  Popper.log.warn e
35
35
  end
36
36
  end
37
37
  Popper.log.info "success popper #{account.name}"
38
38
  end
39
- uidls
39
+ current_uidls - error_uidls
40
40
  end
41
41
 
42
42
  def self.connection(account, &block)
@@ -75,14 +75,18 @@ module Popper
75
75
 
76
76
  def self.prepop
77
77
  Popper.configure.accounts.each do |account|
78
- puts "start prepop #{account.name}"
78
+ Popper.log.info "start prepop #{account.name}"
79
79
  connection(account) do |pop|
80
- uidls = pop.mails.map(&:uidl)
81
- last_uidl(
82
- account.name,
83
- uidls
84
- )
85
- puts "success prepop #{account.name} mail count:#{uidls.count}"
80
+ begin
81
+ uidls = pop.mails.map(&:uidl)
82
+ last_uidl(
83
+ account.name,
84
+ uidls
85
+ )
86
+ Popper.log.info "success prepop #{account.name} mail count:#{uidls.count}"
87
+ rescue => e
88
+ Popper.log.warn e
89
+ end
86
90
  end
87
91
  end
88
92
  end
@@ -1,3 +1,3 @@
1
1
  module Popper
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - pyama86
@@ -138,9 +138,6 @@ files:
138
138
  - Rakefile
139
139
  - bin/console
140
140
  - bin/setup
141
- - coverage/.last_run.json
142
- - coverage/.resultset.json
143
- - coverage/.resultset.json.lock
144
141
  - exe/popper
145
142
  - lib/popper.rb
146
143
  - lib/popper/action.rb