kindleclippings 1.0.0 → 1.1.0
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 +30 -10
- data/lib/clippingresult.rb +25 -0
- data/lib/kindleclippings.rb +3 -3
- metadata +3 -2
data/README.markdown
CHANGED
@@ -5,11 +5,21 @@ Kindleclippings is a ruby library for parsing annotations created on your kindle
|
|
5
5
|
When you make annotations on a kindle, they are saved as a file called "My Clippings.txt" under the documents folder.
|
6
6
|
This library will parse these annotations/clippings and give you an array of ruby objects.
|
7
7
|
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
To install kindleclippings just run
|
11
|
+
|
12
|
+
% sudo gem install kindleclippings
|
13
|
+
|
8
14
|
## Usage
|
9
15
|
|
16
|
+
### Parsing
|
17
|
+
|
18
|
+
Parsing the `My Clippings.txt` file.
|
19
|
+
|
10
20
|
require 'kindleclippings'
|
11
21
|
|
12
|
-
parser = KindleClippings::
|
22
|
+
parser = KindleClippings::Parser.new
|
13
23
|
|
14
24
|
clippings = parser.parse_file('My Clippings.txt')
|
15
25
|
clipping = clippings.last
|
@@ -18,14 +28,24 @@ This library will parse these annotations/clippings and give you an array of rub
|
|
18
28
|
clipping.author # => "Berkun Scott"
|
19
29
|
clipping.type # => :Highlight
|
20
30
|
clipping.added_on # => #<DateTime: 2009-12-14T19:10:00+00:00 (353545963/144,0/1,2299161)>
|
21
|
-
clipping.content # => "Most people say \"umm\" and \"uhh\" when they speak. These are called filler sounds
|
31
|
+
clipping.content # => "Most people say \"umm\" and \"uhh\" when they speak. These are called filler sounds ..."
|
32
|
+
|
33
|
+
The annotations can also be parsed directly.
|
22
34
|
|
23
|
-
|
35
|
+
require 'kindleclippings'
|
36
|
+
|
37
|
+
parser = KindleClippings::Parser.new
|
38
|
+
clippings = parser.parse("the content you want to parse.")
|
39
|
+
|
40
|
+
### Retrieve only the information you care about
|
41
|
+
|
42
|
+
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.
|
24
43
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
44
|
+
require 'kindleclippings'
|
45
|
+
|
46
|
+
parser = KindleClippings::Parser.new
|
47
|
+
clippings = parser.parse_file('My Clippings.txt')
|
48
|
+
|
49
|
+
clippings.notes # All the notes
|
50
|
+
clippings.highlights # All the highlights
|
51
|
+
clippings.bookmarks # All the bookmarks
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module KindleClippings
|
2
|
+
|
3
|
+
class ClippingResult < Array
|
4
|
+
|
5
|
+
def highlights
|
6
|
+
filter_by_type(:Highlight)
|
7
|
+
end
|
8
|
+
|
9
|
+
def notes
|
10
|
+
filter_by_type(:Note)
|
11
|
+
end
|
12
|
+
|
13
|
+
def bookmarks
|
14
|
+
filter_by_type(:Bookmark)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def filter_by_type(type)
|
20
|
+
return self unless type
|
21
|
+
self.select { |item| item.type == type }
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/lib/kindleclippings.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module KindleClippings
|
3
3
|
|
4
|
-
class
|
5
|
-
require File.expand_path(File.dirname(__FILE__) + '/
|
4
|
+
class Parser
|
5
|
+
['clipping', 'clippingresult'].each { |file| require File.expand_path(File.dirname(__FILE__) + '/' + file) }
|
6
6
|
|
7
7
|
def parse_file(path)
|
8
8
|
parse(open(path).read)
|
9
9
|
end
|
10
10
|
|
11
11
|
def parse(filecontent)
|
12
|
-
@clippings =
|
12
|
+
@clippings = ClippingResult.new
|
13
13
|
|
14
14
|
filecontent.split("=" * 10).each do |clipping|
|
15
15
|
|
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.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Georg Alexander Boe
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-09 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -33,6 +33,7 @@ extra_rdoc_files:
|
|
33
33
|
- README.markdown
|
34
34
|
files:
|
35
35
|
- lib/clipping.rb
|
36
|
+
- lib/clippingresult.rb
|
36
37
|
- lib/kindleclippings.rb
|
37
38
|
- LICENSE
|
38
39
|
- README.markdown
|