rasem 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.6
1
+ 0.6.0
data/bin/rasem CHANGED
File without changes
@@ -18,7 +18,13 @@ class Rasem::Application
18
18
  svg_file = source_file + ".svg"
19
19
  end
20
20
  img = Rasem::SVGImage.new("100%", "100%") do
21
- eval(File.read(source_file), binding)
21
+ begin
22
+ load File.expand_path(source_file)
23
+ rescue Exception => e
24
+ # Keep the portion of stack trace that belongs to the .rasem file
25
+ backtrace = e.backtrace.grep(Regexp.new(File.expand_path(source_file)))
26
+ raise e.class, e.message, backtrace
27
+ end
22
28
  end
23
29
  File.open(svg_file, "w") do |f|
24
30
  f << img.output
@@ -8,11 +8,11 @@ class Rasem::SVGImage
8
8
  :polygon => {:stroke=>"black"},
9
9
  :polyline => {:stroke=>"black"}
10
10
  }
11
-
11
+
12
12
 
13
13
  def initialize(width, height, output=nil, &block)
14
14
  @output = create_output(output)
15
-
15
+
16
16
  # Initialize a stack of default styles
17
17
  @default_styles = []
18
18
 
@@ -22,7 +22,7 @@ class Rasem::SVGImage
22
22
  self.close
23
23
  end
24
24
  end
25
-
25
+
26
26
  def set_width(new_width)
27
27
  if @output.respond_to?(:sub!)
28
28
  @output.sub!(/<svg width="[^"]+"/, %Q{<svg width="#{new_width}"})
@@ -30,7 +30,7 @@ class Rasem::SVGImage
30
30
  raise "Cannot change width after initialization for this output"
31
31
  end
32
32
  end
33
-
33
+
34
34
  def set_height(new_height)
35
35
  if @output.respond_to?(:sub!)
36
36
  @output.sub!(/<svg width="([^"]+)" height="[^"]+"/, %Q{<svg width="\\1" height="#{new_height}"})
@@ -45,15 +45,15 @@ class Rasem::SVGImage
45
45
  write_style(style)
46
46
  @output << %Q{/>}
47
47
  end
48
-
48
+
49
49
  # Draw a circle given a center and a radius
50
50
  def circle(cx, cy, r, style=DefaultStyles[:circle])
51
51
  @output << %Q{<circle cx="#{cx}" cy="#{cy}" r="#{r}"}
52
52
  write_style(style)
53
53
  @output << %Q{/>}
54
54
  end
55
-
56
- # Draw a rectangle or rounded rectangle
55
+
56
+ # Draw a rectangle or rounded rectangle
57
57
  def rectangle(x, y, width, height, *args)
58
58
  style = (!args.empty? && args.last.is_a?(Hash)) ? args.pop : DefaultStyles[:rect]
59
59
  if args.length == 0
@@ -65,42 +65,42 @@ class Rasem::SVGImage
65
65
  else
66
66
  raise "Illegal number of arguments to rectangle"
67
67
  end
68
-
68
+
69
69
  @output << %Q{<rect x="#{x}" y="#{y}" width="#{width}" height="#{height}"}
70
70
  @output << %Q{ rx="#{rx}" ry="#{ry}"} if rx && ry
71
71
  write_style(style)
72
72
  @output << %Q{/>}
73
73
  end
74
-
74
+
75
75
  # Draw an circle given a center and two radii
76
76
  def ellipse(cx, cy, rx, ry, style=DefaultStyles[:ellipse])
77
77
  @output << %Q{<ellipse cx="#{cx}" cy="#{cy}" rx="#{rx}" ry="#{ry}"}
78
78
  write_style(style)
79
79
  @output << %Q{/>}
80
80
  end
81
-
81
+
82
82
  def polygon(*args)
83
83
  polything("polygon", *args)
84
84
  end
85
-
85
+
86
86
  def polyline(*args)
87
87
  polything("polyline", *args)
88
88
  end
89
-
89
+
90
90
  # Closes the file. No more drawing is possible after this
91
91
  def close
92
92
  write_close
93
93
  @closed = true
94
94
  end
95
-
95
+
96
96
  def output
97
97
  @output.to_s
98
98
  end
99
-
99
+
100
100
  def closed?
101
101
  @closed
102
102
  end
103
-
103
+
104
104
  def with_style(style={}, &proc)
105
105
  # Merge passed style with current default style
106
106
  updated_style = default_style.merge(style)
@@ -122,7 +122,7 @@ class Rasem::SVGImage
122
122
  # Close the group
123
123
  @output << "</g>"
124
124
  end
125
-
125
+
126
126
  def text(x, y, text, style=DefaultStyles[:text])
127
127
  @output << %Q{<text x="#{x}" y="#{y}"}
128
128
  style = fix_style(default_style.merge(style))
@@ -139,7 +139,7 @@ class Rasem::SVGImage
139
139
  end
140
140
  @output << "</text>"
141
141
  end
142
-
142
+
143
143
  private
144
144
  # Creates an object for ouput out of an argument
145
145
  def create_output(arg)
@@ -151,7 +151,7 @@ private
151
151
  raise "Illegal output object: #{arg.inspect}"
152
152
  end
153
153
  end
154
-
154
+
155
155
  # Writes file header
156
156
  def write_header(width, height)
157
157
  @output << <<-HEADER
@@ -162,12 +162,12 @@ private
162
162
  xmlns="http://www.w3.org/2000/svg">
