fde-mail_crawler 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a21e2ffbc7843b1255ea295153e5b375c5262b3d
4
+ data.tar.gz: 2db5a19d68a54da3680153a0ee874bc21889b060
5
+ SHA512:
6
+ metadata.gz: f0e5cb9643b8c043492af9b21c7b364c8ab75bb98afbf75fab0bece8805ac9e928a115e0241bfcd7605cb4dc125c2cbcceea3cea38e3c7856dfc7addf1da42fd
7
+ data.tar.gz: b6582876e228154b2ac4d348884b7c4507eba8c2068a1135e860960379dcca359e74e8a9e5fd76728f295353dec6d430d9afc0aedfd27ef4737298d9704281bf
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.test.env ADDED
@@ -0,0 +1,7 @@
1
+ MAIL_ADDRESS="imap.example.com"
2
+ MAIL_PORT=143
3
+ MAIL_DOMAIN="example.com"
4
+ MAIL_USER_NAME="example@example.com"
5
+ MAIL_PASSWORD="secret"
6
+ MAIL_AUTHENTICATION="plain"
7
+ MAIL_ENABLE_STARTTLS_AUTO=false
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.15.4
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in mail-cralwer.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Felix Langenegger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # Mail::Crawler
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fde/mail_crawler"
5
+
6
+ require 'dotenv'
7
+
8
+ Dotenv.load('.test.env')
9
+
10
+ # You can add fixtures and/or initialization code here to make experimenting
11
+ # with your gem easier. You can also use a different console, if you like.
12
+
13
+ # (If you use this, don't forget to add pry to your Gemfile!)
14
+ require "pry"
15
+
16
+ FDE::MailCrawler.configure do |config|
17
+ config.address = ENV.fetch('MAIL_ADDRESS')
18
+ config.port = ENV.fetch('MAIL_PORT')
19
+ config.domain = ENV.fetch('MAIL_DOMAIN')
20
+ config.user_name = ENV.fetch('MAIL_USER_NAME')
21
+ config.password = ENV.fetch('MAIL_PASSWORD')
22
+ config.authentication = ENV.fetch('MAIL_AUTHENTICATION')
23
+ config.enable_starttls_auto = ENV.fetch('MAIL_ENABLE_STARTTLS_AUTO')
24
+ end
25
+
26
+
27
+ require "irb"
28
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,42 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "fde/mail_crawler/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fde-mail_crawler"
8
+ spec.version = FDE::MailCrawler::VERSION
9
+ spec.authors = ["Felix Langenegger"]
10
+ spec.email = ["f.langenegger@fadendaten.ch"]
11
+
12
+ spec.summary = %q{A simple Mail Crawler}
13
+ spec.description = %q{Crawls the mails in a IMAP Folder}
14
+ spec.homepage = "https://github.com/fashion-data-exchange/mail-crawler"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_runtime_dependency 'mail', '~> 2.6', '>= 2.6.6'
34
+ spec.add_runtime_dependency "dotenv", "~> 2.2", ">= 2.2.1"
35
+
36
+ spec.add_development_dependency "bundler", "~> 1.15"
37
+ spec.add_development_dependency "rake", "~> 10.0"
38
+ spec.add_development_dependency "rspec", "~> 3.0"
39
+ spec.add_development_dependency "pry", "~> 0.10"
40
+ spec.add_development_dependency "pry-remote", "~> 0.1"
41
+ spec.add_development_dependency "pry-nav", "~> 0.2"
42
+ end
@@ -0,0 +1,5 @@
1
+ module FDE
2
+ module MailCrawler
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,62 @@
1
+ require 'fde/mail_crawler/version'
2
+ require 'mail'
3
+
4
+ module FDE
5
+ module MailCrawler
6
+
7
+ class Config
8
+ attr_accessor :address,
9
+ :port,
10
+ :domain,
11
+ :user_name,
12
+ :password,
13
+ :authentication,
14
+ :enable_starttls_auto
15
+
16
+ def attributes
17
+ {
18
+ address: @address,
19
+ port: @port,
20
+ domain: @domain,
21
+ user_name: @user_name,
22
+ password: @password,
23
+ authentication: @authentication,
24
+ enable_starttls_auto: @enable_starttls_auto
25
+ }
26
+ end
27
+ end
28
+
29
+ def self.config
30
+ @@config ||= Config.new
31
+ end
32
+
33
+ def self.imap_account
34
+ @@imap_account ||= Mail.defaults do
35
+ retriever_method :imap, FDE::MailCrawler.config.attributes
36
+ end
37
+ end
38
+
39
+ def self.configure
40
+ yield self.config
41
+ end
42
+
43
+ def self.watch(&block)
44
+ self.crawl.each do |mail|
45
+ yield mail
46
+ end
47
+ end
48
+
49
+ def self.crawl
50
+ FDE::MailCrawler.imap_account.all
51
+ end
52
+
53
+ def self.delete(message_to_delete)
54
+ account = FDE::MailCrawler.imap_account
55
+ account.find_and_delete do |message|
56
+ if message.subject == message_to_delete.subject
57
+ message.skip_deletion
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
metadata ADDED
@@ -0,0 +1,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fde-mail_crawler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Felix Langenegger
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-09-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mail
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.6'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.6.6
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.6'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.6.6
33
+ - !ruby/object:Gem::Dependency
34
+ name: dotenv
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.2'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.2.1
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '2.2'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.2.1
53
+ - !ruby/object:Gem::Dependency
54
+ name: bundler
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.15'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '1.15'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rake
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '10.0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '10.0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: rspec
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '3.0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '3.0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: pry
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '0.10'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '0.10'
109
+ - !ruby/object:Gem::Dependency
110
+ name: pry-remote
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '0.1'
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '0.1'
123
+ - !ruby/object:Gem::Dependency
124
+ name: pry-nav
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '0.2'
130
+ type: :development
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: '0.2'
137
+ description: Crawls the mails in a IMAP Folder
138
+ email:
139
+ - f.langenegger@fadendaten.ch
140
+ executables: []
141
+ extensions: []
142
+ extra_rdoc_files: []
143
+ files:
144
+ - ".gitignore"
145
+ - ".rspec"
146
+ - ".test.env"
147
+ - ".travis.yml"
148
+ - Gemfile
149
+ - LICENSE.txt
150
+ - README.md
151
+ - Rakefile
152
+ - bin/console
153
+ - bin/setup
154
+ - fde-mail_crawler.gemspec
155
+ - lib/fde/mail_crawler.rb
156
+ - lib/fde/mail_crawler/version.rb
157
+ homepage: https://github.com/fashion-data-exchange/mail-crawler
158
+ licenses:
159
+ - MIT
160
+ metadata:
161
+ allowed_push_host: https://rubygems.org
162
+ post_install_message:
163
+ rdoc_options: []
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ requirements: []
177
+ rubyforge_project:
178
+ rubygems_version: 2.6.8
179
+ signing_key:
180
+ specification_version: 4
181
+ summary: A simple Mail Crawler
182
+ test_files: []