kindleclippings 1.3.0 → 1.3.1
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/README.markdown +6 -3
- data/lib/kindleclippings/clipping.rb +5 -4
- data/lib/kindleclippings/parser.rb +3 -3
- metadata +4 -4
data/README.markdown
CHANGED
|
@@ -9,7 +9,7 @@ This library will parse these annotations/clippings and give you an array of rub
|
|
|
9
9
|
|
|
10
10
|
To install kindleclippings just run
|
|
11
11
|
|
|
12
|
-
%
|
|
12
|
+
% gem install kindleclippings
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
@@ -52,9 +52,9 @@ You can retrieve only the annotationstypes you care about. After parsing, you ca
|
|
|
52
52
|
clippings.highlights # All the highlights
|
|
53
53
|
clippings.bookmarks # All the bookmarks
|
|
54
54
|
|
|
55
|
-
#### Author
|
|
55
|
+
#### Author, book title and date
|
|
56
56
|
|
|
57
|
-
You can filter the results by author
|
|
57
|
+
You can filter the results by author, book title or date by using the methods `by_author`, `by_book` and `by_date` on a `ClippingResult` object.
|
|
58
58
|
|
|
59
59
|
require 'kindleclippings'
|
|
60
60
|
|
|
@@ -65,9 +65,12 @@ You can filter the results by author and booktitle by using the methods `by_auth
|
|
|
65
65
|
|
|
66
66
|
clippings.by_book('Born to Run') # All annotations for the book Born to Run
|
|
67
67
|
|
|
68
|
+
clippings.by_date(Date.new(2011, 10, 1), Date.new(2011, 10, 31)) # All annotations for October 2011
|
|
69
|
+
|
|
68
70
|
## Contributors
|
|
69
71
|
|
|
70
72
|
* Georg Alexander Bøe
|
|
71
73
|
* Masatomo Nakano
|
|
72
74
|
* brokensandals
|
|
73
75
|
* fboucheros
|
|
76
|
+
* David Ramalho
|
|
@@ -3,24 +3,25 @@ module KindleClippings
|
|
|
3
3
|
class Clipping
|
|
4
4
|
require 'date'
|
|
5
5
|
|
|
6
|
-
attr_accessor :book_title, :author, :type, :location, :added_on, :content
|
|
6
|
+
attr_accessor :book_title, :author, :type, :location, :added_on, :content, :page
|
|
7
7
|
|
|
8
8
|
def initialize()
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
def initialize(title, author, type, location, added_on, content)
|
|
11
|
+
def initialize(title, author, type, location, added_on, content, page = "0")
|
|
12
12
|
@book_title = title
|
|
13
13
|
@author = author
|
|
14
14
|
@type = type
|
|
15
15
|
@location = location
|
|
16
16
|
@added_on = DateTime.strptime(added_on, "%A, %B %d, %Y, %I:%M %p")
|
|
17
17
|
@content = content
|
|
18
|
+
@page = page.to_i
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
def to_s
|
|
21
22
|
"#{@book_title} (#{author})\n" +
|
|
22
|
-
"- #{@type} Loc. #{@location} | Added on #{@added_on.strftime('%A, %B %d, %Y, %I:%M %p')}\n\n" +
|
|
23
|
+
"- #{@type} #{('on Page ' + @page.to_s + ' | ') if @page > 0}Loc. #{@location} | Added on #{@added_on.strftime('%A, %B %d, %Y, %I:%M %p')}\n\n" +
|
|
23
24
|
"#{@content}"
|
|
24
25
|
end
|
|
25
26
|
end
|
|
26
|
-
end
|
|
27
|
+
end
|
|
@@ -37,7 +37,7 @@ module KindleClippings
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
first_line = lines[0].strip.scan(/^(.+) \((.+)\)$/i).first
|
|
40
|
-
second_line = lines[1].strip.scan(/^- (.+?) Loc. ([0-9-]*?) +\| Added on (.+)$/i).first
|
|
40
|
+
second_line = lines[1].strip.scan(/^- (.+?) (?:on page (\d+) \| |)Loc. ([0-9-]*?) +\| Added on (.+)$/i).first
|
|
41
41
|
|
|
42
42
|
if first_line.nil?
|
|
43
43
|
title = lines[0].strip
|
|
@@ -45,11 +45,11 @@ module KindleClippings
|
|
|
45
45
|
else
|
|
46
46
|
title, author = *first_line
|
|
47
47
|
end
|
|
48
|
-
type, location, date = *second_line
|
|
48
|
+
type, page, location, date = *second_line
|
|
49
49
|
|
|
50
50
|
content = lines[3..-1].join("")
|
|
51
51
|
|
|
52
|
-
Clipping.new(title, author, type.to_sym, location, date, content.strip)
|
|
52
|
+
Clipping.new(title, author, type.to_sym, location, date, content.strip, page)
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kindleclippings
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2012-07-06 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rspec
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &70213467946360 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,7 +21,7 @@ dependencies:
|
|
|
21
21
|
version: 1.2.9
|
|
22
22
|
type: :development
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *70213467946360
|
|
25
25
|
description: A gem to parse Kindle's "My Clippings.txt" file into ruby objects.
|
|
26
26
|
email: georg.boe@gmail.com
|
|
27
27
|
executables: []
|