It's not entirely clear (to me) what you mean by "applying an angular velocity". Angular velocity is an instantaneous property; if you only have a single angular velocity vector, you only have the first derivative of the motion at one point in time, and thus can't say anything about the orientation at other times.
I'll assume that you're assuming the angular velocity to be constant, and that by "applying" it you mean calculating the orientation at later times of a body that has the given initial orientation and undergoes a motion with the given constant angular velocity.
To do this, you need to know a) how to find the unit quaternion corresponding to a rotation vector and b) how to compose two unit quaternions in order get the unit quaternion corresponding to the composition of the corresponding rotations.
For a), let's denote the angular velocity vector by $\vec{\omega}$. Over a time $t$, a motion with this (constant) angular velocity results in a rotation that can be described by the vector $\vec{w}=\vec{\omega}t$, where the direction and magnitude of $\vec{w}$ specify the axis and angle of the rotation, respectively. This rotation corresponds to the unit quaternion
$$q=\left(\cos\frac{|\vec{w}|}{2},\frac{\vec{w}}{|\vec{w}|}\sin\frac{|\vec{w}|}{2}\right)\;.$$
For b), since applying the rotation corresponding to a unit quaternion $q$ to a three-dimensional vector $\vec{v}$ consists in conjugating a quaternion $\nu$ corresponding to $\vec{v}$ by $q$, composing rotations just corresponds to multiplying the corresponding quaternions:
$$q(\vec{v})=q\nu q^{-1}\;,$$
$$q_1(q_2(\vec{v}))=q_1(q_2\nu q_2^{-1})=q_1q_2\nu q_2^{-1} q_1^{-1}=(q_1q_2)(\vec{v})\;.$$
(This is part of what makes quaternions so useful for representing three-dimensional rotations). So now you just multiply $q$ and your initial unit quaternion, say, $q_0$. Since the initial rotation is applied first, the corresponding unit quaternion is on the inside of the nested conjugations, so it has to be the right-hand factor: $q'=qq_0$.
For more on all this, see this Wikipedia article.
After a lot of searching, I have finally found a reference that has what I needed. Although it doesn't appear in a 'Quaternion to Euler' or 'Quaternion to Tait-Bryan' google search, when I gave up and started looking for 'Quaternion to Axis-Angle' with the intention of going through that representation as an intermediate step, I came across the following wonderful document:
Technical Concepts
Orientation, Rotation, Velocity and Acceleration,
and the SRM
Version 2.0, 20 June 2008
Author: Paul Berner, PhD
Contributors: Ralph Toms, PhD, Kevin Trott, Farid Mamaghani, David Shen,
Craig Rollins, Edward Powell, PhD
http://www.sedris.org/wg8home/Documents/WG80485.pdf
It covers a lot of the formalisms, but most importantly, shows derivations and solutions for 3-1-3 and 3-2-1 Euler angle representation. It also seems to cover inter-conversion between pretty much every other rotation representation I'm aware of, and so I would also recommend it as a good general reference.
Oh, and the actual solution for a 3-2-1 ($z-y-x$) Tait-Bryan rotation convention from that reference:
$$
\phi = \operatorname{arctan2}\left(q_2 q_3 + q_0 q_1,\frac{1}{2}-(q_1^2 + q_2^2)\right) \\
\theta = \arcsin(-2(q_1 q_3 - q_0 q_2)) \\
\psi = \operatorname{arctan2}\left(q_1 q_2 + q_0 q_3,\frac{1}{2}-(q_2^2 + q_3^2)\right)
$$
Note that the gimbal-lock situation occurs when $2(q_1 q_3 + q_0 q_2) = \pm1$ (which gives a $\theta$ of $\pm \frac{\pi}{2} $), so it can be clearly identified before you attempt to evaluate $\phi$ and $\psi$.
(Convention for arctan2 is $\operatorname{arctan2}(y, x)$, as hinted on page 3.)
Best Answer
You can use the procedure used in Android devices: http://developer.android.com/guide/topics/sensors/sensors_motion.html#sensors-motion-gyro