Sha256: f9bd74f3722b00eca0498c23eb04d828c6d8be2513dff0a37591809e0af34643
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require 'strava/api/v3' module Middleman module Strava class StravaExtension < ::Middleman::Extension option :access_token, '', 'The access token required to use the Strava API' cattr_accessor :client def initialize(app, options_hash={}, &block) super if (options_hash[:access_token].present?) options[:access_token] = options_hash[:access_token] end end def after_configuration StravaExtension.client = ::Strava::Api::V3::Client.new(:access_token => options[:access_token]) end helpers do def strava_athlete(athlete_id=nil) if (athlete_id.present?) StravaExtension.client.retrieve_another_athlete(athlete_id) else StravaExtension.client.retrieve_current_athlete end end def strava_activities(start, num_days=7) start_date = Date.parse(start) end_date = start_date + num_days StravaExtension.client.list_athlete_activities({:after => start_date.to_time.to_i, :before => end_date.to_time.to_i}).sort_by { |hash| hash['start_date'] } end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
middleman-strava-1.0.0 | lib/middleman-strava/extension.rb |