kindleclippings 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +16 -1
- data/lib/clippingresult.rb +14 -6
- data/lib/kindleclippings.rb +1 -1
- metadata +8 -5
data/README.markdown
CHANGED
@@ -39,6 +39,8 @@ The annotations can also be parsed directly.
|
|
39
39
|
|
40
40
|
### Retrieve only the information you care about
|
41
41
|
|
42
|
+
#### Annotation types
|
43
|
+
|
42
44
|
You can retrieve only the annotationstypes you care about. After parsing, you can call `highlights`, `notes` or `bookmarks` on the collection to get only annotations of that type.
|
43
45
|
|
44
46
|
require 'kindleclippings'
|
@@ -48,4 +50,17 @@ You can retrieve only the annotationstypes you care about. After parsing, you ca
|
|
48
50
|
|
49
51
|
clippings.notes # All the notes
|
50
52
|
clippings.highlights # All the highlights
|
51
|
-
clippings.bookmarks # All the bookmarks
|
53
|
+
clippings.bookmarks # All the bookmarks
|
54
|
+
|
55
|
+
#### Author and book title
|
56
|
+
|
57
|
+
You can filter the results by author and booktitle by using the methods `by_author` and `by_book` on a `ClippingResult` object.
|
58
|
+
|
59
|
+
require 'kindleclippings'
|
60
|
+
|
61
|
+
parser = KindleClippings::Parser.new
|
62
|
+
clippings = parser.parse_file('My Clippings.txt')
|
63
|
+
|
64
|
+
clippings.by_author('Malcolm Gladwell') # All annotations for all the books by Malcolm Gladwell
|
65
|
+
|
66
|
+
clippings.by_book('Born to Run') # All annotations for the book Born to Run
|
data/lib/clippingresult.rb
CHANGED
@@ -3,22 +3,30 @@ module KindleClippings
|
|
3
3
|
class ClippingResult < Array
|
4
4
|
|
5
5
|
def highlights
|
6
|
-
|
6
|
+
filter_by_property(:type, :Highlight)
|
7
7
|
end
|
8
8
|
|
9
9
|
def notes
|
10
|
-
|
10
|
+
filter_by_property(:type, :Note)
|
11
11
|
end
|
12
12
|
|
13
13
|
def bookmarks
|
14
|
-
|
14
|
+
filter_by_property(:type, :Bookmark)
|
15
|
+
end
|
16
|
+
|
17
|
+
def by_author(author)
|
18
|
+
filter_by_property(:author, author)
|
19
|
+
end
|
20
|
+
|
21
|
+
def by_book(book)
|
22
|
+
filter_by_property(:book_title, book)
|
15
23
|
end
|
16
24
|
|
17
25
|
private
|
18
26
|
|
19
|
-
def
|
20
|
-
return self unless
|
21
|
-
self.select { |
|
27
|
+
def filter_by_property(property, value)
|
28
|
+
return self unless value
|
29
|
+
self.select { |annotation| annotation.send(property).downcase == value.downcase }
|
22
30
|
end
|
23
31
|
|
24
32
|
end
|
data/lib/kindleclippings.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 1.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 1.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Georg Alexander Boe
|
@@ -14,13 +14,14 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-08-21 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
@@ -56,6 +57,7 @@ rdoc_options:
|
|
56
57
|
require_paths:
|
57
58
|
- lib
|
58
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
59
61
|
requirements:
|
60
62
|
- - ">="
|
61
63
|
- !ruby/object:Gem::Version
|
@@ -63,6 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
65
|
- 0
|
64
66
|
version: "0"
|
65
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
66
69
|
requirements:
|
67
70
|
- - ">="
|
68
71
|
- !ruby/object:Gem::Version
|
@@ -72,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
75
|
requirements: []
|
73
76
|
|
74
77
|
rubyforge_project:
|
75
|
-
rubygems_version: 1.3.
|
78
|
+
rubygems_version: 1.3.7
|
76
79
|
signing_key:
|
77
80
|
specification_version: 3
|
78
81
|
summary: A gem to parse Kindle's "My Clippings.txt" file into ruby objects.
|