RailsMug 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,7 @@ module RailsMug
26
26
 
27
27
  raise RailsMug::ImagesError, "SmugMug images.get Error: #{json_response['code']} - #{json_response['message']}" if json_response['stat'] == "fail"
28
28
 
29
+ count = 0
29
30
  json_response['Album']['Images'].each do |img|
30
31
  img = RailsMug::Model::Image.new(
31
32
  :id => img['id'],
@@ -33,6 +34,9 @@ module RailsMug
33
34
  )
34
35
  img.get_photo_info @access_token unless opts[:no_info]
35
36
  self.images << img
37
+
38
+ count = count + 1
39
+ break if !opts[:limit].nil? && count >= opts[:limit].to_i
36
40
  end
37
41
 
38
42
  self.images
@@ -1,3 +1,3 @@
1
1
  module RailsMug
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/images_spec.rb CHANGED
@@ -2,16 +2,34 @@ require 'spec_helper'
2
2
 
3
3
  describe RailsMug do
4
4
  session = RailsMug::Session.new('<API KEY>','<API SECRET>','<ACCESS TOKEN>','<ACCESS TOKEN SECRET>')
5
+ album_id = 28536068
6
+ album_key = '4b4dGb'
7
+
8
+ it "should require album_id" do
9
+ rails_mug = RailsMug::Images.new(session)
10
+ expect { rails_mug.get_images }.to raise_error
11
+ end
12
+
13
+ it "should require album_key" do
14
+ rails_mug = RailsMug::Images.new(session)
15
+ expect { rails_mug.get_images album_id }.to raise_error
16
+ end
5
17
 
6
18
  it "should get photos without detailed info" do
7
19
  rails_mug = RailsMug::Images.new(session)
8
- images = rails_mug.get_images 28536068, '4b4dGb', :no_info => true
20
+ images = rails_mug.get_images album_id, album_key, :no_info => true
9
21
  images.should_not be_nil
10
22
  end
11
23
 
12
24
  it "should get photos with detailed info" do
13
25
  rails_mug = RailsMug::Images.new(session)
14
- rails_mug.get_images 28536068, '4b4dGb'
26
+ rails_mug.get_images album_id, album_key
15
27
  rails_mug.images.should_not be_nil
16
28
  end
29
+
30
+ it "should stop after 3 images from an album" do
31
+ rails_mug = RailsMug::Images.new(session)
32
+ rails_mug.get_images album_id, album_key, :limit => 3
33
+ rails_mug.images.count.should be(3)
34
+ end
17
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RailsMug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-21 00:00:00.000000000 Z
12
+ date: 2013-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec