vector_salad 0.1.3 → 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/bin/vector_salad +5 -68
- data/lib/contracts_builtin.rb +34 -0
- data/lib/vector_salad/magic.rb +1 -1
- data/lib/vector_salad/optparse.rb +65 -0
- data/lib/vector_salad/standard_shapes/basic_shape.rb +3 -2
- data/lib/vector_salad/standard_shapes/clip.rb +1 -0
- data/lib/vector_salad/standard_shapes/custom.rb +1 -2
- data/lib/vector_salad/standard_shapes/difference.rb +0 -1
- data/lib/vector_salad/standard_shapes/exclusion.rb +0 -1
- data/lib/vector_salad/standard_shapes/flip.rb +1 -0
- data/lib/vector_salad/standard_shapes/heart.rb +2 -0
- data/lib/vector_salad/standard_shapes/intersection.rb +0 -1
- data/lib/vector_salad/standard_shapes/iso_tri.rb +1 -0
- data/lib/vector_salad/standard_shapes/jitter.rb +1 -0
- data/lib/vector_salad/standard_shapes/move.rb +1 -0
- data/lib/vector_salad/standard_shapes/oval.rb +1 -0
- data/lib/vector_salad/standard_shapes/polygon.rb +2 -1
- data/lib/vector_salad/standard_shapes/rect.rb +1 -0
- data/lib/vector_salad/standard_shapes/rotate.rb +1 -0
- data/lib/vector_salad/standard_shapes/transform.rb +3 -4
- data/lib/vector_salad/standard_shapes/union.rb +0 -1
- data/lib/vector_salad/version.rb +1 -1
- metadata +3 -2
- data/lib/contracts_contracts.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc23021a759973f72595a9b083f0c14557a81ee1
|
4
|
+
data.tar.gz: de57bf043d59f32f38f9c85a4ec54d4b1347c4b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9b18624730aab10da1463714ae2b6da737ffdcf168a205205fe48f668cdfacebe9c9f6d60cae3220472f19267857a6d5650cf1a1162536c3ab167c83afbd429
|
7
|
+
data.tar.gz: 78df56043bb2ad3d9f5ad54bbd8413705c8d2432315477a5af4b449c0febeb954973f89b9a35b00546469cb9d150985417f2e2f3d878c56e0c30e25d3d0c2de8
|
data/bin/vector_salad
CHANGED
@@ -2,74 +2,11 @@
|
|
2
2
|
|
3
3
|
require "optparse"
|
4
4
|
require "ostruct"
|
5
|
-
|
5
|
+
require "vector_salad/version"
|
6
|
+
require "vector_salad/optparse"
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
# Return a structure describing the options.
|
10
|
-
#
|
11
|
-
def self.parse(args)
|
12
|
-
# The options specified on the command line will be collected in *options*.
|
13
|
-
# We set default values here.
|
14
|
-
options = OpenStruct.new
|
15
|
-
options.file = nil
|
16
|
-
options.magic = true
|
17
|
-
options.verbose = false
|
18
|
-
options.width = nil
|
19
|
-
options.height = nil
|
8
|
+
ARGV << "--help" if ARGV.empty?
|
9
|
+
options = VectorSalad::Optparse.parse(ARGV)
|
20
10
|
|
21
|
-
|
22
|
-
opts.banner = "Usage: vrs [options]"
|
23
|
-
|
24
|
-
opts.separator ""
|
25
|
-
opts.separator "Specific options:"
|
26
|
-
|
27
|
-
opts.on("--crop CROP",
|
28
|
-
"Set manual crop, WIDTHxHEIGHT, e.g: 400x600") do |crop|
|
29
|
-
options.width, options.height = crop.split('x').map(&:to_i)
|
30
|
-
end
|
31
|
-
|
32
|
-
# Mandatory argument.
|
33
|
-
opts.on("-f", "--file FILE",
|
34
|
-
"Run VectorSalad on the FILE") do |file|
|
35
|
-
options.file = file
|
36
|
-
end
|
37
|
-
|
38
|
-
opts.on("--[no-]magic",
|
39
|
-
"Add some helpful magic to your design") do |m|
|
40
|
-
puts "So this happened: #{m}"
|
41
|
-
options.magic = m
|
42
|
-
end
|
43
|
-
|
44
|
-
# Boolean switch.
|
45
|
-
# opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
46
|
-
# options.verbose = v
|
47
|
-
# end
|
48
|
-
|
49
|
-
opts.separator ""
|
50
|
-
opts.separator "Common options:"
|
51
|
-
|
52
|
-
# No argument, shows at tail. This will print an options summary.
|
53
|
-
# Try it and see!
|
54
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
55
|
-
puts opts
|
56
|
-
exit
|
57
|
-
end
|
58
|
-
|
59
|
-
# Another typical switch to print the version.
|
60
|
-
opts.on_tail("--version", "Show version") do
|
61
|
-
puts VectorSalad::VERSION
|
62
|
-
exit
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
opt_parser.parse!(args)
|
67
|
-
options
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
ARGV << "-h" if ARGV.empty?
|
72
|
-
options = OptparseVectorSalad.parse(ARGV)
|
73
|
-
|
74
|
-
require_relative "../lib/vector_salad/export_with_magic"
|
11
|
+
require "vector_salad/export_with_magic"
|
75
12
|
puts VectorSalad::ExportWithMagic.new(options).export
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# @api private
|
2
|
+
module Contracts
|
3
|
+
module Builtin
|
4
|
+
class Coords
|
5
|
+
def self.valid?(val)
|
6
|
+
Contracts::Maybe[[Contracts::Num, Contracts::Num]].valid? val
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.to_s
|
10
|
+
"[Num, Num] an x,y coordinate array"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Coord
|
15
|
+
def self.valid?(val)
|
16
|
+
Contracts::Num.valid? val
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.to_s
|
20
|
+
"Num; a coordinate"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class PolySides
|
25
|
+
def self.valid?(val)
|
26
|
+
val && val.is_a?(Integer) && val >= 3
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.to_s
|
30
|
+
"Int; sides of the polygon, minimum of 3"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/vector_salad/magic.rb
CHANGED
@@ -0,0 +1,65 @@
|
|
1
|
+
module VectorSalad
|
2
|
+
# @api private
|
3
|
+
class Optparse
|
4
|
+
def self.defaults
|
5
|
+
@defaults ||= {
|
6
|
+
file: nil,
|
7
|
+
magic: true,
|
8
|
+
verbose: false,
|
9
|
+
width: nil,
|
10
|
+
height: nil
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.options
|
15
|
+
@options ||= OpenStruct.new(defaults)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.tool_name=(name)
|
19
|
+
@tool_name = name
|
20
|
+
end
|
21
|
+
self.tool_name = "vector_salad"
|
22
|
+
|
23
|
+
def self.optparse
|
24
|
+
@optparse ||= OptionParser.new do |o|
|
25
|
+
o.banner = <<-EOF.gsub(/^.*# ?/, "")
|
26
|
+
# Usage:
|
27
|
+
# #{@tool_name} -f path/to/file.rb [options]
|
28
|
+
#
|
29
|
+
# Options:
|
30
|
+
EOF
|
31
|
+
|
32
|
+
o.on_head("-c", "--crop CROP", "Set manual crop, WIDTHxHEIGHT, e.g: 400x600") do |crop|
|
33
|
+
options.width, options.height = crop.split("x").map(&:to_i)
|
34
|
+
end
|
35
|
+
|
36
|
+
o.on_head("-f", "--file FILE", "Run VectorSalad on the FILE") do |file|
|
37
|
+
options.file = file
|
38
|
+
end
|
39
|
+
|
40
|
+
# o.on_head("--[no-]magic", "Add some helpful magic to your design") do |m|
|
41
|
+
# options.magic = m
|
42
|
+
# end
|
43
|
+
|
44
|
+
o.separator ""
|
45
|
+
o.separator "General options:"
|
46
|
+
|
47
|
+
o.on_tail("-h", "--help", "Show this message") do
|
48
|
+
puts o
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
|
52
|
+
o.on_tail("--version", "Show version") do
|
53
|
+
puts VectorSalad::VERSION
|
54
|
+
exit
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Return a structure describing the options.
|
60
|
+
def self.parse(args)
|
61
|
+
optparse.parse!(args)
|
62
|
+
options
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "forwardable"
|
2
2
|
require "contracts"
|
3
|
-
require "
|
3
|
+
require "contracts_builtin"
|
4
4
|
|
5
5
|
module VectorSalad
|
6
6
|
module StandardShapes
|
@@ -13,7 +13,8 @@ module VectorSalad
|
|
13
13
|
# You can't use BasicShape directly.
|
14
14
|
class BasicShape
|
15
15
|
extend Forwardable
|
16
|
-
include Contracts
|
16
|
+
include Contracts::Core
|
17
|
+
include Contracts::Builtin
|
17
18
|
|
18
19
|
attr_accessor :options
|
19
20
|
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require "contracts"
|
2
|
-
require "
|
3
|
-
|
2
|
+
require "contracts_builtin"
|
4
3
|
require "vector_salad/dsl"
|
5
4
|
require "vector_salad/canvas"
|
6
|
-
require "vector_salad/standard_shapes/path"
|
7
5
|
|
8
6
|
module VectorSalad
|
9
7
|
module StandardShapes
|
@@ -11,7 +9,8 @@ module VectorSalad
|
|
11
9
|
class Transform
|
12
10
|
include VectorSalad::DSL
|
13
11
|
include VectorSalad::StandardShapes
|
14
|
-
include Contracts
|
12
|
+
include Contracts::Core
|
13
|
+
include Contracts::Builtin
|
15
14
|
|
16
15
|
def canvas
|
17
16
|
@canvas ||= VectorSalad::Canvas.new
|
data/lib/vector_salad/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vector_salad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon George
|
@@ -209,7 +209,7 @@ files:
|
|
209
209
|
- examples/triangles.png
|
210
210
|
- examples/triangles.rb
|
211
211
|
- examples/triangles.svg
|
212
|
-
- lib/
|
212
|
+
- lib/contracts_builtin.rb
|
213
213
|
- lib/vector_salad.rb
|
214
214
|
- lib/vector_salad/canvas.rb
|
215
215
|
- lib/vector_salad/dsl.rb
|
@@ -221,6 +221,7 @@ files:
|
|
221
221
|
- lib/vector_salad/mixins/at.rb
|
222
222
|
- lib/vector_salad/mixins/mixins.rb
|
223
223
|
- lib/vector_salad/monkeypatches.rb
|
224
|
+
- lib/vector_salad/optparse.rb
|
224
225
|
- lib/vector_salad/shape_proxy.rb
|
225
226
|
- lib/vector_salad/standard_shapes/basic_shape.rb
|
226
227
|
- lib/vector_salad/standard_shapes/circle.rb
|
data/lib/contracts_contracts.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# @api private
|
2
|
-
module Contracts
|
3
|
-
class Coords
|
4
|
-
def self.valid?(val)
|
5
|
-
Contracts::Maybe[[Contracts::Num, Contracts::Num]].valid? val
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.to_s
|
9
|
-
"[Num, Num] an x,y coordinate array"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class Coord
|
14
|
-
def self.valid?(val)
|
15
|
-
Contracts::Num.valid? val
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.to_s
|
19
|
-
"Num; a coordinate"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class PolySides
|
24
|
-
def self.valid?(val)
|
25
|
-
val && val.is_a?(Integer) && val >= 3
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.to_s
|
29
|
-
"Int; sides of the polygon, minimum of 3"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|