kindle-notebook 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2140c0eb8f9baa719a922a97273ec8ded43b91e06b426b591060cf3c748d7b2a
4
- data.tar.gz: 02f8eb3c8769aaaa367f67a470817f0d9898fc5c48bcefd564ef5fdf63c1f174
3
+ metadata.gz: fdf9f8aae86d86694218ea71a942afad7dc5867970b79671f0dede3372bdb5ee
4
+ data.tar.gz: 6a132ae2b4b7291693c0e72992cb02b59248a908fdb0ded0fd220a6c20de2646
5
5
  SHA512:
6
- metadata.gz: 25872df3af96a21ddc6452112483d3010a6c4e3c6668aa684ac3e706baff891bd01786275de7489b389bd120bd1aaecf9df87eaf4354dfed308cd59d8163b383
7
- data.tar.gz: 9425897ec0a94e74774d3c81967ee10bb547e4292b116c88613675845111e418a2ebc182a7b7c01e3ad5b711fa0fbc1c6bc8279c2a78b0ee533d3cddf851f83d
6
+ metadata.gz: ab04dbcf4e7e721f8bd5f2f85b879998ca6f235b8485e55b82d3ab07a8273bf90740f14f9d40a6c064c2ecab136e64a5294138e0d54c6411633390456db69ae4
7
+ data.tar.gz: 15b4d1b7ab4d83bcb98d7b092734ae3d617ae7b4da6c9b3d08c32c2caadd79fadd10768d5334cbb29fd6e0b4794ee14d38b3dcfff3fd0bb85b4832b0621e523f
data/.rubocop.yml CHANGED
@@ -9,6 +9,15 @@ Naming/FileName:
9
9
  Exclude:
10
10
  - lib/kindle-notebook.rb
11
11
 
12
+ RSpec/ExampleLength:
13
+ Max: 7
14
+
15
+ RSpec/MultipleExpectations:
16
+ Max: 7
17
+
18
+ RSpec/MultipleMemoizedHelpers:
19
+ Max: 7
20
+
12
21
  Style/Documentation:
13
22
  Enabled: false
14
23
 
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in kindle-notebook.gemspec
6
6
  gemspec
7
7
 
8
+ gem "puffing-billy", "~> 3.1"
8
9
  gem "rake", "~> 13.0"
9
10
  gem "rspec", "~> 3.0"
10
11
  gem "rubocop", "~> 1.21"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kindle-notebook (0.3.0)
4
+ kindle-notebook (0.3.1)
5
5
  capybara (~> 3.39)
6
6
  capybara-sessionkeeper (~> 0.2.0)
7
7
  selenium-webdriver (~> 4.9)
@@ -25,12 +25,27 @@ GEM
25
25
  capybara
26
26
  selenium-webdriver
27
27
  coderay (1.1.3)
28
+ cookiejar (0.3.3)
28
29
  diff-lcs (1.5.0)
29
30
  dotenv (2.8.1)
31
+ em-http-request (1.1.7)
32
+ addressable (>= 2.3.4)
33
+ cookiejar (!= 0.3.1)
34
+ em-socksify (>= 0.3)
35
+ eventmachine (>= 1.0.3)
36
+ http_parser.rb (>= 0.6.0)
37
+ em-socksify (0.3.2)
38
+ eventmachine (>= 1.0.0.beta.4)
39
+ em-synchrony (1.0.6)
40
+ eventmachine (>= 1.0.0.beta.1)
41
+ eventmachine (1.2.7)
42
+ eventmachine_httpserver (0.2.1)
43
+ http_parser.rb (0.6.0)
30
44
  json (2.6.3)
31
45
  matrix (0.4.2)
32
46
  method_source (1.0.0)
33
47
  mini_mime (1.1.2)
48
+ multi_json (1.15.0)
34
49
  nokogiri (1.14.3-x86_64-linux)
35
50
  racc (~> 1.4)
36
51
  parallel (1.22.1)
@@ -40,6 +55,14 @@ GEM
40
55
  coderay (~> 1.1)
41
56
  method_source (~> 1.0)
42
57
  public_suffix (5.0.1)
58
+ puffing-billy (3.1.0)
59
+ addressable (~> 2.5)
60
+ em-http-request (~> 1.1, >= 1.1.0)
61
+ em-synchrony
62
+ eventmachine (~> 1.2)
63
+ eventmachine_httpserver
64
+ http_parser.rb (~> 0.6.0)
65
+ multi_json
43
66
  racc (1.6.2)
44
67
  rack (3.0.7)
45
68
  rack-test (2.1.0)
@@ -98,6 +121,7 @@ DEPENDENCIES
98
121
  dotenv (~> 2.8, >= 2.8.1)
99
122
  kindle-notebook!
100
123
  pry (~> 0.14.2)
124
+ puffing-billy (~> 3.1)
101
125
  rake (~> 13.0)
102
126
  rspec (~> 3.0)
103
127
  rubocop (~> 1.21)
data/README.md CHANGED
@@ -18,6 +18,24 @@ If bundler is not being used to manage dependencies, install the gem by executin
18
18
  $ gem install kindle-notebook
19
19
  ```
20
20
 
21
+ ## Configuration
22
+
23
+ You can either create a `.env` file and add your credentials, the default values will be fetched from this file, or configure the gem, for example in an initializer file.
24
+
25
+ ```rb
26
+ KindleNotebook.configure do |config|
27
+ config.url = "https://read.amazon.com/"
28
+ config.login = ENV["AMAZON_EMAIL"]
29
+ config.password = ENV["AMAZON_PASSWORD"]
30
+ config.selenium_driver = :firefox
31
+ config.headless_mode = false
32
+ config.min_highlight_words = 1
33
+ config.max_highlight_words = 3
34
+ end
35
+ ```
36
+
37
+ The configuration options `min_highlight_words` and `max_highlight_words` determine the range for a highlight's word count. Highlights with a word count outside this range will not be considered will be filtered out.
38
+
21
39
  ## Usage
22
40
 
23
41
  Sign in:
@@ -76,6 +94,19 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
76
94
 
77
95
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
78
96
 
97
+ ### Testing
98
+
99
+ This gem is using [puffing-billy](https://github.com/oesmith/puffing-billy) for testing which needs the geckodriver executable. It can be installed with:
100
+ ```sh
101
+ $ sudo apt-get install firefox-geckodriver # or
102
+ $ brew install geckodriver
103
+ ```
104
+
105
+ The executable should be in your `PATH`, if it is not you can run the following command (please adapt the location of the geckodriver executable with yours):
106
+ ```sh
107
+ $ echo 'export PATH=$PATH:/home/user/.cache/selenium/geckodriver/linux64/0.33.0' >> ~/.zshrc
108
+ ```
109
+
79
110
  ## Contributing
80
111
 
81
112
  Bug reports and pull requests are welcome on GitHub at https://github.com/b1anca/kindle-notebook. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/b1anca/kindle-notebook/blob/master/CODE_OF_CONDUCT.md).
@@ -4,6 +4,7 @@ require "capybara"
4
4
  require "capybara/sessionkeeper"
5
5
  require "csv"
6
6
  require "selenium-webdriver"
7
+ require "dotenv"
7
8
 
8
9
  require_relative "kindle_notebook/amazon_auth"
9
10
  require_relative "kindle_notebook/book"
@@ -14,15 +15,36 @@ require_relative "kindle_notebook/highlights"
14
15
  require_relative "kindle_notebook/highlight"
15
16
  require_relative "kindle_notebook/version"
16
17
 
18
+ Dotenv.load
19
+
17
20
  module KindleNotebook
18
21
  class Error < StandardError; end
19
22
 
20
- class << self
21
- attr_accessor :configuration, :session
23
+ class Configuration
24
+ attr_accessor :url, :login, :password, :selenium_driver, :headless_mode, :min_highlight_words,
25
+ :max_highlight_words
22
26
 
23
- def configure
24
- self.configuration ||= Configuration.new
25
- yield(configuration)
27
+ def initialize
28
+ @url = ENV["KINDLE_READER_URL"]
29
+ @login = ENV["AMAZON_EMAIL"]
30
+ @password = ENV["AMAZON_PASSWORD"]
31
+ @selenium_driver = ENV["SELENIUM_DRIVER"]
32
+ @headless_mode = ENV["HEADLESS_MODE"] == "true"
33
+ @min_highlight_words = ENV["MIN_HIGHLIGHT_WORDS"].to_i
34
+ @max_highlight_words = ENV["MAX_HIGHLIGHT_WORDS"].to_i
26
35
  end
27
36
  end
37
+
38
+ class << self
39
+ attr_writer :configuration
40
+ attr_accessor :session
41
+ end
42
+
43
+ def self.configuration
44
+ @configuration ||= KindleNotebook::Configuration.new
45
+ end
46
+
47
+ def self.configure
48
+ yield(configuration)
49
+ end
28
50
  end
@@ -10,7 +10,7 @@ module KindleNotebook
10
10
  def sign_in
11
11
  session.visit(KindleNotebook.configuration.url)
12
12
  if valid_cookies?
13
- puts 'Session restored!'
13
+ puts "Session restored!"
14
14
  return session
15
15
  end
16
16
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KindleNotebook
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kindle-notebook
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
  - Bianca Vieira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-24 00:00:00.000000000 Z
11
+ date: 2023-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara