This is mechanized in the OrthogonalExpansions package which should be downloaded from http://www.maplesoft.com/applications/view.aspx?SID=33406 and installed in your Maple.

>with(OrthogonalExpansions); f := 2*x-2:

[BesselSeries, ChebyshevTSeries, ChebyshevUSeries, FourierSeries,

GegenbauerSeries, GramSchmidtL2, Haar, HaarSeries,

HarmonicWavelet, HarmonicWaveletSeries, HermiteSeries,

JacobiSeries, LaguerreSeries, LegendreSeries, MixedSeries,

Rational, RationalSeries, RectSeries, SincSeries, SincWavelet,

SincWaveletSeries, SphericalSeries, Walsh, WalshSeries,

Zernike, ZernikeSeries]

>FS := FourierSeries(f, x = 0 .. 1, series = cosine, 10);

>plot(FS, x = -2 .. 2);

>FS1 := FourierSeries(f, x = 0 .. 1, series = cosine, infinity);