kindle-highlights 0.0.3 → 0.0.4
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/lib/kindle-highlights.rb +18 -7
- metadata +5 -5
data/lib/kindle-highlights.rb
CHANGED
@@ -33,16 +33,27 @@ class KindleHighlight::Highlight
|
|
33
33
|
|
34
34
|
attr_accessor :annotation_id, :asin, :author, :title, :content
|
35
35
|
|
36
|
+
@@amazon_items = Hash.new
|
37
|
+
|
36
38
|
def initialize(highlight)
|
37
39
|
self.annotation_id = highlight.xpath("form/input[@id='annotation_id']").attribute("value").value
|
38
40
|
self.asin = highlight.xpath("p/span[@class='hidden asin']").text
|
39
41
|
self.content = highlight.xpath("span[@class='highlight']").text
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
amazon_item = lookup_or_get_from_cache(self.asin)
|
43
|
+
self.author = amazon_item.item_attributes.author.to_s
|
44
|
+
self.title = amazon_item.item_attributes.title.to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
def lookup_or_get_from_cache(asin)
|
48
|
+
unless @@amazon_items.has_key? (asin)
|
49
|
+
request = Request.new
|
50
|
+
request.locale = 'us'
|
51
|
+
response = ResponseGroup.new('Medium')
|
52
|
+
lookup = Amazon::AWS::ItemLookup.new('ASIN', {'ItemId' => asin, 'MerchantId' => 'Amazon'})
|
53
|
+
puts amazon_item = request.search(lookup, response).item_lookup_response[0].items.inspect
|
54
|
+
amazon_item = request.search(lookup, response).item_lookup_response[0].items.item.first
|
55
|
+
@@amazon_items[asin] = amazon_item
|
56
|
+
end
|
57
|
+
@@amazon_items[asin]
|
47
58
|
end
|
48
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kindle-highlights
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-20 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|
16
|
-
requirement: &
|
16
|
+
requirement: &9614412 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.0.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *9614412
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: ruby-aaws
|
27
|
-
requirement: &
|
27
|
+
requirement: &9614112 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 0.7.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *9614112
|
36
36
|
description: Until there is a Kindle API, this will suffice.
|
37
37
|
email: eric@prudentiadigital.com
|
38
38
|
executables: []
|