kindle_highlights_api 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +73 -0
- data/Rakefile +16 -0
- data/kindle_highlights_api.gemspec +23 -0
- data/lib/kindle_highlights_api/book.rb +19 -0
- data/lib/kindle_highlights_api/fetcher.rb +51 -0
- data/lib/kindle_highlights_api/version.rb +3 -0
- data/lib/kindle_highlights_api.rb +8 -0
- data/test/book_test.rb +26 -0
- data/test/fetcher_test.rb +23 -0
- data/test/fixtures/html/highlights_page_1.html +1054 -0
- data/test/fixtures/html/highlights_page_2.html +362 -0
- data/test/fixtures/html/highlights_page_3.html +1972 -0
- data/test/fixtures/html/highlights_page_4.html +1995 -0
- data/test/fixtures/html/highlights_page_5.html +1397 -0
- data/test/fixtures/html/highlights_page_6.html +385 -0
- data/test/fixtures/html/highlights_page_7.html +174 -0
- data/test/fixtures/html/kindle_home_page.html +588 -0
- data/test/fixtures/html/login_page.html +758 -0
- data/test/fixtures/html/signin_post_response.txt +10 -0
- data/test/test_helper.rb +42 -0
- metadata +123 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
HTTP/1.1 302 Found
|
2
|
+
Server: Server
|
3
|
+
Date: Sun, 27 Apr 2014 01:54:16 GMT
|
4
|
+
Content-Type: text/html;charset=UTF-8
|
5
|
+
Content-Length: 0
|
6
|
+
Connection: keep-alive
|
7
|
+
Pragma: No-cache
|
8
|
+
Cache-Control: no-cache, must-revalidate
|
9
|
+
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
10
|
+
Location: https://kindle.amazon.com:443/authenticate/login_callback?wctx=%2F&openid.assoc_handle=amzn_kindle&aToken=5%7CT2bKSa1fbooeUKhUD66YfLW%2F9y13QtHoZfVGvvvOFvdGm0B2k8S%2F1KicIEJBcEOndhbur0Nz46deFCBRUpQM0Y5T7jTcBZWEZEMsr6SJS%2FnJjL%2BG2Nb%2BGEMcGr9Z9ziGENo%2F3bX9KbE0wU22bAGSjoh2394pdqLNdEv06lBhpTCksMqAT0e68klLEGHdjRMxZxQ21Bsr7z%2BsYExu%2FyZdose0qZx2JfRY&openid.claimed_id=https%3A%2F%2Fwww.amazon.com%2Fap%2Fid%2Famzn1.account.AFS6YC6ZKWAJ64HHNFPQRPE3GO6Q&openid.identity=https%3A%2F%2Fwww.amazon.com%2Fap%2Fid%2Famzn1.account.AFS6YC6ZKWAJ64HHNFPQRPE3GO6Q&openid.mode=id_res&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.op_endpoint=https%3A%2F%2Fwww.amazon.com%2Fap%2Fsignin&openid.response_nonce=2014-04-27T01%3A54%3A16Z-3355228545486825706&openid.return_to=https%3A%2F%2FkiLocation: httomLocation: https://kindle.amazon.cobaLocation: https://kindle.amazon.com:c_handle%2CaToken%2CLocation: https://kin%2Cmode%2Cns%2Cop_eLocation: https://kindle.amazon.com:443nsLocation: https://kindle.amazon.com:4h_
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'kindle_highlights_api'
|
5
|
+
require 'pry'
|
6
|
+
require 'mocha/mini_test'
|
7
|
+
require 'pry-rescue/minitest'
|
8
|
+
require 'fakeweb'
|
9
|
+
|
10
|
+
TEST_ROOT = File.expand_path('..', __FILE__)
|
11
|
+
|
12
|
+
def mock_web_requests
|
13
|
+
FakeWeb.allow_net_connect = false
|
14
|
+
|
15
|
+
kindle_home_url = "https://kindle.amazon.com"
|
16
|
+
|
17
|
+
FakeWeb.register_uri(:get, "#{kindle_home_url}/login", body: fixture_body(:login_page), content_type: "text/html")
|
18
|
+
FakeWeb.register_uri(:post, %r{https://www.amazon.com/ap/signin}, response: fixture_body(:signin_post_response, ext: 'txt'))
|
19
|
+
FakeWeb.register_uri(:get, %r{#{kindle_home_url}/authenticate/login_callback}, body: fixture_body(:kindle_home_page), content_type: "text/html")
|
20
|
+
|
21
|
+
all_fixture_pages.each.with_index do |path, index|
|
22
|
+
current_page_body = File.read(path)
|
23
|
+
|
24
|
+
FakeWeb.register_uri(:get, "#{kindle_home_url}\/your_highlights", body: current_page_body, content_type: "text/html") if index == 0
|
25
|
+
|
26
|
+
next_book_url = Nokogiri::HTML.parse(current_page_body).search("a[id='nextBookLink']/@href").to_s
|
27
|
+
unless next_book_url.empty?
|
28
|
+
next_book_body = fixture_body("highlights_page_#{index + 2}")
|
29
|
+
FakeWeb.register_uri(:get, "#{kindle_home_url}#{next_book_url}", body: next_book_body, content_type: "text/html")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def all_fixture_pages
|
35
|
+
Dir["#{TEST_ROOT}/fixtures/html/highlights_page_*.html"].sort
|
36
|
+
end
|
37
|
+
|
38
|
+
def fixture_body(filename, ext: 'html')
|
39
|
+
File.read("#{TEST_ROOT}/fixtures/html/#{filename.to_s}.#{ext}")
|
40
|
+
end
|
41
|
+
|
42
|
+
mock_web_requests
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kindle_highlights_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gaurav Chande
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mechanize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- gmail@gauravchande.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- kindle_highlights_api.gemspec
|
68
|
+
- lib/kindle_highlights_api.rb
|
69
|
+
- lib/kindle_highlights_api/book.rb
|
70
|
+
- lib/kindle_highlights_api/fetcher.rb
|
71
|
+
- lib/kindle_highlights_api/version.rb
|
72
|
+
- test/book_test.rb
|
73
|
+
- test/fetcher_test.rb
|
74
|
+
- test/fixtures/html/highlights_page_1.html
|
75
|
+
- test/fixtures/html/highlights_page_2.html
|
76
|
+
- test/fixtures/html/highlights_page_3.html
|
77
|
+
- test/fixtures/html/highlights_page_4.html
|
78
|
+
- test/fixtures/html/highlights_page_5.html
|
79
|
+
- test/fixtures/html/highlights_page_6.html
|
80
|
+
- test/fixtures/html/highlights_page_7.html
|
81
|
+
- test/fixtures/html/kindle_home_page.html
|
82
|
+
- test/fixtures/html/login_page.html
|
83
|
+
- test/fixtures/html/signin_post_response.txt
|
84
|
+
- test/test_helper.rb
|
85
|
+
homepage: https://github.com/gauravmc/kindle_highlights_api
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.2.2
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: A wrapper that helps fetch Kindle highlights and play around with them.
|
109
|
+
test_files:
|
110
|
+
- test/book_test.rb
|
111
|
+
- test/fetcher_test.rb
|
112
|
+
- test/fixtures/html/highlights_page_1.html
|
113
|
+
- test/fixtures/html/highlights_page_2.html
|
114
|
+
- test/fixtures/html/highlights_page_3.html
|
115
|
+
- test/fixtures/html/highlights_page_4.html
|
116
|
+
- test/fixtures/html/highlights_page_5.html
|
117
|
+
- test/fixtures/html/highlights_page_6.html
|
118
|
+
- test/fixtures/html/highlights_page_7.html
|
119
|
+
- test/fixtures/html/kindle_home_page.html
|
120
|
+
- test/fixtures/html/login_page.html
|
121
|
+
- test/fixtures/html/signin_post_response.txt
|
122
|
+
- test/test_helper.rb
|
123
|
+
has_rdoc:
|