lolcommits 0.17.2 → 0.17.3

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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/{build.yml → ci.yml} +29 -24
  3. data/.gitignore +2 -0
  4. data/.quickhook/pre-commit/ruby-lint +3 -0
  5. data/.rubocop.yml +309 -9
  6. data/CHANGELOG.md +45 -234
  7. data/CODE_OF_CONDUCT.md +10 -12
  8. data/Gemfile +4 -2
  9. data/README.md +14 -26
  10. data/Rakefile +11 -48
  11. data/bin/cucumber +25 -0
  12. data/bin/lolcommits +2 -12
  13. data/bin/rubocop +25 -0
  14. data/features/step_definitions/lolcommits_steps.rb +0 -2
  15. data/features/support/env.rb +1 -3
  16. data/features/support/path_helpers.rb +2 -4
  17. data/lib/core_ext/mercurial-ruby/changed_file.rb +1 -3
  18. data/lib/core_ext/mercurial-ruby/command.rb +2 -4
  19. data/lib/core_ext/mercurial-ruby/config_file.rb +0 -2
  20. data/lib/core_ext/mercurial-ruby/repository.rb +0 -2
  21. data/lib/core_ext/mercurial-ruby/shell.rb +1 -3
  22. data/lib/lolcommits/animated_gif.rb +12 -7
  23. data/lib/lolcommits/backends/git_info.rb +6 -8
  24. data/lib/lolcommits/backends/installation_git.rb +8 -10
  25. data/lib/lolcommits/backends/installation_mercurial.rb +8 -10
  26. data/lib/lolcommits/backends/mercurial_info.rb +9 -11
  27. data/lib/lolcommits/capturer/capture_cygwin.rb +0 -2
  28. data/lib/lolcommits/capturer/capture_fake.rb +2 -4
  29. data/lib/lolcommits/capturer/capture_linux.rb +4 -6
  30. data/lib/lolcommits/capturer/capture_linux_video.rb +1 -3
  31. data/lib/lolcommits/capturer/capture_mac.rb +2 -4
  32. data/lib/lolcommits/capturer/capture_mac_video.rb +1 -3
  33. data/lib/lolcommits/capturer/capture_windows.rb +2 -4
  34. data/lib/lolcommits/capturer/capture_windows_video.rb +5 -7
  35. data/lib/lolcommits/capturer.rb +9 -12
  36. data/lib/lolcommits/cli/fatals.rb +11 -16
  37. data/lib/lolcommits/cli/launcher.rb +1 -3
  38. data/lib/lolcommits/cli/process_runner.rb +2 -4
  39. data/lib/lolcommits/cli/timelapse_gif.rb +7 -9
  40. data/lib/lolcommits/cli.rb +6 -6
  41. data/lib/lolcommits/configuration.rb +32 -36
  42. data/lib/lolcommits/gem_plugin.rb +5 -7
  43. data/lib/lolcommits/installation.rb +5 -7
  44. data/lib/lolcommits/platform.rb +14 -18
  45. data/lib/lolcommits/plugin/base.rb +4 -8
  46. data/lib/lolcommits/plugin/configuration_helper.rb +4 -6
  47. data/lib/lolcommits/plugin_manager.rb +1 -3
  48. data/lib/lolcommits/runner.rb +16 -21
  49. data/lib/lolcommits/test_helpers/fake_io.rb +0 -2
  50. data/lib/lolcommits/test_helpers/git_repo.rb +3 -5
  51. data/lib/lolcommits/vcs_info.rb +2 -4
  52. data/lib/lolcommits/version.rb +1 -3
  53. data/lib/lolcommits.rb +26 -30
  54. data/lolcommits.gemspec +23 -24
  55. data/test/permissions_test.rb +7 -9
  56. data/test/test_helper.rb +2 -4
  57. metadata +62 -53
  58. data/.gitattributes +0 -1
  59. data/.github/workflows/push_gem.yml +0 -25
  60. data/.rubocop_todo.yml +0 -97
  61. data/.travis.yml +0 -45
  62. data/bin/console +0 -12
