kjlite 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/kjlite.rb +24 -21
  4. data.tar.gz.sig +0 -0
  5. metadata +29 -28
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5cde0f8d3eddc5f53ac438664f8429ccb1ac40b98264a5bb362dcb468b8572f
4
- data.tar.gz: 556f581983938d18ac256f622485ebab6a22c98692221460288032e96067a931
3
+ metadata.gz: d9828f3ba1ba9e27da83bdd6f1bf8d9c68736fc716ad520201a4c97d3cd47003
4
+ data.tar.gz: 62e27f180ddf0603f06352ebef55495314fec8fe8e095ca950ea9ee035d5d7f0
5
5
  SHA512:
6
- metadata.gz: 8c26d4b31d50b8b52e627e933b2bb67ef7c7fb60c67eae09ed8b00b3683b1523be5dd1250e62dfa4293ab1af86891d31f560c94bb2b2a9e2bedaf698e82d6a12
7
- data.tar.gz: 891e58b74defaeca770ce2bbaeed0cc6222741e19584b650e14633d03afb5bf8e0d316c4c57db6bdf55c24c1746b58c829d1881cbb2bd45281238c551828b628
6
+ metadata.gz: 43cc29791deeea09d3f4eefc64c150b545d6821f3e47e84089b999e0a8079e1992f2c69b536d9779e2f6a11c21fd0a2e09057a3eaa43cfb8cbb882bdf662de74
7
+ data.tar.gz: b4b72cb2da6d3a5871eceb7824654d53b57ca677d56aa21f89502d04882a4c1bc17e0b6002dbb6de3be81494ad99ec347ccb1ddd896765d611d44da7f68b65a1
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/kjlite.rb CHANGED
@@ -24,7 +24,7 @@ module KjLite
24
24
  end
25
25
 
26
26
  def text()
27
- @verse[/^\d+:\d+:\d+\s+(.*)/m,1].gsub(/[\r\n]|\s\s/,'')
27
+ @verse[/^\d+:\d+:\d+\s+(.*)/m,1].gsub(/[\r\n\s]+/,' ').rstrip
28
28
  end
29
29
 
30
30
  def title()
@@ -53,11 +53,15 @@ module KjLite
53
53
  def verses(*list)
54
54
 
55
55
  puts 'inside verses' if @debug
56
+ puts '@verses: ' + @verses.inspect if @debug
56
57
 
57
58
  list = list.first.to_a if list.first.is_a? Range
58
59
 
59
60
  if list.empty? then
60
- return @verses.map.with_index {|x,i| Verse.new @book_name, @id, i+1, x}
61
+ return @verses.map.with_index do |x,i|
62
+ #puts 'x: ' + x.inspect
63
+ Verse.new @book_name, @id, i+1, x, debug: @debug
64
+ end
61
65
  elsif list.length < 2
62
66
  Verse.new @book_name, @id, list.first, @verses[list.first.to_i-1]
63
67
  else
@@ -129,7 +133,7 @@ module KjLite
129
133
 
130
134
  attr_reader :to_h, :to_s, :booklist
131
135
 
132
- def initialize(url='http://www.gutenberg.org/cache/epub/30/pg30.txt',
136
+ def initialize(url='https://gutenberg.org/cache/epub/30/pg30.txt',
133
137
  debug: false)
134
138
 
135
139
  filename, @debug = 'kjbible.txt', debug
@@ -137,14 +141,14 @@ module KjLite
137
141
  if File.exists?(filename) then
138
142
  s = File.read(filename)
139
143
  else
140
- s = open(url).read
144
+ s = URI.open(url).read
141
145
  File.write filename, s
142
146
  end
143
147
 
144
148
  s2 = s.split(/.*(?=^Book 01)/,3).last; 0
145
149
  a = s2.split(/.*(?=^Book \d+)/); 0
146
150
 
147
- h = a.inject({}) do |r,x|
151
+ @h = a.inject({}) do |r,x|
148
152
 
149
153
  title, body = x.match(/^Book \d+\s+([^\r]+)\s+(.*)/m).captures
150
154
 
@@ -153,14 +157,16 @@ module KjLite
153
157
  r.merge(title => a3[1..-1])
154
158
 
155
159
  end
156
-
160
+
161
+ #puts '@h: ' + @h.keys.inspect
162
+ =begin
157
163
  @h = h.group_by {|key, _| key[/\d*\s*(.*)/,1]}; 0
158
164
 
159
165
  @h.each do |key, value|
160
166
  @h[key] = value.length < 2 ? value.last.last : value.map(&:last)
161
167
  end
162
-
163
- @to_h, @to_s, @booklist = @h, s, h.keys
168
+ =end
169
+ @to_h, @to_s, @booklist = @h, s, @h.keys
164
170
 
165
171
  end
166
172
 
@@ -171,17 +177,13 @@ module KjLite
171
177
  index = ref.to_s[/^\d+$/] ? (ref.to_i - 1) : find_book(ref.downcase)
172
178
  puts 'index: ' + index.inspect if @debug
173
179
  title = @booklist[index]
174
- r = @h[title.sub(/^\d+\s+/,'')]
180
+ #r = @h[title.sub(/^\d+\s+/,'')]
181
+ r = @h[title]
175
182
 
176
183
  puts 'r: ' + r.class.inspect if @debug
177
184
 
178
- if r.length > 3 then
179
- Book.new index+1, title, r, debug: @debug
180
- else
181
- i = ref[/\d+/].to_i - 1
182
- a = r.map.with_index {|x,i| Book.new index+1, title, r[i], debug: @debug}
183
- a[i]
184
- end
185
+ Book.new index+1, title, r, debug: @debug
186
+
185
187
  end
186
188
 
187
189
  def inspect()
@@ -204,6 +206,8 @@ module KjLite
204
206
 
205
207
  def find_book(ref)
206
208
 
209
+ puts 'find_book/ref: ' + ref.inspect if @debug
210
+
207
211
  h = @booklist.inject({}) do |r,rawx|
208
212
 
209
213
  x = rawx.downcase
@@ -215,20 +219,19 @@ module KjLite
215
219
  NoVowels.compact(x.sub(/(\d)\s/,'\1')),
216
220
  NoVowels.compact(x.sub(/(\d)\s/,'\1-')),
217
221
  ]
