scale 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86687ce7ff6a5fd49f8e64362b33eafdc2918fbb
4
- data.tar.gz: db33554c486c5f7f8bb5202395898667305bb95b
3
+ metadata.gz: 6db10add3a6a7cb43dd0aaeab42c7ab03db0015c
4
+ data.tar.gz: a9c78645146671badd41ca7d72298b1d28853ea0
5
5
  SHA512:
6
- metadata.gz: af23fb556e2d43618624455e4c04a24a12e927410bab6f36a4f3be9936225fa5ff6b55ebc5f6dbac11ab9cb873f7e8cf2712a96b3062d4e9dcacb9ee221dd42a
7
- data.tar.gz: 4b4571e4e4054dddb9a5b278f64c86a953e5d0c588263f8c09849038fc981284e599a016ad773676b6f4d3f5e4907e0f374f42b2f538e9dd407106c646c96a31
6
+ metadata.gz: a49b92c1193a9cc392b9b63f00991e0c2cd0d72c04a4fb37d2995614e6f98f9ed4f36c3d1bb25d975073ce39a43a4d06d2f6f6ff3ecb5501d5d0e49dd10846a3
7
+ data.tar.gz: c9eeb380134d3539cdf995f0def378734d4861fe95c6f7a1d15ae798a09c36be7fd0f88d68a3d1175eb1e4d50ffca1df087879b53e8c85ef8e4d19811e92d1f2
@@ -1,9 +1,13 @@
1
1
  require "scale/version"
2
2
  require "scale/node"
3
3
  require "scale/svg"
4
- require "scale/shapes/rectangle"
5
4
  require "scale/shapes/circle"
6
5
  require "scale/shapes/ellipse"
6
+ require "scale/shapes/line"
7
+ require "scale/shapes/path"
8
+ require "scale/shapes/polygon"
9
+ require "scale/shapes/polyline"
10
+ require "scale/shapes/rectangle"
7
11
  require "scale/text"
8
12
  require "scale/dsl"
9
13
 
@@ -5,6 +5,7 @@ module Scale
5
5
  include Enumerable
6
6
  include Virtus.module
7
7
  attr_reader :content
8
+ attribute :style, String
8
9
 
9
10
  def children
10
11
  @children ||= []
@@ -36,7 +37,11 @@ module Scale
36
37
  end
37
38
 
38
39
  def xml_attributes
39
- attributes.delete_if { |key, value| value.nil? }
40
+ attributes.inject({}) do |memo, (key, value)|
41
+ new_key = key.to_s.gsub(/\_/, "-").to_sym
42
+ memo[new_key] = value unless value.nil?
43
+ memo
44
+ end
40
45
  end
41
46
 
42
47
  private
@@ -0,0 +1,13 @@
1
+ module Scale
2
+ class Line
3
+ include Node
4
+ attribute :x1, Integer # the x position of point 1
5
+ attribute :y1, Integer # the y position of point 1
6
+ attribute :x2, Integer # the x position of point 2
7
+ attribute :y2, Integer # the y position of point 2
8
+
9
+ def xml_tag
10
+ :line
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,40 @@
1
+ module Scale
2
+ class Path
3
+ include Node
4
+ attribute :d, String
5
+
6
+ def move_to(x:, y:)
7
+ command("M#{x} #{y}")
8
+ end
9
+
10
+ def line_to(x:, y:)
11
+ command("L #{x} #{y}")
12
+ end
13
+
14
+ def horizontal(n, relative: false)
15
+ command("#{relative ? "h" : "H"} #{n}")
16
+ end
17
+
18
+ def vertical(n, relative: false)
19
+ command("#{relative ? "v" : "V"} #{n}")
20
+ end
21
+
22
+ def close_path
23
+ command("Z")
24
+ end
25
+
26
+ def xml_tag
27
+ :path
28
+ end
29
+
30
+ private
31
+
32
+ def command(instructions)
33
+ if self.d.nil?
34
+ self.d = instructions
35
+ else
36
+ self.d = "#{self.d} #{instructions}"
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,10 @@
1
+ module Scale
2
+ class Polygon
3
+ include Node
4
+ attribute :points, String
5
+
6
+ def xml_tag
7
+ :polyline
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Scale
2
+ class Polyline
3
+ include Node
4
+ attribute :points, String
5
+
6
+ def xml_tag
7
+ :polyline
8
+ end
9
+ end
10
+ end
@@ -4,6 +4,9 @@ module Scale
4
4
  attribute :width, String
5
5
  attribute :height, String
6
6
  attribute :fill, String
7
+ attribute :fill_opactiy, String
8
+ attribute :stroke, String
9
+ attribute :stroke_opacity, String
7
10
  attribute :x, Integer
8
11
  attribute :y, Integer
9
12
  attribute :rx, Integer
@@ -4,6 +4,18 @@ module Scale
4
4
  attribute :x, Integer
5
5
  attribute :y, Integer
6
6
 
7
+ attribute :font_family, String
8
+ attribute :font_style, String
9
+ attribute :font_weight, String
10
+ attribute :font_variant, String
11
+ attribute :font_stretch, String
12
+ attribute :font_size, String
13
+ attribute :font_size_adjust, String
14
+ attribute :kerning, String
15
+ attribute :letter_spacing, String
16
+ attribute :word_spacing, String
17
+ attribute :text_decoration, String
18
+
7
19
  def initialize(text, attributes = {})
8
20
  @content = text
9
21
  super(attributes)
@@ -1,3 +1,3 @@
1
1
  module Scale
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan
@@ -105,6 +105,10 @@ files:
105
105
  - lib/scale/node.rb
106
106
  - lib/scale/shapes/circle.rb
107
107
  - lib/scale/shapes/ellipse.rb
108
+ - lib/scale/shapes/line.rb
109
+ - lib/scale/shapes/path.rb
110
+ - lib/scale/shapes/polygon.rb
111
+ - lib/scale/shapes/polyline.rb
108
112
  - lib/scale/shapes/rectangle.rb
109
113
  - lib/scale/svg.rb
110
114
  - lib/scale/text.rb