boppers 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +14 -2
  3. data/README.md +282 -10
  4. data/Rakefile +1 -0
  5. data/boppers.gemspec +9 -1
  6. data/exe/boppers +1 -0
  7. data/gems.locked +98 -1
  8. data/images/boppers.png +0 -0
  9. data/images/boppers@2x.png +0 -0
  10. data/images/logo.png +0 -0
  11. data/images/logo.svg +10 -0
  12. data/lib/boppers.rb +35 -0
  13. data/lib/boppers/cli.rb +55 -0
  14. data/lib/boppers/configuration.rb +15 -0
  15. data/lib/boppers/generator/app.rb +28 -0
  16. data/lib/boppers/generator/app/Procfile +1 -0
  17. data/lib/boppers/generator/app/app.json +8 -0
  18. data/lib/boppers/generator/app/config/boppers.rb +83 -0
  19. data/lib/boppers/generator/app/gems.rb +7 -0
  20. data/lib/boppers/generator/plugin.rb +64 -0
  21. data/lib/boppers/generator/plugin/.gitignore +8 -0
  22. data/lib/boppers/generator/plugin/.rubocop.yml +116 -0
  23. data/lib/boppers/generator/plugin/.travis.yml +16 -0
  24. data/lib/boppers/generator/plugin/CODE_OF_CONDUCT.md +74 -0
  25. data/lib/boppers/generator/plugin/LICENSE.txt +21 -0
  26. data/lib/boppers/generator/plugin/README.erb +45 -0
  27. data/lib/boppers/generator/plugin/Rakefile +12 -0
  28. data/lib/boppers/generator/plugin/gems.rb +2 -0
  29. data/lib/boppers/generator/plugin/gemspec.erb +29 -0
  30. data/lib/boppers/generator/plugin/lib/entry.erb +4 -0
  31. data/lib/boppers/generator/plugin/lib/main.erb +10 -0
  32. data/lib/boppers/generator/plugin/lib/version.erb +7 -0
  33. data/lib/boppers/generator/plugin/test/test_file.erb +9 -0
  34. data/lib/boppers/generator/plugin/test/test_helper.erb +11 -0
  35. data/lib/boppers/http_client.rb +9 -0
  36. data/lib/boppers/notifier/hipchat.rb +26 -0
  37. data/lib/boppers/notifier/pushover.rb +27 -0
  38. data/lib/boppers/notifier/sendgrid.rb +40 -0
  39. data/lib/boppers/notifier/slack.rb +35 -0
  40. data/lib/boppers/notifier/stdout.rb +21 -0
  41. data/lib/boppers/notifier/telegram.rb +26 -0
  42. data/lib/boppers/notifier/twitter.rb +34 -0
  43. data/lib/boppers/runner.rb +37 -0
  44. data/lib/boppers/testing.rb +6 -0
  45. data/lib/boppers/testing/bopper_linter.rb +19 -0
  46. data/lib/boppers/testing/notifier_linter.rb +33 -0
  47. data/lib/boppers/utils.rb +11 -0
  48. data/lib/boppers/version.rb +1 -1
  49. data/setup/telegram.rb +20 -0
  50. metadata +142 -5
  51. data/Gemfile.lock +0 -24
@@ -0,0 +1,16 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.4.2
6
+ before_install:
7
+ - gem install bundler
8
+ - bundle install
9
+ before_script:
10
+ - "curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter"
11
+ - chmod +x ./cc-test-reporter
12
+ - "./cc-test-reporter before-build"
13
+ after_script:
14
+ - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
15
+ notifications:
16
+ email: false
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at fnando.vieira@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Nando Vieira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ # Boppers::<%= plugin_namespace %>
2
+
3
+ [![Travis-CI](https://travis-ci.org/[USERNAME]/<%= plugin_name %>.png)](https://travis-ci.org/[USERNAME]/<%= plugin_name %>)
4
+ [![GPA](https://codeclimate.com/github/[USERNAME]/<%= plugin_name %>/badges/gpa.svg)](https://codeclimate.com/github/[USERNAME]/<%= plugin_name %>)
5
+ [![Test Coverage](https://codeclimate.com/github/[USERNAME]/<%= plugin_name %>/badges/coverage.svg)](https://codeclimate.com/github/[USERNAME]/<%= plugin_name %>)
6
+ [![Gem](https://img.shields.io/gem/v/<%= plugin_name %>.svg)](https://rubygems.org/gems/<%= plugin_name %>)
7
+ [![Gem](https://img.shields.io/gem/dt/<%= plugin_name %>.svg)](https://rubygems.org/gems/<%= plugin_name %>)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem "<%= plugin_name %>"
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install <%= plugin_name %>
24
+
25
+ ## Usage
26
+
27
+ TODO: Write usage instructions here
28
+
29
+ ## Development
30
+
31
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
+
33
+ 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).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/<%= plugin_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.
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
42
+
43
+ ## Code of Conduct
44
+
45
+ Everyone interacting in the Boppers project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/<%= plugin_name %>/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "./lib/boppers/<%= name %>/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "<%= plugin_name %>"
7
+ spec.version = Boppers::<%= plugin_namespace %>::VERSION
8
+ spec.authors = ["Author"]
9
+ spec.email = ["author@example.com"]
10
+
11
+ spec.summary = "Some description"
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://rubygems.org/gems/<%= plugin_name %>"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "boppers"
24
+
25
+ spec.add_development_dependency "bundler"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "minitest-utils"
28
+ spec.add_development_dependency "simplecov"
29
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "boppers"
4
+ require "boppers/<%= name %>"
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "boppers/<%= name %>/version"
4
+
5
+ module Boppers
6
+ class <%= plugin_namespace %>
7
+ def call
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boppers
4
+ class <%= plugin_namespace %>
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class Boppers<%= plugin_namespace %>Test < Minitest::Test
6
+ test "check version" do
7
+ assert_equal "0.1.0", Boppers::<%= plugin_namespace %>::VERSION
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "simplecov"
4
+ SimpleCov.start
5
+
6
+ require "bundler/setup"
7
+ require "<%= plugin_name %>"
8
+ require "boppers/testing"
9
+
10
+ require "minitest/utils"
11
+ require "minitest/autorun"
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boppers
4
+ HttpClient = Aitch::Namespace.new
5
+
6
+ HttpClient.configure do |config|
7
+ config.user_agent = "Boppers/#{VERSION} (https://github.com/fnando/boppers)"
8
+ end
9
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boppers
4
+ module Notifier
5
+ class Hipchat
6
+ attr_reader :api_token, :room
7
+
8
+ def initialize(api_token:, room:, subscribe: nil)
9
+ @api_token = api_token
10
+ @room = room
11
+ @subscribe = subscribe
12
+ end
13
+
14
+ def call(title, message, options)
15
+ endpoint = "https://api.hipchat.com/v2/room/#{room}/notification"
16
+ HttpClient.post(endpoint,
17
+ message_format: "text",
18
+ color: options.fetch(:color, "gray"),
19
+ notify: true,
20
+ message: message,
21
+ title: title,
22
+ auth_token: api_token)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boppers
4
+ module Notifier
5
+ class Pushover
6
+ ENDPOINT = "https://api.pushover.net/1/messages.json"
7
+
8
+ attr_reader :app_token, :user_token, :subscribe
9
+
10
+ def initialize(app_token:, user_token:, subscribe: nil)
11
+ @app_token = app_token
12
+ @user_token = user_token
13
+ @subscribe = subscribe
14
+ end
15
+
16
+ def call(title, message, _options)
17
+ HttpClient.post(
18
+ ENDPOINT,
19
+ token: app_token,
20
+ user: user_token,
21
+ title: title,
22
+ message: message
23
+ )
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boppers
4
+ module Notifier
5
+ class Sendgrid
6
+ attr_reader :username, :password, :domain, :email
7
+
8
+ def initialize(username:, password:, domain:, email:, subscribe: nil)
9
+ require "mail"
10
+
11
+ @username = username
12
+ @password = password
13
+ @domain = domain
14
+ @email = email
15
+ @subscribe = subscribe
16
+ end
17
+
18
+ def call(title, message, _options)
19
+ mail = Mail.new
20
+ mail.delivery_method :smtp,
21
+ address: "smtp.sendgrid.net",
22
+ port: 587,
23
+ user_name: username,
24
+ password: password,
25
+ domain: domain,
26
+ authentication: :plain,
27
+ enable_starttls_auto: true
28
+
29
+ mail.subject(title)
30
+ mail.to(email)
31
+ mail.from("Boppers <noreply@boppers>")
32
+ mail.part("text/plain") do |part|
33
+ part.body = message
34
+ end
35
+
36
+ mail.deliver
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boppers
4
+ module Notifier
5
+ class Slack
6
+ attr_reader :api_token, :channel, :subscribe
7
+
8
+ def initialize(api_token:, channel:, subscribe: nil)
9
+ @api_token = api_token
10
+ @channel = channel
11
+ @subscribe = subscribe
12
+ end
13
+
14
+ def call(subject, message, options)
15
+ params = {
16
+ token: api_token,
17
+ text: "",
18
+ channel: channel,
19
+ attachments: JSON.dump(
20
+ [
21
+ {
22
+ fallback: message,
23
+ title: subject,
24
+ text: message,
25
+ color: options[:color]
26
+ }
27
+ ]
28
+ )
29
+ }
30
+
31
+ HttpClient.post("https://slack.com/api/chat.postMessage", params)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boppers
4
+ module Notifier
5
+ class Stdout
6
+ attr_reader :subscribe
7
+
8
+ def initialize(subscribe: nil)
9
+ @subscribe = subscribe
10
+ end
11
+
12
+ def call(title, message, *)
13
+ puts [
14
+ "## #{title}",
15
+ message.gsub(/^/m, " "),
16
+ "\n"
17
+ ].join("\n")
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boppers
4
+ module Notifier
5
+ class Telegram
6
+ attr_reader :api_token, :channel_id, :subscribe
7
+
8
+ def initialize(api_token:, channel_id:, subscribe: nil)
9
+ require "telegram_bot"
10
+
11
+ @api_token = api_token
12
+ @channel_id = channel_id
13
+ @subscribe = subscribe
14
+ end
15
+
16
+ def call(_subject, message, _options)
17
+ bot = TelegramBot.new(token: api_token)
18
+
19
+ notification = TelegramBot::OutMessage.new
20
+ notification.chat = TelegramBot::Channel.new(id: channel_id)
21
+ notification.text = message
22
+ notification.send_with(bot)
23
+ end
24
+ end
25
+ end
26
+ end