Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Tested on ruby 1.8.4 and windows

  • Loading branch information...
commit 0f8aa10da12d1aac64550f5cc433c7d63cfaacd4 1 parent fb60598
Ahmed Eldawy authored

Showing 1 changed file with 20 additions and 4 deletions. Show diff stats Hide diff stats

  1. +20 4 lib/quick_magick.rb
24 lib/quick_magick.rb
... ... @@ -1,9 +1,19 @@
  1 +# Define quick magick error
  2 +module QuickMagick
  3 + class QuickMagickError < RuntimeError; end
  4 +end
  5 +
1 6 # check if ImageMagick is installed
2   -status = `identify --version`
3   -raise QuickMagick::QuickMagickError("ImageMagick not installed") if status.empty?
  7 +begin
  8 + x = `identify --version 2>&1`
  9 + raise(QuickMagick::QuickMagickError, "ImageMagick not installed") unless x.index('ImageMagick')
  10 +rescue Errno::ENOENT
  11 + # For Windows machines
  12 + raise(QuickMagick::QuickMagickError, "ImageMagick not installed")
  13 +end
4 14
5 15 module QuickMagick
6   - class QuickMagickError < RuntimeError; end
  16 + # Different geometry flags
7 17 PercentGeometry = "%"
8 18 AspectGeometry = "!"
9 19 LessGeometry = "<"
@@ -11,23 +21,29 @@ class QuickMagickError < RuntimeError; end
11 21 AreaGeometry = "@"
12 22 MinimumGeometry = "^"
13 23
  24 + # Command for solid color
14 25 SolidColor = "xc"
  26 + # Command for linear gradient
15 27 LinearGradient = "gradient"
  28 + # Command for radial gradient
16 29 RadialGradient = "radial-gradient"
17 30
  31 + # Different possible patterns
18 32 Patterns = %w{bricks checkboard circles crosshatch crosshatch30 crosshatch45 fishscales} +
19 33 (0..20).collect {|level| "gray#{level}" } +
20 34 %w{hexagons horizontal horizontalsaw hs_bdiagonal hs_cross hs_diagcross hs_fdiagonal hs_horizontal
21 35 hs_vertical left30 left45 leftshingle octagons right30 right45 rightshingle smallfishscales
22 36 vertical verticalbricks verticalleftshingle verticalrightshingle verticalsaw}
23 37
24   - # generate a random string of specified length
  38 + # Generate a random string of specified length.
  39 + # Used to generate random names for temp files
25 40 def self.random_string(length=10)
26 41 @@CHARS ||= ("a".."z").to_a + ("1".."9").to_a
27 42 Array.new(length, '').collect{@@CHARS[rand(@@CHARS.size)]}.join
28 43 end
29 44 end
30 45
  46 +# For backward compatibility with ruby < 1.8.7
31 47 unless "".respond_to? :start_with?
32 48 class String
33 49 def start_with?(x)

0 comments on commit 0f8aa10

Please sign in to comment.
Something went wrong with that request. Please try again.