Giter VIP home page Giter VIP logo

sisimai / rb-sisimai Goto Github PK

View Code? Open in Web Editor NEW
83.0 8.0 19.0 6.32 MB

Mail Analyzing Interface for email bounce: A Ruby library to parse RFC5322 bounce mails and generating structured data as JSON from parsed results. Ruby version of Sisimai: an error mail analyzer.

Home Page: https://libsisimai.org/

License: Other

Ruby 99.25% Makefile 0.74% Shell 0.01%
smtp bounce-mails bounce-messages ruby sisimai bounce mail email email-parsing email-bounce

rb-sisimai's Introduction

License Coverage Status Ruby Gem Version

Important

The default branch of this repository is 5-stable (Sisimai 5) since 2nd February 2024. If you want to clone the old version, see the 4-stable1 branch instead. We have moved away from using both the main and master branches in our development process.

Warning

Sisimai 5 requires Ruby 2.4 or later. Check the version of Ruby in your system before installing/upgrading by ruby -v command.

Note

Sisimai is a Ruby Gem or Perl module, but it can be used in any environment where JSON can be read, such as PHP, Python, Go, and Rust. By obtaining the analysis results, it is very useful for understanding the bounce occurrence status.

What is Sisimai

Sisimai is a library that decodes complex and diverse bounce emails and outputs the results of the delivery failure, such as the reason for the bounce and the recipient email address, in structured data. It is also possible to output in JSON format. The Ruby version of Sisimai is ported from the Perl version of Sisimai at github.com/sisimai/p5-sisimai.

The key features of Sisimai

  • Decode email bounces to structured data
    • Sisimai provides detailed insights into bounce emails by extracting 24 key data points.2
      • Essential information: timestamp, origin
      • Sender information: addresser, senderdomain,
      • Recipient information: recipient, destination, alias
      • Delivery information: action, replycode,action, replycode, deliverystatus
      • Bounce details: reason, diagnosticcode, diagnostictype, feedbacktype, hardbounce
      • Message details: subject, messageid, listid,
      • Additional information: smtpagent, timezoneoffset, lhost, rhost, token, catch
    • Output formats
      • Ruby (Hash, Array)
      • JSON
        • (by using oj gem at CRuby)
        • (by using jrjackson gem at JRuby)
      • YAML (yaml gem required)
    • Easy to Install, Use.
      • gem install
      • git clone && make
    • High Precision of Analysis

Command line demo

The following screen shows a demonstration of dump method of Sisimai 5 at the command line using Ruby(rb-sisimai) and jq command.

Setting Up Sisimai

System requirements

More details about system requirements are available at Sisimai | Getting Started page.

Install

From RubyGems

$ sudo gem install sisimai
Fetching: sisimai-5.0.2.gem (100%)
Successfully installed sisimai-5.0.2
Parsing documentation for sisimai-5.0.2
Installing ri documentation for sisimai-5.0.2
Done installing documentation for sisimai after 6 seconds
1 gem installed

From GitHub

Warning

Sisimai 5 requires Ruby 2.4 or later. Check the version of Ruby in your system before installing/upgrading by ruby -v command.

% ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin21]

$ cd /usr/local/src
$ git clone https://github.com/sisimai/rb-sisimai.git

$ cd ./rb-sisimai
$ sudo make depend install-from-local
gem install bundle rake minitest
...
3 gems installed
if [ -d "/usr/local/jr" ]; then \
		PATH="/usr/local/jr/bin:$PATH" /usr/local/jr/bin/gem install bundle rake minitest; \
	fi
...
3 gems installed
/opt/local/bin/rake install
sisimai 5.0.2 built to pkg/sisimai-5.0.2.gem.
sisimai (5.0.2) installed.
if [ -d "/usr/local/jr" ]; then \
		PATH="/usr/local/jr/bin:$PATH" /usr/local/jr/bin/rake install; \
	fi
sisimai 5.0.2 built to pkg/sisimai-5.0.2-java.gem.
sisimai (5.0.2) installed.

Usage

Basic usage

Sisimai->rise() method provides the feature for getting decoded data as Ruby Hash from bounced email messages as the following. Beginning with v4.25.6, new accessor origin which keeps the path to email file as a data source is available.

#! /usr/bin/env ruby
require 'sisimai'
v = Sisimai.rise('/path/to/mbox')       # or path to Maildir/

# In v4.23.0, the rise() and dump() methods of the Sisimai class can now read the entire bounce
# email as a string, in addition to the PATH to the email file or mailbox.
f = File.open('/path/to/mbox', 'r');    # or path to Maildir/
v = Sisimai.rise(f.read)

# If you also need analysis results that are "delivered" (successfully delivered), please specify
# the "delivered" option to the rise() method as shown below.
v = Sisimai.rise('/path/to/mbox', delivered: true)

# From v5.0.0, Sisimai no longer returns analysis results with a bounce reason of "vacation" by
# default. If you also need analysis results that show a "vacation" reason, please specify the
# "vacation" option to the rise() method as shown in the following code.
v = Sisimai.rise('/path/to/mbox', vacation: true );

if v.is_a? Array
  v.each do |e|
    puts e.class                # Sisimai::Fact
    puts e.recipient.class      # Sisimai::Address
    puts e.timestamp.class      # Sisimai::Time

    puts e.addresser.address    # "[email protected]" # From
    puts e.recipient.address    # "[email protected]"    # To
    puts e.recipient.host       # "example.jp"
    puts e.deliverystatus       # "5.1.1"
    puts e.replycode            # "550"
    puts e.reason               # "userunknown"
    puts e.origin               # "/var/spool/bounce/Maildir/new/1740074341.eml"
    puts e.hardbounce           # true

    h = e.damn                  # Convert to HASH
    j = e.dump('json')          # Convert to JSON string
    puts e.dump('json')         # JSON formatted bounce data
  end
end

Convert to JSON

Sisimai.dump() method provides the feature for getting decoded data as JSON string from bounced email messages like the following code:

# Get JSON string from path of a mailbox or a Maildir/
puts Sisimai.dump('/path/to/mbox')  # or path to Maildir/

# dump() method also accepts "delivered" and "vacation" option like the following code:
puts Sisimai.dump('/path/to/mbox', delivered: true, vacation: true)

Callback feature

:c___ (c and three _s, looks like a fishhook) argument of Sisimai.rise and Sisimai.dump is an Array and is a parameter to receive Proc objects for callback feature. The first element of :c___ argument is called at Sisimai::Message.sift for dealing email headers and entire message body. The second element of :c___ argument is called at the end of each email file parsing. The result generated by the callback method is accessible via Sisimai::Fact.catch.

[0] For email headers and the body

Callback method set in the first element of :c___ is called at Sisimai::Message.sift().

#! /usr/bin/env ruby
require 'sisimai'
code = lambda do |args|
  head = args['headers']    # (*Hash)  Email headers
  body = args['message']    # (String) Message body
  adds = { 'x-mailer' => '', 'queue-id' => '' }

  if cv = body.match(/^X-Postfix-Queue-ID:\s*(.+)$/)
    adds['queue-id'] = cv[1]
  end
  r['x-mailer'] = head['x-mailer'] || ''
  return adds
end

data = Sisimai.rise('/path/to/mbox', c___: [code, nil])
json = Sisimai.dump('/path/to/mbox', c___: [code, nil])

puts data[0].catch['x-mailer']  # "Apple Mail (2.1283)"
puts data[0].catch['queue-id']  # "43f4KX6WR7z1xcMG"

For each email file

Callback method set in the second element of :c___ is called at Sisimai.rise method for dealing each email file.

path = '/path/to/maildir'
code = lambda do |args|
  kind = args['kind']   # (String) Sisimai::Mail.kind
  mail = args['mail']   # (String) Entire email message
  path = args['path']   # (String) Sisimai::Mail.path
  fact = args['fact']   # (Array)  List of Sisimai::Fact

  fact.each do |e|
    # Store custom information in the "catch" accessor
    e.catch ||= {}
    e.catch['size'] = mail.size
    e.catch['kind'] = kind.capitalize

    if cv = mail.match(/^Return-Path: (.+)$/)
      # Return-Path: <MAILER-DAEMON>
      e.catch['return-path'] = cv[1]
    end
    e.catch['parsedat'] = Time.new.localtime.to_s

    # Save the original email with an additional "X-Sisimai-Parsed:" header to a different PATH.
    a = sprintf("X-Sisimai-Parsed: %d", fact.size)
    p = sprintf("/path/to/another/directory/sisimai-%s.eml", e.token)
    v = mail.sub(/^(From:.+?)$/, '\1' + "\n" + a)
    f = File.open(p, 'w:UTF-8')
    f.write(v)
    f.close

    # Remove the email file in Maildir/ after decoding
    File.delete(path) if kind == 'maildir'

    # Need to not return a value
  end
end

list = Sisimai.rise(path, c___: [nil, code])

puts list[0].catch['size']          # 2202
puts list[0].catch['kind']          # "Maildir"
puts list[0].catch['return-path']   # "<MAILER-DAEMON>"

More information about the callback feature is available at Sisimai | How To Parse - Callback Page.

One-Liner

% ruby -rsisimai -e 'puts Sisimai.dump($*.shift)' /path/to/mbox

Output example

[
  {
    "destination": "google.example.com",
    "lhost": "gmail-smtp-in.l.google.com",
    "hardbounce": 0,
    "reason": "authfailure",
    "catch": null,
    "addresser": "[email protected]",
    "alias": "[email protected]",
    "smtpagent": "Postfix",
    "smtpcommand": "DATA",
    "senderdomain": "example.jp",
    "listid": "",
    "action": "failed",
    "feedbacktype": "",
    "messageid": "[email protected]",
    "origin": "./gmail-5.7.26.eml",
    "recipient": "[email protected]",
    "rhost": "gmail-smtp-in.l.google.com",
    "subject": "Nyaan",
    "timezoneoffset": "+0900",
    "replycode": 550,
    "token": "84656774898baa90660be3e12fe0526e108d4473",
    "diagnostictype": "SMTP",
    "timestamp": 1650119685,
    "diagnosticcode": "host gmail-smtp-in.l.google.com[64.233.187.27] said: This mail has been blocked because the sender is unauthenticated. Gmail requires all senders to authenticate with either SPF or DKIM. Authentication results: DKIM = did not pass SPF [relay3.example.com] with ip: [192.0.2.22] = did not pass For instructions on setting up authentication, go to https://support.google.com/mail/answer/81126#authentication c2-202200202020202020222222cat.127 - gsmtp (in reply to end of DATA command)",
    "deliverystatus": "5.7.26"
  }
]

Differences between Sisimai 4 and Sisimai 5

The following table show the differences between Sisimai 4.25.16p1 and Sisimai 5. More information about differences are available at Sisimai | Differences page.

Features

Beginning with v5.0.0, Sisimai requires Ruby 2.4.0 or later.

Features Sisimai 4 Sisimai 5
System requirements (CRuby) 2.1 - 3.3.0 2.4 or later
System requirements (JRuby) 9.0.4.0 - 9.1.17.0 9.2 or later
Callback feature for the original email file N/A Available3
The number of MTA/ESP modules 68 70
The number of detectable bounce reasons 29 34
Dependencies (Except Ruby Standard Gems) 1 gem 1 gem
Source lines of code 10,300 lines 11,370 lines
Test frameworks rspec minitest
The number of tests in spec/ or test/ directory 311,000 tests 338,000 tests
The number of bounce emails decoded/sec (CRuby)4 231 emails 305 emails
License 2 Clause BSD 2 Caluse BSD
Commercial support Available Available

Decoding Method

Some decoding method names, class names, parameter names have been changed at Sisimai 5. The details of the decoded data are available at LIBSISIMAI.ORG/EN/DATA

Decoding Method Sisimai 4 Sisimai 5
Decoding method name Sisimai.make Sisimai.rise
Dumping method name Sisimai.dump Sisimai.dump
Class name of decoded object Sisimai::Data Sisimai::Fact
Parameter name of the callback hook :c___5
Method name for checking the hard/soft bounce softbounce hardbounce
Decode a vacation message by default Yes No
Sisimai::Message returns an object Yes No
MIME decoding class Sisimai::MIME Sisimai::RFC2045
Decoding transcript of SMTP session No Yes6

MTA/ESP Module Names

Three ESP module names have been changed at Sisimai 5. The list of the all MTA/ESP modules is available at LIBSISIMAI.ORG/EN/ENGINE

Sisimai::Rhost:: Sisimai 4 Sisimai 5
Microsoft Exchange Online ExchangeOnline Microsoft
Google Workspace GoogleApps Google
Tencent TencentQQ Tencent

Bounce Reasons

Five bounce reasons have been added at Sisimai 5. The list of the all bounce reasons sisimai can detect is available at LIBSISIMAI.ORG/EN/REASON

Rejected due to Sisimai 4 Sisimai 5
sender domain authentication(SPF,DKIM,DMARC) SecurityError AuthFailure
low/bad reputation of the sender hostname/IP addr. Blocked BadReputation
missing PTR/having invalid PTR Blocked RequirePTR
non-compliance with RFC7 SecurityError NotCompliantRFC
exceeding a rate limit or sending too fast SecurityError Speeding

Contributing

Bug report

Please use the issue tracker to report any bugs.

Emails could not be decoded

Bounce mails which could not be decoded by Sisimai are saved in the repository set-of-emails/to-be-debugged-because/sisimai-cannot-parse-yet. If you have found any bounce email cannot be decoded using Sisimai, please add the email into the directory and send Pull-Request to this repository.

Other Information

Related Sites

See also

Author

@azumakuniyuki

Copyright

Copyright (C) 2015-2024 azumakuniyuki, All Rights Reserved.

License

This software is distributed under The BSD 2-Clause License.

Footnotes

  1. Specify -b 4-stable when you clone Sisimai 4 for example, git clone -b 4-stable https://github.com/sisimai/rb-sisimai.git

  2. The callback function allows you to add your own data under the catch accessor.

  3. The 2nd argument of :c___ parameter at Sisimai.rise method

  4. macOS Monterey/1.6GHz Dual-Core Intel Core i5/16GB-RAM/Ruby 3.3.0

  5. :c___ looks like a fishhook

  6. Sisimai::SMTP::Transcript.rise Method provides the feature

  7. RFC5322 and related RFCs

rb-sisimai's People

Contributors

azumakuniyuki avatar hiroyuki-sato avatar jpanderson-outreach avatar koic avatar lunatyq avatar michiakinakaya avatar rinmu avatar subuta avatar taku1201 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rb-sisimai's Issues

[BUG] Sisimai.make() method does not work properly on Linux

Sisimai.make() and dump() method don't work properly on Linux when the first argument of the method is a path to a directory. This bug was found from some comments in http://qiita.com/taku1201/items/0afae3dd90507a688e3e

make() works properly on MacOS X and OpenBSD

% ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
% uname -srpm
Darwin 15.3.0 x86_64 i386
% ruby -rsisimai -e 'print Sisimai.make($*.shift).size' set-of-emails/maildir/bsd/
365
% uname -srpm
OpenBSD 5.4 i386 i386
% ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [i386-openbsd5.4]

% ruby -rsisimai -e 'print Sisimai.make($*.shift).size' set-of-emails/maildir/bsd/ 
365

On Linux (CentOS and Ubuntu)

% ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
% uname -srpm
Linux 2.6.32-279.22.1.el6.x86_64 x86_64 x86_64
% cat /etc/redhat-release 
CentOS release 6.3 (Final)

% ruby -rsisimai -e 'print Sisimai.make($*.shift).size' set-of-emails/maildir/bsd/
1
% ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
% uname -srpm
Linux 2.6.39.1-x86_64-linode19 x86_64 unknown
% cat /etc/debian_version 
squeeze/sid

% ruby -rsisimai -e 'print Sisimai.make($*.shift).size' set-of-emails/maildir/bsd/
1

Something wrong on Sisimai::Mail::Maildir class, perhaps.

Sisimai::Address.TO_JSON

This method is called from JSON when the dump format is JSON.

sub TO_JSON {
    # Instance method for JSON::encode()
    # @return   [String] The value of "address" accessor
    my $self = shift;
    return $self->address;
}

Don't include nil in the return value of Sisimai::MTA::*.scan() method

Initial value of the following keys have nil

      def DELIVERYSTATUS
        return {
          'spec'         => nil,  # Protocl specification
          'date'         => nil,  # The value of Last-Attempt-Date header
          'rhost'        => nil,  # The value of Remote-MTA header
          'lhost'        => nil,  # The value of Received-From-MTA header
          'alias'        => nil,  # The value of alias entry(RHS)
          'agent'        => nil,  # MTA name
          'action'       => nil,  # The value of Action header
          'status'       => nil,  # The value of Status header
          'reason'       => nil,  # Temporary reason of bounce
          'command'      => nil,  # SMTP command in the message body
          'diagnosis'    => nil,  # The value of Diagnostic-Code header
          'recipient'    => nil,  # The value of Final-Recipient header
          'softbounce'   => nil,  # Soft bounce or not
          'feedbacktype' => nil,  # Feedback Type
        }
      end

When there is any value which is still nil or could not be detected, each value should be set ''(empty string).

Update TODO part in gemspec.

You need to update "TODO" part in gemespec file.
Please update later.

rake build 
rake aborted!
WARNING:  See http://guides.rubygems.org/specification-reference/ for help
ERROR:  While executing gem ... (Gem::InvalidSpecificationException)
    "FIXME" or "TODO" is not a description

Tasks: TOP => build
(See full trace by running task with --trace)

example

diff --git a/sisimai.gemspec b/sisimai.gemspec
index cc3c25b..18596ad 100644
--- a/sisimai.gemspec
+++ b/sisimai.gemspec
@@ -14,9 +14,9 @@ Gem::Specification.new do |spec|
       "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
   end

-  spec.summary       = 'TODO: Write a short summary, because Rubygems requires one.'
-  spec.description   = 'TODO: Write a longer description or delete this line.'
-  spec.homepage      = "TODO: Put your gem's website or public repo URL here."
+  spec.summary       = 'Mail Analyzing Interface'
+  spec.description   = 'Sisimai is a Ruby library for analyzing RFC5322 bounce emails and generating structured data from parsed results.'
+  spec.homepage      = "https://github.com/sisimai/rb-Sisimai"
   spec.license       = 'MIT'

   spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }

after this update, you can create gem file.

rake build 
sisimai 4.0.0 built to pkg/sisimai-4.0.0.gem.

[BUG] Sisimai.make() freezes on FreeBSD

Sisimai.make() and dump() method freeze on FreeBSD when the first argument is a path to a directory.

% uname -srpm
FreeBSD 10.1-RELEASE-p24 amd64 amd64
% ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-freebsd10.1]

% ruby -rsisimai -e 'print Sisimai.make($*.shift).size' ./set-of-emails/maildir/bsd
^C/usr/local/lib/ruby/gems/2.2.0/gems/sisimai-4.17.0/lib/sisimai/message.rb:46:in `initialize': Interrupt

Something wrong in Sisimai::Mail::Maildir class, perhaps.

Test codes to be ported to the Ruby version of Sisimai

  • 001-sisimai.t
  • 010-address.t
  • 011-mime.t
  • 012-string.t
  • 013-datetime.t
  • 014-time.t
  • 020-mail.t
  • 021-mail-mbox.t
  • 022-mail-maildir.t
  • 023-mail-stdin.t
  • 030-rfc3463.t
  • 031-rfc5322.t
  • 032-rfc2606.t
  • 035-rfc5321.t
  • 040-message.t
  • 041-order.t
  • 050-mta.t
  • 051-mta-children.t
  • 052-mta-relative.t
  • 060-msp.t
  • 061-msp-children.t
  • 070-mda.t
  • 190-emails-crlf-or-cr.t
  • 200-reason.t
  • 201-reason-children.t
  • 300-rhost.t
  • 301-rhost-googleapps.t
  • 500-data.t
  • 501-data-json.t
  • 502-data-yaml.t
  • 510-mta-userdefined.t
  • 800-cannot-parse-yet.t
  • 801-reason-is-undefined.t
  • 802-reason-is-onhold.t

`jgem install sisimai` fails on JRuby

I've tested on JRuby 9.0.5.0 on FreeBSD and got the same error message when "jgem install sisimai".

# uname -mprs
FreeBSD 10.1-RELEASE-p24 amd64 amd64

# /usr/local/bin/java -version
openjdk version "1.7.0_95"
OpenJDK Runtime Environment (build 1.7.0_95-b00)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)

# /usr/local/jruby/bin/jruby -v
jruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d OpenJDK 64-Bit Server VM 24.95-b01 on 1.7.0_95-b00 +jit [FreeBSD-amd64]
# /usr/local/jruby/bin/jgem install sisimai
Fetching: oj-2.14.4.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing sisimai:
    ERROR: Failed to build gem native extension.

    /usr/local/jruby/bin/jruby -r ./siteconf20160216-13461-17h6cbz.rb extconf.rb
NotImplementedError: C extensions are not supported
    <top> at /usr/local/jruby/lib/ruby/stdlib/mkmf.rb:1
  require at org/jruby/RubyKernel.java:937
   (root) at /usr/local/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
    <top> at extconf.rb:1

extconf failed, exit code 1

Gem files will remain installed in /usr/local/jruby/lib/ruby/gems/shared/gems/oj-2.14.4 for inspection.
Results logged to /usr/local/jruby/lib/ruby/gems/shared/extensions/universal-java-1.7/2.2.0/oj-2.14.4/gem_make.out

This problem is reported from @hiroyuki-sato at his Gist: https://gist.github.com/hiroyuki-sato/b71049e3dfb20e5408fb

Convert some String values and Hash keys to Symbol

Because symbol is about 2 times faster than String.

require 'benchmark'

HowMany = 30000000
String0 = 'sironeko'
Symbol0 = :sironeko

puts 'ok' if String0 == 'sironeko'
puts 'ok' if Symbol0 == :sironeko

Benchmark.bmbm do |b|
  b1 = 0
  b.report('String') do
    HowMany.times do
      b1 += 1 if String0 == 'sironeko'
    end
  end

  b2 = 0
  b.report('Symbol') do
    HowMany.times do
      b2 += 1 if Symbol0 == :sironeko
    end
  end
end

__END__
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin13]
Rehearsal ------------------------------------------
String   6.540000   0.070000   6.610000 (  6.619563)
Symbol   3.170000   0.050000   3.220000 (  3.255752)
--------------------------------- total: 9.830000sec

             user     system      total        real
String   6.470000   0.060000   6.530000 (  6.535174)
Symbol   3.080000   0.020000   3.100000 (  3.105818)
ruby string-vs-symbol.rb  19.31s user 0.21s system 99% cpu 19.593 total

https://github.com/azumakuniyuki/ruby-benchmark-collection/blob/master/string-vs-symbol.rb

Style/SpaceInsideParens: Space inside parentheses detected

  • lib/sisimai/data.rb:239:29:
  • lib/sisimai/data.rb:239:57:
  • lib/sisimai/message.rb:33:18:
  • lib/sisimai/message.rb:33:25:
  • lib/sisimai/message.rb:34:18:
  • lib/sisimai/message.rb:34:25:
  • lib/sisimai/mime.rb:120:25:
  • lib/sisimai/mime.rb:120:39:
  • lib/sisimai/mime.rb:121:25:
  • lib/sisimai/mime.rb:121:39:
  • lib/sisimai/msp.rb:13:33:
  • lib/sisimai/msp.rb:13:40:
  • lib/sisimai/msp.rb:14:33:
  • lib/sisimai/msp.rb:14:40:
  • lib/sisimai/mta.rb:13:33:
  • lib/sisimai/mta.rb:13:40:
  • lib/sisimai/mta.rb:14:33:
  • lib/sisimai/mta.rb:14:40:

Version number of the first release

  1. Use the same version with p5-Sisimai (v4.14.1 or v4.14.2)
  2. Version number independent from p5-Sisimai. Current version of rb-Sisimai is v4.0.0

Lint/UselessAssignment: Useless assignment to variable

  • lib/sisimai/address.rb:72:9:
  • lib/sisimai/address.rb:134:7:
  • lib/sisimai/arf.rb:92:9:
  • lib/sisimai/arf.rb:134:28:
  • lib/sisimai/data.rb:335:13:
  • lib/sisimai/data.rb:336:13:
  • lib/sisimai/data.rb:396:7:
  • lib/sisimai/datetime.rb:261:9:
  • lib/sisimai/datetime.rb:293:9:
  • lib/sisimai/datetime.rb:471:9:
  • lib/sisimai/datetime.rb:505:9:
  • lib/sisimai/mail/maildir.rb:44:9:
  • lib/sisimai/mail/maildir.rb:45:9:
  • lib/sisimai/mail/maildir.rb:46:9:
  • lib/sisimai/mail/maildir.rb:47:9:
  • lib/sisimai/message.rb:55:7:
  • lib/sisimai/message.rb:452:33:
  • lib/sisimai/mime.rb:31:9:
  • lib/sisimai/msp/us/receivingses.rb:218:15:
  • lib/sisimai/mta/domino.rb:75:30:
  • lib/sisimai/mta/exchange.rb:130:30:
  • lib/sisimai/mta/exim.rb:173:11:
  • lib/sisimai/mta/exim.rb:183:15:
  • lib/sisimai/mta/exim.rb:189:30:
  • lib/sisimai/mta/mailmarshalsmtp.rb:55:11:
  • lib/sisimai/mta/opensmtpd.rb:121:30:
  • lib/sisimai/mta/qmail.rb:168:30:
  • lib/sisimai/mta/surfcontrol.rb:52:11:
  • lib/sisimai/mta/x4.rb:189:11:

character class has duplicated range

rb-Sisimai/lib/sisimai/time.rb:201: warning: character class has duplicated range
rb-Sisimai/lib/sisimai/time.rb:207: warning: character class has duplicated range

rake spec fails on JRuby 1.7

https://travis-ci.org/azumakuniyuki/rb-Sisimai/jobs/91039695

Using worker: worker-linux-docker-1c8832e5.prod.travis-ci.org:travis-linux-6

Build system information
Build language: ruby
Build image provisioning date and time
Thu Feb  5 15:09:33 UTC 2015
Operating System Details
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.5 LTS
Release:    12.04
Codename:   precise
Linux Version
3.13.0-29-generic
Cookbooks Version
a68419e https://github.com/travis-ci/travis-cookbooks/tree/a68419e
GCC version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

LLVM version
clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Pre-installed Ruby versions
ruby-1.9.3-p551
Pre-installed Node.js versions
v0.10.36
Pre-installed Go versions
1.4.1
Redis version
redis-server 2.8.19
riak version
2.0.2
MongoDB version
MongoDB 2.4.12
CouchDB version
couchdb 1.6.1
Neo4j version
1.9.4
RabbitMQ Version
3.4.3
ElasticSearch version
1.4.0
Installed Sphinx versions
2.0.10
2.1.9
2.2.6
Default Sphinx version
2.2.6
Installed Firefox version
firefox 31.0esr
PhantomJS version
1.9.8
ant -version
Apache Ant(TM) version 1.8.2 compiled on December 3 2011
mvn -version
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T17:29:23+00:00)
Maven home: /usr/local/maven
Java version: 1.7.0_76, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "3.13.0-29-generic", arch: "amd64", family: "unix"

$ git clone --depth=50 --branch=master https://github.com/azumakuniyuki/rb-Sisimai.git azumakuniyuki/rb-Sisimai
Cloning into 'azumakuniyuki/rb-Sisimai'...
remote: Counting objects: 217, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 217 (delta 10), reused 0 (delta 0), pack-reused 187
Receiving objects: 100% (217/217), 34.03 KiB | 0 bytes/s, done.
Resolving deltas: 100% (98/98), done.
Checking connectivity... done.
$ cd azumakuniyuki/rb-Sisimai
$ git checkout -qf a00a1809eb4e09fcdefc4c819317fb7a9f6de82b

This job is running on container-based infrastructure, which does not allow use of 'sudo', setuid and setguid executables.
If you require sudo, add 'sudo: required' to your .travis.yml
See http://docs.travis-ci.com/user/workers/container-based-infrastructure/ for details.
Setting up build cache
$ export CASHER_DIR=$HOME/.casher
$ Installing caching utilities
attempting to download cache archive
fetching master/cache--rvm-jruby-d19--gemfile-Gemfile.tgz
fetching master/cache--rvm-jruby-d19--gemfile-Gemfile.tbz
could not download cache
$ rvm use jruby-d19 --install --binary --fuzzy
Using /home/travis/.rvm/gems/jruby-1.7.19-d19
$ export BUNDLE_GEMFILE=$PWD/Gemfile
$ java -Xmx32m -version
java version "1.7.0_76"
Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)
$ javac -J-Xmx32m -version
javac 1.7.0_76
$ ruby --version
jruby 1.7.19 (1.9.3p551) 2015-02-05 32f5af0 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_76-b13 +jit [linux-amd64]
$ rvm --version
rvm 1.26.10 (latest-minor) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
$ bundle --version
Bundler version 1.7.12
$ gem --version
2.4.5
$ gem update bundler
Updating installed gems
Updating bundler
Fetching: bundler-1.10.6.gem (100%)
Successfully installed bundler-1.10.6
Gems updated: bundler
adding /home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle to cache
$ bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Using bundler 1.10.6
Installing diff-lcs 1.2.5
Installing rake 10.4.2
Using sisimai 0.1.0 from source at .
Installing rspec-support 3.4.0
Installing rspec-expectations 3.4.0
Installing rspec-core 3.4.0
Installing rspec-mocks 3.4.0
Installing rspec 3.4.0
Bundle complete! 4 Gemfile dependencies, 9 gems now installed.
Bundled gems are installed into ./vendor/bundle.
$ bundle exec rake spec
/home/travis/.rvm/rubies/jruby-1.7.19-d19/bin/jruby -I/home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle/jruby/1.9/gems/rspec-core-3.4.0/lib:/home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle/jruby/1.9/gems/rspec-support-3.4.0/lib /home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle/jruby/1.9/gems/rspec-core-3.4.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
SyntaxError: /home/travis/build/azumakuniyuki/rb-Sisimai/spec/sisimai-string_spec.rb:54: invalid multibyte char (US-ASCII)
             load at org/jruby/RubyKernel.java:1087
           (root) at /home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle/jruby/1.9/gems/rspec-core-3.4.0/lib/rspec/core/configuration.rb:1
             each at org/jruby/RubyArray.java:1613
  load_spec_files at /home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle/jruby/1.9/gems/rspec-core-3.4.0/lib/rspec/core/configuration.rb:1361
  load_spec_files at /home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle/jruby/1.9/gems/rspec-core-3.4.0/lib/rspec/core/configuration.rb:1359
            setup at /home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle/jruby/1.9/gems/rspec-core-3.4.0/lib/rspec/core/runner.rb:102
              run at /home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle/jruby/1.9/gems/rspec-core-3.4.0/lib/rspec/core/runner.rb:88
              run at /home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle/jruby/1.9/gems/rspec-core-3.4.0/lib/rspec/core/runner.rb:73
           (root) at /home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle/jruby/1.9/gems/rspec-core-3.4.0/exe/rspec:4
/home/travis/.rvm/rubies/jruby-1.7.19-d19/bin/jruby -I/home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle/jruby/1.9/gems/rspec-core-3.4.0/lib:/home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle/jruby/1.9/gems/rspec-support-3.4.0/lib /home/travis/build/azumakuniyuki/rb-Sisimai/vendor/bundle/jruby/1.9/gems/rspec-core-3.4.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb failed

The command "bundle exec rake spec" exited with 1.
store build cache
$ bundle clean
Resolving dependencies...
changes detected, packing new archive
uploading archive

Done. Your build exited with 1.

Sisimai::SMTP::*

Sisimai::RFC3463 and Sisimai::RFC5321 will be renamed and belonged to Sisimai::SMTP::* name space because the both module deal only SMTP status code or reply code.
See sisimai/p5-sisimai#131

rb-Sisimai does not work properly in multithread environment.

Reference.

@hiroysato ここで、クラス変数(マルチスレッドで共有されている)に対して、ロックなしでconcat(配列を破壊的に変更する)しているのがマズそうな気がします:https://t.co/xE7BZZvOOH

— Sadayuki Furuhashi (@frsyuki) 2016, 2月 5
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

I'm developing embulk-parser-sisimai_analyzer. It run in multithread environment.

error log

@hiroysato ad-hocですが典型的な回避策は、まずクラスに定数 GLOBAL_MUTEX = https://t.co/Uk7arSpaiP を定義しておいて、

— Sadayuki Furuhashi (@frsyuki) 2016, 2月 5
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

@hiroysato Sisimai::https://t.co/x6qwXS0Hrh を、GLOBAL_MUTEX.synchornized { Sisimai::https://t.co/x6qwXS0Hrh } に置き換える方法があります。まぁそれほど悪くないと思います

— Sadayuki Furuhashi (@frsyuki) 2016, 2月 5
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

sisimai/time_spec.rb use eq not be.

I saw https://ci.appveyor.com/project/azumakuniyuki/rb-sisimai

expect and got values are same. Maybe you should use eq

http://engineerflies.blogspot.jp/2012/06/rspecequal-eql-eq-be.html

sisimai/time_spec.rb

  describe '.to_json' do
    it('returns Integer') { expect(to.to_json).to be_a Integer }
    it('returns machine time') { expect(to.to_json).to be to.to_time.to_i }
  end
[00:00:39]   90) Sisimai::Time.to_json returns machine time
[00:00:39]       Failure/Error: it('returns machine time') { expect(to.to_json).to be to.to_time.to_i }
[00:00:39] 
[00:00:39]         expected #<Bignum:194267220> => -210863520000
[00:00:39]              got #<Bignum:194268260> => -210863520000
[00:00:39] 
[00:00:39]         Compared using equal?, which compares object identity,
[00:00:39]         but expected and actual are not the same object. Use
[00:00:39]         `expect(actual).to eq(expected)` if you don't care about
[00:00:39]         object identity in this example.
[00:00:39]       # ./spec/sisimai/time_spec.rb:13:in `block (3 levels) in <top (required)>'

