cskit 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ac84566cea888ff9477e3bb701a61baf499aeee
4
- data.tar.gz: a9475fd9c7387d8d822f6b48f7e4a18356ff0a12
3
+ metadata.gz: 54b61172da1e6b1de7a0ce4965d4719291eb8d08
4
+ data.tar.gz: 9d32a03328acfa3c7b6210e1f3f25ce7401f3760
5
5
  SHA512:
6
- metadata.gz: 623a052e6de8426972d65aab3034a40682710fb1e7ab592b56dafb8f10322bc99252e0158975c8f8364a40ccee273564fd7af852641326e932e55a3a82a63446
7
- data.tar.gz: ce82b6aa1e550181d6c95ec10f72b62c3aba2a9f9ee0ffef27b34e77cfcdb808d6d71318169f4ef1814cfa69fbfa382413adb2716ca6d540d450decfba85e1cb
6
+ metadata.gz: 85b1a4e42f3d0582e022195c9c9e02efea87eb2115a327387c03ee3f8fff85dadd077980a5c4156665844494c7566fb832df48b57c41088224669f2f7087a7eb
7
+ data.tar.gz: 4463be21b3ccd6d5793843a3e0874aae3169747d6a3b8d3e17d0975f3d8016a2e0ade6d036461223f57de41aa80038392d8551ade516efca56b81c8399d61ab2
data/Gemfile CHANGED
@@ -7,5 +7,6 @@ group :test do
7
7
  end
8
8
 
9
9
  group :development, :test do
10
+ gem 'rake'
10
11
  gem 'pry-byebug'
11
12
  end
data/History.txt CHANGED
@@ -1,10 +1,20 @@
1
- == 1.0.0
1
+ == 1.2.0
2
2
 
3
- * Birthday!
3
+ * Fix several citation parsing issues.
4
+ -> Issue causing fragment like "I will" to be interpreted as a book name.
5
+ -> Issue causing NoMethodError in Science and Health plain text formatter.
6
+ Method name changed from `start_fragment` to `starter` in v1.1.0.
7
+ -> Issue causing NoMethodError when parsing Science and Health citations
8
+ because the `only?` method was not defined on any terminator, broken
9
+ since v1.1.0.
10
+ * Fix issue causing the Science and Health reader to only return the first
11
+ line for paragraph-based citations, eg 583:10.
12
+ * Fix incorrect parser invocation in Volume base class, broken since v1.1.0.
13
+ * Reminder: write some blasted tests :/
4
14
 
5
- == 1.0.1
15
+ == 1.1.1
6
16
 
7
- * Fix preface regex to detect pages starting at vii instead of vi for Science and Health.
17
+ * Fix bible parser to handle books like "II Chronicles" and "Song of Solomon".
8
18
 
9
19
  == 1.1.0
10
20
 
@@ -12,6 +22,10 @@
12
22
  * Add parser tests.
13
23
  * General cleanup.
14
24
 
15
- == 1.1.1
25
+ == 1.0.1
16
26
 
17
- * Fix bible parser to handle books like "II Chronicles" and "Song of Solomon".
27
+ * Fix preface regex to detect pages starting at vii instead of vi for Science and Health.
28
+
29
+ == 1.0.0
30
+
31
+ * Birthday!
data/cskit.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.version = ::CSKit::VERSION
9
9
  s.authors = ['Cameron Dutro']
10
10
  s.email = ['camertron@gmail.com']
11
- s.homepage = 'http://github.com/camertron'
11
+ s.homepage = 'http://github.com/CSOBerkeley/cskit-rb'
12
12
 
13
13
  s.description = s.summary = 'Christian Science citation library for Ruby.'
14
14
 
@@ -31,8 +31,8 @@ module CSKit
31
31
  line_text = line.text
32
32
 
33
33
  line_text = if line_index == 0
34
- if citation_line.start_fragment
35
- index = line_text.index(citation_line.start_fragment)
34
+ if citation_line.starter
35
+ index = line_text.index(citation_line.starter)
36
36
  index ? line_text[index..-1] : line_text
37
37
  else
38
38
  matches = line_text.match(SENTENCE_START_REGEX)
@@ -91,7 +91,18 @@ module CSKit
91
91
  end
92
92
 
93
93
  def book
94
- current.value.tap { next_token(:book, :sos, :text) }
94
+ text
95
+ end
96
+
97
+ def text
98
+ ''.tap do |result|
99
+ while current && current.type == :text
100
+ result << "#{current.value} "
101
+ next_token(:text)
102
+ end
103
+
104
+ result.strip!
105
+ end
95
106
  end
96
107
 
97
108
  def chapter_list
@@ -173,8 +184,13 @@ module CSKit
173
184
 
174
185
  def positional
175
186
  card = cardinality
