smeargle 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,6 @@
1
+ ## v0.0.1
2
+ * Inital Release
3
+ * Images with Filtering
4
+
5
+ ## v0.1.0
6
+ * Added simple_images
data/README.md CHANGED
@@ -62,6 +62,18 @@ to run. You may want to have it run in the background.
62
62
  end
63
63
  ```
64
64
 
65
+ If you're not looking to filter images, and don't need detailed information,
66
+ then you can use simple_images. This method returns an array of image
67
+ urls, and is faster than the images method.
68
+
69
+ ```
70
+ s = Smeargle::Sketch.new 'google.com'
71
+
72
+ s.simple_images.each do |img|
73
+ img # returns 'http://google.com/test.jpg'
74
+ end
75
+ ```
76
+
65
77
  ## Contributing
66
78
 
67
79
  1. Fork it
@@ -18,12 +18,19 @@ module Smeargle
18
18
  def formatted_images
19
19
  formatted_images = []
20
20
  image_collection.each do |img|
21
- image = image_format img
22
- formatted_images << image_details(image)
21
+ formatted_images << image_format(img)
23
22
  end
24
23
  formatted_images
25
24
  end
26
25
 
26
+ def detailed_images
27
+ detailed_images = []
28
+ formatted_images.each do |img|
29
+ detailed_images << image_details(img)
30
+ end
31
+ detailed_images
32
+ end
33
+
27
34
  def image_format img
28
35
  if URI(img).relative?
29
36
  self.safe_url + img
@@ -39,11 +46,15 @@ module Smeargle
39
46
  end
40
47
 
41
48
  def filtered_images
42
- images = formatted_images
49
+ images = detailed_images
43
50
  images.reject! { |x| x[:width] < min_width } if min_width
44
51
  images.reject! { |x| x[:height] < min_height } if min_height
45
52
  images
46
53
  end
47
54
 
55
+ def simple_images
56
+ @simple_images ||= formatted_images
57
+ end
58
+
48
59
  end
49
60
  end
@@ -1,3 +1,3 @@
1
1
  module Smeargle
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -9,7 +9,7 @@ describe Smeargle::Image do
9
9
  { url: 'test.png', height: 10, width: 10 })
10
10
 
11
11
  FakeWeb.register_uri :get, 'http://google.com',
12
- body: "Google <img src='test.png' /> <img src='test.png' />"
12
+ body: "Google <img src='/test.png' /> <img src='/test.png' />"
13
13
  end
14
14
 
15
15
  describe 'images' do
@@ -38,6 +38,20 @@ describe Smeargle::Image do
38
38
  end
39
39
  end
40
40
 
41
+ describe 'formatted images' do
42
+ it 'should return an array of formatted urls' do
43
+ e = smeargle.formatted_images
44
+ e.first.should == 'http://google.com/test.png'
45
+ end
46
+ end
47
+
48
+ describe 'detailed_images' do
49
+ it 'should return an array of hashes' do
50
+ e = smeargle.detailed_images
51
+ e.first.should be_a Hash
52
+ end
53
+ end
54
+
41
55
  describe 'image_collection' do
42
56
  it 'should not contain duplicates' do
43
57
  smeargle.image_collection.count.should == 1
@@ -53,4 +67,11 @@ describe Smeargle::Image do
53
67
  end
54
68
  end
55
69
 
70
+ describe 'simple_images' do
71
+ it 'should contain an array of urls' do
72
+ s = Smeargle::Sketch.new 'google.com'
73
+ s.simple_images.first.should =~ /test\.png/
74
+ end
75
+ end
76
+
56
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smeargle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
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: 2012-09-03 00:00:00.000000000 Z
12
+ date: 2012-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -99,6 +99,7 @@ extensions: []
99
99
  extra_rdoc_files: []
100
100
  files:
101
101
  - .gitignore
102
+ - CHANGELOG
102
103
  - Gemfile
103
104
  - LICENSE
104
105
  - README.md
@@ -126,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
127
  version: '0'
127
128
  segments:
128
129
  - 0
129
- hash: 1742334504080811707
130
+ hash: -4409639940633573992
130
131
  required_rubygems_version: !ruby/object:Gem::Requirement
131
132
  none: false
132
133
  requirements:
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  version: '0'
136
137
  segments:
137
138
  - 0
138
- hash: 1742334504080811707
139
+ hash: -4409639940633573992
139
140
  requirements: []
140
141
  rubyforge_project:
141
142
  rubygems_version: 1.8.23