rounders 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +10 -1
  5. data/.travis.yml +9 -0
  6. data/README.ja.md +196 -0
  7. data/README.md +56 -8
  8. data/lib/rounders.rb +18 -10
  9. data/lib/rounders/commands/global_command.rb +13 -5
  10. data/lib/rounders/commands/sub_commands/generate.rb +24 -8
  11. data/lib/rounders/generators/app/app_generator.rb +46 -0
  12. data/lib/rounders/generators/app/templates/.rspec +2 -0
  13. data/lib/rounders/generators/app/templates/Gemfile +10 -0
  14. data/lib/rounders/generators/app/templates/MIT-LICENSE +20 -0
  15. data/lib/rounders/generators/app/templates/README.md.tt +21 -0
  16. data/lib/rounders/generators/app/templates/Rakefile +4 -0
  17. data/lib/rounders/generators/app/templates/app/handlers/.gitkeep +0 -0
  18. data/lib/rounders/generators/app/templates/app/matchers/.gitkeep +0 -0
  19. data/lib/rounders/generators/app/templates/app/receivers/.gitkeep +0 -0
  20. data/{templates/app → lib/rounders/generators/app/templates}/config/initializers/mail.rb +2 -2
  21. data/lib/rounders/generators/app/templates/gitignore +54 -0
  22. data/lib/rounders/generators/app/templates/spec/handlers/.gitkeep +0 -0
  23. data/lib/rounders/generators/app/templates/spec/matchers/.gitkeep +0 -0
  24. data/lib/rounders/generators/app/templates/spec/receivers/.gitkeep +0 -0
  25. data/lib/rounders/generators/app/templates/spec/spec_helper.rb.tt +105 -0
  26. data/lib/rounders/generators/app/templates/travis.yml +9 -0
  27. data/lib/rounders/generators/base.rb +69 -0
  28. data/lib/rounders/generators/handler/handler_generator.rb +16 -0
  29. data/lib/rounders/generators/handler/templates/%underscored_name%_handler.rb.tt +12 -0
  30. data/lib/rounders/generators/matcher/matcher_generator.rb +15 -0
  31. data/{templates/generators/matcher.mustache.rb → lib/rounders/generators/matcher/templates/%underscored_name%_matcher.rb.tt} +1 -1
  32. data/lib/rounders/generators/plugin/plugin_generator.rb +49 -0
  33. data/lib/rounders/generators/plugin/templates/.rspec +2 -0
  34. data/lib/rounders/generators/plugin/templates/Gemfile +4 -0
  35. data/lib/rounders/generators/plugin/templates/MIT-LICENSE +20 -0
  36. data/lib/rounders/generators/plugin/templates/README.md.tt +35 -0
  37. data/lib/rounders/generators/plugin/templates/Rakefile +4 -0
  38. data/lib/rounders/generators/plugin/templates/gitignore +54 -0
  39. data/lib/rounders/generators/plugin/templates/lib/rounders/%underscored_name%.rb.tt +6 -0
  40. data/lib/rounders/generators/plugin/templates/lib/rounders/%underscored_name%/version.rb.tt +5 -0
  41. data/lib/rounders/generators/plugin/templates/rounders-%underscored_name%.gemspec.tt +25 -0
  42. data/lib/rounders/generators/plugin/templates/spec/rounders/%underscored_name%_spec.rb.tt +7 -0
  43. data/lib/rounders/generators/plugin/templates/spec/rounders/.gitkeep +0 -0
  44. data/lib/rounders/generators/plugin/templates/spec/spec_helper.rb.tt +123 -0
  45. data/lib/rounders/generators/plugin/templates/travis.yml +9 -0
  46. data/lib/rounders/generators/receiver/receiver_generator.rb +15 -0
  47. data/lib/rounders/generators/receiver/templates/%underscored_name%_receiver.rb.tt +16 -0
  48. data/lib/rounders/handlers/handler.rb +3 -2
  49. data/lib/rounders/matchers/matcher.rb +4 -3
  50. data/lib/rounders/plugins/pluggable.rb +12 -2
  51. data/lib/rounders/receivers/mail.rb +41 -0
  52. data/lib/rounders/receivers/receiver.rb +29 -0
  53. data/lib/rounders/rounder.rb +1 -1
  54. data/lib/rounders/util.rb +20 -0
  55. data/lib/rounders/version.rb +1 -1
  56. data/rounders.gemspec +6 -5
  57. metadata +65 -33
  58. data/circle.yml +0 -36
  59. data/lib/rounders/generators/app.rb +0 -28
  60. data/lib/rounders/generators/generator.rb +0 -48
  61. data/lib/rounders/generators/handler.rb +0 -12
  62. data/lib/rounders/generators/matcher.rb +0 -9
  63. data/lib/rounders/receiver.rb +0 -67
  64. data/templates/app/Gemfile +0 -2
  65. data/templates/generators/handler.mustache.rb +0 -14
