bomdb 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.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/README.md +2 -2
- data/bomdb.gemspec +1 -0
- data/data/book_of_mormon.db +0 -0
- data/lib/bomdb/cli/application.rb +21 -8
- data/lib/bomdb/query.rb +16 -5
- data/lib/bomdb/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd01b4bf2376536e016d15f732d330d173fb1d64
|
4
|
+
data.tar.gz: 3b3e5b8854ad7a4085da015c657ba864bb5bf695
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e46a8923ff7d502d18ac5eeb42f08ef8ba33a4d2eac3ebc4f57558b027a34848f6abf0a3c9d4330662ee5b4d661fa9e9aa282366bf0b0afc4d47d087e1c59cb
|
7
|
+
data.tar.gz: b186e70951e1dbf255cc9c9aa7c7c20be9ab74e9896f5766f71339534f2eb8f78fb736ab6d3cdad8cacc61a7e862ffbd00ad2de949c1f19f47410b9ab0d30a6b
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bomdb (0.1
|
4
|
+
bomdb (0.2.1)
|
5
5
|
colorize (~> 0.7)
|
6
6
|
constellation (~> 0.1)
|
7
7
|
sequel (~> 4.21)
|
8
8
|
sqlite3 (~> 1.3)
|
9
|
+
text_clean
|
9
10
|
thor (~> 0.19)
|
10
11
|
|
11
12
|
GEM
|
@@ -35,6 +36,7 @@ GEM
|
|
35
36
|
rspec-support (3.2.2)
|
36
37
|
sequel (4.21.0)
|
37
38
|
sqlite3 (1.3.10)
|
39
|
+
text_clean (0.2.2)
|
38
40
|
thor (0.19.1)
|
39
41
|
|
40
42
|
PLATFORMS
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# BomDB -- Book of Mormon DB
|
2
2
|
|
3
|
-
|
3
|
+
BomDB is a command-line tool (packaged as a Ruby gem) that provides multiple editions of the Book of Mormon in machine-readable form. At its heart is a sqlite3 database--data can be imported or exported using various formats and options.
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
@@ -27,7 +27,7 @@ Moroni 10:34 And now I bid unto all farewell. I soon go to rest in the paradise
|
|
27
27
|
Suppose we want to remove the book, chapter, and verse headings from the output:
|
28
28
|
|
29
29
|
```bash
|
30
|
-
$ bomdb show 1829 --no-
|
30
|
+
$ bomdb show 1829 --no-verses
|
31
31
|
|
32
32
|
I Nephi having been born of goodly parents, therefore I was taught somewhat in all the learning of my father...
|
33
33
|
# ... etc ...
|
data/bomdb.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency 'thor', '~> 0.19'
|
25
25
|
spec.add_dependency 'constellation', '~> 0.1'
|
26
26
|
spec.add_dependency 'colorize', '~> 0.7'
|
27
|
+
spec.add_dependency 'text_clean'
|
27
28
|
|
28
29
|
# spec.add_development_dependency 'bundler', '~> 1.7'
|
29
30
|
spec.add_development_dependency 'rake', '~> 10.0'
|
data/data/book_of_mormon.db
CHANGED
Binary file
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'bomdb'
|
3
3
|
require 'colorize'
|
4
|
+
require 'text_clean'
|
4
5
|
|
5
6
|
module BomDB
|
6
7
|
module Cli
|
@@ -111,7 +112,7 @@ module BomDB
|
|
111
112
|
|
112
113
|
|
113
114
|
desc "show EDITION RANGE", "show an edition of the Book of Mormon, or a RANGE of verses"
|
114
|
-
option :
|
115
|
+
option :verses, :type => :boolean, :default => true,
|
115
116
|
:description => "show book, chapter, verse annotations"
|
116
117
|
option :exclude, :type => :string, :aliases => [:x],
|
117
118
|
:description => "exclude verses that are references, e.g. Bible-OT references"
|
@@ -123,18 +124,30 @@ module BomDB
|
|
123
124
|
:description => "show chapter and verse in color"
|
124
125
|
option :"for-alignment", :type => :boolean, :default => false,
|
125
126
|
:description => "show output in 'alignment' mode. Useful for debugging 'align' subcommand issues."
|
126
|
-
|
127
|
+
option :clean, :type => :boolean, :default => false,
|
128
|
+
:description => "remove punctuation and normalize text by sentence"
|
129
|
+
def show(edition = '1992', range = nil)
|
127
130
|
body_format = nil
|
131
|
+
wordsep = options[:sep]
|
132
|
+
linesep = options[:linesep]
|
133
|
+
|
128
134
|
if options[:"for-alignment"]
|
129
135
|
linesep = " "
|
130
136
|
verse_format = verse_format_for_alignment(options[:color])
|
137
|
+
elsif options[:clean]
|
138
|
+
linesep = " "
|
139
|
+
verse_format = lambda{ |b,c,v| '' }
|
140
|
+
body_format = lambda do |body|
|
141
|
+
TextClean.clean(body)
|
142
|
+
end
|
131
143
|
else
|
132
|
-
|
133
|
-
if options[:verse]
|
144
|
+
if options[:verses]
|
134
145
|
if options[:color]
|
135
|
-
verse_format = lambda
|
136
|
-
|
137
|
-
|
146
|
+
verse_format = lambda do |b,c,v|
|
147
|
+
b.colorize(:yellow) + wordsep +
|
148
|
+
c.to_s.colorize(:green) + ':' +
|
149
|
+
v.to_s.colorize(:light_green)
|
150
|
+
end
|
138
151
|
else
|
139
152
|
verse_format = nil
|
140
153
|
end
|
@@ -149,7 +162,7 @@ module BomDB
|
|
149
162
|
).print(
|
150
163
|
verse_format: verse_format,
|
151
164
|
body_format: body_format,
|
152
|
-
sep:
|
165
|
+
sep: wordsep,
|
153
166
|
linesep: linesep
|
154
167
|
)
|
155
168
|
end
|
data/lib/bomdb/query.rb
CHANGED
@@ -23,7 +23,11 @@ module BomDB
|
|
23
23
|
select(:book_name, :verse_chapter, :verse_number, :content_body)
|
24
24
|
q.where!(:editions__edition_id => edition[:edition_id]) if @edition
|
25
25
|
q.where!(:verse_heading => nil) unless @headings
|
26
|
-
|
26
|
+
if @exclude
|
27
|
+
excluded_verse_ids = db[:refs].select(:verse_id).
|
28
|
+
where(:ref_name => @exclude.split(/\s*,\s*/))
|
29
|
+
q.exclude!(:verses__verse_id => excluded_verse_ids)
|
30
|
+
end
|
27
31
|
q
|
28
32
|
end
|
29
33
|
|
@@ -37,15 +41,22 @@ module BomDB
|
|
37
41
|
body_format ||= lambda{ |body| body + linesep }
|
38
42
|
query.each do |row|
|
39
43
|
shown = true
|
40
|
-
|
44
|
+
verse = verse_format[
|
41
45
|
row[:book_name],
|
42
46
|
row[:verse_chapter],
|
43
47
|
row[:verse_number]
|
44
48
|
]
|
45
|
-
|
46
|
-
|
49
|
+
unless verse.empty?
|
50
|
+
io.print verse
|
51
|
+
io.print sep
|
52
|
+
end
|
53
|
+
begin
|
54
|
+
io.print body_format[ row[:content_body] ]
|
55
|
+
rescue TypeError
|
56
|
+
next
|
57
|
+
end
|
47
58
|
end
|
48
|
-
io.puts "Nothing
|
59
|
+
io.puts "Nothing shown" unless shown
|
49
60
|
end
|
50
61
|
end
|
51
62
|
end
|
data/lib/bomdb/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bomdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Duane Johnson
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.7'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: text_clean
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|