https://github.com/riboseinc/ruby-vcard
a pure-ruby library for decoding and encoding vCard
https://github.com/riboseinc/ruby-vcard
Last synced: about 1 month ago
JSON representation
a pure-ruby library for decoding and encoding vCard
- Host: GitHub
- URL: https://github.com/riboseinc/ruby-vcard
- Owner: riboseinc
- License: mit
- Created: 2017-06-19T03:58:31.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-05-18T03:57:14.000Z (about 4 years ago)
- Last Synced: 2025-04-05T23:32:31.165Z (about 2 months ago)
- Language: Ruby
- Size: 408 KB
- Stars: 6
- Watchers: 9
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
**NOTE: This gem has been superseded by https://github.com/riboseinc/ruby-vobject , which incorporates both Vcards and Vcalendars. It is no longer being maintained.**
= Ruby vObject vCard gem
This is a pure Ruby library for decoding and encoding vCards using the
vObject structure.== Installation
Install the vObject gem.
Add this line to your application's Gemfile:
[source,ruby]
----
gem 'vcard'
----== Usage
Vobject.parse("")
* Components, properties, and parameters are all objects.
* Each type of component is a distinct object.
* The parameters of a property are represented as an array of parameter objects.
* If a property has multiple values, given on separate lines, they are represented
as an array of value properties. Each value hash may have its own parameters.
* The values of properties are native Ruby types wherever possible
(hashes, dates, integers, doubles).vCard example:
```
BEGIN:VCARD
VERSION:4.0
UID:urn:uuid:4fbe8971-0bc3-424c-9c26-36c3e1eff6b1
FN:J. Doe
N:Doe;J.;;;
EMAIL;PID=1.1:jdoe@ex
ample.com
EMAIL;PID=2.1:[email protected]
EMAIL;PID=2.2:[email protected]
TEL;PID=1.1;VALUE=uri:tel:+1-555-555-5555
TEL;PID=2.1,2.2;VALUE=uri:tel:+1-666-666-6666
CLIENTPIDMAP:1;urn:uuid:53e374d9-337e-4727-8803-a1e9c14e0556
CLIENTPIDMAP:2;urn:uuid:1f762d2b-03c4-4a83-9a03-75ff658a6eee
END:VCARD
```converts to:
```
#,
#,
#,
#"Doe",
:givenname=>"J.",
:additionalname=>"",
:honprefix=>"",
:honsuffix=>""}>,
#],
@param_name=:PID>],
@prop_name=:EMAIL,
@value="[email protected]">,
#],
@param_name=:PID>],
@prop_name=:EMAIL,
@value="[email protected]">,
#],
@param_name=:PID>],
@prop_name=:EMAIL,
@value="[email protected]">],
@prop_name=:EMAIL>,
#],
@param_name=:PID>,
#],
@prop_name=:TEL,
@value="tel:+1-555-555-5555">,
#,
#],
@param_name=:PID>,
#],
@prop_name=:TEL,
@value="tel:+1-666-666-6666">],
@prop_name=:TEL>,
#"1", :uri=>"urn:uuid:53e374d9-337e-4727-8803-a1e9c14e0556"}>,
#"2", :uri=>"urn:uuid:1f762d2b-03c4-4a83-9a03-75ff658a6eee"}>],
@prop_name=:CLIENTPIDMAP>],
@comp_name=:VCARD>
```## Implementation
This gem is implemented using [Rsec](https://github.com/luikore/rsec), a very fast PEG grammar based on StringScanner.
## Coverage
This tool is intended as a reference implementation, and it is very strict in its conformance: it requires all rules for parameter coocurrence,
property typing, parameter typing, permitted properties within components, etc to be met by objects.The tool only parses one object at a time, and does not parse Vobject streams.
This tool supports v3.0 vCard as specified in RFC 2425 and RFC 2426, and as updated in RFC 2739 (calendar attributes) and RFC 4770 (extensions for Instant Messaging). It allows for the VCARD 2.1 style specification of PREF parameters in RFC 2739.
This tool supports v4.0 vCard as specified in RFC 6350, and as updated in RFC 6868 (parameter encoding), RFC 6474 (place of birth, place and date of death), RFC 6715 (OMA CAB extensions), and RF 6473 (KIND:application).
== Development
After checking out the repo, run `bin/setup` to install dependencies.
Then, run `rake spec` to run the tests. You can also run `bin/console`
for an interactive prompt that will allow you to experiment.To install this gem onto your local machine, run `bundle exec rake
install`. To release a new version, update the version number in
`version.rb`, and then run `bundle exec rake release`, which will create
a git tag for the version, push git commits and tags, and push the
`.gem` file to https://rubygems.org[rubygems.org].