skeptick 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +14 -0
- data/README.md +63 -289
- data/lib/skeptick/command.rb +8 -19
- data/lib/skeptick/convert.rb +65 -82
- data/lib/skeptick/core.rb +1 -7
- data/lib/skeptick/dsl_context.rb +32 -0
- data/lib/skeptick/sugar.rb +13 -7
- data/lib/skeptick/sugar/canvas.rb +8 -0
- data/lib/skeptick/sugar/clone.rb +9 -0
- data/lib/skeptick/sugar/compose.rb +50 -0
- data/lib/skeptick/sugar/delete.rb +9 -0
- data/lib/skeptick/sugar/draw.rb +7 -0
- data/lib/skeptick/sugar/font.rb +7 -0
- data/lib/skeptick/sugar/format.rb +7 -0
- data/lib/skeptick/sugar/geometry.rb +25 -31
- data/lib/skeptick/sugar/resized_image.rb +15 -0
- data/lib/skeptick/sugar/rounded_corners_image.rb +42 -0
- data/lib/skeptick/sugar/swap.rb +12 -0
- data/lib/skeptick/sugar/text.rb +11 -0
- data/lib/skeptick/sugar/torn_paper_image.rb +32 -0
- data/lib/skeptick/sugar/write.rb +8 -0
- data/lib/skeptick/version.rb +1 -1
- data/logo.rb +12 -11
- data/refresh_preview.scpt +1 -1
- data/skeptick.gemspec +1 -0
- data/test/convert_test.rb +128 -33
- data/test/sugar/canvas_test.rb +16 -0
- data/test/sugar/clone_test.rb +41 -0
- data/test/sugar/{composition_test.rb → compose_test.rb} +35 -87
- data/test/sugar/delete_test.rb +41 -0
- data/test/sugar/draw_test.rb +11 -0
- data/test/sugar/font_test.rb +11 -0
- data/test/sugar/format_test.rb +12 -0
- data/test/sugar/{resizing_test.rb → resized_image_test.rb} +5 -5
- data/test/sugar/rounded_corners_image_test.rb +53 -0
- data/test/sugar/swap_test.rb +28 -0
- data/test/sugar/text_test.rb +22 -0
- data/test/sugar/torn_paper_image_test.rb +53 -0
- data/test/sugar/write_test.rb +14 -0
- metadata +57 -34
- data/lib/skeptick/chain.rb +0 -55
- data/lib/skeptick/chain/dsl_context.rb +0 -21
- data/lib/skeptick/convert/dsl_context.rb +0 -27
- data/lib/skeptick/helper.rb +0 -26
- data/lib/skeptick/image.rb +0 -69
- data/lib/skeptick/image/dsl_context.rb +0 -29
- data/lib/skeptick/sugar/composition.rb +0 -55
- data/lib/skeptick/sugar/debugging.rb +0 -12
- data/lib/skeptick/sugar/drawing.rb +0 -32
- data/lib/skeptick/sugar/edges.rb +0 -70
- data/lib/skeptick/sugar/formatting.rb +0 -12
- data/lib/skeptick/sugar/resizing.rb +0 -16
- data/lib/skeptick/sugar/sequence_manipulation.rb +0 -43
- data/test/chain_test.rb +0 -94
- data/test/image_test.rb +0 -145
- data/test/sugar/debugging_test.rb +0 -24
- data/test/sugar/drawing_test.rb +0 -86
- data/test/sugar/edges_test.rb +0 -99
- data/test/sugar/formatting_test.rb +0 -19
- data/test/sugar/sequence_manipulation_test.rb +0 -98
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'skeptick/sugar/swap'
|
3
|
+
|
4
|
+
class SwapTest < Skeptick::TestCase
|
5
|
+
include Skeptick
|
6
|
+
|
7
|
+
def test_swap_without_args
|
8
|
+
cmd = convert { swap }
|
9
|
+
assert_equal 'convert +swap miff:-', cmd.to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_swap_with_one_arg_raises_error
|
13
|
+
assert_raises(ArgumentError) do
|
14
|
+
convert{ swap(1) }.to_s
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_swap_with_two_args
|
19
|
+
cmd = convert('foo', 'bar') { swap(1,2) }
|
20
|
+
assert_equal 'convert foo bar -swap 1,2 miff:-', cmd.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_swap_with_three_args_raises_error
|
24
|
+
assert_raises(ArgumentError) do
|
25
|
+
convert{ swap(1,2,3) }.to_s
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'skeptick/sugar/text'
|
3
|
+
|
4
|
+
class TextTest < Skeptick::TestCase
|
5
|
+
include Skeptick
|
6
|
+
|
7
|
+
def test_text_in_convert_without_left_top
|
8
|
+
cmd = convert { text 'Foo bar baz.' }
|
9
|
+
assert_equal 'convert -draw text \'Foo bar baz.\' miff:-', cmd.to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_text_in_convert_with_left_top
|
13
|
+
cmd = convert { text 'Foo bar baz.', left: 7, top: 9 }
|
14
|
+
assert_equal 'convert -draw text 7,9 \'Foo bar baz.\' miff:-',
|
15
|
+
cmd.to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_text_in_convert_with_top_only
|
19
|
+
cmd = convert { text 'Foo bar baz.', top: 9 }
|
20
|
+
assert_equal 'convert -draw text \'Foo bar baz.\' miff:-', cmd.to_s
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'skeptick/sugar/torn_paper_image'
|
3
|
+
|
4
|
+
class TornPaperImageTest < Skeptick::TestCase
|
5
|
+
include Skeptick
|
6
|
+
|
7
|
+
def test_torn_paper_image_without_block_spread_blur_threshold
|
8
|
+
img = torn_paper_image('foo')
|
9
|
+
assert_equal 'convert foo ( +clone -virtual-pixel transparent ' +
|
10
|
+
'-spread 1 -channel A -blur 0x.7 -threshold 50% ) -blur 0x.7 ' +
|
11
|
+
'-compose copy_opacity -composite miff:-', img.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_torn_paper_image_with_block_spread_blur_threshold
|
15
|
+
img = torn_paper_image('foo', spread: 17, blur: '1x4', threshold: 70) do
|
16
|
+
image 'tile:granite:'
|
17
|
+
append '-brightness-contrast', '38x-33'
|
18
|
+
end
|
19
|
+
|
20
|
+
assert_equal 'convert foo ( tile:granite: -brightness-contrast 38x-33 ) ( '\
|
21
|
+
'+clone -virtual-pixel transparent -spread 17 -channel A -blur 1x4 '\
|
22
|
+
'-threshold 70% ) -blur 1x4 -compose copy_opacity -composite miff:-',
|
23
|
+
img.to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_nested_torn_paper_image
|
27
|
+
cmd = convert(to: 'bar') do
|
28
|
+
torn_paper_image('foo')
|
29
|
+
end
|
30
|
+
|
31
|
+
assert_equal 'convert foo ( +clone -virtual-pixel transparent ' +
|
32
|
+
'-spread 1 -channel A -blur 0x.7 -threshold 50% ) -blur 0x.7 -compose ' +
|
33
|
+
'copy_opacity -composite bar', cmd.to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_nested_torn_paper_image_via_lvar_arg
|
37
|
+
img = torn_paper_image('foo')
|
38
|
+
cmd = convert(img, to: 'bar')
|
39
|
+
|
40
|
+
assert_equal 'convert foo ( +clone -virtual-pixel transparent ' +
|
41
|
+
'-spread 1 -channel A -blur 0x.7 -threshold 50% ) -blur 0x.7 -compose ' +
|
42
|
+
'copy_opacity -composite bar', cmd.to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_nested_torn_paper_image_via_lvar_in_block
|
46
|
+
img = torn_paper_image('foo')
|
47
|
+
cmd = convert(to: 'bar') { image(img) }
|
48
|
+
|
49
|
+
assert_equal 'convert foo ( +clone -virtual-pixel transparent ' +
|
50
|
+
'-spread 1 -channel A -blur 0x.7 -threshold 50% ) -blur 0x.7 -compose ' +
|
51
|
+
'copy_opacity -composite bar', cmd.to_s
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'skeptick/sugar/write'
|
3
|
+
|
4
|
+
class WriteTest < Skeptick::TestCase
|
5
|
+
include Skeptick
|
6
|
+
|
7
|
+
def test_write_in_convert
|
8
|
+
cmd = convert('foo') do
|
9
|
+
write 'path'
|
10
|
+
end
|
11
|
+
|
12
|
+
assert_equal 'convert foo -write path miff:-', cmd.to_s
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skeptick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxim Chernyak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: posix-spawn
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.9.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Thin ImageMagick DSL with smart command composition
|
42
56
|
email:
|
43
57
|
- max@bitsonnet.com
|
@@ -52,42 +66,47 @@ files:
|
|
52
66
|
- README.md
|
53
67
|
- Rakefile
|
54
68
|
- lib/skeptick.rb
|
55
|
-
- lib/skeptick/chain.rb
|
56
|
-
- lib/skeptick/chain/dsl_context.rb
|
57
69
|
- lib/skeptick/command.rb
|
58
70
|
- lib/skeptick/convert.rb
|
59
|
-
- lib/skeptick/convert/dsl_context.rb
|
60
71
|
- lib/skeptick/core.rb
|
72
|
+
- lib/skeptick/dsl_context.rb
|
61
73
|
- lib/skeptick/error.rb
|
62
|
-
- lib/skeptick/helper.rb
|
63
|
-
- lib/skeptick/image.rb
|
64
|
-
- lib/skeptick/image/dsl_context.rb
|
65
74
|
- lib/skeptick/railtie.rb
|
66
75
|
- lib/skeptick/sugar.rb
|
67
|
-
- lib/skeptick/sugar/
|
68
|
-
- lib/skeptick/sugar/
|
69
|
-
- lib/skeptick/sugar/
|
70
|
-
- lib/skeptick/sugar/
|
71
|
-
- lib/skeptick/sugar/
|
76
|
+
- lib/skeptick/sugar/canvas.rb
|
77
|
+
- lib/skeptick/sugar/clone.rb
|
78
|
+
- lib/skeptick/sugar/compose.rb
|
79
|
+
- lib/skeptick/sugar/delete.rb
|
80
|
+
- lib/skeptick/sugar/draw.rb
|
81
|
+
- lib/skeptick/sugar/font.rb
|
82
|
+
- lib/skeptick/sugar/format.rb
|
72
83
|
- lib/skeptick/sugar/geometry.rb
|
73
|
-
- lib/skeptick/sugar/
|
74
|
-
- lib/skeptick/sugar/
|
84
|
+
- lib/skeptick/sugar/resized_image.rb
|
85
|
+
- lib/skeptick/sugar/rounded_corners_image.rb
|
86
|
+
- lib/skeptick/sugar/swap.rb
|
87
|
+
- lib/skeptick/sugar/text.rb
|
88
|
+
- lib/skeptick/sugar/torn_paper_image.rb
|
89
|
+
- lib/skeptick/sugar/write.rb
|
75
90
|
- lib/skeptick/version.rb
|
76
91
|
- logo.png
|
77
92
|
- logo.rb
|
78
93
|
- refresh_preview.scpt
|
79
94
|
- skeptick.gemspec
|
80
|
-
- test/chain_test.rb
|
81
95
|
- test/convert_test.rb
|
82
|
-
- test/
|
83
|
-
- test/sugar/
|
84
|
-
- test/sugar/
|
85
|
-
- test/sugar/
|
86
|
-
- test/sugar/
|
87
|
-
- test/sugar/
|
96
|
+
- test/sugar/canvas_test.rb
|
97
|
+
- test/sugar/clone_test.rb
|
98
|
+
- test/sugar/compose_test.rb
|
99
|
+
- test/sugar/delete_test.rb
|
100
|
+
- test/sugar/draw_test.rb
|
101
|
+
- test/sugar/font_test.rb
|
102
|
+
- test/sugar/format_test.rb
|
88
103
|
- test/sugar/geometry_test.rb
|
89
|
-
- test/sugar/
|
90
|
-
- test/sugar/
|
104
|
+
- test/sugar/resized_image_test.rb
|
105
|
+
- test/sugar/rounded_corners_image_test.rb
|
106
|
+
- test/sugar/swap_test.rb
|
107
|
+
- test/sugar/text_test.rb
|
108
|
+
- test/sugar/torn_paper_image_test.rb
|
109
|
+
- test/sugar/write_test.rb
|
91
110
|
- test/test_helper.rb
|
92
111
|
homepage: https://github.com/maxim/skeptick
|
93
112
|
licenses: []
|
@@ -108,21 +127,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
127
|
version: '0'
|
109
128
|
requirements: []
|
110
129
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.4.5
|
112
131
|
signing_key:
|
113
132
|
specification_version: 4
|
114
133
|
summary: Skeptick doesn't believe in Magick
|
115
134
|
test_files:
|
116
|
-
- test/chain_test.rb
|
117
135
|
- test/convert_test.rb
|
118
|
-
- test/
|
119
|
-
- test/sugar/
|
120
|
-
- test/sugar/
|
121
|
-
- test/sugar/
|
122
|
-
- test/sugar/
|
123
|
-
- test/sugar/
|
136
|
+
- test/sugar/canvas_test.rb
|
137
|
+
- test/sugar/clone_test.rb
|
138
|
+
- test/sugar/compose_test.rb
|
139
|
+
- test/sugar/delete_test.rb
|
140
|
+
- test/sugar/draw_test.rb
|
141
|
+
- test/sugar/font_test.rb
|
142
|
+
- test/sugar/format_test.rb
|
124
143
|
- test/sugar/geometry_test.rb
|
125
|
-
- test/sugar/
|
126
|
-
- test/sugar/
|
144
|
+
- test/sugar/resized_image_test.rb
|
145
|
+
- test/sugar/rounded_corners_image_test.rb
|
146
|
+
- test/sugar/swap_test.rb
|
147
|
+
- test/sugar/text_test.rb
|
148
|
+
- test/sugar/torn_paper_image_test.rb
|
149
|
+
- test/sugar/write_test.rb
|
127
150
|
- test/test_helper.rb
|
128
151
|
has_rdoc:
|
data/lib/skeptick/chain.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'skeptick/helper'
|
2
|
-
require 'skeptick/convert'
|
3
|
-
require 'skeptick/chain/dsl_context'
|
4
|
-
require 'skeptick/command'
|
5
|
-
|
6
|
-
module Skeptick
|
7
|
-
class Chain
|
8
|
-
include Command::Executable
|
9
|
-
|
10
|
-
PIPE = 'miff:-'
|
11
|
-
|
12
|
-
def initialize(context, *args, &blk)
|
13
|
-
options = Helper.extract_options!(args)
|
14
|
-
@to = options[:to]
|
15
|
-
@context = context
|
16
|
-
@block = blk
|
17
|
-
reset
|
18
|
-
end
|
19
|
-
|
20
|
-
def convert(*args, &blk)
|
21
|
-
@executables << Convert.new(@context, *args, &blk)
|
22
|
-
end
|
23
|
-
|
24
|
-
def piping?
|
25
|
-
@executables.last && @executables.last.piping?
|
26
|
-
end
|
27
|
-
|
28
|
-
def process_method_missing(*args, &blk)
|
29
|
-
@context.send(*args, &blk)
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_s
|
33
|
-
process_dsl
|
34
|
-
@executables.map(&:command).join(' | ')
|
35
|
-
end
|
36
|
-
|
37
|
-
def inspect
|
38
|
-
"Skeptick::Chain(#{to_s})"
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
def reset
|
43
|
-
@executables = []
|
44
|
-
end
|
45
|
-
|
46
|
-
def process_dsl
|
47
|
-
reset
|
48
|
-
DslContext.new(self).instance_eval(&@block)
|
49
|
-
|
50
|
-
if @executables.size > 0 && @to && piping?
|
51
|
-
@executables.last.destination = @to
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Skeptick
|
2
|
-
class Chain
|
3
|
-
class DslContext
|
4
|
-
def initialize(chain)
|
5
|
-
@chain = chain
|
6
|
-
end
|
7
|
-
|
8
|
-
def convert(*args, &blk)
|
9
|
-
@chain.convert(*args, &blk)
|
10
|
-
end
|
11
|
-
|
12
|
-
def pipe_or(path)
|
13
|
-
@chain.piping? ? :pipe : path
|
14
|
-
end
|
15
|
-
|
16
|
-
def method_missing(*args, &blk)
|
17
|
-
@chain.process_method_missing(*args, &blk)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Skeptick
|
2
|
-
class Convert
|
3
|
-
class DslContext
|
4
|
-
def initialize(convert)
|
5
|
-
@convert = convert
|
6
|
-
end
|
7
|
-
|
8
|
-
def set(*args)
|
9
|
-
@convert.set(*args)
|
10
|
-
end
|
11
|
-
alias_method :apply, :set
|
12
|
-
alias_method :with, :set
|
13
|
-
|
14
|
-
def convert(*args, &blk)
|
15
|
-
@convert.convert(*args, &blk)
|
16
|
-
end
|
17
|
-
|
18
|
-
def image(obj = nil, &blk)
|
19
|
-
@convert.image(obj, &blk)
|
20
|
-
end
|
21
|
-
|
22
|
-
def method_missing(*args, &blk)
|
23
|
-
@convert.process_method_missing(*args, &blk)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/skeptick/helper.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module Skeptick
|
2
|
-
module Helper
|
3
|
-
module_function
|
4
|
-
|
5
|
-
def extract_options!(array)
|
6
|
-
array.last.is_a?(Hash) ? array.pop : {}
|
7
|
-
end
|
8
|
-
|
9
|
-
def object_to_index_range_list(obj)
|
10
|
-
case obj
|
11
|
-
when Integer, String
|
12
|
-
obj
|
13
|
-
when Range
|
14
|
-
"#{obj.min}-#{obj.max}"
|
15
|
-
when Array
|
16
|
-
obj.join(',')
|
17
|
-
else
|
18
|
-
raise "invalid sequence reference"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def process_args(*args)
|
23
|
-
args.map{ |arg| arg.is_a?(Symbol) ? "-#{arg.to_s}" : arg }.join(' ')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/skeptick/image.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'skeptick/helper'
|
2
|
-
require 'skeptick/convert'
|
3
|
-
require 'skeptick/chain'
|
4
|
-
require 'skeptick/image/dsl_context'
|
5
|
-
|
6
|
-
module Skeptick
|
7
|
-
class Image
|
8
|
-
attr_accessor :prepends, :appends
|
9
|
-
|
10
|
-
def initialize(context, obj = nil, &blk)
|
11
|
-
@context = context
|
12
|
-
@obj = obj || blk
|
13
|
-
reset
|
14
|
-
end
|
15
|
-
|
16
|
-
def set(*args)
|
17
|
-
@prepends << Helper.process_args(*args)
|
18
|
-
end
|
19
|
-
|
20
|
-
def apply(*args)
|
21
|
-
@appends << Helper.process_args(*args)
|
22
|
-
end
|
23
|
-
|
24
|
-
def image(obj, &blk)
|
25
|
-
@image = Image.new(@context, obj, &blk)
|
26
|
-
end
|
27
|
-
|
28
|
-
def convert(*args, &blk)
|
29
|
-
@image = Convert.new(@context, *args, &blk).become_inner
|
30
|
-
end
|
31
|
-
|
32
|
-
def process_method_missing(*args, &blk)
|
33
|
-
@context.send(*args, &blk)
|
34
|
-
end
|
35
|
-
|
36
|
-
def to_s
|
37
|
-
parts.join(' ')
|
38
|
-
end
|
39
|
-
|
40
|
-
def inspect
|
41
|
-
"Skeptick::Image(#{to_s})"
|
42
|
-
end
|
43
|
-
|
44
|
-
def parts
|
45
|
-
case @obj
|
46
|
-
when :pipe then [ Chain::PIPE ]
|
47
|
-
when Convert then @obj.become_inner.parts
|
48
|
-
when Image then @obj.parts
|
49
|
-
when Array then @obj
|
50
|
-
when Proc then build_parts
|
51
|
-
else [ @obj ]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
def build_parts
|
58
|
-
reset
|
59
|
-
DslContext.new(self).instance_eval(&@obj)
|
60
|
-
[*@prepends, @image, *@appends].compact
|
61
|
-
end
|
62
|
-
|
63
|
-
def reset
|
64
|
-
@image = nil
|
65
|
-
@prepends = []
|
66
|
-
@appends = []
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|