fakesmtpd 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -62,6 +62,7 @@ module FakeSMTPd
62
62
  end
63
63
 
64
64
  def serve(io)
65
+ io.set_encoding('UTF-8')
65
66
  request_line = io.gets
66
67
  path = request_line.split[1]
67
68
  handle_client(request_line, path, io)
@@ -127,7 +128,9 @@ module FakeSMTPd
127
128
  client.puts 'HTTP/1.1 200 OK'
128
129
  client.puts 'Content-type: application/json;charset=utf-8'
129
130
  client.puts
130
- message = JSON.parse(File.read(message_file))
131
+ message = File.open(message_file, 'r:UTF-8') do |f|
132
+ JSON.parse(f.read)
133
+ end
131
134
  client.puts JSON.pretty_generate(
132
135
  message.merge(
133
136
  _links: {
@@ -182,7 +185,7 @@ module FakeSMTPd
182
185
  end
183
186
 
184
187
  class Server < GServer
185
- VERSION = '0.3.0'
188
+ VERSION = '0.3.1'
186
189
  USAGE = <<-EOU.gsub(/^ {6}/, '')
187
190
  Usage: #{File.basename($0)} <smtp-port> <message-dir> [options]
188
191
 
@@ -203,7 +206,7 @@ module FakeSMTPd
203
206
  def main(argv = [])
204
207
  options = {
205
208
  pidfile: nil,
206
- logfile: $stderr,
209
+ logfile: $stderr.set_encoding('UTF-8'),
207
210
  }
208
211
 
209
212
  OptionParser.new do |opts|
@@ -219,7 +222,7 @@ module FakeSMTPd
219
222
  opts.on('-l LOGFILE', '--logfile LOGFILE',
220
223
  'Optional file where all log messages will be written ' <<
221
224
  '(default $stderr)') do |logfile|
222
- options[:logfile] = File.open(logfile, 'a')
225
+ options[:logfile] = File.open(logfile, 'a:UTF-8')
223
226
  end
224
227
  end.parse!(argv)
225
228
 
@@ -287,6 +290,8 @@ module FakeSMTPd
287
290
  end
288
291
 
289
292
  def serve(client)
293
+ client.set_encoding('UTF-8')
294
+
290
295
  class << client
291
296
  attr_reader :client_id
292
297
 
@@ -364,7 +369,7 @@ module FakeSMTPd
364
369
 
365
370
  def store(message_id, from, recipients, body)
366
371
  outfile = File.join(message_dir, "fakesmtpd-client-#{message_id}.json")
367
- File.open(outfile, 'w') do |f|
372
+ File.open(outfile, 'w:UTF-8') do |f|
368
373
  f.write JSON.pretty_generate(
369
374
  message_id: message_id,
370
375
  from: from,
@@ -1,3 +1,3 @@
1
1
  module FakeSMTPd
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -1,3 +1,5 @@
1
+ require 'minitest/spec'
2
+
1
3
  require 'json'
2
4
  require 'net/http'
3
5
  require 'net/smtp'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakesmtpd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-25 00:00:00.000000000 Z
12
+ date: 2013-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -80,7 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  segments:
82
82
  - 0
83
- hash: -2619994145312715398
83
+ hash: -2428930604012564884
84
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  segments:
91
91
  - 0
92
- hash: -2619994145312715398
92
+ hash: -2428930604012564884
93
93
  requirements: []
94
94
  rubyforge_project:
95
95
  rubygems_version: 1.8.23