@@ -1,48 +0,0 @@
1
- require 'mustache'
2
- module Rounders
3
- module Generators
4
- class Generator < Mustache
5
- include Rounders::Plugins::Pluggable
6
- attr_reader :name
7
-
8
- class << self
9
- def inherited(klass)
10
- klass.template_path = Pathname('../../../../templates/generators').expand_path(__FILE__).to_s.freeze
11
- klass.template_name = klass.name.demodulize.downcase
12
- klass.template_extension = 'mustache.rb'
13
- end
14
- end
15
-
16
- def initialize(name)
17
- @name = name
18
- end
19
-
20
- def class_name
21
- name.classify
22
- end
23
-
24
- def generate
25
- mkpath
26
- file_path = output_path.join(file_name)
27
- file_path.open('w+') do |file|
28
- file.puts(render)
29
- end
30
- puts "create #{file_path}"
31
- end
32
-
33
- private
34
-
35
- def file_name
36
- "#{name.downcase.underscore}.rb"
37
- end
38
-
39
- def mkpath
40
- output_path.mkpath
41
- end
42
-
43
- def output_path
44
- Pathname("#{Rounders::PLUGIN_DIR_PATH}/#{self.class.directory_name}")
45
- end
46
- end
47
- end
48
- end
@@ -1,12 +0,0 @@
1
- module Rounders
2
- module Generators
3
- class Handler < Generator
4
- attr_accessor :handlers
5
-
6
- def initialize(name: nil, handlers: [])
7
- super(name)
8
- @handlers = handlers
9
- end
10
- end
11
- end
12
- end
@@ -1,9 +0,0 @@
1
- module Rounders
2
- module Generators
3
- class Matcher < Generator
4
- def initialize(name: nil)
5
- super(name)
6
- end
7
- end
8
- end
9
- end
@@ -1,67 +0,0 @@
1
- module Rounders
2
- class Receiver
3
- class Config
4
- attr_accessor :protocol
5
- attr_accessor :mail_server_settings
6
- attr_accessor :find_options
7
- end
8
- DEFALUT_FIND_OPTION = {
9
- keys: %w(NOT SEEN)
10
- }.freeze
11
- attr_reader :client, :find_options
12
-
13
- def initialize(client: nil, find_options: {})
14
- @client = client
15
- @find_options = DEFALUT_FIND_OPTION.merge(find_options)
16
- end
17
-
18
- def configure
19
- config = Config.new
20
- yield config
21
- @client = Receiver.create_client(config)
22
- end
23
-
24
- def receive
25
- @client.
26
- find(find_options).
27
- map { |message| Rounders::Mail.new(message) }
28
- end
29
-
30
- class << self
31
- def configure
32
- config = Config.new
33
- yield config
34
- @receiver = create_client(config)
35
- end
36
-
37
- def create_client(config)
38
- retriever = parser.lookup_retriever_method(config.protocol)
39
- new(
40
- client: retriever.new(config.mail_server_settings),
41
- find_options: config.find_options)
42
- end
43
-
44
- def receive
45
- receivers.
46
- map(&:receive).
47
- flatten.
48
- sort { |a, b| a.date <=> b.date }
49
- end
50
-
51
- def reset
52
- @receiver = nil
53
- @receivers = nil
54
- end
55
-
56
- private
57
-
58
- def receivers
59
- [@receiver]
60
- end
61
-
62
- def parser
63
- ::Mail::Configuration.instance
64
- end
65
- end
66
- end
67
- end
@@ -1,2 +0,0 @@
1
- source 'https://rubygems.org'
2
- gem 'rounders'
@@ -1,14 +0,0 @@
1
- module Rounders
2
- module Handlers
3
- class {{ class_name }} < Rounders::Handlers::Handler
4
- {{#handlers}}
5
- on({ body: 'example' }, :{{.}})
6
- {{/handlers}}
7
- {{#handlers}}
8
-
9
- def {{.}}(mail)
10
- end
11
- {{/handlers}}
12
- end
13
- end
14
- end