smailr 0.8.1 → 0.8.2
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.
- checksums.yaml +4 -4
- data/bin/smailr +7 -0
- data/lib/smailr/cli.rb +5 -0
- data/lib/smailr/version.rb +1 -1
- data/lib/smailr.rb +40 -9
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 711ed3fbc0dd02795b873d6b8c5dae375ee2db772765d607550040b1946357f2
|
|
4
|
+
data.tar.gz: bdd43490822316051212b776a8834eb6ae41348d3df98fbe887d152126ab9f3e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 79c3f97dea293a130fdfa8ba385c8609700b3d91b0d3268f9e7bca211bb207cf21f643d4df0b64ac93ebaa8f274e23de4156773d0a47e1ae4ed7748142d78791
|
|
7
|
+
data.tar.gz: dbbacb1c5f7940d1bed41b22ba809faa5628698924e77f68ee4336e8550010cab560f863c87b2ed6dda56195ad2a6f4391067003f98c788b3cb9b8e84c6a3e78
|
data/bin/smailr
CHANGED
data/lib/smailr/cli.rb
CHANGED
|
@@ -106,6 +106,11 @@ module Smailr
|
|
|
106
106
|
case args[0]
|
|
107
107
|
when /^[^@][A-Z0-9.-]+\.[A-Z]{2,6}$/i then
|
|
108
108
|
domain = Smailr::Model::Domain[:fqdn => args[0]]
|
|
109
|
+
unless domain
|
|
110
|
+
error "No such domain: #{args[0]}"
|
|
111
|
+
exit 1
|
|
112
|
+
end
|
|
113
|
+
|
|
109
114
|
domain.mailboxes.each do |mbox|
|
|
110
115
|
puts "m: #{mbox.localpart}@#{args[0]}"
|
|
111
116
|
end
|
data/lib/smailr/version.rb
CHANGED
data/lib/smailr.rb
CHANGED
|
@@ -20,27 +20,61 @@ module Smailr
|
|
|
20
20
|
|
|
21
21
|
# Exception Classes
|
|
22
22
|
class MissingDomain < StandardError ; end
|
|
23
|
+
class ConfigurationError < StandardError ; end
|
|
23
24
|
|
|
24
25
|
class << self;
|
|
25
26
|
attr_accessor :config
|
|
26
27
|
attr_accessor :config_files
|
|
27
|
-
attr_accessor :load_config
|
|
28
28
|
attr_accessor :contrib_directory
|
|
29
29
|
attr_accessor :migrations_directory
|
|
30
|
+
attr_accessor :bundled_config_file
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def self.load_config
|
|
33
34
|
config = {}
|
|
34
|
-
config_files.
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
runtime_config_files = config_files.reject { |f| f == bundled_config_file }
|
|
36
|
+
readable_runtime_config_files = runtime_config_files.select { |f| File.file?(f) && File.readable?(f) }
|
|
37
|
+
unreadable_runtime_config_files = runtime_config_files.select { |f| File.exist?(f) && !File.readable?(f) }
|
|
38
|
+
|
|
39
|
+
if readable_runtime_config_files.empty?
|
|
40
|
+
if unreadable_runtime_config_files.any?
|
|
41
|
+
raise ConfigurationError, "Cannot read configuration file: #{unreadable_runtime_config_files.join(', ')}"
|
|
37
42
|
end
|
|
43
|
+
|
|
44
|
+
raise ConfigurationError, "Cannot find configuration file. Checked: #{runtime_config_files.join(', ')}"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
if bundled_config_file && File.readable?(bundled_config_file)
|
|
48
|
+
config.merge!(YAML.load_file(bundled_config_file) || {})
|
|
38
49
|
end
|
|
50
|
+
|
|
51
|
+
readable_runtime_config_files.each do |f|
|
|
52
|
+
config.merge!(YAML.load_file(f) || {})
|
|
53
|
+
end
|
|
54
|
+
|
|
39
55
|
self.config = config
|
|
40
56
|
end
|
|
41
57
|
|
|
42
58
|
def self.db_connect
|
|
59
|
+
unless self.config && self.config['database']
|
|
60
|
+
raise ConfigurationError, "Configuration file is missing database settings."
|
|
61
|
+
end
|
|
62
|
+
|
|
43
63
|
Sequel.connect(self.config['database'])
|
|
64
|
+
rescue Sequel::DatabaseConnectionError => e
|
|
65
|
+
raise ConfigurationError, "Cannot open database connection: #{e.message}"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def self.initialize!
|
|
69
|
+
load_config
|
|
70
|
+
|
|
71
|
+
unless defined?(Smailr::Model)
|
|
72
|
+
require 'smailr/model'
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
Smailr.send(:remove_const, :DB) if Smailr.const_defined?(:DB, false)
|
|
76
|
+
Smailr.const_set(:DB, db_connect)
|
|
77
|
+
Smailr::DB.sql_log_level = :debug
|
|
44
78
|
end
|
|
45
79
|
|
|
46
80
|
def self.logger
|
|
@@ -65,8 +99,5 @@ end
|
|
|
65
99
|
|
|
66
100
|
Smailr.contrib_directory ||= File.expand_path('../../contrib', __FILE__)
|
|
67
101
|
Smailr.migrations_directory ||= File.expand_path('../../migrations', __FILE__)
|
|
68
|
-
Smailr.
|
|
69
|
-
Smailr.
|
|
70
|
-
Smailr::DB = Smailr::db_connect
|
|
71
|
-
require 'smailr/model'
|
|
72
|
-
Smailr::DB.sql_log_level = :debug
|
|
102
|
+
Smailr.bundled_config_file ||= File.expand_path('../../smailr.yml', __FILE__)
|
|
103
|
+
Smailr.config_files ||= [ Smailr.bundled_config_file, '/etc/smailr.yml' ]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smailr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stefan Schlesinger
|
|
@@ -57,6 +57,20 @@ dependencies:
|
|
|
57
57
|
- - "~>"
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
59
|
version: '3.1'
|
|
60
|
+
- !ruby/object:Gem::Dependency
|
|
61
|
+
name: logger
|
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '0'
|
|
67
|
+
type: :runtime
|
|
68
|
+
prerelease: false
|
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '0'
|
|
60
74
|
- !ruby/object:Gem::Dependency
|
|
61
75
|
name: net-smtp
|
|
62
76
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -161,7 +175,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
161
175
|
requirements:
|
|
162
176
|
- - ">="
|
|
163
177
|
- !ruby/object:Gem::Version
|
|
164
|
-
version: '
|
|
178
|
+
version: '3.1'
|
|
165
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
180
|
requirements:
|
|
167
181
|
- - ">="
|