lolcommits-sample_plugin 0.5.0 → 0.5.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 +4 -4
- data/.github/workflows/ci.yml +56 -0
- data/.quickhook/pre-commit/ruby-lint +3 -0
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +7 -1
- data/Gemfile +5 -1
- data/README.md +70 -79
- data/Rakefile +1 -1
- data/bin/rubocop +5 -0
- data/lib/lolcommits/plugin/sample_plugin.rb +1 -2
- data/lib/lolcommits/sample_plugin/version.rb +1 -1
- data/lib/lolcommits/sample_plugin.rb +2 -2
- data/lolcommits-plugin-sample.gemspec +6 -5
- data/test/lolcommits/plugin/sample_plugin_test.rb +107 -0
- data/test/test_helper.rb +17 -0
- metadata +16 -12
- data/.github/workflows/build.yml +0 -34
- data/.github/workflows/push_gem.yml +0 -25
- data/.simplecov +0 -9
- data/.travis.yml +0 -29
- data/PULL_REQUEST_TEMPLATE.md +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97ed049cbe971c2dffb65a484ea68bcaf51f477260a1cdfdce3f15210e7d151e
|
4
|
+
data.tar.gz: 79dc06a571560eb3e2d8478903d67c25c49a18b41e2718c578d473c86e2a7c2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e079b0255ccc5b871e043437504ab14891ca2c8c54fe27ee702cc1c2450ae3a76c50492caf5bded39e9e1153553caa28860c8feacb92a51afb31f41d54ba3dd3
|
7
|
+
data.tar.gz: 99da23a21319c0c67cf7d7b522ed576a8f8fd1c8a2a77a4f907ca72f580ae45f8feed50d6d0c4439ca55244cc8e04aa17f34d253ca19386a14d4e56dc55e2867
|
@@ -0,0 +1,56 @@
|
|
1
|
+
name: CI
|
2
|
+
permissions:
|
3
|
+
contents: read
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches:
|
8
|
+
- main
|
9
|
+
pull_request:
|
10
|
+
branches:
|
11
|
+
- main
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
rubocop:
|
15
|
+
name: RuboCop
|
16
|
+
runs-on: ubuntu-latest
|
17
|
+
env:
|
18
|
+
BUNDLE_ONLY: rubocop
|
19
|
+
steps:
|
20
|
+
- name: Checkout code
|
21
|
+
uses: actions/checkout@v4
|
22
|
+
- name: Setup Ruby and install gems
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: 3.3.0
|
26
|
+
bundler-cache: true
|
27
|
+
- name: Run Rubocop
|
28
|
+
run: bundle exec rubocop --parallel
|
29
|
+
test:
|
30
|
+
name: ${{ format('Unit tests (Ruby {0})', matrix.ruby-version) }}
|
31
|
+
runs-on: ubuntu-latest
|
32
|
+
strategy:
|
33
|
+
matrix:
|
34
|
+
ruby-version:
|
35
|
+
- "3.1"
|
36
|
+
- "3.2"
|
37
|
+
- "3.3"
|
38
|
+
- "3.4"
|
39
|
+
continue-on-error: true
|
40
|
+
steps:
|
41
|
+
- name: Checkout code
|
42
|
+
uses: actions/checkout@v4
|
43
|
+
- name: Setup Ruby and install gems
|
44
|
+
uses: ruby/setup-ruby@v1
|
45
|
+
with:
|
46
|
+
ruby-version: ${{ matrix.ruby-version }}
|
47
|
+
bundler-cache: true
|
48
|
+
- name: Configure Git
|
49
|
+
run: |
|
50
|
+
git config --global user.name $NAME
|
51
|
+
git config --global user.email $EMAIL
|
52
|
+
env:
|
53
|
+
NAME: "George Costanza"
|
54
|
+
EMAIL: "george.costanza@vandelay.com"
|
55
|
+
- name: Run tests
|
56
|
+
run: bundle exec rake test
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,11 @@ project adheres to [Semantic Versioning][Semver].
|
|
9
9
|
|
10
10
|
- Your contribution here!
|
11
11
|
|
12
|
+
## [0.5.1] - 2024-12-29
|
13
|
+
### Changed
|
14
|
+
- Push gems with bundler (not GitHub actions)
|
15
|
+
- Updated documentation links
|
16
|
+
|
12
17
|
## [0.5.0] - 2024-09-22
|
13
18
|
### Removed
|
14
19
|
- Support for Ruby < 3.1 (older rubies no longer supported)
|
@@ -62,7 +67,8 @@ project adheres to [Semantic Versioning][Semver].
|
|
62
67
|
### Changed
|
63
68
|
- Initial release
|
64
69
|
|
65
|
-
[Unreleased]: https://github.com/lolcommits/lolcommits-sample_plugin/compare/v0.5.
|
70
|
+
[Unreleased]: https://github.com/lolcommits/lolcommits-sample_plugin/compare/v0.5.1...HEAD
|
71
|
+
[0.5.1]: https://github.com/lolcommits/lolcommits-sample_plugin/compare/v0.5.0...v0.5.1
|
66
72
|
[0.5.0]: https://github.com/lolcommits/lolcommits-sample_plugin/compare/v0.4.0...v0.5.0
|
67
73
|
[0.4.0]: https://github.com/lolcommits/lolcommits-sample_plugin/compare/v0.3.0...v0.4.0
|
68
74
|
[0.3.0]: https://github.com/lolcommits/lolcommits-sample_plugin/compare/v0.2.0...v0.3.0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
# Lolcommits Sample Plugin
|
2
2
|
|
3
|
-
[](https://github.com/lolcommits/lolcommits-sample_plugin/actions/workflows/ci.yml)
|
4
4
|
[](http://rubygems.org/gems/lolcommits-sample_plugin)
|
5
5
|
[](https://depfu.com/github/lolcommits/lolcommits-sample_plugin)
|
6
6
|
|
7
|
-
[lolcommits](https://lolcommits.github.io/) takes a snapshot with your
|
8
|
-
|
9
|
-
|
7
|
+
[lolcommits](https://lolcommits.github.io/) takes a snapshot with your webcam
|
8
|
+
every time you git commit code, and archives a lolcat style image with it. Git
|
9
|
+
blame has never been so much fun!
|
10
10
|
|
11
|
-
Lolcommit plugins allow developers to add features by running code
|
12
|
-
|
13
|
-
|
11
|
+
Lolcommit plugins allow developers to add features by running code before or
|
12
|
+
after snapshots are taken. Installed plugin gems are automatically loaded before
|
13
|
+
the capturing process starts.
|
14
14
|
|
15
|
-
This gem showcases an example plugin. It prints short messages to the
|
16
|
-
|
17
|
-
|
15
|
+
This gem showcases an example plugin. It prints short messages to the screen
|
16
|
+
before and after every lolcommit. After configuring the plugin to be enabled,
|
17
|
+
you'll see something like this for a capture:
|
18
18
|
|
19
19
|
✨ Say cheese 😁 !
|
20
20
|
*** Preserving this moment in history.
|
@@ -22,13 +22,12 @@ be enabled, you'll see something like this for a capture:
|
|
22
22
|
wow! 9e6303c at /path/to/lolcommit.jpg is your best looking commit yet!
|
23
23
|
(it was an image!)
|
24
24
|
|
25
|
-
Use this repo to jump-start development on your own plugin. It has
|
26
|
-
|
25
|
+
Use this repo to jump-start development on your own plugin. It has tests, docs
|
26
|
+
and hooks with useful tools; CI, Rdoc etc.
|
27
27
|
|
28
28
|
## Developing your own plugin
|
29
29
|
|
30
|
-
First, there are some things your gem *must* do to be loaded and
|
31
|
-
executed:
|
30
|
+
First, there are some things your gem *must* do to be loaded and executed:
|
32
31
|
|
33
32
|
* The gem name must have a `lolcommits-` prefix.
|
34
33
|
* Require `lolcommits` in your `gemspec` file as a development
|
@@ -39,8 +38,8 @@ executed:
|
|
39
38
|
|
40
39
|
### Your Plugin Class
|
41
40
|
|
42
|
-
You plugin class must have a namespace and path that matches your gem
|
43
|
-
|
41
|
+
You plugin class must have a namespace and path that matches your gem name and
|
42
|
+
be in the gem's `LOAD_PATH`.
|
44
43
|
|
45
44
|
# for a gem named lolcommits-zapier you should have a plugin class:
|
46
45
|
class Lolcommits::Plugin::Zapier < Lolcommits::Plugin::Base
|
@@ -56,8 +55,8 @@ name and be in the gem's `LOAD_PATH`.
|
|
56
55
|
# at lib/lolcommits/plugin/super_awesome.rb
|
57
56
|
# required in a file at lib/lolcommits/super_awesome.rb
|
58
57
|
|
59
|
-
The following methods can be overridden to execute code during the
|
60
|
-
|
58
|
+
The following methods can be overridden to execute code during the capture
|
59
|
+
process:
|
61
60
|
|
62
61
|
* `run_pre_capture` - executes before the capture starts, at this point
|
63
62
|
you could alter the commit message/sha text.
|
@@ -70,12 +69,12 @@ capture process:
|
|
70
69
|
|
71
70
|
### Plugin configuration
|
72
71
|
|
73
|
-
Available options can be defined in an Array (`@options` instance var)
|
74
|
-
|
72
|
+
Available options can be defined in an Array (`@options` instance var) and/or a
|
73
|
+
Hash (by overriding the `default_options` method).
|
75
74
|
|
76
|
-
By default (on initialize), `@options` will be set to `[:enabled]`. This
|
77
|
-
|
78
|
-
|
75
|
+
By default (on initialize), `@options` will be set to `[:enabled]`. This option
|
76
|
+
is mandatory since `enabled?` checks `configuration[:enabled] == true` before
|
77
|
+
any capture hooks can run.
|
79
78
|
|
80
79
|
Using a Hash to define default options allows you to:
|
81
80
|
|
@@ -84,13 +83,13 @@ Using a Hash to define default options allows you to:
|
|
84
83
|
- define nested options (the user is prompted for each nested option
|
85
84
|
key)
|
86
85
|
|
87
|
-
`configure_option_hash` will iterate over all options prompting the user
|
88
|
-
|
86
|
+
`configure_option_hash` will iterate over all options prompting the user for
|
87
|
+
input while building the configuration Hash.
|
89
88
|
|
90
|
-
Lolcommits will save this Hash to a YAML file. During the capture
|
91
|
-
|
92
|
-
|
93
|
-
|
89
|
+
Lolcommits will save this Hash to a YAML file. During the capture process the
|
90
|
+
configuration is loaded, parsed and available in the plugin class as
|
91
|
+
`configuration`. Or if you want to fall back to default values, you should use
|
92
|
+
the `config_option` method to dig into the Hash.
|
94
93
|
|
95
94
|
Alternatively you can override these methods to fully customise the
|
96
95
|
configuration process.
|
@@ -107,25 +106,24 @@ By default a plugin will only run it's capture hooks if:
|
|
107
106
|
* `valid_configuration?` returns true
|
108
107
|
* `enabled?` returns true
|
109
108
|
|
110
|
-
A `parse_user_input` method is available to help parse strings from
|
111
|
-
|
109
|
+
A `parse_user_input` method is available to help parse strings from STDIN to
|
110
|
+
Ruby objects (e.g. boolean, integer or nil).
|
112
111
|
|
113
|
-
During plugin configuration, your plugin class will be initialized with
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
112
|
+
During plugin configuration, your plugin class will be initialized with the
|
113
|
+
optional `config` argument (and no runner). This allows you to read the existing
|
114
|
+
saved options during configuration. E.g. to show existing options back to the
|
115
|
+
user, allowing you to ask if they want to keep or change an option if
|
116
|
+
reconfiguring.
|
118
117
|
|
119
|
-
__NOTE__: If your plugin does not require configuration and should be
|
120
|
-
|
121
|
-
|
122
|
-
the plugin.
|
118
|
+
__NOTE__: If your plugin does not require configuration and should be enabled by
|
119
|
+
default (on gem install) you could override the `enabled?` method to always
|
120
|
+
return `true`. Simply uninstalling the gem will disable the plugin.
|
123
121
|
|
124
122
|
For more help, check out [the
|
125
123
|
documentation](http://www.rubydoc.info/github/lolcommits/lolcommits-sample_plugin/Lolcommits/Plugin/SamplePlugin)
|
126
124
|
for this plugin, or take a look at [other
|
127
|
-
|
128
|
-
|
125
|
+
lolcommit_plugins](https://github.com/search?q=topic%3Alolcommits-plugin+org%3Alolcommits&type=Repositories)
|
126
|
+
in the wild.
|
129
127
|
|
130
128
|
### The Lolcommits 'runner'
|
131
129
|
|
@@ -150,11 +148,11 @@ instance var for use in your plugin's code.
|
|
150
148
|
* `runner.capture_image` - `true` when an image (jpg) was captured, false for gifs/videos
|
151
149
|
|
152
150
|
After the capturing process completes, (i.e. in `run_post_capture` or
|
153
|
-
`run_capture_ready` hooks) use `runner.lolcommit_path` to access the
|
154
|
-
|
151
|
+
`run_capture_ready` hooks) use `runner.lolcommit_path` to access the lolcommit
|
152
|
+
file (jpg, mp4 or gif).
|
155
153
|
|
156
|
-
__NOTE__: it is possible for both an animated gif *AND* video to be
|
157
|
-
|
154
|
+
__NOTE__: it is possible for both an animated gif *AND* video to be generated,
|
155
|
+
in this case `lolcommits_path` points to the `mp4` video and
|
158
156
|
`runner.lolcommits_gif_path` points to the animated `gif`.
|
159
157
|
|
160
158
|
Take a look at
|
@@ -165,19 +163,18 @@ for more details.
|
|
165
163
|
|
166
164
|
After capturing (and resizing), the
|
167
165
|
[runner](https://github.com/lolcommits/lolcommits/blob/master/lib/lolcommits/runner.rb)
|
168
|
-
provides a blank (transparent) PNG for plugins to manipulate. It
|
169
|
-
|
170
|
-
|
171
|
-
To make use of this `runner.overlay`, reference it in any `post_capture`
|
172
|
-
|
173
|
-
[utility](http://rubydoc.info/github/minimagick/minimagick) method. For
|
174
|
-
|
175
|
-
[lolcommits-loltext](https://github.com/lolcommits/lolcommits-loltext)
|
166
|
+
provides a blank (transparent) PNG for plugins to manipulate. It matches the
|
167
|
+
width and height of the lolcommit capture.
|
168
|
+
|
169
|
+
To make use of this `runner.overlay`, reference it in any `post_capture` hook.
|
170
|
+
You can use any `MiniMagick::Image`
|
171
|
+
[utility](http://rubydoc.info/github/minimagick/minimagick) method. For example
|
172
|
+
the [lolcommits-loltext](https://github.com/lolcommits/lolcommits-loltext)
|
176
173
|
plugin annotates text, a border and overlay colour
|
177
174
|
[here](https://github.com/lolcommits/lolcommits-loltext/blob/master/lib/lolcommits/plugin/loltext.rb#L74).
|
178
175
|
|
179
|
-
After all `post_capture` hooks finish, this overlay PNG is composited on
|
180
|
-
|
176
|
+
After all `post_capture` hooks finish, this overlay PNG is composited on top of
|
177
|
+
the snapshot and the final lolcommit file is available at
|
181
178
|
`runner.lolcommit_path` for `capture_ready` hooks to use.
|
182
179
|
|
183
180
|
### Testing your plugin
|
@@ -225,7 +222,7 @@ repo](https://github.com/lolcommits/lolcommits-sample_plugin/blob/master/test/lo
|
|
225
222
|
|
226
223
|
## Requirements
|
227
224
|
|
228
|
-
* Ruby >=
|
225
|
+
* Ruby >= 3.1
|
229
226
|
* A webcam
|
230
227
|
* [ImageMagick](http://www.imagemagick.org)
|
231
228
|
* [ffmpeg](https://www.ffmpeg.org) (optional) for animated gif capturing
|
@@ -233,8 +230,8 @@ repo](https://github.com/lolcommits/lolcommits-sample_plugin/blob/master/test/lo
|
|
233
230
|
## Installation
|
234
231
|
|
235
232
|
Follow the [install
|
236
|
-
guide](https://github.com/lolcommits/lolcommits#installation) for
|
237
|
-
|
233
|
+
guide](https://github.com/lolcommits/lolcommits#installation) for lolcommits
|
234
|
+
first. Then run the following:
|
238
235
|
|
239
236
|
$ gem install lolcommits-sample_plugin
|
240
237
|
|
@@ -243,17 +240,15 @@ Next configure and enable this plugin with:
|
|
243
240
|
$ lolcommits --config -p sample_plugin
|
244
241
|
# set enabled to `true` and configure other options as you like
|
245
242
|
|
246
|
-
That's it! Every lolcommit now comes with it's own emoji themed
|
247
|
-
commentary!
|
243
|
+
That's it! Every lolcommit now comes with it's own emoji themed commentary!
|
248
244
|
|
249
245
|
## Development
|
250
246
|
|
251
|
-
Check out this repo and run `bin/setup`, this will install dependencies
|
252
|
-
|
253
|
-
a coverage report.
|
247
|
+
Check out this repo and run `bin/setup`, this will install dependencies and
|
248
|
+
generate docs. Run `bundle exec rake` to run all tests.
|
254
249
|
|
255
|
-
You can also run `bin/console` for an interactive prompt that will allow
|
256
|
-
|
250
|
+
You can also run `bin/console` for an interactive prompt that will allow you to
|
251
|
+
experiment with the gem code.
|
257
252
|
|
258
253
|
## Tests
|
259
254
|
|
@@ -270,16 +265,13 @@ Generate docs for this gem with:
|
|
270
265
|
## Troubles?
|
271
266
|
|
272
267
|
If you think something is broken or missing, please raise a new
|
273
|
-
[issue](https://github.com/lolcommits/lolcommits-sample_plugin/issues).
|
274
|
-
|
275
|
-
closed).
|
268
|
+
[issue](https://github.com/lolcommits/lolcommits-sample_plugin/issues). Take a
|
269
|
+
moment to check it hasn't been raised in the past (and possibly closed).
|
276
270
|
|
277
271
|
## Contributing
|
278
272
|
|
279
|
-
Bug
|
280
|
-
[
|
281
|
-
and [pull
|
282
|
-
requests](https://github.com/lolcommits/lolcommits-sample_plugin/pulls)
|
273
|
+
Bug [reports](https://github.com/lolcommits/lolcommits-sample_plugin/issues) and
|
274
|
+
[pull requests](https://github.com/lolcommits/lolcommits-sample_plugin/pulls)
|
283
275
|
are welcome on GitHub.
|
284
276
|
|
285
277
|
When submitting pull requests, remember to add tests covering any new behaviour,
|
@@ -287,10 +279,9 @@ and ensure all tests are passing on CI. Read the [contributing
|
|
287
279
|
guidelines](https://github.com/lolcommits/lolcommits-sample_plugin/blob/master/CONTRIBUTING.md)
|
288
280
|
for more details.
|
289
281
|
|
290
|
-
This project is intended to be a safe, welcoming space for
|
291
|
-
|
292
|
-
|
293
|
-
See
|
282
|
+
This project is intended to be a safe, welcoming space for collaboration, and
|
283
|
+
contributors are expected to adhere to the [Contributor
|
284
|
+
Covenant](http://contributor-covenant.org) code of conduct. See
|
294
285
|
[here](https://github.com/lolcommits/lolcommits-sample_plugin/blob/master/CODE_OF_CONDUCT.md)
|
295
286
|
for more details.
|
296
287
|
|
@@ -301,8 +292,8 @@ The gem is available as open source under the terms of
|
|
301
292
|
|
302
293
|
## Links
|
303
294
|
|
304
|
-
* [CI](https://github.com/lolcommits/lolcommits-sample_plugin/actions/workflows/
|
305
|
-
* [RDoc](
|
295
|
+
* [CI](https://github.com/lolcommits/lolcommits-sample_plugin/actions/workflows/ci.yml)
|
296
|
+
* [RDoc](https://rubydoc.info/gems/lolcommits-sample_plugin)
|
306
297
|
* [Issues](http://github.com/lolcommits/lolcommits-sample_plugin/issues)
|
307
298
|
* [Report a bug](http://github.com/lolcommits/lolcommits-sample_plugin/issues/new)
|
308
299
|
* [Gem](http://rubygems.org/gems/lolcommits-sample_plugin)
|
data/Rakefile
CHANGED
data/bin/rubocop
ADDED
@@ -5,15 +5,16 @@ require 'lolcommits/sample_plugin/version'
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "lolcommits-sample_plugin"
|
7
7
|
spec.version = Lolcommits::SamplePlugin::VERSION
|
8
|
-
spec.authors = ["Matthew Hutchinson"]
|
9
|
-
spec.email = ["matt@hiddenloop.com"]
|
10
|
-
spec.summary = %q
|
8
|
+
spec.authors = [ "Matthew Hutchinson" ]
|
9
|
+
spec.email = [ "matt@hiddenloop.com" ]
|
10
|
+
spec.summary = %q(Example gem for lolcommits plugin development)
|
11
11
|
spec.homepage = "https://github.com/lolcommits/lolcommits-sample_plugin"
|
12
12
|
spec.license = "LGPL-3.0"
|
13
|
-
spec.description = %q
|
13
|
+
spec.description = %q(Use this gem as a guide or template to get started with lolcommits plugin development)
|
14
14
|
|
15
15
|
spec.metadata = {
|
16
16
|
"homepage_uri" => "https://github.com/lolcommits/lolcommits-sample_plugin",
|
17
|
+
"documentation_uri" => "https://rubydoc.info/gems/lolcommits-sample_plugin",
|
17
18
|
"changelog_uri" => "https://github.com/lolcommits/lolcommits-sample_plugin/blob/master/CHANGELOG.md",
|
18
19
|
"source_code_uri" => "https://github.com/lolcommits/lolcommits-sample_plugin",
|
19
20
|
"bug_tracker_uri" => "https://github.com/lolcommits/lolcommits-sample_plugin/issues",
|
@@ -24,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
24
25
|
spec.test_files = `git ls-files -- {test,features}/*`.split("\n")
|
25
26
|
spec.bindir = "bin"
|
26
27
|
spec.executables = []
|
27
|
-
spec.require_paths = ["lib"]
|
28
|
+
spec.require_paths = [ "lib" ]
|
28
29
|
|
29
30
|
spec.required_ruby_version = ">= 3.1"
|
30
31
|
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
describe Lolcommits::Plugin::SamplePlugin do
|
6
|
+
include Lolcommits::TestHelpers::GitRepo
|
7
|
+
include Lolcommits::TestHelpers::FakeIO
|
8
|
+
|
9
|
+
describe "with a runner" do
|
10
|
+
def runner
|
11
|
+
# a simple lolcommits runner with an empty configuration Hash
|
12
|
+
@runner ||= Lolcommits::Runner.new(
|
13
|
+
lolcommit_path: "/path/to/lolcommit.jpg"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def plugin
|
18
|
+
@plugin ||= Lolcommits::Plugin::SamplePlugin.new(runner: runner)
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid_enabled_config
|
22
|
+
{
|
23
|
+
enabled: true,
|
24
|
+
ask_for_cheese: false,
|
25
|
+
always_a_great_commit?: true,
|
26
|
+
camera_emoji: {
|
27
|
+
enabled: true,
|
28
|
+
emoji_multiplier: 5
|
29
|
+
}
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#run_pre_capture" do
|
34
|
+
before { commit_repo_with_message }
|
35
|
+
|
36
|
+
it "outputs a message to stdout" do
|
37
|
+
in_repo do
|
38
|
+
_(Proc.new { plugin.run_pre_capture }).
|
39
|
+
must_output "✨ Say cheese 😁 !\n"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
after { teardown_repo }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#run_post_capture" do
|
47
|
+
before { commit_repo_with_message }
|
48
|
+
|
49
|
+
it "outputs a message to stdout" do
|
50
|
+
plugin.configuration = valid_enabled_config
|
51
|
+
in_repo do
|
52
|
+
_(Proc.new { plugin.run_post_capture }).
|
53
|
+
must_output "📸 📸 📸 📸 📸 Snap!\n"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
after { teardown_repo }
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#run_capture_ready" do
|
61
|
+
before { commit_repo_with_message }
|
62
|
+
|
63
|
+
it "outputs a message to stdout" do
|
64
|
+
in_repo do
|
65
|
+
_(Proc.new { plugin.run_capture_ready }).
|
66
|
+
must_output "wow! #{last_commit.sha[0..10]} at /path/to/lolcommit.jpg is your best looking commit yet!\n(it was an image!)\n"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
after { teardown_repo }
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#enabled?" do
|
74
|
+
it "returns be false by default" do
|
75
|
+
_(plugin.enabled?).must_equal false
|
76
|
+
end
|
77
|
+
|
78
|
+
it "returns true when configured" do
|
79
|
+
plugin.configuration = valid_enabled_config
|
80
|
+
_(plugin.enabled?).must_equal true
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "configuration" do
|
85
|
+
it "allows plugin options to be configured" do
|
86
|
+
configured_plugin_options = {}
|
87
|
+
|
88
|
+
fake_io_capture(inputs: %w[true false true true 5]) do
|
89
|
+
configured_plugin_options = plugin.configure_options!
|
90
|
+
end
|
91
|
+
|
92
|
+
_(configured_plugin_options).must_equal(valid_enabled_config)
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#valid_configuration?" do
|
96
|
+
it "returns false without config set" do
|
97
|
+
_(plugin.valid_configuration?).must_equal(false)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "returns true for a valid configuration" do
|
101
|
+
plugin.configuration = valid_enabled_config
|
102
|
+
_(plugin.valid_configuration?).must_equal true
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
4
|
+
|
5
|
+
# lolcommits gem
|
6
|
+
require "lolcommits"
|
7
|
+
|
8
|
+
# lolcommit test helpers
|
9
|
+
require "lolcommits/test_helpers/git_repo"
|
10
|
+
require "lolcommits/test_helpers/fake_io"
|
11
|
+
|
12
|
+
# plugin gem test libs
|
13
|
+
require "lolcommits/sample_plugin"
|
14
|
+
require "minitest/autorun"
|
15
|
+
|
16
|
+
# swallow all debug output during test runs
|
17
|
+
def debug(msg); end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolcommits-sample_plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Hutchinson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lolcommits
|
@@ -74,35 +74,37 @@ executables: []
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
- ".github/workflows/
|
78
|
-
- ".github/workflows/push_gem.yml"
|
77
|
+
- ".github/workflows/ci.yml"
|
79
78
|
- ".gitignore"
|
80
|
-
- ".
|
81
|
-
- ".
|
79
|
+
- ".quickhook/pre-commit/ruby-lint"
|
80
|
+
- ".rubocop.yml"
|
82
81
|
- CHANGELOG.md
|
83
82
|
- CODE_OF_CONDUCT.md
|
84
83
|
- CONTRIBUTING.md
|
85
84
|
- Gemfile
|
86
85
|
- LICENSE
|
87
|
-
- PULL_REQUEST_TEMPLATE.md
|
88
86
|
- README.md
|
89
87
|
- Rakefile
|
90
88
|
- bin/console
|
89
|
+
- bin/rubocop
|
91
90
|
- bin/setup
|
92
91
|
- lib/lolcommits/plugin/sample_plugin.rb
|
93
92
|
- lib/lolcommits/sample_plugin.rb
|
94
93
|
- lib/lolcommits/sample_plugin/version.rb
|
95
94
|
- lolcommits-plugin-sample.gemspec
|
95
|
+
- test/lolcommits/plugin/sample_plugin_test.rb
|
96
|
+
- test/test_helper.rb
|
96
97
|
homepage: https://github.com/lolcommits/lolcommits-sample_plugin
|
97
98
|
licenses:
|
98
99
|
- LGPL-3.0
|
99
100
|
metadata:
|
100
101
|
homepage_uri: https://github.com/lolcommits/lolcommits-sample_plugin
|
102
|
+
documentation_uri: https://rubydoc.info/gems/lolcommits-sample_plugin
|
101
103
|
changelog_uri: https://github.com/lolcommits/lolcommits-sample_plugin/blob/master/CHANGELOG.md
|
102
104
|
source_code_uri: https://github.com/lolcommits/lolcommits-sample_plugin
|
103
105
|
bug_tracker_uri: https://github.com/lolcommits/lolcommits-sample_plugin/issues
|
104
106
|
allowed_push_host: https://rubygems.org
|
105
|
-
post_install_message:
|
107
|
+
post_install_message:
|
106
108
|
rdoc_options: []
|
107
109
|
require_paths:
|
108
110
|
- lib
|
@@ -117,8 +119,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
119
|
- !ruby/object:Gem::Version
|
118
120
|
version: '0'
|
119
121
|
requirements: []
|
120
|
-
rubygems_version: 3.5.
|
121
|
-
signing_key:
|
122
|
+
rubygems_version: 3.5.22
|
123
|
+
signing_key:
|
122
124
|
specification_version: 4
|
123
125
|
summary: Example gem for lolcommits plugin development
|
124
|
-
test_files:
|
126
|
+
test_files:
|
127
|
+
- test/lolcommits/plugin/sample_plugin_test.rb
|
128
|
+
- test/test_helper.rb
|
data/.github/workflows/build.yml
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
name: Tests
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [ "main" ]
|
6
|
-
pull_request:
|
7
|
-
branches: [ "main" ]
|
8
|
-
|
9
|
-
permissions:
|
10
|
-
contents: read
|
11
|
-
|
12
|
-
jobs:
|
13
|
-
test:
|
14
|
-
runs-on: ubuntu-latest
|
15
|
-
strategy:
|
16
|
-
fail-fast: false
|
17
|
-
matrix:
|
18
|
-
ruby-version: ['3.1', '3.2', '3.3', '3.4']
|
19
|
-
steps:
|
20
|
-
- uses: actions/checkout@v4
|
21
|
-
- name: Set up Ruby
|
22
|
-
uses: ruby/setup-ruby@v1
|
23
|
-
with:
|
24
|
-
ruby-version: ${{ matrix.ruby-version }}
|
25
|
-
bundler-cache: true
|
26
|
-
- name: Configure git user name, email
|
27
|
-
run: |
|
28
|
-
git config --global user.name $NAME
|
29
|
-
git config --global user.email $EMAIL
|
30
|
-
env:
|
31
|
-
NAME: "George Costanza"
|
32
|
-
EMAIL: "george.costanza@vandelay.com"
|
33
|
-
- name: Run tests
|
34
|
-
run: bundle exec rake test
|
@@ -1,25 +0,0 @@
|
|
1
|
-
name: Publish gem to RubyGems.org
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
tags:
|
6
|
-
- v*
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
push:
|
10
|
-
name: Push gem to RubyGems.org
|
11
|
-
runs-on: ubuntu-latest
|
12
|
-
|
13
|
-
permissions:
|
14
|
-
id-token: write
|
15
|
-
contents: write
|
16
|
-
|
17
|
-
steps:
|
18
|
-
- uses: actions/checkout@v4
|
19
|
-
- name: Set up Ruby
|
20
|
-
uses: ruby/setup-ruby@v1
|
21
|
-
with:
|
22
|
-
bundler-cache: true
|
23
|
-
ruby-version: ruby
|
24
|
-
|
25
|
-
- uses: rubygems/release-gem@v1
|
data/.simplecov
DELETED
data/.travis.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
cache: bundler
|
4
|
-
rvm:
|
5
|
-
- 2.5.8
|
6
|
-
- 2.6.6
|
7
|
-
- 2.7.2
|
8
|
-
- 3.0.0
|
9
|
-
- ruby-head
|
10
|
-
|
11
|
-
before_install:
|
12
|
-
- git --version
|
13
|
-
- git config --global user.email "lol@commits.org"
|
14
|
-
- git config --global user.name "Lolcommits"
|
15
|
-
|
16
|
-
matrix:
|
17
|
-
allow_failures:
|
18
|
-
- rvm: ruby-head
|
19
|
-
|
20
|
-
env:
|
21
|
-
global:
|
22
|
-
- CC_TEST_REPORTER_ID=7fb6d4a66ca2ac21658b29d3738952994f3b68354a8e3e6318bf1108eda6c243
|
23
|
-
- GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi)
|
24
|
-
before_script:
|
25
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
26
|
-
- chmod +x ./cc-test-reporter
|
27
|
-
- ./cc-test-reporter before-build - GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi)
|
28
|
-
after_script:
|
29
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/PULL_REQUEST_TEMPLATE.md
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
|
2
|
-
Explain what you're changing and why here.
|
3
|
-
|
4
|
-
---
|
5
|
-
#### :memo: Checklist
|
6
|
-
|
7
|
-
Please check this list and leave it intact for the reviewer. Thanks! :heart:
|
8
|
-
|
9
|
-
- [ ] Commit messages provide context (why not just what, some tips [here](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)).
|
10
|
-
- [ ] If relevant, mention GitHub issue number above and include in a commit message.
|
11
|
-
- [ ] Latest code from master merged.
|
12
|
-
- [ ] New behaviour has test coverage.
|
13
|
-
- [ ] Avoid duplicating code.
|
14
|
-
- [ ] No commented out code.
|
15
|
-
- [ ] Avoid comments for your code, write code that explains itself.
|
16
|
-
- [ ] Changes are simple, useful, clear and brief.
|