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
@@ -0,0 +1,15 @@
1
+ module Rounders
2
+ module Generators
3
+ class MatcherGenerator < Base
4
+ desc 'matcher <name>'
5
+
6
+ def set_destination_root
7
+ self.destination_root = feature_path
8
+ end
9
+
10
+ def create_matcher
11
+ template '%underscored_name%_matcher.rb.tt'
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,6 +1,6 @@
1
1
  module Rounders
2
2
  module Matchers
3
- class {{ class_name }} < Rounders::Matchers::Matcher
3
+ class <%= class_name %> < Rounders::Matchers::Matcher
4
4
  def match(message)
5
5
  end
6
6
  end
@@ -0,0 +1,49 @@
1
+ module Rounders
2
+ module Generators
3
+ class PluginGenerator < Base
4
+ argument :name, type: :string
5
+ argument :path, type: :string, required: false
6
+
7
+ def set_destination_root
8
+ self.destination_root = "rounders-#{underscored_name}"
9
+ end
10
+
11
+ def create_directory
12
+ directory('lib')
13
+ directory('spec')
14
+ end
15
+
16
+ def readme
17
+ template 'README.md'
18
+ end
19
+
20
+ def gemfile
21
+ template 'Gemfile'
22
+ end
23
+
24
+ def license
25
+ template 'MIT-LICENSE'
26
+ end
27
+
28
+ def gemspec
29
+ template 'rounders-%underscored_name%.gemspec.tt'
30
+ end
31
+
32
+ def gitignore
33
+ template 'gitignore', '.gitignore'
34
+ end
35
+
36
+ def travis
37
+ template 'travis.yml', '.travis.yml'
38
+ end
39
+
40
+ def rakefile
41
+ template 'Rakefile'
42
+ end
43
+ # def lib
44
+ # template "lib/%namespaced_name%.rb.tt"
45
+ # template "lib/%namespaced_name%/version.rb.tt"
46
+ #
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rounders.gemspec
4
+ gemspec
@@ -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,35 @@
1
+ # Rounders::<%= namespaced_name %>
2
+
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'rounders-<%= underscored_name %>'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ ## Usage
17
+
18
+ TODO: Write usage instructions here
19
+
20
+ ## Development
21
+
22
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
23
+
24
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/<%= underscored_name %>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
29
+
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
34
+
35
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,4 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ RSpec::Core::RakeTask.new(:spec)
4
+ task default: :spec
@@ -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
+
@@ -0,0 +1,6 @@
1
+ module Rounders
2
+ module <%= namespaced_name %>
3
+ end
4
+ end
5
+
6
+ require 'rounders/<%= underscored_name %>/version'
@@ -0,0 +1,5 @@
1
+ module Rounders
2
+ module <%= namespaced_name %>
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require 'rounders/<%= underscored_name %>/version'
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "rounders-<%= underscored_name %>"
9
+ s.version = Rounders::<%= class_name %>::VERSION
10
+ s.authors = ["TODO: Your name"]
11
+ s.email = ["TODO: Your email"]
12
+ s.homepage = "TODO"
13
+ s.summary = "TODO: Summary of Rounders::<%= class_name %>."
14
+ s.description = "TODO: Description of Rounders::<%= class_name %>."
15
+ s.license = "MIT"
16
+ s.files = Dir["{app,config,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
17
+ s.file = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ s.test_files = Dir["spec/**/*"]
19
+ s.add_dependency 'rounders', '~> <%= Rounders::VERSION %>'
20
+ s.add_development_dependency 'bundler'
21
+ s.add_development_dependency 'rake'
22
+ s.add_development_dependency 'rspec', '~> 3.0'
23
+ s.add_development_dependency 'simplecov'
24
+ s.add_development_dependency 'coveralls'
25
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Rounders::<%= namespaced_name %> do
4
+ it 'has a version number' do
5
+ expect(Rounders::<%= namespaced_name %>::VERSION).not_to be nil
6
+ end
7
+ end
@@ -0,0 +1,123 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ if ENV['CI']
3
+ require 'simplecov'
4
+ require 'coveralls'
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
6
+ [
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
10
+ )
11
+ SimpleCov.start do
12
+ add_group 'lib', 'lib'
13
+ add_filter '/vendor/'
14
+ end
15
+ end
16
+
17
+ # This file was generated by the `rspec --init` command. Conventionally, all
18
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
19
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
20
+ # this file to always be loaded, without a need to explicitly require it in any
21
+ # files.
22
+ #
23
+ # Given that it is always loaded, you are encouraged to keep this file as
24
+ # light-weight as possible. Requiring heavyweight dependencies from this file
25
+ # will add to the boot time of your test suite on EVERY test run, even for an
26
+ # individual file that may not need all of that loaded. Instead, consider making
27
+ # a separate helper file that requires the additional dependencies and performs
28
+ # the additional setup, and require it from the spec files that actually need
29
+ # it.
30
+ #
31
+ # The `.rspec` file also contains a few flags that are not defaults but that
32
+ # users commonly want.
33
+ #
34
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
35
+ RSpec.configure do |config|
36
+ # rspec-expectations config goes here. You can use an alternate
37
+ # assertion/expectation library such as wrong or the stdlib/minitest
38
+ # assertions if you prefer.
39
+ config.expect_with :rspec do |expectations|
40
+ # This option will default to `true` in RSpec 4. It makes the `description`
41
+ # and `failure_message` of custom matchers include text for helper methods
42
+ # defined using `chain`, e.g.:
43
+ # be_bigger_than(2).and_smaller_than(4).description
44
+ # # => "be bigger than 2 and smaller than 4"
45
+ # ...rather than:
46
+ # # => "be bigger than 2"
47
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
48
+ end
49
+
50
+ # rspec-mocks config goes here. You can use an alternate test double
51
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
52
+ config.mock_with :rspec do |mocks|
53
+ # Prevents you from mocking or stubbing a method that does not exist on
54
+ # a real object. This is generally recommended, and will default to
55
+ # `true` in RSpec 4.
56
+ mocks.verify_partial_doubles = true
57
+ end
58
+
59
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
60
+ # have no way to turn it off -- the option exists only for backwards
61
+ # compatibility in RSpec 3). It causes shared context metadata to be
62
+ # inherited by the metadata hash of host groups and examples, rather than
63
+ # triggering implicit auto-inclusion in groups with matching metadata.
64
+ config.shared_context_metadata_behavior = :apply_to_host_groups
65
+
66
+ # The settings below are suggested to provide a good initial experience
67
+ # with RSpec, but feel free to customize to your heart's content.
68
+ =begin
69
+ # This allows you to limit a spec run to individual examples or groups
70
+ # you care about by tagging them with `:focus` metadata. When nothing
71
+ # is tagged with `:focus`, all examples get run. RSpec also provides
72
+ # aliases for `it`, `describe`, and `context` that include `:focus`
73
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
74
+ config.filter_run_when_matching :focus
75
+
76
+ # Allows RSpec to persist some state between runs in order to support
77
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
78
+ # you configure your source control system to ignore this file.
79
+ config.example_status_persistence_file_path = "spec/examples.txt"
80
+
81
+ # Limits the available syntax to the non-monkey patched syntax that is
82
+ # recommended. For more details, see:
83
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
84
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
85
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
86
+ config.disable_monkey_patching!
87
+
88
+ # This setting enables warnings. It's recommended, but in some cases may
89
+ # be too noisy due to issues in dependencies.
90
+ config.warnings = true
91
+
92
+ # Many RSpec users commonly either run the entire suite or an individual
93
+ # file, and it's useful to allow more verbose output when running an
94
+ # individual spec file.
95
+ if config.files_to_run.one?
96
+ # Use the documentation formatter for detailed output,
97
+ # unless a formatter has already been configured
98
+ # (e.g. via a command-line flag).
99
+ config.default_formatter = 'doc'
100
+ end
101
+
102
+ # Print the 10 slowest examples and example groups at the
103
+ # end of the spec run, to help surface which specs are running
104
+ # particularly slow.
105
+ config.profile_examples = 10
106
+
107
+ # Run specs in random order to surface order dependencies. If you find an
108
+ # order dependency and want to debug it, you can fix the order by providing
109
+ # the seed, which is printed after each run.
110
+ # --seed 1234
111
+ config.order = :random
112
+
113
+ # Seed global randomization in this process using the `--seed` CLI option.
114
+ # Setting this allows you to use `--seed` to deterministically reproduce
115
+ # test failures related to randomization by passing the same `--seed` value
116
+ # as the one that triggered the failure.
117
+ Kernel.srand config.seed
118
+ =end
119
+ end
120
+
121
+
122
+ require 'rounders'
123
+ require 'rounders/<%= underscored_name %>'
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.3
4
+ - 2.4.0
5
+ before_install:
6
+ - gem install bundler -v 1.13.7
7
+ - gem update --system
8
+ env:
9
+ - CI=true
@@ -0,0 +1,15 @@
1
+ module Rounders
2
+ module Generators
3
+ class ReceiverGenerator < Base
4
+ desc 'receiver <name>'
5
+
6
+ def set_destination_root
7
+ self.destination_root = feature_path
8
+ end
9
+
10
+ def create_receiver
11
+ template '%underscored_name%_receiver.rb.tt'
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ module Rounders
2
+ module Receivers
3
+ class <%= class_name %> < Rounders::Receivers::Receiver
4
+ def initialize()
5
+ end
6
+
7
+ def receive
8
+ end
9
+
10
+ class << self
11
+ def receive
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -2,7 +2,8 @@ module Rounders
2
2
  module Handlers
3
3
  class Handler
4
4
  include Rounders::Plugins::Pluggable
5
- attr_reader :matches, :rouder
5
+ attr_reader :matches, :rounder
6
+
6
7
  class << self
7
8
  class Dispatcher
8
9
  attr_reader :matcher, :method_name
@@ -21,7 +22,7 @@ module Rounders
21
22
  mails.map do |mail|
22
23
  dispatchers.each do |dispatcher|
23
24
  matches = dispatcher.matcher.match(mail)
24
- next if matches.blank?
25
+ next if matches.nil?
25
26
  new(rounder, matches).public_send(dispatcher.method_name, mail)
26
27
  end
27
28
  end