diff --git a/README.md b/README.md index edfc57c..edd7285 100644 --- a/README.md +++ b/README.md @@ -230,10 +230,12 @@ Downloads the small version and yields an IO object to the block. Downloads the medium version and yields an IO object to the block. -### client.videos.track(id) +### client.videos.track(id, format='json') Fetches the GPS track for the specified video. +Format can be 'json', 'geojson', 'gpx', or 'kml'. + ## Audio @@ -261,10 +263,12 @@ Downloads the small version and yields an IO object to the block. Downloads the medium version and yields an IO object to the block. -### client.audio.track(id) +### client.audio.track(id, format='json') Fetches the GPS track for the specified audio. +Format can be 'json', 'geojson', 'gpx', or 'kml'. + ## Memberships @@ -312,3 +316,4 @@ Fetches the GPS track for the specified audio. 3. Commit your changes (`git commit -am 'Added some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request + diff --git a/lib/fulcrum.rb b/lib/fulcrum.rb index 4e2b941..8ecc787 100644 --- a/lib/fulcrum.rb +++ b/lib/fulcrum.rb @@ -13,6 +13,8 @@ require 'fulcrum/form' require 'fulcrum/membership' require 'fulcrum/photo' +require 'fulcrum/actions/media_versions' +require 'fulcrum/actions/gps_track' require 'fulcrum/video' require 'fulcrum/audio' require 'fulcrum/signature' @@ -21,4 +23,5 @@ require 'fulcrum/layer' require 'fulcrum/changeset' require 'fulcrum/webhook' -require 'fulcrum/client' \ No newline at end of file +require 'fulcrum/client' + diff --git a/lib/fulcrum/actions/gps_track.rb b/lib/fulcrum/actions/gps_track.rb new file mode 100644 index 0000000..40c3546 --- /dev/null +++ b/lib/fulcrum/actions/gps_track.rb @@ -0,0 +1,9 @@ +module Fulcrum + module GpsTrack + extend ActiveSupport::Concern + + def track(id, format='json') + call(:get, member_action(id, 'track', format)) + end + end +end diff --git a/lib/fulcrum/actions/media_versions.rb b/lib/fulcrum/actions/media_versions.rb new file mode 100644 index 0000000..88a83ea --- /dev/null +++ b/lib/fulcrum/actions/media_versions.rb @@ -0,0 +1,13 @@ +module Fulcrum + module MediaVersions + extend ActiveSupport::Concern + + def small(id, &blk) + download_version(id, 'small', &blk) + end + + def medium(id, &blk) + download_version(id, 'medium', &blk) + end + end +end diff --git a/lib/fulcrum/audio.rb b/lib/fulcrum/audio.rb index 88a5b20..3e19bf6 100644 --- a/lib/fulcrum/audio.rb +++ b/lib/fulcrum/audio.rb @@ -1,5 +1,8 @@ module Fulcrum class Audio < MediaResource + include MediaVersions + include GpsTrack + def resources_name resource_name end @@ -11,17 +14,5 @@ def default_content_type def create_action 'audio/upload' end - - def small(id, &blk) - download_version(id, 'small', &blk) - end - - def medium(id, &blk) - download_version(id, 'medium', &blk) - end - - def track(id) - call(:get, member_action(id, 'track')) - end end end diff --git a/lib/fulcrum/video.rb b/lib/fulcrum/video.rb index f326ae8..fa6bbf3 100644 --- a/lib/fulcrum/video.rb +++ b/lib/fulcrum/video.rb @@ -1,5 +1,8 @@ module Fulcrum class Video < MediaResource + include MediaVersions + include GpsTrack + def default_content_type 'video/mp4' end @@ -7,17 +10,5 @@ def default_content_type def create_action 'videos/upload' end - - def small(id, &blk) - download_version(id, 'small', &blk) - end - - def medium(id, &blk) - download_version(id, 'medium', &blk) - end - - def track(id) - call(:get, member_action(id, 'track')) - end end end