data/bin/cucumber ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'cucumber' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
10
+
11
+ bundle_binstub = File.expand_path("bundle", __dir__)
12
+
13
+ if File.file?(bundle_binstub)
14
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
15
+ load(bundle_binstub)
16
+ else
17
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
18
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
19
+ end
20
+ end
21
+
22
+ require "rubygems"
23
+ require "bundler/setup"
24
+
25
+ load Gem.bin_path("cucumber", "cucumber")
data/bin/lolcommits CHANGED
@@ -1,22 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- begin
4
- require 'lolcommits'
5
- rescue LoadError
6
- require 'rubygems'
7
- require 'lolcommits'
8
- end
9
-
10
- require 'optparse'
11
- require 'optparse_plus'
12
- require 'lolcommits/cli.rb'
3
+ require 'lolcommits'
13
4
 
14
5
  # allow logging from everywhere
15
6
  include OptparsePlus::CLILogging
16
7
 
17
8
  class App
18
9
  include OptparsePlus::Main
19
-
20
10
  include Lolcommits
21
11
  include Lolcommits::CLI
22
12
 
@@ -37,7 +27,7 @@ class App
37
27
  end
38
28
 
39
29
  plugin_manager = PluginManager.init
40
- config = Configuration.new(plugin_manager, test_mode: options[:test])
30
+ config = Configuration.new(plugin_manager, test_mode: options[:test])
41
31
 
42
32
  if options[:version]
43
33
  puts Lolcommits::VERSION
data/bin/rubocop ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rubocop' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
10
+
11
+ bundle_binstub = File.expand_path("bundle", __dir__)
12
+
13
+ if File.file?(bundle_binstub)
14
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
15
+ load(bundle_binstub)
16
+ else
17
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
18
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
19
+ end
20
+ end
21
+
22
+ require "rubygems"
23
+ require "bundler/setup"
24
+
25
+ load Gem.bin_path("rubocop", "rubocop")
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'fileutils'
4
2
  require 'aruba/api'
5
3
 
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'aruba/cucumber'
4
2
  require 'optparse_plus/cucumber'
5
3
  require 'open3'
@@ -47,7 +45,7 @@ end
47
45
 
48
46
  # adjust the path so tests dont see a global imagemagick install
49
47
  Before('@fake-no-imagemagick') do
50
- reject_paths_with_cmd('mogrify')
48
+ reject_paths_with_cmd('magick')
51
49
  end
52
50
 
53
51
  # adjust the path so tests dont see a global ffmpeg install
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'fileutils'
4
2
  require 'aruba/api'
5
3
  require 'lolcommits/platform'
@@ -10,9 +8,9 @@ module PathHelpers
10
8
  tmpbindir = expand_path('./bin')
11
9
  FileUtils.mkdir_p tmpbindir
12
10
 
13
- preseve_cmds_in_path(%w(git mplayer), tmpbindir)
11
+ preseve_cmds_in_path(%w[git mplayer], tmpbindir)
14
12
 
15
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
13
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [ '' ]
16
14
  newpaths = ENV['PATH'].split(File::PATH_SEPARATOR).reject do |path|
17
15
  found_cmd = false
18
16
  exts.each do |ext|
@@ -1,12 +1,10 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Mercurial
4
2
  class ChangedFile
5
3
  private
6
4
 
7
5
  def enforce_unicode(str)
8
6
  # String#encode patched to be Ruby 3.0+ compatible
9
- str.encode('utf-8', invalid: :replace, undef: :replace, replace: '?')
7
+ str.encode("utf-8", invalid: :replace, undef: :replace, replace: "?")
10
8
  end
11
9
  end
12
10
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  if Lolcommits::Platform.platform_windows?
4
2
  module Mercurial
5
3
  class Command
@@ -9,8 +7,8 @@ if Lolcommits::Platform.platform_windows?
9
7
  def execution_proc
10
8
  proc do
11
9
  debug(command)
12
- result = ''
13
- error = ''
10
+ result = ""
11
+ error = ""
14
12
  status = nil
15
13
  Open3.popen3(command) do |_stdin, stdout, stderr, wait_thread|
16
14
  Timeout.timeout(timeout) do
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Mercurial
4
2
  class ConfigFile
5
3
  def exists?
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Mercurial
4
2
  class Repository
5
3
  def self.open(destination)
@@ -1,11 +1,9 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Mercurial
4
2
  class Shell
5
3
  # windows command line doesn't like single quotes
6
4
  def self.interpolate_arguments(cmd_with_args)
7
5
  cmd_with_args.shift.tap do |cmd|
8
- cmd.gsub!('?') do
6
+ cmd.gsub!("?") do
9
7
  if Lolcommits::Platform.platform_windows?
10
8
  "\"#{cmd_with_args.shift}\""
11
9
  else
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  class AnimatedGif
5
3
  def create(video_path:, output_path:)
@@ -20,12 +18,19 @@ module Lolcommits
20
18
  # create the looping animated gif from frames (delete frame files except every #{skip} frame)
21
19
  Dir["#{frames_dir}/*.png"].each do |frame_filename|
22
20
  basename = File.basename(frame_filename)
23
- frame_number = basename.split('.').first.to_i
21
+ frame_number = basename.split(".").first.to_i
24
22
  File.delete(frame_filename) if frame_number % skip != 0
25
23
  end
26
24
 
27
- # convert to animated gif with delay and gif optimisation
28
- system_call "convert -layers OptimizeTransparency -delay #{delay} -loop 0 \"#{frames_dir}/*.png\" -coalesce \"#{output_path}\""
25
+ # convert to animated gif with delay and transparency optimising
26
+ MiniMagick.convert do |convert|
27
+ convert << "#{frames_dir}/*.png"
28
+ convert.layers "OptimizeTransparency"
29
+ convert.delay delay
30
+ convert.loop 0
31
+ convert.coalesce
32
+ convert << output_path
33
+ end
29
34
 
30
35
  # remove tmp frames dir
31
36
  FileUtils.rm_rf(frames_dir)
@@ -38,13 +43,13 @@ module Lolcommits
38
43
  end
39
44
 
40
45
  def null_string
41
- Lolcommits::Platform.platform_windows? ? 'nul' : '/dev/null'
46
+ Lolcommits::Platform.platform_windows? ? "nul" : "/dev/null"
42
47
  end
43
48
 
44
49
  def frame_delay(fps, skip)
45
50
  # calculate frame delay
46
51
  delay = ((100.0 * skip) / fps.to_f).to_i
47
- [delay, 6].max # hard limit for IE browsers
52
+ [ delay, 6 ].max # hard limit for IE browsers
48
53
  end
49
54
 
50
55
  def video_fps(file)
@@ -1,19 +1,17 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  class GitInfo
5
3
  GIT_URL_REGEX = %r{.*:([/\w-]*).git}
6
4
 
7
- def self.repo_root?(path = '.')
8
- File.directory?(File.join(path, '.git'))
5
+ def self.repo_root?(path = ".")
6
+ File.directory?(File.join(path, ".git"))
9
7
  end
10
8
 
11
- def self.local_name(path = '.')
9
+ def self.local_name(path = ".")
12
10
  File.basename(Git.open(path).dir.to_s)
13
11
  end
14
12
 
15
13
  def initialize
16
- debug 'parsed the following values from commit:'
14
+ debug "parsed the following values from commit:"
17
15
  debug "\t#{message}"
18
16
  debug "\t#{sha}"
19
17
  debug "\t#{repo_internal_path}"
@@ -30,7 +28,7 @@ module Lolcommits
30
28
 
31
29
  def message
32
30
  @message ||= begin
33
- message = last_commit.message || ''
31
+ message = last_commit.message || ""
34
32
  message.split("\n").first
35
33
  end
36
34
  end
@@ -81,7 +79,7 @@ module Lolcommits
81
79
  "#{url.tr(':', '/').gsub(/^git@/, 'https://').gsub(/\.git$/, '')}/commit/"
82
80
  end
83
81
 
84
- def repository(path = '.')
82
+ def repository(path = ".")
85
83
  @repository ||= Git.open(path)
86
84
  end
87
85
 
@@ -1,17 +1,15 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  #
5
3
  # Methods to handle enabling and disabling of lolcommits
6
4
  #
7
5
  class InstallationGit
8
- HOOK_PATH = File.join '.git', 'hooks', 'post-commit'
9
- HOOK_DIR = File.join '.git', 'hooks'
6
+ HOOK_PATH = File.join ".git", "hooks", "post-commit"
7
+ HOOK_DIR = File.join ".git", "hooks"
10
8
 
11
9
  #
12
10
  # IF --ENABLE, DO ENABLE
13
11
  #
14
- def self.do_enable(capture_args = '')
12
+ def self.do_enable(capture_args = "")
15
13
  # its possible a hooks dir doesnt exist, so create it if so
16
14
  Dir.mkdir(HOOK_DIR) unless File.directory?(HOOK_DIR)
17
15
 
@@ -33,7 +31,7 @@ module Lolcommits
33
31
  add_shebang = true
