[Uw-ruby] Uw-ruby Digest, Vol 2, Issue 18
Steve Dame
steve at vdsp.com
Thu Nov 22 20:45:01 PST 2007
Happy Turkey Day to all!
Continued discussion on the use of CGI and CSS. I agree and I hate the
ugly hard to ready stuff that M$ exports to its HTML files. I'm only
using these M$ Office tools because they are easy to get a WYSWIG HTML
document whipped into shape quickly, using the tools in Excel, etc. and
then export it to HTML. Then it is quicker to go in and strip out all
the garbage and leave the basic structure than to pick through each
individual item and try to build them from scratch.
Here's a starting example of what I am trying to do in the form of a CGI
script's output.
http://www.erudite-test.com/erutest/TestSB2.htm
Jim Clark made a good suggestion which was to store all of the <style>
information in a separate file and then read it in using the Ruby CGI
tools. I'll also have to look at what Ryan was suggesting. I was also
interested in how to perform graphing options from CGI and it looks like
there are some great Class libraries out there for that sort of thing also.
The key idea of my script is to build an extended CGI Class that can
dump some dynamic output and graph some sensor data as a starting point
for a much richer application.
-Steve
uw-ruby-request at zenspider.com wrote:
> Send Uw-ruby mailing list submissions to
> uw-ruby at zenspider.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://www.zenspider.com/mailman/listinfo/uw-ruby
> or, via email, send a message with subject or body 'help' to
> uw-ruby-request at zenspider.com
>
> You can reach the person managing the list at
> uw-ruby-owner at zenspider.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Uw-ruby digest..."
>
>
> Today's Topics:
>
> 1. Re: autotest qwirky? (Ryan Davis)
> 2. Re: DOM or Stream parsing? (Dan McHarness)
> 3. Re: Encapsulating HTML <style> using CGI?? (Ryan Davis)
> 4. Re: Encapsulating HTML <style> using CGI?? (Brent A. LaMotte)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 21 Nov 2007 16:45:43 -0800
> From: Ryan Davis <ryand-uwruby at zenspider.com>
> Subject: Re: [Uw-ruby] autotest qwirky?
> To: UW's Ruby Certificate Program <uw-ruby at zenspider.com>
> Message-ID: <BB13B5EE-2819-424D-B8DE-421E5BCBD6E2 at zenspider.com>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
>
> On Nov 18, 2007, at 20:51 , Ryan Ward wrote:
>
>
>> Both homework files open in my editor (test_weekX.rb and weekX.rb).
>> I have terminal running with autotest in the background. I make a
>> change to weekX.rb hit save, then watch autotest detect the change.
>>
>> In this case #2 kept failing over and over and I couldn't figure out
>> why. Could swear my code looked ok. I did some more muckin around
>> with my code, saving again, then decided to revert back to my original
>> code and then saving once more. All of a sudden the test started
>> passing with the exact same code when the test failed.
>>
>
> Autotest isn't quirky, it is very very mechanical.
>
>
>> 2) Failure:
>> test_find_all_evens(TestWeek4) [test/test_week4.rb:44]:
>> --- /var/folders/T3/T3JeDhXpGXSZWZV0lFaRTE+++TI/-Tmp-/expect.4006.0
>> 2007-11-18 20:18:09.000000000 -0800
>> +++ /var/folders/T3/T3JeDhXpGXSZWZV0lFaRTE+++TI/-Tmp-/butwas.4006.0
>> 2007-11-18 20:18:09.000000000 -0800
>> @@ -1 +1 @@
>> -<[2, 4, 6, 8]>
>> +<nil>
>>
>>
>> I have noticed this in many times now, in previous weeks home work as
>> well. Is there some sort of caching happening in autotest, or maybe
>> this is Textmate doing something weird with saves? Or some user error?
>>
>
> Generally what I've found is people write tests that don't have their
> dependencies set up correctly or depend on various load orders.
> Autotest always outputs it's command line so you can see what it is
> running and how. Grab that and try to reproduce your problem w/o
> autotest.
>
> http://blog.zenspider.com/archives/2006/11/rake_passes_but_autotest_fails.html
>
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 21 Nov 2007 22:44:15 -0800 (PST)
> From: Dan McHarness <dmcharness at yahoo.com>
> Subject: Re: [Uw-ruby] DOM or Stream parsing?
> To: Uw-ruby at zenspider.com
> Message-ID: <835841.45178.qm at web51906.mail.re2.yahoo.com>
> Content-Type: text/plain; charset=iso-8859-1
>
> FWIW, using the REXML::StreamListener I got the
> following results:
>
> via Benchmark test ~9.5 sec (avg of 3 tests)
> via unit test: ~11.25 sec (avg of 3 tests)
>
> --- Dan McHarness <dmcharness at yahoo.com> wrote:
>
>
>> FWIW my view is that for this introductory class I
>> should be learning how to use the standard XML
>> library
>> that ships with ruby. Saying that, I'll be looking
>> to
>> use the SAX approach over DOM if I can, but I want
>> to
>> make sure I first understand how to utilize REXML.
>>
>>
>>
>>
>> --- uw-ruby-request at zenspider.com wrote:
>>
>>
>>> Send Uw-ruby mailing list submissions to
>>> uw-ruby at zenspider.com
>>>
>>> To subscribe or unsubscribe via the World Wide
>>>
>> Web,
>>
>>> visit
>>> http://www.zenspider.com/mailman/listinfo/uw-ruby
>>> or, via email, send a message with subject or body
>>> 'help' to
>>> uw-ruby-request at zenspider.com
>>>
>>> You can reach the person managing the list at
>>> uw-ruby-owner at zenspider.com
>>>
>>> When replying, please edit your Subject line so it
>>> is more specific
>>> than "Re: Contents of Uw-ruby digest..."
>>>
>>>
>>> Today's Topics:
>>>
>>> 1. DOM or Stream parsing? (Garrick West)
>>> 2. Re: DOM or Stream parsing? (Richard Leickly)
>>> 3. Re: DOM or Stream parsing? (Mark Holton)
>>>
>>>
>>>
>>>
> ----------------------------------------------------------------------
>
>>> Message: 1
>>> Date: Sat, 17 Nov 2007 23:44:43 -0800
>>> From: "Garrick West" <garrick at acm.org>
>>> Subject: [Uw-ruby] DOM or Stream parsing?
>>> To: Uw-ruby at zenspider.com
>>> Message-ID:
>>>
>>>
>>>
> <9e0ec7f70711172344k5ece4150x48027f44ca531dc6 at mail.gmail.com>
>
>>> Content-Type: text/plain; charset="iso-8859-1"
>>>
>>> Hi Ryan,
>>> I figured I'd send this to the list as others
>>>
>> might
>>
>>> be interested in your
>>> response:
>>>
>>> Wow. That iTunes library is a bit of a monster to
>>> pull in with DOM, but it
>>> seems to work (at least on my system;). The DTD
>>>
>> is
>>
>>> almost as simple as you
>>> can get, so it's not it would be too hard to do
>>> Stream parsing, but I
>>> question the value of doing so If you're not
>>> concerned about the load time.
>>> It takes 54 seconds on my 2nd gen MacBook Pro
>>> usingREXML, and I've seen
>>> some form posts googling around suggesting libxml
>>>
>> is
>>
>>> faster,
>>> but can be a pain to set up (possibly dated?).
>>>
>>> Thoughts?
>>> --Garrick West
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL:
>>>
>>>
> http://www.zenspider.com/pipermail/uw-ruby/attachments/20071117/639146b6/attachment-0001.html
>
>>> ------------------------------
>>>
>>> Message: 2
>>> Date: Sun, 18 Nov 2007 00:39:36 -0800
>>> From: "Richard Leickly"
>>> <Richard at iphc.washington.edu>
>>> Subject: Re: [Uw-ruby] DOM or Stream parsing?
>>> To: "UW's Ruby Certificate Program"
>>> <uw-ruby at zenspider.com>
>>> Message-ID:
>>>
>>>
>>>
> <40F0CA56251F1445A08B6019E34798B175BB61 at everglade.iphc.washington.edu>
>
>>> Content-Type: text/plain; charset="us-ascii"
>>>
>>> I don't know all those acronyms; but it sounds
>>>
>> like
>>
>>> you are rolling in
>>> some heavy artillary, Garrick !!
>>> I used file.open() on the xml file. Quick. The
>>> greps and the operations
>>> on the resulting arrays were also quick. I have a
>>>
>> v.
>>
>>> old Dell Platitude
>>> laptop.
>>>
>>> RD: maybe we could look at some of the more
>>> interesting solutions in
>>> class. Sounds like GW has more tricks than Felix
>>> The Cat.
>>>
>>> Richard Leickly
>>>
>>> P.S. Yes...I am working on the weekend. Yes..I do
>>> have a life.
>>> ________________________________
>>>
>>> From: uw-ruby-bounces at zenspider.com
>>> [mailto:uw-ruby-bounces at zenspider.com] On Behalf
>>>
>> Of
>>
>>> Garrick West
>>> Sent: Saturday, November 17, 2007 11:45 PM
>>> To: Uw-ruby at zenspider.com
>>> Subject: [Uw-ruby] DOM or Stream parsing?
>>>
>>>
>>> Hi Ryan,
>>> I figured I'd send this to the list as others
>>>
>> might
>>
>>> be interested in
>>> your response:
>>>
>>> Wow. That iTunes library is a bit of a monster to
>>> pull in with DOM, but
>>> it seems to work (at least on my system;). The
>>>
>> DTD
>>
>>> is almost as simple
>>> as you can get, so it's not it would be too hard
>>>
>> to
>>
>>> do Stream parsing,
>>> but I question the value of doing so If you're not
>>> concerned about the
>>> load time. It takes 54 seconds on my 2nd gen
>>> MacBook Pro using
>>> REXML, and I've seen some form posts googling
>>>
>> around
>>
>>> suggesting libxml
>>> is faster,
>>> but can be a pain to set up (possibly dated?).
>>>
>>>
>>> Thoughts?
>>> --Garrick West
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL:
>>>
>>>
> http://www.zenspider.com/pipermail/uw-ruby/attachments/20071118/0fa1c186/attachment-0001.html
>
>>> ------------------------------
>>>
>>> Message: 3
>>> Date: Sun, 18 Nov 2007 01:45:20 -0800
>>> From: "Mark Holton" <holtonma at gmail.com>
>>> Subject: Re: [Uw-ruby] DOM or Stream parsing?
>>> To: "UW's Ruby Certificate Program"
>>> <uw-ruby at zenspider.com>
>>> Message-ID:
>>>
>>>
>>>
> <8bd9e8730711180145g4802903eie1f30e8aefa55d37 at mail.gmail.com>
>
>>> Content-Type: text/plain; charset="iso-8859-1"
>>>
>>> Came across this tonight: XmlSimple library ...in
>>> the 'xml-simple' gem...
>>> parses an XML document into a Ruby hash.
>>>
>>> Guessing, and from what I read, there are no
>>> performance saving when sucking
>>> in the XML, but the resulting object is easier to
>>> use -- ends up as nested
>>> structure of Ruby hashes and arrays.
>>>
>>> http://xml-simple.rubyforge.org/
>>>
>>> :Holton
>>>
>>>
>>> On Nov 17, 2007 11:44 PM, Garrick West
>>> <garrick at acm.org> wrote:
>>>
>>>
>>>> Hi Ryan,
>>>> I figured I'd send this to the list as others
>>>>
>>> might be interested in your
>>>
>>>> response:
>>>>
>>>> Wow. That iTunes library is a bit of a monster
>>>>
>> to
>>
>>
> === message truncated ===
>
>
>
> ____________________________________________________________________________________
> Be a better sports nut! Let your teams follow you
> with Yahoo Mobile. Try it now. http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 22 Nov 2007 01:59:26 -0800
> From: Ryan Davis <ryand-uwruby at zenspider.com>
> Subject: Re: [Uw-ruby] Encapsulating HTML <style> using CGI??
> To: UW's Ruby Certificate Program <uw-ruby at zenspider.com>
> Message-ID: <A4D7AE4F-762C-4023-B4E2-F3B38C066A15 at zenspider.com>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
>
> On Nov 20, 2007, at 23:13 , Steve Dame wrote:
>
>
>> I have a question about using Ruby CGI. I want to be able to generate
>> some very rich web tables that the HTML is generated from a tool chain
>> of Excel--Word and then exported to an HTML file for the look and feel
>> of my web page.
>>
>> The cgi.rb example got me pointed in the right direction, but how does
>> one go about pulling raw text "style" strings into a cgi object so
>> that
>> it can properly build an HTML sections output?
>>
>> The objective is to get a section of the CGI Ruby script to generate
>> something like:
>>
>
> You use lots of words in combinations and forms I don't currently
> understand. Some of that is surely me (and the time), but... wha?
>
> You want a CGI to create... what? A word document?
>
>
>> <style>
>> <!--
>> /* Font Definitions */
>> @font-face
>> {font-family:"Times New Roman";
>> panose-1:0 2 2 6 3 5 4 5 2 3;
>> mso-font-charset:0;
>> mso-generic-font-family:auto;
>> mso-font-pitch:variable;
>> mso-font-signature:50331648 0 0 0 1 0;}
>>
>
> that's not HTML or CSS. It may work on IE, but the rest of the world
> won't see a thing afaik.
>
> Anyhow... I'm still not sure what you're trying to do, but the general
> idea is you've got data coming in via some stream (sounds like from a
> static file or stdin) that you're pulling in, then you morph that
> however appropriate, and push that out towards the web client... I
> usually use builder or markaby because they let me write my output in
> a structured ruby code block:
>
>
>> mab = Markaby::Builder.new
>> mab.html do
>> head do
>> title "title"
>> style do
>> self << "body { font-family: Optima, Times; background-color:
>> #99F }"
>> self << "h1 { color: #339 ; text-align: center }"
>> self << "h2 { color: #006 }"
>> self << "a { color: black }"
>> end
>> end
>> body do
>> h1 "title"
>>
>> table do
>> # ... etc ...
>> end
>> end
>> end
>>
>
>
>
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Thu, 22 Nov 2007 11:18:38 -0800
> From: "Brent A. LaMotte" <brent at lbbl.org>
> Subject: Re: [Uw-ruby] Encapsulating HTML <style> using CGI??
> To: UW's Ruby Certificate Program <uw-ruby at zenspider.com>
> Message-ID: <6E3FC46F-4939-44F6-92CD-A41B2AF03135 at lbbl.org>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
> The output he has is CSS (it's not valid, it is heinous, but it would
> work) - it's the same code a Word generated CSS and HTML file would
> output (GOD ARE THEY EVER UGLY, said the front end developer who has
> seen more than his share of that garbage - the mso- attributes in the
> CSS is the dead giveaway).
>
> It'll work in non-IE browsers, but I would bet cross browser is not
> part of his spec.
>
> On Nov 22, 2007, at 1:59 AM, Ryan Davis wrote:
>
>
>> On Nov 20, 2007, at 23:13 , Steve Dame wrote:
>>
>>
>>> I have a question about using Ruby CGI. I want to be able to
>>> generate
>>> some very rich web tables that the HTML is generated from a tool
>>> chain
>>> of Excel--Word and then exported to an HTML file for the look and
>>> feel
>>> of my web page.
>>>
>>> The cgi.rb example got me pointed in the right direction, but how
>>> does
>>> one go about pulling raw text "style" strings into a cgi object so
>>> that
>>> it can properly build an HTML sections output?
>>>
>>> The objective is to get a section of the CGI Ruby script to generate
>>> something like:
>>>
>> You use lots of words in combinations and forms I don't currently
>> understand. Some of that is surely me (and the time), but... wha?
>>
>> You want a CGI to create... what? A word document?
>>
>>
>>> <style>
>>> <!--
>>> /* Font Definitions */
>>> @font-face
>>> {font-family:"Times New Roman";
>>> panose-1:0 2 2 6 3 5 4 5 2 3;
>>> mso-font-charset:0;
>>> mso-generic-font-family:auto;
>>> mso-font-pitch:variable;
>>> mso-font-signature:50331648 0 0 0 1 0;}
>>>
>> that's not HTML or CSS. It may work on IE, but the rest of the world
>> won't see a thing afaik.
>>
>> Anyhow... I'm still not sure what you're trying to do, but the general
>> idea is you've got data coming in via some stream (sounds like from a
>> static file or stdin) that you're pulling in, then you morph that
>> however appropriate, and push that out towards the web client... I
>> usually use builder or markaby because they let me write my output in
>> a structured ruby code block:
>>
>>
>>> mab = Markaby::Builder.new
>>> mab.html do
>>> head do
>>> title "title"
>>> style do
>>> self << "body { font-family: Optima, Times; background-color:
>>> #99F }"
>>> self << "h1 { color: #339 ; text-align: center }"
>>> self << "h2 { color: #006 }"
>>> self << "a { color: black }"
>>> end
>>> end
>>> body do
>>> h1 "title"
>>>
>>> table do
>>> # ... etc ...
>>> end
>>> end
>>> end
>>>
>>
>>
>>
>> _______________________________________________
>> Uw-ruby mailing list
>> Uw-ruby at zenspider.com
>> http://www.zenspider.com/mailman/listinfo/uw-ruby
>>
>
>
>
> ------------------------------
>
> _______________________________________________
> Uw-ruby mailing list
> Uw-ruby at zenspider.com
> http://www.zenspider.com/mailman/listinfo/uw-ruby
>
>
> End of Uw-ruby Digest, Vol 2, Issue 18
> **************************************
>
--
Stephen Dame
President/CEO
Virtual DSP Corporation
4119 125th St SE
Everett, WA 98208
Tel 425.379.8888
Fax 425.357.0567
http://www.virtual-dsp.com
More information about the Uw-ruby
mailing list