pericope 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console +14 -0
- data/bin/pericope +1 -1
- data/lib/pericope.rb +33 -19
- data/lib/pericope/cli.rb +2 -2
- data/lib/pericope/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9520cfcbbe46071bc2f891a3eb1cd2c4790b88b
|
4
|
+
data.tar.gz: 06d8cc8008621dd923b08054a63cfb627f532f57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b8e7a0866232493e1bd8b36d80ff5baefa278df4f76129e6f130e56cc2a73b4190aa9ef26a2555399733c583f76315608d140ff6787fb91473a0b56af4757c2
|
7
|
+
data.tar.gz: 643ca5b7bdcd8fcaef115c2afd7c13a91c835c0d6b520422c90cdf63211570a124039bd223a832b5f8c0c972caef7ed70d10cc4211df37df817357488c7d0012
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pericope"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/pericope
CHANGED
data/lib/pericope.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require "pericope/version"
|
4
4
|
|
5
5
|
class Pericope
|
6
6
|
attr_reader :book,
|
@@ -54,7 +54,7 @@ class Pericope
|
|
54
54
|
|
55
55
|
|
56
56
|
def self.book_has_chapters?(book)
|
57
|
-
book_chapter_counts[book
|
57
|
+
book_chapter_counts[book] > 1
|
58
58
|
end
|
59
59
|
|
60
60
|
def book_has_chapters?
|
@@ -172,8 +172,8 @@ class Pericope
|
|
172
172
|
|
173
173
|
|
174
174
|
|
175
|
-
def to_s
|
176
|
-
"#{book_name} #{
|
175
|
+
def to_s(options={})
|
176
|
+
"#{book_name} #{well_formatted_reference(options)}"
|
177
177
|
end
|
178
178
|
|
179
179
|
|
@@ -209,19 +209,34 @@ class Pericope
|
|
209
209
|
|
210
210
|
|
211
211
|
|
212
|
-
def well_formatted_reference
|
212
|
+
def well_formatted_reference(options={})
|
213
213
|
recent_chapter = nil # e.g. in 12:1-8, remember that 12 is the chapter when we parse the 8
|
214
214
|
recent_chapter = 1 unless book_has_chapters?
|
215
|
-
|
215
|
+
|
216
|
+
verse_range_separator = options.fetch(:verse_range_separator, "–") # en-dash
|
217
|
+
chapter_range_separator = options.fetch(:chapter_range_separator, "—") # em-dash
|
218
|
+
verse_list_separator = options.fetch(:verse_list_separator, ", ")
|
219
|
+
chapter_list_separator = options.fetch(:chapter_list_separator, "; ")
|
220
|
+
always_print_verse_range = options.fetch(:always_print_verse_range, false)
|
221
|
+
|
222
|
+
s = ""
|
223
|
+
ranges.each_with_index do |range, i|
|
216
224
|
min_chapter = Pericope.get_chapter(range.begin)
|
217
225
|
min_verse = Pericope.get_verse(range.begin)
|
218
226
|
max_chapter = Pericope.get_chapter(range.end)
|
219
227
|
max_verse = Pericope.get_verse(range.end)
|
220
|
-
s = ""
|
221
228
|
|
222
|
-
if
|
229
|
+
if i > 0
|
230
|
+
if recent_chapter == min_chapter
|
231
|
+
s << verse_list_separator
|
232
|
+
else
|
233
|
+
s << chapter_list_separator
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
if min_verse == 1 && max_verse >= Pericope.get_max_verse(book, max_chapter) && !always_print_verse_range
|
223
238
|
s << min_chapter.to_s
|
224
|
-
s << "
|
239
|
+
s << "#{chapter_range_separator}#{max_chapter}" if max_chapter > min_chapter
|
225
240
|
else
|
226
241
|
if recent_chapter == min_chapter
|
227
242
|
s << min_verse.to_s
|
@@ -232,18 +247,17 @@ class Pericope
|
|
232
247
|
|
233
248
|
if range.count > 1
|
234
249
|
|
235
|
-
s << "-"
|
236
250
|
if min_chapter == max_chapter
|
237
|
-
s << max_verse
|
251
|
+
s << "#{verse_range_separator}#{max_verse}"
|
238
252
|
else
|
239
253
|
recent_chapter = max_chapter
|
240
|
-
s << "#{max_chapter}:#{max_verse}"
|
254
|
+
s << "#{chapter_range_separator}#{max_chapter}:#{max_verse}"
|
241
255
|
end
|
242
256
|
end
|
243
257
|
end
|
258
|
+
end
|
244
259
|
|
245
|
-
|
246
|
-
end.join(", ")
|
260
|
+
s
|
247
261
|
end
|
248
262
|
|
249
263
|
|
@@ -269,7 +283,7 @@ class Pericope
|
|
269
283
|
end
|
270
284
|
|
271
285
|
def self.get_max_chapter(book)
|
272
|
-
book_chapter_counts[book
|
286
|
+
book_chapter_counts[book]
|
273
287
|
end
|
274
288
|
|
275
289
|
|
@@ -280,8 +294,8 @@ private
|
|
280
294
|
|
281
295
|
def set_book(value)
|
282
296
|
@book = value || raise(ArgumentError, "must specify book")
|
283
|
-
@book_name = Pericope.book_names[@book
|
284
|
-
@book_chapter_count = Pericope.book_chapter_counts[@book
|
297
|
+
@book_name = Pericope.book_names[@book]
|
298
|
+
@book_chapter_count = Pericope.book_chapter_counts[@book]
|
285
299
|
end
|
286
300
|
|
287
301
|
|
@@ -482,7 +496,7 @@ private
|
|
482
496
|
current_book_id = nil
|
483
497
|
chapters = 0
|
484
498
|
@chapter_verse_counts = {}
|
485
|
-
@book_chapter_counts = []
|
499
|
+
@book_chapter_counts = [{}]
|
486
500
|
|
487
501
|
path = File.expand_path(File.dirname(__FILE__) + "/../data/chapter_verse_count.txt")
|
488
502
|
File.open(path) do |file|
|
@@ -522,7 +536,7 @@ private
|
|
522
536
|
# as the aforementioned book.
|
523
537
|
segments = text.chomp.split("\t")
|
524
538
|
book_id = segments.shift.to_i
|
525
|
-
@book_names[book_id
|
539
|
+
@book_names[book_id] = segments.shift
|
526
540
|
@book_name_regexes[book_id] = /\b(?:#{segments.join("|")})\b/
|
527
541
|
end
|
528
542
|
end
|
data/lib/pericope/cli.rb
CHANGED
data/lib/pericope/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pericope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Lail
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -106,6 +106,7 @@ extensions: []
|
|
106
106
|
extra_rdoc_files: []
|
107
107
|
files:
|
108
108
|
- README.mdown
|
109
|
+
- bin/console
|
109
110
|
- bin/pericope
|
110
111
|
- data/book_abbreviations.txt
|
111
112
|
- data/chapter_verse_count.txt
|