[Feature Request] Is it possible to create single parsed JSON file?

Is it possible to create single parsed JSON file?
If not, please add those methods.

I would like to create JSON object per mails.

Example.

https://github.com/hiroyuki-sato/embulk-parser-sisimai_analyzer/blob/master/lib/embulk/parser/sisimai_analyzer.rb#L33

{"subject":"キジトラ","replycode":"550","action":"failed","lhost":"192.0.2.31","diagnosticcode":"550 Unknown user [email protected]","timestamp":1240874268,"deliverystatus":"5.1.1","addresser":"[email protected]","smtpcommand":"DATA","reason":"userunknown","smtpagent":"Sendmail","alias":"","recipient":"[email protected]","token":"1e86ae85ee6075211a5cb514c312c5a89193268d","feedbacktype":"","softbounce":0,"rhost":"mfsmax.docomo.ne.jp","listid":"","messageid":"[email protected]","diagnostictype":"SMTP","destination":"docomo.ne.jp","timezoneoffset":"+0900","senderdomain":"example.jp"}
{"subject":"キジトラ","replycode":"550","action":"failed","lhost":"192.0.2.97","diagnosticcode":"550 Host unknown","timestamp":1221728044,"deliverystatus":"5.1.2","addresser":"[email protected]","smtpcommand":"","reason":"hostunknown","smtpagent":"Sendmail","alias":"","recipient":"[email protected]","token":"d059e55e074333fe59001b1d30d27da85a1a9c1d","feedbacktype":"","softbounce":0,"rhost":"example.gov","listid":"","messageid":"AA406E7E18714AB2927DAACC24B47C4A@USER-PC97","diagnostictype":"SMTP","destination":"example.gov","timezoneoffset":"+0900","senderdomain":"example.jp"}

