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,17 +1,33 @@
|
|
1
|
+
require 'rounders/generators/base'
|
2
|
+
require 'rounders/generators/app/app_generator'
|
3
|
+
require 'rounders/generators/handler/handler_generator'
|
4
|
+
require 'rounders/generators/matcher/matcher_generator'
|
5
|
+
require 'rounders/generators/receiver/receiver_generator'
|
6
|
+
|
1
7
|
module Rounders
|
2
8
|
module Commands
|
3
9
|
module SubCommands
|
4
10
|
class Generate < Thor
|
5
|
-
|
11
|
+
register(
|
12
|
+
Rounders::Generators::HandlerGenerator,
|
13
|
+
'handler',
|
14
|
+
'handler <name> [<handlers>...]',
|
15
|
+
'Generate new handler'
|
16
|
+
)
|
6
17
|
|
7
|
-
|
8
|
-
Rounders::Generators::
|
9
|
-
|
18
|
+
register(
|
19
|
+
Rounders::Generators::MatcherGenerator,
|
20
|
+
'matcher',
|
21
|
+
'matcher <name>',
|
22
|
+
'Generate new matcher'
|
23
|
+
)
|
10
24
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
25
|
+
register(
|
26
|
+
Rounders::Generators::ReceiverGenerator,
|
27
|
+
'receiver',
|
28
|
+
'receiver <name>',
|
29
|
+
'Generate new receiver'
|
30
|
+
)
|
15
31
|
end
|
16
32
|
end
|
17
33
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Rounders
|
2
|
+
module Generators
|
3
|
+
class AppGenerator < Base
|
4
|
+
argument :name, type: :string
|
5
|
+
argument :path, type: :string, required: false
|
6
|
+
|
7
|
+
def set_destination_root
|
8
|
+
p = path.nil? ? name : path
|
9
|
+
self.destination_root = p
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_directory
|
13
|
+
directory('app')
|
14
|
+
directory('config')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test
|
18
|
+
directory('spec')
|
19
|
+
end
|
20
|
+
|
21
|
+
def readme
|
22
|
+
template 'README.md'
|
23
|
+
end
|
24
|
+
|
25
|
+
def gemfile
|
26
|
+
template 'Gemfile'
|
27
|
+
end
|
28
|
+
|
29
|
+
def license
|
30
|
+
template 'MIT-LICENSE'
|
31
|
+
end
|
32
|
+
|
33
|
+
def gitignore
|
34
|
+
template 'gitignore', '.gitignore'
|
35
|
+
end
|
36
|
+
|
37
|
+
def travis
|
38
|
+
template 'travis.yml', '.travis.yml'
|
39
|
+
end
|
40
|
+
|
41
|
+
def rakefile
|
42
|
+
template 'Rakefile'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright <%= Date.today.year %> YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# <%= name %>
|
2
|
+
|
3
|
+
## README
|
4
|
+
|
5
|
+
* Ruby version
|
6
|
+
|
7
|
+
* System dependencies
|
8
|
+
|
9
|
+
* Configuration
|
10
|
+
|
11
|
+
* Database creation
|
12
|
+
|
13
|
+
* Database initialization
|
14
|
+
|
15
|
+
* How to run the test suite
|
16
|
+
|
17
|
+
* Services (job queues, cache servers, search engines, etc.)
|
18
|
+
|
19
|
+
* Deployment instructions
|
20
|
+
|
21
|
+
* ...
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,8 +1,8 @@
|
|
1
|
-
Rounders::
|
1
|
+
Rounders::Receivers::Mail.configure do |config|
|
2
2
|
# please show more option
|
3
3
|
#
|
4
4
|
config.protocol = :imap
|
5
|
-
config.
|
5
|
+
config.mail_server_setting = {
|
6
6
|
address: 'imap.gmail.com',
|
7
7
|
port: 993,
|
8
8
|
user_name: ENV['GMAIL_USER_NAME'],
|
@@ -0,0 +1,54 @@
|
|
1
|
+
### https://raw.github.com/github/gitignore/9f6724149b9a0a861b402683f6c50c5f085d130b/ruby.gitignore
|
2
|
+
|
3
|
+
*.gem
|
4
|
+
*.rbc
|
5
|
+
/.config
|
6
|
+
/coverage/
|
7
|
+
/InstalledFiles
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/spec/examples.txt
|
11
|
+
/test/tmp/
|
12
|
+
/test/version_tmp/
|
13
|
+
/tmp/
|
14
|
+
|
15
|
+
# Used by dotenv library to load environment variables.
|
16
|
+
# .env
|
17
|
+
|
18
|
+
## Specific to RubyMotion:
|
19
|
+
.dat*
|
20
|
+
.repl_history
|
21
|
+
build/
|
22
|
+
*.bridgesupport
|
23
|
+
build-iPhoneOS/
|
24
|
+
build-iPhoneSimulator/
|
25
|
+
|
26
|
+
## Specific to RubyMotion (use of CocoaPods):
|
27
|
+
#
|
28
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
29
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
30
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
31
|
+
#
|
32
|
+
# vendor/Pods/
|
33
|
+
|
34
|
+
## Documentation cache and generated files:
|
35
|
+
/.yardoc/
|
36
|
+
/_yardoc/
|
37
|
+
/doc/
|
38
|
+
/rdoc/
|
39
|
+
|
40
|
+
## Environment normalization:
|
41
|
+
/.bundle/
|
42
|
+
/vendor/bundle
|
43
|
+
/lib/bundler/man/
|
44
|
+
|
45
|
+
# for a library or gem, you might want to ignore these files since the code is
|
46
|
+
# intended to run in multiple environments; otherwise, check them in:
|
47
|
+
# Gemfile.lock
|
48
|
+
# .ruby-version
|
49
|
+
# .ruby-gemset
|
50
|
+
|
51
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
52
|
+
.rvmrc
|
53
|
+
|
54
|
+
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,105 @@
|
|
1
|
+
$LOAD_PATH.unshift 'app'
|
2
|
+
|
3
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
4
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
5
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
6
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
7
|
+
# files.
|
8
|
+
#
|
9
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
10
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
11
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
12
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
13
|
+
# a separate helper file that requires the additional dependencies and performs
|
14
|
+
# the additional setup, and require it from the spec files that actually need
|
15
|
+
# it.
|
16
|
+
#
|
17
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
18
|
+
# users commonly want.
|
19
|
+
#
|
20
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
21
|
+
RSpec.configure do |config|
|
22
|
+
# rspec-expectations config goes here. You can use an alternate
|
23
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
24
|
+
# assertions if you prefer.
|
25
|
+
config.expect_with :rspec do |expectations|
|
26
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
27
|
+
# and `failure_message` of custom matchers include text for helper methods
|
28
|
+
# defined using `chain`, e.g.:
|
29
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
30
|
+
# # => "be bigger than 2 and smaller than 4"
|
31
|
+
# ...rather than:
|
32
|
+
# # => "be bigger than 2"
|
33
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
34
|
+
end
|
35
|
+
|
36
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
37
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
38
|
+
config.mock_with :rspec do |mocks|
|
39
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
40
|
+
# a real object. This is generally recommended, and will default to
|
41
|
+
# `true` in RSpec 4.
|
42
|
+
mocks.verify_partial_doubles = true
|
43
|
+
end
|
44
|
+
|
45
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
46
|
+
# have no way to turn it off -- the option exists only for backwards
|
47
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
48
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
49
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
50
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
51
|
+
|
52
|
+
# The settings below are suggested to provide a good initial experience
|
53
|
+
# with RSpec, but feel free to customize to your heart's content.
|
54
|
+
=begin
|
55
|
+
# This allows you to limit a spec run to individual examples or groups
|
56
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
57
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
58
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
59
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
60
|
+
config.filter_run_when_matching :focus
|
61
|
+
|
62
|
+
# Allows RSpec to persist some state between runs in order to support
|
63
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
64
|
+
# you configure your source control system to ignore this file.
|
65
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
66
|
+
|
67
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
68
|
+
# recommended. For more details, see:
|
69
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
70
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
71
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
72
|
+
config.disable_monkey_patching!
|
73
|
+
|
74
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
75
|
+
# be too noisy due to issues in dependencies.
|
76
|
+
config.warnings = true
|
77
|
+
|
78
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
79
|
+
# file, and it's useful to allow more verbose output when running an
|
80
|
+
# individual spec file.
|
81
|
+
if config.files_to_run.one?
|
82
|
+
# Use the documentation formatter for detailed output,
|
83
|
+
# unless a formatter has already been configured
|
84
|
+
# (e.g. via a command-line flag).
|
85
|
+
config.default_formatter = 'doc'
|
86
|
+
end
|
87
|
+
|
88
|
+
# Print the 10 slowest examples and example groups at the
|
89
|
+
# end of the spec run, to help surface which specs are running
|
90
|
+
# particularly slow.
|
91
|
+
config.profile_examples = 10
|
92
|
+
|
93
|
+
# Run specs in random order to surface order dependencies. If you find an
|
94
|
+
# order dependency and want to debug it, you can fix the order by providing
|
95
|
+
# the seed, which is printed after each run.
|
96
|
+
# --seed 1234
|
97
|
+
config.order = :random
|
98
|
+
|
99
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
100
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
101
|
+
# test failures related to randomization by passing the same `--seed` value
|
102
|
+
# as the one that triggered the failure.
|
103
|
+
Kernel.srand config.seed
|
104
|
+
=end
|
105
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# rubocop:disable Style/CyclomaticComplexity, Style/AbcSize:
|
2
|
+
|
3
|
+
module Rounders
|
4
|
+
module Generators
|
5
|
+
class Base < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
include Rounders::Plugins::Pluggable
|
8
|
+
argument :name, type: :string
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def class_name
|
13
|
+
Util.infrect(name).classify
|
14
|
+
end
|
15
|
+
|
16
|
+
def feature_path
|
17
|
+
Pathname("#{Rounders::APP_PATH}/#{self.class.directory_name}")
|
18
|
+
end
|
19
|
+
|
20
|
+
def empty_directory_with_keep_file(destination, config = {})
|
21
|
+
empty_directory(destination, config)
|
22
|
+
keep_file(destination)
|
23
|
+
end
|
24
|
+
|
25
|
+
def keep_file(destination)
|
26
|
+
create_file("#{destination}/.keep")
|
27
|
+
end
|
28
|
+
|
29
|
+
def underscored_name
|
30
|
+
@underscored_name ||= Util.infrect(name).underscore
|
31
|
+
end
|
32
|
+
|
33
|
+
def namespaced_name
|
34
|
+
@namespaced_name ||= Util.infrect(name.tr('-', '/')).classify
|
35
|
+
end
|
36
|
+
|
37
|
+
class << self
|
38
|
+
def inherited(klass)
|
39
|
+
klass.define_singleton_method(:source_root) do
|
40
|
+
default_source_root
|
41
|
+
end
|
42
|
+
|
43
|
+
klass.define_singleton_method(:generator_name) do
|
44
|
+
@generator_name ||= feature_name
|
45
|
+
end
|
46
|
+
|
47
|
+
klass.define_singleton_method(:default_source_root) do
|
48
|
+
return unless base_name && generator_name
|
49
|
+
return unless default_generator_root
|
50
|
+
path = Pathname.new(default_generator_root).join('templates')
|
51
|
+
path if path.exist?
|
52
|
+
end
|
53
|
+
|
54
|
+
klass.define_singleton_method(:base_name) do
|
55
|
+
@base_name ||= begin
|
56
|
+
base = name.to_s.split('::').first
|
57
|
+
Rounders::Util.infrect(base).underscore unless base.nil?
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
klass.define_singleton_method(:default_generator_root) do
|
62
|
+
path = Pathname(__FILE__).dirname.join(generator_name).expand_path
|
63
|
+
path if path.exist?
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Rounders
|
2
|
+
module Generators
|
3
|
+
class HandlerGenerator < Base
|
4
|
+
desc 'handler <name> [<handlers>...]'
|
5
|
+
argument :handlers, type: :array
|
6
|
+
|
7
|
+
def set_destination_root
|
8
|
+
self.destination_root = feature_path
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_handler
|
12
|
+
template '%underscored_name%_handler.rb.tt'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
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| %>
|
7
|
+
|
8
|
+
def <%= handler %>(mail)
|
9
|
+
end<% end %>
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|