Class: Lolcommits::Loltext
- Defined in:
- lib/lolcommits/plugins/loltext.rb
Instance Attribute Summary
Attributes inherited from Plugin
Class Method Summary collapse
Instance Method Summary collapse
-
#enabled? ⇒ Boolean
enabled by default (if no configuration exists).
-
#initialize(runner) ⇒ Loltext
constructor
A new instance of Loltext.
- #run ⇒ Object
Methods inherited from Plugin
#configuration, #configure_options!, #configured?, #debug, #execute, #puts, #valid_configuration?
Constructor Details
#initialize(runner) ⇒ Loltext
Returns a new instance of Loltext.
4 5 6 7 |
# File 'lib/lolcommits/plugins/loltext.rb', line 4 def initialize(runner) super @font_location = runner ? runner.font : nil end |
Class Method Details
.name ⇒ Object
47 48 49 |
# File 'lib/lolcommits/plugins/loltext.rb', line 47 def self.name 'loltext' end |
Instance Method Details
#enabled? ⇒ Boolean
enabled by default (if no configuration exists)
10 11 12 |
# File 'lib/lolcommits/plugins/loltext.rb', line 10 def enabled? !configured? || super end |
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lolcommits/plugins/loltext.rb', line 14 def run font_location = @font_location || File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'fonts', 'Impact.ttf') debug 'Annotating image via MiniMagick' image = MiniMagick::Image.open(self.runner.main_image) image. do |c| c.gravity 'SouthWest' c.fill 'white' c.stroke 'black' c.strokewidth '2' c.pointsize(self.runner.animate? ? '24' : '48') c.interline_spacing '-9' c.font font_location c.annotate '0', clean_msg(self.runner.) end image. do |c| c.gravity 'NorthEast' c.fill 'white' c.stroke 'black' c.strokewidth '2' c.pointsize(self.runner.animate? ? '21' : '32') c.font font_location c.annotate '0', self.runner.sha end debug "Writing changed file to #{self.runner.main_image}" image.write self.runner.main_image end |