218
- puts 'a3: ' + a3.inspect if @debug
222
+ #puts 'a3: ' + a3.inspect if @debug
219
223
  a3b = a3.uniq.abbrev.keys.reject {|x| x[/^\s*\d+$/] or x.length < 2}
220
224
  r.merge(rawx => a3b)
221
225
 
222
226
  end
223
- puts 'h: ' + h.inspect if @debug
227
+ #puts 'h: ' + h.inspect if @debug
224
228
  r = h.find {|key, val| val.grep(/#{ref}/).any? }
225
229
  r = h.find {|key, vl| vl.grep(/#{ref.sub(/\d+\s*/,'')}/).any? } unless r
226
- puts 'r: ' + r.inspect if @debug
227
- @booklist.index r.first
230
+ puts '_r: ' + r.inspect if @debug
231
+ @booklist.index r.first if r
228
232
 
229
233
  end
230
234
 
231
235
  end
232
236
 
233
237
  end
234
-
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kjlite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,32 +10,33 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkxMTEwMjI1ODIwWhcN
15
- MjAxMTA5MjI1ODIwWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCopv51
17
- GSwrFtZUTZpTIu7RGRwQ6Alj9l6deGz5fi8X8rBSYJdH0G//3O0ZReVmvNrWCHpT
18
- Wda7myeLOuSJglqPNbI9ECj4eO25TYm4GYnPUGcmH9D4zPF/Bi3WfEZqSKxnJ1pg
19
- FcABSvyE+NzUldKPONAYriTl5jTu/5rPwoyJD6TlhYbilbZtuB9E7A30umghbmFr
20
- SF3pnnJ10l4JNWxujL1o/UMrxJgn8hjca5PhPA/mEE1IUPwBQZGVzNLsosAPcqqq
21
- 7DPwD58wSExY7WrAgA7OQpeX8Arau5X2ccDIySWuBzejatnAfMca6SC1zcLaisXP
22
- UCxxTyGAonlucgyHsLEkGIIzFRILZmRSDVLiLTMBhLgTfR8dPhfRjhTyAPxi4sim
23
- MsWnZWV8CsjnS9a0rUpbtsXFwfYDtZPlZLjAX0uNIeR+/WpvZ7eAkF+KVXgEIZO1
24
- JlpVEXMlr72FcydMKzlTHZPJ5kItZzOhv4UMDXH1W069vyH/NagwWHHPS1kCAwEA
25
- Aa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cz56iPoe4m8sNIM1wpPCn8Gim0Aqb6rA
33
+ ToIWu8HKGZirK8lDNT1TnDAEfeieMeQE+ha3MycqPQjTUOffqd9jIKf8zMelIXXX
34
+ EDbY7W3a8ntMUSyX+3FD1k/JNGwgJ6hAIoEL1JklVBU0utqU+25IFkrwAzsGKzYX
35
+ wHsrBcLrEqKeQ4v6zBckiJcr+ibE19ycTKkwxjJtYMJBOA7VC62i1q132a+t6Co7
36
+ EALnBk6AgDlRDIbN+5DYzhfnTJ1Tjl8AktYuDKy5QnljJI1ywXdnUUQV4sbSUiIq
37
+ GLSnE26JTgh8Vx2YqZ7IisLxAR/yR2wdAG8=
37
38
  -----END CERTIFICATE-----
38
- date: 2019-11-10 00:00:00.000000000 Z
39
+ date: 2022-10-31 00:00:00.000000000 Z
39
40
  dependencies:
40
41
  - !ruby/object:Gem::Dependency
41
42
  name: novowels
@@ -58,7 +59,7 @@ dependencies:
58
59
  - !ruby/object:Gem::Version
59
60
  version: 0.1.3
60
61
  description:
61
- email: james@jamesrobertson.eu
62
+ email: digital.robertson@gmail.com
62
63
  executables: []
63
64
  extensions: []
64
65
  extra_rdoc_files: []
@@ -83,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
84
  - !ruby/object:Gem::Version
84
85
  version: '0'
85
86
  requirements: []
86
- rubygems_version: 3.0.3
87
+ rubygems_version: 3.3.7
87
88
  signing_key:
88
89
  specification_version: 4
89
90
  summary: kjlist is a lightweight version of the kj gem for accessing the King James
metadata.gz.sig CHANGED
Binary file