163
163
  HEADER
164
164
  end
165
-
165
+
166
166
  # Write the closing tag of the file
167
167
  def write_close
168
168
  @output << "</svg>"
169
169
  end
170
-
170
+
171
171
  # Draws either a polygon or polyline according to the first parameter
172
172
  def polything(name, *args)
173
173
  return if args.empty?
@@ -181,15 +181,16 @@ private
181
181
  @output << "#{x},#{y}"
182
182
  @output << " " unless coords.empty?
183
183
  end
184
- @output << '"/>'
184
+ @output << '"'
185
185
  write_style(style)
186
+ @output << '/>'
186
187
  end
187
-
188
+
188
189
  # Return current deafult style
189
190
  def default_style
190
191
  @default_styles.last || {}
191
192
  end
192
-
193
+
193
194
  # Returns a new hash for styles after fixing names to match SVG standard
194
195
  def fix_style(style)
195
196
  new_style = {}
@@ -199,7 +200,7 @@ private
199
200
  end
200
201
  new_style
201
202
  end
202
-
203
+
203
204
  # Writes styles to current output
204
205
  # Avaialable styles are:
205
206
  # fill: Fill color
@@ -218,3 +219,4 @@ private
218
219
  @output << '"'
219
220
  end
220
221
  end
222
+
metadata CHANGED
@@ -1,90 +1,71 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rasem
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 5
8
- - 6
9
- version: 0.5.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Ahmed Eldawy
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-04-14 00:00:00 -05:00
12
+ date: 2011-07-08 00:00:00.000000000 -04:00
18
13
  default_executable: rasem
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
21
16
  name: rspec
22
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &13580532 !ruby/object:Gem::Requirement
23
18
  none: false
24
- requirements:
19
+ requirements:
25
20
  - - ~>
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 2
29
- - 3
30
- - 0
21
+ - !ruby/object:Gem::Version
31
22
  version: 2.3.0
32
23
  type: :development
33
24
  prerelease: false
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *13580532
26
+ - !ruby/object:Gem::Dependency
36
27
  name: bundler
37
- requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirement: &13578168 !ruby/object:Gem::Requirement
38
29
  none: false
39
- requirements:
30
+ requirements:
40
31
  - - ~>
41
- - !ruby/object:Gem::Version
42
- segments:
43
- - 1
44
- - 0
45
- - 0
32
+ - !ruby/object:Gem::Version
46
33
  version: 1.0.0
47
34
  type: :development
48
35
  prerelease: false
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *13578168
37
+ - !ruby/object:Gem::Dependency
51
38
  name: jeweler
52
- requirement: &id003 !ruby/object:Gem::Requirement
39
+ requirement: &13577844 !ruby/object:Gem::Requirement
53
40
  none: false
54
- requirements:
41
+ requirements:
55
42
  - - ~>
56
- - !ruby/object:Gem::Version
57
- segments:
58
- - 1
59
- - 5
60
- - 2
43
+ - !ruby/object:Gem::Version
61
44
  version: 1.5.2
62
45
  type: :development
63
46
  prerelease: false
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
47
+ version_requirements: *13577844
48
+ - !ruby/object:Gem::Dependency
66
49
  name: rcov
67
- requirement: &id004 !ruby/object:Gem::Requirement
50
+ requirement: &13577544 !ruby/object:Gem::Requirement
68
51
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- segments:
73
- - 0
74
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
75
56
  type: :development
76
57
  prerelease: false
77
- version_requirements: *id004
78
- description: " This gem allows you to describe your images using ruby code.\n You can use rasem to draw complex images using small portions of ruby code\n"
58
+ version_requirements: *13577544
59
+ description: ! " This gem allows you to describe your images using ruby code.\n You
60
+ can use rasem to draw complex images using small portions of ruby code\n"
79
61
  email: eldawy@cs.umn.edu
80
- executables:
62
+ executables:
81
63
  - rasem
82
64
  extensions: []
83
-
84
- extra_rdoc_files:
65
+ extra_rdoc_files:
85
66
  - LICENSE.txt
86
67
  - README.rdoc
87
- files:
68
+ files:
88
69
  - .document
89
70
  - .rspec
90
71
  - Gemfile
@@ -100,37 +81,33 @@ files:
100
81
  - spec/spec_helper.rb
101
82
  has_rdoc: true
102
83
  homepage: http://github.com/aseldawy/rasem
103
- licenses:
84
+ licenses:
104
85
  - MIT
105
86
  post_install_message:
106
87
  rdoc_options: []
107
-
108
- require_paths:
88
+ require_paths:
109
89
  - lib
110
- required_ruby_version: !ruby/object:Gem::Requirement
90
+ required_ruby_version: !ruby/object:Gem::Requirement
111
91
  none: false
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- hash: 367852017
116
- segments:
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ segments:
117
97
  - 0
118
- version: "0"
119
- required_rubygems_version: !ruby/object:Gem::Requirement
98
+ hash: -491594989
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
100
  none: false
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- segments:
125
- - 0
126
- version: "0"
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
127
105
  requirements: []
128
-
129
106
  rubyforge_project:
130
- rubygems_version: 1.3.7
107
+ rubygems_version: 1.5.2
131
108
  signing_key:
132
109
  specification_version: 3
133
110
  summary: A gem to generate images from ruby files
134
- test_files:
111
+ test_files:
135
112
  - spec/rasem_spec.rb
136
113
  - spec/spec_helper.rb