streamio 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.5.1 2011-06-16
2
+
3
+ * Added lots of (YARD style) documentation and updated README
4
+
1
5
  == 0.5.0 2011-06-15
2
6
 
3
7
  * Basic api functionality for Videos, Images and Encoding Profiles
data/README.rdoc CHANGED
@@ -32,4 +32,19 @@ Use it.
32
32
  # Find a video by id
33
33
  video = Streamio::Video.find("4c57f3975412901427000005")
34
34
 
35
+ # Create a video
36
+ video = Streamio::Video.new
37
+ video.save # false
38
+ video.errors # {:file => ["can't be blank"]}
39
+ video.file = File.new("my_awesome_video.mov")
40
+ video.save # true
41
+
35
42
  Same principles work for the other availible models (Streamio::Image and Streamio::EncodingProfile).
43
+
44
+ == More Documentation
45
+
46
+ YARDoc is avaible here:
47
+ http://rubydoc.info/gems/streamio
48
+
49
+ Please refer to the official Streamio API Documentation for details on parameters etc:
50
+ http://streamio.com/api/docs
data/lib/streamio.rb CHANGED
@@ -15,6 +15,14 @@ module Streamio
15
15
  attr_accessor :use_ssl
16
16
  attr_accessor :host
17
17
 
18
+ # The idiomatic configure block for the Streamio gem. Basically a shortcut
19
+ # for the Streamio module attributes.
20
+ #
21
+ # @example Configure your API username and password.
22
+ # Streamio.configure do |config|
23
+ # config.username = "my_awesome_account"
24
+ # config.password = "3633b4a027d74ead0038addff89550"
25
+ # end
18
26
  def configure
19
27
  yield self
20
28
  end
@@ -1,10 +1,22 @@
1
1
  module Streamio
2
2
  class Model
3
3
  class << self
4
+ # Gets a model by its id.
5
+ #
6
+ # @param [String] id The models id.
7
+ #
8
+ # @return [Model] The found model.
4
9
  def find(id)
5
10
  parse_response(resource["#{id}"].get)
6
11
  end
7
12
 
13
+ # Querys for a list of models.
14
+ #
15
+ # @param [Hash] parameters The parameters will determine the conditions
16
+ # for the query. Refer to Streamio API reference for a list of valid
17
+ # parameters for each of the different models availible.
18
+ #
19
+ # @return [Array] Array of found models.
8
20
  def all(parameters = {})
9
21
  sanitize_parameters(parameters)
10
22
  parse_response(resource.get(:params => parameters))
@@ -30,9 +42,14 @@ module Streamio
30
42
  end
31
43
 
32
44
  CASTED_ATTRIBUTES = %w(tags created_at updated_at)
33
-
34
- attr_reader :attributes, :errors
35
-
45
+
46
+ # A Hash resulting from parsing the JSON returned from Streamios API.
47
+ attr_reader :attributes
48
+
49
+ # A Hash containing validation errors after a failed +save+.
50
+ attr_reader :errors
51
+
52
+ # @param [Hash] attributes The attributes you wish to apply to the new Model instance.
36
53
  def initialize(attributes = {})
37
54
  @errors = {}
38
55
  @attributes = attributes.inject(Hash.new) do |options, (key, value)|
@@ -40,7 +57,16 @@ module Streamio
40
57
  options
41
58
  end
42
59
  end
43
-
60
+
61
+ # Saves the model.
62
+ #
63
+ # If the model is new a record gets created, otherwise the existing record
64
+ # gets updated.
65
+ #
66
+ # If +save+ fails it might be due to validation errors so you might want
67
+ # to check the models +errors+.
68
+ #
69
+ # @return [Boolean] Indicating if the save / update was successful.
44
70
  def save
45
71
  if persisted?
46
72
  update
@@ -51,31 +77,40 @@ module Streamio
51
77
  @errors = JSON.parse(e.response)
52
78
  false
53
79
  end
54
-
80
+
81
+ # Deletes the record and freezes this instance to reflect that no changes
82
+ # should be made (since they can't be persisted).
83
+ #
84
+ # @return [Boolean] True if the record was deleted.
55
85
  def destroy
56
86
  self.class.resource[id].delete
57
87
  @attributes.freeze
58
88
  true
59
89
  end
60
-
90
+
91
+ # @return [Boolean] True if the record is persisted.
61
92
  def persisted?
62
93
  !destroyed? && !id.nil?
63
94
  end
64
-
95
+
96
+ # @return [Boolean] True if you destroyed this record.
65
97
  def destroyed?
66
98
  @attributes.frozen?
67
99
  end
68
-
100
+
101
+ # @return [Array] Array of tags applied to the record.
69
102
  def tags
70
103
  @attributes["tags"] = [] if @attributes["tags"].nil?
71
104
  @attributes["tags"]
72
105
  end
73
-
106
+
107
+ # @return [Time] When the record was created.
74
108
  def created_at
75
109
  return nil unless @attributes["created_at"]
76
110
  Time.parse(@attributes["created_at"])
77
111
  end
78
-
112
+
113
+ # @return [Time] When the record was last updated.
79
114
  def updated_at
80
115
  return nil unless @attributes["updated_at"]
81
116
  Time.parse(@attributes["updated_at"])
@@ -1,3 +1,3 @@
1
1
  module Streamio
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -20,13 +20,25 @@ module Streamio
20
20
  end
21
21
  end
22
22
 
23
- def add_transcoding(parameters = {})
23
+ # Adds a transcoding to the video instance.
24
+ #
25
+ # @param [Hash] parameters The parameters to pass in when creating the transcoding.
26
+ #
27
+ # @option parameters [String] :encoding_profile_id Id of the Encoding Profile to be used for the transcoding.
28
+ #
29
+ # @return [Boolean] Indicating wether the transcoding was successfully created.
30
+ def add_transcoding(parameters)
24
31
  self.class.resource["#{id}/transcodings"].post(parameters)
25
32
  true
26
33
  rescue RestClient::Exception
27
34
  false
28
35
  end
29
36
 
37
+ # Deletes a transcoding from the video.
38
+ #
39
+ # @param [String] transcoding_id The id of the transcoding to be deleted.
40
+ #
41
+ # @return [Boolean] Indicating wether the transcoding was successfully deleted.
30
42
  def delete_transcoding(transcoding_id)
31
43
  self.class.resource["#{id}/transcodings/#{transcoding_id}"].delete
32
44
  true
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: streamio
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.0
5
+ version: 0.5.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - David Backeus
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-15 00:00:00 Z
13
+ date: 2011-06-16 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -108,3 +108,4 @@ specification_version: 3
108
108
  summary: Ruby wrapper for the Streamio api.
109
109
  test_files: []
110
110
 
111
+ has_rdoc: