klipbook 0.3.0 → 1.0.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/Gemfile +6 -5
- data/Gemfile.lock +62 -25
- data/Guardfile +1 -2
- data/README.md +66 -18
- data/Rakefile +5 -1
- data/bin/klipbook +85 -1
- data/example.png +0 -0
- data/features/collate.feature +51 -0
- data/features/fixtures/clippings-for-three-books.txt +105 -0
- data/features/list.feature +31 -0
- data/features/step_definitions/collate_steps.rb +61 -0
- data/features/step_definitions/list_steps.rb +15 -0
- data/features/support/env.rb +5 -1
- data/klipbook.gemspec +49 -32
- data/lib/klipbook/book.rb +18 -0
- data/lib/klipbook/clipping.rb +4 -10
- data/lib/klipbook/collator.rb +17 -0
- data/lib/klipbook/config.rb +22 -0
- data/lib/klipbook/fetcher.rb +29 -0
- data/lib/klipbook/invalid_source_error.rb +12 -0
- data/lib/klipbook/output/book_helpers.rb +12 -0
- data/lib/klipbook/{book_summary.erb → output/html_book_summary.erb} +65 -11
- data/lib/klipbook/output/html_summary_writer.rb +42 -0
- data/lib/klipbook/printer.rb +18 -0
- data/lib/klipbook/sources/amazon_site/book_scraper.rb +67 -0
- data/lib/klipbook/sources/amazon_site/scraper.rb +78 -0
- data/lib/klipbook/sources/kindle_device/entry.rb +11 -0
- data/lib/klipbook/sources/kindle_device/entry_parser.rb +85 -0
- data/lib/klipbook/sources/kindle_device/file.rb +57 -0
- data/lib/klipbook/sources/kindle_device/file_parser.rb +33 -0
- data/lib/klipbook/version.rb +1 -1
- data/lib/klipbook.rb +18 -5
- data/spec/lib/klipbook/book_spec.rb +33 -0
- data/spec/lib/klipbook/collator_spec.rb +40 -0
- data/spec/lib/klipbook/fetcher_spec.rb +81 -0
- data/spec/lib/klipbook/output/html_summary_writer_spec.rb +90 -0
- data/spec/lib/klipbook/printer_spec.rb +45 -0
- data/spec/lib/klipbook/sources/kindle_device/entry_parser_spec.rb +275 -0
- data/spec/lib/klipbook/sources/kindle_device/file_parser_spec.rb +68 -0
- data/spec/lib/klipbook/sources/kindle_device/file_spec.rb +163 -0
- metadata +158 -58
- data/features/list_books.feature +0 -23
- data/features/print_book_summary.feature +0 -10
- data/features/step_definitions/klipbook_steps.rb +0 -87
- data/lib/klipbook/book_summary.rb +0 -35
- data/lib/klipbook/cli.rb +0 -49
- data/lib/klipbook/clippings_file.rb +0 -50
- data/lib/klipbook/clippings_parser.rb +0 -98
- data/lib/klipbook/runner.rb +0 -29
- data/spec/lib/klipbook/book_summary_spec.rb +0 -30
- data/spec/lib/klipbook/clipping_spec.rb +0 -17
- data/spec/lib/klipbook/clippings_file_spec.rb +0 -60
- data/spec/lib/klipbook/clippings_parser_spec.rb +0 -367
- data/spec/lib/klipbook/runner_spec.rb +0 -87
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.
|
4
|
+
version: 1.0.0
|
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-09-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement:
|
15
|
+
name: gli
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,47 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: mechanize
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rainbow
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
25
62
|
- !ruby/object:Gem::Dependency
|
26
63
|
name: rspec
|
27
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
28
65
|
none: false
|
29
66
|
requirements:
|
30
67
|
- - ! '>='
|
@@ -32,10 +69,15 @@ dependencies:
|
|
32
69
|
version: '0'
|
33
70
|
type: :development
|
34
71
|
prerelease: false
|
35
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
36
78
|
- !ruby/object:Gem::Dependency
|
37
79
|
name: rr
|
38
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
39
81
|
none: false
|
40
82
|
requirements:
|
41
83
|
- - ! '>='
|
@@ -43,10 +85,15 @@ dependencies:
|
|
43
85
|
version: '0'
|
44
86
|
type: :development
|
45
87
|
prerelease: false
|
46
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
47
94
|
- !ruby/object:Gem::Dependency
|
48
95
|
name: bundler
|
49
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
50
97
|
none: false
|
51
98
|
requirements:
|
52
99
|
- - ! '>='
|
@@ -54,10 +101,15 @@ dependencies:
|
|
54
101
|
version: '0'
|
55
102
|
type: :development
|
56
103
|
prerelease: false
|
57
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
58
110
|
- !ruby/object:Gem::Dependency
|
59
111
|
name: jeweler
|
60
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
61
113
|
none: false
|
62
114
|
requirements:
|
63
115
|
- - ~>
|
@@ -65,10 +117,15 @@ dependencies:
|
|
65
117
|
version: 1.6.4
|
66
118
|
type: :development
|
67
119
|
prerelease: false
|
68
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 1.6.4
|
69
126
|
- !ruby/object:Gem::Dependency
|
70
127
|
name: rcov
|
71
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
72
129
|
none: false
|
73
130
|
requirements:
|
74
131
|
- - ! '>='
|
@@ -76,21 +133,15 @@ dependencies:
|
|
76
133
|
version: '0'
|
77
134
|
type: :development
|
78
135
|
prerelease: false
|
79
|
-
version_requirements:
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: cucumber
|
82
|
-
requirement: &70207424502720 !ruby/object:Gem::Requirement
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
137
|
none: false
|
84
138
|
requirements:
|
85
139
|
- - ! '>='
|
86
140
|
- !ruby/object:Gem::Version
|
87
141
|
version: '0'
|
88
|
-
type: :development
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: *70207424502720
|
91
142
|
- !ruby/object:Gem::Dependency
|
92
|
-
name:
|
93
|
-
requirement:
|
143
|
+
name: pry
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
94
145
|
none: false
|
95
146
|
requirements:
|
96
147
|
- - ! '>='
|
@@ -98,10 +149,15 @@ dependencies:
|
|
98
149
|
version: '0'
|
99
150
|
type: :development
|
100
151
|
prerelease: false
|
101
|
-
version_requirements:
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
102
158
|
- !ruby/object:Gem::Dependency
|
103
|
-
name:
|
104
|
-
requirement:
|
159
|
+
name: cucumber
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
105
161
|
none: false
|
106
162
|
requirements:
|
107
163
|
- - ! '>='
|
@@ -109,10 +165,15 @@ dependencies:
|
|
109
165
|
version: '0'
|
110
166
|
type: :development
|
111
167
|
prerelease: false
|
112
|
-
version_requirements:
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
113
174
|
- !ruby/object:Gem::Dependency
|
114
|
-
name:
|
115
|
-
requirement:
|
175
|
+
name: aruba
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
116
177
|
none: false
|
117
178
|
requirements:
|
118
179
|
- - ! '>='
|
@@ -120,10 +181,15 @@ dependencies:
|
|
120
181
|
version: '0'
|
121
182
|
type: :development
|
122
183
|
prerelease: false
|
123
|
-
version_requirements:
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
124
190
|
- !ruby/object:Gem::Dependency
|
125
|
-
name:
|
126
|
-
requirement:
|
191
|
+
name: guard
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
127
193
|
none: false
|
128
194
|
requirements:
|
129
195
|
- - ! '>='
|
@@ -131,10 +197,15 @@ dependencies:
|
|
131
197
|
version: '0'
|
132
198
|
type: :development
|
133
199
|
prerelease: false
|
134
|
-
version_requirements:
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ! '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
135
206
|
- !ruby/object:Gem::Dependency
|
136
|
-
name:
|
137
|
-
requirement:
|
207
|
+
name: guard-rspec
|
208
|
+
requirement: !ruby/object:Gem::Requirement
|
138
209
|
none: false
|
139
210
|
requirements:
|
140
211
|
- - ! '>='
|
@@ -142,10 +213,15 @@ dependencies:
|
|
142
213
|
version: '0'
|
143
214
|
type: :development
|
144
215
|
prerelease: false
|
145
|
-
version_requirements:
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ! '>='
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
146
222
|
- !ruby/object:Gem::Dependency
|
147
|
-
name:
|
148
|
-
requirement:
|
223
|
+
name: guard-cucumber
|
224
|
+
requirement: !ruby/object:Gem::Requirement
|
149
225
|
none: false
|
150
226
|
requirements:
|
151
227
|
- - ! '>='
|
@@ -153,10 +229,15 @@ dependencies:
|
|
153
229
|
version: '0'
|
154
230
|
type: :development
|
155
231
|
prerelease: false
|
156
|
-
version_requirements:
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
none: false
|
234
|
+
requirements:
|
235
|
+
- - ! '>='
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0'
|
157
238
|
- !ruby/object:Gem::Dependency
|
158
|
-
name:
|
159
|
-
requirement:
|
239
|
+
name: terminal-notifier-guard
|
240
|
+
requirement: !ruby/object:Gem::Requirement
|
160
241
|
none: false
|
161
242
|
requirements:
|
162
243
|
- - ! '>='
|
@@ -164,7 +245,12 @@ dependencies:
|
|
164
245
|
version: '0'
|
165
246
|
type: :development
|
166
247
|
prerelease: false
|
167
|
-
version_requirements:
|
248
|
+
version_requirements: !ruby/object:Gem::Requirement
|
249
|
+
none: false
|
250
|
+
requirements:
|
251
|
+
- - ! '>='
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: '0'
|
168
254
|
description: Process your Kindle clippings file to generate a nicely formatted compilation
|
169
255
|
of the clippings of the books you've read
|
170
256
|
email: ray.grasso@gmail.com
|
@@ -186,26 +272,40 @@ files:
|
|
186
272
|
- Rakefile
|
187
273
|
- bin/klipbook
|
188
274
|
- example.png
|
189
|
-
- features/
|
190
|
-
- features/
|
191
|
-
- features/
|
275
|
+
- features/collate.feature
|
276
|
+
- features/fixtures/clippings-for-three-books.txt
|
277
|
+
- features/list.feature
|
278
|
+
- features/step_definitions/collate_steps.rb
|
279
|
+
- features/step_definitions/list_steps.rb
|
192
280
|
- features/support/env.rb
|
193
281
|
- klipbook.gemspec
|
194
282
|
- lib/klipbook.rb
|
195
283
|
- lib/klipbook/blank.rb
|
196
|
-
- lib/klipbook/
|
197
|
-
- lib/klipbook/book_summary.rb
|
198
|
-
- lib/klipbook/cli.rb
|
284
|
+
- lib/klipbook/book.rb
|
199
285
|
- lib/klipbook/clipping.rb
|
200
|
-
- lib/klipbook/
|
201
|
-
- lib/klipbook/
|
202
|
-
- lib/klipbook/
|
286
|
+
- lib/klipbook/collator.rb
|
287
|
+
- lib/klipbook/config.rb
|
288
|
+
- lib/klipbook/fetcher.rb
|
289
|
+
- lib/klipbook/invalid_source_error.rb
|
290
|
+
- lib/klipbook/output/book_helpers.rb
|
291
|
+
- lib/klipbook/output/html_book_summary.erb
|
292
|
+
- lib/klipbook/output/html_summary_writer.rb
|
293
|
+
- lib/klipbook/printer.rb
|
294
|
+
- lib/klipbook/sources/amazon_site/book_scraper.rb
|
295
|
+
- lib/klipbook/sources/amazon_site/scraper.rb
|
296
|
+
- lib/klipbook/sources/kindle_device/entry.rb
|
297
|
+
- lib/klipbook/sources/kindle_device/entry_parser.rb
|
298
|
+
- lib/klipbook/sources/kindle_device/file.rb
|
299
|
+
- lib/klipbook/sources/kindle_device/file_parser.rb
|
203
300
|
- lib/klipbook/version.rb
|
204
|
-
- spec/lib/klipbook/
|
205
|
-
- spec/lib/klipbook/
|
206
|
-
- spec/lib/klipbook/
|
207
|
-
- spec/lib/klipbook/
|
208
|
-
- spec/lib/klipbook/
|
301
|
+
- spec/lib/klipbook/book_spec.rb
|
302
|
+
- spec/lib/klipbook/collator_spec.rb
|
303
|
+
- spec/lib/klipbook/fetcher_spec.rb
|
304
|
+
- spec/lib/klipbook/output/html_summary_writer_spec.rb
|
305
|
+
- spec/lib/klipbook/printer_spec.rb
|
306
|
+
- spec/lib/klipbook/sources/kindle_device/entry_parser_spec.rb
|
307
|
+
- spec/lib/klipbook/sources/kindle_device/file_parser_spec.rb
|
308
|
+
- spec/lib/klipbook/sources/kindle_device/file_spec.rb
|
209
309
|
- spec/spec_helper.rb
|
210
310
|
- spec/support/rspec2.rb
|
211
311
|
- spec/support/with_rr.rb
|
@@ -224,7 +324,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
224
324
|
version: '0'
|
225
325
|
segments:
|
226
326
|
- 0
|
227
|
-
hash:
|
327
|
+
hash: -434895124641263041
|
228
328
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
329
|
none: false
|
230
330
|
requirements:
|
@@ -233,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
333
|
version: '0'
|
234
334
|
requirements: []
|
235
335
|
rubyforge_project:
|
236
|
-
rubygems_version: 1.8.
|
336
|
+
rubygems_version: 1.8.23
|
237
337
|
signing_key:
|
238
338
|
specification_version: 3
|
239
339
|
summary: Klipbook creates a nice html summary of the clippings you've created on your
|
data/features/list_books.feature
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
Feature: klipbook lists the books in a clipping file
|
2
|
-
As an avid reader and note taker
|
3
|
-
I want to be shown an indexed list of books in my clipping file
|
4
|
-
So that I can choose which book I want to extract a pretty collated list of notes from
|
5
|
-
|
6
|
-
Scenario: Empty file
|
7
|
-
Given I have a file that contains no clippings
|
8
|
-
When I list the books in the file with klipbook
|
9
|
-
Then I should see the message "Your clippings file contains no books"
|
10
|
-
|
11
|
-
Scenario: File with one book
|
12
|
-
Given I have a file that contains clippings for the book titled "The life of dogs"
|
13
|
-
When I list the books in the file with klipbook
|
14
|
-
Then I should see the message "The list of books in your clippings file:"
|
15
|
-
And I should see the message "[1] The life of dogs"
|
16
|
-
|
17
|
-
Scenario: File with two books
|
18
|
-
Given I have a file that contains clippings for the book titled "The life of dogs"
|
19
|
-
And I have a file that contains clippings for the book titled "A hard day's night"
|
20
|
-
When I list the books in the file with klipbook
|
21
|
-
Then I should see the message "The list of books in your clippings file:"
|
22
|
-
And I should see the message "[1] A hard day's night"
|
23
|
-
And I should see the message "[2] The life of dogs"
|
@@ -1,10 +0,0 @@
|
|
1
|
-
Feature: klipbook outputs a pretty summary of the clippings for a book
|
2
|
-
As an avid reader and note taker
|
3
|
-
I want to see a pretty summary file of the clippings for a book
|
4
|
-
So that I can read a nice summary of my clippings for a book I've read
|
5
|
-
|
6
|
-
Scenario: File with clippings for a book
|
7
|
-
Given I have a file that contains multiple clippings for the book titled "The life of dogs"
|
8
|
-
When I print the summary for book number "1" with klipbook
|
9
|
-
Then I should see a pretty summary for the book "The life of dogs"
|
10
|
-
|
@@ -1,87 +0,0 @@
|
|
1
|
-
Before do
|
2
|
-
FileUtils.mkdir_p(TEST_DIR)
|
3
|
-
Dir.chdir(TEST_DIR)
|
4
|
-
end
|
5
|
-
|
6
|
-
After do
|
7
|
-
Dir.chdir(TEST_DIR)
|
8
|
-
FileUtils.rm_rf(TEST_DIR)
|
9
|
-
end
|
10
|
-
|
11
|
-
class Output
|
12
|
-
def messages
|
13
|
-
@messages ||= []
|
14
|
-
end
|
15
|
-
|
16
|
-
def puts(message)
|
17
|
-
messages << message
|
18
|
-
end
|
19
|
-
|
20
|
-
def write(message)
|
21
|
-
messages << message
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def output
|
26
|
-
@output ||= Output.new
|
27
|
-
end
|
28
|
-
|
29
|
-
CLIPPING_FILE = 'test_clippings.txt'
|
30
|
-
|
31
|
-
Given /^I have a file that contains no clippings$/ do
|
32
|
-
File.open(CLIPPING_FILE, 'w') do |f|
|
33
|
-
f.write ''
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
When /^I list the books in the file with klipbook$/ do
|
38
|
-
File.open(CLIPPING_FILE, 'r') do |f|
|
39
|
-
Klipbook::Runner.new(f).list_books(output)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
Then /^I should see the message "([^"]*)"$/ do |message|
|
44
|
-
output.messages.should include(message)
|
45
|
-
end
|
46
|
-
|
47
|
-
Given /^I have a file that contains clippings for the book titled "([^"]*)"$/ do |book_title|
|
48
|
-
File.open(CLIPPING_FILE, 'a') do |f|
|
49
|
-
f.write <<EOF
|
50
|
-
#{book_title}
|
51
|
-
- Highlight Loc. 466-69 | Added on Thursday, April 21, 2011, 07:31 AM
|
52
|
-
|
53
|
-
A test highlight
|
54
|
-
==========
|
55
|
-
EOF
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
Given /^I have a file that contains multiple clippings for the book titled "([^"]*)"$/ do |book_title|
|
60
|
-
File.open(CLIPPING_FILE, 'a') do |f|
|
61
|
-
f.write <<EOF
|
62
|
-
#{book_title}
|
63
|
-
- Highlight Loc. 466-69 | Added on Thursday, April 21, 2011, 07:31 AM
|
64
|
-
|
65
|
-
A test highlight
|
66
|
-
==========
|
67
|
-
#{book_title}
|
68
|
-
- Highlight Loc. 490 | Added on Thursday, April 21, 2011, 07:36 AM
|
69
|
-
|
70
|
-
A second highlight
|
71
|
-
==========
|
72
|
-
EOF
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
When /^I print the summary for book number "([^"]+)" with klipbook/ do |book_number|
|
77
|
-
book_number = book_number.to_i
|
78
|
-
|
79
|
-
File.open(CLIPPING_FILE, 'r') do |f|
|
80
|
-
Klipbook::Runner.new(f).print_book_summary(book_number, output)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
Then /^I should see a pretty summary for the book "([^"]*)"$/ do |book_title|
|
85
|
-
output.messages.first.should include("<h1>#{book_title}</h1")
|
86
|
-
end
|
87
|
-
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
|
-
module Klipbook
|
4
|
-
class BookSummary
|
5
|
-
attr_accessor :title, :author, :clippings
|
6
|
-
|
7
|
-
def initialize(title, author, clippings=[])
|
8
|
-
@title = title
|
9
|
-
@author = author
|
10
|
-
@clippings = clippings.sort
|
11
|
-
end
|
12
|
-
|
13
|
-
def hash
|
14
|
-
title.hash ^ author.hash
|
15
|
-
end
|
16
|
-
|
17
|
-
def eql?(other)
|
18
|
-
self == other
|
19
|
-
end
|
20
|
-
|
21
|
-
def ==(other)
|
22
|
-
return false unless other.instance_of?(self.class)
|
23
|
-
title == other.title && author == other.author
|
24
|
-
end
|
25
|
-
|
26
|
-
def as_html(options={})
|
27
|
-
include_pages = options[:include_pages]
|
28
|
-
ERB.new(template, 0, '%<>').result(binding)
|
29
|
-
end
|
30
|
-
|
31
|
-
def template
|
32
|
-
@template ||= File.read(File.join(File.dirname(__FILE__), 'book_summary.erb'))
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/lib/klipbook/cli.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
|
3
|
-
module Klipbook
|
4
|
-
class CLI < Thor
|
5
|
-
|
6
|
-
desc 'list CLIPPINGS_FILE', 'List the books in the clippings file'
|
7
|
-
def list(clippings_file=nil)
|
8
|
-
if (clippings_file.nil?)
|
9
|
-
puts 'Please provide a CLIPPINGS_FILE'
|
10
|
-
exit 1
|
11
|
-
end
|
12
|
-
|
13
|
-
clippings_file = ensure_clippings_file_exists(clippings_file)
|
14
|
-
|
15
|
-
Klipbook::Runner.new(clippings_file).list_books
|
16
|
-
end
|
17
|
-
|
18
|
-
desc 'summarise CLIPPINGS_FILE BOOK_NUMBER OUTPUT_FILE', 'Output an html summary of the clippings for a book'
|
19
|
-
method_option :include_pages, :aliases => '-p', :desc => 'Include page numbers in output when available'
|
20
|
-
def summarise(clippings_file=nil, book_number=nil, output_file=nil)
|
21
|
-
if (clippings_file.nil? or book_number.nil? or output_file.nil?)
|
22
|
-
puts 'Please provide a CLIPPINGS_FILE, BOOK_NUMBER, and OUTPUT_FILE'
|
23
|
-
exit 1
|
24
|
-
end
|
25
|
-
|
26
|
-
clippings_file = ensure_clippings_file_exists(clippings_file)
|
27
|
-
|
28
|
-
book_number = book_number.to_i
|
29
|
-
|
30
|
-
Klipbook::Runner.new(clippings_file).print_book_summary(book_number, File.open(output_file, 'w'), options)
|
31
|
-
end
|
32
|
-
|
33
|
-
map '-v' => :version
|
34
|
-
desc 'version', 'Display Klipbook version'
|
35
|
-
def version
|
36
|
-
puts "Klipbook #{Klipbook::VERSION}"
|
37
|
-
end
|
38
|
-
|
39
|
-
no_tasks do
|
40
|
-
def ensure_clippings_file_exists(clippings_file)
|
41
|
-
unless File.exist?(clippings_file)
|
42
|
-
$stderr.puts "Clippings file doesn't exist: #{clippings_file}"
|
43
|
-
exit 1
|
44
|
-
end
|
45
|
-
File.open(clippings_file, 'r')
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module Klipbook
|
2
|
-
class ClippingsFile
|
3
|
-
attr_accessor :books
|
4
|
-
|
5
|
-
def initialize(file_text, parser=Klipbook::ClippingsParser.new)
|
6
|
-
@books = extract_books_from_file_text(parser, file_text)
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def extract_books_from_file_text(parser, file_text)
|
12
|
-
clippings = parser.extract_clippings_from(file_text)
|
13
|
-
|
14
|
-
group_clippings_into_books(clippings)
|
15
|
-
end
|
16
|
-
|
17
|
-
def group_clippings_into_books(clippings)
|
18
|
-
books = clippings.inject({}) do |new_hash, clipping|
|
19
|
-
new_hash[hash_key_for_book(clipping)] ||= []
|
20
|
-
new_hash[hash_key_for_book(clipping)] << clipping
|
21
|
-
new_hash
|
22
|
-
end
|
23
|
-
|
24
|
-
books = sort_books_by_title(books)
|
25
|
-
books = sort_clippings_by_location(books)
|
26
|
-
build_book_summaries(books)
|
27
|
-
end
|
28
|
-
|
29
|
-
def build_book_summaries(books)
|
30
|
-
books.values.map { |clippings| Klipbook::BookSummary.new(clippings.first.title, clippings.first.author, clippings) }
|
31
|
-
end
|
32
|
-
|
33
|
-
def hash_key_for_book(clipping)
|
34
|
-
"#{clipping.title}#{clipping.author}"
|
35
|
-
end
|
36
|
-
|
37
|
-
def sort_books_by_title(books)
|
38
|
-
Hash[books.sort]
|
39
|
-
end
|
40
|
-
|
41
|
-
def sort_clippings_by_location(books)
|
42
|
-
books.inject({}) do |new_hash, (k, v)|
|
43
|
-
new_hash[k] = v.sort
|
44
|
-
new_hash
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
|