lolcommits-discord 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ad67943c486e6f184dd046d022fa2a969f545a0bacb561f42cc0822414feb0e5
4
+ data.tar.gz: 28a1ea11155dc3d81662ea0a08d2d664b53ae548fd8c4bde9eb9bb9ee3d7aab1
5
+ SHA512:
6
+ metadata.gz: e409f7ec96fe309f3ccf70041041f0165f1977b52f66f80dcc37add098ea7b3aa3595161946d93c725cca1a17066000017904293dc53d98b4def54b77b80d361
7
+ data.tar.gz: 4b85569926caac802c492184b0394557be54efefa7c9d064fd66a0c3541674a1436858beb6c1950bd4bbbe6ec904e5dffc991476570d7ef2b7ff207a3ac0035c
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # ChangeLog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog][KeepAChangelog] and this
6
+ project adheres to [Semantic Versioning][Semver].
7
+
8
+
9
+ ## [Unreleased]
10
+
11
+ ## [0.0.1] - 2021-07-29
12
+ ### Added
13
+ - Super basic posting to Discord webhook (plugin based on lolcommits-slack)
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Lolcommits Discord
2
+
3
+ [![Gem](https://img.shields.io/gem/v/lolcommits-discord.svg?style=flat)](http://rubygems.org/gems/lolcommits-discord)
4
+
5
+ [lolcommits](https://lolcommits.github.io/) takes a snapshot with your
6
+ webcam every time you git commit code, and archives a lolcat style image
7
+ with it. Git blame has never been so much fun!
8
+
9
+ This plugin automatically posts your lolcommits to a
10
+ [Discord](https://discord.com) channel.
11
+
12
+ The Discord message will contain the git commit message and repo name. The
13
+ SHA is used as the uploaded file name. Posting will be retried (once)
14
+ should any error occur.
15
+
16
+ ## Requirements
17
+
18
+ * Ruby >= 2.3
19
+ * A webcam
20
+ * [ImageMagick](http://www.imagemagick.org)
21
+ * [ffmpeg](https://www.ffmpeg.org) (optional) for animated gif capturing
22
+
23
+ ## Installation
24
+
25
+ Follow the [install
26
+ guide](https://github.com/lolcommits/lolcommits#installation) for
27
+ lolcommits first. Then run the following:
28
+
29
+ $ gem install lolcommits-discord
30
+
31
+ ## Configuration
32
+
33
+ Next configure and enable with:
34
+
35
+ $ lolcommits --config -p discord
36
+ # set enabled to `true`
37
+ # enter your Discord webhook URL
38
+
39
+ That's it! Every lolcommit will now be posted to the Discord channel.
40
+ To disable simply reconfigure with `enabled: false`.
41
+
42
+ ## License
43
+
44
+ The gem is available as open source under the terms of
45
+ [LGPL-3](https://opensource.org/licenses/LGPL-3.0).
46
+
47
+ This plugin was inspired by (read: mostly copied from) [lolcommits-slack](http://github.com/lolcommits/lolcommits-slack).
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lolcommits/plugin/discord"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ # install deps
7
+ bundle install
8
+
9
+ # generate docs
10
+ bundle exec rake rdoc
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lolcommits/discord/version'
4
+ require 'lolcommits/plugin/discord'
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lolcommits
4
+ module Discord
5
+ VERSION = "0.0.1".freeze
6
+ end
7
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lolcommits/plugin/base'
4
+ require 'discordrb/webhooks'
5
+
6
+ module Lolcommits
7
+ module Plugin
8
+ class Discord < Base
9
+
10
+ # Number of times to retry if RestClient.post fails
11
+ RETRY_COUNT = 1
12
+
13
+ ##
14
+ # Capture ready hook, runs after lolcommits captures a snapshot.
15
+ #
16
+ def run_capture_ready
17
+ retries = RETRY_COUNT
18
+ begin
19
+ print "Posting to Discord ... "
20
+
21
+ client = Discordrb::Webhooks::Client.new(url: configuration[:webhook])
22
+ response = client.execute do |builder|
23
+ builder.content = "[#{runner.vcs_info.repo}]\n> ```#{runner.message}```"
24
+ builder.file = File.new(runner.lolcommit_path)
25
+ end
26
+
27
+ debug response
28
+ print "done!\n"
29
+ rescue => e
30
+ print "failed! #{e.message}"
31
+ if retries > 0
32
+ retries -= 1
33
+ print " - retrying ...\n"
34
+ retry
35
+ else
36
+ print " - giving up ...\n"
37
+ puts 'Try running config again:'
38
+ puts "\tlolcommits --config -p discord"
39
+ end
40
+ end
41
+ end
42
+
43
+ ##
44
+ # Prompts the user to configure integration with Discord
45
+ #
46
+ # Prompts user for a Discord webhook URL
47
+ #
48
+ # @return [Hash] a hash of configured plugin options
49
+ #
50
+ def configure_options!
51
+ options = super
52
+
53
+ if options[:enabled]
54
+ print "enter your Discord webhook URL below, then press enter: (e.g. https://discord.com/api/webhooks/1234/xxxx-xx-xxxxx) \n"
55
+ webhook_url = parse_user_input(gets.strip)
56
+
57
+ options.merge!(
58
+ webhook: webhook_url,
59
+ )
60
+ end
61
+
62
+ options
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,39 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'lolcommits/discord/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "lolcommits-discord"
7
+ spec.version = Lolcommits::Discord::VERSION
8
+ spec.authors = ["Zach Kanzler"]
9
+ spec.email = ["they4kman@gmail.com"]
10
+ spec.summary = %q{Sends lolcommits to one (or more) Discord channels}
11
+ spec.homepage = "https://github.com/theY4Kman/lolcommits-discord"
12
+ spec.license = "LGPL-3.0"
13
+ spec.description = %q{Automatically post your lolcommits to Slack}
14
+
15
+ spec.metadata = {
16
+ "homepage_uri" => "https://github.com/theY4Kman/lolcommits-discord",
17
+ "changelog_uri" => "https://github.com/theY4Kman/lolcommits-discord/blob/master/CHANGELOG.md",
18
+ "source_code_uri" => "https://github.com/theY4Kman/lolcommits-discord",
19
+ "bug_tracker_uri" => "https://github.com/theY4Kman/lolcommits-discord/issues",
20
+ "allowed_push_host" => "https://rubygems.org"
21
+ }
22
+
23
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|features)/}) }
24
+ # spec.test_files = `git ls-files -- {test,features}/*`.split("\n")
25
+ spec.bindir = "bin"
26
+ spec.executables = []
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.required_ruby_version = ">= 2.4"
30
+
31
+ spec.add_runtime_dependency "discordrb-webhooks", ">= 3.4.2"
32
+ spec.add_runtime_dependency "lolcommits", ">= 0.14.2"
33
+
34
+ # spec.add_development_dependency "webmock"
35
+ spec.add_development_dependency "bundler"
36
+ spec.add_development_dependency "rake"
37
+ # spec.add_development_dependency "minitest"
38
+ # spec.add_development_dependency "simplecov"
39
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lolcommits-discord
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Zach Kanzler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-07-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: discordrb-webhooks
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.4.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.4.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: lolcommits
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.14.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.14.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Automatically post your lolcommits to Slack
70
+ email:
71
+ - they4kman@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - CHANGELOG.md
78
+ - Gemfile
79
+ - README.md
80
+ - bin/console
81
+ - bin/setup
82
+ - lib/lolcommits/discord.rb
83
+ - lib/lolcommits/discord/version.rb
84
+ - lib/lolcommits/plugin/discord.rb
85
+ - lolcommits-discord.gemspec
86
+ homepage: https://github.com/theY4Kman/lolcommits-discord
87
+ licenses:
88
+ - LGPL-3.0
89
+ metadata:
90
+ homepage_uri: https://github.com/theY4Kman/lolcommits-discord
91
+ changelog_uri: https://github.com/theY4Kman/lolcommits-discord/blob/master/CHANGELOG.md
92
+ source_code_uri: https://github.com/theY4Kman/lolcommits-discord
93
+ bug_tracker_uri: https://github.com/theY4Kman/lolcommits-discord/issues
94
+ allowed_push_host: https://rubygems.org
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '2.4'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubygems_version: 3.1.2
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Sends lolcommits to one (or more) Discord channels
114
+ test_files: []