audio_book_creator 0.0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +2 -2
  4. data/CHANGELOG.md +24 -0
  5. data/Gemfile +3 -3
  6. data/README.md +9 -4
  7. data/audio_book_creator.gemspec +3 -3
  8. data/{bin → exe}/audio_book_creator +3 -0
  9. data/lib/audio_book_creator.rb +4 -2
  10. data/lib/audio_book_creator/binder.rb +2 -1
  11. data/lib/audio_book_creator/book_def.rb +2 -2
  12. data/lib/audio_book_creator/cached_hash.rb +1 -1
  13. data/lib/audio_book_creator/cascading_array.rb +8 -8
  14. data/lib/audio_book_creator/chapter.rb +1 -1
  15. data/lib/audio_book_creator/cli.rb +36 -29
  16. data/lib/audio_book_creator/conductor.rb +5 -3
  17. data/lib/audio_book_creator/defaulter.rb +41 -0
  18. data/lib/audio_book_creator/editor.rb +2 -3
  19. data/lib/audio_book_creator/page_db.rb +14 -8
  20. data/lib/audio_book_creator/page_def.rb +7 -15
  21. data/lib/audio_book_creator/runner.rb +5 -3
  22. data/lib/audio_book_creator/speaker.rb +1 -1
  23. data/lib/audio_book_creator/spider.rb +9 -28
  24. data/lib/audio_book_creator/surfer_def.rb +1 -5
  25. data/lib/audio_book_creator/url_filter.rb +1 -1
  26. data/lib/audio_book_creator/version.rb +1 -1
  27. data/lib/audio_book_creator/web_page.rb +49 -0
  28. data/run_mutant +89 -0
  29. data/spec/audio_book_creator/binder_spec.rb +3 -3
  30. data/spec/audio_book_creator/book_creator_spec.rb +2 -3
  31. data/spec/audio_book_creator/book_def_spec.rb +33 -22
  32. data/spec/audio_book_creator/cached_hash_spec.rb +4 -0
  33. data/spec/audio_book_creator/cli_spec.rb +189 -122
  34. data/spec/audio_book_creator/conductor_spec.rb +17 -6
  35. data/spec/audio_book_creator/defaulter_spec.rb +154 -0
  36. data/spec/audio_book_creator/editor_spec.rb +7 -7
  37. data/spec/audio_book_creator/page_db_spec.rb +73 -11
  38. data/spec/audio_book_creator/page_def_spec.rb +26 -40
  39. data/spec/audio_book_creator/speaker_spec.rb +2 -2
  40. data/spec/audio_book_creator/spider_spec.rb +10 -15
  41. data/spec/audio_book_creator/surfer_def_spec.rb +1 -4
  42. data/spec/audio_book_creator/url_filter_spec.rb +1 -1
  43. data/spec/audio_book_creator/web_page_spec.rb +65 -0
  44. data/spec/audio_book_creator_spec.rb +23 -0
  45. data/spec/spec_helper.rb +15 -12
  46. metadata +14 -20
@@ -2,16 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe AudioBookCreator::SurferDef do
4
4
  context "with parameters" do
5
- subject { described_class.new("host", 5, true, "database") }
6
- it { expect(subject.host).to eq("host") }
5
+ subject { described_class.new(5, true) }
7
6
  it { expect(subject.max).to eq(5) }
8
7
  it { expect(subject.regen_html).to be_truthy }
9
- it { expect(subject.cache_filename).to eq("database")}
10
8
  end
11
9
 
12
10
  context "with nils" do
13
11
  subject { described_class.new }
14
- it { expect(subject.host).to be_nil }
15
12
  it { expect(subject.regen_html).not_to be_truthy }
16
13
  end
17
14
  end
@@ -34,7 +34,7 @@ describe AudioBookCreator::UrlFilter do
34
34
  end
35
35
 
36
36
  context "visit with #extensions" do
37
- %w(/page / .html .php .jsp .htm).each do |ext|
37
+ %w(/page / .html .php .jsp .htm .cfm).each do |ext|
38
38
  it "visits page2#{ext}" do
39
39
  expect(subject.include?(uri("page2#{ext}"))).not_to be_truthy
40
40
  end
