kindle_highlights 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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_
@@ -0,0 +1,42 @@
1
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
2
+
3
+ require 'minitest/autorun'
4
+ require 'kindle_highlights'
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 CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kindle_highlights
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gaurav Chande
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-26 00:00:00.000000000 Z
11
+ date: 2014-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,14 +28,28 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
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
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  description:
@@ -52,7 +66,22 @@ files:
52
66
  - Rakefile
53
67
  - kindle_highlights.gemspec
54
68
  - lib/kindle_highlights.rb
69
+ - lib/kindle_highlights/book.rb
70
+ - lib/kindle_highlights/fetcher.rb
55
71
  - lib/kindle_highlights/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
56
85
  homepage: https://github.com/gauravmc/kindle_highlights
57
86
  licenses:
58
87
  - MIT
@@ -77,5 +106,18 @@ rubygems_version: 2.2.2
77
106
  signing_key:
78
107
  specification_version: 4
79
108
  summary: A wrapper that helps fetch Kindle highlights and play around with them.
80
- test_files: []
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
81
123
  has_rdoc: