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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d43d6c063f0538d31a42c0e9fe432c561bd8595
4
- data.tar.gz: 6d763ff7a6dd32348ab9b93d9bd03694894dfd02
3
+ metadata.gz: fbacabd11969fabf95be68cfb36d3dbce926bc05
4
+ data.tar.gz: 664540bd14ff7515e03130ca7845b074926ac99e
5
5
  SHA512:
6
- metadata.gz: 69fe8f516ebb23184ac4a8b017eb9661c533da9fdf8a7f55ae9460e904a21ab6333d686f065df9036fe4e6bf7fa7bc8391fbba9994bdcdb89b42ac56dbb44377
7
- data.tar.gz: 4af7f4544a1b0aca2ddb86487de29c778e2f6f81ee4da4ad816cd162f9b29eed1db81a65e2c619ab8c8ee403be930f5dddeb21bd4a972f4b1d14b0453b83bd8c
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.4
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
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
- require 'bundler'
3
+
4
4
  require 'rounders'
5
5
 
6
6
  Rounders::Commander.start(ARGV)
@@ -1,16 +1,6 @@
1
- module Rounders
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
- # logger is the logger that will be used for Rounders.logger
12
- setting :logger, Rounders::Logger.get_logger, reader: true
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,5 +1,4 @@
1
- Rounders::Application.configure do |config|
1
+ class Rounders::<%= class_name %> < Rounders::Application
2
2
  # config.logger = Logger.new('log/rounders.log')
3
-
4
3
  # config.store = :memory
5
4
  end
@@ -1,8 +1,12 @@
1
- class <%= class_name %> < Rounders::Handlers::Handler
2
- <% handlers.each do |handler| %>
3
- on({ body: 'example' }, :<%= handler %>)<% end -%>
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
- def <%= handler %>(mail)
7
- end<% end %>
8
+ def <%= handler %>(mail)
9
+ end<% end %>
10
+ end
11
+ end
8
12
  end
@@ -1,4 +1,8 @@
1
- class <%= class_name %> < Rounders::Matchers::Matcher
2
- def match(message)
1
+ module Rounders
2
+ module Matchers
3
+ class <%= class_name %> < Rounders::Matchers::Matcher
4
+ def match(message)
5
+ end
6
+ end
3
7
  end
4
8
  end
@@ -120,4 +120,5 @@ end
120
120
 
121
121
 
122
122
  require 'rounders'
123
+ require 'rounders/spec'
123
124
  require 'rounders/<%= underscored_name %>'
@@ -1,12 +1,16 @@
1
- class <%= class_name %> < Rounders::Receivers::Receiver
2
- def initialize()
3
- end
1
+ module Rounders
2
+ module Receivers
3
+ class <%= class_name %> < Rounders::Receivers::Receiver
4
+ def initialize
5
+ end
4
6
 
5
- def receive
6
- end
7
+ def receive
8
+ end
7
9
 
8
- class << self
9
- def receive
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(child_class)
18
- Rounders.handlers << child_class
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
- setting :protocol, :imap
5
- setting :options, {}
6
- setting :mail_server_setting
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 initialize(client: nil, options: {})
12
- @client = client
13
- @options = DEFAULT_FIND_OPTION.merge(options)
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
- @client.find(@options).map { |message| Rounders::Mail.new(message) }
23
+ client.find(options).map { |message| Rounders::Mail.new(message) }
18
24
  end
19
25
 
20
26
  class << self
21
27
  def create
22
- config = Mail.config
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(child_class)
6
- child_class.include Rounders::Plugins::Pluggable
7
- child_class.extend Dry::Configurable
8
- Rounders.receivers << child_class
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
@@ -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
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.before(:each) do
3
+ Topping.build
4
+ end
5
+ end
@@ -2,6 +2,7 @@ module Rounders
2
2
  module Stores
3
3
  class Store
4
4
  include Rounders::Plugins::Pluggable
5
+ include Topping::Configurable::Branch
5
6
 
6
7
  def [](key)
7
8
  data[key]
@@ -1,3 +1,3 @@
1
1
  module Rounders
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.7.0'.freeze
3
3
  end
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 'dry-configurable'
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 'dry-configurable'
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.6.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 00:00:00.000000000 Z
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: dry-configurable
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.5.1
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