@@ -0,0 +1,65 @@
1
+ require "spec_helper"
2
+
3
+ describe AudioBookCreator::WebPage do
4
+ describe "#initialize" do
5
+ it "sets url" do
6
+ expect(described_class.new("url", nil).url).to eq("url")
7
+ end
8
+
9
+ it "sets body" do
10
+ expect(described_class.new(nil, "body").body).to eq("body")
11
+ end
12
+ end
13
+
14
+ describe "#css" do
15
+ subject { described_class.new("url", "<h1>body</h1><h2></h2><p>p1</p><p>p2</p>") }
16
+ it "fetches no element" do
17
+ expect(subject.css("title")).to eq([])
18
+ end
19
+
20
+ it "fetches blank element" do
21
+ expect(subject.css("h2")).to eq([""])
22
+ end
23
+
24
+ it "fetches single element" do
25
+ expect(subject.css("h1")).to eq(["body"])
26
+ end
27
+
28
+ it "fetches multi element" do
29
+ expect(subject.css("p text()")).to eq(%w(p1 p2))
30
+ end
31
+ end
32
+
33
+ describe "#links" do
34
+ let(:root) { uri("") }
35
+ let(:subject) { web_page(root, "title", "<a href='tgt1'>a</a><a href='tgt2'>a</a>")}
36
+
37
+ it { expect(subject.links('h1')).to be_empty}
38
+ it { expect(subject.links('a')).to eq(uri(%w(tgt1 tgt2))) }
39
+ end
40
+
41
+ context "#eql" do
42
+ subject { described_class.new("url", "body") }
43
+ it "should understand ==" do
44
+ expect(subject).to eq(Class.new(described_class).new("url", "body"))
45
+ end
46
+
47
+ it "should understand != nil" do
48
+ expect(subject).not_to eq(nil)
49
+ end
50
+
51
+ it "should understand != different class" do
52
+ expect(subject).not_to eq("abc")
53
+ end
54
+
55
+ it "should understand != url" do
56
+ expect(subject).not_to eq(described_class.new("url2", "body"))
57
+ end
58
+ end
59
+
60
+ describe ".map_urls" do
61
+ subject { described_class }
62
+ it { expect(subject.map_urls(site(%w(a b c#d)))).to eq(uri(%w(a b c))) }
63
+ it { expect(subject.map_urls(uri(%w(a b c#d)))).to eq(uri(%w(a b c))) }
64
+ end
65
+ end
@@ -22,4 +22,27 @@ describe AudioBookCreator do
22
22
  expect(subject.should_write?("x", false)).not_to be_truthy
23
23
  end
24
24
  end
25
+
26
+ context ".logger=" do
27
+ let(:log) { double("logger") }
28
+ it "sets logger" do
29
+ subject.logger=log
30
+ expect(subject.logger).to eq(log)
31
+ subject.logger=nil
32
+ end
33
+ end
34
+
35
+ context ".logger" do
36
+ before { subject.logger=nil }
37
+
38
+ it "logs to stdout" do
39
+ expect(STDOUT).to receive(:write).with(/logging message/)
40
+ subject.logger.error "logging message"
41
+ end
42
+
43
+ it "defaults to warning" do
44
+ # clear out the cache up front
45
+ expect(subject.logger.level).to eq(Logger::WARN)
46
+ end
47
+ end
25
48
  end
@@ -1,22 +1,20 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
 
3
- unless ENV['MUTANT']
4
- require "coveralls"
5
- require "simplecov"
6
- require "codeclimate-test-reporter"
3
+ # unless ENV['MUTANT']
4
+ # require "simplecov"
5
+ # require "codeclimate-test-reporter"
7
6
 
8
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
9
- Coveralls::SimpleCov::Formatter,
10
- SimpleCov::Formatter::HTMLFormatter,
11
- CodeClimate::TestReporter::Formatter
12
- ]
7
+ # SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
8
+ # SimpleCov::Formatter::HTMLFormatter,
9
+ # CodeClimate::TestReporter::Formatter
10
+ # ])
13
11
 
14
- end
12
+ # end
15
13
 
16
14
  require_relative "support/test_logger"
17
15
 
18
16
  begin
19
- require "pry"
17
+ require "byebug"
20
18
  rescue LoadError
21
19
  end
22
20
 
@@ -26,6 +24,11 @@ module SpecHelpers
26
24
  %(<a href="#{url}"#{clazz}>link</a>")
27
25
  end
28
26
 
27
+ def web_page(*args)
28
+ url = args.shift
29
+ AudioBookCreator::WebPage.new(url, page(*args))
30
+ end
31
+
29
32
  def page(title, *args)
30
33
  %(<html><head><title>#{title}</title></head>
31
34
  <body>#{Array(args).join(" ")}</body>
@@ -79,7 +82,7 @@ module SpecHelpers
79
82
  end
80
83
  end
81
84
 
82
- SimpleCov.start unless ENV['MUTANT']
85
+ # SimpleCov.start unless ENV['MUTANT']
83
86
 
84
87
  require 'audio_book_creator'
85
88
 
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audio_book_creator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keenan Brock
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2015-03-07 00:00:00.000000000 Z
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: sqlite3-ruby
14
+ name: sqlite3
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: coveralls
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: codeclimate-test-reporter
113
99
  requirement: !ruby/object:Gem::Requirement
@@ -135,12 +121,13 @@ files:
135
121
  - ".gitignore"
136
122
  - ".rspec"
137
123
  - ".travis.yml"
124
+ - CHANGELOG.md
138
125
  - Gemfile
139
126
  - LICENSE.txt
140
127
  - README.md
141
128
  - Rakefile
142
129
  - audio_book_creator.gemspec
143
- - bin/audio_book_creator
130
+ - exe/audio_book_creator
144
131
  - lib/audio_book_creator.rb
145
132
  - lib/audio_book_creator/binder.rb
146
133
  - lib/audio_book_creator/book_creator.rb
@@ -150,6 +137,7 @@ files:
150
137
  - lib/audio_book_creator/chapter.rb
151
138
  - lib/audio_book_creator/cli.rb
152
139
  - lib/audio_book_creator/conductor.rb
140
+ - lib/audio_book_creator/defaulter.rb
153
141
  - lib/audio_book_creator/editor.rb
154
142
  - lib/audio_book_creator/logging.rb
155
143
  - lib/audio_book_creator/page_db.rb
@@ -163,6 +151,8 @@ files:
163
151
  - lib/audio_book_creator/url_filter.rb
164
152
  - lib/audio_book_creator/version.rb
165
153
  - lib/audio_book_creator/web.rb
154
+ - lib/audio_book_creator/web_page.rb
155
+ - run_mutant
166
156
  - spec/audio_book_creator/binder_spec.rb
167
157
  - spec/audio_book_creator/book_creator_spec.rb
168
158
  - spec/audio_book_creator/book_def_spec.rb
@@ -171,6 +161,7 @@ files:
171
161
  - spec/audio_book_creator/chapter_spec.rb
172
162
  - spec/audio_book_creator/cli_spec.rb
173
163
  - spec/audio_book_creator/conductor_spec.rb
164
+ - spec/audio_book_creator/defaulter_spec.rb
174
165
  - spec/audio_book_creator/editor_spec.rb
175
166
  - spec/audio_book_creator/logging_spec.rb
176
167
  - spec/audio_book_creator/page_db_spec.rb
@@ -183,6 +174,7 @@ files:
183
174
  - spec/audio_book_creator/surfer_def_spec.rb
184
175
  - spec/audio_book_creator/url_filter_spec.rb
185
176
  - spec/audio_book_creator/version_spec.rb
177
+ - spec/audio_book_creator/web_page_spec.rb
186
178
  - spec/audio_book_creator/web_spec.rb
187
179
  - spec/audio_book_creator_spec.rb
188
180
  - spec/spec_helper.rb
@@ -207,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
199
  version: '0'
208
200
  requirements: []
209
201
  rubyforge_project:
210
- rubygems_version: 2.2.2
202
+ rubygems_version: 2.5.2
211
203
  signing_key:
212
204
  specification_version: 4
213
205
  summary: Create an audiobook from a url
@@ -220,6 +212,7 @@ test_files:
220
212
  - spec/audio_book_creator/chapter_spec.rb
221
213
  - spec/audio_book_creator/cli_spec.rb
222
214
  - spec/audio_book_creator/conductor_spec.rb
215
+ - spec/audio_book_creator/defaulter_spec.rb
223
216
  - spec/audio_book_creator/editor_spec.rb
224
217
  - spec/audio_book_creator/logging_spec.rb
225
218
  - spec/audio_book_creator/page_db_spec.rb
@@ -232,6 +225,7 @@ test_files:
232
225
  - spec/audio_book_creator/surfer_def_spec.rb
233
226
  - spec/audio_book_creator/url_filter_spec.rb
234
227
  - spec/audio_book_creator/version_spec.rb
228
+ - spec/audio_book_creator/web_page_spec.rb
235
229
  - spec/audio_book_creator/web_spec.rb
236
230
  - spec/audio_book_creator_spec.rb
237
231
  - spec/spec_helper.rb