yfrog 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -12,6 +12,8 @@ this gem is intended to abstract this process for robustness.
12
12
 
13
13
  require 'yfrog'
14
14
 
15
+ valid_url = YFrog.valid_url?("http://yfrog.com/kjugqgbj")
16
+
15
17
  image_url = YFrog.image_url_for("http://yfrog.com/kjugqgbj")
16
18
 
17
19
  # license
@@ -1,6 +1,15 @@
1
1
  module YFrog
2
2
  class << self
3
+
4
+ def valid_url?(url)
5
+ !!url.match("yfrog")
6
+ end
7
+
3
8
  def image_url_for(url, options = {:format => :medium} )
9
+ raise ArgumentError unless valid_url?(url)
10
+
11
+ url = "http://" << url unless url =~ /^http:\/\//
12
+
4
13
  suffix = case options.delete(:format)
5
14
  when :medium; ":medium"
6
15
  when :iphone; ":iphone"
@@ -7,41 +7,71 @@ describe YFrog do
7
7
  it { should be }
8
8
  end
9
9
 
10
+ describe "#valid_url?" do
11
+ subject { YFrog.valid_url?(url) }
12
+ context "with a non-yfrog url" do
13
+ let(:url) { "http://yfrawg.com/kjugqgbj" }
14
+ it { should == false }
15
+ end
16
+
17
+ context "with a yfrog url" do
18
+ let(:url) { "http://yfrog.com/kjugqgbj" }
19
+ it { should == true }
20
+ end
21
+
22
+ end
23
+
10
24
  describe "#image_url_for" do
11
- let(:url) { "http://yfrog.com/kjugqgbj" }
12
25
 
13
- context "without arguments" do
14
- subject { YFrog.image_url_for(url) }
15
- it { should == "http://yfrog.com/kjugqgbj:medium" }
26
+ context "with a non-yfrog url" do
27
+ let(:url) { "http://yfrawg.com/kjugqgbj" }
28
+ it "should raise an error" do
29
+ expect { YFrog.image_url_for(url) }.to raise_error(ArgumentError)
30
+ end
16
31
  end
17
32
 
18
- context "with a format specified" do
19
- subject { YFrog.image_url_for(url, :format => format) }
20
- context "medium" do
21
- let(:format) { :medium }
33
+ context "with a yfrog url" do
34
+ let(:url) { "http://yfrog.com/kjugqgbj" }
35
+
36
+ context "without http://" do
37
+ let(:url) { "yfrog.com/kjugqgbj" }
38
+ subject { YFrog.image_url_for(url) }
22
39
  it { should == "http://yfrog.com/kjugqgbj:medium" }
23
40
  end
24
41
 
25
- context "iphone" do
26
- let(:format) { :iphone }
27
- it { should == "http://yfrog.com/kjugqgbj:iphone" }
42
+ context "without arguments" do
43
+ subject { YFrog.image_url_for(url) }
44
+ it { should == "http://yfrog.com/kjugqgbj:medium" }
28
45
  end
29
46
 
30
- context "small" do
31
- let(:format) { :small }
32
- it { should == "http://yfrog.com/kjugqgbj:small" }
33
- end
47
+ context "with a format specified" do
48
+ subject { YFrog.image_url_for(url, :format => format) }
49
+ context "medium" do
50
+ let(:format) { :medium }
51
+ it { should == "http://yfrog.com/kjugqgbj:medium" }
52
+ end
34
53
 
35
- context "thumb" do
36
- let(:format) { :thumb }
37
- it { should == "http://yfrog.com/kjugqgbj:small" }
54
+ context "iphone" do
55
+ let(:format) { :iphone }
56
+ it { should == "http://yfrog.com/kjugqgbj:iphone" }
57
+ end
58
+
59
+ context "small" do
60
+ let(:format) { :small }
61
+ it { should == "http://yfrog.com/kjugqgbj:small" }
62
+ end
63
+
64
+ context "thumb" do
65
+ let(:format) { :thumb }
66
+ it { should == "http://yfrog.com/kjugqgbj:small" }
67
+ end
38
68
  end
39
- end
40
69
 
41
- context "with an unsupported format" do
42
- let(:format) { :omgwtfbbq }
43
- it "should raise an exception" do
44
- expect { YFrog.image_url_for(url, :format => format) }.to raise_error(ArgumentError)
70
+ context "with an unsupported format" do
71
+ let(:format) { :omgwtfbbq }
72
+ it "should raise an exception" do
73
+ expect { YFrog.image_url_for(url, :format => format) }.to raise_error(ArgumentError)
74
+ end
45
75
  end
46
76
  end
47
77
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "yfrog"
5
- s.version = "1.0.0"
5
+ s.version = "1.0.1"
6
6
  s.date = Time.now.strftime('%Y-%m-%d')
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Sean Moon"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yfrog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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: 2011-10-14 00:00:00.000000000 -04:00
12
+ date: 2011-10-16 00:00:00.000000000 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description: work with yfrog urls to get image urls and such