squib 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +14 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +201 -175
- data/Gemfile +2 -4
- data/README.md +650 -645
- data/RELEASE TODO.md +18 -18
- data/Rakefile +106 -99
- data/appveyor.yml +29 -0
- data/lib/squib.rb +32 -32
- data/lib/squib/api/background.rb +20 -20
- data/lib/squib/api/data.rb +131 -131
- data/lib/squib/api/image.rb +108 -90
- data/lib/squib/api/save.rb +151 -149
- data/lib/squib/api/settings.rb +35 -35
- data/lib/squib/api/shapes.rb +255 -230
- data/lib/squib/api/text.rb +65 -65
- data/lib/squib/api/text_embed.rb +96 -96
- data/lib/squib/args/arg_loader.rb +138 -138
- data/lib/squib/args/box.rb +54 -54
- data/lib/squib/args/card_range.rb +32 -32
- data/lib/squib/args/color_validator.rb +11 -11
- data/lib/squib/args/coords.rb +32 -32
- data/lib/squib/args/dir_validator.rb +16 -16
- data/lib/squib/args/draw.rb +92 -92
- data/lib/squib/args/embed_adjust.rb +25 -25
- data/lib/squib/args/embed_key.rb +17 -17
- data/lib/squib/args/hand_special.rb +37 -37
- data/lib/squib/args/import.rb +39 -39
- data/lib/squib/args/input_file.rb +37 -37
- data/lib/squib/args/paint.rb +43 -43
- data/lib/squib/args/paragraph.rb +116 -115
- data/lib/squib/args/save_batch.rb +63 -60
- data/lib/squib/args/scale_box.rb +53 -53
- data/lib/squib/args/sheet.rb +72 -72
- data/lib/squib/args/showcase_special.rb +38 -38
- data/lib/squib/args/svg_special.rb +37 -37
- data/lib/squib/args/transform.rb +60 -24
- data/lib/squib/args/typographer.rb +117 -117
- data/lib/squib/card.rb +66 -67
- data/lib/squib/conf.rb +131 -117
- data/lib/squib/constants.rb +12 -178
- data/lib/squib/deck.rb +113 -113
- data/lib/squib/graphics/cairo_context_wrapper.rb +113 -99
- data/lib/squib/graphics/gradient_regex.rb +46 -46
- data/lib/squib/graphics/hand.rb +42 -42
- data/lib/squib/graphics/image.rb +103 -76
- data/lib/squib/graphics/save_doc.rb +103 -103
- data/lib/squib/graphics/save_images.rb +39 -33
- data/lib/squib/graphics/shapes.rb +135 -119
- data/lib/squib/graphics/showcase.rb +85 -85
- data/lib/squib/graphics/text.rb +176 -176
- data/lib/squib/layout_parser.rb +91 -91
- data/lib/squib/layouts/economy.yml +85 -85
- data/lib/squib/layouts/fantasy.yml +101 -101
- data/lib/squib/layouts/hand.yml +62 -62
- data/lib/squib/layouts/playing-card.yml +35 -35
- data/lib/squib/layouts/tuck_box.yml +45 -45
- data/lib/squib/project_template/IDEAS.md +22 -0
- data/lib/squib/project_template/PLAYTESTING.md +26 -0
- data/lib/squib/project_template/RULES.md +21 -0
- data/lib/squib/project_template/config.yml +49 -45
- data/lib/squib/sample_helpers.rb +34 -0
- data/lib/squib/version.rb +10 -10
- data/samples/autoscale_font/_autoscale_font.rb +29 -0
- data/samples/color_shortcuts.rb +6 -6
- data/samples/csv_import.rb +26 -26
- data/samples/custom-config.yml +5 -5
- data/samples/custom_config.rb +18 -18
- data/samples/draw_shapes.rb +48 -45
- data/samples/embed_text.rb +88 -88
- data/samples/excel.rb +55 -55
- data/samples/hand.rb +24 -24
- data/samples/images/_images.rb +104 -0
- data/samples/intro/01_hello.rb +9 -0
- data/samples/intro/02_options.rb +15 -0
- data/samples/intro/03_layout.rb +12 -0
- data/samples/intro/04_arrays.rb +16 -0
- data/samples/intro/05_excel.rb +15 -0
- data/samples/layouts.rb +62 -62
- data/samples/layouts_builtin.rb +51 -51
- data/samples/load_images.rb +99 -78
- data/samples/load_images_config.yml +1 -0
- data/samples/quantity_explosion.csv +2 -2
- data/samples/ranges.rb +64 -64
- data/samples/sample.csv +2 -2
- data/samples/saves.rb +9 -1
- data/samples/sprites.png +0 -0
- data/samples/text/_text.rb +46 -0
- data/samples/text_options.rb +102 -102
- data/spec/api/api_data_spec.rb +117 -117
- data/spec/api/api_settings_spec.rb +37 -37
- data/spec/args/box_spec.rb +127 -127
- data/spec/args/draw_spec.rb +101 -95
- data/spec/args/embed_key_spec.rb +13 -13
- data/spec/args/input_file_spec.rb +21 -21
- data/spec/args/paint_spec.rb +21 -21
- data/spec/args/paragraph_spec.rb +152 -152
- data/spec/args/range_spec.rb +40 -40
- data/spec/args/save_batch_spec.rb +51 -51
- data/spec/args/scale_box_spec.rb +71 -71
- data/spec/args/sheet_spec.rb +58 -58
- data/spec/args/showcase_special_spec.rb +15 -15
- data/spec/args/transform_spec.rb +25 -0
- data/spec/card_spec.rb +11 -0
- data/spec/conf_spec.rb +13 -3
- data/spec/data/conf/unrecognized.yml +4 -0
- data/spec/data/csv/qty.csv +2 -2
- data/spec/data/csv/qty_named.csv +2 -2
- data/spec/data/csv/with_spaces.csv +2 -2
- data/spec/data/samples/autoscale_font.rb.txt +84 -84
- data/spec/data/samples/basic.rb.txt +227 -209
- data/spec/data/samples/config_text_markup.rb.txt +72 -72
- data/spec/data/samples/csv_import.rb.txt +213 -213
- data/spec/data/samples/custom_config.rb.txt +57 -48
- data/spec/data/samples/draw_shapes.rb.txt +555 -3
- data/spec/data/samples/embed_text.rb.txt +283 -283
- data/spec/data/samples/excel.rb.txt +661 -661
- data/spec/data/samples/gradients.rb.txt +77 -79
- data/spec/data/samples/hand.rb.txt +538 -538
- data/spec/data/samples/hello_world.rb.txt +36 -36
- data/spec/data/samples/load_images.rb.txt +170 -0
- data/spec/data/samples/portrait-landscape.rb.txt +51 -49
- data/spec/data/samples/ranges.rb.txt +472 -460
- data/spec/data/samples/saves.rb.txt +810 -801
- data/spec/data/samples/showcase.rb.txt +5926 -5910
- data/spec/data/samples/text_options.rb.txt +1125 -1125
- data/spec/data/samples/tgc_proofs.rb.txt +95 -81
- data/spec/graphics/cairo_context_wrapper_spec.rb +104 -84
- data/spec/graphics/graphics_save_doc_spec.rb +67 -67
- data/spec/samples/diff-with-css.example.html +39 -0
- data/spec/samples/expected/load_images_00.png +0 -0
- data/spec/samples/expected/shape_00.png +0 -0
- data/spec/samples/run_samples_spec.rb +17 -0
- data/spec/samples/samples_regression_spec.rb +72 -82
- data/spec/spec_helper.rb +9 -1
- data/squib.gemspec +49 -48
- data/squib.sublime-project +42 -42
- metadata +94 -48
- data/spec/graphics/graphics_images_spec.rb +0 -94
@@ -1,25 +1,25 @@
|
|
1
|
-
require 'squib/args/arg_loader'
|
2
|
-
|
3
|
-
module Squib
|
4
|
-
# @api private
|
5
|
-
module Args
|
6
|
-
|
7
|
-
class EmbedAdjust
|
8
|
-
include ArgLoader
|
9
|
-
|
10
|
-
def self.parameters
|
11
|
-
{ dx: 0, dy: 0 }
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.expanding_parameters
|
15
|
-
parameters.keys # all of them
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.params_with_units
|
19
|
-
parameters.keys # all of them
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
1
|
+
require 'squib/args/arg_loader'
|
2
|
+
|
3
|
+
module Squib
|
4
|
+
# @api private
|
5
|
+
module Args
|
6
|
+
|
7
|
+
class EmbedAdjust
|
8
|
+
include ArgLoader
|
9
|
+
|
10
|
+
def self.parameters
|
11
|
+
{ dx: 0, dy: 0 }
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.expanding_parameters
|
15
|
+
parameters.keys # all of them
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.params_with_units
|
19
|
+
parameters.keys # all of them
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/lib/squib/args/embed_key.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
require 'squib/args/arg_loader'
|
2
|
-
|
3
|
-
module Squib
|
4
|
-
# @api private
|
5
|
-
module Args
|
6
|
-
|
7
|
-
class EmbedKey
|
8
|
-
|
9
|
-
# Validate the embed lookup key
|
10
|
-
def validate_key(str)
|
11
|
-
str.to_s
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
1
|
+
require 'squib/args/arg_loader'
|
2
|
+
|
3
|
+
module Squib
|
4
|
+
# @api private
|
5
|
+
module Args
|
6
|
+
|
7
|
+
class EmbedKey
|
8
|
+
|
9
|
+
# Validate the embed lookup key
|
10
|
+
def validate_key(str)
|
11
|
+
str.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -1,37 +1,37 @@
|
|
1
|
-
require 'cairo'
|
2
|
-
|
3
|
-
module Squib
|
4
|
-
# @api private
|
5
|
-
module Args
|
6
|
-
|
7
|
-
class HandSpecial
|
8
|
-
include ArgLoader
|
9
|
-
|
10
|
-
def initialize(card_height)
|
11
|
-
@card_height = card_height
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.parameters
|
15
|
-
{
|
16
|
-
angle_range: (Math::PI / -4.0)..(Math::PI / 4),
|
17
|
-
radius: :auto
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.expanding_parameters
|
22
|
-
[] # none of them
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.params_with_units
|
26
|
-
[ :radius ]
|
27
|
-
end
|
28
|
-
|
29
|
-
def validate_radius(arg)
|
30
|
-
return 0.3 * @card_height if arg.to_s.downcase.strip == 'auto'
|
31
|
-
arg
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
1
|
+
require 'cairo'
|
2
|
+
|
3
|
+
module Squib
|
4
|
+
# @api private
|
5
|
+
module Args
|
6
|
+
|
7
|
+
class HandSpecial
|
8
|
+
include ArgLoader
|
9
|
+
|
10
|
+
def initialize(card_height)
|
11
|
+
@card_height = card_height
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.parameters
|
15
|
+
{
|
16
|
+
angle_range: (Math::PI / -4.0)..(Math::PI / 4),
|
17
|
+
radius: :auto
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.expanding_parameters
|
22
|
+
[] # none of them
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.params_with_units
|
26
|
+
[ :radius ]
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_radius(arg)
|
30
|
+
return 0.3 * @card_height if arg.to_s.downcase.strip == 'auto'
|
31
|
+
arg
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/lib/squib/args/import.rb
CHANGED
@@ -1,40 +1,40 @@
|
|
1
|
-
require 'squib/args/arg_loader'
|
2
|
-
|
3
|
-
module Squib
|
4
|
-
# @api private
|
5
|
-
module Args
|
6
|
-
|
7
|
-
class Import
|
8
|
-
include ArgLoader
|
9
|
-
|
10
|
-
def self.parameters
|
11
|
-
{ strip: true,
|
12
|
-
explode: 'Qty'
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.expanding_parameters
|
17
|
-
[] # none of them
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.params_with_units
|
21
|
-
[] # none of them
|
22
|
-
end
|
23
|
-
|
24
|
-
def validate_strip(arg)
|
25
|
-
raise 'Strip must be true or false' unless arg == true || arg == false
|
26
|
-
arg
|
27
|
-
end
|
28
|
-
|
29
|
-
def validate_explode(arg)
|
30
|
-
arg
|
31
|
-
end
|
32
|
-
|
33
|
-
def strip?
|
34
|
-
strip
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
1
|
+
require 'squib/args/arg_loader'
|
2
|
+
|
3
|
+
module Squib
|
4
|
+
# @api private
|
5
|
+
module Args
|
6
|
+
|
7
|
+
class Import
|
8
|
+
include ArgLoader
|
9
|
+
|
10
|
+
def self.parameters
|
11
|
+
{ strip: true,
|
12
|
+
explode: 'Qty'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.expanding_parameters
|
17
|
+
[] # none of them
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.params_with_units
|
21
|
+
[] # none of them
|
22
|
+
end
|
23
|
+
|
24
|
+
def validate_strip(arg)
|
25
|
+
raise 'Strip must be true or false' unless arg == true || arg == false
|
26
|
+
arg
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_explode(arg)
|
30
|
+
arg
|
31
|
+
end
|
32
|
+
|
33
|
+
def strip?
|
34
|
+
strip
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
40
|
end
|
@@ -1,37 +1,37 @@
|
|
1
|
-
require 'squib/args/arg_loader'
|
2
|
-
|
3
|
-
module Squib
|
4
|
-
# @api private
|
5
|
-
module Args
|
6
|
-
|
7
|
-
class InputFile
|
8
|
-
include ArgLoader
|
9
|
-
|
10
|
-
def initialize(dsl_method_default = {})
|
11
|
-
@dsl_method_default = dsl_method_default
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.parameters
|
15
|
-
{ file: nil,
|
16
|
-
sheet: 0,
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.expanding_parameters
|
21
|
-
parameters.keys # all of them
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.params_with_units
|
25
|
-
[] # none of them
|
26
|
-
end
|
27
|
-
|
28
|
-
def validate_file(arg, _i)
|
29
|
-
return nil if arg.nil?
|
30
|
-
raise "File #{File.expand_path(arg)} does not exist!" unless File.exists?(arg)
|
31
|
-
File.expand_path(arg)
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
1
|
+
require 'squib/args/arg_loader'
|
2
|
+
|
3
|
+
module Squib
|
4
|
+
# @api private
|
5
|
+
module Args
|
6
|
+
|
7
|
+
class InputFile
|
8
|
+
include ArgLoader
|
9
|
+
|
10
|
+
def initialize(dsl_method_default = {})
|
11
|
+
@dsl_method_default = dsl_method_default
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.parameters
|
15
|
+
{ file: nil,
|
16
|
+
sheet: 0,
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.expanding_parameters
|
21
|
+
parameters.keys # all of them
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.params_with_units
|
25
|
+
[] # none of them
|
26
|
+
end
|
27
|
+
|
28
|
+
def validate_file(arg, _i)
|
29
|
+
return nil if arg.nil?
|
30
|
+
raise "File #{File.expand_path(arg)} does not exist!" unless File.exists?(arg)
|
31
|
+
File.expand_path(arg)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/lib/squib/args/paint.rb
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
require 'cairo'
|
2
|
-
require 'squib/args/arg_loader'
|
3
|
-
require 'squib/args/color_validator'
|
4
|
-
|
5
|
-
module Squib
|
6
|
-
# @api private
|
7
|
-
module Args
|
8
|
-
class Paint
|
9
|
-
include ArgLoader
|
10
|
-
include ColorValidator
|
11
|
-
|
12
|
-
def self.parameters
|
13
|
-
{ alpha: 1.0,
|
14
|
-
blend: :none,
|
15
|
-
mask: nil,
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def self.expanding_parameters
|
21
|
-
parameters.keys # all of them are expandable
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.params_with_units
|
25
|
-
[]
|
26
|
-
end
|
27
|
-
|
28
|
-
def initialize(custom_colors)
|
29
|
-
@custom_colors = custom_colors
|
30
|
-
end
|
31
|
-
|
32
|
-
def validate_alpha(arg, _i)
|
33
|
-
raise 'alpha must respond to to_f' unless arg.respond_to? :to_f
|
34
|
-
arg.to_f
|
35
|
-
end
|
36
|
-
|
37
|
-
def validate_mask(arg, _i)
|
38
|
-
colorify(arg, @custom_colors)
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
1
|
+
require 'cairo'
|
2
|
+
require 'squib/args/arg_loader'
|
3
|
+
require 'squib/args/color_validator'
|
4
|
+
|
5
|
+
module Squib
|
6
|
+
# @api private
|
7
|
+
module Args
|
8
|
+
class Paint
|
9
|
+
include ArgLoader
|
10
|
+
include ColorValidator
|
11
|
+
|
12
|
+
def self.parameters
|
13
|
+
{ alpha: 1.0,
|
14
|
+
blend: :none,
|
15
|
+
mask: nil,
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def self.expanding_parameters
|
21
|
+
parameters.keys # all of them are expandable
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.params_with_units
|
25
|
+
[]
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(custom_colors)
|
29
|
+
@custom_colors = custom_colors
|
30
|
+
end
|
31
|
+
|
32
|
+
def validate_alpha(arg, _i)
|
33
|
+
raise 'alpha must respond to to_f' unless arg.respond_to? :to_f
|
34
|
+
arg.to_f
|
35
|
+
end
|
36
|
+
|
37
|
+
def validate_mask(arg, _i)
|
38
|
+
colorify(arg, @custom_colors)
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
44
|
end
|
data/lib/squib/args/paragraph.rb
CHANGED
@@ -1,115 +1,116 @@
|
|
1
|
-
require 'squib/args/arg_loader'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
arg =
|
45
|
-
arg
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
arg.to_f
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
end
|
1
|
+
require 'squib/args/arg_loader'
|
2
|
+
require 'squib/constants'
|
3
|
+
|
4
|
+
module Squib
|
5
|
+
# @api private
|
6
|
+
module Args
|
7
|
+
|
8
|
+
class Paragraph
|
9
|
+
include ArgLoader
|
10
|
+
|
11
|
+
|
12
|
+
def self.parameters
|
13
|
+
{ align: :left,
|
14
|
+
str: 'Hello, World!',
|
15
|
+
font: :use_set,
|
16
|
+
font_size: nil,
|
17
|
+
markup: false,
|
18
|
+
justify: false,
|
19
|
+
wrap: true,
|
20
|
+
ellipsize: :end,
|
21
|
+
spacing: nil,
|
22
|
+
valign: :top,
|
23
|
+
hint: :off
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.expanding_parameters
|
28
|
+
parameters.keys # all of them
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.params_with_units
|
32
|
+
[] # none of them
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(deck_font)
|
36
|
+
@deck_font = deck_font
|
37
|
+
end
|
38
|
+
|
39
|
+
def validate_str(arg, _i)
|
40
|
+
arg.to_s
|
41
|
+
end
|
42
|
+
|
43
|
+
def validate_font(arg, _i)
|
44
|
+
arg = @deck_font if arg == :use_set
|
45
|
+
arg = DEFAULT_FONT if arg == :default
|
46
|
+
arg
|
47
|
+
end
|
48
|
+
|
49
|
+
def validate_align(arg, _i)
|
50
|
+
case arg.to_s.downcase.strip
|
51
|
+
when 'left'
|
52
|
+
Pango::ALIGN_LEFT
|
53
|
+
when 'right'
|
54
|
+
Pango::ALIGN_RIGHT
|
55
|
+
when 'center'
|
56
|
+
Pango::ALIGN_CENTER
|
57
|
+
else
|
58
|
+
raise ArgumentError, 'align must be one of: center, left, right'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def validate_wrap(arg, _i)
|
63
|
+
case arg.to_s.downcase.strip
|
64
|
+
when 'word'
|
65
|
+
Pango::Layout::WRAP_WORD
|
66
|
+
when 'char', 'false'
|
67
|
+
Pango::Layout::WRAP_CHAR
|
68
|
+
when 'word_char', 'true'
|
69
|
+
Pango::Layout::WRAP_WORD_CHAR
|
70
|
+
else
|
71
|
+
raise ArgumentError, 'wrap must be one of: word, char, word_char, true, or false'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def validate_ellipsize(arg, _i)
|
76
|
+
case arg.to_s.downcase.strip
|
77
|
+
when 'none', 'false'
|
78
|
+
Pango::Layout::ELLIPSIZE_NONE
|
79
|
+
when 'start'
|
80
|
+
Pango::Layout::ELLIPSIZE_START
|
81
|
+
when 'middle'
|
82
|
+
Pango::Layout::ELLIPSIZE_MIDDLE
|
83
|
+
when 'end', 'true'
|
84
|
+
Pango::Layout::ELLIPSIZE_END
|
85
|
+
else
|
86
|
+
raise ArgumentError, 'ellipsize must be one of: none, start, middle, end, true, or false'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def validate_justify(arg, _i)
|
91
|
+
case arg
|
92
|
+
when nil, true, false
|
93
|
+
arg
|
94
|
+
else
|
95
|
+
raise ArgumentError, 'justify must be one of: nil, true, or false'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def validate_spacing(arg, _i)
|
100
|
+
return nil if arg.nil?
|
101
|
+
raise ArgumentError, 'spacing must be a number or nil' unless arg.respond_to? :to_f
|
102
|
+
arg.to_f * Pango::SCALE
|
103
|
+
end
|
104
|
+
|
105
|
+
def validate_valign(arg, _i)
|
106
|
+
if %w(top middle bottom).include? arg.to_s.downcase
|
107
|
+
arg.to_s.downcase
|
108
|
+
else
|
109
|
+
raise ArgumentError, 'valign must be one of: top, middle, bottom'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|