fletcher 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,14 +1,13 @@
1
1
  # Fletcher
2
+
2
3
  [![Build Status](https://travis-ci.org/hulihanapplications/fletcher.png)](http://travis-ci.org/hulihanapplications/fletcher)
3
4
 
4
-
5
-
6
- Fletcher is a cross-website product/model information fetcher. Give fletcher a product url and you'll get back a nice, simple object that's easy to work with.
5
+ Fletcher is a cross-website product information fetcher. Just give fletcher a product's url and you'll get back a nice, uniform object that's easy to work with.
7
6
 
8
7
  ## Features
9
8
 
9
+ * No third-party API access required (good for websites that don't even have API access)
10
10
  * Uses nokogiri for data parsing
11
- * No third-party API Access Required (Good for websites that don't even have API access)
12
11
 
13
12
  ## Supported Websites
14
13
 
@@ -18,8 +17,8 @@ Fletcher is a cross-website product/model information fetcher. Give fletcher a p
18
17
  * [game.co.uk](http://www.game.co.uk)
19
18
  * [Google Shopping](http://www.google.com/products/)
20
19
  * [play.com](http://www.play.com)
21
- * [ThinkGeek](http://www.thinkgeek.com)
22
20
  * [Steam](http://store.steampowered.com)
21
+ * [ThinkGeek](http://www.thinkgeek.com)
23
22
 
24
23
  ## Installation
25
24
 
@@ -29,26 +28,28 @@ gem install fletcher
29
28
 
30
29
  ## Usage
31
30
 
31
+ ### API
32
+
32
33
  ```ruby
33
34
  require "fletcher"
34
35
 
35
- model = Fletcher.fetch "http://www.amazon.com/Avenir-Deluxe-Unicycle-20-Inch-Wheel/dp/B00165Q9F8"
36
+ product = Fletcher.fetch "http://www.amazon.com/Avenir-Deluxe-Unicycle-20-Inch-Wheel/dp/B00165Q9F8"
36
37
 
37
- model.name # => "Avenir Deluxe Unicycle (20-Inch Wheel)"
38
+ product.name # => "Avenir Deluxe Unicycle (20-Inch Wheel)"
38
39
 
39
- model.description # => "A wonderful unicycle"
40
+ product.description # => "A wonderful unicycle"
40
41
 
41
- model.images.count # => 1
42
- model.image # => {:url => "http://ecx.images-amazon.com/images/I/41b3TNb3uCL._SL500_AA300_.jpg", :alt => "Picture of Unicycle"}
43
- model.image.url # => "http://ecx.images-amazon.com/images/I/41b3TNb3uCL._SL500_AA300_.jpg"
42
+ product.images.count # => 1
43
+ product.image # => {:src => "http://ecx.images-amazon.com/images/I/41b3TNb3uCL._SL500_AA300_.jpg", :alt => "Picture of Unicycle"}
44
+ product.image.src # => "http://ecx.images-amazon.com/images/I/41b3TNb3uCL._SL500_AA300_.jpg"
44
45
 
45
- model.price # => #<Money cents:500 currency:USD>
46
- model.price.to_f # => 5.0
47
- model.price.format # => "$5.00"
48
- model.price.currency.symbol # => "$"
46
+ product.price # => #<Money cents:500 currency:USD>
47
+ product.price.to_f # => 5.0
48
+ product.price.format # => "$5.00"
49
+ product.price.currency.symbol # => "$"
49
50
 
50
51
  # Get Raw Nokogiri Document
51
- model.doc.class.name # => Nokogiri::HTML::Document
52
+ product.doc.class.name # => Nokogiri::HTML::Document
52
53
 
53
54
  # Get list of supported websites/services
54
55
  Fletcher.models # => [:amazon, :ebay, :etsy, :thinkgeek, ...]
@@ -56,11 +57,11 @@ Fletcher.models # => [:amazon, :ebay, :etsy, :thinkgeek, ...]
56
57
 
57
58
  ## Attributes
58
59
 
59
- The following attributes are available from models:
60
-
61
- * title - (String) The name of the model/product
62
- * description - (String) The model/product description
63
- * price - (Money) A [Money](https://github.com/RubyMoney/money) object representing the model price. This makes exchange rates and math functionality easy to use.
64
- * image - (Hash) The main image of the model
65
- * images - (Array) Any available images of the model
60
+ The following attributes/method are available for a product:
66
61
 
62
+ * `name` - (String) The name of the product
63
+ * `description` - (String) The product's description
64
+ * `price` - (Money) A [Money](https://github.com/RubyMoney/money) object representing the product's price. This makes converting exchange rates and math functionality easy to use.
65
+ * `image` - (Hash) The main image of the product, if available. This is a hash containing standard HTML attributes: `src`, `alt`, `width`, `height`, etc.
66
+ * `images` - (Array) An array of product images.
67
+ * `doc` - The raw `Nokogiri::HTML::Document` object for the product. You can use this to pull other stuff from the product's page.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
data/fletcher.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fletcher"
8
- s.version = "0.5.1"
8
+ s.version = "0.5.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dave Hulihan", "Hulihan Applications"]
@@ -23,7 +23,7 @@ module Fletcher
23
23
  parse_price(raw_price.gsub(/US/, "")) if raw_price
24
24
 
25
25
  # Get Image
26
- self.images = [{:url => doc.xpath("//span[@itemprop='image']/img").first_string}]
26
+ self.images = [{:src => doc.xpath("//span[@itemprop='image']/img").first_string}]
27
27
  self.image = images.first
28
28
  end
29
29
  end
@@ -31,7 +31,7 @@ module Fletcher
31
31
  parse_price(raw_price.gsub(/Only /, "")) if raw_price
32
32
 
33
33
  # Get Image
34
- self.images = [{:url => doc.xpath("//meta[@property='og:image']/@content").first_string}]
34
+ self.images = [{:src => doc.xpath("//meta[@property='og:image']/@content").first_string}]
35
35
  self.image = images.first
36
36
  end
37
37
  end
@@ -22,7 +22,7 @@ module Fletcher
22
22
  parse_price(doc.xpath("//form[@id='buy']/h3").first_string) rescue nil
23
23
 
24
24
  # Get Images
25
- self.images = [{:url => doc.xpath("//meta[@property='og:image']/@content").first_string}]
25
+ self.images = [{:src => doc.xpath("//meta[@property='og:image']/@content").first_string}]
26
26
  self.image = images.first
27
27
  end
28
28
  end
@@ -11,6 +11,7 @@ describe Fletcher, :vcr do
11
11
  it "should fetch a thinkgeek product's information" do
12
12
  item = Fletcher.fetch(Factory(:thinkgeek).url)
13
13
  item.should_not be_nil
14
+ item.image.should_not be_nil
14
15
  item.name.should_not be_nil
15
16
  item.description.should_not be_nil
16
17
  end
@@ -18,6 +19,7 @@ describe Fletcher, :vcr do
18
19
  it "should fetch a thinkgeek product with price range" do
19
20
  item = Fletcher.fetch(Factory(:thinkgeek_with_price_range).url)
20
21
  item.should_not be_nil
22
+ item.image.should_not be_nil
21
23
  item.name.should_not be_nil
22
24
  item.description.should_not be_nil
23
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fletcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -270,7 +270,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
270
270
  version: '0'
271
271
  segments:
272
272
  - 0
273
- hash: 1654336260587893613
273
+ hash: 1020600340918133872
274
274
  required_rubygems_version: !ruby/object:Gem::Requirement
275
275
  none: false
276
276
  requirements: