howcast 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/VERSION +1 -1
- data/howcast.gemspec +2 -3
- data/lib/howcast/client/homepage.rb +8 -2
- data/lib/howcast/client/playlist.rb +1 -1
- data/lib/howcast/client/user.rb +2 -18
- data/spec/howcast/client/homepage_spec.rb +2 -1
- data/spec/howcast/client/playlist_spec.rb +8 -0
- data/spec/howcast/client/user_spec.rb +21 -1
- data/spec/xml_fixtures_helper.rb +51 -11
- metadata +3 -4
- data/howcast-0.6.0.gem +0 -0
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.1
|
data/howcast.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{howcast}
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.1"
|
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"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-04-01}
|
13
13
|
s.description = %q{ Howcast offers an Application Programming Interface (API) which allows
|
14
14
|
developers to build applications that interface with Howcast. The Howcast
|
15
15
|
API is RESTful (REpresentational State Transfer) and users of this API will
|
@@ -31,7 +31,6 @@ Gem::Specification.new do |s|
|
|
31
31
|
"README.markdown",
|
32
32
|
"Rakefile",
|
33
33
|
"VERSION",
|
34
|
-
"howcast-0.6.0.gem",
|
35
34
|
"howcast.gemspec",
|
36
35
|
"lib/howcast.rb",
|
37
36
|
"lib/howcast/client.rb",
|
@@ -24,7 +24,7 @@
|
|
24
24
|
class Howcast::Client
|
25
25
|
class Homepage
|
26
26
|
extend WatchAttrAccessors
|
27
|
-
attr_accessor :videos
|
27
|
+
attr_accessor :videos, :playlists
|
28
28
|
|
29
29
|
# Creates a new Homepage object which is used to encapsulate all the attributes available
|
30
30
|
# from the Howcast homepage API.
|
@@ -60,6 +60,12 @@ class Howcast::Client
|
|
60
60
|
# Howcast::Client.new.homepage
|
61
61
|
def homepage
|
62
62
|
response = establish_connection("homepage/staff_videos.xml")
|
63
|
-
parse_single_xml(response, Homepage)
|
63
|
+
homepage = parse_single_xml(response, Homepage)
|
64
|
+
response = establish_connection("homepage/staff_playlists.xml")
|
65
|
+
homepage.playlists = parse_playlists(response)
|
64
66
|
end
|
67
|
+
|
68
|
+
private
|
69
|
+
def parse_playlists(xml)
|
70
|
+
end
|
65
71
|
end
|
@@ -24,7 +24,7 @@
|
|
24
24
|
class Howcast::Client
|
25
25
|
class Playlist
|
26
26
|
extend WatchAttrAccessors
|
27
|
-
attr_accessor :title, :videos
|
27
|
+
attr_accessor :title, :description, :playlist_thumbnail_url, :videos
|
28
28
|
|
29
29
|
# Creates a new Playlist object which is used to encapsulate all the attributes available
|
30
30
|
# from the Howcast playlist API.
|
data/lib/howcast/client/user.rb
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
class Howcast::Client
|
25
25
|
class User
|
26
26
|
extend WatchAttrAccessors
|
27
|
-
attr_accessor :login, :videos
|
27
|
+
attr_accessor :login, :firstname, :lastname, :thumbnail_url, :views, :count, :videos
|
28
28
|
|
29
29
|
# Creates a new User object which is used to encapsulate all the attributes available
|
30
30
|
# from the Howcast user profile API.
|
@@ -64,22 +64,6 @@ class Howcast::Client
|
|
64
64
|
# Howcast::Client.new.user('someone')
|
65
65
|
def user(login, options = {})
|
66
66
|
response = establish_connection("users/#{login}/profile/videos#{"/#{options[:page]}" if options[:page]}.xml")
|
67
|
-
|
67
|
+
parse_single_xml(response, User)
|
68
68
|
end
|
69
|
-
|
70
|
-
private
|
71
|
-
# Exception here to set the login vs. parsing it (not currently included in the api response)
|
72
|
-
def parse_single_user_xml(login, xml)
|
73
|
-
hash = {}
|
74
|
-
User.attr_accessors.each do |attribute|
|
75
|
-
node_name = attribute.to_s.gsub("_", "-") # xml schema uses hyphens for spaces, but ruby uses underscores
|
76
|
-
if node_name == "videos"
|
77
|
-
hash[attribute] = videos_for(xml) unless xml.at(node_name).nil?
|
78
|
-
else
|
79
|
-
hash[attribute] = !xml.at(node_name).nil? ? xml.at(node_name).inner_text.strip : ""
|
80
|
-
end
|
81
|
-
end
|
82
|
-
hash[:login] = login
|
83
|
-
hash.values.all?{|v| v==""} ? nil : User.new(hash)
|
84
|
-
end
|
85
69
|
end
|
@@ -17,13 +17,14 @@ describe Howcast::Client::Homepage, "initialize" do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
describe Howcast::Client, "
|
20
|
+
describe Howcast::Client, "homepage" do
|
21
21
|
before do
|
22
22
|
@hc = Howcast::Client.new(:key => "myapikey")
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should establish a connection with the correct homepage videos url" do
|
26
26
|
@hc.should_receive(:open).with(equivalent_uri("http://www.howcast.com/homepage/staff_videos.xml?api_key=myapikey")).and_return(homepage_videos_xml)
|
27
|
+
@hc.should_receive(:open).with(equivalent_uri("http://www.howcast.com/homepage/staff_playlists.xml?api_key=myapikey")).and_return(homepage_playlists_xml)
|
27
28
|
@hc.homepage
|
28
29
|
end
|
29
30
|
|
@@ -35,6 +35,14 @@ describe Howcast::Client, "playlist" do
|
|
35
35
|
@hc.playlist(12345).title.should == "Howcast - Eggs-Travaganza!"
|
36
36
|
end
|
37
37
|
|
38
|
+
it "should set the description attribute in the playlist model response" do
|
39
|
+
@hc.playlist(12345).description.should == "Become an eggs-pert! We can teach you how to test eggs for freshness, crack them, and hard-boil, poach, scramble, or fry them perfectly. We'll even let you in on a little trick for hard-boiling eggs so they peel easily."
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should set the thumbnail url in the playlist model response" do
|
43
|
+
@hc.playlist(12345).playlist_thumbnail_url.should == "http://img.howcast.com/thumbnails/1072/hpn_a011_perfect_scrambled_eggs_sd_medium.jpg"
|
44
|
+
end
|
45
|
+
|
38
46
|
it "should set the videos attribute in the playlist model response" do
|
39
47
|
videos = @hc.playlist(12345).videos
|
40
48
|
videos.size.should == 8
|
@@ -37,7 +37,27 @@ describe Howcast::Client, "user" do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should set the login attribute in the user model response" do
|
40
|
-
@hc.user('someone').login.should == "
|
40
|
+
@hc.user('someone').login.should == "mrmark86"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should set the first name attribute in the user model response" do
|
44
|
+
@hc.user('someone').firstname.should == "Mark"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should set the last name attribute in the user model response" do
|
48
|
+
@hc.user('someone').lastname.should == "Rogers"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should set the views attribute in the user model response" do
|
52
|
+
@hc.user('someone').views.should == "63"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should set the count attribute in the user model response" do
|
56
|
+
@hc.user('someone').count.should == "1"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should set the thumbnail url attribute in the user model response" do
|
60
|
+
@hc.user('someone').thumbnail_url.should == "http://img.howcast.com/images/icons/user-medium.gif"
|
41
61
|
end
|
42
62
|
|
43
63
|
it "should set the videos attribute in the user model response" do
|
data/spec/xml_fixtures_helper.rb
CHANGED
@@ -2491,13 +2491,18 @@ module XmlFixturesHelper
|
|
2491
2491
|
<?xml version="1.0" encoding="UTF-8"?>
|
2492
2492
|
<howcast version="0.1">
|
2493
2493
|
<title>Howcast - mrmark86's videos</title>
|
2494
|
+
<firstname>Mark</firstname>
|
2494
2495
|
<count>1</count>
|
2496
|
+
<lastname>Rogers</lastname>
|
2497
|
+
<login>mrmark86</login>
|
2498
|
+
<thumbnail-url>http://img.howcast.com/images/icons/user-medium.gif</thumbnail-url>
|
2499
|
+
<views>63</views>
|
2495
2500
|
<videos>
|
2496
2501
|
<video>
|
2497
2502
|
<category-id>1356</category-id>
|
2498
2503
|
<id>329098</id>
|
2499
2504
|
<title>How To Remove Bike Handlebar Grips</title>
|
2500
|
-
<views>
|
2505
|
+
<views>165</views>
|
2501
2506
|
<type>HowcastGuide</type>
|
2502
2507
|
<created-at>Sun, 14 Mar 2010 11:02:07 -0700</created-at>
|
2503
2508
|
<rating>0</rating>
|
@@ -2517,7 +2522,7 @@ module XmlFixturesHelper
|
|
2517
2522
|
<category parent_id="1353" id="1356">Biking Equipment</category>
|
2518
2523
|
</category-hierarchy>
|
2519
2524
|
<comment-count>0</comment-count>
|
2520
|
-
<thumbnail-url>http://img.howcast.com/
|
2525
|
+
<thumbnail-url>http://img.howcast.com/thumbnails/329098/RemoveBikeHandlebarGrips_xxlarge_maintained_aspect.png</thumbnail-url>
|
2521
2526
|
<permalink>http://www.howcast.com/videos/329098-How-To-Remove-Bike-Handlebar-Grips</permalink>
|
2522
2527
|
<content_rating>nonadult</content_rating>
|
2523
2528
|
</video>
|
@@ -2764,12 +2769,16 @@ module XmlFixturesHelper
|
|
2764
2769
|
<?xml version="1.0" encoding="UTF-8"?>
|
2765
2770
|
<howcast version="0.1">
|
2766
2771
|
<title>Howcast - Eggs-Travaganza!</title>
|
2772
|
+
<permalink>http://www.howcast.com/playlists/4566-EggsTravaganza</permalink>
|
2773
|
+
<description>Become an eggs-pert! We can teach you how to test eggs for freshness, crack them, and hard-boil, poach, scramble, or fry them perfectly. We'll even let you in on a little trick for hard-boiling eggs so they peel easily.</description>
|
2774
|
+
<playlist-thumbnail-url>http://img.howcast.com/thumbnails/1072/hpn_a011_perfect_scrambled_eggs_sd_medium.jpg</playlist-thumbnail-url>
|
2775
|
+
<id>4566</id>
|
2767
2776
|
<videos>
|
2768
2777
|
<video>
|
2769
2778
|
<category-id>392</category-id>
|
2770
2779
|
<id>21314</id>
|
2771
2780
|
<title>How To Separate an Egg</title>
|
2772
|
-
<views>
|
2781
|
+
<views>4808</views>
|
2773
2782
|
<type>HowcastGuide</type>
|
2774
2783
|
<created-at>Fri, 01 Aug 2008 17:00:40 -0700</created-at>
|
2775
2784
|
<rating>11</rating>
|
@@ -2796,7 +2805,7 @@ module XmlFixturesHelper
|
|
2796
2805
|
<category-id>392</category-id>
|
2797
2806
|
<id>191496</id>
|
2798
2807
|
<title>How To Test Eggs For Freshness</title>
|
2799
|
-
<views>
|
2808
|
+
<views>4920</views>
|
2800
2809
|
<type>HowcastGuide</type>
|
2801
2810
|
<created-at>Wed, 10 Jun 2009 07:47:21 -0700</created-at>
|
2802
2811
|
<rating>27</rating>
|
@@ -2823,7 +2832,7 @@ module XmlFixturesHelper
|
|
2823
2832
|
<category-id>392</category-id>
|
2824
2833
|
<id>282247</id>
|
2825
2834
|
<title>How To Crack an Egg</title>
|
2826
|
-
<views>
|
2835
|
+
<views>1565</views>
|
2827
2836
|
<type>HowcastGuide</type>
|
2828
2837
|
<created-at>Fri, 04 Dec 2009 09:16:18 -0800</created-at>
|
2829
2838
|
<rating>0</rating>
|
@@ -2850,7 +2859,7 @@ module XmlFixturesHelper
|
|
2850
2859
|
<category-id>382</category-id>
|
2851
2860
|
<id>258250</id>
|
2852
2861
|
<title>How To Hard-Boil an Egg</title>
|
2853
|
-
<views>
|
2862
|
+
<views>1013</views>
|
2854
2863
|
<type>HowcastGuide</type>
|
2855
2864
|
<created-at>Tue, 20 Oct 2009 15:17:37 -0700</created-at>
|
2856
2865
|
<rating>3</rating>
|
@@ -2877,7 +2886,7 @@ module XmlFixturesHelper
|
|
2877
2886
|
<category-id>382</category-id>
|
2878
2887
|
<id>29259</id>
|
2879
2888
|
<title>How To Poach an Egg</title>
|
2880
|
-
<views>
|
2889
|
+
<views>22398</views>
|
2881
2890
|
<type>HowcastGuide</type>
|
2882
2891
|
<created-at>Tue, 02 Sep 2008 10:03:03 -0700</created-at>
|
2883
2892
|
<rating>64</rating>
|
@@ -2904,10 +2913,10 @@ module XmlFixturesHelper
|
|
2904
2913
|
<category-id>382</category-id>
|
2905
2914
|
<id>2578</id>
|
2906
2915
|
<title>How To Hard-Boil an Egg So It Peels Easily</title>
|
2907
|
-
<views>
|
2916
|
+
<views>22406</views>
|
2908
2917
|
<type>HowcastGuide</type>
|
2909
2918
|
<created-at>Tue, 18 Mar 2008 11:08:10 -0700</created-at>
|
2910
|
-
<rating>
|
2919
|
+
<rating>33</rating>
|
2911
2920
|
<username>SheriffThompson</username>
|
2912
2921
|
<description>
|
2913
2922
|
<![CDATA[Have you ever thrown out a perfectly good hard-boiled egg because you got so frustrated trying to peel it? Here’s how to cook the perfectly-peelable egg. ]]>
|
@@ -2931,7 +2940,7 @@ module XmlFixturesHelper
|
|
2931
2940
|
<category-id>382</category-id>
|
2932
2941
|
<id>1072</id>
|
2933
2942
|
<title>How To Make Perfect Scrambled Eggs</title>
|
2934
|
-
<views>
|
2943
|
+
<views>19760</views>
|
2935
2944
|
<type>HowcastGuide</type>
|
2936
2945
|
<created-at>Tue, 05 Feb 2008 13:28:45 -0800</created-at>
|
2937
2946
|
<rating>23</rating>
|
@@ -2958,7 +2967,7 @@ module XmlFixturesHelper
|
|
2958
2967
|
<category-id>382</category-id>
|
2959
2968
|
<id>29262</id>
|
2960
2969
|
<title>How To Fry an Egg</title>
|
2961
|
-
<views>
|
2970
|
+
<views>25419</views>
|
2962
2971
|
<type>HowcastGuide</type>
|
2963
2972
|
<created-at>Tue, 02 Sep 2008 10:45:47 -0700</created-at>
|
2964
2973
|
<rating>32</rating>
|
@@ -2985,4 +2994,35 @@ module XmlFixturesHelper
|
|
2985
2994
|
</howcast>
|
2986
2995
|
PLAYLIST
|
2987
2996
|
end
|
2997
|
+
|
2998
|
+
def homepage_playlists_xml
|
2999
|
+
<<-PLAYLISTS
|
3000
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
3001
|
+
<howcast version="0.1">
|
3002
|
+
<title>Howcast - Staff Picks</title>
|
3003
|
+
<playlists>
|
3004
|
+
<playlist>
|
3005
|
+
<id>286</id>
|
3006
|
+
<title>Pranks For the Memories</title>
|
3007
|
+
<views>4260</views>
|
3008
|
+
<created-at>Tue, 06 May 2008 13:13:15 -0700</created-at>
|
3009
|
+
<videos-count>15</videos-count>
|
3010
|
+
<rating>1</rating>
|
3011
|
+
<permalink>http://www.howcast.com/playlists/286-Pull-Pranks-and-Fake-Out-Your-Friends</permalink>
|
3012
|
+
<thumbnail-url>http://img.howcast.com/thumbnails/2721/ppn_milkhouse_buried_cubicle_prank_sd_medium.jpg</thumbnail-url>
|
3013
|
+
</playlist>
|
3014
|
+
<playlist>
|
3015
|
+
<id>94</id>
|
3016
|
+
<title>Happy Easter!</title>
|
3017
|
+
<views>1776</views>
|
3018
|
+
<created-at>Tue, 18 Mar 2008 14:18:38 -0700</created-at>
|
3019
|
+
<videos-count>8</videos-count>
|
3020
|
+
<rating>6</rating>
|
3021
|
+
<permalink>http://www.howcast.com/playlists/94-Easter-Eggstravaganza</permalink>
|
3022
|
+
<thumbnail-url>http://img.howcast.com/thumbnails/2567/ppn_zeug_easter_eggs_sd_medium.jpg</thumbnail-url>
|
3023
|
+
</playlist>
|
3024
|
+
</playlists>
|
3025
|
+
</howcast>
|
3026
|
+
PLAYLISTS
|
3027
|
+
end
|
2988
3028
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 1
|
9
|
+
version: 0.7.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jingshen Jimmy Zhang
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-04-01 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -57,7 +57,6 @@ files:
|
|
57
57
|
- README.markdown
|
58
58
|
- Rakefile
|
59
59
|
- VERSION
|
60
|
-
- howcast-0.6.0.gem
|
61
60
|
- howcast.gemspec
|
62
61
|
- lib/howcast.rb
|
63
62
|
- lib/howcast/client.rb
|
data/howcast-0.6.0.gem
DELETED
Binary file
|