rounders 0.5.2 → 0.6.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: 126e0a927c3fa14106a6a32c49c144d26ee97f97
4
- data.tar.gz: b02639af80afccfee88ebaa8ee589c285084efbc
3
+ metadata.gz: 2d43d6c063f0538d31a42c0e9fe432c561bd8595
4
+ data.tar.gz: 6d763ff7a6dd32348ab9b93d9bd03694894dfd02
5
5
  SHA512:
6
- metadata.gz: 9f8856192b7941e1381fea21c7681299372dd9ab28a11a3625818a931e2fdc4bec79aa02b6fbb87188a4c352971dc9616dcd379f5de8c1c97da8daefca08af0b
7
- data.tar.gz: 9fd50ba93e486fdedd1ed853c4b29c4db24bebdbdf4a8e9ec1e9f6c206f861e4e657ef5a4085a30bbee8156173817e5fba0abc613d51839cb5b016df08abcbc9
6
+ metadata.gz: 69fe8f516ebb23184ac4a8b017eb9661c533da9fdf8a7f55ae9460e904a21ab6333d686f065df9036fe4e6bf7fa7bc8391fbba9994bdcdb89b42ac56dbb44377
7
+ data.tar.gz: 4af7f4544a1b0aca2ddb86487de29c778e2f6f81ee4da4ad816cd162f9b29eed1db81a65e2c619ab8c8ee403be930f5dddeb21bd4a972f4b1d14b0453b83bd8c
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rounders.gemspec
4
4
  gemspec
5
+ group :test do
6
+ gem 'aruba', '~> 0.14.2'
7
+ end
data/Guardfile CHANGED
@@ -7,6 +7,7 @@ group :red_green_refactor, halt_on_fail: true do
7
7
  guard :rspec, cmd: 'bundle exec rspec --color --format documentation' do
8
8
  watch(%r{^spec/.+_spec\.rb$})
9
9
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
10
+ watch(%r{^lib/rounders/generators/(.+)\.rb$}) { |_m| 'spec/cli/**/*_spec.rb' }
10
11
  watch('spec/spec_helper.rb') { 'spec' }
11
12
  end
12
13
  end
@@ -0,0 +1,16 @@
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
10
+
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
15
+ end
16
+ end
@@ -1,7 +1,8 @@
1
1
  module Rounders
2
2
  module Commands
3
3
  class GlobalCommand < Thor
4
- class_option :help, type: :boolean, aliases: '-h', desc: 'Help message.'
4
+ class_option :help, type: :boolean, aliases: '-h', desc: 'Help message'
5
+ class_option :version, type: :boolean, desc: 'version'
5
6
  package_name 'rounders'
6
7
 
7
8
  register(
@@ -14,9 +15,14 @@ module Rounders
14
15
  register(
15
16
  Rounders::Generators::PluginGenerator,
16
17
  'plugin',
17
- 'plugin <name>',
18
+ 'plugin <name> <path>',
18
19
  'Generate new rounders plugin'
19
20
  )
21
+
22
+ desc 'version', 'Show rounders versoin'
23
+ def version
24
+ puts Rounders::VERSION
25
+ end
20
26
  end
21
27
  end
22
28
  end
@@ -2,6 +2,7 @@ module Rounders
2
2
  module Commands
3
3
  class LocalCommand < Thor
4
4
  class_option :help, type: :boolean, aliases: '-h', desc: 'Help message.'
5
+ class_option :version, type: :boolean, desc: 'version'
5
6
  package_name 'rounders'
6
7
 
7
8
  desc 'start', 'Start the Rounders'
@@ -9,6 +10,7 @@ module Rounders
9
10
  method_option :dotenv, type: :boolean, default: false
10
11
  method_option :daemon, type: :boolean, default: false
11
12
  method_option :pid, type: :string
13
+
12
14
  def start
13
15
  rounder = Rounders::Rounder.new(options)
14
16
  rounder.start
@@ -17,6 +19,11 @@ module Rounders
17
19
  desc 'generate [Type]', 'Generate new code'
18
20
  method_option aliases: '-g'
19
21
  subcommand 'generate', SubCommands::Generate
22
+
23
+ desc 'version', 'Show rounders versoin'
24
+ def version
25
+ puts Rounders::VERSION
26
+ end
20
27
  end
21
28
  end
22
29
  end
@@ -5,7 +5,7 @@ module Rounders
5
5
  argument :path, type: :string, required: false
6
6
 
7
7
  def set_destination_root
8
- p = path.nil? ? name : path
8
+ p = path.nil? ? name : File.join(path, name)
9
9
  self.destination_root = p
10
10
  end
11
11
 
@@ -0,0 +1,5 @@
1
+ Rounders::Application.configure do |config|
2
+ # config.logger = Logger.new('log/rounders.log')
3
+
4
+ # config.store = :memory
5
+ end
@@ -5,8 +5,8 @@ Rounders::Receivers::Mail.configure do |config|
5
5
  config.mail_server_setting = {
6
6
  address: 'imap.gmail.com',
7
7
  port: 993,
8
- user_name: ENV['GMAIL_USER_NAME'],
9
- password: ENV['GMAIL_PASSWORD'],
8
+ user_name: ENV['USER_NAME'],
9
+ password: ENV['PASSWORD'],
10
10
  enable_ssl: true
11
11
  }
12
12
  config.options = {
@@ -5,7 +5,9 @@ module Rounders
5
5
  argument :path, type: :string, required: false
6
6
 
7
7
  def set_destination_root
8
- self.destination_root = "rounders-#{underscored_name}"
8
+ n = "rounders-#{underscored_name}"
9
+ p = path.nil? ? n : File.join(path, n)
10
+ self.destination_root = p
9
11
  end
10
12
 
11
13
  def create_directory
data/lib/rounders/mail.rb CHANGED
@@ -54,6 +54,14 @@ module Rounders
54
54
  @mail = mail
55
55
  end
56
56
 
57
+ def text
58
+ if mail.multipart?
59
+ mail.text_part.decoded
60
+ else
61
+ mail.decoded
62
+ end
63
+ end
64
+
57
65
  private
58
66
 
59
67
  def respond_to_missing?(method, *args, &block)
@@ -8,11 +8,7 @@ module Rounders
8
8
  end
9
9
 
10
10
  def match(mail)
11
- if mail.multipart?
12
- mail.text_part.decoded.match(pattern)
13
- else
14
- mail.decoded.match(pattern)
15
- end
11
+ mail.text.match(pattern)
16
12
  end
17
13
  end
18
14
  end
@@ -24,10 +24,6 @@ module Rounders
24
24
  Rounders.matchers[klass.symbol] = klass
25
25
  end
26
26
 
27
- def symbol
28
- Util.infrect(name.split('::').last).underscore.to_sym
29
- end
30
-
31
27
  def build(conditions)
32
28
  matchers = conditions.map do |key, pattern|
33
29
  matcher = Rounders.matchers[key]
@@ -22,12 +22,16 @@ module Rounders
22
22
  @directory_name ||= Util.infrect(feature_name.split('_').first).pluralize
23
23
  end
24
24
 
25
+ def symbol
26
+ Util.infrect(name.split('::').last).underscore.to_sym
27
+ end
28
+
25
29
  def load_path
26
30
  @load_path ||= File.join(Rounders::APP_PATH, directory_name)
27
31
  end
28
32
 
29
33
  def load_plugins
30
- Pathname.glob("#{load_path}/*.rb").each do |plugin|
34
+ Pathname.glob("#{load_path}/**/*.rb").each do |plugin|
31
35
  begin
32
36
  Rounders.logger.info "load #{plugin.expand_path}"
33
37
  require_relative plugin.expand_path
@@ -14,6 +14,10 @@ module Rounders
14
14
  polling
15
15
  end
16
16
 
17
+ def store
18
+ @store ||= Rounders.stores[Rounders::Application.store].new
19
+ end
20
+
17
21
  private
18
22
 
19
23
  def bundle
@@ -40,8 +44,10 @@ module Rounders
40
44
  end
41
45
 
42
46
  def load_config
43
- Pathname.glob(File.join(Dir.pwd, 'config/initializers/*.rb')).each do |config|
44
- require_relative config
47
+ Rounders::Application.load_path.each do |path|
48
+ Pathname.glob(File.join(Dir.pwd, path)).each do |config|
49
+ require_relative config
50
+ end
45
51
  end
46
52
  end
47
53
 
@@ -0,0 +1,9 @@
1
+ module Rounders
2
+ module Stores
3
+ class Memory < Rounders::Stores::Store
4
+ def data
5
+ @data ||= {}
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ module Rounders
2
+ module Stores
3
+ class Store
4
+ include Rounders::Plugins::Pluggable
5
+
6
+ def [](key)
7
+ data[key]
8
+ end
9
+
10
+ def []=(key, value)
11
+ data[key] = value
12
+ end
13
+
14
+ def data
15
+ raise 'Called abstract method: data'
16
+ end
17
+
18
+ class << self
19
+ def inherited(klass)
20
+ Rounders.stores[klass.symbol] = klass
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module Rounders
2
- VERSION = '0.5.2'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
data/lib/rounders.rb CHANGED
@@ -8,16 +8,21 @@ require 'mail'
8
8
  require 'dotenv'
9
9
 
10
10
  require 'rounders/logger'
11
+ require 'rounders/application'
11
12
  require 'rounders/util'
12
13
 
13
14
  module Rounders
14
15
  # Your code goes here...
15
16
  CONFIG_DIR_PATH = File.join(Dir.pwd, 'config').freeze
16
- APP_PATH = File.join(Dir.pwd, 'app').freeze
17
+ APP_PATH = File.join(Dir.pwd, Rounders::Application.app_path).freeze
17
18
 
18
19
  class << self
19
20
  attr_accessor :logger
20
21
 
22
+ def global?
23
+ !Pathname(Rounders::APP_PATH).exist?
24
+ end
25
+
21
26
  def handlers
22
27
  @_handlers ||= []
23
28
  end
@@ -30,12 +35,12 @@ module Rounders
30
35
  @_receivers ||= []
31
36
  end
32
37
 
33
- def global?
34
- !Pathname(Rounders::APP_PATH).exist?
38
+ def stores
39
+ @_stores ||= {}
35
40
  end
36
41
  end
37
42
 
38
- self.logger = Logger.get_logger
43
+ self.logger = Rounders::Application.logger
39
44
  end
40
45
 
41
46
  require 'rounders/mail'
@@ -53,7 +58,8 @@ require 'rounders/commander'
53
58
  require 'rounders/receivers/receiver'
54
59
  require 'rounders/receivers/mail'
55
60
  require 'rounders/rounder'
56
- require 'rounders/brains/base'
61
+ require 'rounders/stores/store'
62
+ require 'rounders/stores/memory'
57
63
 
58
64
  require 'rounders/generators/base'
59
65
  require 'rounders/generators/app/app_generator'
data/rounders.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency 'bundler'
23
23
  spec.add_development_dependency 'rake'
24
24
  spec.add_development_dependency 'rspec', '~> 3.0'
25
+ spec.add_development_dependency 'aruba'
25
26
  spec.add_development_dependency 'simplecov'
26
27
  spec.add_development_dependency 'coveralls'
27
28
  spec.add_development_dependency 'guard'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rounders
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - akira.takahashi
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: aruba
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: simplecov
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -241,7 +255,7 @@ files:
241
255
  - Rakefile
242
256
  - bin/rounders
243
257
  - lib/rounders.rb
244
- - lib/rounders/brains/base.rb
258
+ - lib/rounders/application.rb
245
259
  - lib/rounders/commander.rb
246
260
  - lib/rounders/commands/global_command.rb
247
261
  - lib/rounders/commands/local_command.rb
@@ -255,6 +269,7 @@ files:
255
269
  - lib/rounders/generators/app/templates/app/handlers/.gitkeep
256
270
  - lib/rounders/generators/app/templates/app/matchers/.gitkeep
257
271
  - lib/rounders/generators/app/templates/app/receivers/.gitkeep
272
+ - lib/rounders/generators/app/templates/config/application.rb
258
273
  - lib/rounders/generators/app/templates/config/initializers/mail.rb
259
274
  - lib/rounders/generators/app/templates/gitignore
260
275
  - lib/rounders/generators/app/templates/spec/handlers/.gitkeep
@@ -301,6 +316,8 @@ files:
301
316
  - lib/rounders/receivers/mail.rb
302
317
  - lib/rounders/receivers/receiver.rb
303
318
  - lib/rounders/rounder.rb
319
+ - lib/rounders/stores/memory.rb
320
+ - lib/rounders/stores/store.rb
304
321
  - lib/rounders/util.rb
305
322
  - lib/rounders/version.rb
306
323
  - rounders.gemspec
@@ -1,5 +0,0 @@
1
- module Rounders
2
- module Brains
3
- class Base; end
4
- end
5
- end