rounders 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/.rspec +2 -0
- data/.rubocop.yml +10 -1
- data/.travis.yml +9 -0
- data/README.ja.md +196 -0
- data/README.md +56 -8
- data/lib/rounders.rb +18 -10
- data/lib/rounders/commands/global_command.rb +13 -5
- data/lib/rounders/commands/sub_commands/generate.rb +24 -8
- data/lib/rounders/generators/app/app_generator.rb +46 -0
- data/lib/rounders/generators/app/templates/.rspec +2 -0
- data/lib/rounders/generators/app/templates/Gemfile +10 -0
- data/lib/rounders/generators/app/templates/MIT-LICENSE +20 -0
- data/lib/rounders/generators/app/templates/README.md.tt +21 -0
- data/lib/rounders/generators/app/templates/Rakefile +4 -0
- data/lib/rounders/generators/app/templates/app/handlers/.gitkeep +0 -0
- data/lib/rounders/generators/app/templates/app/matchers/.gitkeep +0 -0
- data/lib/rounders/generators/app/templates/app/receivers/.gitkeep +0 -0
- data/{templates/app → lib/rounders/generators/app/templates}/config/initializers/mail.rb +2 -2
- data/lib/rounders/generators/app/templates/gitignore +54 -0
- data/lib/rounders/generators/app/templates/spec/handlers/.gitkeep +0 -0
- data/lib/rounders/generators/app/templates/spec/matchers/.gitkeep +0 -0
- data/lib/rounders/generators/app/templates/spec/receivers/.gitkeep +0 -0
- data/lib/rounders/generators/app/templates/spec/spec_helper.rb.tt +105 -0
- data/lib/rounders/generators/app/templates/travis.yml +9 -0
- data/lib/rounders/generators/base.rb +69 -0
- data/lib/rounders/generators/handler/handler_generator.rb +16 -0
- data/lib/rounders/generators/handler/templates/%underscored_name%_handler.rb.tt +12 -0
- data/lib/rounders/generators/matcher/matcher_generator.rb +15 -0
- data/{templates/generators/matcher.mustache.rb → lib/rounders/generators/matcher/templates/%underscored_name%_matcher.rb.tt} +1 -1
- data/lib/rounders/generators/plugin/plugin_generator.rb +49 -0
- data/lib/rounders/generators/plugin/templates/.rspec +2 -0
- data/lib/rounders/generators/plugin/templates/Gemfile +4 -0
- data/lib/rounders/generators/plugin/templates/MIT-LICENSE +20 -0
- data/lib/rounders/generators/plugin/templates/README.md.tt +35 -0
- data/lib/rounders/generators/plugin/templates/Rakefile +4 -0
- data/lib/rounders/generators/plugin/templates/gitignore +54 -0
- data/lib/rounders/generators/plugin/templates/lib/rounders/%underscored_name%.rb.tt +6 -0
- data/lib/rounders/generators/plugin/templates/lib/rounders/%underscored_name%/version.rb.tt +5 -0
- data/lib/rounders/generators/plugin/templates/rounders-%underscored_name%.gemspec.tt +25 -0
- data/lib/rounders/generators/plugin/templates/spec/rounders/%underscored_name%_spec.rb.tt +7 -0
- data/lib/rounders/generators/plugin/templates/spec/rounders/.gitkeep +0 -0
- data/lib/rounders/generators/plugin/templates/spec/spec_helper.rb.tt +123 -0
- data/lib/rounders/generators/plugin/templates/travis.yml +9 -0
- data/lib/rounders/generators/receiver/receiver_generator.rb +15 -0
- data/lib/rounders/generators/receiver/templates/%underscored_name%_receiver.rb.tt +16 -0
- data/lib/rounders/handlers/handler.rb +3 -2
- data/lib/rounders/matchers/matcher.rb +4 -3
- data/lib/rounders/plugins/pluggable.rb +12 -2
- data/lib/rounders/receivers/mail.rb +41 -0
- data/lib/rounders/receivers/receiver.rb +29 -0
- data/lib/rounders/rounder.rb +1 -1
- data/lib/rounders/util.rb +20 -0
- data/lib/rounders/version.rb +1 -1
- data/rounders.gemspec +6 -5
- metadata +65 -33
- data/circle.yml +0 -36
- data/lib/rounders/generators/app.rb +0 -28
- data/lib/rounders/generators/generator.rb +0 -48
- data/lib/rounders/generators/handler.rb +0 -12
- data/lib/rounders/generators/matcher.rb +0 -9
- data/lib/rounders/receiver.rb +0 -67
- data/templates/app/Gemfile +0 -2
- 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
|
data/lib/rounders/receiver.rb
DELETED
@@ -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
|
data/templates/app/Gemfile
DELETED