smailr 0.8.2 → 0.8.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 711ed3fbc0dd02795b873d6b8c5dae375ee2db772765d607550040b1946357f2
4
- data.tar.gz: bdd43490822316051212b776a8834eb6ae41348d3df98fbe887d152126ab9f3e
3
+ metadata.gz: ec2eb186ac1f81e1be4bb80e199288cb2d63661bfbfa4a07190b4cefd59c5f44
4
+ data.tar.gz: 2740f99b5401c4163a09793ac62cfc5cff8e8aa7c0a3aaa2686c57d79fe58be3
5
5
  SHA512:
6
- metadata.gz: 79c3f97dea293a130fdfa8ba385c8609700b3d91b0d3268f9e7bca211bb207cf21f643d4df0b64ac93ebaa8f274e23de4156773d0a47e1ae4ed7748142d78791
7
- data.tar.gz: dbbacb1c5f7940d1bed41b22ba809faa5628698924e77f68ee4336e8550010cab560f863c87b2ed6dda56195ad2a6f4391067003f98c788b3cb9b8e84c6a3e78
6
+ metadata.gz: 6974dbf722f0f0c508c9b012a622b63a74b400c4bced9b778e40fae5805efa6b93b87b9230fb1057037f6b83b535f6047a80b99ddf47e1ce57624369335aa547
7
+ data.tar.gz: 052e8c354fdc58689d24430f69fa67b59c5e331f862e834b8e65a0ebc4c49cc7a684e5bfd258aa9be4e3a120c83c93ae9e964f0ca79993500928782bd4e50f95
data/bin/smailr CHANGED
@@ -1,12 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
- #$: << File.expand_path('../../lib', __FILE__)
3
- #
4
- #require 'pathname'
5
- #ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
6
- # Pathname.new(__FILE__).realpath)
7
- #
8
- #require 'rubygems'
9
- #require 'bundler/setup'
2
+
3
+ require 'smailr/version'
4
+
5
+ if ARGV == ['version'] || ARGV.include?('--version')
6
+ puts "smailr #{Smailr::VERSION}"
7
+ exit 0
8
+ end
10
9
 
11
10
  require 'smailr'
12
11
  require 'smailr/cli'
data/lib/smailr/alias.rb CHANGED
@@ -2,10 +2,11 @@ module Smailr
2
2
  class Alias
3
3
  def self.add(source, destinations)
4
4
  srclocalpart, srcdomain = source.split('@')
5
+ domain = Model::Domain[:fqdn => srcdomain]
5
6
 
6
7
  # We don't want aliases for non-local domains, since the
7
8
  # exim router won't accept it.
8
- if not Model::Domain[:fqdn => srcdomain].exists?
9
+ unless domain
9
10
  raise MissingDomain, "You are trying to add an alias for a non existing domain: #{source}"
10
11
  end
11
12
 
@@ -14,7 +15,7 @@ module Smailr
14
15
 
15
16
  Smailr::logger.warn("Adding alias: #{source} -> #{dst}")
16
17
 
17
- Model::Alias.find_or_create(:domain => Model::Domain[:fqdn => srcdomain],
18
+ Model::Alias.find_or_create(:domain => domain,
18
19
  :localpart => srclocalpart,
19
20
  :dstdomain => dstdomain,
20
21
  :dstlocalpart => dstlocalpart)
data/lib/smailr/cli.rb CHANGED
@@ -107,7 +107,7 @@ module Smailr
107
107
  when /^[^@][A-Z0-9.-]+\.[A-Z]{2,6}$/i then
108
108
  domain = Smailr::Model::Domain[:fqdn => args[0]]
109
109
  unless domain
110
- error "No such domain: #{args[0]}"
110
+ say_error "No such domain: #{args[0]}"
111
111
  exit 1
112
112
  end
113
113
 
@@ -124,7 +124,7 @@ module Smailr
124
124
  puts d[:fqdn]
125
125
  end
126
126
  else
127
- error "You can either list a domains or a domains addresses."
127
+ say_error "You can either list a domains or a domains addresses."
128
128
  exit 1
129
129
  end
130
130
  end
@@ -1,3 +1,3 @@
1
1
  module Smailr
2
- VERSION = '0.8.2'
2
+ VERSION = '0.8.4'
3
3
  end
data/lib/smailr.rb CHANGED
@@ -67,13 +67,16 @@ module Smailr
67
67
 
68
68
  def self.initialize!
69
69
  load_config
70
+ database = db_connect
71
+
72
+ Smailr.send(:remove_const, :DB) if Smailr.const_defined?(:DB, false)
73
+ Smailr.const_set(:DB, database)
74
+ Sequel::Model.db = database
70
75
 
71
76
  unless defined?(Smailr::Model)
72
77
  require 'smailr/model'
73
78
  end
74
79
 
75
- Smailr.send(:remove_const, :DB) if Smailr.const_defined?(:DB, false)
76
- Smailr.const_set(:DB, db_connect)
77
80
  Smailr::DB.sql_log_level = :debug
78
81
  end
79
82
 
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.2
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Schlesinger