Class: Lolcommits::Runner
- Inherits:
-
Object
- Object
- Lolcommits::Runner
- Defined in:
- lib/lolcommits/runner.rb
Instance Attribute Summary collapse
-
#capture_delay ⇒ Object
Returns the value of attribute capture_delay.
-
#capture_device ⇒ Object
Returns the value of attribute capture_device.
-
#capture_duration ⇒ Object
Returns the value of attribute capture_duration.
-
#capture_gif ⇒ Object
Returns the value of attribute capture_gif.
-
#capture_path ⇒ Object
Returns the value of attribute capture_path.
-
#capture_stealth ⇒ Object
Returns the value of attribute capture_stealth.
-
#capture_video ⇒ Object
Returns the value of attribute capture_video.
-
#config ⇒ Object
Returns the value of attribute config.
-
#lolcommit_gif_path ⇒ Object
Returns the value of attribute lolcommit_gif_path.
-
#lolcommit_path ⇒ Object
Returns the value of attribute lolcommit_path.
-
#message ⇒ Object
Returns the value of attribute message.
-
#sha ⇒ Object
Returns the value of attribute sha.
-
#vcs_info ⇒ Object
Returns the value of attribute vcs_info.
Instance Method Summary collapse
- #capture_image? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Runner
constructor
A new instance of Runner.
-
#overlay ⇒ Object
return MiniMagick overlay png for manipulation (or create one).
- #run ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Runner
Returns a new instance of Runner.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lolcommits/runner.rb', line 11 def initialize(attributes = {}) attributes.each do |attr, val| send("#{attr}=", val) end if GitInfo.repo_root? self.vcs_info = GitInfo.new elsif MercurialInfo.repo_root? self.vcs_info = MercurialInfo.new end if vcs_info self.sha ||= vcs_info.sha self. ||= vcs_info. end return unless config self.capture_path = config.capture_path(lolcommit_ext) self.lolcommit_path = config.sha_path(sha, lolcommit_ext) self.lolcommit_gif_path = config.sha_path(sha, "gif") if capture_gif end |
Instance Attribute Details
#capture_delay ⇒ Object
Returns the value of attribute capture_delay.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def capture_delay @capture_delay end |
#capture_device ⇒ Object
Returns the value of attribute capture_device.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def capture_device @capture_device end |
#capture_duration ⇒ Object
Returns the value of attribute capture_duration.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def capture_duration @capture_duration end |
#capture_gif ⇒ Object
Returns the value of attribute capture_gif.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def capture_gif @capture_gif end |
#capture_path ⇒ Object
Returns the value of attribute capture_path.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def capture_path @capture_path end |
#capture_stealth ⇒ Object
Returns the value of attribute capture_stealth.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def capture_stealth @capture_stealth end |
#capture_video ⇒ Object
Returns the value of attribute capture_video.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def capture_video @capture_video end |
#config ⇒ Object
Returns the value of attribute config.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def config @config end |
#lolcommit_gif_path ⇒ Object
Returns the value of attribute lolcommit_gif_path.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def lolcommit_gif_path @lolcommit_gif_path end |
#lolcommit_path ⇒ Object
Returns the value of attribute lolcommit_path.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def lolcommit_path @lolcommit_path end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def @message end |
#sha ⇒ Object
Returns the value of attribute sha.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def sha @sha end |
#vcs_info ⇒ Object
Returns the value of attribute vcs_info.
6 7 8 |
# File 'lib/lolcommits/runner.rb', line 6 def vcs_info @vcs_info end |
Instance Method Details
#capture_image? ⇒ Boolean
79 80 81 |
# File 'lib/lolcommits/runner.rb', line 79 def capture_image? capture_duration.to_i.zero? end |
#overlay ⇒ Object
return MiniMagick overlay png for manipulation (or create one)
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/lolcommits/runner.rb', line 56 def @overlay ||= begin source_path = capture_image? ? lolcommit_path : capture_path unless File.exist?(source_path) raise "too early to overlay, capture doesn't exist yet" end base = MiniMagick::Image.open(source_path) png_tempfile = MiniMagick::Utilities.tempfile(".png") debug("creating a new empty overlay png for lolcommit (#{base.dimensions.join('x')})") MiniMagick.convert do |convert| convert.size "#{base.width}x#{base.height}" convert.xc "transparent" convert << png_tempfile.path end debug "mehhh!" MiniMagick::Image.open(png_tempfile.path) end end |
#run ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/lolcommits/runner.rb', line 34 def run execute_plugins_for(:pre_capture) # main capture run_capture # capture must exist to run post capture methods unless File.exist?(capture_path) raise "failed to capture any image or video!" end run_post_capture run_capture_ready rescue StandardError => e debug("#{e.class}: #{e.}") exit 1 ensure debug "running cleanup" FileUtils.rm_f(capture_path) end |