victor 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e578183630315066cfac8073fe7a95df4b200a2
4
- data.tar.gz: 12cd33f3ad1dbbf877f7fd84c56bc26c05c15024
3
+ metadata.gz: 98c7ece8b164674e9f575a651f7184a48deb28d5
4
+ data.tar.gz: 4752c3cbec9917b65a44303fa2e4c6f192242d3c
5
5
  SHA512:
6
- metadata.gz: 16ff14fb0e35c9d866d3ceb69750aa2220cfc4c3ceb28760c44da377003b8e8ba8667818582a375a2a7c8dbff08527e0db0e71d8f38d39e43b596a6b57e3c535
7
- data.tar.gz: 96f4949a8103de5e5f535530b43e033fc8cc29088bc7f967baa8e4e15c45ac1a2a17396122280ebf4e59f3c0ae0c3e3ed9449195bdbc57d37ef0f247418322c9
6
+ metadata.gz: 8325e8a532a0999f63a81b0537822bd93465eb26a9dc36b8ee973238097380015478e6fffb6a989101adcbca73a481faa206dd13f817a3bc00bdb5518514014c
7
+ data.tar.gz: 448f222425c01a7efba6cda9d8b5ab11c81af9339df45e7eb12472938e505e7ac9b3d1cde66142351587e31b6e98853f48d3146b6658a98f2f9b297d608e956f
data/README.md CHANGED
@@ -29,6 +29,32 @@ gem 'victor'
29
29
  Examples
30
30
  --------------------------------------------------
31
31
 
32
+ ```ruby
33
+ require 'victor'
34
+
35
+ svg = SVG.new width: 140, height: 100, style: { background: '#ddd' }
36
+
37
+ svg.build do
38
+ rect x: 10, y: 10, width: 120, height: 80, rx: 10, fill: '#666'
39
+
40
+ circle cx: 50, cy: 50, r: 30, fill: 'yellow'
41
+ circle cx: 58, cy: 32, r: 4, fill: 'black'
42
+ polygon points: %w[45,50 80,30 80,70], fill: '#666'
43
+
44
+ 3.times do |i|
45
+ x = 80 + i*18
46
+ circle cx: x, cy: 50, r: 4, fill: 'yellow'
47
+ end
48
+ end
49
+
50
+ svg.save 'pacman'
51
+ ```
52
+
53
+ Output:
54
+
55
+ [![pacman](https://cdn.rawgit.com/DannyBen/victor/master/examples/09_pacman.svg)](https://github.com/DannyBen/victor/blob/master/examples/09_pacman.rb)
56
+
57
+
32
58
  See the [examples] folder for several ruby scripts and their SVG output.
33
59
 
34
60
 
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  module Victor
4
2
 
5
3
  class CSS
@@ -10,14 +8,24 @@ module Victor
10
8
  end
11
9
 
12
10
  def to_s
11
+ convert_hash attributes
12
+ end
13
+
14
+ private
15
+
16
+ def convert_hash(hash, indent=2)
17
+ return hash unless hash.is_a? Hash
18
+
13
19
  result = []
14
- attributes.each do |selector, styles|
15
- result.push " #{selector} {"
16
- styles.each do |key, value|
17
- key = key.to_s.tr '_', '-'
18
- result.push " #{key}: #{value};"
20
+ hash.each do |key, value|
21
+ key = key.to_s.tr '_', '-'
22
+ if value.is_a? Hash
23
+ result.push " " * indent + "#{key} {"
24
+ result.push convert_hash(value, indent+2)
25
+ result.push " " * indent + "}"
26
+ else
27
+ result.push " " * indent + "#{key}: #{value};"
19
28
  end
20
- result.push " }"
21
29
  end
22
30
 
23
31
  result.join "\n"
@@ -1,3 +1,3 @@
1
1
  module Victor
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: victor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-28 00:00:00.000000000 Z
11
+ date: 2016-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: runfile