redimap 0.4.0 → 0.5.0

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -1
  3. data/bin/redimap +27 -16
  4. data/lib/redimap/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ba76df09385c366a60e9b398d4b4609a26aa651
4
- data.tar.gz: 7c513536095b241ea1614e84efb333c26845bc4f
3
+ metadata.gz: 1ff106fa18b156a8c236ea26e3ba03644d023bf8
4
+ data.tar.gz: dc152c2d823229d6096defd661002cdb960c32f8
5
5
  SHA512:
6
- metadata.gz: e9d01fb5a28bba8e1df681f42708550e7af1d76ff1ebafd15a8ee77f4af14220e149e8427f5f0b29f9d183023fa95caf259d9d475fbf0c182817a0c2ee478583
7
- data.tar.gz: 0da97e1f2f3328fdbec7d8cb4b678c3ef01a25a5249fc289dc5d5cd0ffc72ecc19d34935f2ff7f76742a15e969412aec33ba1b28c95b8ea323b43b541406f399
6
+ metadata.gz: b8f18cc18df4e57895a8cec72c54531e6f248603c684f6e914a38eab81bb5b362df3ae4f95014b9a776797444310ff2afa6ac0e41ea451898a87e33d674de8c7
7
+ data.tar.gz: 83e38fac9519fbfd59a914a332d5ef8ca23fb73a680f8148d78c591747608ef13e6a660a6f8a82eb22b9643503847e7b5e327cc3b1334c188c0dc5a00f393d19
data/README.md CHANGED
@@ -28,7 +28,27 @@ Check and queue new messages and quit:
28
28
 
29
29
  $ bundle exec redimap --host mail.example.com --user a@example.com --password helpimacarrot
30
30
 
31
- Use `--eternal` to run eternally.
31
+ It is also possible to set config using environment variables. Command-line
32
+ options override environment variables. Note that environment variables are in
33
+ lowercase, and are named differently to command-line parameters.
34
+
35
+ $ imap_host=mail.example.com imap_user=a@example.com imap_password=helpimacarrot bundle exec redimap
36
+
37
+ The complete list of available environment variables is:
38
+
39
+ eternal
40
+ log_level
41
+ imap_host
42
+ imap_port
43
+ imap_username
44
+ imap_password
45
+ imap_mailboxes
46
+ redis_url
47
+ redis_ns_redimap
48
+ redis_ns_queue
49
+ polling_interval
50
+
51
+ Use `--eternal` or `eternal=1` to run eternally.
32
52
 
33
53
 
34
54
  ## Contributions
@@ -67,7 +67,7 @@ OptionParser.new do |opts|
67
67
  opts.separator "Other:"
68
68
 
69
69
  opts.on("-v", "--[no-]verbose", "Be somewhat verbose") do |o|
70
- options[:verbose] = o
70
+ options[:log_level] = 'DEBUG'
71
71
  end
72
72
 
73
73
  opts.on_tail("--help", "Show this message") do
@@ -85,20 +85,31 @@ end.parse!
85
85
  # = Configure
86
86
 
87
87
  Redimap.configure do |c|
88
- c.log_level = 'DEBUG' if options[:verbose]
89
-
90
- c.imap_host = options[:imap_host] if options[:imap_host]
91
- c.imap_port = options[:imap_port] if options[:imap_port]
92
- c.imap_username = options[:imap_username] if options[:imap_username]
93
- c.imap_password = options[:imap_password] if options[:imap_password]
94
-
95
- c.imap_mailboxes = options[:imap_mailboxes] if options[:imap_mailboxes]
96
-
97
- c.redis_url = options[:redis_url] if options[:redis_url]
98
- c.redis_ns_redimap = options[:redis_ns_redimap] if options[:redis_ns_redimap]
99
- c.redis_ns_queue = options[:redis_ns_queue] if options[:redis_ns_queue]
100
-
101
- c.polling_interval = options[:polling_interval] if options[:polling_interval]
88
+ %w[
89
+ log_level
90
+ imap_host
91
+ imap_port
92
+ imap_username
93
+ imap_password
94
+ imap_mailboxes
95
+ redis_url
96
+ redis_ns_redimap
97
+ redis_ns_queue
98
+ polling_interval
99
+ ].each do |e_k|
100
+ e_v = case e_k
101
+ when 'imap_port'
102
+ ENV[e_k].to_i
103
+ when 'imap_mailboxes'
104
+ ENV[e_k].split(',')
105
+ else
106
+ ENV[e_k]
107
+ end if ENV[e_k] # Read env var if set, parsing as for params.
108
+
109
+ e_v = options[e_k.to_sym] if options[e_k.to_sym] # Override from params.
110
+
111
+ c.instance_variable_set("@#{e_k}", e_v) if e_v # Only set extant settings.
112
+ end
102
113
  end
103
114
 
104
115
  @logger = Redimap.logger
@@ -109,7 +120,7 @@ end
109
120
  loop do
110
121
  Redimap.queue_new_mailboxes_uids
111
122
 
112
- break unless options[:eternal]
123
+ break unless (options[:eternal] || ENV['eternal'].to_i == 1)
113
124
 
114
125
  @logger.debug { "Snoring for #{Redimap.config.polling_interval} s" }
115
126
 
@@ -1,5 +1,5 @@
1
1
  module Redimap
2
2
 
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redimap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tiredpixel