Libraries to be ported to Ruby version of Sisimai

  • Sisimai.pm
  • Sisimai/ARF.pm
  • Sisimai/Address.pm
  • Sisimai/Data.pm
  • Sisimai/Data/JSON.pm
  • Sisimai/Data/YAML.pm
  • Sisimai/DateTime.pm
  • Sisimai/MDA.pm
  • Sisimai/MIME.pm
  • Sisimai/MSP.pm
  • Sisimai/MSP/DE/EinsUndEins.pm
  • Sisimai/MSP/DE/GMX.pm
  • Sisimai/MSP/JP/Biglobe.pm
  • Sisimai/MSP/JP/EZweb.pm
  • Sisimai/MSP/JP/KDDI.pm
  • Sisimai/MSP/RU/MailRu.pm
  • Sisimai/MSP/RU/Yandex.pm
  • Sisimai/MSP/UK/MessageLabs.pm
  • Sisimai/MSP/US/AmazonSES.pm
  • Sisimai/MSP/US/Aol.pm
  • Sisimai/MSP/US/Bigfoot.pm
  • Sisimai/MSP/US/Facebook.pm
  • Sisimai/MSP/US/Google.pm
  • Sisimai/MSP/US/Outlook.pm
  • Sisimai/MSP/US/ReceivingSES.pm
  • Sisimai/MSP/US/SendGrid.pm
  • Sisimai/MSP/US/Verizon.pm
  • Sisimai/MSP/US/Yahoo.pm
  • Sisimai/MSP/US/Zoho.pm
  • Sisimai/MTA.pm
  • Sisimai/MTA/Activehunter.pm
  • Sisimai/MTA/ApacheJames.pm
  • Sisimai/MTA/Courier.pm
  • Sisimai/MTA/Domino.pm
  • Sisimai/MTA/Exchange.pm
  • Sisimai/MTA/Exim.pm
  • Sisimai/MTA/IMailServer.pm
  • Sisimai/MTA/InterScanMSS.pm
  • Sisimai/MTA/MXLogic.pm
  • Sisimai/MTA/MailFoundry.pm
  • Sisimai/MTA/MailMarshalSMTP.pm
  • Sisimai/MTA/McAfee.pm
  • Sisimai/MTA/MessagingServer.pm
  • Sisimai/MTA/Notes.pm
  • Sisimai/MTA/OpenSMTPD.pm
  • Sisimai/MTA/Postfix.pm
  • Sisimai/MTA/Sendmail.pm
  • Sisimai/MTA/SurfControl.pm
  • Sisimai/MTA/UserDefined.pm
  • Sisimai/MTA/V5sendmail.pm
  • Sisimai/MTA/X1.pm
  • Sisimai/MTA/X2.pm
  • Sisimai/MTA/X3.pm
  • Sisimai/MTA/X4.pm
  • Sisimai/MTA/X5.pm
  • Sisimai/MTA/mFILTER.pm
  • Sisimai/MTA/qmail.pm
  • Sisimai/Mail.pm
  • Sisimai/Mail/Maildir.pm
  • Sisimai/Mail/Mbox.pm
  • Sisimai/Mail/STDIN.pm
  • Sisimai/Message.pm
  • Sisimai/Order.pm
  • Sisimai/RFC2606.pm
  • Sisimai/RFC3463.pm
  • Sisimai/RFC3464.pm
  • Sisimai/RFC3834.pm
  • Sisimai/RFC5321.pm
  • Sisimai/RFC5322.pm
  • Sisimai/Reason.pm
  • Sisimai/Reason/Blocked.pm
  • Sisimai/Reason/ContentError.pm
  • Sisimai/Reason/ExceedLimit.pm
  • Sisimai/Reason/Expired.pm
  • Sisimai/Reason/Filtered.pm
  • Sisimai/Reason/HasMoved.pm
  • Sisimai/Reason/HostUnknown.pm
  • Sisimai/Reason/MailboxFull.pm
  • Sisimai/Reason/MailerError.pm
  • Sisimai/Reason/MesgTooBig.pm
  • Sisimai/Reason/NetworkError.pm
  • Sisimai/Reason/NoRelaying.pm
  • Sisimai/Reason/NotAccept.pm
  • Sisimai/Reason/OnHold.pm
  • Sisimai/Reason/Rejected.pm
  • Sisimai/Reason/SecurityError.pm
  • Sisimai/Reason/SpamDetected.pm
  • Sisimai/Reason/Suspend.pm
  • Sisimai/Reason/SystemError.pm
  • Sisimai/Reason/SystemFull.pm
  • Sisimai/Reason/TooManyConn.pm
  • Sisimai/Reason/UserUnknown.pm
  • Sisimai/Rhost.pm
  • Sisimai/Rhost/GoogleApps.pm
  • Sisimai/String.pm
  • Sisimai/Time.pm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.