34
32
  end
35
33
 
36
- File.open(HOOK_PATH, add_shebang ? 'w' : 'a') do |f|
34
+ File.open(HOOK_PATH, add_shebang ? "w" : "a") do |f|
37
35
  f.write("#!/bin/sh\n") if add_shebang
38
36
  f.write(hook_script(capture_args))
39
37
  end
@@ -59,9 +57,9 @@ module Lolcommits
59
57
  end
60
58
  end
61
59
 
62
- def self.hook_script(capture_args = '')
63
- ruby_path = Lolcommits::Platform.command_which('ruby', only_path: true)
64
- imagick_path = Lolcommits::Platform.command_which('identify', only_path: true)
60
+ def self.hook_script(capture_args = "")
61
+ ruby_path = Lolcommits::Platform.command_which("ruby", only_path: true)
62
+ imagick_path = Lolcommits::Platform.command_which("identify", only_path: true)
65
63
  capture_cmd = "if [ ! -d \"$GIT_DIR/rebase-merge\" ] && [ \"$LOLCOMMITS_CAPTURE_DISABLED\" != \"true\" ]; then lolcommits --capture #{capture_args}; fi"
66
64
  exports = "GIT_DIR=${GIT_DIR-`git rev-parse --git-dir`} && LANG=\"#{ENV.fetch('LANG', nil)}\" && PATH=\"$PATH:#{ruby_path}:#{imagick_path}\""
67
65
 
@@ -95,7 +93,7 @@ module Lolcommits
95
93
 
96
94
  def self.remove_existing_hook!
97
95
  hook = File.read(HOOK_PATH)
98
- out = File.open(HOOK_PATH, 'w')
96
+ out = File.open(HOOK_PATH, "w")
99
97
  skip = false
100
98
 
101
99
  hook.lines.each do |line|
@@ -1,17 +1,15 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  #
5
3
  # Methods to handle enabling and disabling of lolcommits
6
4
  #
7
5
  class InstallationMercurial
8
- HOOK_SECTION = 'hooks'
9
- HOOK_OPERATIONS = %w(commit record crecord).freeze
6
+ HOOK_SECTION = "hooks"
7
+ HOOK_OPERATIONS = %w[commit record crecord].freeze
10
8
 
11
9
  #
12
10
  # IF --ENABLE, DO ENABLE
13
11
  #
14
- def self.do_enable(capture_args = '')
12
+ def self.do_enable(capture_args = "")
15
13
  if lolcommits_hook_exists?
16
14
  # clear away any existing lolcommits hook
17
15
  remove_existing_hook!
@@ -39,9 +37,9 @@ module Lolcommits
39
37
  end
40
38
  end
41
39
 
42
- def self.hook_script(capture_args = '')
43
- ruby_path = Lolcommits::Platform.command_which('ruby', only_path: true)
44
- imagick_path = Lolcommits::Platform.command_which('identify', only_path: true)
40
+ def self.hook_script(capture_args = "")
41
+ ruby_path = Lolcommits::Platform.command_which("ruby", only_path: true)
42
+ imagick_path = Lolcommits::Platform.command_which("identify", only_path: true)
45
43
  capture_cmd = "if [ \"$LOLCOMMITS_CAPTURE_DISABLED\" != \"true\" ]; then lolcommits --capture #{capture_args}; fi"
46
44
  exports = "LANG=\"#{ENV.fetch('LANG', nil)}\" && PATH=\"$PATH:#{ruby_path}:#{imagick_path}\""
47
45
 
@@ -53,13 +51,13 @@ module Lolcommits
53
51
  end
54
52
 
55
53
  def self.repository
56
- Mercurial::Repository.open('.')
54
+ Mercurial::Repository.open(".")
57
55
  end
58
56
 
59
57
  # does a mercurial hook exist with lolcommits commands?
60
58
  def self.lolcommits_hook_exists?
61
59
  config = repository.config
62
- config.exists? && config.setting_exists?(HOOK_SECTION, 'post-crecord.lolcommits')
60
+ config.exists? && config.setting_exists?(HOOK_SECTION, "post-crecord.lolcommits")
63
61
  end
64
62
 
65
63
  # can we load the hgrc?
@@ -1,26 +1,24 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  class MercurialInfo
5
- def self.repo_root?(path = '.')
6
- File.directory?(File.join(path, '.hg'))
3
+ def self.repo_root?(path = ".")
4
+ File.directory?(File.join(path, ".hg"))
7
5
  end
8
6
 
9
- def self.local_name(path = '.')
7
+ def self.local_name(path = ".")
10
8
  File.basename(File.dirname(Mercurial::Repository.open(path).dothg_path))
11
9
  end
12
10
 
13
11
  def initialize
14
12
  # mercurial sets HG_RESULT for post- hooks
15
- if ENV.key?('HG_RESULT') && ENV['HG_RESULT'] != '0'
16
- debug 'Aborting lolcommits hook from failed operation'
13
+ if ENV.key?("HG_RESULT") && ENV["HG_RESULT"] != "0"
14
+ debug "Aborting lolcommits hook from failed operation"
17
15
  exit 1
18
16
  end
19
17
 
20
18
  Mercurial.configure do |conf|
21
- conf.hg_binary_path = 'hg'
19
+ conf.hg_binary_path = "hg"
22
20
  end
23
- debug 'parsed the following values from commit:'
21
+ debug "parsed the following values from commit:"
24
22
  debug "\t#{message}"
25
23
  debug "\t#{sha}"
26
24
  debug "\t#{repo_internal_path}"
@@ -37,7 +35,7 @@ module Lolcommits
37
35
 
38
36
  def message
39
37
  @message ||= begin
40
- message = last_commit.message || ''
38
+ message = last_commit.message || ""
41
39
  message.split("\n").first
42
40
  end
43
41
  end
@@ -76,7 +74,7 @@ module Lolcommits
76
74
  super("#{self.class}: #{message}")
77
75
  end
78
76
 
79
- def repository(path = '.')
77
+ def repository(path = ".")
80
78
  @repository ||= Mercurial::Repository.open(path)
81
79
  end
82
80
 
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  class CaptureCygwin < CaptureWindows
5
3
  def capture
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  class CaptureFake < Capturer
5
3
  def capture
@@ -9,8 +7,8 @@ module Lolcommits
9
7
  private
10
8
 
11
9
  def test_file
12
- filename = capture_duration.zero? ? 'test_image.jpg' : 'test_video.mp4'
13
- File.join(Configuration::LOLCOMMITS_ROOT, 'test', 'assets', filename)
10
+ filename = capture_duration.zero? ? "test_image.jpg" : "test_video.mp4"
11
+ File.join(Configuration::LOLCOMMITS_ROOT, "test", "assets", filename)
14
12
  end
15
13
  end
16
14
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  class CaptureLinux < Capturer
5
3
  MPLAYER_FPS = 25
@@ -15,13 +13,13 @@ module Lolcommits
15
13
  # multiply the set value (in seconds) by 25
16
14
  frames = delay.to_i * MPLAYER_FPS
17
15
 
18
- debug 'calling out to mplayer to capture image'
16
+ debug "calling out to mplayer to capture image"
19
17
  # mplayer's output is ugly and useless, let's throw it away
20
18
  _stdin, stdout, _stderr = Open3.popen3("mplayer -vo jpeg:outdir=#{tmpdir} #{capture_device_string} -frames #{frames} -fps #{MPLAYER_FPS} tv://")
21
19
  # looks like we still need to read the output for something to happen
22
20
  stdout.read
23
21
 
24
- debug 'calling out to mplayer to capture image'
22
+ debug "calling out to mplayer to capture image"
25
23
 
26
24
  # get last frame from tmpdir (regardless of fps)
27
25
  all_frames = Dir.glob("#{tmpdir}/*.jpg").sort_by do |f|
@@ -29,10 +27,10 @@ module Lolcommits
29
27
  end
30
28
 
31
29
  if all_frames.empty?
32
- debug 'failed to capture any image'
30
+ debug "failed to capture any image"
33
31
  else
34
32
  FileUtils.mv(all_frames.last, capture_path)
35
- debug 'cleaning up'
33
+ debug "cleaning up"
36
34
  end
37
35
 
38
36
  FileUtils.rm_rf(tmpdir)
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  class CaptureLinuxVideo < Capturer
5
3
  def capture
@@ -9,7 +7,7 @@ module Lolcommits
9
7
  private
10
8
 
11
9
  def capture_device_string
12
- capture_device || Dir.glob('/dev/video*').first
10
+ capture_device || Dir.glob("/dev/video*").first
13
11
  end
14
12
  end
15
13
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  class CaptureMac < Capturer
5
3
  def capture
@@ -9,11 +7,11 @@ module Lolcommits
9
7
  private
10
8
 
11
9
  def capture_device_string
12
- capture_device.nil? ? '' : "-d \"#{capture_device}\""
10
+ capture_device.nil? ? "" : "-d \"#{capture_device}\""
13
11
  end
14
12
 
15
13
  def executable_path
16
- File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'imagesnap', 'imagesnap')
14
+ File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "imagesnap", "imagesnap")
17
15
  end
18
16
  end
19
17
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  class CaptureMacVideo < Capturer
5
3
  def capture
@@ -17,7 +15,7 @@ module Lolcommits
17
15
  end
18
16
 
19
17
  def executable_path
20
- File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'videosnap', 'videosnap')
18
+ File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "videosnap", "videosnap")
21
19
  end
22
20
  end
23
21
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  class CaptureWindows < Capturer
5
3
  def capture
@@ -17,12 +15,12 @@ module Lolcommits
17
15
  " /delay #{capture_delay * 1000}"
18
16
  else
19
17
  # DirectShow takes a while to show, default to 3 sec delay
20
- ' /delay 3000'
18
+ " /delay 3000"
21
19
  end
22
20
  end
23
21
 
24
22
  def executable_path
25
- File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'CommandCam', 'CommandCam.exe')
23
+ File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "CommandCam", "CommandCam.exe")
26
24
  end
27
25
  end
28
26
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  class CaptureWindowsVideo < Capturer
5
3
  def capture
@@ -15,24 +13,24 @@ module Lolcommits
15
13
  end
16
14
 
17
15
  def ffpmeg_list_devices_cmd
18
- 'ffmpeg -list_devices true -f dshow -i dummy 2>&1'
16
+ "ffmpeg -list_devices true -f dshow -i dummy 2>&1"
19
17
  end
20
18
 
21
19
  # inspired by this code from @rdp http://tinyurl.com/y7t276bh
22
20
  def device_names
23
21
  @device_names ||= begin
24
22
  names = []
25
- cmd_output = ''
23
+ cmd_output = ""
26
24
  count = 0
27
- while cmd_output.empty? || !cmd_output.split('DirectShow')[2]
25
+ while cmd_output.empty? || !cmd_output.split("DirectShow")[2]
28
26
  cmd_output = system_call(ffpmeg_list_devices_cmd, capture_output: true)
29
27
  count += 1
30
- raise 'failed to find a video capture device with ffmpeg -list_devices' if count == 5
28
+ raise "failed to find a video capture device with ffmpeg -list_devices" if count == 5
31
29
 
32
30
  sleep 0.1
33
31
  end
34
32
  cmd_output.gsub!("\r\n", "\n")
35
- video = cmd_output.split('DirectShow')[1]
33
+ video = cmd_output.split("DirectShow")[1]
36
34
 
37
35
  video.lines.map do |line|
38
36
  names << Regexp.last_match(1) if line =~ /"(.+)"\n/
@@ -1,9 +1,6 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Lolcommits
4
2
  class Capturer
5
- attr_accessor :capture_device, :capture_delay, :capture_duration,
6
- :capture_path
3
+ attr_accessor :capture_device, :capture_delay, :capture_duration, :capture_path
7
4
 
8
5
  def initialize(attributes = {})
9
6
  attributes.each do |attr, val|
@@ -22,11 +19,11 @@ module Lolcommits
22
19
  end
23
20
  end
24
21
 
25
- require 'lolcommits/capturer/capture_mac'
26
- require 'lolcommits/capturer/capture_mac_video'
27
- require 'lolcommits/capturer/capture_linux'
28
- require 'lolcommits/capturer/capture_linux_video'
29
- require 'lolcommits/capturer/capture_windows'
30
- require 'lolcommits/capturer/capture_windows_video'
31
- require 'lolcommits/capturer/capture_cygwin'
32
- require 'lolcommits/capturer/capture_fake'
22
+ require "lolcommits/capturer/capture_mac"
23
+ require "lolcommits/capturer/capture_mac_video"
24
+ require "lolcommits/capturer/capture_linux"
25
+ require "lolcommits/capturer/capture_linux_video"
26
+ require "lolcommits/capturer/capture_windows"
27
+ require "lolcommits/capturer/capture_windows_video"
28
+ require "lolcommits/capturer/capture_cygwin"
29
+ require "lolcommits/capturer/capture_fake"