klipbook 0.2.0 → 0.2.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.md +6 -2
- data/klipbook.gemspec +2 -2
- data/lib/klipbook/clippings_parser.rb +3 -3
- data/lib/klipbook/version.rb +1 -1
- data/spec/lib/klipbook/clippings_parser_spec.rb +123 -0
- metadata +31 -31
data/README.md
CHANGED
@@ -36,13 +36,17 @@ Klipbook is a Ruby gem. To install simply run:
|
|
36
36
|
|
37
37
|
Currently [the Amazon highlights site](https://kindle.amazon.com/your_highlights) only shows clippings for books you've purchased on Amazon.
|
38
38
|
|
39
|
+
## Supported Devices
|
40
|
+
|
41
|
+
Klipbook has been tested on clippings files from 3rd generation Kindles and the Kindle Touch.
|
42
|
+
|
39
43
|
## Tested platforms
|
40
44
|
|
41
|
-
Klipbook has been tested on
|
45
|
+
Klipbook has been tested on Mac OSX Lion and Ubuntu using MRI 1.9.3.
|
42
46
|
|
43
47
|
## Contributing to Klipbook
|
44
48
|
|
45
|
-
Fork the project on [Github](https://github.com/grassdog/klipbook) and submit a pull request.
|
49
|
+
Fork the project on [Github](https://github.com/grassdog/klipbook), add tests for your changes, and submit a well described pull request.
|
46
50
|
|
47
51
|
## Copyright
|
48
52
|
|
data/klipbook.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "klipbook"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ray Grasso"]
|
12
|
-
s.date = "2011-12-
|
12
|
+
s.date = "2011-12-27"
|
13
13
|
s.description = "Process your Kindle clippings file to generate a nicely formatted compilation of the clippings of the books you've read"
|
14
14
|
s.email = "ray.grasso@gmail.com"
|
15
15
|
s.executables = ["klipbook"]
|
@@ -58,7 +58,7 @@ module Klipbook
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def extract_type(metadata)
|
61
|
-
type = metadata.scan(/^- (\w+)/).first
|
61
|
+
type = metadata.scan(/^-( Your)? (\w+)/).first[1]
|
62
62
|
type.downcase.to_sym
|
63
63
|
end
|
64
64
|
|
@@ -67,11 +67,11 @@ module Klipbook
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def extract_location(metadata)
|
70
|
-
match = metadata.scan(/Loc
|
70
|
+
match = metadata.scan(/Loc(ation|\.) ([0-9]+-?)/)
|
71
71
|
|
72
72
|
return nil if match.empty?
|
73
73
|
|
74
|
-
location = match.first
|
74
|
+
location = match.first[1]
|
75
75
|
location.to_i
|
76
76
|
end
|
77
77
|
|
data/lib/klipbook/version.rb
CHANGED
@@ -75,6 +75,24 @@ describe Klipbook::ClippingsParser do
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
context 'on a 4th-generation highlight' do
|
79
|
+
let (:content) do
|
80
|
+
"Book title\n" +
|
81
|
+
"- Your Highlight Location 466-69 | Added on Thursday, April 21, 2011, 07:31 AM\n" +
|
82
|
+
"\n" +
|
83
|
+
"The first line of the highlight\n" +
|
84
|
+
"The second line of the highlight"
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'marks the clipping as a highlight' do
|
88
|
+
subject[:type].should == :highlight
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'extracts the highlighted text' do
|
92
|
+
subject[:text].should == "The first line of the highlight\nThe second line of the highlight"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
78
96
|
context 'on a note' do
|
79
97
|
let (:content) do
|
80
98
|
"Book title\n" +
|
@@ -92,6 +110,23 @@ describe Klipbook::ClippingsParser do
|
|
92
110
|
end
|
93
111
|
end
|
94
112
|
|
113
|
+
context 'on a 4th-generation note' do
|
114
|
+
let (:content) do
|
115
|
+
"Book title\n" +
|
116
|
+
"- Your Note Location 623 | Added on Thursday, April 21, 2011, 07:31 AM\n" +
|
117
|
+
"\n" +
|
118
|
+
"The note text"
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'marks the clipping as a note' do
|
122
|
+
subject[:type].should == :note
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'extracts the note text' do
|
126
|
+
subject[:text].should == "The note text"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
95
130
|
context 'on a bookmark' do
|
96
131
|
let (:content) do
|
97
132
|
"Book title\n" +
|
@@ -109,6 +144,23 @@ describe Klipbook::ClippingsParser do
|
|
109
144
|
end
|
110
145
|
end
|
111
146
|
|
147
|
+
context 'on a 4th-generation bookmark' do
|
148
|
+
let (:content) do
|
149
|
+
"Book title\n" +
|
150
|
+
"- Your Bookmark on Page 1 | Location 406 | Added on Thursday, April 21, 2011, 07:31 AM\n" +
|
151
|
+
"\n" +
|
152
|
+
"\n"
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'marks the clipping as a bookmark' do
|
156
|
+
subject[:type].should == :bookmark
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'extracts empty text' do
|
160
|
+
subject[:text].should == ''
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
112
164
|
context 'on a clipping with a single location value' do
|
113
165
|
let (:content) do
|
114
166
|
"Book title\n" +
|
@@ -127,6 +179,24 @@ describe Klipbook::ClippingsParser do
|
|
127
179
|
end
|
128
180
|
end
|
129
181
|
|
182
|
+
context 'on a 4th-generation clipping with a single location value' do
|
183
|
+
let (:content) do
|
184
|
+
"Book title\n" +
|
185
|
+
"- Your Highlight Location 465 | Added on Thursday, April 21, 2011, 07:31 AM\n" +
|
186
|
+
"\n" +
|
187
|
+
"The first line of the highlight\n" +
|
188
|
+
"The second line of the highlight"
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'extracts the location' do
|
192
|
+
subject[:location].should == 465
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'extracts the added_on date' do
|
196
|
+
subject[:added_on].should == 'Thursday, April 21, 2011, 07:31 AM'
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
130
200
|
context 'on a clipping with a location range' do
|
131
201
|
let (:content) do
|
132
202
|
"Book title\n" +
|
@@ -145,6 +215,24 @@ describe Klipbook::ClippingsParser do
|
|
145
215
|
end
|
146
216
|
end
|
147
217
|
|
218
|
+
context 'on a 4th-generation clipping with a location range' do
|
219
|
+
let (:content) do
|
220
|
+
"Book title\n" +
|
221
|
+
"- Your Highlight Location 466-69 | Added on Thursday, April 21, 2011, 07:31 AM\n" +
|
222
|
+
"\n" +
|
223
|
+
"The first line of the highlight\n" +
|
224
|
+
"The second line of the highlight"
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'extracts the first element of the location range' do
|
228
|
+
subject[:location].should == 466
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'extracts the added_on date' do
|
232
|
+
subject[:added_on].should == 'Thursday, April 21, 2011, 07:31 AM'
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
148
236
|
context 'on a highlight with a page number and location range' do
|
149
237
|
let (:content) do
|
150
238
|
"Book title\n" +
|
@@ -163,6 +251,24 @@ describe Klipbook::ClippingsParser do
|
|
163
251
|
end
|
164
252
|
end
|
165
253
|
|
254
|
+
context 'on a 4th-generation highlight with a page number and location range' do
|
255
|
+
let (:content) do
|
256
|
+
"Book title\n" +
|
257
|
+
"- Your Highlight on Page 171 | Location 1858-59 | Added on Thursday, April 21, 2011, 07:31 AM\n" +
|
258
|
+
"\n" +
|
259
|
+
"Some highlighted text\n" +
|
260
|
+
"\n"
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'extracts the first element of the location range' do
|
264
|
+
subject[:location].should == 1858
|
265
|
+
end
|
266
|
+
|
267
|
+
it 'extracts the date' do
|
268
|
+
subject[:added_on].should == 'Thursday, April 21, 2011, 07:31 AM'
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
166
272
|
context 'on a highlight with a page number and no location' do
|
167
273
|
let (:content) do
|
168
274
|
"Book title\n" +
|
@@ -179,6 +285,23 @@ describe Klipbook::ClippingsParser do
|
|
179
285
|
subject[:added_on].should == 'Thursday, April 21, 2011, 07:31 AM'
|
180
286
|
end
|
181
287
|
end
|
288
|
+
|
289
|
+
context 'on a 4th-generation highlight with a page number and no location' do
|
290
|
+
let (:content) do
|
291
|
+
"Book title\n" +
|
292
|
+
"- Your Highlight on Page 9 | Added on Thursday, April 21, 2011, 07:31 AM\n" +
|
293
|
+
"\n" +
|
294
|
+
"Clipping"
|
295
|
+
end
|
296
|
+
|
297
|
+
it 'extracts no location' do
|
298
|
+
subject[:location].should be_nil
|
299
|
+
end
|
300
|
+
|
301
|
+
it 'extracts the date' do
|
302
|
+
subject[:added_on].should == 'Thursday, April 21, 2011, 07:31 AM'
|
303
|
+
end
|
304
|
+
end
|
182
305
|
end
|
183
306
|
|
184
307
|
describe '#build_clipping_from' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: klipbook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.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: 2011-12-
|
12
|
+
date: 2011-12-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70138331394120 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70138331394120
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70138331393620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70138331393620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rr
|
38
|
-
requirement: &
|
38
|
+
requirement: &70138331392640 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70138331392640
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70138331391540 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70138331391540
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &70138331390420 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.6.4
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70138331390420
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rcov
|
71
|
-
requirement: &
|
71
|
+
requirement: &70138331389020 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70138331389020
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: cucumber
|
82
|
-
requirement: &
|
82
|
+
requirement: &70138331387100 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70138331387100
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: guard
|
93
|
-
requirement: &
|
93
|
+
requirement: &70138331385960 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70138331385960
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: guard-rspec
|
104
|
-
requirement: &
|
104
|
+
requirement: &70138331385220 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70138331385220
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: guard-cucumber
|
115
|
-
requirement: &
|
115
|
+
requirement: &70138331384540 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70138331384540
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: rb-inotify
|
126
|
-
requirement: &
|
126
|
+
requirement: &70138331383720 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70138331383720
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: rb-fsevent
|
137
|
-
requirement: &
|
137
|
+
requirement: &70138331380640 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: '0'
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *70138331380640
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: rb-fchange
|
148
|
-
requirement: &
|
148
|
+
requirement: &70138331378720 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,10 +153,10 @@ dependencies:
|
|
153
153
|
version: '0'
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *70138331378720
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: growl_notify
|
159
|
-
requirement: &
|
159
|
+
requirement: &70138331376960 !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
162
162
|
- - ! '>='
|
@@ -164,7 +164,7 @@ dependencies:
|
|
164
164
|
version: '0'
|
165
165
|
type: :development
|
166
166
|
prerelease: false
|
167
|
-
version_requirements: *
|
167
|
+
version_requirements: *70138331376960
|
168
168
|
description: Process your Kindle clippings file to generate a nicely formatted compilation
|
169
169
|
of the clippings of the books you've read
|
170
170
|
email: ray.grasso@gmail.com
|
@@ -224,7 +224,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
224
224
|
version: '0'
|
225
225
|
segments:
|
226
226
|
- 0
|
227
|
-
hash:
|
227
|
+
hash: -915464957452187253
|
228
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
229
|
none: false
|
230
230
|
requirements:
|