From 5be7f7b373ba4d4717b46e4d831c750ed990281b Mon Sep 17 00:00:00 2001 From: Kyle Tolle Date: Fri, 10 Apr 2015 14:09:01 -0600 Subject: [PATCH 1/6] Extract media versions module for video and audio --- lib/fulcrum.rb | 1 + lib/fulcrum/audio.rb | 10 ++-------- lib/fulcrum/media_versions.rb | 13 +++++++++++++ lib/fulcrum/video.rb | 10 ++-------- 4 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 lib/fulcrum/media_versions.rb diff --git a/lib/fulcrum.rb b/lib/fulcrum.rb index 4e2b941..d5e253f 100644 --- a/lib/fulcrum.rb +++ b/lib/fulcrum.rb @@ -13,6 +13,7 @@ require 'fulcrum/form' require 'fulcrum/membership' require 'fulcrum/photo' +require 'fulcrum/media_versions' require 'fulcrum/video' require 'fulcrum/audio' require 'fulcrum/signature' diff --git a/lib/fulcrum/audio.rb b/lib/fulcrum/audio.rb index 88a5b20..7e5b11f 100644 --- a/lib/fulcrum/audio.rb +++ b/lib/fulcrum/audio.rb @@ -1,5 +1,7 @@ module Fulcrum class Audio < MediaResource + include MediaVersions + def resources_name resource_name end @@ -12,14 +14,6 @@ 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 diff --git a/lib/fulcrum/media_versions.rb b/lib/fulcrum/media_versions.rb new file mode 100644 index 0000000..88a83ea --- /dev/null +++ b/lib/fulcrum/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/video.rb b/lib/fulcrum/video.rb index f326ae8..6fab756 100644 --- a/lib/fulcrum/video.rb +++ b/lib/fulcrum/video.rb @@ -1,5 +1,7 @@ module Fulcrum class Video < MediaResource + include MediaVersions + def default_content_type 'video/mp4' end @@ -8,14 +10,6 @@ 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 From 9ee4171d821e92c71273ef6e3fb56350c3512ebc Mon Sep 17 00:00:00 2001 From: Kyle Tolle Date: Fri, 10 Apr 2015 14:12:55 -0600 Subject: [PATCH 2/6] Extract gps track module video and audio --- lib/fulcrum.rb | 1 + lib/fulcrum/audio.rb | 5 +---- lib/fulcrum/gps_track.rb | 9 +++++++++ lib/fulcrum/video.rb | 5 +---- 4 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 lib/fulcrum/gps_track.rb diff --git a/lib/fulcrum.rb b/lib/fulcrum.rb index d5e253f..9db7161 100644 --- a/lib/fulcrum.rb +++ b/lib/fulcrum.rb @@ -14,6 +14,7 @@ require 'fulcrum/membership' require 'fulcrum/photo' require 'fulcrum/media_versions' +require 'fulcrum/gps_tracks' require 'fulcrum/video' require 'fulcrum/audio' require 'fulcrum/signature' diff --git a/lib/fulcrum/audio.rb b/lib/fulcrum/audio.rb index 7e5b11f..3e19bf6 100644 --- a/lib/fulcrum/audio.rb +++ b/lib/fulcrum/audio.rb @@ -1,6 +1,7 @@ module Fulcrum class Audio < MediaResource include MediaVersions + include GpsTrack def resources_name resource_name @@ -13,9 +14,5 @@ def default_content_type def create_action 'audio/upload' end - - def track(id) - call(:get, member_action(id, 'track')) - end end end diff --git a/lib/fulcrum/gps_track.rb b/lib/fulcrum/gps_track.rb new file mode 100644 index 0000000..5fbdcf8 --- /dev/null +++ b/lib/fulcrum/gps_track.rb @@ -0,0 +1,9 @@ +module Fulcrum + module GpsTrack + extend ActiveSupport::Concern + + 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 6fab756..fa6bbf3 100644 --- a/lib/fulcrum/video.rb +++ b/lib/fulcrum/video.rb @@ -1,6 +1,7 @@ module Fulcrum class Video < MediaResource include MediaVersions + include GpsTrack def default_content_type 'video/mp4' @@ -9,9 +10,5 @@ def default_content_type def create_action 'videos/upload' end - - def track(id) - call(:get, member_action(id, 'track')) - end end end From 9ab3a95a6730904e9708c20841b2ddd29ba9a689 Mon Sep 17 00:00:00 2001 From: Kyle Tolle Date: Fri, 10 Apr 2015 14:17:50 -0600 Subject: [PATCH 3/6] Use the correct module name --- lib/fulcrum.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/fulcrum.rb b/lib/fulcrum.rb index 9db7161..e804beb 100644 --- a/lib/fulcrum.rb +++ b/lib/fulcrum.rb @@ -14,7 +14,7 @@ require 'fulcrum/membership' require 'fulcrum/photo' require 'fulcrum/media_versions' -require 'fulcrum/gps_tracks' +require 'fulcrum/gps_track' require 'fulcrum/video' require 'fulcrum/audio' require 'fulcrum/signature' @@ -23,4 +23,5 @@ require 'fulcrum/layer' require 'fulcrum/changeset' require 'fulcrum/webhook' -require 'fulcrum/client' \ No newline at end of file +require 'fulcrum/client' + From 194a9304c2e47e2ea35e754ee4c40a13d4235d70 Mon Sep 17 00:00:00 2001 From: Kyle Tolle Date: Fri, 10 Apr 2015 14:31:53 -0600 Subject: [PATCH 4/6] Move media modules to actions dir --- lib/fulcrum.rb | 4 ++-- lib/fulcrum/{ => actions}/gps_track.rb | 0 lib/fulcrum/{ => actions}/media_versions.rb | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename lib/fulcrum/{ => actions}/gps_track.rb (100%) rename lib/fulcrum/{ => actions}/media_versions.rb (100%) diff --git a/lib/fulcrum.rb b/lib/fulcrum.rb index e804beb..8ecc787 100644 --- a/lib/fulcrum.rb +++ b/lib/fulcrum.rb @@ -13,8 +13,8 @@ require 'fulcrum/form' require 'fulcrum/membership' require 'fulcrum/photo' -require 'fulcrum/media_versions' -require 'fulcrum/gps_track' +require 'fulcrum/actions/media_versions' +require 'fulcrum/actions/gps_track' require 'fulcrum/video' require 'fulcrum/audio' require 'fulcrum/signature' diff --git a/lib/fulcrum/gps_track.rb b/lib/fulcrum/actions/gps_track.rb similarity index 100% rename from lib/fulcrum/gps_track.rb rename to lib/fulcrum/actions/gps_track.rb diff --git a/lib/fulcrum/media_versions.rb b/lib/fulcrum/actions/media_versions.rb similarity index 100% rename from lib/fulcrum/media_versions.rb rename to lib/fulcrum/actions/media_versions.rb From 81652003de2e1322154807f257bbc40203ec8019 Mon Sep 17 00:00:00 2001 From: Kyle Tolle Date: Fri, 10 Apr 2015 14:36:14 -0600 Subject: [PATCH 5/6] Add format parameter to #track For #11 --- lib/fulcrum/actions/gps_track.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fulcrum/actions/gps_track.rb b/lib/fulcrum/actions/gps_track.rb index 5fbdcf8..40c3546 100644 --- a/lib/fulcrum/actions/gps_track.rb +++ b/lib/fulcrum/actions/gps_track.rb @@ -2,8 +2,8 @@ module Fulcrum module GpsTrack extend ActiveSupport::Concern - def track(id) - call(:get, member_action(id, 'track')) + def track(id, format='json') + call(:get, member_action(id, 'track', format)) end end end From 933371ad2ec69b8a2290259232111b33ca5c9c19 Mon Sep 17 00:00:00 2001 From: Kyle Tolle Date: Fri, 10 Apr 2015 14:39:31 -0600 Subject: [PATCH 6/6] Update README for new #track parameter Fixes #11. --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 +