graffle 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/History.txt +2 -0
  2. data/LICENSE.txt +34 -0
  3. data/Manifest.txt +53 -0
  4. data/README.txt +19 -0
  5. data/Rakefile +32 -0
  6. data/Rakefile.hoe +23 -0
  7. data/bin/bin-skeleton +23 -0
  8. data/graffle.tmproj +335 -0
  9. data/lib/graffle.rb +43 -0
  10. data/lib/graffle/.document +4 -0
  11. data/lib/graffle/lib-skeleton +3 -0
  12. data/lib/graffle/nodoc/hacks.rb +69 -0
  13. data/lib/graffle/point.rb +42 -0
  14. data/lib/graffle/stereotypes.rb +446 -0
  15. data/lib/graffle/styled-text-reader.rb +52 -0
  16. data/lib/graffle/third-party/s4t-utils.rb +21 -0
  17. data/lib/graffle/third-party/s4t-utils/capturing-globals.rb +78 -0
  18. data/lib/graffle/third-party/s4t-utils/claims.rb +14 -0
  19. data/lib/graffle/third-party/s4t-utils/command-line.rb +15 -0
  20. data/lib/graffle/third-party/s4t-utils/error-handling.rb +20 -0
  21. data/lib/graffle/third-party/s4t-utils/friendly-format.rb +27 -0
  22. data/lib/graffle/third-party/s4t-utils/hacks.rb +32 -0
  23. data/lib/graffle/third-party/s4t-utils/load-path-auto-adjuster.rb +120 -0
  24. data/lib/graffle/third-party/s4t-utils/more-assertions.rb +29 -0
  25. data/lib/graffle/third-party/s4t-utils/os.rb +28 -0
  26. data/lib/graffle/third-party/s4t-utils/rake-task-helpers.rb +75 -0
  27. data/lib/graffle/third-party/s4t-utils/rakefile-common.rb +106 -0
  28. data/lib/graffle/third-party/s4t-utils/svn-file-movement.rb +101 -0
  29. data/lib/graffle/third-party/s4t-utils/test-util.rb +19 -0
  30. data/lib/graffle/third-party/s4t-utils/version.rb +3 -0
  31. data/lib/graffle/version.rb +8 -0
  32. data/setup.rb +1585 -0
  33. data/test/abstract-graphic-tests.rb +56 -0
  34. data/test/array-and-hash-stereotyping-tests.rb +49 -0
  35. data/test/document-tests.rb +117 -0
  36. data/test/graffle-file-types/as-a-package.graffle/data.plist +953 -0
  37. data/test/graffle-file-types/as-a-package.graffle/image1.png +0 -0
  38. data/test/graffle-file-types/as-a-package.graffle/image2.png +0 -0
  39. data/test/graffle-file-types/as-a-package.graffle/image3.png +0 -0
  40. data/test/graffle-file-types/multiple-canvases.graffle +6821 -0
  41. data/test/graffle-file-types/opening-tests.rb +45 -0
  42. data/test/graffle-file-types/two-boxes-and-a-line.graffle +347 -0
  43. data/test/group-tests.rb +109 -0
  44. data/test/hacks-tests.rb +58 -0
  45. data/test/line-graphic-tests.rb +155 -0
  46. data/test/point-tests.rb +43 -0
  47. data/test/set-standalone-test-paths.rb +5 -0
  48. data/test/shaped-graphic-tests.rb +93 -0
  49. data/test/sheet-tests.rb +124 -0
  50. data/test/styled-text-reader-tests.rb +89 -0
  51. data/test/test-skeleton +19 -0
  52. data/test/text-tests.rb +55 -0
  53. data/test/util.rb +15 -0
  54. metadata +139 -0
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created by Brian Marick on 2007-07-06.
4
+ # Copyright (c) 2007. All rights reserved.
5
+
6
+ require "../set-standalone-test-paths.rb" unless $started_from_rakefile
7
+ require 'test/unit'
8
+ require 's4t-utils'
9
+ include S4tUtils
10
+
11
+ require 'graffle'
12
+ require 'extensions/string'
13
+
14
+ class TestOpeningOfDocuments < Test::Unit::TestCase
15
+ include Graffle
16
+
17
+ def test_reading_of_plain_file
18
+ document = Graffle.parse(relative("multiple-canvases.graffle"))
19
+ assert_equal(3, document.sheets.length)
20
+ #Å pp document.sheets[0].graphics[0]
21
+ end
22
+
23
+ def test_reading_of_package
24
+ document = Graffle.parse(relative("as-a-package.graffle"))
25
+ assert_equal(1, document.sheets.length)
26
+ end
27
+
28
+ def test_reading_of_file_with_lines
29
+ document = Graffle.parse(relative("two-boxes-and-a-line.graffle"))
30
+ assert_equal(1, document.sheets.length)
31
+ line = document.first_sheet.first_line
32
+ assert_equal("the line has a label", line.label_rtf.as_plain_text)
33
+ assert_equal("the line extends from this box", line.tail.content.as_plain_text)
34
+ assert_equal("the line extends to this box", line.head.content.as_plain_text)
35
+
36
+ assert_equal('FilledArrow', line['Style']['stroke']['HeadArrow'])
37
+ end
38
+
39
+
40
+ private
41
+
42
+ def relative(file)
43
+ File.join(PACKAGE_ROOT, 'test', 'graffle-file-types', file)
44
+ end
45
+ end
@@ -0,0 +1,347 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>ActiveLayerIndex</key>
6
+ <integer>0</integer>
7
+ <key>AutoAdjust</key>
8
+ <true/>
9
+ <key>CanvasColor</key>
10
+ <dict>
11
+ <key>w</key>
12
+ <string>1</string>
13
+ </dict>
14
+ <key>CanvasPoint</key>
15
+ <string>{0, 0}</string>
16
+ <key>CanvasScale</key>
17
+ <real>1</real>
18
+ <key>ColumnAlign</key>
19
+ <integer>1</integer>
20
+ <key>ColumnSpacing</key>
21
+ <real>36</real>
22
+ <key>CreationDate</key>
23
+ <string>2007-07-03 13:41:25 -0500</string>
24
+ <key>Creator</key>
25
+ <string>Brian Marick</string>
26
+ <key>DisplayScale</key>
27
+ <string>1 in = 1 in</string>
28
+ <key>GraphDocumentVersion</key>
29
+ <integer>5</integer>
30
+ <key>GraphicsList</key>
31
+ <array>
32
+ <dict>
33
+ <key>Bounds</key>
34
+ <string>{{179.219, 118.716}, {111, 14}}</string>
35
+ <key>Class</key>
36
+ <string>ShapedGraphic</string>
37
+ <key>FitText</key>
38
+ <string>YES</string>
39
+ <key>FontInfo</key>
40
+ <dict>
41
+ <key>Color</key>
42
+ <dict>
43
+ <key>w</key>
44
+ <string>0</string>
45
+ </dict>
46
+ <key>Font</key>
47
+ <string>Helvetica</string>
48
+ <key>Size</key>
49
+ <real>12</real>
50
+ </dict>
51
+ <key>ID</key>
52
+ <integer>10</integer>
53
+ <key>Line</key>
54
+ <dict>
55
+ <key>ID</key>
56
+ <integer>9</integer>
57
+ <key>Offset</key>
58
+ <real>-10.140846252441406</real>
59
+ <key>Position</key>
60
+ <real>0.5693163275718689</real>
61
+ <key>RotationType</key>
62
+ <integer>2</integer>
63
+ </dict>
64
+ <key>Rotation</key>
65
+ <real>62.62640380859375</real>
66
+ <key>Shape</key>
67
+ <string>Rectangle</string>
68
+ <key>Style</key>
69
+ <dict>
70
+ <key>shadow</key>
71
+ <dict>
72
+ <key>Draws</key>
73
+ <string>NO</string>
74
+ </dict>
75
+ <key>stroke</key>
76
+ <dict>
77
+ <key>Draws</key>
78
+ <string>NO</string>
79
+ </dict>
80
+ </dict>
81
+ <key>Text</key>
82
+ <dict>
83
+ <key>Text</key>
84
+ <string>{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420
85
+ {\fonttbl\f0\fswiss\fcharset77 Helvetica;}
86
+ {\colortbl;\red255\green255\blue255;}
87
+ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural
88
+
89
+ \f0\fs24 \cf0 the line has a label}</string>
90
+ </dict>
91
+ </dict>
92
+ <dict>
93
+ <key>Class</key>
94
+ <string>LineGraphic</string>
95
+ <key>Head</key>
96
+ <dict>
97
+ <key>ID</key>
98
+ <integer>8</integer>
99
+ </dict>
100
+ <key>ID</key>
101
+ <integer>9</integer>
102
+ <key>Points</key>
103
+ <array>
104
+ <string>{134.489, 109.964}</string>
105
+ <string>{225, 129}</string>
106
+ <string>{258.425, 193.556}</string>
107
+ </array>
108
+ <key>Style</key>
109
+ <dict>
110
+ <key>stroke</key>
111
+ <dict>
112
+ <key>HeadArrow</key>
113
+ <string>FilledArrow</string>
114
+ <key>TailArrow</key>
115
+ <string>0</string>
116
+ </dict>
117
+ </dict>
118
+ <key>Tail</key>
119
+ <dict>
120
+ <key>ID</key>
121
+ <integer>7</integer>
122
+ </dict>
123
+ </dict>
124
+ <dict>
125
+ <key>Bounds</key>
126
+ <string>{{241, 194}, {70, 67}}</string>
127
+ <key>Class</key>
128
+ <string>ShapedGraphic</string>
129
+ <key>ID</key>
130
+ <integer>8</integer>
131
+ <key>Shape</key>
132
+ <string>Rectangle</string>
133
+ <key>Text</key>
134
+ <dict>
135
+ <key>Text</key>
136
+ <string>{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420
137
+ {\fonttbl\f0\fswiss\fcharset77 Helvetica;}
138
+ {\colortbl;\red255\green255\blue255;}
139
+ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural
140
+
141
+ \f0\fs24 \cf0 the line extends to this box}</string>
142
+ </dict>
143
+ </dict>
144
+ <dict>
145
+ <key>Bounds</key>
146
+ <string>{{64, 69}, {70, 67}}</string>
147
+ <key>Class</key>
148
+ <string>ShapedGraphic</string>
149
+ <key>ID</key>
150
+ <integer>7</integer>
151
+ <key>Shape</key>
152
+ <string>Rectangle</string>
153
+ <key>Text</key>
154
+ <dict>
155
+ <key>Text</key>
156
+ <string>{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420
157
+ {\fonttbl\f0\fswiss\fcharset77 Helvetica;}
158
+ {\colortbl;\red255\green255\blue255;}
159
+ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural
160
+
161
+ \f0\fs24 \cf0 the line extends from this box}</string>
162
+ </dict>
163
+ </dict>
164
+ </array>
165
+ <key>GridInfo</key>
166
+ <dict/>
167
+ <key>GuidesLocked</key>
168
+ <string>NO</string>
169
+ <key>GuidesVisible</key>
170
+ <string>YES</string>
171
+ <key>HPages</key>
172
+ <integer>1</integer>
173
+ <key>ImageCounter</key>
174
+ <integer>1</integer>
175
+ <key>IsPalette</key>
176
+ <string>NO</string>
177
+ <key>KeepToScale</key>
178
+ <false/>
179
+ <key>Layers</key>
180
+ <array>
181
+ <dict>
182
+ <key>Lock</key>
183
+ <string>NO</string>
184
+ <key>Name</key>
185
+ <string>Layer 1</string>
186
+ <key>Print</key>
187
+ <string>YES</string>
188
+ <key>View</key>
189
+ <string>YES</string>
190
+ </dict>
191
+ </array>
192
+ <key>LayoutInfo</key>
193
+ <dict/>
194
+ <key>LinksVisible</key>
195
+ <string>NO</string>
196
+ <key>MagnetsVisible</key>
197
+ <string>NO</string>
198
+ <key>MasterSheet</key>
199
+ <string>Master 1</string>
200
+ <key>MasterSheets</key>
201
+ <array>
202
+ <dict>
203
+ <key>ActiveLayerIndex</key>
204
+ <integer>0</integer>
205
+ <key>AutoAdjust</key>
206
+ <true/>
207
+ <key>CanvasColor</key>
208
+ <dict>
209
+ <key>w</key>
210
+ <string>1</string>
211
+ </dict>
212
+ <key>CanvasPoint</key>
213
+ <string>{0, 0}</string>
214
+ <key>CanvasScale</key>
215
+ <real>1</real>
216
+ <key>ColumnAlign</key>
217
+ <integer>1</integer>
218
+ <key>ColumnSpacing</key>
219
+ <real>36</real>
220
+ <key>DisplayScale</key>
221
+ <string>1 in = 1 in</string>
222
+ <key>GraphicsList</key>
223
+ <array/>
224
+ <key>GridInfo</key>
225
+ <dict/>
226
+ <key>HPages</key>
227
+ <integer>1</integer>
228
+ <key>IsPalette</key>
229
+ <string>NO</string>
230
+ <key>KeepToScale</key>
231
+ <false/>
232
+ <key>Layers</key>
233
+ <array>
234
+ <dict>
235
+ <key>Lock</key>
236
+ <string>NO</string>
237
+ <key>Name</key>
238
+ <string>Layer 1</string>
239
+ <key>Print</key>
240
+ <string>YES</string>
241
+ <key>View</key>
242
+ <string>YES</string>
243
+ </dict>
244
+ </array>
245
+ <key>LayoutInfo</key>
246
+ <dict/>
247
+ <key>Orientation</key>
248
+ <integer>2</integer>
249
+ <key>OutlineStyle</key>
250
+ <string>Basic</string>
251
+ <key>RowAlign</key>
252
+ <integer>1</integer>
253
+ <key>RowSpacing</key>
254
+ <real>36</real>
255
+ <key>SheetTitle</key>
256
+ <string>Master 1</string>
257
+ <key>UniqueID</key>
258
+ <integer>1</integer>
259
+ <key>VPages</key>
260
+ <integer>1</integer>
261
+ </dict>
262
+ </array>
263
+ <key>ModificationDate</key>
264
+ <string>2007-07-06 10:16:08 -0500</string>
265
+ <key>Modifier</key>
266
+ <string>Brian Marick</string>
267
+ <key>NotesVisible</key>
268
+ <string>NO</string>
269
+ <key>Orientation</key>
270
+ <integer>2</integer>
271
+ <key>PointVisible</key>
272
+ <string>NO</string>
273
+ <key>OutlineStyle</key>
274
+ <string>Basic</string>
275
+ <key>PageBreaks</key>
276
+ <string>YES</string>
277
+ <key>PrintInfo</key>
278
+ <dict>
279
+ <key>NSBottomMargin</key>
280
+ <array>
281
+ <string>float</string>
282
+ <string>0</string>
283
+ </array>
284
+ <key>NSLeftMargin</key>
285
+ <array>
286
+ <string>float</string>
287
+ <string>0</string>
288
+ </array>
289
+ <key>NSPaperSize</key>
290
+ <array>
291
+ <string>size</string>
292
+ <string>{612, 792}</string>
293
+ </array>
294
+ <key>NSRightMargin</key>
295
+ <array>
296
+ <string>float</string>
297
+ <string>0</string>
298
+ </array>
299
+ <key>NSTopMargin</key>
300
+ <array>
301
+ <string>float</string>
302
+ <string>0</string>
303
+ </array>
304
+ </dict>
305
+ <key>ReadOnly</key>
306
+ <string>NO</string>
307
+ <key>RowAlign</key>
308
+ <integer>1</integer>
309
+ <key>RowSpacing</key>
310
+ <real>36</real>
311
+ <key>SheetTitle</key>
312
+ <string>Canvas 1</string>
313
+ <key>SmartAlignmentGuidesActive</key>
314
+ <string>YES</string>
315
+ <key>SmartDistanceGuidesActive</key>
316
+ <string>YES</string>
317
+ <key>UniqueID</key>
318
+ <integer>1</integer>
319
+ <key>UseEntirePage</key>
320
+ <true/>
321
+ <key>VPages</key>
322
+ <integer>1</integer>
323
+ <key>WindowInfo</key>
324
+ <dict>
325
+ <key>CurrentSheet</key>
326
+ <string>0</string>
327
+ <key>DrawerOpen</key>
328
+ <false/>
329
+ <key>DrawerTab</key>
330
+ <string>Outline</string>
331
+ <key>DrawerWidth</key>
332
+ <real>209</real>
333
+ <key>FitInWindow</key>
334
+ <false/>
335
+ <key>Frame</key>
336
+ <string>{{323, -33}, {594, 746}}</string>
337
+ <key>ShowRuler</key>
338
+ <false/>
339
+ <key>ShowStatusBar</key>
340
+ <true/>
341
+ <key>VisibleRegion</key>
342
+ <string>{{0, 0}, {579, 632}}</string>
343
+ <key>Zoom</key>
344
+ <string>1</string>
345
+ </dict>
346
+ </dict>
347
+ </plist>
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created by Brian Marick on 2007-07-06.
4
+ # Copyright (c) 2007. All rights reserved.
5
+
6
+ require "set-standalone-test-paths.rb" unless $started_from_rakefile
7
+ require 'test/unit'
8
+ require 's4t-utils'
9
+ include S4tUtils
10
+
11
+ require 'graffle'
12
+
13
+ class TestGroups < Test::Unit::TestCase
14
+ include Graffle
15
+ include Graffle::Builders
16
+
17
+ def test_creation
18
+ assert_true(group.behaves_like?(Group))
19
+ assert_equal("Group", group['Class'])
20
+ assert_equal([], group['Graphics'])
21
+ assert_equal([], group.graphics)
22
+ end
23
+
24
+ def test_group_has_an_array_of_graphics
25
+ abstract = abstract_graphic
26
+ line = line_graphic
27
+ shaped = shaped_graphic
28
+
29
+ assert_equal([abstract, line, shaped],
30
+ group { with abstract, line, shaped }.graphics)
31
+ end
32
+
33
+ def test_group_elements_know_parent
34
+ abstract = abstract_graphic
35
+ line = line_graphic
36
+ shaped = shaped_graphic
37
+ g = group { with abstract, line, shaped }
38
+
39
+ assert_equal(g, abstract.container )
40
+ assert_equal(g, line.container)
41
+ assert_equal(g, shaped.container)
42
+ end
43
+
44
+ def test_groups_have_ids
45
+ o = group { graffle_id_is 1 }
46
+ assert_equal(1, o.graffle_id)
47
+ assert_equal(1, o['ID'])
48
+ end
49
+
50
+ def test_groups_can_be_found_by_id
51
+ s = sheet {
52
+ with group { graffle_id_is 1 }
53
+ }
54
+
55
+ assert_equal(1, s.find_by_id(1).graffle_id)
56
+ end
57
+
58
+
59
+ def test_group_can_find_graphics_by_id
60
+ shaped = shaped_graphic { graffle_id_is 1 }
61
+ line = line_graphic { graffle_id_is 2 }
62
+
63
+ g = group { with shaped, line }
64
+
65
+ assert_equal(shaped, g.find_by_id(1))
66
+ assert_equal(line, g.find_by_id(2))
67
+ assert_nil(g.find_by_id(3))
68
+ end
69
+
70
+ def test_groups_have_containers_too
71
+ s = sheet {
72
+ with group
73
+ }
74
+
75
+ assert_equal(s, s.graphics[0].container)
76
+ end
77
+
78
+ def test_groups_stereotype_and_structure_their_contents
79
+ g = group {
80
+ with head = shaped_graphic { graffle_id_is 333 }
81
+ with tail = shaped_graphic { graffle_id_is 44 }
82
+ with line_graphic {
83
+ graffle_id_is 3
84
+ go_from tail
85
+ go_to head
86
+ }
87
+ }
88
+
89
+ g = Plist.parse_xml(g.to_plist)
90
+ Graffle.stereotype(g)
91
+
92
+ assert_true(g.behaves_like?(Group))
93
+
94
+ assert_true(g.graphics[0].behaves_like?(ShapedGraphic))
95
+ assert_true(g.graphics[1].behaves_like?(ShapedGraphic))
96
+ assert_true(g.graphics[2].behaves_like?(LineGraphic))
97
+
98
+ # graphics link to their parent groups.
99
+ assert_equal(g, g.graphics[0].container)
100
+ assert_equal(g, g.graphics[1].container)
101
+ assert_equal(g, g.graphics[2].container)
102
+
103
+ # links within a group work (this is no surprise)
104
+ assert_equal(g.graphics[0], g.graphics[2].to)
105
+ assert_equal(g.graphics[1], g.graphics[2].from)
106
+ end
107
+
108
+
109
+ end