tcocca-etsy4r 0.3.0 → 0.3.1

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.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 0
2
+ :patch: 1
3
3
  :major: 0
4
4
  :minor: 3
@@ -5,13 +5,14 @@ module Etsy4r
5
5
 
6
6
  def initialize(listing_id)
7
7
  @listing_id = listing_id
8
- @parse_url = "http://www.etsy.com/view_listing.php?listing_id=#{@listing_id}"
8
+ @parse_url = set_parse_url
9
+ @images = parse_images
9
10
  end
10
11
 
11
- def images
12
- return @listing_images if @listing_images
12
+ def parse_images
13
+ return @images if @images
13
14
 
14
- @listing_images = {}
15
+ listing_images = {}
15
16
  require 'hpricot'
16
17
  require 'open-uri'
17
18
 
@@ -24,7 +25,7 @@ module Etsy4r
24
25
  image_list.each_with_index do |img_url, i|
25
26
  img_dom = /\/\/(\S*)\//.match(img_url)[1]
26
27
  img_id = /\.([\d]*)\./.match(img_url)[1]
27
- @listing_images["#{i}"] = {
28
+ listing_images["#{i}"] = {
28
29
  "image_url_430xN" => "http://#{img_dom}/il_430xN.#{img_id}.jpg",
29
30
  "image_url_200x200" => "http://#{img_dom}/il_200x200.#{img_id}.jpg",
30
31
  "image_url_155x125" => "http://#{img_dom}/il_155x125.#{img_id}.jpg",
@@ -33,7 +34,13 @@ module Etsy4r
33
34
  "image_url_25x25" => "http://#{img_dom}/il_25x25.#{img_id}.jpg"
34
35
  }
35
36
  end
36
- return @listing_images
37
+ return listing_images
38
+ end
39
+
40
+ private
41
+
42
+ def set_parse_url
43
+ "http://www.etsy.com/view_listing.php?listing_id=#{@listing_id}"
37
44
  end
38
45
 
39
46
  end
@@ -6,8 +6,8 @@ describe Etsy4r::ImageParser do
6
6
  include Etsy4rImageParserSpecHelper
7
7
 
8
8
  before do
9
+ Etsy4r::ImageParser.any_instance.stubs(:set_parse_url).returns(File.dirname(__FILE__) + "/../fixtures/images.html")
9
10
  @image_parser = Etsy4r::ImageParser.new(19781773)
10
- @image_parser.parse_url = File.dirname(__FILE__) + "/../fixtures/images.html"
11
11
  end
12
12
 
13
13
  describe 'initialize' do
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  begin
2
2
  require 'spec'
3
+ require 'mocha'
3
4
  rescue LoadError
4
5
  require 'rubygems'
5
6
  gem 'rspec'
6
7
  require 'spec'
8
+ require 'mocha'
7
9
  end
8
10
 
9
11
  $:.unshift(File.dirname(__FILE__) + '/../lib')
@@ -17,7 +19,6 @@ module Etsy4rSpecHelper
17
19
 
18
20
  end
19
21
 
20
-
21
22
  module Etsy4rImageParserSpecHelper
22
23
 
23
24
  def test_image_hash
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tcocca-etsy4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Cocca
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-10 00:00:00 -07:00
12
+ date: 2009-04-17 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency