rounders 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/bin/rounders +1 -1
- data/lib/rounders/application.rb +3 -13
- data/lib/rounders/configuration.rb +17 -0
- data/lib/rounders/generators/app/templates/config/application.rb +1 -2
- data/lib/rounders/generators/handler/templates/%underscored_name%_handler.rb.tt +10 -6
- data/lib/rounders/generators/matcher/templates/%underscored_name%_matcher.rb.tt +6 -2
- data/lib/rounders/generators/plugin/templates/spec/spec_helper.rb.tt +1 -0
- data/lib/rounders/generators/receiver/templates/%underscored_name%_receiver.rb.tt +11 -7
- data/lib/rounders/handlers/handler.rb +4 -2
- data/lib/rounders/matchers/matcher.rb +3 -0
- data/lib/rounders/receivers/mail.rb +14 -13
- data/lib/rounders/receivers/receiver.rb +6 -4
- data/lib/rounders/rounder.rb +3 -2
- data/lib/rounders/spec.rb +5 -0
- data/lib/rounders/stores/store.rb +1 -0
- data/lib/rounders/version.rb +1 -1
- data/lib/rounders.rb +6 -4
- data/rounders.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbacabd11969fabf95be68cfb36d3dbce926bc05
|
4
|
+
data.tar.gz: 664540bd14ff7515e03130ca7845b074926ac99e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2b12d795afc2f201a9b2b79893848d6a6f36fe14050705b882d8f4e5eddb0790dd44b42c0f7f40c655694e819fdb983cb82b0c97839436ea8579d07b70d9b46
|
7
|
+
data.tar.gz: 1677df996af52e83e94683778803a449a33447415d09c05593f23aa00685bceab828409ee7e3ad0d4d84155395e798e4d6309428706dd9d0cb4b0c46894e4146
|
data/.rubocop.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
|
2
2
|
AllCops:
|
3
|
-
TargetRubyVersion: 2.3
|
3
|
+
TargetRubyVersion: 2.3
|
4
4
|
Exclude:
|
5
5
|
- 'vendor/**/*'
|
6
6
|
- 'spec/fixtures/**/*'
|
7
7
|
- 'tmp/**/*'
|
8
|
-
- 'templates/**/*'
|
8
|
+
- 'lib/rounders/generators/**/templates/**/*'
|
9
9
|
##################### Metrics ##################################
|
10
10
|
|
11
11
|
Metrics/LineLength:
|
data/bin/rounders
CHANGED
data/lib/rounders/application.rb
CHANGED
@@ -1,16 +1,6 @@
|
|
1
|
-
|
2
|
-
class Application
|
3
|
-
extend Dry::Configurable
|
4
|
-
|
5
|
-
setting :load_path, [
|
6
|
-
'config/initializers/*.rb'
|
7
|
-
], reader: true
|
8
|
-
|
9
|
-
setting :app_path, 'app', reader: true
|
1
|
+
require_relative 'configuration'
|
10
2
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
setting :store, :memory, reader: true
|
3
|
+
module Rounders
|
4
|
+
class Application < Rounders::DefaultConfiguration
|
15
5
|
end
|
16
6
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Rounders
|
2
|
+
class DefaultConfiguration
|
3
|
+
extend Topping::Configurable::HQ
|
4
|
+
|
5
|
+
config :load_path, required: true, default: [
|
6
|
+
'config/initializers/*.rb'
|
7
|
+
]
|
8
|
+
|
9
|
+
config :app_path, required: true, default: 'app', type: String
|
10
|
+
|
11
|
+
# logger is the logger that will be used for Rounders.logger
|
12
|
+
config :logger, required: true, default: Rounders::Logger.get_logger
|
13
|
+
|
14
|
+
# Use temporaly store
|
15
|
+
config :store, required: true, default: :memory, type: Symbol
|
16
|
+
end
|
17
|
+
end
|
@@ -1,8 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
<% handlers.each do |handler| %>
|
1
|
+
module Rounders
|
2
|
+
module Handlers
|
3
|
+
class <%= class_name %> < Rounders::Handlers::Handler
|
4
|
+
<% handlers.each do |handler| %>
|
5
|
+
on({ body: 'example' }, :<%= handler %>)<% end -%>
|
6
|
+
<% handlers.each do |handler| %>
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
+
def <%= handler %>(mail)
|
9
|
+
end<% end %>
|
10
|
+
end
|
11
|
+
end
|
8
12
|
end
|
@@ -1,12 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module Rounders
|
2
|
+
module Receivers
|
3
|
+
class <%= class_name %> < Rounders::Receivers::Receiver
|
4
|
+
def initialize
|
5
|
+
end
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
+
def receive
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
+
class << self
|
11
|
+
def receive
|
12
|
+
end
|
13
|
+
end
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
@@ -2,6 +2,7 @@ module Rounders
|
|
2
2
|
module Handlers
|
3
3
|
class Handler
|
4
4
|
include Rounders::Plugins::Pluggable
|
5
|
+
include Topping::Configurable::Branch
|
5
6
|
attr_reader :matches, :rounder
|
6
7
|
|
7
8
|
class << self
|
@@ -14,8 +15,9 @@ module Rounders
|
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
17
|
-
def inherited(
|
18
|
-
|
18
|
+
def inherited(klass)
|
19
|
+
super
|
20
|
+
Rounders.handlers << klass
|
19
21
|
end
|
20
22
|
|
21
23
|
def dispatch(rounder, mails)
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Rounders
|
2
2
|
module Matchers
|
3
|
+
include Topping::Configurable::Branch
|
4
|
+
|
3
5
|
class NoImplementError < StandardError
|
4
6
|
end
|
5
7
|
class Matcher
|
@@ -21,6 +23,7 @@ module Rounders
|
|
21
23
|
|
22
24
|
class << self
|
23
25
|
def inherited(klass)
|
26
|
+
super
|
24
27
|
Rounders.matchers[klass.symbol] = klass
|
25
28
|
end
|
26
29
|
|
@@ -1,30 +1,31 @@
|
|
1
1
|
module Rounders
|
2
2
|
module Receivers
|
3
3
|
class Mail < Rounders::Receivers::Receiver
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
config :protocol, default: :imap, required: true
|
5
|
+
config :options, default: {}, required: true
|
6
|
+
config :mail_server_setting, default: {}, required: true
|
7
|
+
|
7
8
|
DEFAULT_FIND_OPTION = {
|
8
9
|
keys: %w[NOT SEEN]
|
9
10
|
}.freeze
|
10
11
|
|
11
|
-
def
|
12
|
-
@client
|
13
|
-
|
12
|
+
def client
|
13
|
+
return @client if @client
|
14
|
+
retriever = Rounders::Receivers::Mail.parser.lookup_retriever_method(config.protocol)
|
15
|
+
@client = retriever.new(config.mail_server_setting)
|
16
|
+
end
|
17
|
+
|
18
|
+
def options
|
19
|
+
@options ||= DEFAULT_FIND_OPTION.merge(config.options)
|
14
20
|
end
|
15
21
|
|
16
22
|
def receive
|
17
|
-
|
23
|
+
client.find(options).map { |message| Rounders::Mail.new(message) }
|
18
24
|
end
|
19
25
|
|
20
26
|
class << self
|
21
27
|
def create
|
22
|
-
|
23
|
-
retriever = parser.lookup_retriever_method(config.protocol)
|
24
|
-
new(
|
25
|
-
client: retriever.new(config.mail_server_setting),
|
26
|
-
options: config.options
|
27
|
-
)
|
28
|
+
new
|
28
29
|
end
|
29
30
|
|
30
31
|
def receive
|
@@ -1,11 +1,13 @@
|
|
1
1
|
module Rounders
|
2
2
|
module Receivers
|
3
3
|
class Receiver
|
4
|
+
include Topping::Configurable::Branch
|
5
|
+
|
4
6
|
class << self
|
5
|
-
def inherited(
|
6
|
-
|
7
|
-
|
8
|
-
Rounders.receivers <<
|
7
|
+
def inherited(klass)
|
8
|
+
super
|
9
|
+
klass.include Rounders::Plugins::Pluggable
|
10
|
+
Rounders.receivers << klass
|
9
11
|
end
|
10
12
|
|
11
13
|
def receive
|
data/lib/rounders/rounder.rb
CHANGED
@@ -15,7 +15,7 @@ module Rounders
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def store
|
18
|
-
@store ||= Rounders.stores[Rounders::Application.store].new
|
18
|
+
@store ||= Rounders.stores[Rounders::Application.config.store].new
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
@@ -44,7 +44,7 @@ module Rounders
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def load_config
|
47
|
-
Rounders::Application.load_path.each do |path|
|
47
|
+
Rounders::Application.config.load_path.each do |path|
|
48
48
|
Pathname.glob(File.join(Dir.pwd, path)).each do |config|
|
49
49
|
require_relative config
|
50
50
|
end
|
@@ -74,6 +74,7 @@ module Rounders
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def setup
|
77
|
+
Topping.build
|
77
78
|
daemon
|
78
79
|
dotenv
|
79
80
|
pid
|
data/lib/rounders/version.rb
CHANGED
data/lib/rounders.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'rounders/version'
|
2
2
|
|
3
|
+
require 'bundler'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'forwardable'
|
3
6
|
require 'thor'
|
4
7
|
require 'thor/group'
|
5
|
-
require '
|
6
|
-
require 'forwardable'
|
8
|
+
require 'topping'
|
7
9
|
require 'mail'
|
8
10
|
require 'dotenv'
|
9
11
|
|
@@ -14,7 +16,7 @@ require 'rounders/util'
|
|
14
16
|
module Rounders
|
15
17
|
# Your code goes here...
|
16
18
|
CONFIG_DIR_PATH = File.join(Dir.pwd, 'config').freeze
|
17
|
-
APP_PATH = File.join(Dir.pwd, Rounders::Application.app_path).freeze
|
19
|
+
APP_PATH = File.join(Dir.pwd, Rounders::Application.config.app_path).freeze
|
18
20
|
|
19
21
|
class << self
|
20
22
|
attr_accessor :logger
|
@@ -40,7 +42,7 @@ module Rounders
|
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
43
|
-
self.logger = Rounders::Application.logger
|
45
|
+
self.logger = Rounders::Application.config.logger
|
44
46
|
end
|
45
47
|
|
46
48
|
require 'rounders/mail'
|
data/rounders.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency 'guard-rubocop', '~> 1.2.0'
|
31
31
|
spec.add_development_dependency 'pry'
|
32
32
|
spec.add_dependency 'dotenv'
|
33
|
-
spec.add_dependency '
|
33
|
+
spec.add_dependency 'topping'
|
34
34
|
spec.add_dependency 'mail', '~> 2.6.4'
|
35
35
|
spec.add_dependency 'mail-gpg'
|
36
36
|
spec.add_dependency 'hanami-utils'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rounders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akira.takahashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -165,7 +165,7 @@ dependencies:
|
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
168
|
+
name: topping
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - ">="
|
@@ -260,6 +260,7 @@ files:
|
|
260
260
|
- lib/rounders/commands/global_command.rb
|
261
261
|
- lib/rounders/commands/local_command.rb
|
262
262
|
- lib/rounders/commands/sub_commands/generate.rb
|
263
|
+
- lib/rounders/configuration.rb
|
263
264
|
- lib/rounders/generators/app/app_generator.rb
|
264
265
|
- lib/rounders/generators/app/templates/.rspec
|
265
266
|
- lib/rounders/generators/app/templates/Gemfile
|
@@ -316,6 +317,7 @@ files:
|
|
316
317
|
- lib/rounders/receivers/mail.rb
|
317
318
|
- lib/rounders/receivers/receiver.rb
|
318
319
|
- lib/rounders/rounder.rb
|
320
|
+
- lib/rounders/spec.rb
|
319
321
|
- lib/rounders/stores/memory.rb
|
320
322
|
- lib/rounders/stores/store.rb
|
321
323
|
- lib/rounders/util.rb
|
@@ -341,7 +343,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
341
343
|
version: '0'
|
342
344
|
requirements: []
|
343
345
|
rubyforge_project:
|
344
|
-
rubygems_version: 2.
|
346
|
+
rubygems_version: 2.6.11
|
345
347
|
signing_key:
|
346
348
|
specification_version: 4
|
347
349
|
summary: bot-ish pluggable incoming mail processing framework
|