xamplr 1.2.0 → 1.3.15
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +12 -0
- data/CHANGES.txt +37 -0
- data/COPYING +661 -0
- data/Makefile +13 -0
- data/README.rdoc +24 -4
- data/Rakefile +2 -2
- data/VERSION.yml +3 -2
- data/bin/xampl-gen +17 -0
- data/docs/intro/.gitignore +1 -0
- data/docs/intro/example1/example1.rb +6 -0
- data/docs/intro/example1/xml/hello.xml +1 -0
- data/docs/intro/example2/example2.rb +38 -0
- data/docs/intro/example2/project-generator.rb +22 -0
- data/docs/intro/example2/xml/hello.xml +2 -0
- data/docs/intro/example3/example3.rb +30 -0
- data/docs/intro/example3/example3a.rb +16 -0
- data/docs/intro/example3/generated.png +0 -0
- data/docs/intro/example3/grab-yuml.rb +10 -0
- data/docs/intro/example3/greeter.rb +15 -0
- data/docs/intro/example3/greeting.rb +9 -0
- data/docs/intro/example3/project-generator.rb +25 -0
- data/docs/intro/example3/xml/greeter.xml +6 -0
- data/docs/intro/example4/example4.rb +27 -0
- data/docs/intro/example4/example4a.rb +19 -0
- data/docs/intro/example4/grab-yuml.rb +10 -0
- data/docs/intro/example4/greeter.rb +15 -0
- data/docs/intro/example4/greeting.rb +9 -0
- data/docs/intro/example4/project-generator.rb +25 -0
- data/docs/intro/example4/xml/greeter.xml +6 -0
- data/docs/intro/grab-yuml.rb +10 -0
- data/docs/intro/project-generator.rb +51 -0
- data/docs/intro/xampl.lyx +1494 -0
- data/docs/intro/xampl.pdf +0 -0
- data/examples/employees/final/xampl-gen.rb +38 -0
- data/examples/employees/final/xml/ddd-final.xml +86 -0
- data/examples/employees/final-xampl/xampl-gen.rb +38 -0
- data/examples/employees/final-xampl/xml/ddd-final-xampl.xml +86 -0
- data/examples/employees/first/xampl-gen.rb +38 -0
- data/examples/employees/first/xml/ddd-first.xml +48 -0
- data/examples/employees/twist/twist.graphml +333 -0
- data/examples/employees/twist/xampl-gen.rb +38 -0
- data/examples/employees/twist/xml/twist.xml +90 -0
- data/examples/employees/xamplr-twist.xml +2 -0
- data/examples/employees/yuml-diagrams/DDD-final-approach.graphml +393 -0
- data/examples/employees/yuml-diagrams/DDD-final-xampl-approach.graphml +265 -0
- data/examples/employees/yuml-diagrams/DDD-ideal-final-approach.graphml +357 -0
- data/examples/employees/yuml-diagrams/ddd-final.png +0 -0
- data/examples/employees/yuml-diagrams/ddd-final.yuml +8 -0
- data/examples/employees/yuml-diagrams/ddd-first.png +0 -0
- data/examples/employees/yuml-diagrams/ddd-first.yuml +7 -0
- data/examples/employees/yuml-diagrams/final-yed.png +0 -0
- data/examples/employees/yuml-diagrams/first-yed.png +0 -0
- data/examples/employees/yuml-diagrams/twist.png +0 -0
- data/examples/employees/yuml-diagrams/twist.yuml +12 -0
- data/examples/employees/yuml-diagrams/xamplr-final-no-mixins.png +0 -0
- data/examples/employees/yuml-diagrams/xamplr-final-simplified.png +0 -0
- data/examples/employees/yuml-diagrams/xamplr-final-with-mixins.png +0 -0
- data/examples/employees/yuml-diagrams/yuml-simplified.txt +19 -0
- data/examples/employees/yuml-diagrams/yuml-with-mixins.txt +53 -0
- data/examples/employees/yuml-diagrams/yuml.txt +27 -0
- data/examples/hobbies/Makefile +5 -0
- data/examples/hobbies/hobbies.rb +193 -0
- data/examples/hobbies/project-generator.rb +25 -0
- data/examples/hobbies/xampl-gen.rb +38 -0
- data/examples/hobbies/xml/hobby.xml +3 -0
- data/examples/hobbies/xml/people.xml +5 -0
- data/examples/random-people/.gitignore +2 -0
- data/examples/random-people/Makefile +5 -1
- data/examples/random-people/xampl-gen.rb +5 -2
- data/examples/random-people-shared-addresses/.gitignore +2 -0
- data/examples/random-people-shared-addresses/Makefile +8 -9
- data/examples/random-people-shared-addresses/batch-load-users-profiled.rb +91 -0
- data/examples/random-people-shared-addresses/batch-load-users-safe.rb +81 -0
- data/examples/random-people-shared-addresses/batch-load-users.rb +59 -63
- data/examples/random-people-shared-addresses/xampl-gen.rb +2 -0
- data/examples/read-testing/.gitignore +2 -0
- data/examples/read-testing/rrr.rb +2 -1
- data/examples/read-testing/xampl-gen.rb +2 -0
- data/examples/tokyo-cabinet-experimental/.gitignore +2 -0
- data/examples/tokyo-cabinet-experimental/xampl-gen.rb +2 -0
- data/examples/write-testing/README +4 -0
- data/examples/write-testing/RESULTS.home +33 -0
- data/examples/write-testing/RESULTS.raconteur +33 -0
- data/examples/write-testing/write-speed-test.rb +40 -0
- data/lib/xamplr/.cvsignore +1 -0
- data/lib/xamplr/TODO +2 -1
- data/lib/xamplr/exceptions.rb +24 -1
- data/lib/xamplr/from-xml.rb +13 -5
- data/lib/xamplr/graphml-out.rb +6 -25
- data/lib/xamplr/indexed-array.rb +10 -2
- data/lib/xamplr/persist-to-xml.rb +6 -7
- data/lib/xamplr/persistence.rb +132 -48
- data/lib/xamplr/persister.rb +48 -25
- data/lib/xamplr/persisters/filesystem.rb +8 -2
- data/lib/xamplr/persisters/tokyo-cabinet.rb +243 -63
- data/lib/xamplr/persisters/tokyo-cabinet.rb.1-DB +694 -0
- data/lib/xamplr/persisters/tokyo-cabinet.rb.N-DB +692 -0
- data/lib/xamplr/persisters/tokyo-cabinet.rb.NICE-TRY +807 -0
- data/lib/xamplr/templates/.cvsignore +3 -0
- data/lib/xamplr/templates/child_indexed.template +6 -6
- data/lib/xamplr/templates/element_data.template +2 -1
- data/lib/xamplr/templates/element_empty.template +2 -10
- data/lib/xamplr/templates/element_mixed.template +2 -1
- data/lib/xamplr/templates/element_simple.template +2 -1
- data/lib/xamplr/templates/package.template +13 -1
- data/lib/xamplr/visitor.rb +7 -6
- data/lib/xamplr/visitors.rb +2 -1
- data/lib/xamplr/xampl-cl-gen.rb +89 -0
- data/lib/xamplr/xampl-generator.rb +86 -50
- data/lib/xamplr/xampl-object.rb +51 -0
- data/lib/xamplr/xampl-persisted-object.rb +13 -4
- data/lib/xamplr/yuml-out.rb +129 -0
- data/lib/xamplr-generator.rb +0 -1
- data/lib/xamplr.rb +18 -18
- data/regression/tc-indexes-crossing-pid-boundaries/Makefile +14 -0
- data/regression/tc-indexes-crossing-pid-boundaries/bad-idea.rb +40 -0
- data/regression/tc-indexes-crossing-pid-boundaries/fail-badly.rb +17 -0
- data/regression/tc-indexes-crossing-pid-boundaries/fail.rb +11 -0
- data/regression/tc-indexes-crossing-pid-boundaries/fucking-bad-idea.rb +44 -0
- data/regression/tc-indexes-crossing-pid-boundaries/setup.rb +15 -0
- data/regression/tc-indexes-crossing-pid-boundaries/xml/bad-idea.xml +4 -0
- data/regression/tightly-nested-mutual-mentions/Makefile +14 -0
- data/regression/tightly-nested-mutual-mentions/build.rb +31 -0
- data/regression/tightly-nested-mutual-mentions/load.rb +21 -0
- data/regression/tightly-nested-mutual-mentions/repo-keep.tgz +0 -0
- data/regression/tightly-nested-mutual-mentions/setup.rb +8 -0
- data/regression/tightly-nested-mutual-mentions/xampl-gen.rb +36 -0
- data/regression/tightly-nested-mutual-mentions/xml/stuff.xml +7 -0
- data/xamplr.gemspec +322 -0
- metadata +116 -13
- data/test/test_helper.rb +0 -10
- data/test/xamplr_test.rb +0 -7
@@ -0,0 +1,1494 @@
|
|
1
|
+
#LyX 1.6.4.1 created this file. For more info see http://www.lyx.org/
|
2
|
+
\lyxformat 345
|
3
|
+
\begin_document
|
4
|
+
\begin_header
|
5
|
+
\textclass book
|
6
|
+
\begin_preamble
|
7
|
+
\usepackage{color}
|
8
|
+
\usepackage{alltt}
|
9
|
+
|
10
|
+
|
11
|
+
\newcommand{\hlstd}[1]{\textcolor[rgb]{0,0,0}{#1}}
|
12
|
+
\newcommand{\hlnum}[1]{\textcolor[rgb]{0.16,0.16,1}{#1}}
|
13
|
+
\newcommand{\hlesc}[1]{\textcolor[rgb]{1,0,1}{#1}}
|
14
|
+
\newcommand{\hlstr}[1]{\textcolor[rgb]{1,0,0}{#1}}
|
15
|
+
\newcommand{\hldstr}[1]{\textcolor[rgb]{0.51,0.51,0}{#1}}
|
16
|
+
\newcommand{\hlslc}[1]{\textcolor[rgb]{0.51,0.51,0.51}{\it{#1}}}
|
17
|
+
\newcommand{\hlcom}[1]{\textcolor[rgb]{0.51,0.51,0.51}{\it{#1}}}
|
18
|
+
\newcommand{\hldir}[1]{\textcolor[rgb]{0,0.51,0}{#1}}
|
19
|
+
\newcommand{\hlsym}[1]{\textcolor[rgb]{0,0,0}{#1}}
|
20
|
+
\newcommand{\hlline}[1]{\textcolor[rgb]{0.33,0.33,0.33}{#1}}
|
21
|
+
\newcommand{\hlkwa}[1]{\textcolor[rgb]{0,0,0}{\bf{#1}}}
|
22
|
+
\newcommand{\hlkwb}[1]{\textcolor[rgb]{0.51,0,0}{#1}}
|
23
|
+
\newcommand{\hlkwc}[1]{\textcolor[rgb]{0,0,0}{\bf{#1}}}
|
24
|
+
\newcommand{\hlkwd}[1]{\textcolor[rgb]{0,0,0.51}{#1}}
|
25
|
+
\end_preamble
|
26
|
+
\use_default_options true
|
27
|
+
\language british
|
28
|
+
\inputencoding auto
|
29
|
+
\font_roman default
|
30
|
+
\font_sans default
|
31
|
+
\font_typewriter default
|
32
|
+
\font_default_family default
|
33
|
+
\font_sc false
|
34
|
+
\font_osf false
|
35
|
+
\font_sf_scale 100
|
36
|
+
\font_tt_scale 100
|
37
|
+
|
38
|
+
\graphics default
|
39
|
+
\float_placement h
|
40
|
+
\paperfontsize default
|
41
|
+
\spacing single
|
42
|
+
\use_hyperref true
|
43
|
+
\pdf_bookmarks true
|
44
|
+
\pdf_bookmarksnumbered false
|
45
|
+
\pdf_bookmarksopen false
|
46
|
+
\pdf_bookmarksopenlevel 1
|
47
|
+
\pdf_breaklinks true
|
48
|
+
\pdf_pdfborder true
|
49
|
+
\pdf_colorlinks true
|
50
|
+
\pdf_backref false
|
51
|
+
\pdf_pdfusetitle true
|
52
|
+
\papersize default
|
53
|
+
\use_geometry false
|
54
|
+
\use_amsmath 1
|
55
|
+
\use_esint 1
|
56
|
+
\cite_engine basic
|
57
|
+
\use_bibtopic false
|
58
|
+
\paperorientation portrait
|
59
|
+
\secnumdepth 3
|
60
|
+
\tocdepth 3
|
61
|
+
\paragraph_separation skip
|
62
|
+
\defskip medskip
|
63
|
+
\quotes_language english
|
64
|
+
\papercolumns 1
|
65
|
+
\papersides 1
|
66
|
+
\paperpagestyle default
|
67
|
+
\tracking_changes false
|
68
|
+
\output_changes false
|
69
|
+
\author ""
|
70
|
+
\author ""
|
71
|
+
\end_header
|
72
|
+
|
73
|
+
\begin_body
|
74
|
+
|
75
|
+
\begin_layout Title
|
76
|
+
Xampl
|
77
|
+
\end_layout
|
78
|
+
|
79
|
+
\begin_layout Author
|
80
|
+
Bob Hutchison
|
81
|
+
\end_layout
|
82
|
+
|
83
|
+
\begin_layout Standard
|
84
|
+
\begin_inset CommandInset toc
|
85
|
+
LatexCommand tableofcontents
|
86
|
+
|
87
|
+
\end_inset
|
88
|
+
|
89
|
+
|
90
|
+
\end_layout
|
91
|
+
|
92
|
+
\begin_layout Part
|
93
|
+
Introduction
|
94
|
+
\end_layout
|
95
|
+
|
96
|
+
\begin_layout Chapter
|
97
|
+
Installing Xampl
|
98
|
+
\end_layout
|
99
|
+
|
100
|
+
\begin_layout Part
|
101
|
+
Xampl by Example
|
102
|
+
\end_layout
|
103
|
+
|
104
|
+
\begin_layout Chapter
|
105
|
+
A Little Background
|
106
|
+
\end_layout
|
107
|
+
|
108
|
+
\begin_layout Standard
|
109
|
+
Over the last ten or eleven years I've taught a bunch of programmers how
|
110
|
+
to use xampl.
|
111
|
+
It normally takes about 45 minutes to get them going… and then an extended
|
112
|
+
period of intermittent answering questions and making suggestions.
|
113
|
+
To do this I took advantage of the shared context of a project we both
|
114
|
+
were working on.
|
115
|
+
\end_layout
|
116
|
+
|
117
|
+
\begin_layout Standard
|
118
|
+
Xampl has never been documented, though several attempts have been made.
|
119
|
+
This time I'm serious.
|
120
|
+
\end_layout
|
121
|
+
|
122
|
+
\begin_layout Standard
|
123
|
+
I think teaching technique won't translate very well to print and example
|
124
|
+
code.
|
125
|
+
I suppose I could try simulate this and choose some well understood domain,
|
126
|
+
like weblogs, and work that through\SpecialChar \ldots{}
|
127
|
+
and hope that'd work.
|
128
|
+
It might if I was sitting beside you, but I'm not.
|
129
|
+
And I have to do something, so I'm going to take a bunch of passes at writing
|
130
|
+
a progressively more complex 'Hello World' program.
|
131
|
+
A bit of a stretch, but\SpecialChar \ldots{}
|
132
|
+
|
133
|
+
\end_layout
|
134
|
+
|
135
|
+
\begin_layout Chapter
|
136
|
+
Hello World
|
137
|
+
\end_layout
|
138
|
+
|
139
|
+
\begin_layout Section
|
140
|
+
Hello World, Take One
|
141
|
+
\end_layout
|
142
|
+
|
143
|
+
\begin_layout Subsection
|
144
|
+
The Experiment
|
145
|
+
\end_layout
|
146
|
+
|
147
|
+
\begin_layout Standard
|
148
|
+
Let's see if we can get a start with xampl by using it to print hello-world
|
149
|
+
on the screen.
|
150
|
+
Then I'll explain what happened.
|
151
|
+
\end_layout
|
152
|
+
|
153
|
+
\begin_layout Standard
|
154
|
+
\noindent
|
155
|
+
You'll need to create a directory somewhere in which to place the files
|
156
|
+
associated with this project.
|
157
|
+
I'll be defining path names using
|
158
|
+
\family typewriter
|
159
|
+
.
|
160
|
+
|
161
|
+
\family default
|
162
|
+
to mean this directory, so you might want to open a terminal and change
|
163
|
+
directories to it.
|
164
|
+
The source for this example is distributed in the xampl gem and is located
|
165
|
+
at
|
166
|
+
\family typewriter
|
167
|
+
<path to the xampl gem>/docs/intro/example1
|
168
|
+
\family default
|
169
|
+
which will likely be read-only and so should be copied someplace else
|
170
|
+
\begin_inset Foot
|
171
|
+
status open
|
172
|
+
|
173
|
+
\begin_layout Plain Layout
|
174
|
+
If you are lazy, which is possibly one of the very good reasons you are
|
175
|
+
interested in xampl, then you can simply untar the file
|
176
|
+
\family typewriter
|
177
|
+
<path to the xampl gem>/docs/intro/examples.tgz
|
178
|
+
\family default
|
179
|
+
(or unzip
|
180
|
+
\family typewriter
|
181
|
+
<path to the xampl gem>/docs/intro/examples.zip
|
182
|
+
\family default
|
183
|
+
) to someplace convenient.
|
184
|
+
\end_layout
|
185
|
+
|
186
|
+
\end_inset
|
187
|
+
|
188
|
+
.
|
189
|
+
\end_layout
|
190
|
+
|
191
|
+
\begin_layout Standard
|
192
|
+
Xampl works by inspecting a collection of XML files and deriving a class
|
193
|
+
model from what it finds.
|
194
|
+
We'll only need one XML file right now:
|
195
|
+
\end_layout
|
196
|
+
|
197
|
+
\begin_layout Standard
|
198
|
+
\begin_inset Float figure
|
199
|
+
wide false
|
200
|
+
sideways false
|
201
|
+
status collapsed
|
202
|
+
|
203
|
+
\begin_layout Plain Layout
|
204
|
+
\begin_inset External
|
205
|
+
template XMLCode
|
206
|
+
filename example1/xml/hello.xml
|
207
|
+
|
208
|
+
\end_inset
|
209
|
+
|
210
|
+
|
211
|
+
\end_layout
|
212
|
+
|
213
|
+
\begin_layout Plain Layout
|
214
|
+
\begin_inset Caption
|
215
|
+
|
216
|
+
\begin_layout Plain Layout
|
217
|
+
./xml/hello.xml
|
218
|
+
\end_layout
|
219
|
+
|
220
|
+
\end_inset
|
221
|
+
|
222
|
+
|
223
|
+
\end_layout
|
224
|
+
|
225
|
+
\begin_layout Plain Layout
|
226
|
+
|
227
|
+
\end_layout
|
228
|
+
|
229
|
+
\end_inset
|
230
|
+
|
231
|
+
|
232
|
+
\end_layout
|
233
|
+
|
234
|
+
\begin_layout Standard
|
235
|
+
To make this happen and generate the xampl code, run
|
236
|
+
\begin_inset Marginal
|
237
|
+
status collapsed
|
238
|
+
|
239
|
+
\begin_layout Plain Layout
|
240
|
+
Are you in the right directory?
|
241
|
+
\end_layout
|
242
|
+
|
243
|
+
\end_inset
|
244
|
+
|
245
|
+
:
|
246
|
+
\end_layout
|
247
|
+
|
248
|
+
\begin_layout Standard
|
249
|
+
\begin_inset listings
|
250
|
+
lstparams "numbers=left"
|
251
|
+
inline false
|
252
|
+
status open
|
253
|
+
|
254
|
+
\begin_layout Plain Layout
|
255
|
+
|
256
|
+
[working] >> xampl-gen
|
257
|
+
\end_layout
|
258
|
+
|
259
|
+
\begin_layout Plain Layout
|
260
|
+
|
261
|
+
comprehend file ./xml/hello.xml
|
262
|
+
\end_layout
|
263
|
+
|
264
|
+
\begin_layout Plain Layout
|
265
|
+
|
266
|
+
WRITE TO FILE: ./xampl_generated_code/XamplAdHoc.rb
|
267
|
+
\end_layout
|
268
|
+
|
269
|
+
\end_inset
|
270
|
+
|
271
|
+
|
272
|
+
\end_layout
|
273
|
+
|
274
|
+
\begin_layout Standard
|
275
|
+
That's how I'll show a command line session―a mix of commands (with the
|
276
|
+
|
277
|
+
\family typewriter
|
278
|
+
[working] >> prefix
|
279
|
+
\family default
|
280
|
+
like line 1) and the rest output.
|
281
|
+
\end_layout
|
282
|
+
|
283
|
+
\begin_layout Standard
|
284
|
+
|
285
|
+
\family typewriter
|
286
|
+
Xampl-gen
|
287
|
+
\family default
|
288
|
+
will print a line like line 2 for every xml file it finds, meaning that
|
289
|
+
xampl is have a look at it and analysing it.
|
290
|
+
By default
|
291
|
+
\family typewriter
|
292
|
+
xampl-gen
|
293
|
+
\family default
|
294
|
+
will analyse all files that match the pattern
|
295
|
+
\family typewriter
|
296
|
+
./xml/**/*.xml
|
297
|
+
\begin_inset Foot
|
298
|
+
status open
|
299
|
+
|
300
|
+
\begin_layout Plain Layout
|
301
|
+
all files in ./xml and and all sub-directories for files with the extension
|
302
|
+
|
303
|
+
\family typewriter
|
304
|
+
.xml
|
305
|
+
\end_layout
|
306
|
+
|
307
|
+
\end_inset
|
308
|
+
|
309
|
+
|
310
|
+
\family default
|
311
|
+
.
|
312
|
+
The xml files
|
313
|
+
\emph on
|
314
|
+
must
|
315
|
+
\emph default
|
316
|
+
be well-formed and xampl-gen will choke if they are not.
|
317
|
+
\end_layout
|
318
|
+
|
319
|
+
\begin_layout Standard
|
320
|
+
Xampl-gen will write something like line 3 for each file it generates.
|
321
|
+
In this example there is only one, and it is called XamplAdHoc.
|
322
|
+
This is xampl-gen's default output file, and we haven't told it anything
|
323
|
+
better, so try to suppress your gag-reflex until I show you how to deal
|
324
|
+
with this.
|
325
|
+
But, maybe to calm you down a bit, it is considered
|
326
|
+
\emph on
|
327
|
+
very
|
328
|
+
\emph default
|
329
|
+
bad form to allow xampl to generate code into this file for production
|
330
|
+
use.
|
331
|
+
\end_layout
|
332
|
+
|
333
|
+
\begin_layout Standard
|
334
|
+
For the moment, lets just ignore what's in the XamplAdHoc.rb file.
|
335
|
+
It's a little frightening.
|
336
|
+
\end_layout
|
337
|
+
|
338
|
+
\begin_layout Standard
|
339
|
+
To do something with this, let's run this short little ruby program:
|
340
|
+
\end_layout
|
341
|
+
|
342
|
+
\begin_layout Standard
|
343
|
+
\begin_inset Float figure
|
344
|
+
wide false
|
345
|
+
sideways false
|
346
|
+
status collapsed
|
347
|
+
|
348
|
+
\begin_layout Plain Layout
|
349
|
+
\begin_inset External
|
350
|
+
template RubyCode
|
351
|
+
filename example1/example1.rb
|
352
|
+
|
353
|
+
\end_inset
|
354
|
+
|
355
|
+
|
356
|
+
\end_layout
|
357
|
+
|
358
|
+
\begin_layout Plain Layout
|
359
|
+
\begin_inset Caption
|
360
|
+
|
361
|
+
\begin_layout Plain Layout
|
362
|
+
./example1.rb
|
363
|
+
\end_layout
|
364
|
+
|
365
|
+
\end_inset
|
366
|
+
|
367
|
+
|
368
|
+
\end_layout
|
369
|
+
|
370
|
+
\begin_layout Plain Layout
|
371
|
+
|
372
|
+
\end_layout
|
373
|
+
|
374
|
+
\end_inset
|
375
|
+
|
376
|
+
|
377
|
+
\end_layout
|
378
|
+
|
379
|
+
\begin_layout Standard
|
380
|
+
And this is what we get when we run it:
|
381
|
+
\end_layout
|
382
|
+
|
383
|
+
\begin_layout Standard
|
384
|
+
\begin_inset listings
|
385
|
+
lstparams "numbers=left,tabsize=2"
|
386
|
+
inline false
|
387
|
+
status open
|
388
|
+
|
389
|
+
\begin_layout Plain Layout
|
390
|
+
|
391
|
+
[working] >> ruby example1.rb
|
392
|
+
\end_layout
|
393
|
+
|
394
|
+
\begin_layout Plain Layout
|
395
|
+
|
396
|
+
<hello-world/>
|
397
|
+
\end_layout
|
398
|
+
|
399
|
+
\end_inset
|
400
|
+
|
401
|
+
|
402
|
+
\end_layout
|
403
|
+
|
404
|
+
\begin_layout Standard
|
405
|
+
And by golly! I see a hello world right there on line 2.
|
406
|
+
\end_layout
|
407
|
+
|
408
|
+
\begin_layout Standard
|
409
|
+
How'd that happen? The file we just generated was included on line 1.
|
410
|
+
In line 3 we start a transaction, called example1.
|
411
|
+
These transactions are necessary, but in this example doesn't buy us a
|
412
|
+
lot, it is mostly just overhead
|
413
|
+
\begin_inset Foot
|
414
|
+
status collapsed
|
415
|
+
|
416
|
+
\begin_layout Plain Layout
|
417
|
+
Yes, I know\SpecialChar \ldots{}
|
418
|
+
for such a simple program this seems like gross overkill.
|
419
|
+
It is I suppose, but it isn't often that xampl is used on simple programs
|
420
|
+
like this.
|
421
|
+
\end_layout
|
422
|
+
|
423
|
+
\end_inset
|
424
|
+
|
425
|
+
.
|
426
|
+
For now just remember that when you create or change a xampl object you
|
427
|
+
have to be in a transaction or a Xampl::UnmanagedChange exception will
|
428
|
+
be raised and that involves a rollback.
|
429
|
+
I'll be covering transactions in pretty thorough detail, and there is a
|
430
|
+
prolonged discussion in chapter
|
431
|
+
\begin_inset CommandInset ref
|
432
|
+
LatexCommand vref
|
433
|
+
reference "sec:Transactions"
|
434
|
+
|
435
|
+
\end_inset
|
436
|
+
|
437
|
+
.
|
438
|
+
Line 4 creates a new instance of the class
|
439
|
+
\family typewriter
|
440
|
+
HelloWorld
|
441
|
+
\family default
|
442
|
+
.
|
443
|
+
Line 5 calls the
|
444
|
+
\family typewriter
|
445
|
+
to_xml
|
446
|
+
\family default
|
447
|
+
method and prints the result.
|
448
|
+
\end_layout
|
449
|
+
|
450
|
+
\begin_layout Standard
|
451
|
+
HelloWorld is a class generated by xampl.
|
452
|
+
The name is derived from the XML element name using rules described in
|
453
|
+
|
454
|
+
\begin_inset CommandInset ref
|
455
|
+
LatexCommand vref
|
456
|
+
reference "sec:Name-Generation"
|
457
|
+
|
458
|
+
\end_inset
|
459
|
+
|
460
|
+
.
|
461
|
+
\end_layout
|
462
|
+
|
463
|
+
\begin_layout Subsection
|
464
|
+
What Did xampl Do?
|
465
|
+
\end_layout
|
466
|
+
|
467
|
+
\begin_layout Standard
|
468
|
+
You can look in the generated code yourself and you'll find that one class
|
469
|
+
and one module were generated and a surprising 150 or more lines of code.
|
470
|
+
The class has 20 methods, and the module has 7.
|
471
|
+
The module and none of the methods are interesting to us right now, all
|
472
|
+
of them will be soon.
|
473
|
+
And all for this near-trivial example.
|
474
|
+
\end_layout
|
475
|
+
|
476
|
+
\begin_layout Standard
|
477
|
+
The class is called
|
478
|
+
\family typewriter
|
479
|
+
HelloWorld
|
480
|
+
\family default
|
481
|
+
.
|
482
|
+
It mixes in two modules:
|
483
|
+
\family typewriter
|
484
|
+
Xampl::XamplObject
|
485
|
+
\family default
|
486
|
+
, and
|
487
|
+
\family typewriter
|
488
|
+
Xampl::XamplWithoutContent
|
489
|
+
\family default
|
490
|
+
, and inherits nothing.
|
491
|
+
The mixin
|
492
|
+
\family typewriter
|
493
|
+
Xampl::XamplObject
|
494
|
+
\family default
|
495
|
+
means that his is a xampl object, and it carries a bunch of methods, including
|
496
|
+
the
|
497
|
+
\family typewriter
|
498
|
+
to_xml
|
499
|
+
\family default
|
500
|
+
method used in the example.
|
501
|
+
The mixin
|
502
|
+
\family typewriter
|
503
|
+
Xampl::XamplWithoutContent
|
504
|
+
\family default
|
505
|
+
means that
|
506
|
+
\family typewriter
|
507
|
+
HelloWorld
|
508
|
+
\family default
|
509
|
+
has no content and no references to any other xampl managed objects (like
|
510
|
+
an empty XML element).
|
511
|
+
\end_layout
|
512
|
+
|
513
|
+
\begin_layout Subsection
|
514
|
+
Summary
|
515
|
+
\end_layout
|
516
|
+
|
517
|
+
\begin_layout Itemize
|
518
|
+
basic structure of a xampl project on disk
|
519
|
+
\end_layout
|
520
|
+
|
521
|
+
\begin_layout Itemize
|
522
|
+
basic usage of the xampl-gen program
|
523
|
+
\end_layout
|
524
|
+
|
525
|
+
\begin_layout Itemize
|
526
|
+
a simple example of using the generated code
|
527
|
+
\end_layout
|
528
|
+
|
529
|
+
\begin_layout Itemize
|
530
|
+
xampl has some kind of way of dealing with name incompatibilities between
|
531
|
+
XML and Ruby
|
532
|
+
\end_layout
|
533
|
+
|
534
|
+
\begin_layout Itemize
|
535
|
+
xampl creates a Ruby class for each XML elements discovered
|
536
|
+
\end_layout
|
537
|
+
|
538
|
+
\begin_layout Section
|
539
|
+
Hello hello?!
|
540
|
+
\end_layout
|
541
|
+
|
542
|
+
\begin_layout Subsection
|
543
|
+
The Experiment
|
544
|
+
\end_layout
|
545
|
+
|
546
|
+
\begin_layout Standard
|
547
|
+
Carrying on from the previous experiment\SpecialChar \ldots{}
|
548
|
+
That was nice but it could only
|
549
|
+
say hello to the world, and then only if we squinted.
|
550
|
+
What if we wanted to say hello to more than just the world? What if we
|
551
|
+
wanted to have objects that behaved differently? What if we wanted to say
|
552
|
+
it nicer? What if we wanted to get rid of that horribly ugly XamplAdHoc.rb
|
553
|
+
file and actually put the generated code in modules?
|
554
|
+
\end_layout
|
555
|
+
|
556
|
+
\begin_layout Standard
|
557
|
+
\noindent
|
558
|
+
\align left
|
559
|
+
The code for this experiment is in the directory:
|
560
|
+
\family typewriter
|
561
|
+
<path to the xampl gem>/docs/intro/example2
|
562
|
+
\end_layout
|
563
|
+
|
564
|
+
\begin_layout Standard
|
565
|
+
Okay, so lets look at this xml file, Figure
|
566
|
+
\begin_inset CommandInset ref
|
567
|
+
LatexCommand ref
|
568
|
+
reference "fig:./xml/example2.xml"
|
569
|
+
|
570
|
+
\end_inset
|
571
|
+
|
572
|
+
,
|
573
|
+
\end_layout
|
574
|
+
|
575
|
+
\begin_layout Standard
|
576
|
+
\begin_inset Float figure
|
577
|
+
wide false
|
578
|
+
sideways false
|
579
|
+
status open
|
580
|
+
|
581
|
+
\begin_layout Plain Layout
|
582
|
+
\begin_inset External
|
583
|
+
template XMLCode
|
584
|
+
filename example2/xml/hello.xml
|
585
|
+
|
586
|
+
\end_inset
|
587
|
+
|
588
|
+
|
589
|
+
\end_layout
|
590
|
+
|
591
|
+
\begin_layout Plain Layout
|
592
|
+
\begin_inset Caption
|
593
|
+
|
594
|
+
\begin_layout Plain Layout
|
595
|
+
./xml/example2.xml
|
596
|
+
\begin_inset CommandInset label
|
597
|
+
LatexCommand label
|
598
|
+
name "fig:./xml/example2.xml"
|
599
|
+
|
600
|
+
\end_inset
|
601
|
+
|
602
|
+
|
603
|
+
\end_layout
|
604
|
+
|
605
|
+
\end_inset
|
606
|
+
|
607
|
+
|
608
|
+
\end_layout
|
609
|
+
|
610
|
+
\end_inset
|
611
|
+
|
612
|
+
|
613
|
+
\end_layout
|
614
|
+
|
615
|
+
\begin_layout Standard
|
616
|
+
There are two important differences between this xml file and the one for
|
617
|
+
the first example:
|
618
|
+
\end_layout
|
619
|
+
|
620
|
+
\begin_layout Itemize
|
621
|
+
there is an attribute, who, associated with the element hello (no more hello-wor
|
622
|
+
ld).
|
623
|
+
The value of the attribute is just for example, it does not find its way
|
624
|
+
into the generated code, it could have been anything including ''.
|
625
|
+
\end_layout
|
626
|
+
|
627
|
+
\begin_layout Itemize
|
628
|
+
There is a namespace defined, in this case com.xampl.intro.example2
|
629
|
+
\end_layout
|
630
|
+
|
631
|
+
\begin_layout Standard
|
632
|
+
As soon as we have a namespace defined, then we can map them to Ruby modules.
|
633
|
+
This is done in a ruby file called
|
634
|
+
\family typewriter
|
635
|
+
project-generator.rb
|
636
|
+
\family default
|
637
|
+
.
|
638
|
+
It is always called that and is located in the directory from where the
|
639
|
+
|
640
|
+
\family typewriter
|
641
|
+
xampl-gen
|
642
|
+
\family default
|
643
|
+
command is run.
|
644
|
+
This is what it looks like Figure
|
645
|
+
\begin_inset CommandInset ref
|
646
|
+
LatexCommand vref
|
647
|
+
reference "fig:./project-generator.rb"
|
648
|
+
|
649
|
+
\end_inset
|
650
|
+
|
651
|
+
.
|
652
|
+
This file is loaded by the xampl-gen command if it exists.
|
653
|
+
It re-opens
|
654
|
+
\begin_inset Foot
|
655
|
+
status collapsed
|
656
|
+
|
657
|
+
\begin_layout Plain Layout
|
658
|
+
xampl re-opens classes routinely and profits greatly by the technique.
|
659
|
+
There's a term,
|
660
|
+
\emph on
|
661
|
+
monkey-patching,
|
662
|
+
\emph default
|
663
|
+
applied to this technique that is intended to be derogatory, but it isn't
|
664
|
+
taken that way in the Ruby community.
|
665
|
+
\end_layout
|
666
|
+
|
667
|
+
\end_inset
|
668
|
+
|
669
|
+
the class
|
670
|
+
\family typewriter
|
671
|
+
ProjectGenerator
|
672
|
+
\family default
|
673
|
+
(line 1) and re-defines the method
|
674
|
+
\family typewriter
|
675
|
+
resolve-namespaces
|
676
|
+
\family default
|
677
|
+
(line 3).
|
678
|
+
An array of arrays is expected.
|
679
|
+
What line 15 is doing is saying that the namespace com.xampl.intro.example2
|
680
|
+
should be mapped to the Ruby module
|
681
|
+
\family typewriter
|
682
|
+
Example2
|
683
|
+
\family default
|
684
|
+
, and when writing XML xampl should prefer the prefix ex2 to identify the
|
685
|
+
namespace.
|
686
|
+
\end_layout
|
687
|
+
|
688
|
+
\begin_layout Standard
|
689
|
+
\begin_inset Float figure
|
690
|
+
wide false
|
691
|
+
sideways false
|
692
|
+
status open
|
693
|
+
|
694
|
+
\begin_layout Plain Layout
|
695
|
+
\begin_inset External
|
696
|
+
template RubyCode
|
697
|
+
filename example2/project-generator.rb
|
698
|
+
|
699
|
+
\end_inset
|
700
|
+
|
701
|
+
|
702
|
+
\end_layout
|
703
|
+
|
704
|
+
\begin_layout Plain Layout
|
705
|
+
\begin_inset Caption
|
706
|
+
|
707
|
+
\begin_layout Plain Layout
|
708
|
+
./project-generator.rb
|
709
|
+
\begin_inset CommandInset label
|
710
|
+
LatexCommand label
|
711
|
+
name "fig:./project-generator.rb"
|
712
|
+
|
713
|
+
\end_inset
|
714
|
+
|
715
|
+
|
716
|
+
\end_layout
|
717
|
+
|
718
|
+
\end_inset
|
719
|
+
|
720
|
+
|
721
|
+
\end_layout
|
722
|
+
|
723
|
+
\begin_layout Plain Layout
|
724
|
+
|
725
|
+
\end_layout
|
726
|
+
|
727
|
+
\end_inset
|
728
|
+
|
729
|
+
|
730
|
+
\end_layout
|
731
|
+
|
732
|
+
\begin_layout Standard
|
733
|
+
So run xampl-gen and you should see something like:
|
734
|
+
\end_layout
|
735
|
+
|
736
|
+
\begin_layout Standard
|
737
|
+
\begin_inset listings
|
738
|
+
inline false
|
739
|
+
status open
|
740
|
+
|
741
|
+
\begin_layout Plain Layout
|
742
|
+
|
743
|
+
[working] >> xampl-gen
|
744
|
+
\end_layout
|
745
|
+
|
746
|
+
\begin_layout Plain Layout
|
747
|
+
|
748
|
+
comprehend file ./xml/hello.xml
|
749
|
+
\end_layout
|
750
|
+
|
751
|
+
\begin_layout Plain Layout
|
752
|
+
|
753
|
+
WRITE TO FILE: ./xampl_generated_code/Example2.rb
|
754
|
+
\end_layout
|
755
|
+
|
756
|
+
\end_inset
|
757
|
+
|
758
|
+
|
759
|
+
\end_layout
|
760
|
+
|
761
|
+
\begin_layout Standard
|
762
|
+
You'll note that the XamplAdHoc.rb file is gone, replaced by Exampl2.rb.
|
763
|
+
Xampl will place all code generated for a module into a single file named
|
764
|
+
after the module.
|
765
|
+
If you open up the generated Ruby file you'll see that the code is now
|
766
|
+
inside the module Example2.
|
767
|
+
\end_layout
|
768
|
+
|
769
|
+
\begin_layout Standard
|
770
|
+
So, lets do something with this.
|
771
|
+
Have a look at this Figure
|
772
|
+
\begin_inset CommandInset ref
|
773
|
+
LatexCommand vref
|
774
|
+
reference "fig:./example2.rb"
|
775
|
+
|
776
|
+
\end_inset
|
777
|
+
|
778
|
+
and its output.
|
779
|
+
\end_layout
|
780
|
+
|
781
|
+
\begin_layout Standard
|
782
|
+
\begin_inset Float figure
|
783
|
+
wide false
|
784
|
+
sideways false
|
785
|
+
status open
|
786
|
+
|
787
|
+
\begin_layout Plain Layout
|
788
|
+
\begin_inset External
|
789
|
+
template RubyCode
|
790
|
+
filename /Users/hutch/GIT-public/xamplr/docs/intro/example2/example2.rb
|
791
|
+
|
792
|
+
\end_inset
|
793
|
+
|
794
|
+
|
795
|
+
\end_layout
|
796
|
+
|
797
|
+
\begin_layout Plain Layout
|
798
|
+
\begin_inset Caption
|
799
|
+
|
800
|
+
\begin_layout Plain Layout
|
801
|
+
./example2.rb
|
802
|
+
\begin_inset CommandInset label
|
803
|
+
LatexCommand label
|
804
|
+
name "fig:./example2.rb"
|
805
|
+
|
806
|
+
\end_inset
|
807
|
+
|
808
|
+
|
809
|
+
\end_layout
|
810
|
+
|
811
|
+
\end_inset
|
812
|
+
|
813
|
+
|
814
|
+
\end_layout
|
815
|
+
|
816
|
+
\end_inset
|
817
|
+
|
818
|
+
|
819
|
+
\end_layout
|
820
|
+
|
821
|
+
\begin_layout Standard
|
822
|
+
\begin_inset listings
|
823
|
+
lstparams "float,language=bash,numbers=left"
|
824
|
+
inline false
|
825
|
+
status open
|
826
|
+
|
827
|
+
\begin_layout Plain Layout
|
828
|
+
|
829
|
+
[working] >> ruby example2.rb
|
830
|
+
\end_layout
|
831
|
+
|
832
|
+
\begin_layout Plain Layout
|
833
|
+
|
834
|
+
haven't set the who attribute yet...
|
835
|
+
\end_layout
|
836
|
+
|
837
|
+
\begin_layout Plain Layout
|
838
|
+
|
839
|
+
<ex2:hello xmlns:ex2="com.xampl.intro.example2"/>
|
840
|
+
\end_layout
|
841
|
+
|
842
|
+
\begin_layout Plain Layout
|
843
|
+
|
844
|
+
Hello hello?!
|
845
|
+
\end_layout
|
846
|
+
|
847
|
+
\begin_layout Plain Layout
|
848
|
+
|
849
|
+
\end_layout
|
850
|
+
|
851
|
+
\begin_layout Plain Layout
|
852
|
+
|
853
|
+
have set the who attribute to 'world'...
|
854
|
+
|
855
|
+
\end_layout
|
856
|
+
|
857
|
+
\begin_layout Plain Layout
|
858
|
+
|
859
|
+
<ex2:hello who="world" xmlns:ex2="com.xampl.intro.example2"/>
|
860
|
+
\end_layout
|
861
|
+
|
862
|
+
\begin_layout Plain Layout
|
863
|
+
|
864
|
+
\end_layout
|
865
|
+
|
866
|
+
\begin_layout Plain Layout
|
867
|
+
|
868
|
+
<ex2:hello who='world'
|
869
|
+
\end_layout
|
870
|
+
|
871
|
+
\begin_layout Plain Layout
|
872
|
+
|
873
|
+
xmlns:ex2='com.xampl.intro.example2'/>
|
874
|
+
\end_layout
|
875
|
+
|
876
|
+
\begin_layout Plain Layout
|
877
|
+
|
878
|
+
Hello world!
|
879
|
+
\end_layout
|
880
|
+
|
881
|
+
\begin_layout Plain Layout
|
882
|
+
|
883
|
+
\end_layout
|
884
|
+
|
885
|
+
\begin_layout Plain Layout
|
886
|
+
|
887
|
+
there are two Hello things now...
|
888
|
+
|
889
|
+
\end_layout
|
890
|
+
|
891
|
+
\begin_layout Plain Layout
|
892
|
+
|
893
|
+
Hello world!
|
894
|
+
\end_layout
|
895
|
+
|
896
|
+
\begin_layout Plain Layout
|
897
|
+
|
898
|
+
Hello there!
|
899
|
+
\end_layout
|
900
|
+
|
901
|
+
\begin_layout Plain Layout
|
902
|
+
|
903
|
+
\end_layout
|
904
|
+
|
905
|
+
\begin_layout Plain Layout
|
906
|
+
|
907
|
+
print an array of the two Hello things...
|
908
|
+
|
909
|
+
\end_layout
|
910
|
+
|
911
|
+
\begin_layout Plain Layout
|
912
|
+
|
913
|
+
Hello world!
|
914
|
+
\end_layout
|
915
|
+
|
916
|
+
\begin_layout Plain Layout
|
917
|
+
|
918
|
+
Hello there!
|
919
|
+
\end_layout
|
920
|
+
|
921
|
+
\begin_layout Plain Layout
|
922
|
+
|
923
|
+
\end_layout
|
924
|
+
|
925
|
+
\begin_layout Plain Layout
|
926
|
+
|
927
|
+
inspect an array of the two Hello things...
|
928
|
+
|
929
|
+
\end_layout
|
930
|
+
|
931
|
+
\begin_layout Plain Layout
|
932
|
+
|
933
|
+
[ <ex2:hello who='world'
|
934
|
+
\end_layout
|
935
|
+
|
936
|
+
\begin_layout Plain Layout
|
937
|
+
|
938
|
+
xmlns:ex2='com.xampl.intro.example2'/>,
|
939
|
+
\end_layout
|
940
|
+
|
941
|
+
\begin_layout Plain Layout
|
942
|
+
|
943
|
+
<ex2:hello who='there'
|
944
|
+
\end_layout
|
945
|
+
|
946
|
+
\begin_layout Plain Layout
|
947
|
+
|
948
|
+
xmlns:ex2='com.xampl.intro.example2'/>]
|
949
|
+
\end_layout
|
950
|
+
|
951
|
+
\end_inset
|
952
|
+
|
953
|
+
|
954
|
+
\end_layout
|
955
|
+
|
956
|
+
\begin_layout Standard
|
957
|
+
So what's happening here? Line 1 requires the generated Ruby code, line
|
958
|
+
3 includes the module
|
959
|
+
\family typewriter
|
960
|
+
Example2
|
961
|
+
\family default
|
962
|
+
so we don't have to keep specifying the module name.
|
963
|
+
Line 5 re-opens the class
|
964
|
+
\family typewriter
|
965
|
+
Hello
|
966
|
+
\family default
|
967
|
+
and defines a
|
968
|
+
\family typewriter
|
969
|
+
to_s
|
970
|
+
\family default
|
971
|
+
method.
|
972
|
+
Line 11 starts one of those transactions again.
|
973
|
+
\end_layout
|
974
|
+
|
975
|
+
\begin_layout Standard
|
976
|
+
Line 12 creates a new instance of
|
977
|
+
\family typewriter
|
978
|
+
Hello
|
979
|
+
\family default
|
980
|
+
,
|
981
|
+
\family typewriter
|
982
|
+
h
|
983
|
+
\family default
|
984
|
+
, and prints it's XML and string representation on lines 15-16 (see lines
|
985
|
+
3-4 of the output listing).
|
986
|
+
Line 18 sets the value of
|
987
|
+
\family typewriter
|
988
|
+
h
|
989
|
+
\family default
|
990
|
+
's who attribute to '
|
991
|
+
\family typewriter
|
992
|
+
world
|
993
|
+
\family default
|
994
|
+
' then prints some stuff resulting in output lines 6-11.
|
995
|
+
\end_layout
|
996
|
+
|
997
|
+
\begin_layout Standard
|
998
|
+
Line 25-28 creates another, different, instance of
|
999
|
+
\family typewriter
|
1000
|
+
Hello
|
1001
|
+
\family default
|
1002
|
+
,
|
1003
|
+
\family typewriter
|
1004
|
+
h2
|
1005
|
+
\family default
|
1006
|
+
, and an array,
|
1007
|
+
\family typewriter
|
1008
|
+
all
|
1009
|
+
\family default
|
1010
|
+
, that contains
|
1011
|
+
\family typewriter
|
1012
|
+
h
|
1013
|
+
\family default
|
1014
|
+
and
|
1015
|
+
\family typewriter
|
1016
|
+
h2
|
1017
|
+
\family default
|
1018
|
+
.
|
1019
|
+
Lines 30-37 generate the output lines 17-25.
|
1020
|
+
\end_layout
|
1021
|
+
|
1022
|
+
\begin_layout Standard
|
1023
|
+
There's a new method being used called
|
1024
|
+
\family typewriter
|
1025
|
+
pp_xml
|
1026
|
+
\family default
|
1027
|
+
.
|
1028
|
+
It is similar to
|
1029
|
+
\family typewriter
|
1030
|
+
to_xml
|
1031
|
+
\family default
|
1032
|
+
in that it prints XML, but it does in a prettier way
|
1033
|
+
\begin_inset Foot
|
1034
|
+
status collapsed
|
1035
|
+
|
1036
|
+
\begin_layout Plain Layout
|
1037
|
+
the 'pp' in
|
1038
|
+
\family typewriter
|
1039
|
+
pp_xml
|
1040
|
+
\family default
|
1041
|
+
stands for pretty-print.
|
1042
|
+
\end_layout
|
1043
|
+
|
1044
|
+
\end_inset
|
1045
|
+
|
1046
|
+
.
|
1047
|
+
There is another significant difference that we'll get to when we talk
|
1048
|
+
about persistence.
|
1049
|
+
\end_layout
|
1050
|
+
|
1051
|
+
\begin_layout Subsection
|
1052
|
+
What Did xampl do?
|
1053
|
+
\end_layout
|
1054
|
+
|
1055
|
+
\begin_layout Standard
|
1056
|
+
Pretty much the same thing as the first experiment.
|
1057
|
+
Except that the file is named after a module, and the generated code is
|
1058
|
+
in that module.
|
1059
|
+
There is also code to support an attribute.
|
1060
|
+
\end_layout
|
1061
|
+
|
1062
|
+
\begin_layout Subsection
|
1063
|
+
Summary
|
1064
|
+
\end_layout
|
1065
|
+
|
1066
|
+
\begin_layout Itemize
|
1067
|
+
how to map XML namespaces to Ruby modules
|
1068
|
+
\end_layout
|
1069
|
+
|
1070
|
+
\begin_layout Itemize
|
1071
|
+
how an XML attribute maps to a Ruby instance variable
|
1072
|
+
\end_layout
|
1073
|
+
|
1074
|
+
\begin_layout Itemize
|
1075
|
+
that there can be more than one instance of xampl objects created
|
1076
|
+
\end_layout
|
1077
|
+
|
1078
|
+
\begin_layout Itemize
|
1079
|
+
the values taken by instance variables are in no way constrained to the
|
1080
|
+
values found in the XML files the code was generated from
|
1081
|
+
\begin_inset Foot
|
1082
|
+
status collapsed
|
1083
|
+
|
1084
|
+
\begin_layout Plain Layout
|
1085
|
+
This has proved to be incredibly difficult for some programmers to grasp.
|
1086
|
+
The xml files used to generate xampl objects are
|
1087
|
+
\family typewriter
|
1088
|
+
\emph on
|
1089
|
+
not
|
1090
|
+
\family default
|
1091
|
+
\emph default
|
1092
|
+
schemas, they are examples.
|
1093
|
+
\end_layout
|
1094
|
+
|
1095
|
+
\end_inset
|
1096
|
+
|
1097
|
+
|
1098
|
+
\end_layout
|
1099
|
+
|
1100
|
+
\begin_layout Itemize
|
1101
|
+
there is a xampl build-in method,
|
1102
|
+
\family typewriter
|
1103
|
+
pp_xml
|
1104
|
+
\family default
|
1105
|
+
, that prints xml from a xampl object in a prettier way than that of
|
1106
|
+
\family typewriter
|
1107
|
+
to_xml
|
1108
|
+
\end_layout
|
1109
|
+
|
1110
|
+
\begin_layout Section
|
1111
|
+
The Greeter
|
1112
|
+
\end_layout
|
1113
|
+
|
1114
|
+
\begin_layout Subsection
|
1115
|
+
The Experiment
|
1116
|
+
\end_layout
|
1117
|
+
|
1118
|
+
\begin_layout Standard
|
1119
|
+
xml goes here
|
1120
|
+
\begin_inset CommandInset ref
|
1121
|
+
LatexCommand ref
|
1122
|
+
reference "fig:./xml/greeter.xml"
|
1123
|
+
|
1124
|
+
\end_inset
|
1125
|
+
|
1126
|
+
, blah
|
1127
|
+
\end_layout
|
1128
|
+
|
1129
|
+
\begin_layout Standard
|
1130
|
+
\begin_inset Float figure
|
1131
|
+
wide false
|
1132
|
+
sideways false
|
1133
|
+
status open
|
1134
|
+
|
1135
|
+
\begin_layout Plain Layout
|
1136
|
+
\begin_inset External
|
1137
|
+
template XMLCode
|
1138
|
+
filename example3/xml/greeter.xml
|
1139
|
+
|
1140
|
+
\end_inset
|
1141
|
+
|
1142
|
+
|
1143
|
+
\end_layout
|
1144
|
+
|
1145
|
+
\begin_layout Plain Layout
|
1146
|
+
\begin_inset Caption
|
1147
|
+
|
1148
|
+
\begin_layout Plain Layout
|
1149
|
+
./xml/greeter.xml
|
1150
|
+
\begin_inset CommandInset label
|
1151
|
+
LatexCommand label
|
1152
|
+
name "fig:./xml/greeter.xml"
|
1153
|
+
|
1154
|
+
\end_inset
|
1155
|
+
|
1156
|
+
|
1157
|
+
\end_layout
|
1158
|
+
|
1159
|
+
\end_inset
|
1160
|
+
|
1161
|
+
|
1162
|
+
\end_layout
|
1163
|
+
|
1164
|
+
\begin_layout Plain Layout
|
1165
|
+
|
1166
|
+
\end_layout
|
1167
|
+
|
1168
|
+
\end_inset
|
1169
|
+
|
1170
|
+
|
1171
|
+
\end_layout
|
1172
|
+
|
1173
|
+
\begin_layout Standard
|
1174
|
+
object diagram
|
1175
|
+
\begin_inset CommandInset ref
|
1176
|
+
LatexCommand ref
|
1177
|
+
reference "fig:./generated3.yuml"
|
1178
|
+
|
1179
|
+
\end_inset
|
1180
|
+
|
1181
|
+
, blah
|
1182
|
+
\end_layout
|
1183
|
+
|
1184
|
+
\begin_layout Standard
|
1185
|
+
\begin_inset Float figure
|
1186
|
+
wide false
|
1187
|
+
sideways false
|
1188
|
+
status open
|
1189
|
+
|
1190
|
+
\begin_layout Plain Layout
|
1191
|
+
\begin_inset Graphics
|
1192
|
+
filename example3/generated.png
|
1193
|
+
|
1194
|
+
\end_inset
|
1195
|
+
|
1196
|
+
|
1197
|
+
\end_layout
|
1198
|
+
|
1199
|
+
\begin_layout Plain Layout
|
1200
|
+
\begin_inset Caption
|
1201
|
+
|
1202
|
+
\begin_layout Plain Layout
|
1203
|
+
./generated.yuml
|
1204
|
+
\begin_inset CommandInset label
|
1205
|
+
LatexCommand label
|
1206
|
+
name "fig:./generated3.yuml"
|
1207
|
+
|
1208
|
+
\end_inset
|
1209
|
+
|
1210
|
+
|
1211
|
+
\end_layout
|
1212
|
+
|
1213
|
+
\end_inset
|
1214
|
+
|
1215
|
+
|
1216
|
+
\end_layout
|
1217
|
+
|
1218
|
+
\begin_layout Plain Layout
|
1219
|
+
|
1220
|
+
\end_layout
|
1221
|
+
|
1222
|
+
\end_inset
|
1223
|
+
|
1224
|
+
|
1225
|
+
\end_layout
|
1226
|
+
|
1227
|
+
\begin_layout Standard
|
1228
|
+
greeter
|
1229
|
+
\begin_inset CommandInset ref
|
1230
|
+
LatexCommand ref
|
1231
|
+
reference "fig:./greeter3.rb"
|
1232
|
+
|
1233
|
+
\end_inset
|
1234
|
+
|
1235
|
+
, blah
|
1236
|
+
\end_layout
|
1237
|
+
|
1238
|
+
\begin_layout Standard
|
1239
|
+
\begin_inset Float figure
|
1240
|
+
wide false
|
1241
|
+
sideways false
|
1242
|
+
status open
|
1243
|
+
|
1244
|
+
\begin_layout Plain Layout
|
1245
|
+
\begin_inset External
|
1246
|
+
template RubyCode
|
1247
|
+
filename example3/greeter.rb
|
1248
|
+
|
1249
|
+
\end_inset
|
1250
|
+
|
1251
|
+
|
1252
|
+
\end_layout
|
1253
|
+
|
1254
|
+
\begin_layout Plain Layout
|
1255
|
+
\begin_inset Caption
|
1256
|
+
|
1257
|
+
\begin_layout Plain Layout
|
1258
|
+
./greeter.rb
|
1259
|
+
\begin_inset CommandInset label
|
1260
|
+
LatexCommand label
|
1261
|
+
name "fig:./greeter3.rb"
|
1262
|
+
|
1263
|
+
\end_inset
|
1264
|
+
|
1265
|
+
|
1266
|
+
\end_layout
|
1267
|
+
|
1268
|
+
\end_inset
|
1269
|
+
|
1270
|
+
|
1271
|
+
\end_layout
|
1272
|
+
|
1273
|
+
\begin_layout Plain Layout
|
1274
|
+
|
1275
|
+
\end_layout
|
1276
|
+
|
1277
|
+
\end_inset
|
1278
|
+
|
1279
|
+
|
1280
|
+
\end_layout
|
1281
|
+
|
1282
|
+
\begin_layout Standard
|
1283
|
+
greeting
|
1284
|
+
\begin_inset CommandInset ref
|
1285
|
+
LatexCommand ref
|
1286
|
+
reference "fig:./greeting3.rb"
|
1287
|
+
|
1288
|
+
\end_inset
|
1289
|
+
|
1290
|
+
, blah
|
1291
|
+
\end_layout
|
1292
|
+
|
1293
|
+
\begin_layout Standard
|
1294
|
+
\begin_inset Float figure
|
1295
|
+
wide false
|
1296
|
+
sideways false
|
1297
|
+
status open
|
1298
|
+
|
1299
|
+
\begin_layout Plain Layout
|
1300
|
+
\begin_inset External
|
1301
|
+
template RubyCode
|
1302
|
+
filename example3/greeting.rb
|
1303
|
+
|
1304
|
+
\end_inset
|
1305
|
+
|
1306
|
+
|
1307
|
+
\end_layout
|
1308
|
+
|
1309
|
+
\begin_layout Plain Layout
|
1310
|
+
\begin_inset Caption
|
1311
|
+
|
1312
|
+
\begin_layout Plain Layout
|
1313
|
+
./greeting.rb
|
1314
|
+
\begin_inset CommandInset label
|
1315
|
+
LatexCommand label
|
1316
|
+
name "fig:./greeting3.rb"
|
1317
|
+
|
1318
|
+
\end_inset
|
1319
|
+
|
1320
|
+
|
1321
|
+
\end_layout
|
1322
|
+
|
1323
|
+
\end_inset
|
1324
|
+
|
1325
|
+
|
1326
|
+
\end_layout
|
1327
|
+
|
1328
|
+
\begin_layout Plain Layout
|
1329
|
+
|
1330
|
+
\end_layout
|
1331
|
+
|
1332
|
+
\end_inset
|
1333
|
+
|
1334
|
+
|
1335
|
+
\end_layout
|
1336
|
+
|
1337
|
+
\begin_layout Standard
|
1338
|
+
example3
|
1339
|
+
\begin_inset CommandInset ref
|
1340
|
+
LatexCommand ref
|
1341
|
+
reference "fig:./example3.rb"
|
1342
|
+
|
1343
|
+
\end_inset
|
1344
|
+
|
1345
|
+
, blah
|
1346
|
+
\end_layout
|
1347
|
+
|
1348
|
+
\begin_layout Standard
|
1349
|
+
\begin_inset Float figure
|
1350
|
+
wide false
|
1351
|
+
sideways false
|
1352
|
+
status open
|
1353
|
+
|
1354
|
+
\begin_layout Plain Layout
|
1355
|
+
\begin_inset External
|
1356
|
+
template RubyCode
|
1357
|
+
filename example3/example3.rb
|
1358
|
+
|
1359
|
+
\end_inset
|
1360
|
+
|
1361
|
+
|
1362
|
+
\end_layout
|
1363
|
+
|
1364
|
+
\begin_layout Plain Layout
|
1365
|
+
\begin_inset Caption
|
1366
|
+
|
1367
|
+
\begin_layout Plain Layout
|
1368
|
+
./example3.rb
|
1369
|
+
\begin_inset CommandInset label
|
1370
|
+
LatexCommand label
|
1371
|
+
name "fig:./example3.rb"
|
1372
|
+
|
1373
|
+
\end_inset
|
1374
|
+
|
1375
|
+
|
1376
|
+
\end_layout
|
1377
|
+
|
1378
|
+
\end_inset
|
1379
|
+
|
1380
|
+
|
1381
|
+
\end_layout
|
1382
|
+
|
1383
|
+
\begin_layout Plain Layout
|
1384
|
+
|
1385
|
+
\end_layout
|
1386
|
+
|
1387
|
+
\end_inset
|
1388
|
+
|
1389
|
+
|
1390
|
+
\end_layout
|
1391
|
+
|
1392
|
+
\begin_layout Standard
|
1393
|
+
example3a
|
1394
|
+
\begin_inset CommandInset ref
|
1395
|
+
LatexCommand ref
|
1396
|
+
reference "fig:./example3a.rb"
|
1397
|
+
|
1398
|
+
\end_inset
|
1399
|
+
|
1400
|
+
, blah
|
1401
|
+
\end_layout
|
1402
|
+
|
1403
|
+
\begin_layout Standard
|
1404
|
+
\begin_inset Float figure
|
1405
|
+
wide false
|
1406
|
+
sideways false
|
1407
|
+
status collapsed
|
1408
|
+
|
1409
|
+
\begin_layout Plain Layout
|
1410
|
+
\begin_inset External
|
1411
|
+
template RubyCode
|
1412
|
+
filename example3/example3a.rb
|
1413
|
+
|
1414
|
+
\end_inset
|
1415
|
+
|
1416
|
+
|
1417
|
+
\end_layout
|
1418
|
+
|
1419
|
+
\begin_layout Plain Layout
|
1420
|
+
\begin_inset Caption
|
1421
|
+
|
1422
|
+
\begin_layout Plain Layout
|
1423
|
+
./example3a.rb
|
1424
|
+
\begin_inset CommandInset label
|
1425
|
+
LatexCommand label
|
1426
|
+
name "fig:./example3a.rb"
|
1427
|
+
|
1428
|
+
\end_inset
|
1429
|
+
|
1430
|
+
|
1431
|
+
\end_layout
|
1432
|
+
|
1433
|
+
\end_inset
|
1434
|
+
|
1435
|
+
|
1436
|
+
\end_layout
|
1437
|
+
|
1438
|
+
\begin_layout Plain Layout
|
1439
|
+
|
1440
|
+
\end_layout
|
1441
|
+
|
1442
|
+
\end_inset
|
1443
|
+
|
1444
|
+
|
1445
|
+
\end_layout
|
1446
|
+
|
1447
|
+
\begin_layout Standard
|
1448
|
+
blather blather
|
1449
|
+
\end_layout
|
1450
|
+
|
1451
|
+
\begin_layout Part
|
1452
|
+
Programming Manual
|
1453
|
+
\end_layout
|
1454
|
+
|
1455
|
+
\begin_layout Chapter
|
1456
|
+
Code Generation
|
1457
|
+
\end_layout
|
1458
|
+
|
1459
|
+
\begin_layout Section
|
1460
|
+
Name Generation
|
1461
|
+
\begin_inset CommandInset label
|
1462
|
+
LatexCommand label
|
1463
|
+
name "sec:Name-Generation"
|
1464
|
+
|
1465
|
+
\end_inset
|
1466
|
+
|
1467
|
+
|
1468
|
+
\end_layout
|
1469
|
+
|
1470
|
+
\begin_layout Chapter
|
1471
|
+
Persistence
|
1472
|
+
\end_layout
|
1473
|
+
|
1474
|
+
\begin_layout Section
|
1475
|
+
Transactions
|
1476
|
+
\begin_inset CommandInset label
|
1477
|
+
LatexCommand label
|
1478
|
+
name "sec:Transactions"
|
1479
|
+
|
1480
|
+
\end_inset
|
1481
|
+
|
1482
|
+
|
1483
|
+
\end_layout
|
1484
|
+
|
1485
|
+
\begin_layout Section
|
1486
|
+
Repositories
|
1487
|
+
\end_layout
|
1488
|
+
|
1489
|
+
\begin_layout Section
|
1490
|
+
Persistence Managers
|
1491
|
+
\end_layout
|
1492
|
+
|
1493
|
+
\end_body
|
1494
|
+
\end_document
|