howcast 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,6 +1,10 @@
1
+ == 0.7.2 2010-04-01
2
+
3
+ * Update homepage object per API changes
4
+
1
5
  == 0.7.1 2010-04-01
2
6
 
3
- * Add playlist and user objects per API changes
7
+ * Update playlist and user objects per API changes
4
8
 
5
9
  == 0.7.0 2010-03-19
6
10
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.2
Binary file
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{howcast}
8
- s.version = "0.7.1"
8
+ s.version = "0.7.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jingshen Jimmy Zhang", "Ian Smith-Heisters"]
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
31
31
  "README.markdown",
32
32
  "Rakefile",
33
33
  "VERSION",
34
+ "howcast-0.7.1.gem",
34
35
  "howcast.gemspec",
35
36
  "lib/howcast.rb",
36
37
  "lib/howcast/client.rb",
@@ -59,13 +59,18 @@ class Howcast::Client
59
59
  # Create the Howcast homepage object
60
60
  # Howcast::Client.new.homepage
61
61
  def homepage
62
- response = establish_connection("homepage/staff_videos.xml")
63
- homepage = parse_single_xml(response, Homepage)
64
- response = establish_connection("homepage/staff_playlists.xml")
65
- homepage.playlists = parse_playlists(response)
62
+ homepage = parse_single_xml(establish_connection("homepage/staff_videos.xml"), Homepage)
63
+ homepage.playlists = parse_playlists(establish_connection("homepage/staff_playlists.xml"))
64
+ homepage
66
65
  end
67
66
 
68
67
  private
69
68
  def parse_playlists(xml)
69
+ playlists = []
70
+ node = xml.at('playlists')
71
+ node.children_of_type('playlist').each do |child|
72
+ playlists << parse_single_xml(child, Playlist)
73
+ end unless node.nil?
74
+ playlists
70
75
  end
71
76
  end
@@ -39,7 +39,11 @@ class Howcast::Client
39
39
  # Playlist.new :title => "My Playlist"
40
40
  def initialize(attributes={})
41
41
  attributes.each do |k, v|
42
- self.send("#{k}=", v) if self.respond_to?(k)
42
+ if k == :title
43
+ self.send("#{k}=", v.gsub(/^Howcast - /, '')) if self.respond_to?(k)
44
+ else
45
+ self.send("#{k}=", v) if self.respond_to?(k)
46
+ end
43
47
  end
44
48
  end
45
49
  end
@@ -36,8 +36,18 @@ describe Howcast::Client, "homepage" do
36
36
  end
37
37
 
38
38
  it "should set the videos attribute in the homepage model response" do
39
+ @hc.should_receive(:open).with(equivalent_uri("http://www.howcast.com/homepage/staff_videos.xml?api_key=myapikey")).and_return(homepage_videos_xml)
40
+ @hc.should_receive(:open).with(equivalent_uri("http://www.howcast.com/homepage/staff_playlists.xml?api_key=myapikey")).and_return(homepage_playlists_xml)
39
41
  videos = @hc.homepage.videos
40
42
  videos.size.should == 8
41
43
  videos[0].title.should == "How To Display Impeccable Manners"
42
44
  end
45
+
46
+ it "should set the playlists attribute in the homepage model response" do
47
+ @hc.should_receive(:open).with(equivalent_uri("http://www.howcast.com/homepage/staff_videos.xml?api_key=myapikey")).and_return(homepage_videos_xml)
48
+ @hc.should_receive(:open).with(equivalent_uri("http://www.howcast.com/homepage/staff_playlists.xml?api_key=myapikey")).and_return(homepage_playlists_xml)
49
+ playlists = @hc.homepage.playlists
50
+ playlists.size.should == 2
51
+ playlists[0].title.should == "Pranks For the Memories"
52
+ end
43
53
  end
@@ -32,7 +32,7 @@ describe Howcast::Client, "playlist" do
32
32
  end
33
33
 
34
34
  it "should set the title attribute in the playlist model response" do
35
- @hc.playlist(12345).title.should == "Howcast - Eggs-Travaganza!"
35
+ @hc.playlist(12345).title.should == "Eggs-Travaganza!"
36
36
  end
37
37
 
38
38
  it "should set the description attribute in the playlist model response" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 1
9
- version: 0.7.1
8
+ - 2
9
+ version: 0.7.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jingshen Jimmy Zhang
@@ -57,6 +57,7 @@ files:
57
57
  - README.markdown
58
58
  - Rakefile
59
59
  - VERSION
60
+ - howcast-0.7.1.gem
60
61
  - howcast.gemspec
61
62
  - lib/howcast.rb
62
63
  - lib/howcast/client.rb