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,2 @@
1
+ Version 0.1.0
2
+ * Basic version can talk about lines, boxes, sheets, etc.
@@ -0,0 +1,34 @@
1
+ This software is Copyright (C) 2007 by Brian Marick <marick@exampler.com>. It is licensed according to "the Ruby license". Specifically:
2
+
3
+ You can redistribute it and/or modify it under either the terms of the GNU General Public License, version 2, <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html> or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a) place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b) use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c) make other distribution arrangements with the author.
21
+
22
+ 3. You may modify and include part of the software into any other
23
+ software (possibly commercial).
24
+
25
+ 4. Text or files supplied as input to or produced as output from
26
+ the software do not automatically fall under the copyright of the
27
+ software, but belong to whomever generated them, and may be sold
28
+ commercially, and may be aggregated with this software.
29
+
30
+ 5. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
31
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
32
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33
+ PURPOSE.
34
+
@@ -0,0 +1,53 @@
1
+ History.txt
2
+ LICENSE.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ Rakefile.hoe
7
+ bin/bin-skeleton
8
+ graffle.tmproj
9
+ lib/graffle.rb
10
+ lib/graffle/.document
11
+ lib/graffle/lib-skeleton
12
+ lib/graffle/nodoc/hacks.rb
13
+ lib/graffle/point.rb
14
+ lib/graffle/stereotypes.rb
15
+ lib/graffle/styled-text-reader.rb
16
+ lib/graffle/third-party/s4t-utils.rb
17
+ lib/graffle/third-party/s4t-utils/capturing-globals.rb
18
+ lib/graffle/third-party/s4t-utils/claims.rb
19
+ lib/graffle/third-party/s4t-utils/command-line.rb
20
+ lib/graffle/third-party/s4t-utils/error-handling.rb
21
+ lib/graffle/third-party/s4t-utils/friendly-format.rb
22
+ lib/graffle/third-party/s4t-utils/hacks.rb
23
+ lib/graffle/third-party/s4t-utils/load-path-auto-adjuster.rb
24
+ lib/graffle/third-party/s4t-utils/more-assertions.rb
25
+ lib/graffle/third-party/s4t-utils/os.rb
26
+ lib/graffle/third-party/s4t-utils/rake-task-helpers.rb
27
+ lib/graffle/third-party/s4t-utils/rakefile-common.rb
28
+ lib/graffle/third-party/s4t-utils/svn-file-movement.rb
29
+ lib/graffle/third-party/s4t-utils/test-util.rb
30
+ lib/graffle/third-party/s4t-utils/version.rb
31
+ lib/graffle/version.rb
32
+ setup.rb
33
+ test/abstract-graphic-tests.rb
34
+ test/array-and-hash-stereotyping-tests.rb
35
+ test/document-tests.rb
36
+ test/graffle-file-types/as-a-package.graffle/data.plist
37
+ test/graffle-file-types/as-a-package.graffle/image1.png
38
+ test/graffle-file-types/as-a-package.graffle/image2.png
39
+ test/graffle-file-types/as-a-package.graffle/image3.png
40
+ test/graffle-file-types/multiple-canvases.graffle
41
+ test/graffle-file-types/opening-tests.rb
42
+ test/graffle-file-types/two-boxes-and-a-line.graffle
43
+ test/group-tests.rb
44
+ test/hacks-tests.rb
45
+ test/line-graphic-tests.rb
46
+ test/point-tests.rb
47
+ test/set-standalone-test-paths.rb
48
+ test/shaped-graphic-tests.rb
49
+ test/sheet-tests.rb
50
+ test/styled-text-reader-tests.rb
51
+ test/test-skeleton
52
+ test/text-tests.rb
53
+ test/util.rb
@@ -0,0 +1,19 @@
1
+ This is a package that parses OmniGraffle documents. {Omnigraffle}[http://www.omnigroup.com/applications/omnigraffle/] is a drawing program only available on the Mac.
2
+
3
+ OmniGraffle documents are stored in Apple {plist format}[http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Articles/XMLPListsConcept.html]. This package first
4
+ uses the {Plist}[http://rubyforge.org/projects/plist/] gem to read the document and convert it into a structure of
5
+ _nodes_ (hashes and arrays). It then descends the structure and decorates the nodes with methods that give more convenient access to some of their content.
6
+
7
+ Here's a short example of some of the accessors in action:
8
+
9
+ document = Graffle.parse("two-boxes-and-a-line.graffle")
10
+ line = document.first_sheet.first_line
11
+ puts line.tail.content.as_plain_text
12
+ puts line.head.content.as_plain_text
13
+ puts line.label_rtf.as_plain_text
14
+
15
+ All of the raw data is still available:
16
+
17
+ puts line['Style']['stroke']['HeadArrow']
18
+
19
+ The process of decorating a node is called _stereotyping_ it. Nodes are stereotyped with modules, and the node is said to _behave_ _like_ that module.
@@ -0,0 +1,32 @@
1
+ # This is a Rakefile that would live in the root folder for any package
2
+ # that follows the Scripting for Testers conventions. You should not need
3
+ # to edit it.
4
+
5
+ $started_from_rakefile=true
6
+
7
+ require 'pathname'
8
+ PACKAGE_ROOT = Dir.pwd
9
+ $:.unshift("#{PACKAGE_ROOT}/lib")
10
+ require 'graffle/third-party/s4t-utils/load-path-auto-adjuster'
11
+
12
+ require 's4t-utils'
13
+ include S4tUtils
14
+
15
+ # The following two lines are used to tell generic Rake tasks about
16
+ # this particular project. If you installed using the s4t-utils
17
+ # installation tool, they should have already been set correctly.
18
+
19
+ MyFileSystemName='graffle' # No ".rb" extension.
20
+ MyModuleName='Graffle'
21
+
22
+
23
+ # These are the Ruby files 'rake rdoc' searchs for documentation.
24
+ # The following includes all ruby files except for third-party
25
+ # libraries. Change at will.
26
+
27
+ MyRdocFiles = FileList.new("lib/graffle.rb",
28
+ "lib/graffle/**/*.rb").exclude("**/third-party/**")
29
+
30
+
31
+ require 's4t-utils/rakefile-common'
32
+
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created by Brian Marick on 2007-07-03.
4
+ # Copyright (c) 2007. All rights reserved.
5
+
6
+ require 'hoe'
7
+ require 'graffle/version'
8
+
9
+ def second_level_to_document
10
+ files = File.read("lib/graffle/.document").split
11
+ files.collect { |f| "lib/graffle/" + f }.join('|')
12
+ end
13
+
14
+ Hoe.new("graffle", Graffle::Version) do |p|
15
+ p.rubyforge_name = "graffle"
16
+ p.author = "Brian Marick"
17
+ p.description = "Working with OmniGraffle documents."
18
+ p.email = "marick@exampler.com"
19
+ p.extra_deps = [['extensions', '>= 0.6.0'],
20
+ ['plist', '>= 3.0.0']]
21
+ p.test_globs = "test/**/*-tests.rb"
22
+ p.rdoc_pattern = %r{README.txt|History.txt|lib/graffle.rb|#{second_level_to_document}}
23
+ end
@@ -0,0 +1,23 @@
1
+ #! /opt/local/bin/ruby
2
+
3
+ ### The following adjusts the load path so that the correct version of
4
+ ### a self-contained package is found, no matter where the script is
5
+ ### run from.
6
+ require 'pathname'
7
+ $:.unshift((Pathname.new(__FILE__).parent.parent + 'lib').to_s)
8
+ require 'graffle/third-party/s4t-utils/load-path-auto-adjuster'
9
+
10
+
11
+ require 's4t-utils'
12
+ include S4tUtils
13
+
14
+ require 'graffle'
15
+ # You probably want to include your module as well, but I won't assume
16
+ # that.
17
+ # include Graffle
18
+
19
+ if $0 == __FILE__
20
+ with_pleasant_exceptions do
21
+ # Your program here.
22
+ end
23
+ end
@@ -0,0 +1,335 @@
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>currentDocument</key>
6
+ <string>test/line-graphic-tests.rb</string>
7
+ <key>documents</key>
8
+ <array>
9
+ <dict>
10
+ <key>expanded</key>
11
+ <true/>
12
+ <key>name</key>
13
+ <string>graffle</string>
14
+ <key>regexFolderFilter</key>
15
+ <string>!.*/(\.[^/]*|CVS|third-party|pkg|doc|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
16
+ <key>selected</key>
17
+ <true/>
18
+ <key>sourceDirectory</key>
19
+ <string></string>
20
+ </dict>
21
+ </array>
22
+ <key>fileHierarchyDrawerWidth</key>
23
+ <integer>200</integer>
24
+ <key>metaData</key>
25
+ <dict>
26
+ <key>README.txt</key>
27
+ <dict>
28
+ <key>caret</key>
29
+ <dict>
30
+ <key>column</key>
31
+ <integer>15</integer>
32
+ <key>line</key>
33
+ <integer>15</integer>
34
+ </dict>
35
+ <key>firstVisibleColumn</key>
36
+ <integer>0</integer>
37
+ <key>firstVisibleLine</key>
38
+ <integer>0</integer>
39
+ </dict>
40
+ <key>Rakefile</key>
41
+ <dict>
42
+ <key>caret</key>
43
+ <dict>
44
+ <key>column</key>
45
+ <integer>22</integer>
46
+ <key>line</key>
47
+ <integer>7</integer>
48
+ </dict>
49
+ <key>firstVisibleColumn</key>
50
+ <integer>0</integer>
51
+ <key>firstVisibleLine</key>
52
+ <integer>0</integer>
53
+ </dict>
54
+ <key>lib/graffle/nodoc/hacks.rb</key>
55
+ <dict>
56
+ <key>caret</key>
57
+ <dict>
58
+ <key>column</key>
59
+ <integer>5</integer>
60
+ <key>line</key>
61
+ <integer>39</integer>
62
+ </dict>
63
+ <key>firstVisibleColumn</key>
64
+ <integer>0</integer>
65
+ <key>firstVisibleLine</key>
66
+ <integer>14</integer>
67
+ </dict>
68
+ <key>lib/graffle/stereotypes.rb</key>
69
+ <dict>
70
+ <key>caret</key>
71
+ <dict>
72
+ <key>column</key>
73
+ <integer>27</integer>
74
+ <key>line</key>
75
+ <integer>170</integer>
76
+ </dict>
77
+ <key>firstVisibleColumn</key>
78
+ <integer>0</integer>
79
+ <key>firstVisibleLine</key>
80
+ <integer>150</integer>
81
+ </dict>
82
+ <key>lib/graffle/styled-text-reader.rb</key>
83
+ <dict>
84
+ <key>caret</key>
85
+ <dict>
86
+ <key>column</key>
87
+ <integer>0</integer>
88
+ <key>line</key>
89
+ <integer>9</integer>
90
+ </dict>
91
+ <key>firstVisibleColumn</key>
92
+ <integer>0</integer>
93
+ <key>firstVisibleLine</key>
94
+ <integer>0</integer>
95
+ </dict>
96
+ <key>test/abstract-graphic-tests.rb</key>
97
+ <dict>
98
+ <key>caret</key>
99
+ <dict>
100
+ <key>column</key>
101
+ <integer>49</integer>
102
+ <key>line</key>
103
+ <integer>10</integer>
104
+ </dict>
105
+ <key>firstVisibleColumn</key>
106
+ <integer>0</integer>
107
+ <key>firstVisibleLine</key>
108
+ <integer>0</integer>
109
+ </dict>
110
+ <key>test/array-and-hash-stereotyping-tests.rb</key>
111
+ <dict>
112
+ <key>caret</key>
113
+ <dict>
114
+ <key>column</key>
115
+ <integer>25</integer>
116
+ <key>line</key>
117
+ <integer>29</integer>
118
+ </dict>
119
+ <key>firstVisibleColumn</key>
120
+ <integer>0</integer>
121
+ <key>firstVisibleLine</key>
122
+ <integer>0</integer>
123
+ </dict>
124
+ <key>test/document-tests.rb</key>
125
+ <dict>
126
+ <key>caret</key>
127
+ <dict>
128
+ <key>column</key>
129
+ <integer>0</integer>
130
+ <key>line</key>
131
+ <integer>106</integer>
132
+ </dict>
133
+ <key>firstVisibleColumn</key>
134
+ <integer>0</integer>
135
+ <key>firstVisibleLine</key>
136
+ <integer>0</integer>
137
+ </dict>
138
+ <key>test/graffle-file-types/as-a-package.graffle/data.plist</key>
139
+ <dict>
140
+ <key>caret</key>
141
+ <dict>
142
+ <key>column</key>
143
+ <integer>18</integer>
144
+ <key>line</key>
145
+ <integer>560</integer>
146
+ </dict>
147
+ <key>firstVisibleColumn</key>
148
+ <integer>0</integer>
149
+ <key>firstVisibleLine</key>
150
+ <integer>525</integer>
151
+ </dict>
152
+ <key>test/graffle-file-types/multiple-canvases.graffle</key>
153
+ <dict>
154
+ <key>caret</key>
155
+ <dict>
156
+ <key>column</key>
157
+ <integer>20</integer>
158
+ <key>line</key>
159
+ <integer>599</integer>
160
+ </dict>
161
+ <key>firstVisibleColumn</key>
162
+ <integer>0</integer>
163
+ <key>firstVisibleLine</key>
164
+ <integer>559</integer>
165
+ </dict>
166
+ <key>test/graffle-file-types/opening-tests.rb</key>
167
+ <dict>
168
+ <key>caret</key>
169
+ <dict>
170
+ <key>column</key>
171
+ <integer>65</integer>
172
+ <key>line</key>
173
+ <integer>26</integer>
174
+ </dict>
175
+ <key>firstVisibleColumn</key>
176
+ <integer>0</integer>
177
+ <key>firstVisibleLine</key>
178
+ <integer>3</integer>
179
+ </dict>
180
+ <key>test/graffle-file-types/two-boxes-and-a-line.graffle</key>
181
+ <dict>
182
+ <key>caret</key>
183
+ <dict>
184
+ <key>column</key>
185
+ <integer>0</integer>
186
+ <key>line</key>
187
+ <integer>0</integer>
188
+ </dict>
189
+ <key>firstVisibleColumn</key>
190
+ <integer>0</integer>
191
+ <key>firstVisibleLine</key>
192
+ <integer>0</integer>
193
+ </dict>
194
+ <key>test/group-tests.rb</key>
195
+ <dict>
196
+ <key>caret</key>
197
+ <dict>
198
+ <key>column</key>
199
+ <integer>26</integer>
200
+ <key>line</key>
201
+ <integer>12</integer>
202
+ </dict>
203
+ <key>firstVisibleColumn</key>
204
+ <integer>0</integer>
205
+ <key>firstVisibleLine</key>
206
+ <integer>0</integer>
207
+ </dict>
208
+ <key>test/hacks-tests.rb</key>
209
+ <dict>
210
+ <key>caret</key>
211
+ <dict>
212
+ <key>column</key>
213
+ <integer>28</integer>
214
+ <key>line</key>
215
+ <integer>42</integer>
216
+ </dict>
217
+ <key>firstVisibleColumn</key>
218
+ <integer>0</integer>
219
+ <key>firstVisibleLine</key>
220
+ <integer>19</integer>
221
+ </dict>
222
+ <key>test/line-graphic-tests.rb</key>
223
+ <dict>
224
+ <key>caret</key>
225
+ <dict>
226
+ <key>column</key>
227
+ <integer>4</integer>
228
+ <key>line</key>
229
+ <integer>91</integer>
230
+ </dict>
231
+ <key>firstVisibleColumn</key>
232
+ <integer>0</integer>
233
+ <key>firstVisibleLine</key>
234
+ <integer>57</integer>
235
+ </dict>
236
+ <key>test/shaped-graphic-tests.rb</key>
237
+ <dict>
238
+ <key>caret</key>
239
+ <dict>
240
+ <key>column</key>
241
+ <integer>0</integer>
242
+ <key>line</key>
243
+ <integer>18</integer>
244
+ </dict>
245
+ <key>firstVisibleColumn</key>
246
+ <integer>0</integer>
247
+ <key>firstVisibleLine</key>
248
+ <integer>0</integer>
249
+ </dict>
250
+ <key>test/sheet-tests.rb</key>
251
+ <dict>
252
+ <key>caret</key>
253
+ <dict>
254
+ <key>column</key>
255
+ <integer>3</integer>
256
+ <key>line</key>
257
+ <integer>121</integer>
258
+ </dict>
259
+ <key>firstVisibleColumn</key>
260
+ <integer>0</integer>
261
+ <key>firstVisibleLine</key>
262
+ <integer>87</integer>
263
+ </dict>
264
+ <key>test/styled-text-reader-tests.rb</key>
265
+ <dict>
266
+ <key>caret</key>
267
+ <dict>
268
+ <key>column</key>
269
+ <integer>37</integer>
270
+ <key>line</key>
271
+ <integer>41</integer>
272
+ </dict>
273
+ <key>firstVisibleColumn</key>
274
+ <integer>0</integer>
275
+ <key>firstVisibleLine</key>
276
+ <integer>16</integer>
277
+ </dict>
278
+ <key>test/test-skeleton</key>
279
+ <dict>
280
+ <key>caret</key>
281
+ <dict>
282
+ <key>column</key>
283
+ <integer>0</integer>
284
+ <key>line</key>
285
+ <integer>12</integer>
286
+ </dict>
287
+ <key>firstVisibleColumn</key>
288
+ <integer>0</integer>
289
+ <key>firstVisibleLine</key>
290
+ <integer>0</integer>
291
+ </dict>
292
+ <key>test/text-tests.rb</key>
293
+ <dict>
294
+ <key>caret</key>
295
+ <dict>
296
+ <key>column</key>
297
+ <integer>0</integer>
298
+ <key>line</key>
299
+ <integer>28</integer>
300
+ </dict>
301
+ <key>firstVisibleColumn</key>
302
+ <integer>0</integer>
303
+ <key>firstVisibleLine</key>
304
+ <integer>0</integer>
305
+ </dict>
306
+ </dict>
307
+ <key>openDocuments</key>
308
+ <array>
309
+ <string>test/graffle-file-types/as-a-package.graffle/data.plist</string>
310
+ <string>test/styled-text-reader-tests.rb</string>
311
+ <string>test/test-skeleton</string>
312
+ <string>Rakefile</string>
313
+ <string>test/graffle-file-types/multiple-canvases.graffle</string>
314
+ <string>test/hacks-tests.rb</string>
315
+ <string>test/line-graphic-tests.rb</string>
316
+ <string>lib/graffle/stereotypes.rb</string>
317
+ <string>test/abstract-graphic-tests.rb</string>
318
+ <string>test/graffle-file-types/opening-tests.rb</string>
319
+ <string>test/graffle-file-types/two-boxes-and-a-line.graffle</string>
320
+ <string>README.txt</string>
321
+ <string>test/group-tests.rb</string>
322
+ <string>test/document-tests.rb</string>
323
+ <string>lib/graffle/styled-text-reader.rb</string>
324
+ <string>test/shaped-graphic-tests.rb</string>
325
+ <string>lib/graffle/nodoc/hacks.rb</string>
326
+ <string>test/array-and-hash-stereotyping-tests.rb</string>
327
+ <string>test/sheet-tests.rb</string>
328
+ <string>test/text-tests.rb</string>
329
+ </array>
330
+ <key>showFileHierarchyDrawer</key>
331
+ <true/>
332
+ <key>windowFrame</key>
333
+ <string>{{5, 0}, {740, 778}}</string>
334
+ </dict>
335
+ </plist>