mediaplug2-ruby 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -1
- data/lib/mediaplug/mediaplug.rb +8 -4
- data/lib/mediaplug/mediaplug_url.rb +7 -2
- metadata +20 -5
data/CHANGELOG.rdoc
CHANGED
data/lib/mediaplug/mediaplug.rb
CHANGED
@@ -1,24 +1,28 @@
|
|
1
|
+
require 'bitly'
|
1
2
|
class MediaPlug
|
2
3
|
class InvalidAction < StandardError; end
|
4
|
+
class BitLyCredsMissing < StandardError; end
|
3
5
|
attr_accessor :server
|
4
6
|
|
5
7
|
# Server is the domain of the MediaPlug server, e.g. "mp.yourdomain.com"
|
6
|
-
def initialize(server)
|
8
|
+
def initialize(server, bitly_login = nil, bitly_key = nil)
|
7
9
|
self.server = server
|
10
|
+
@bitly = Bitly.new(bitly_login, bitly_key) if bitly_login && bitly_key
|
8
11
|
end
|
9
12
|
|
10
13
|
# Generates an image-formatted MediaPlugURL from the specified URL
|
11
14
|
def image(url, format='jpg')
|
12
|
-
MediaPlugURL.new(server,:image,url,format)
|
15
|
+
MediaPlugURL.new(server,:image,url,format, @bitly)
|
13
16
|
end
|
14
17
|
|
15
18
|
# Generates a video-formatted MediaPlugURL from the specified URL
|
16
19
|
def video(url, format='flv')
|
17
|
-
MediaPlugURL.new(server,:video,url,format)
|
20
|
+
MediaPlugURL.new(server,:video,url,format, @bitly)
|
18
21
|
end
|
19
22
|
|
20
23
|
# Generates an audio-formatted MediaPlugURL from the specified URL
|
21
24
|
def audio(url, format='mp3')
|
22
|
-
MediaPlugURL.new(server,:audio,url,format)
|
25
|
+
MediaPlugURL.new(server,:audio,url,format, @bitly)
|
23
26
|
end
|
27
|
+
|
24
28
|
end
|
@@ -3,14 +3,19 @@
|
|
3
3
|
# by using its to_s method. It should be instantiated through
|
4
4
|
# the MediaPlug class, not by itself:
|
5
5
|
class MediaPlugURL
|
6
|
-
def initialize(server, media_type, url, format)
|
6
|
+
def initialize(server, media_type, url, format, bitly)
|
7
7
|
@server = server
|
8
8
|
@media_type = media_type
|
9
9
|
@url = url
|
10
10
|
@format = format
|
11
|
+
@bitly = bitly
|
11
12
|
@actions = []
|
12
13
|
end
|
13
|
-
|
14
|
+
def shorten
|
15
|
+
raise MediaPlug::BitLyCredsMissing if @bitly.blank?
|
16
|
+
@bitly.shorten(self.to_s).short_url
|
17
|
+
end
|
18
|
+
|
14
19
|
# <b>Image Only:</b> Resize an image to the dimensions specified. The
|
15
20
|
# dimensions may be specified as a string, a Hash, or an Array.
|
16
21
|
#
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mediaplug2-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Bleigh
|
@@ -18,8 +18,23 @@ cert_chain: []
|
|
18
18
|
|
19
19
|
date: 2011-03-23 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
|
-
dependencies:
|
22
|
-
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: bitly
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 5
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
- 6
|
34
|
+
- 1
|
35
|
+
version: 0.6.1
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
23
38
|
description: A wrapper for the MediaPlug 2 API to give a simple syntax for MediaPlug URL generation.
|
24
39
|
email: ping@intridea.com
|
25
40
|
executables: []
|