Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Library for manipulating the WURFL using ruby
Ruby
Branch: master
Pull request Compare This branch is 2 commits ahead, 5 commits behind mobalean:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
lib/wurfl
test
.gitignore
Examples.txt
LICENSE
README.rdoc
Rakefile
VERSION
wurfl.gemspec

README.rdoc

WURFL

WURFL is a collection of libraries and command line tools for using and manipulating the WURFL. To start using it, simply install the gem:

sudo gem install wurfl

Tools

All tools are run via wurfltools.rb

loader

Is used to parse and load a WURFL XML file into memory or save a PStore database that is used by most of the other tools. This application creates WURFL PStore databases that are essential for use with the other Ruby applications.

inspector

Is a tool that will let you do various searches and queries on the WURFL. This is a very simple, yet powerful program for finding information about the handsets in the WURFL. See the wurflinspector examples section for usage.

Usage

The command below will search through all handsets and return the ids of handsets that match the passed Ruby boolean evaluation

This command will return all handsets that have more than 2 colors.

wurfltools.rb inspector -d pstorehandsets.db -s '{ |hand| hand["colors"].to_i > 2 }'"

The Ruby query must go in between the single quote marks and needs to declare the WurflHandset instance variable name.

This command shows you how you can cheat with the current design of the wurflinspector and print more user friendly results. This example assumes you have the command line programs sort and uniq, but that is only to make the output look better. This example does the same as the above, except that it prints out the brand name and model name of the matching handsets instead of the WURFL id.

Note: this should all go into one command line call

wurfltools.rb inspector -d pstorehandsets.db -s '{|hand| puts
"#{hand["brand_name"]} #{hand["model_name"]}" if hand["colors"].to_i >
2}' | sort | uniq"

The following individual handset query commands will tell the value of capabilities and from where it obtained the setting.

A command to query the handset with the id sonyericsson_t300_ver1 for all of its' capabilities:

wurfltools.rb inspector -d pstorehandsets.db -i sonyericsson_t300_ver1

A command to query the handset with the id sonyericsson_t300_ver1 for backlight capability:

wurfltools.rb inspector -d pstorehandsets.db -i sonyericsson_t300_ver1 -q
backlight

uamatch

Is a tool that will let you do various searches and queries on the WURFL based on user-agent strings. This is a very simple, yet powerful program for finding information about the handsets in the WURFL. See the uamatch examples section for usage.

The uamatcher will retrieve the handset descriptions with the closest Levenshtein distance (also called the edit distance) to the user-agent string you pass as argument.

For details see: en.wikipedia.org/wiki/Levenshtein_distance

When more than one handset has the same distance to the user agent string queried, the command will iterate over the result set and print the result for each handset.

The found wurfl_ids can serve as input to the inspector command. You can also specifically query for a certain capability.

Usage

The following individual handset query commands will tell the value of capabilities and from where it obtained the setting.

A command to query the handset with the user-agent SL55 for all of its capabilities:

wurfltools.rb uamatch -d pstorehandsets.db -u SL55

A command to query the handset with the id SL55 for the wallpaper_jpg capability:

wurfltools.rb uamatch -d pstorehandsets.db -u SL55 -q wallpaper_jpg

sanitycheck

Is a partial WURFL validating program. It does a few simple checks to make sure the XML structure is parse-able by the wurflloader. If you receive loading errors by the wurflloader, then you can run the wurflsanitycheck program to find the lines in the XML file that might be causing the problem.

comparator

Is a another simple program that will find the differences from two WURFL Ruby PStore databases. This is another way of finding changes from the different versions of the WURFL without running a diff on the XML files.

uaproftowurfl

Is a program that takes UAProfiles and creates an equivalent WURFL entry. It holds all of the mappings used to convert a UAProfile to a WURFL entry. This program alone makes using the Ruby tools worth it.

The mappings are not fully complete and can certainly use your input in improving them.

About the source code: The main piece of code to read are the methods under the “UAProfile Mappings” comment.

For now you can ignore the details above this comment. Basically each method is the name of a UAProfifle component. When you parse a UAProfile file it will call each UAProfile component's method name.

So you can simply look at UAProfile component's method to see how it maps to the WURFL. If a component is not found as a method it will be logged to Standard Error. For this log one can then add the method to the UAProfToWurfl class later.

Usage

A simple usage is:

wurfltools.rb uaproftowurfl sampleprofile.xml

Example use from a bash shell with many profiles:

for i in `ls profiles`; do 
  wurfltools.rb uaproftowurfl profiles/$i >output/$i.wurfl 
  2> output/$i.parser.err; 
done

This assumes that you have a profiles directory with all of the UAProf file you wish to parse and a output directory to place the results and errors.

Authors

  • Zev Blut (Original Author)

  • Paul McMahon (gem installer, refactorings)

  • Kai W. Zimmermann (uamatch)

Contribution

All contribution is welcome. Please see the repo at github.com/pwim/wurfl.

License

See LICENSE

Copyright

Copyright © 2009, mobalean (www.mobalean.com/)

Copyright © 2003, Ubiquitous Business Technology (ubit.com) All rights reserved.

Send enquiries to: info@mobalean.com

Something went wrong with that request. Please try again.