From aidanf at gmail.com Wed Mar 1 04:21:02 2006 From: aidanf at gmail.com (Aidan Finn) Date: Wed, 1 Mar 2006 09:21:02 +0000 Subject: [Vpim-talk] editing and deleting fields in a vcard In-Reply-To: <20060225065556.GA478@ensemble.local> References: <4836d4ce0602240632m61c60ed6uebf62a58ed51b13@mail.gmail.com> <20060225065556.GA478@ensemble.local> Message-ID: <4836d4ce0603010121r7294dad2m6cd1ebaecfca0585@mail.gmail.com> Hi Sam, Thanks for your reply. I think it would be useful to be able to edit a vcard in place rather than having to copy all the fields into a new vcard. I wouldn't worry about the user nuking their vcards - I think it should be up to the user to make sure the edited vcard is valid. I think you can already mess up a vcard anyway by using push to append a field to a vcard if that field already exists. Another issue related to editing is the ability to save a vcard in different formats. For example, if I edit a vcard that is vcard-2.1, vpim will save the new vcard as vcard-3.0 format. It would be useful to be able to specify vcard2.1 format, or have a method for outputing the vcard as a string in 2.1 format. Cheers, AF On 2/25/06, Sam Roberts wrote: > > > Currently, yes. > > Use Vpim::Maker::Vcard.make(), then call maker#add_field for every field > you want to add unchanged. For the field you want to change, call > Vpim::DirectoryInfo::Field#copy to get a mutable version of the field, > mutate it (#value=, etc.), then add it. > > What I was worried about was that people would change a card to no > longer be valid, remove VERSION:, add a second N:, etc. So, I wanted it > to be hard to damage a vCard that you had decoded. If you want to change > it, just make another. > > This seems a little painful as I describe it, though, and maybe I should > give developers enough rope to hang themselves. > > Or, I might add a maker#copy(other_card) API, that copies all the fields > in the other_card into the one being made (if its valid, no duplicate > VERSION, etc.). Maybe I could also make it take an optional block. I > would yield the field to the block, and if the block returns true, copy > it, or even add the return value of the yield, but its not so different > from doing it yourself: > > other_card.each do |field| > if want to change it.. > field = field.copy > field.value= 'other' > end > maker.add_field(field) > end > > What do you think? > > Cheers, > Sam > > > > _______________________________________________ > Vpim-talk mailing list > Vpim-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/vpim-talk > -- ------------------------------- http://www.aidanf.net ------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/vpim-talk/attachments/20060301/3e520f95/attachment.htm From sroberts at uniserve.com Wed Mar 1 15:04:26 2006 From: sroberts at uniserve.com (Sam Roberts) Date: Wed, 1 Mar 2006 12:04:26 -0800 Subject: [Vpim-talk] editing and deleting fields in a vcard In-Reply-To: <4836d4ce0603010121r7294dad2m6cd1ebaecfca0585@mail.gmail.com> References: <4836d4ce0602240632m61c60ed6uebf62a58ed51b13@mail.gmail.com> <20060225065556.GA478@ensemble.local> <4836d4ce0603010121r7294dad2m6cd1ebaecfca0585@mail.gmail.com> Message-ID: <20060301200425.GA13685@pebble> > Thanks for your reply. I think it would be useful to be able to edit a vcard > in place rather than having to copy all the fields into a new vcard. I > wouldn't worry about the user nuking their vcards - I think it should be up > to the user to make sure the edited vcard is valid. I think you can already > mess up a vcard anyway by using push to append a field to a vcard if that > field already exists. True, though I've called that a bug and fixed it in my working copy (can't add BEGIN/END/VERSION, can't add N or FN if they are already there, everything else is allowed multiples). I also added copying examples, and higher level APIs to copy kindof based on what I described below. I've some more hours of work before its cleaned up for release, though, the unit tests are broken. And I'll try and come up with an API to make Vcard mutable in some way that is moderately safe. It won't be in the next release, though, I've a day job. :-) > Another issue related to editing is the ability to save a vcard in > different formats. For example, if I edit a vcard that is vcard-2.1, > vpim will save the new vcard as vcard-3.0 format. It would be useful > to be able to specify vcard2.1 format, or have a method for outputing > the vcard as a string in 2.1 format. One of the design goals of vPim is to NOT modify input data if possible when rewriting, so this is definitely a problem. I'll also try and make round-trip work 1-to-1, and make it faster (profiling makes it look like performance is dominated by String#upcase and String#downcase, believe it or not). The encoding variables are: - VCARD version (2.1/3.0), which mostly affects how params are specified, and the allowed encodings and names of those encodings. - character set Currently, decoding auto detects utf-8 and ucs-2, with or without byte order marks, but always writes as utf-8 without BOM. It would be nice to control this. I've two possible approaches: - make these options part of the Vcard, so changing the version would involve mutating the vCard or copying a vCard to a new one that is set to a different version - make them an input to the encoding process, where the default is the values stored in Vcard when it was decoded. Have you ever wanted to encode the same card in multiple character sets, or multiple vCard versions? If that is common, I need to make it part of the encoding process, otherwise I can make it part of the Vcard, which is easier Cheers, Sam From aidanf at gmail.com Fri Mar 3 07:25:24 2006 From: aidanf at gmail.com (Aidan Finn) Date: Fri, 3 Mar 2006 12:25:24 +0000 Subject: [Vpim-talk] editing and deleting fields in a vcard In-Reply-To: <20060301200425.GA13685@pebble> References: <4836d4ce0602240632m61c60ed6uebf62a58ed51b13@mail.gmail.com> <20060225065556.GA478@ensemble.local> <4836d4ce0603010121r7294dad2m6cd1ebaecfca0585@mail.gmail.com> <20060301200425.GA13685@pebble> Message-ID: <4836d4ce0603030425n8fdb100ga9e8c9f595c15426@mail.gmail.com> Hi Sam, I have never wanted to encode a vcard in multiple versions or multiple character sets. It might be useful to explain what I'm using vpim for. I'm using vpim to read and edit my phone contacts. Currently I'm using php to do this but am changing to vpim as I've started using ruby a lot in the last couple of months. The idea is that I can sync my phone contacts to my computer, edit them there and then sync them back to the phone. This requires the ability to save the vcard back in the same format and character set as it was originally encoded (Most mobile phones implement vcard2.1, but not 3.0.) What encodings are currently supported by vpim? I tested vpim with a couple of thousand vcards and 12 failed to decode with Vpim::InvalidEncodingError. Cheers, AF > The encoding variables are: > - VCARD version (2.1/3.0), which mostly affects how params are > specified, and the allowed encodings and names of those encodings. > - character set > > Currently, decoding auto detects utf-8 and ucs-2, with or without byte > order marks, but always writes as utf-8 without BOM. It would be nice to > control this. > > I've two possible approaches: > > - make these options part of the Vcard, so changing the version would > involve mutating the vCard or copying a vCard to a new one that is > set to a different version > > - make them an input to the encoding process, where the default is the > values stored in Vcard when it was decoded. > > Have you ever wanted to encode the same card in multiple character sets, > or multiple vCard versions? If that is common, I need to make it part of > the encoding process, otherwise I can make it part of the Vcard, which > is easier -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/vpim-talk/attachments/20060303/d4a9e001/attachment-0001.htm From sroberts at uniserve.com Sat Mar 4 02:24:17 2006 From: sroberts at uniserve.com (Sam Roberts) Date: Fri, 3 Mar 2006 23:24:17 -0800 Subject: [Vpim-talk] editing and deleting fields in a vcard In-Reply-To: <4836d4ce0603030425n8fdb100ga9e8c9f595c15426@mail.gmail.com> References: <4836d4ce0602240632m61c60ed6uebf62a58ed51b13@mail.gmail.com> <20060225065556.GA478@ensemble.local> <4836d4ce0603010121r7294dad2m6cd1ebaecfca0585@mail.gmail.com> <20060301200425.GA13685@pebble> <4836d4ce0603030425n8fdb100ga9e8c9f595c15426@mail.gmail.com> Message-ID: <20060304072417.GA520@ensemble.local> Quoting aidanf at gmail.com, on Fri, Mar 03, 2006 at 12:25:24PM +0000: > I have never wanted to encode a vcard in multiple versions or multiple > character sets. > > The idea is that I can sync my phone contacts to my computer, edit them > there and then sync them back to the phone. This requires the ability to > save the vcard back in the same format and character set as it was > originally encoded (Most mobile phones implement vcard2.1, but not 3.0.) So you don't want transcoding, but you want encoding preserved. Ok, thats not so hard to do. Much easier than transcoding. > What encodings are currently supported by vpim? I tested vpim with a couple > of thousand vcards and 12 failed to decode with Vpim::InvalidEncodingError. Thats great that you could do that. I would like to see the ones that failed, I think I support any valid 2.1 vCard, but I could be wrong, or the card could be technically invalid. Even if they are invalid, I want vPim to be useful, not righteous, so I would try and make decoding work. On encoding, I just reemit the fields, in their original forms. The only things that might cause you problems are new fields that use base64 encoding, and (as you found), that new cards always use version 3.0. I can add support for encoding version 2.1 cards. - can you give me examples of cards that fail? - what kinds of fields do you add? - what kinds of fields to you delete, if any? - do you ever modify fields? - what kinds of character set are these cards encoded in? have you had any problems with how vpim treats character sets? - what php vcard lib did you use? did you like its api? Btw, The biggest difference between 2.1 and 3.0 is the types of encodings supported, 3.0 just allows encoding=b (base-64), version 2.1 allows encoding=7bit, 8bit, quoted-printable, and base64. Unless you have pictures, certs, or other binary data in your cards, that shouldn't matter. The other difference is that 2.1 allows params to miss their name, you can write: ADR;home:blah,blah,... And the decoder is supposed to realize that means ADR;type=home:blah,blah,... but if you see a raw "base64", the decoder is supposed to realize that what is meant is encoding=base64. Anyhow, I support this on input, but don't encode things like that. The fully specified pname=pvalue is always allowed by 2.1 and 3.0. Cheers, Sam From aidanf at gmail.com Wed Mar 8 06:06:41 2006 From: aidanf at gmail.com (Aidan Finn) Date: Wed, 8 Mar 2006 11:06:41 +0000 Subject: [Vpim-talk] editing and deleting fields in a vcard In-Reply-To: <20060304072417.GA520@ensemble.local> References: <4836d4ce0602240632m61c60ed6uebf62a58ed51b13@mail.gmail.com> <20060225065556.GA478@ensemble.local> <4836d4ce0603010121r7294dad2m6cd1ebaecfca0585@mail.gmail.com> <20060301200425.GA13685@pebble> <4836d4ce0603030425n8fdb100ga9e8c9f595c15426@mail.gmail.com> <20060304072417.GA520@ensemble.local> Message-ID: <4836d4ce0603080306y3d05119cpe4604870f75f1e3c@mail.gmail.com> I will send you some examples of vcards that fail. Most of the failed ones had notes or labels of ENCODING=QUOTED-PRINTABLE that caused the decoding exception. I mostly add/delete/edit name and telephone fields but have the ability to add/delete/edit all the defined fields. At the moment I am doing this by creating a contact object with attr_accessor methods for all the vcard fields and using vpim to load these values from a vcard and save them back to a vcard. cheers, AF On 3/4/06, Sam Roberts wrote: > > Quoting aidanf at gmail.com, on Fri, Mar 03, 2006 at 12:25:24PM +0000: > > I have never wanted to encode a vcard in multiple versions or multiple > > character sets. > > > > The idea is that I can sync my phone contacts to my computer, edit them > > there and then sync them back to the phone. This requires the ability to > > save the vcard back in the same format and character set as it was > > originally encoded (Most mobile phones implement vcard2.1, but not 3.0.) > > So you don't want transcoding, but you want encoding preserved. Ok, > thats not so hard to do. Much easier than transcoding. > > > What encodings are currently supported by vpim? I tested vpim with a > couple > > of thousand vcards and 12 failed to decode with > Vpim::InvalidEncodingError. > > Thats great that you could do that. I would like to see the ones that > failed, I think I support any valid 2.1 vCard, but I could be wrong, or > the card could be technically invalid. Even if they are invalid, I want > vPim to be useful, not righteous, so I would try and make decoding work. > > On encoding, I just reemit the fields, in their original forms. The only > things that might cause you problems are new fields that use base64 > encoding, and (as you found), that new cards always use version 3.0. I > can add support for encoding version 2.1 cards. > > - can you give me examples of cards that fail? > - what kinds of fields do you add? > - what kinds of fields to you delete, if any? > - do you ever modify fields? > - what kinds of character set are these cards encoded in? have you had > any problems with how vpim treats character sets? > - what php vcard lib did you use? did you like its api? > > Btw, The biggest difference between 2.1 and 3.0 is the types of > encodings supported, 3.0 just allows encoding=b (base-64), version 2.1 > allows encoding=7bit, 8bit, quoted-printable, and base64. Unless you > have pictures, certs, or other binary data in your cards, that shouldn't > matter. > > The other difference is that 2.1 allows params to miss their name, you > can write: > > ADR;home:blah,blah,... > > And the decoder is supposed to realize that means > > ADR;type=home:blah,blah,... > > but if you see a raw "base64", the decoder is supposed to realize that > what is meant is encoding=base64. Anyhow, I support this on input, but > don't encode things like that. The fully specified pname=pvalue is > always allowed by 2.1 and 3.0. > > Cheers, > Sam > > -- ------------------------------- http://www.aidanf.net ------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/vpim-talk/attachments/20060308/ae1c2a51/attachment.htm From sroberts at uniserve.com Thu Mar 9 00:27:30 2006 From: sroberts at uniserve.com (Sam Roberts) Date: Wed, 8 Mar 2006 21:27:30 -0800 Subject: [Vpim-talk] possibly invalid quoted printable in v2.1 vcards In-Reply-To: <4836d4ce0603080325i76c3f977k11bcd04ca6fa8237@mail.gmail.com> References: <4836d4ce0602240632m61c60ed6uebf62a58ed51b13@mail.gmail.com> <20060225065556.GA478@ensemble.local> <4836d4ce0603010121r7294dad2m6cd1ebaecfca0585@mail.gmail.com> <20060301200425.GA13685@pebble> <4836d4ce0603030425n8fdb100ga9e8c9f595c15426@mail.gmail.com> <20060304072417.GA520@ensemble.local> <4836d4ce0603080325i76c3f977k11bcd04ca6fa8237@mail.gmail.com> Message-ID: <20060309052730.GA669@ensemble.local> Quoting aidanf at gmail.com, on Wed, Mar 08, 2006 at 11:25:22AM +0000: > Hi Sam, > Here are some examples of vcards that failed to decode. I tested vpim > against a database of contacts from the place where I work. From around 4800 > contacts, only 12 failed. I've tried to anonymize them a bit by just > replacing names and phonenumbers. Can you confirm this is really what the cards look like: BEGIN:VCARD VERSION:2.1 N:Middle Family;Ny_full LABEL;CHARSET=ISO-8859-1;ENCODING=QUOTED-PRINTABLE:Box 1234=0AWorkv=E4gen = 2=0AWorkv=E4gen 1=0AUme=E5=0AV=E4sterbotten=0A12345=0AS END:VCARD If so, I'm not sure what I can do. Thats not a valid 2.1 vCard as far as I can tell. I keep staring and staring at the spec from imc.org, and its not formatted like any of the examples in the spec. The text is so vague, its hard to say definitively that its wrong, but I don't think it is folded properly, it should look like: BEGIN:VCARD VERSION:2.1 N:Middle Family;Ny_full LABEL;CHARSET=ISO-8859-1;ENCODING=QUOTED-PRINTABLE:Box 1234=0AWorkv=E4gen 2=0AWorkv=E4gen 1=0AUme=E5=0AV=E4sterbotten=0A12345=0AS END:VCARD See the space at the beginning? That's how you know the next line is a continuation of the previous LABEL: line. Also, the trailing "=" must be removed, too. I'm sorry, I would have to gut the decoder and the internal APIs to deal with this, and unless I find out that this kind of encoding is pretty common, thats not what I want to spend my time doing. I've hacked the decoder to support other invalid encodings, but those were easy, this would be pretty time consuming. If you want to do it, I'm happy give you pointers on how to write a vCard 2.0 decoding routine that deals with this, the core Field.decode0() routine would be usable. Pre-processing your input with the following filter will allow you to read the cards in: qp = false $stdin.each do |line| if line =~ /;ENCODING=QUOTED-PRINTABLE[:;].*=$/ qp = true line.gsub!(/=$/, '') elsif qp $stdout << ' ' if line =~ /=$/ # qp continues line.gsub!(/=$/, '') else qp = false end end $stdout << line # When we see the beginning of if line =~ /;ENCODING=QUOTED-PRINTABLE[:;].*=$/ end end If the phone is just echoing back what it was given, you might be able to just patch the cards, and maybe the corrected ones can be downloaded and retrieved, and all will be well from now on. If the phone itself is doing this kind of quoted-printable, and requires that format, then you might have to post-process to reverse the process above. Btw, all the cards failed for the same reason. Sorry. Sam From sroberts at uniserve.com Thu Mar 9 00:58:44 2006 From: sroberts at uniserve.com (Sam Roberts) Date: Wed, 8 Mar 2006 21:58:44 -0800 Subject: [Vpim-talk] vpim-0.17 released Message-ID: <20060309055844.GA909@ensemble.local> This release basically features reasonable support for the name fields in a vCard, and better support for modifying vCards, including partial support for modifying vCard 2.1. Cheers, Sam 0.17 - 2006-03-08 - DirectoryInfo#delete - new - Maker::Vcard#fullname - new - Provide an example of how to create, copy, and modify version 2.1 vCards. - Maker::Vcard.make2 - new - Maker::Vcard.make - deprecated - Profiled decoding of a huge iCalendar file. Performance appears to be dominated by overhead of String#downcase (20% of time spent in Field#name?). Keeping the field group, field name, and field's parameter's names internally in uppercase and using ruby 1.8's String#casecmp? is a first attempt at optimization. This is a change in the default case returned, but it aligns with the RFC and common usage. - Maker::Vcard.make - full_name is now optional, it will be derived from name/N: - Maker::Vcard#add_field - better argument checking - Maker::Vcard#copy - new - Vcard#[] - now limits return to fields with values - Vcard#name - new - Vcard::Name - new - Vcard#nicknames - new - Field#params and Field#param - deprecated and undocumented, I could never remember the difference - Field#pnames - new - Field#pvalues - new - Methods.casecmp? - new - Field#pref= - new - Field#pvalue_idel - new - Field#pvalue_iadd - new From aidanf at gmail.com Mon Mar 13 18:46:25 2006 From: aidanf at gmail.com (Aidan Finn) Date: Mon, 13 Mar 2006 23:46:25 +0000 Subject: [Vpim-talk] possibly invalid quoted printable in v2.1 vcards In-Reply-To: <20060309052730.GA669@ensemble.local> References: <4836d4ce0602240632m61c60ed6uebf62a58ed51b13@mail.gmail.com> <20060225065556.GA478@ensemble.local> <4836d4ce0603010121r7294dad2m6cd1ebaecfca0585@mail.gmail.com> <20060301200425.GA13685@pebble> <4836d4ce0603030425n8fdb100ga9e8c9f595c15426@mail.gmail.com> <20060304072417.GA520@ensemble.local> <4836d4ce0603080325i76c3f977k11bcd04ca6fa8237@mail.gmail.com> <20060309052730.GA669@ensemble.local> Message-ID: <4836d4ce0603131546m65e7929eld182b1e4955a6fe7@mail.gmail.com> Yup, I checked and thats what the vcards actually look like, even if they're not following the spec. I'll wait and see how common this problem is (<0.25%in my test) before I look at implementing a decoder for it. For the moment it looks a lot easier to just preprocess the input and then write back a valid vcard. Cheers, AF On 3/9/06, Sam Roberts wrote: > > Quoting aidanf at gmail.com, on Wed, Mar 08, 2006 at 11:25:22AM +0000: > > Hi Sam, > > Here are some examples of vcards that failed to decode. I tested vpim > > against a database of contacts from the place where I work. From around > 4800 > > contacts, only 12 failed. I've tried to anonymize them a bit by just > > replacing names and phonenumbers. > > Can you confirm this is really what the cards look like: > > BEGIN:VCARD > VERSION:2.1 > N:Middle Family;Ny_full > LABEL;CHARSET=ISO-8859-1;ENCODING=QUOTED-PRINTABLE:Box 1234=0AWorkv=E4gen > = > 2=0AWorkv=E4gen 1=0AUme=E5=0AV=E4sterbotten=0A12345=0AS > END:VCARD > > If so, I'm not sure what I can do. Thats not a valid 2.1 vCard as far as > I can tell. I keep staring and staring at the spec from imc.org, and its > not formatted like any of the examples in the spec. The text is so > vague, its hard to say definitively that its wrong, but I don't think it > is folded properly, it should look like: > > BEGIN:VCARD > VERSION:2.1 > N:Middle Family;Ny_full > LABEL;CHARSET=ISO-8859-1;ENCODING=QUOTED-PRINTABLE:Box 1234=0AWorkv=E4gen > 2=0AWorkv=E4gen 1=0AUme=E5=0AV=E4sterbotten=0A12345=0AS > END:VCARD > > See the space at the beginning? That's how you know the next line is a > continuation of the previous LABEL: line. Also, the trailing "=" must be > removed, too. > > I'm sorry, I would have to gut the decoder and the internal APIs to deal > with this, and unless I find out that this kind of encoding is pretty > common, thats not what I want to spend my time doing. I've hacked the > decoder to support other invalid encodings, but those were easy, this > would be pretty time consuming. > > If you want to do it, I'm happy give you pointers on how to write a > vCard 2.0 decoding routine that deals with this, the core > Field.decode0() routine would be usable. > > Pre-processing your input with the following filter will allow you to > read the cards in: > > qp = false > > $stdin.each do |line| > if line =~ /;ENCODING=QUOTED-PRINTABLE[:;].*=$/ > qp = true > line.gsub!(/=$/, '') > elsif qp > $stdout << ' ' > if line =~ /=$/ > # qp continues > line.gsub!(/=$/, '') > else > qp = false > end > end > > $stdout << line > > # When we see the beginning of > if line =~ /;ENCODING=QUOTED-PRINTABLE[:;].*=$/ > end > end > > If the phone is just echoing back what it was given, you might be able > to just patch the cards, and maybe the corrected ones can be downloaded > and retrieved, and all will be well from now on. If the phone itself is > doing this kind of quoted-printable, and requires that format, then you > might have to post-process to reverse the process above. > > Btw, all the cards failed for the same reason. > > Sorry. > Sam > > > > -- ------------------------------- http://www.aidanf.net ------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/vpim-talk/attachments/20060313/e31040bb/attachment-0001.htm From sroberts at uniserve.com Sat Mar 18 15:36:38 2006 From: sroberts at uniserve.com (Sam Roberts) Date: Sat, 18 Mar 2006 12:36:38 -0800 Subject: [Vpim-talk] Gem Install problem In-Reply-To: <200603171903.k2HJ3MjT024165@rubyforge.org> References: <200603171903.k2HJ3MjT024165@rubyforge.org> Message-ID: <20060318203638.GA923@ensemble.local> Quoting anejr at alevans.com, on Fri, Mar 17, 2006 at 02:03:22PM -0500: > Installed via "gem install". It thinks it's installed correctly: > alsmini:~ al$ irb > irb(main):001:0> require 'rubygems' > => true > irb(main):002:0> require_gem 'vpim/maker/vcard' It doesn't appear that you can require specific files within a gem, I'm not sure what I can do about this, does anybody have suggestions? ensemble:~/p/ruby/vpim/trunk/releases % /usr/local/bin/ruby18 -rrubygems -e "require_gem 'vpim/vpim'; p Vpim::VERSION" /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:204:in `report_activate_error': Could not find RubyGem vpim/vpim (> 0.0.0) (Gem::LoadError) I added a top-level vpim.rb that requires all the parts currently implemented, and requiring that file seems to work: ensemble:~/p/ruby/vpim/trunk/releases % /usr/local/bin/ruby18 -rrubygems -e "require_gem 'vpim'; p Vpim::Maker::Vcard" Vpim::Maker::Vcard ensemble:~/p/ruby/vpim/trunk/releases % /usr/local/bin/ruby18 -rrubygems -e "require_gem 'vpim'; p Vpim::VERSION" "0.18" Could you give the attached gem a whirl, and tell me if it works for you, too? Thanks Sam -------------- next part -------------- A non-text attachment was scrubbed... Name: vpim-0.18.gem Type: application/octet-stream Size: 37888 bytes Desc: not available Url : http://rubyforge.org/pipermail/vpim-talk/attachments/20060318/08a661bb/attachment-0001.obj From rgkaufman at gmail.com Mon Mar 20 14:15:21 2006 From: rgkaufman at gmail.com (Rob Kaufman) Date: Mon, 20 Mar 2006 11:15:21 -0800 Subject: [Vpim-talk] Gem Install problem In-Reply-To: <20060318203638.GA923@ensemble.local> References: <200603171903.k2HJ3MjT024165@rubyforge.org> <20060318203638.GA923@ensemble.local> Message-ID: <17112e2f0603201115y1ec75a39ged7843721914cb64@mail.gmail.com> Hi Sam, I tried installing your gem on my Windows 2000 Cygwin Ruby 1.8.4 Gem 0.8.10 setup. Everything worked fine running test_date.rb from 0.15 (it was convenient) and running a few of the samples from the vpim README at vpim.rubyforge.org However I've noticed that the way you have called your gem in the below quoted example will not work. Gems can be included with require_gem (in which case only the top level appears accessible) or by adding '-rubygems' (only one r, not '-rrubygems') and just requiring as normal in your code. This is the preferred method because then code doesn't have to be different if vpim is a gem vs if it is installed from tgz. To convert your example: $ /usr/bin/ruby -e "require 'vpim/vpim'; p Vpim::VERSION" -e:1:in `require': no such file to load -- vpim/vpim (LoadError) from -e:1 $ /usr/bin/ruby -rubygems -e "require 'vpim/vpim'; p Vpim::VERSION" "0.18" An alternative way to add command line arguments to ruby is to set RUBYOPTS ('export' is of course for bash, use 'set' or whatever your shell requires). $ export RUBYOPT=rubygems RKaufma2 at WASPUS7147 ~/down $ /usr/bin/ruby -e "require 'vpim/vpim'; p Vpim::VERSION" "0.18" Hope That Helps, Rob Kaufman On 3/18/06, Sam Roberts wrote: > Quoting anejr at alevans.com, on Fri, Mar 17, 2006 at 02:03:22PM -0500: > > Installed via "gem install". It thinks it's installed correctly: > > alsmini:~ al$ irb > > irb(main):001:0> require 'rubygems' > > => true > > irb(main):002:0> require_gem 'vpim/maker/vcard' > > It doesn't appear that you can require specific files within a gem, I'm > not sure what I can do about this, does anybody have suggestions? > > ensemble:~/p/ruby/vpim/trunk/releases % /usr/local/bin/ruby18 -rrubygems -e "require_gem 'vpim/vpim'; p Vpim::VERSION" > /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:204:in > `report_activate_error': Could not find RubyGem vpim/vpim (> 0.0.0) (Gem::LoadError) > > > I added a top-level vpim.rb that requires all the parts currently > implemented, and requiring that file seems to work: > > ensemble:~/p/ruby/vpim/trunk/releases % /usr/local/bin/ruby18 -rrubygems -e "require_gem 'vpim'; p Vpim::Maker::Vcard" > Vpim::Maker::Vcard > ensemble:~/p/ruby/vpim/trunk/releases % /usr/local/bin/ruby18 -rrubygems -e "require_gem 'vpim'; p Vpim::VERSION" > "0.18" > > Could you give the attached gem a whirl, and tell me if it works for > you, too? > > Thanks > Sam > > > > _______________________________________________ > Vpim-talk mailing list > Vpim-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/vpim-talk > > > From sroberts at uniserve.com Tue Mar 21 02:08:49 2006 From: sroberts at uniserve.com (Sam Roberts) Date: Mon, 20 Mar 2006 23:08:49 -0800 Subject: [Vpim-talk] Adding new fields to Maker::Vcard In-Reply-To: References: <200603171903.k2HJ3MjT024165@rubyforge.org> <20060318070802.GA553@ensemble.local> <20060319234929.GA1437@ensemble.local> <31E82936-C444-4BF3-95AA-98DB33001748@tbtm.org> <20060320184247.GA10772@pebble> <20060320220333.GA15080@pebble> Message-ID: <20060321070849.GA660@ensemble.local> Quoting anejr at tbtm.org, on Mon, Mar 20, 2006 at 05:28:53PM -0600: > On Mar 20, 2006, at 4:03 PM, Sam Roberts wrote: > > >On Mon, Mar 20, 2006 at 12:59:03PM -0600, Al Evans wrote: > >>by trial and error, because I wanted to construct my own "N" field. > > > >Vpim::Maker::Vcard allows you to construct your own N field, > >specifying the components of the field in any way you like. > > > >Why do you need to create the Field() directly? > > Uh... I was working from the examples instead of the source, and > couldn't figure out how to change a field without copying the whole > vcard. I want users to be able to edit the info obtained from their > vCards. Now I'm doing this (for example) ex_cpvcard.txt, at the end uses a Maker::Vcard to add a nickname to an existing vCard. > def url=(new_url) > card = get_id_card > f = card.field('URL').copy > f.value = new_url > f.freeze #???? > card.delete(card.field('URL')) > card.push(f) > end > > I didn't see any obvious way to change the contents of fields, since > they're frozen. Correct, if you twiddle their insides the card can become invalid. There are countless fields in the vCard spec, I haven't gone through to try and implement every one. I'm happy to implement the ones you use, though, if you give me a list. Also, recognize that you can add support to Maker::Vcard yourself (and if you do, I'd appreciate you emailing me the patches!). This example will be in the next release. Note that it shows a simple field, but using the example implementations, its easy to add more complex examples. # ex_mkyourown.rb require 'vpim/maker/vcard' module Vpim module Maker class Vcard # Add a user-defined field, X-MY-OWN:. # # This can be done both to encode custom fields, or to add support for # fields that Maker::Vcard doesn't support. In the latter case, please # submit your methods so I can add them to vPim. def add_my_own(value) @card << Vpim::DirectoryInfo::Field.create( 'X-MY-OWN', value.to_str ); end end end end Vpim::Maker::Vcard.make2 do |m| m.add_name do |n| n.given = 'Given' end m.add_my_own 'my value' end puts card Or your example: require 'vpim/maker/vcard' module Vpim module Maker class Vcard def add_url(value) @card << Vpim::DirectoryInfo::Field.create( 'URL', value.to_str ); end end end end # ... def url=(new_url) card = get_id_card card.delete(card.field('URL')) # ... note that the above will only delete the first URL, there is no # limit on the number of URL fields in a vCard. You probably want to # handle that. Vpim::Maker::Vcard.make2(card) { |m| m.add_url new_url } end Cheers, Sam From sroberts at uniserve.com Tue Mar 21 02:48:49 2006 From: sroberts at uniserve.com (Sam Roberts) Date: Mon, 20 Mar 2006 23:48:49 -0800 Subject: [Vpim-talk] vpim-0.323 released In-Reply-To: <20060309055844.GA909@ensemble.local> References: <20060309055844.GA909@ensemble.local> Message-ID: <20060321074849.GB1218@ensemble.local> I feel that the internals of vpim are fairly stable, so I've started a push to develop higher-level APIs. Last release was mostly work on the Vcard maker. This release I've mostly worked on APIs to access properties of iCalendar components. I've designed APIs to access almost all the component properties defined in RFC2445, and implemented more than half the new APIs of Vevent, Vtodo, and Vjournal. I also have plans to do similar high-level APIs for vCard, and to create Maker classes for iCalendar components and recurrence rules. The work goes fast, but there is lots to do. I've also moved to using the svn revision number, it makes it easier to find the source for a particular release without having to do any branching. Also, this release should have a better gem package. Cheers, Sam CHANGES @2006-03-20: - Maker::Vcard#add_url - new - ex_mkyourown.rb - new example - Modularized the component property accessor methods, and added lots of Icalendar property support for Vevent, Vtodo, and Vjournal. - Fixed support for TEXT decoding. - Use Subversion revision as release sub-version. - It appears that a top-level vpim.rb that requires everything else is needed for ruby-gems, gemspec seems to work now. - Don't package backup files (.../*.rb~). - Icalendar decoding optimizations. Icalendar.decode is about twice as fast now, and more optimizations are scheduled. - Continue the move to using uppercase for all syntactic elements that can be mixed case. The API might eventually allow only uppercase, it appears case-insensitive comparisons still have a noticeable effect on performance. Excerpt from local design notes: APIs: Vpim Icalendar Rrule Attendee Attachment ...? Vevent Vtodo V... Property Common (summary/description/...) Times (dtstart/dtend/duration) ... Rrule Shouldn't this be under Icalendar? Also, I think it needs to take DTEND and/or DURATION as an arg, or in Vevent, both #dtend and #duration need to take an optional +ytime+, so you can find the how long each occurence is. Icalendar# prodid n: 1 #value TEXT version n: 1 #value "2.0" calscale n:0-1 #value "GREGORIAN" method n:0-1 #value ... see iTIP components... #event #todo #journal #freebusy #timezone #iana... #x... Vevent# #properties --> a Dirinfo? #class n:0-1 #value "PUBLIC" / "PRIVATE" / "CONFIDENTIAL" / ... (default is "PUBLIC") #created n:0-1 #value DATE-TIME, must be UTC (default is "PUBLIC") #dtstamp n:0-1 #value DATE-TIME, must be UTC #last-modified n:0-1 #value DATE-TIME, must be UTC #dtstart, #dtend, n:0-1 #value DATE-TIME, or optionally DATE param VALUE param TZID supported? (dtstart is required for VEVENT, different criteria by component) #duration n:0-1 #value special format... currently return seconds, but that is only with respect to the specific occurence. Perhaps it should take an arg, where it's arg is start time. Default is DTSTART, but if you want to know the duration of each occurence, you can ask with the new start time. Or does Rrule already handle this? note: either DTEND or DURATION, but not both #description/#location/#summary n:0-1 #value TEXT param ALTREP param LANGUAGE Deal with altrep by having #description_altrep, etc, returning a URI #geo n:0-1 #value [ FLOAT, FLOAT ], the latitude and longitude #organizer n:0-1 #value CAL-ADDRESS param CN param DIR param SENTBY param LANGUAGE #priority n:0-1 #value INTEGER, range is 0-9, 0 being unspecified (the default), 1 being highest priority #sequence n:0-1 #value INTEGER #status n:0-1 #value "TENTATIVE"/ "CONFIRMED"/ "CANCELLED" (different for each component) #transp n:0-1 #value "OPAQUE" / "TRANSPARENT" #uid n:0-1 #value TEXT #url n:0-1 #value URI, return as text? probably easiest... maybe accept URI though, particularly if it has a to_str or to_s method #recurid n:0-1 #value DATE-TIME, or optionally DATE param VALUE param TZID supported? param RANGE Should be a class, and it has tons of special handling... deal with later if I ever do iTIP. #attachments n:0-* ... array of class Attachment Attachment #uri TEXT (default) #binary String, ENCODING=BASE64, VALUE=BINARY #format param FMTTYPE, application/x-word, etc., default to "" or nil? #value either binary, or download the URI, can it be a StringIO? #attendees n:0-* ... array of class Address #categories n:0-* #value TEXT ... array of String param LANGUAGE ... don't support (Concatenate all the categories found, comma seperated in each value, all the property values in one array) #resources n:0-* #value TEXT ... array of String param LANGUAGE ... don't support param ALTREP ... don't support (Concatenate all the resources found, comma seperated in each value, all the property values in one array) #comments n:0-* #value TEXT ... array of String param LANGUAGE ... don't support param ALTREP ... don't support (Concatenate all the comments found, all the property values in one array) #contacts n:0-* #value TEXT ... array of String param LANGUAGE ... don't support param ALTREP ... don't support #exrules n:0-* #value RRULE ... array of Rrule #exdates n:0-* #value DATE-TIME, or optionally DATE ... array of Time, or Date? param VALUE param TZID supported? #rstatus n:0-* #value TEXT, kindof ... array of class Status: #code #description #extra #relationships "RELATED-TO" n:0-* #value TEXT ... array of class Related: #uid String #type "PARENT"/ "CHILD" / "SIBLING" (parent is default) #target ... a component? could use special handing: #parents (default) #children #siblings --> type should be components, that I look up by UID #rrule #rdate ... both may occur multiple times, how to handle? I think I need a #recurrences that returns an object that has all the rrules, rdates, and exceptional conditions in it, and returns them in sorted order.... Not trivial! Definitely could use some test code. ; the following are optional, ; and MAY occur more than once x-prop Give access to the underlying fields if they want to do something special. For multi-valued properties where it might be useful to have access to the params, sometime, I could do #comments(detailed=false) where detailed returns objects if its needed. In the meantime, there's always the dirinfo APIs. alarms... n:0-* ... array of Alarm: TBD... Summary of properties by component type: can have *alarmc: vevent vtodo Done: Vtodo: Vevent: Vjournal: the following are optional, but MUST NOT occur more than once x class x x x x created x x x x description x x x x dtstamp x x x x dtstart x x x x last-mod x x x x organizer x x x recurid x x x seq x x x x status x x x x summary x x x x uid x x x x url x x x completed x x geo x x x location x x percent x x priority x x x transp x due x duration x x dtend x the following are optional, and MAY occur more than once x categories x x x x comment x x x x contact x x x x resources x x attach x x x attendee x x x related x x x exdate x x x exrule x x x rdate x x x rrule x x x rstatus x x x Notes: Vtodo - either 'due' or 'duration' may appear in a 'todoprop', but 'due' and 'duration' MUST NOT occur in the same 'todoprop' due duration Vevent - either 'dtend' or 'duration' may appear in a 'eventprop', but 'dtend' and 'duration' MUST NOT occur in the same 'eventprop' dtend duration