lolcommits 0.17.2 → 0.18.0
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/.rubocop.yml +309 -9
- data/README.md +14 -26
- data/bin/lolcommits +2 -12
- data/lib/core_ext/mercurial-ruby/changed_file.rb +1 -3
- data/lib/core_ext/mercurial-ruby/command.rb +2 -4
- data/lib/core_ext/mercurial-ruby/config_file.rb +0 -2
- data/lib/core_ext/mercurial-ruby/repository.rb +0 -2
- data/lib/core_ext/mercurial-ruby/shell.rb +1 -3
- data/lib/lolcommits/animated_gif.rb +12 -7
- data/lib/lolcommits/backends/git_info.rb +6 -8
- data/lib/lolcommits/backends/installation_git.rb +8 -10
- data/lib/lolcommits/backends/installation_mercurial.rb +8 -10
- data/lib/lolcommits/backends/mercurial_info.rb +9 -11
- data/lib/lolcommits/capturer/capture_cygwin.rb +0 -2
- data/lib/lolcommits/capturer/capture_fake.rb +2 -4
- data/lib/lolcommits/capturer/capture_linux.rb +4 -6
- data/lib/lolcommits/capturer/capture_linux_video.rb +1 -3
- data/lib/lolcommits/capturer/capture_mac.rb +2 -4
- data/lib/lolcommits/capturer/capture_mac_video.rb +1 -3
- data/lib/lolcommits/capturer/capture_windows.rb +2 -4
- data/lib/lolcommits/capturer/capture_windows_video.rb +5 -7
- data/lib/lolcommits/capturer.rb +9 -12
- data/lib/lolcommits/cli/fatals.rb +11 -16
- data/lib/lolcommits/cli/launcher.rb +1 -3
- data/lib/lolcommits/cli/process_runner.rb +2 -4
- data/lib/lolcommits/cli/timelapse_gif.rb +11 -11
- data/lib/lolcommits/cli.rb +6 -6
- data/lib/lolcommits/configuration.rb +32 -36
- data/lib/lolcommits/gem_plugin.rb +5 -7
- data/lib/lolcommits/installation.rb +5 -7
- data/lib/lolcommits/platform.rb +14 -18
- data/lib/lolcommits/plugin/base.rb +4 -8
- data/lib/lolcommits/plugin/configuration_helper.rb +4 -6
- data/lib/lolcommits/plugin_manager.rb +1 -3
- data/lib/lolcommits/runner.rb +21 -24
- data/lib/lolcommits/test_helpers/fake_io.rb +0 -2
- data/lib/lolcommits/test_helpers/git_repo.rb +3 -5
- data/lib/lolcommits/vcs_info.rb +2 -4
- data/lib/lolcommits/version.rb +1 -3
- data/lib/lolcommits.rb +26 -30
- metadata +42 -83
- data/.gitattributes +0 -1
- data/.github/workflows/build.yml +0 -64
- data/.github/workflows/push_gem.yml +0 -25
- data/.gitignore +0 -15
- data/.rubocop_todo.yml +0 -97
- data/.travis.yml +0 -45
- data/CHANGELOG.md +0 -637
- data/CODE_OF_CONDUCT.md +0 -73
- data/CONTRIBUTING.md +0 -44
- data/Gemfile +0 -4
- data/PULL_REQUEST_TEMPLATE.md +0 -16
- data/Rakefile +0 -53
- data/bin/console +0 -12
- data/features/bugs.feature +0 -52
- data/features/lolcommits.feature +0 -376
- data/features/step_definitions/lolcommits_steps.rb +0 -238
- data/features/support/env.rb +0 -56
- data/features/support/path_helpers.rb +0 -38
- data/lolcommits.gemspec +0 -62
- data/test/assets/test_image.jpg +0 -0
- data/test/assets/test_video.mp4 +0 -0
- data/test/images/test_image.jpg +0 -0
- data/test/permissions_test.rb +0 -19
- data/test/test_helper.rb +0 -4
data/lib/lolcommits/platform.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'mini_magick'
|
4
|
-
require 'rbconfig'
|
1
|
+
require "mini_magick"
|
2
|
+
require "rbconfig"
|
5
3
|
|
6
4
|
module Lolcommits
|
7
5
|
class Platform
|
8
6
|
# The capturer class constant to use
|
9
7
|
# @return Class
|
10
8
|
def self.capturer_class(animate: false)
|
11
|
-
if ENV[
|
12
|
-
const_get(ENV[
|
9
|
+
if ENV["LOLCOMMITS_CAPTURER"]
|
10
|
+
const_get(ENV["LOLCOMMITS_CAPTURER"])
|
13
11
|
elsif platform_mac?
|
14
12
|
animate ? CaptureMacVideo : CaptureMac
|
15
13
|
elsif platform_linux?
|
@@ -19,20 +17,20 @@ module Lolcommits
|
|
19
17
|
elsif platform_cygwin?
|
20
18
|
CaptureCygwin
|
21
19
|
else
|
22
|
-
raise
|
20
|
+
raise "Unknown / Unsupported Platform."
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
26
24
|
# Are we on a Mac platform?
|
27
25
|
# @return Boolean
|
28
26
|
def self.platform_mac?
|
29
|
-
host_os.include?(
|
27
|
+
host_os.include?("darwin")
|
30
28
|
end
|
31
29
|
|
32
30
|
# Are we on a Linux platform?
|
33
31
|
# @return Boolean
|
34
32
|
def self.platform_linux?
|
35
|
-
host_os.include?(
|
33
|
+
host_os.include?("linux")
|
36
34
|
end
|
37
35
|
|
38
36
|
# Are we on a Windows platform?
|
@@ -44,13 +42,13 @@ module Lolcommits
|
|
44
42
|
# Are we on a Cygwin platform?
|
45
43
|
# @return Boolean
|
46
44
|
def self.platform_cygwin?
|
47
|
-
host_os.include?(
|
45
|
+
host_os.include?("cygwin")
|
48
46
|
end
|
49
47
|
|
50
48
|
# return host_os identifier from the RbConfig::CONFIG constant
|
51
49
|
# @return String
|
52
50
|
def self.host_os
|
53
|
-
ENV[
|
51
|
+
ENV["LOLCOMMITS_FAKE_HOST_OS"] || RbConfig::CONFIG["host_os"].downcase
|
54
52
|
end
|
55
53
|
|
56
54
|
# Is the platform capable of capturing animated GIFs from webcam?
|
@@ -62,9 +60,7 @@ module Lolcommits
|
|
62
60
|
# Is a valid install of imagemagick present on the system?
|
63
61
|
# @return Boolean
|
64
62
|
def self.valid_imagemagick_installed?
|
65
|
-
return false unless command_which(
|
66
|
-
|
67
|
-
return false unless command_which('mogrify')
|
63
|
+
return false unless command_which("magick")
|
68
64
|
|
69
65
|
# cli_version check will throw a MiniMagick::Error exception if IM is not
|
70
66
|
# installed in PATH, since it attempts to parse output from `identify`
|
@@ -78,7 +74,7 @@ module Lolcommits
|
|
78
74
|
# @note For now, this just checks for presence, any version should work.
|
79
75
|
# @return Boolean
|
80
76
|
def self.valid_ffmpeg_installed?
|
81
|
-
command_which(
|
77
|
+
command_which("ffmpeg")
|
82
78
|
end
|
83
79
|
|
84
80
|
# Cross-platform way of finding an executable in the $PATH.
|
@@ -91,8 +87,8 @@ module Lolcommits
|
|
91
87
|
#
|
92
88
|
# @return Boolean
|
93
89
|
def self.command_which(cmd, only_path: false)
|
94
|
-
exts = ENV[
|
95
|
-
ENV[
|
90
|
+
exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [ "" ]
|
91
|
+
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
|
96
92
|
exts.each do |ext|
|
97
93
|
exe = "#{path}/#{cmd}#{ext}"
|
98
94
|
return only_path ? path : exe if File.executable? exe
|
@@ -123,7 +119,7 @@ module Lolcommits
|
|
123
119
|
# TODO: handle other platforms here (linux/windows) e.g with ffmpeg -list_devices
|
124
120
|
return unless Platform.platform_mac?
|
125
121
|
|
126
|
-
videosnap = File.join(Configuration::LOLCOMMITS_ROOT,
|
122
|
+
videosnap = File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "videosnap", "videosnap")
|
127
123
|
`#{videosnap} -l`
|
128
124
|
end
|
129
125
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'lolcommits/plugin/configuration_helper'
|
1
|
+
require "lolcommits/plugin/configuration_helper"
|
4
2
|
|
5
3
|
module Lolcommits
|
6
4
|
module Plugin
|
@@ -13,7 +11,7 @@ module Lolcommits
|
|
13
11
|
self.runner = runner
|
14
12
|
self.name = name || self.class.to_s
|
15
13
|
self.configuration = config || {}
|
16
|
-
self.options = [:enabled]
|
14
|
+
self.options = [ :enabled ]
|
17
15
|
end
|
18
16
|
|
19
17
|
def run_pre_capture; end
|
@@ -51,9 +49,7 @@ module Lolcommits
|
|
51
49
|
#
|
52
50
|
# @return [Hash] the configured plugin options
|
53
51
|
def configure_options!
|
54
|
-
configure_option_hash(
|
55
|
-
options.map { |option| [option, nil] }.to_h.merge(default_options)
|
56
|
-
)
|
52
|
+
configure_option_hash(options.map { |option| [ option, nil ] }.to_h.merge(default_options))
|
57
53
|
end
|
58
54
|
|
59
55
|
def default_options
|
@@ -103,7 +99,7 @@ module Lolcommits
|
|
103
99
|
def configure_option_hash(option_hash, spacing_count = 0)
|
104
100
|
option_hash.keys.reduce({}) do |acc, option|
|
105
101
|
option_value = option_hash[option]
|
106
|
-
prefix =
|
102
|
+
prefix = " " * spacing_count
|
107
103
|
if option_value.is_a?(Hash)
|
108
104
|
puts "#{prefix}#{option}:\n"
|
109
105
|
acc.merge(option => configure_option_hash(option_value, (spacing_count + 1)))
|
@@ -1,13 +1,11 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
module Lolcommits
|
4
2
|
module Plugin
|
5
3
|
module ConfigurationHelper
|
6
4
|
# handle for bools, strings, ints and blanks from user input
|
7
5
|
def parse_user_input(str)
|
8
|
-
if
|
6
|
+
if "true".casecmp(str).zero?
|
9
7
|
true
|
10
|
-
elsif
|
8
|
+
elsif "false".casecmp(str).zero?
|
11
9
|
false
|
12
10
|
elsif str =~ /^[0-9]+$/
|
13
11
|
str.to_i
|
@@ -29,7 +27,7 @@ module Lolcommits
|
|
29
27
|
# ]
|
30
28
|
# User will be asked for Organization, can tab to autocomplete, and chosen
|
31
29
|
# value is returned.
|
32
|
-
def prompt_autocomplete_hash(prompt, items, name:
|
30
|
+
def prompt_autocomplete_hash(prompt, items, name: "name", value: "value", suggest_words: 5)
|
33
31
|
words = items.map { |item| item[name] }.sort
|
34
32
|
puts "e.g. #{words.take(suggest_words).join(', ')}" if suggest_words.positive?
|
35
33
|
completed_input = gets_autocomplete(prompt, words)
|
@@ -40,7 +38,7 @@ module Lolcommits
|
|
40
38
|
|
41
39
|
def gets_autocomplete(prompt, words)
|
42
40
|
completion_handler = proc { |s| words.grep(/^#{Regexp.escape(s)}/) }
|
43
|
-
Readline.completion_append_character =
|
41
|
+
Readline.completion_append_character = ""
|
44
42
|
Readline.completion_proc = completion_handler
|
45
43
|
|
46
44
|
while (line = Readline.readline(prompt, true).strip)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
module Lolcommits
|
4
2
|
class PluginManager
|
5
3
|
GEM_NAME_PREFIX = /^#{Lolcommits::GEM_NAME}-/
|
@@ -62,7 +60,7 @@ module Lolcommits
|
|
62
60
|
|
63
61
|
def gem_list
|
64
62
|
Gem.refresh
|
65
|
-
Gem::Specification.respond_to?(:each) ? Gem::Specification : Gem.source_index.find_name(
|
63
|
+
Gem::Specification.respond_to?(:each) ? Gem::Specification : Gem.source_index.find_name("")
|
66
64
|
end
|
67
65
|
end
|
68
66
|
end
|
data/lib/lolcommits/runner.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'lolcommits/platform'
|
4
|
-
require 'lolcommits/animated_gif'
|
1
|
+
require "lolcommits/platform"
|
2
|
+
require "lolcommits/animated_gif"
|
5
3
|
|
6
4
|
module Lolcommits
|
7
5
|
class Runner
|
@@ -30,7 +28,7 @@ module Lolcommits
|
|
30
28
|
|
31
29
|
self.capture_path = config.capture_path(lolcommit_ext)
|
32
30
|
self.lolcommit_path = config.sha_path(sha, lolcommit_ext)
|
33
|
-
self.lolcommit_gif_path = config.sha_path(sha,
|
31
|
+
self.lolcommit_gif_path = config.sha_path(sha, "gif") if capture_gif
|
34
32
|
end
|
35
33
|
|
36
34
|
def run
|
@@ -41,7 +39,7 @@ module Lolcommits
|
|
41
39
|
|
42
40
|
# capture must exist to run post capture methods
|
43
41
|
unless File.exist?(capture_path)
|
44
|
-
raise
|
42
|
+
raise "failed to capture any image or video!"
|
45
43
|
end
|
46
44
|
|
47
45
|
run_post_capture
|
@@ -50,7 +48,7 @@ module Lolcommits
|
|
50
48
|
debug("#{e.class}: #{e.message}")
|
51
49
|
exit 1
|
52
50
|
ensure
|
53
|
-
debug
|
51
|
+
debug "running cleanup"
|
54
52
|
FileUtils.rm_f(capture_path)
|
55
53
|
end
|
56
54
|
|
@@ -63,15 +61,17 @@ module Lolcommits
|
|
63
61
|
end
|
64
62
|
|
65
63
|
base = MiniMagick::Image.open(source_path)
|
66
|
-
png_tempfile = MiniMagick::Utilities.tempfile(
|
64
|
+
png_tempfile = MiniMagick::Utilities.tempfile(".png")
|
67
65
|
debug("creating a new empty overlay png for lolcommit (#{base.dimensions.join('x')})")
|
68
66
|
|
69
|
-
MiniMagick
|
70
|
-
|
71
|
-
|
72
|
-
|
67
|
+
MiniMagick.convert do |convert|
|
68
|
+
convert.size "#{base.width}x#{base.height}"
|
69
|
+
convert.xc "transparent"
|
70
|
+
convert << png_tempfile.path
|
73
71
|
end
|
74
72
|
|
73
|
+
debug "mehhh!"
|
74
|
+
|
75
75
|
MiniMagick::Image.open(png_tempfile.path)
|
76
76
|
end
|
77
77
|
end
|
@@ -94,7 +94,7 @@ module Lolcommits
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def run_capture
|
97
|
-
puts
|
97
|
+
puts "*** Preserving this moment in history." unless capture_stealth
|
98
98
|
capturer = Platform.capturer_class(animate: !capture_image?).new(
|
99
99
|
capture_path: capture_path,
|
100
100
|
capture_device: capture_device,
|
@@ -119,10 +119,7 @@ module Lolcommits
|
|
119
119
|
# optionally create animated gif
|
120
120
|
return unless capture_gif
|
121
121
|
|
122
|
-
AnimatedGif.new.create(
|
123
|
-
video_path: lolcommit_path,
|
124
|
-
output_path: lolcommit_gif_path
|
125
|
-
)
|
122
|
+
AnimatedGif.new.create(video_path: lolcommit_path, output_path: lolcommit_gif_path)
|
126
123
|
|
127
124
|
# done if we are capturing both video and gif
|
128
125
|
return if capture_video
|
@@ -145,9 +142,9 @@ module Lolcommits
|
|
145
142
|
debug "resizing raw image (#{image.dimensions.join('x')}) to #{lolcommit_path} (640x480)"
|
146
143
|
# hacky resize to fill bounds
|
147
144
|
image.combine_options do |c|
|
148
|
-
c.resize
|
149
|
-
c.gravity
|
150
|
-
c.extent
|
145
|
+
c.resize "640x480^"
|
146
|
+
c.gravity "center"
|
147
|
+
c.extent "640x480"
|
151
148
|
end
|
152
149
|
image.write(lolcommit_path)
|
153
150
|
else
|
@@ -157,10 +154,10 @@ module Lolcommits
|
|
157
154
|
end
|
158
155
|
|
159
156
|
def apply_overlay
|
160
|
-
debug
|
157
|
+
debug "applying overlay to lolcommit"
|
161
158
|
if capture_image?
|
162
159
|
MiniMagick::Image.open(lolcommit_path).composite(overlay) do |c|
|
163
|
-
c.gravity
|
160
|
+
c.gravity "center"
|
164
161
|
end.write(lolcommit_path)
|
165
162
|
else
|
166
163
|
system_call "ffmpeg -v quiet -nostats -i #{capture_path} -i #{overlay.path} \
|
@@ -171,9 +168,9 @@ module Lolcommits
|
|
171
168
|
|
172
169
|
def lolcommit_ext
|
173
170
|
if capture_image?
|
174
|
-
|
171
|
+
"jpg"
|
175
172
|
else
|
176
|
-
|
173
|
+
"mp4"
|
177
174
|
end
|
178
175
|
end
|
179
176
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
module Lolcommits
|
4
2
|
module TestHelpers
|
5
3
|
module GitRepo
|
@@ -8,11 +6,11 @@ module Lolcommits
|
|
8
6
|
end
|
9
7
|
|
10
8
|
def repo_path
|
11
|
-
|
9
|
+
"/tmp/lolcommits-plugin-test-repo"
|
12
10
|
end
|
13
11
|
|
14
12
|
def repo_exists?
|
15
|
-
File.directory?(File.expand_path(repo_path,
|
13
|
+
File.directory?(File.expand_path(repo_path, ".git"))
|
16
14
|
end
|
17
15
|
|
18
16
|
def last_commit
|
@@ -25,7 +23,7 @@ module Lolcommits
|
|
25
23
|
`git init --quiet #{repo_path}`
|
26
24
|
end
|
27
25
|
|
28
|
-
def commit_repo_with_message(message =
|
26
|
+
def commit_repo_with_message(message = "test message", file_name: "test.txt", file_content: "testing")
|
29
27
|
setup_repo unless repo_exists?
|
30
28
|
`echo '#{file_content}' >> #{repo_path}/#{file_name}`
|
31
29
|
`cd #{repo_path} && git add #{file_name}`
|
data/lib/lolcommits/vcs_info.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
module Lolcommits
|
4
2
|
class VCSInfo
|
5
|
-
def self.repo_root?(path =
|
3
|
+
def self.repo_root?(path = ".")
|
6
4
|
GitInfo.repo_root?(path) || MercurialInfo.repo_root?(path)
|
7
5
|
end
|
8
6
|
|
9
|
-
def self.local_name(path =
|
7
|
+
def self.local_name(path = ".")
|
10
8
|
if GitInfo.repo_root?(path)
|
11
9
|
GitInfo.local_name(path)
|
12
10
|
elsif MercurialInfo.repo_root?(path)
|
data/lib/lolcommits/version.rb
CHANGED
data/lib/lolcommits.rb
CHANGED
@@ -1,41 +1,37 @@
|
|
1
|
-
|
1
|
+
require "mini_magick"
|
2
|
+
require "fileutils"
|
3
|
+
require "git"
|
4
|
+
require "open3"
|
5
|
+
require "date"
|
6
|
+
require "mercurial-ruby"
|
2
7
|
|
3
|
-
|
4
|
-
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
|
13
|
-
require 'lolcommits/version'
|
14
|
-
require 'lolcommits/configuration'
|
15
|
-
require 'lolcommits/capturer'
|
16
|
-
require 'lolcommits/vcs_info'
|
17
|
-
require 'lolcommits/installation'
|
18
|
-
require 'lolcommits/platform'
|
19
|
-
require 'lolcommits/gem_plugin'
|
20
|
-
require 'lolcommits/plugin_manager'
|
21
|
-
require 'lolcommits/plugin/base'
|
8
|
+
require "lolcommits/version"
|
9
|
+
require "lolcommits/cli"
|
10
|
+
require "lolcommits/configuration"
|
11
|
+
require "lolcommits/capturer"
|
12
|
+
require "lolcommits/vcs_info"
|
13
|
+
require "lolcommits/installation"
|
14
|
+
require "lolcommits/platform"
|
15
|
+
require "lolcommits/gem_plugin"
|
16
|
+
require "lolcommits/plugin_manager"
|
17
|
+
require "lolcommits/plugin/base"
|
22
18
|
|
23
19
|
# after lolcommits/platform, so that we can do platform-conditional override
|
24
|
-
require
|
25
|
-
require
|
20
|
+
require "core_ext/mercurial-ruby/command"
|
21
|
+
require "core_ext/mercurial-ruby/shell"
|
26
22
|
|
27
23
|
# String#encode patched to be Ruby 3.0+ compatible
|
28
|
-
require
|
24
|
+
require "core_ext/mercurial-ruby/changed_file"
|
29
25
|
# Mercurial::ConfigFile#exists? patched to be Ruby 3.2+ compatible
|
30
|
-
require
|
26
|
+
require "core_ext/mercurial-ruby/config_file"
|
31
27
|
# Mercurial::Repository.open patched to be Ruby 3.2+ compatible
|
32
|
-
require
|
28
|
+
require "core_ext/mercurial-ruby/repository"
|
33
29
|
|
34
30
|
# backends
|
35
|
-
require
|
36
|
-
require
|
37
|
-
require
|
38
|
-
require
|
31
|
+
require "lolcommits/backends/installation_git"
|
32
|
+
require "lolcommits/backends/installation_mercurial"
|
33
|
+
require "lolcommits/backends/git_info"
|
34
|
+
require "lolcommits/backends/mercurial_info"
|
39
35
|
|
40
36
|
# require runner after all the plugins have been required
|
41
|
-
require
|
37
|
+
require "lolcommits/runner"
|