cameraplus 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.gitignore +9 -0
  2. data/.rvmrc +55 -0
  3. data/Gemfile +3 -0
  4. data/LICENSE +22 -0
  5. data/README.md +227 -0
  6. data/Rakefile +2 -0
  7. data/cameraplus.gemspec +25 -0
  8. data/lib/cameraplus.rb +18 -0
  9. data/lib/cameraplus/api/page.rb +17 -0
  10. data/lib/cameraplus/api/request.rb +45 -0
  11. data/lib/cameraplus/api/search.rb +25 -0
  12. data/lib/cameraplus/api/user.rb +17 -0
  13. data/lib/cameraplus/comment.rb +14 -0
  14. data/lib/cameraplus/exceptions.rb +7 -0
  15. data/lib/cameraplus/page.rb +34 -0
  16. data/lib/cameraplus/page_metadata.rb +73 -0
  17. data/lib/cameraplus/photo.rb +49 -0
  18. data/lib/cameraplus/photo_exif.rb +13 -0
  19. data/lib/cameraplus/photo_recipe.rb +12 -0
  20. data/lib/cameraplus/search.rb +45 -0
  21. data/lib/cameraplus/user.rb +72 -0
  22. data/lib/cameraplus/version.rb +3 -0
  23. data/lib/core_ext/hash.rb +13 -0
  24. data/spec/cameraplus/api/page_spec.rb +17 -0
  25. data/spec/cameraplus/api/request_spec.rb +47 -0
  26. data/spec/cameraplus/api/search_spec.rb +37 -0
  27. data/spec/cameraplus/api/user_spec.rb +17 -0
  28. data/spec/cameraplus/comment_spec.rb +32 -0
  29. data/spec/cameraplus/page_metadata_spec.rb +117 -0
  30. data/spec/cameraplus/page_spec.rb +84 -0
  31. data/spec/cameraplus/photo_exif_spec.rb +23 -0
  32. data/spec/cameraplus/photo_recipe_spec.rb +19 -0
  33. data/spec/cameraplus/photo_spec.rb +82 -0
  34. data/spec/cameraplus/search_spec.rb +51 -0
  35. data/spec/cameraplus/user_spec.rb +82 -0
  36. data/spec/core_ext/hash_spec.rb +53 -0
  37. data/spec/spec_helper.rb +6 -0
  38. data/spec/vcr_cassettes/api_request_invalid.yml +56 -0
  39. data/spec/vcr_cassettes/api_request_valid.yml +78 -0
  40. data/spec/vcr_cassettes/more_results.yml +369 -0
  41. data/spec/vcr_cassettes/page.yml +58 -0
  42. data/spec/vcr_cassettes/search.yml +55 -0
  43. data/spec/vcr_cassettes/user.yml +78 -0
  44. data/spec/vcr_config.rb +7 -0
  45. metadata +177 -0
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe Cameraplus::API::User do
4
+
5
+ use_vcr_cassette :user
6
+
7
+ it "should receive a hash" do
8
+ response = Cameraplus::API::User.find "mostlylisa"
9
+ response.should be_a Hash
10
+ end
11
+
12
+ it "should make a request to the Camera+ API" do
13
+ Cameraplus::API::Request.should_receive(:call).with "/user/mostlylisa:pages", {}
14
+ Cameraplus::API::User.find "mostlylisa"
15
+ end
16
+
17
+ end
@@ -0,0 +1,32 @@
1
+ require "spec_helper"
2
+
3
+ describe Cameraplus::Comment do
4
+
5
+ let(:data) do
6
+ {
7
+ author: "Lisa Bettany",
8
+ avatar: "https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-snc4\/261022_674215636_4030749_q.jpg",
9
+ url: "http:\/\/www.facebook.com\/profile.php?id=674215636",
10
+ text: "great shot!"
11
+ }
12
+ end
13
+
14
+ subject { Cameraplus::Comment.new data }
15
+
16
+ it "has an author" do
17
+ subject.author.should eq "Lisa Bettany"
18
+ end
19
+
20
+ it "has an avatar" do
21
+ subject.avatar.should eq "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/261022_674215636_4030749_q.jpg"
22
+ end
23
+
24
+ it "has an url" do
25
+ subject.url.should eq "http://www.facebook.com/profile.php?id=674215636"
26
+ end
27
+
28
+ it "has text" do
29
+ subject.text.should eq "great shot!"
30
+ end
31
+
32
+ end
@@ -0,0 +1,117 @@
1
+ require "spec_helper"
2
+
3
+ describe Cameraplus::PageMetadata do
4
+
5
+ use_vcr_cassette :page
6
+
7
+ subject { Cameraplus::PageMetadata.find "b72Z" }
8
+
9
+ it "should be a Page" do
10
+ subject.should be_a Cameraplus::PageMetadata
11
+ end
12
+
13
+ context ".find" do
14
+
15
+ it "finds the url of the specified page" do
16
+ subject.url.should eq "http://camerapl.us/b72Z"
17
+ end
18
+
19
+ it "finds the created at datetime of the specified page" do
20
+ subject.created_at.should eq DateTime.parse("2011-07-01 21:50:40")
21
+ end
22
+
23
+ it "finds the location of the specified page" do
24
+ subject.location.should eq "42.574017 18.641312"
25
+ end
26
+
27
+ it "finds the location name of the specified page" do
28
+ subject.location_name.should eq "Kotor, Montenegro"
29
+ end
30
+
31
+ it "finds the tweet text of the specified page" do
32
+ subject.tweet_text.should eq "Tiny Town of Kotor, Montenegro #mybestphoto"
33
+ end
34
+
35
+ it "finds the tweet id of the specified page" do
36
+ subject.tweet_id.should eq 86914646237384704
37
+ end
38
+
39
+ it "finds the view count of the specified page" do
40
+ subject.view_count.should eq 925
41
+ end
42
+
43
+ it "finds the comment count of the specified page" do
44
+ subject.comment_count.should eq 6
45
+ end
46
+
47
+ end
48
+
49
+ context "#user" do
50
+
51
+ it "should be a User" do
52
+ subject.user.should be_a Cameraplus::User
53
+ end
54
+
55
+ it "has an username" do
56
+ subject.user.username.should eq "lucyk"
57
+ end
58
+
59
+ it "has a name" do
60
+ subject.user.name.should eq "Oleg Lutsenko"
61
+ end
62
+
63
+ end
64
+
65
+ context "#photos" do
66
+
67
+ it "should be an Array" do
68
+ subject.photos.should be_an Array
69
+ end
70
+
71
+ it "should contain a Cameraplus::Photo" do
72
+ subject.photos.first.should be_a Cameraplus::Photo
73
+ end
74
+
75
+ context "with a Cameraplus::Photo" do
76
+
77
+ it "should have recipes" do
78
+ subject.photos.first.recipes.should be_an Array
79
+ end
80
+
81
+ it "should contain a Cameraplus::PhotoRecipe" do
82
+ subject.photos.first.recipes.first.should be_a Cameraplus::PhotoRecipe
83
+ end
84
+
85
+ it "should have exif data" do
86
+ subject.photos.last.exif.should be_an Array
87
+ end
88
+
89
+ it "should contain a Cameraplus::PhotoExif" do
90
+ subject.photos.first.exif.first.should be_a Cameraplus::PhotoExif
91
+ end
92
+
93
+ end
94
+
95
+ end
96
+
97
+ context "#comments" do
98
+
99
+ it "should be an Array" do
100
+ subject.comments.should be_an Array
101
+ end
102
+
103
+ it "should contain a Cameraplus::Comment" do
104
+ subject.comments.first.should be_a Cameraplus::Comment
105
+ end
106
+
107
+ it "should know the number of comments" do
108
+ subject.comments.size.should eq 6
109
+ end
110
+
111
+ it "should know the authors of the comments" do
112
+ subject.comments.map(&:author).should eq ["Lisa Bettany", "Oleg Lutsenko", "Oliver Penack", "John Goundry \u2714", "Jason Hansen", "Jonathan Feuer"]
113
+ end
114
+
115
+ end
116
+
117
+ end
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cameraplus::Page do
4
+
5
+ let(:data) do
6
+ {
7
+ url: "http:\/\/campl.us\/iao4",
8
+ tweettext: "Carnival in Venice, a travel photographer''s dream shoot!",
9
+ tweetid: "180064216093437954",
10
+ timestamp: "2012-03-14 22:53:49",
11
+ views: 1951,
12
+ comments: 1,
13
+ location: "45.43383498680353 12.34226474539595",
14
+ locationname: "Venice, Venice",
15
+ images: [ photo ]
16
+ }
17
+ end
18
+
19
+ let(:photo) do
20
+ {
21
+ "800px" => "http:\/\/pics.campl.us\/f\/0\/0b497f01791c851db1a17f81e0621a5c.jpg",
22
+ "120px" => "http:\/\/pics.campl.us\/t\/0\/0b497f01791c851db1a17f81e0621a5c.jpg",
23
+ "480px" => "http:\/\/pics.campl.us\/iphone\/0\/0b497f01791c851db1a17f81e0621a5c.jpg",
24
+ :fullwidth => 800,
25
+ :fullheight => 590,
26
+ :location => "45.43383498680353 12.34226474539595"
27
+ }
28
+ end
29
+
30
+ subject { Cameraplus::Page.new data }
31
+
32
+ context "instance" do
33
+
34
+ it "has an url" do
35
+ subject.url.should eq "http://campl.us/iao4"
36
+ end
37
+
38
+ it "has a datetime at which it was created" do
39
+ subject.created_at.should eq DateTime.parse("2012-03-14 22:53:49")
40
+ end
41
+
42
+ it "has a location" do
43
+ subject.location.should eq "45.43383498680353 12.34226474539595"
44
+ end
45
+
46
+ it "has a location name" do
47
+ subject.location_name.should eq "Venice, Venice"
48
+ end
49
+
50
+ it "has a tweet text" do
51
+ subject.tweet_text.should eq "Carnival in Venice, a travel photographer''s dream shoot!"
52
+ end
53
+
54
+ it "has a tweet id" do
55
+ subject.tweet_id.should eq 180064216093437954
56
+ end
57
+
58
+ it "has a view count" do
59
+ subject.view_count.should eq 1951
60
+ end
61
+
62
+ it "has a comment count" do
63
+ subject.comment_count.should eq 1
64
+ end
65
+
66
+ end
67
+
68
+ context "#photos" do
69
+
70
+ it "should be an Array" do
71
+ subject.photos.should be_an Array
72
+ end
73
+
74
+ it "should contain a Cameraplus::Photo" do
75
+ subject.photos.first.should be_a Cameraplus::Photo
76
+ end
77
+
78
+ it "should have one photo" do
79
+ subject.photos.size.should eq 1
80
+ end
81
+
82
+ end
83
+
84
+ end
@@ -0,0 +1,23 @@
1
+ require "spec_helper"
2
+
3
+ describe Cameraplus::PhotoExif do
4
+
5
+ let(:data) do
6
+ { :title => "Exposure", :value => "1\/120 sec", :style => "main" }
7
+ end
8
+
9
+ subject { Cameraplus::PhotoExif.new data }
10
+
11
+ it "should have a title" do
12
+ subject.title.should eq "Exposure"
13
+ end
14
+
15
+ it "should have a value" do
16
+ subject.value.should eq "1/120 sec"
17
+ end
18
+
19
+ it "should have a style" do
20
+ subject.style.should eq "main"
21
+ end
22
+
23
+ end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe Cameraplus::PhotoRecipe do
4
+
5
+ let(:data) do
6
+ { :type => "fx", :value => "Vibrant" }
7
+ end
8
+
9
+ subject { Cameraplus::PhotoRecipe.new data }
10
+
11
+ it "should have a type" do
12
+ subject.type.should eq "fx"
13
+ end
14
+
15
+ it "should have a value" do
16
+ subject.value.should eq "Vibrant"
17
+ end
18
+
19
+ end
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cameraplus::Photo do
4
+
5
+ let(:data) do
6
+ {
7
+ "800px" => "http:\/\/pics.campl.us\/f\/0\/0b497f01791c851db1a17f81e0621a5c.jpg",
8
+ "120px" => "http:\/\/pics.campl.us\/t\/0\/0b497f01791c851db1a17f81e0621a5c.jpg",
9
+ "480px" => "http:\/\/pics.campl.us\/iphone\/0\/0b497f01791c851db1a17f81e0621a5c.jpg",
10
+ "fullwidth" => 800,
11
+ "fullheight" => 590,
12
+ "location" => "45.43383498680353 12.34226474539595",
13
+ "recipe" => [
14
+ {
15
+ "type" => "fx",
16
+ "value" => "Vibrant"
17
+ }
18
+ ],
19
+ "exifdata" => [
20
+ {
21
+ "title" => "Camera",
22
+ "value" => "Apple iPhone 4S",
23
+ "style" => "main"
24
+ }
25
+ ]
26
+ }
27
+ end
28
+
29
+ subject { Cameraplus::Photo.new data }
30
+
31
+ context "instance" do
32
+
33
+ it "has a small version" do
34
+ subject.small.should eq "http://pics.campl.us/t/0/0b497f01791c851db1a17f81e0621a5c.jpg"
35
+ end
36
+
37
+ it "has a medium version" do
38
+ subject.medium.should eq "http://pics.campl.us/iphone/0/0b497f01791c851db1a17f81e0621a5c.jpg"
39
+ end
40
+
41
+ it "has a large version" do
42
+ subject.large.should eq "http://pics.campl.us/f/0/0b497f01791c851db1a17f81e0621a5c.jpg"
43
+ end
44
+
45
+ it "has a width" do
46
+ subject.width.should eq 800
47
+ end
48
+
49
+ it "has a height" do
50
+ subject.height.should eq 590
51
+ end
52
+
53
+ it "has a location" do
54
+ subject.location.should eq "45.43383498680353 12.34226474539595"
55
+ end
56
+
57
+ end
58
+
59
+ context "#recipes" do
60
+
61
+ it "should have recipes" do
62
+ subject.recipes.should be_an Array
63
+ end
64
+
65
+ it "should contain a Cameraplus::PhotoRecipe" do
66
+ subject.recipes.first.should be_a Cameraplus::PhotoRecipe
67
+ end
68
+
69
+ end
70
+
71
+ context "#exif" do
72
+
73
+ it "should have exif data" do
74
+ subject.exif.should be_an Array
75
+ end
76
+
77
+ it "should contain a Cameraplus::PhotoExif" do
78
+ subject.exif.first.should be_a Cameraplus::PhotoExif
79
+ end
80
+
81
+ end
82
+ end
@@ -0,0 +1,51 @@
1
+ require "spec_helper"
2
+
3
+ describe Cameraplus::Search do
4
+
5
+ context "by username" do
6
+
7
+ use_vcr_cassette :search
8
+
9
+ let(:results) { Cameraplus::Search.find username: "mostlylisa" }
10
+
11
+ it "should find a list of results" do
12
+ results.should be_an Array
13
+ end
14
+
15
+ context "with a Search object selected" do
16
+
17
+ let(:result) { results.first }
18
+
19
+ context "#page" do
20
+
21
+ it "should be a Page" do
22
+ result.page.should be_a Cameraplus::Page
23
+ end
24
+
25
+ end
26
+
27
+ context "#user" do
28
+
29
+ it "should be a User" do
30
+ result.user.should be_a Cameraplus::User
31
+ end
32
+
33
+ end
34
+
35
+ context "#photos" do
36
+
37
+ it "should be an Array" do
38
+ result.photos.should be_an Array
39
+ end
40
+
41
+ it "should contain a Cameraplus::Photo" do
42
+ result.photos.first.should be_a Cameraplus::Photo
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,82 @@
1
+ require "spec_helper"
2
+
3
+ describe Cameraplus::User do
4
+
5
+ use_vcr_cassette :user
6
+
7
+ let(:user) { Cameraplus::User.find "mostlylisa" }
8
+
9
+ it "should be a User" do
10
+ user.should be_a Cameraplus::User
11
+ end
12
+
13
+ context ".find" do
14
+
15
+ it "finds the id of the specified user" do
16
+ user.id.should eq 6978642
17
+ end
18
+
19
+ it "finds the username of the specified user" do
20
+ user.username.should eq "mostlylisa"
21
+ end
22
+
23
+ it "finds the name of the specified user" do
24
+ user.name.should eq "Lisa Bettany"
25
+ end
26
+
27
+ it "finds the avatar of the specified user" do
28
+ user.avatar.should eq "http://a0.twimg.com/profile_images/1767370289/284161_10150711631895637_674215636_19658534_6246798_n_normal.jpeg"
29
+ end
30
+
31
+ it "finds the number of pages of the specified user" do
32
+ user.page_count.should eq 122
33
+ end
34
+
35
+ it "finds the number of photos of the specified user" do
36
+ user.photo_count.should eq 876
37
+ end
38
+
39
+ end
40
+
41
+ context "#pages" do
42
+
43
+ it "should be an Array" do
44
+ user.pages.should be_a Array
45
+ end
46
+
47
+ it "should contain a Cameraplus::Page" do
48
+ user.pages.first.should be_a Cameraplus::Page
49
+ end
50
+
51
+ it "should have one page" do
52
+ user.pages.size.should eq 3
53
+ end
54
+
55
+ end
56
+
57
+ context "#more_results" do
58
+
59
+ use_vcr_cassette :more_results
60
+
61
+ let(:user) { Cameraplus::User.find "kalleboo" }
62
+ let(:more_results) { user.more_results }
63
+
64
+ it "should be a User" do
65
+ more_results.should be_a Cameraplus::User
66
+ end
67
+
68
+ it "should retrieve more pages" do
69
+ more_results.pages.should be_an Array
70
+ end
71
+
72
+ it "should contain pages that aren't the same as the first pages" do
73
+ more_results.pages.should_not eq user.pages
74
+ end
75
+
76
+ it "should contain Cameraplus::Page objects" do
77
+ more_results.pages.each { |page| page.should be_a Cameraplus::Page }
78
+ end
79
+
80
+ end
81
+
82
+ end