176
- fragment = current.value
177
- next_token(:text, :semicolon, :colon, :comma)
187
+ fragment = text
188
+
189
+ if fragment.empty?
190
+ fragment = current.value
191
+ next_token(:semicolon, :colon, :comma)
192
+ end
193
+
178
194
  Positional.new(card, fragment)
179
195
  end
180
196
 
@@ -6,8 +6,6 @@ module CSKit
6
6
 
7
7
  class BibleTokenizer < CSKit::Parsers::Tokenizer
8
8
  PATTERNS = {
9
- book: /\Ai{1,3}\s+[^\s\(\);:,]+/i,
10
- sos: /\Asong\s+of\s+solomon/i,
11
9
  left_paren: /\A\(/,
12
10
  right_paren: /\A\)/,
13
11
  dash: /\A-/,
@@ -28,7 +28,7 @@ module CSKit
28
28
  end
29
29
 
30
30
  str << ' (only)' if only?
31
- str << " #{start_fragment}" if start_fragment
31
+ str << " #{starter}" if starter
32
32
  str
33
33
  end
34
34
 
@@ -40,6 +40,10 @@ module CSKit
40
40
  terminator: terminator ? terminator.to_hash : nil
41
41
  }
42
42
  end
43
+
44
+ def only?
45
+ terminator && terminator.only?
46
+ end
43
47
  end
44
48
 
45
49
  class Positional
@@ -76,6 +80,9 @@ module CSKit
76
80
  end
77
81
 
78
82
  class FragmentTerminator < Positional
83
+ def only?
84
+ false
85
+ end
79
86
  end
80
87
 
81
88
  class OnlyTerminator
@@ -87,6 +94,10 @@ module CSKit
87
94
  { only: true }
88
95
  end
89
96
 
97
+ def only?
98
+ true
99
+ end
100
+
90
101
  private def initialize
91
102
  end
92
103
  end
@@ -82,14 +82,14 @@ module CSKit
82
82
 
83
83
  def readings_for(citation)
84
84
  citation.lines.map do |citation_line|
85
- lines = if citation_line.finish
86
- get_line_range(citation_line.start..citation_line.finish, citation.page)
87
- else
85
+ lines = if citation_line.start == citation_line.finish
88
86
  if citation_line.only?
89
87
  [get_line(citation_line.start, citation.page)]
90
88
  else
91
89
  get_paragraph(citation.page, citation_line.start).lines
92
90
  end
91
+ else
92
+ get_line_range(citation_line.start..citation_line.finish, citation.page)
93
93
  end
94
94
 
95
95
  Reading.new(lines, citation_line)
data/lib/cskit/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module CSKit
4
- VERSION = '1.1.1'
4
+ VERSION = '1.2.0'
5
5
  end
data/lib/cskit/volume.rb CHANGED
@@ -10,17 +10,13 @@ module CSKit
10
10
  end
11
11
 
12
12
  def parse_citation(citation_text)
13
- parser.parse(citation_text).to_object
13
+ config[:parser].new(citation_text).parse
14
14
  end
15
15
 
16
16
  def readings_for(citation)
17
17
  reader.readings_for(citation)
18
18
  end
19
19
 
20
- def parser
21
- @parser ||= config[:parser].new
22
- end
23
-
24
20
  def reader
25
21
  @reader ||= config[:reader].new(self)
26
22
  end
@@ -230,4 +230,26 @@ describe BibleParser do
230
230
  })
231
231
  end
232
232
  end
233
+
234
+ context 'multiple verses with multi-word starters' do
235
+ let(:citation_text) { 'John 14:12-14, 16-21 I will, 25-27 (to 1st .)' }
236
+
237
+ it 'parses correctly' do
238
+ expect(parser.parse.to_hash).to eq({
239
+ book: 'John', chapters: [{
240
+ chapter_number: 14, verses: [{
241
+ start: 12, finish: 14, terminator: nil, starter: nil
242
+ }, {
243
+ start: 16, finish: 21, terminator: nil, starter: {
244
+ fragment: 'I will', cardinality: 1
245
+ }
246
+ }, {
247
+ start: 25, finish: 27, starter: nil, terminator: {
248
+ fragment: '.', cardinality: 1
249
+ }
250
+ }]
251
+ }]
252
+ })
253
+ end
254
+ end
233
255
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cskit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-06 00:00:00.000000000 Z
11
+ date: 2017-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -74,7 +74,7 @@ files:
74
74
  - spec/parsers/bible/bible_parser_spec.rb
75
75
  - spec/parsers/science_health/science_health_parser_spec.rb
76
76
  - spec/spec_helper.rb
77
- homepage: http://github.com/camertron
77
+ homepage: http://github.com/CSOBerkeley/cskit-rb
78
78
  licenses: []
79
79
  metadata: {}
80
80
  post_install_message:
@@ -93,9 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.2.3
96
+ rubygems_version: 2.6.13
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Christian Science citation library for Ruby.
100
100
  test_files: []
101
- has_rdoc: true