cskit 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZjI2YTAyZWQ5ZDVlMTQ0OGVmMDFmODEzMjAxNjExMjJlODMyNjk3MA==
5
- data.tar.gz: !binary |-
6
- OTExOGU2MjJjNTUyZWVkMDVlMzEzNGIyMjMwZGJkODYxOTRmYjIxNQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- Nzc4MDcyZWE1ZWU5ODg4MTJlNzJhYjU5NmQ2MTYwMWI4YTVlM2RiMjZmYTY5
10
- MmU5YTFhNjM5NzM4YTYxNWRiNDk5NmIxNWNhMzU4N2JmYzUxMGQxYTZlYjE2
11
- Mjc4MDhkZWUzODI5ZmI4N2Q1ZTk2NzdiNWUyNTlhNDJlOGJkN2E=
12
- data.tar.gz: !binary |-
13
- YzdmOGI5YmFkZjc0OTYzYmVmODJlNzEwYzI5MTkwYTdmYjQ4N2I0OGQ2NTI5
14
- YTNkY2JjZDEzYjNjZjEwZGNiMzMyZDllMmI5NzQ4MTI2YTBjNjAzYWFmODg5
15
- NzYyZWYwNWY5MjNhNDZjYmE1MjRlZDFjMjU4ZDQ5MThkOWNhNjU=
2
+ SHA1:
3
+ metadata.gz: b63a117f2cc1e418414654ab99412b9a70355c05
4
+ data.tar.gz: 59293273440f24aea1a23c80c6b96d845d601a12
5
+ SHA512:
6
+ metadata.gz: cd54044d09b723ccfd504dd87d9a44283df32ddd56905a40df1b0e36314368b04388c343e2d9190b175f2f786ecf0e89e2e824488fb72ff11bf808f2238d9b3f
7
+ data.tar.gz: 204c2eec966c773dfabb68a3e70a2778ef7811691238dbc26a01ce66f0bbf55651b943e6eebf4c1fd39ddda6f883027ad1889d980526a2fed6570e2ce3616ee0
data/Gemfile CHANGED
@@ -5,4 +5,4 @@ gemspec
5
5
  group :development do
6
6
  gem "pry"
7
7
  gem "pry-nav"
8
- end
8
+ end
@@ -1,3 +1,8 @@
1
1
  == 1.0.0
2
2
 
3
- * Birthday!
3
+ * Birthday!
4
+
5
+ == 1.0.1
6
+
7
+ * Fix preface regex to detect pages starting at vii instead of vi for Science and Health.
8
+
data/README.md CHANGED
@@ -8,6 +8,9 @@ CSKit is a citation parsing and retrieval toolkit for various Christian Science
8
8
  2. Science and Health with Key to the Scriptures ([cskit-shkts-rb](https://github.com/camertron/cskit-shkts-rb))
9
9
  3. Christian Science Hymnal ([cskit-hymnal-rb](https://github.com/camertron/cskit-hymnal-rb))
10
10
 
11
+ Clone all repositories with this handy one-liner:
12
+ `\curl -sSL http://bit.ly/1dyPu88 | bash -s`
13
+
11
14
  ## Installation
12
15
 
13
16
  `gem install cskit`, `gem install cskit-shkts`, etc
@@ -39,7 +39,7 @@ module CSKit
39
39
  annotated_str = CSKit::AnnotatedString.new(text, reading.annotations_at(index))
40
40
  annotated_str.delete(terminator_pos + 1, text.length - (terminator_pos + 1)) if terminator_pos
41
41
  annotated_str.delete(0, starter_pos) if starter_pos
42
-
42
+
43
43
  text = annotated_str.render do |snippet, annotation|
44
44
  annotation_formatter.format_annotation(annotation, snippet)
45
45
  end
@@ -9,7 +9,7 @@ module CSKit
9
9
  SENTENCE_TERMINATOR_REGEX = /[;\?\.]/
10
10
 
11
11
  # either a period + space, quotes, or start of line followed by the first capital letter or number.
12
- SENTENCE_START_REGEX = /(\.\s+|\.\"\s+|\.\'\s+|^)[A-Z0-9\"\']/
12
+ SENTENCE_START_REGEX = /(\.\s+|\.\"\s+|\.\'\s+|\?\s+|\!\s+|^)[A-Z0-9\"\']/
13
13
 
14
14
  def format_readings(readings)
15
15
  join(
@@ -6,6 +6,10 @@ module CSKit
6
6
 
7
7
  attr_reader :volume
8
8
 
9
+ Paragraph = Struct.new(
10
+ :lines, :line_start, :line_end, :page_start, :page_end
11
+ )
12
+
9
13
  def initialize(volume)
10
14
  @volume = volume
11
15
  end
@@ -22,34 +26,48 @@ module CSKit
22
26
  def each_line(line_number, page_number)
23
27
  while page = get_page(page_number)
24
28
  yield get_line(line_number, page_number), line_number, page_number
29
+ line_number, page_number = increment(line_number, page_number)
30
+ end
31
+ rescue Errno::ENOENT => e
32
+ end
25
33
 
26
- line_number, page_number = if (line_number + 1) > page.lines.size
27
- [1, next_page_number(page_number)]
28
- else
29
- [line_number + 1, page_number]
30
- end
34
+ # be careful - this will go all the way to the end of the book unless you break
35
+ def each_paragraph(line_number, page_number)
36
+ while paragraph = get_paragraph(page_number, line_number)
37
+ yield paragraph
38
+ line_number, page_number = increment(
39
+ paragraph.line_end, paragraph.page_end
40
+ )
31
41
  end
42
+ rescue Errno::ENOENT => e
32
43
  end
33
44
 
34
45
  def get_paragraph(page_number, line_number)
46
+ original_page_number = page_number
47
+ original_line_number = line_number
35
48
  first_line = true
36
49
  lines = []
37
50
 
38
- each_line(line_number, page_number) do |line, line_number, page_number|
51
+ each_line(line_number, page_number) do |cur_line, cur_line_number, cur_page_number|
39
52
  if first_line
40
- lines << line
53
+ lines << cur_line
41
54
  else
42
- if line.paragraph_start? && !first_line
55
+ if cur_line.paragraph_start? && !first_line
43
56
  break
44
57
  else
45
- lines << line
58
+ lines << cur_line
46
59
  end
47
60
  end
48
61
 
49
62
  first_line = false
63
+ line_number = cur_line_number
64
+ page_number = cur_page_number
50
65
  end
51
66
 
52
- lines
67
+ Paragraph.new(
68
+ lines, original_line_number, line_number,
69
+ original_page_number, page_number
70
+ )
53
71
  end
54
72
 
55
73
  def get_line_range(range, page_number)
@@ -69,7 +87,7 @@ module CSKit
69
87
  if citation_line.only?
70
88
  [get_line(citation_line.start, citation.page)]
71
89
  else
72
- get_paragraph(citation.page, citation_line.start)
90
+ get_paragraph(citation.page, citation_line.start).lines
73
91
  end
74
92
  end
75
93
 
@@ -79,6 +97,15 @@ module CSKit
79
97
 
80
98
  protected
81
99
 
100
+ def increment(line_number, page_number)
101
+ page = get_page(page_number)
102
+ if (line_number + 1) > page.lines.size
103
+ [1, next_page_number(page_number)]
104
+ else
105
+ [line_number + 1, page_number]
106
+ end
107
+ end
108
+
82
109
  def next_page_number(page_number)
83
110
  numerals = ["vi", "vii", "ix", "x", "xi", "xii"]
84
111
  if index = numerals.index(page_number)
@@ -88,7 +115,11 @@ module CSKit
88
115
  numerals[index + 1]
89
116
  end
90
117
  else
91
- (page_number.to_i + 1).to_s
118
+ if page_number == "497"
119
+ "501"
120
+ else
121
+ (page_number.to_i + 1).to_s
122
+ end
92
123
  end
93
124
  end
94
125
 
@@ -6,7 +6,7 @@ module CSKit
6
6
 
7
7
  Page = Struct.new(:number, :lines) do
8
8
  def preface?
9
- !!(number =~ /vi{1,3}|xi{1,2}|i{0,1}x/)
9
+ !!(number =~ /vi{2,3}|xi{1,2}|i{0,1}x/)
10
10
  end
11
11
 
12
12
  def to_hash
@@ -46,4 +46,4 @@ module CSKit
46
46
 
47
47
  end
48
48
  end
49
- end
49
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module CSKit
4
- VERSION = "1.0.0"
5
- end
4
+ VERSION = "1.0.1"
5
+ end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cskit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-10 00:00:00.000000000 Z
11
+ date: 2016-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: treetop
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: Christian Science citation library for Ruby.
@@ -59,18 +59,26 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - Gemfile
63
+ - History.txt
64
+ - LICENSE
65
+ - README.md
66
+ - Rakefile
67
+ - cskit.gemspec
68
+ - lib/cskit.rb
62
69
  - lib/cskit/annotated_string.rb
63
70
  - lib/cskit/annotator.rb
71
+ - lib/cskit/formatters.rb
72
+ - lib/cskit/formatters/bible.rb
64
73
  - lib/cskit/formatters/bible/bible_html_formatter.rb
65
74
  - lib/cskit/formatters/bible/bible_plain_text_formatter.rb
66
- - lib/cskit/formatters/bible.rb
75
+ - lib/cskit/formatters/science_health.rb
67
76
  - lib/cskit/formatters/science_health/science_health_html_formatter.rb
68
77
  - lib/cskit/formatters/science_health/science_health_plain_text_formatter.rb
69
- - lib/cskit/formatters/science_health.rb
70
- - lib/cskit/formatters.rb
78
+ - lib/cskit/lesson.rb
71
79
  - lib/cskit/lesson/lesson.rb
72
80
  - lib/cskit/lesson/section.rb
73
- - lib/cskit/lesson.rb
81
+ - lib/cskit/parsers.rb
74
82
  - lib/cskit/parsers/bible/bible.rb
75
83
  - lib/cskit/parsers/bible/bible.treetop
76
84
  - lib/cskit/parsers/bible/nodes.rb
@@ -79,23 +87,15 @@ files:
79
87
  - lib/cskit/parsers/science_health/objects.rb
80
88
  - lib/cskit/parsers/science_health/science_health.rb
81
89
  - lib/cskit/parsers/science_health/science_health.treetop
82
- - lib/cskit/parsers.rb
90
+ - lib/cskit/readers.rb
83
91
  - lib/cskit/readers/bible_reader.rb
84
92
  - lib/cskit/readers/reading.rb
85
93
  - lib/cskit/readers/science_health_reader.rb
86
- - lib/cskit/readers.rb
94
+ - lib/cskit/resources/volumes.rb
87
95
  - lib/cskit/resources/volumes/bible.rb
88
96
  - lib/cskit/resources/volumes/science_health.rb
89
- - lib/cskit/resources/volumes.rb
90
97
  - lib/cskit/version.rb
91
98
  - lib/cskit/volume.rb
92
- - lib/cskit.rb
93
- - Gemfile
94
- - History.txt
95
- - LICENSE
96
- - README.md
97
- - Rakefile
98
- - cskit.gemspec
99
99
  homepage: http://github.com/camertron
100
100
  licenses: []
101
101
  metadata: {}
@@ -105,18 +105,19 @@ require_paths:
105
105
  - lib
106
106
  required_ruby_version: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - ! '>='
113
+ - - ">="
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
117
  rubyforge_project:
118
- rubygems_version: 2.0.5
118
+ rubygems_version: 2.2.3
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: Christian Science citation library for Ruby.
122
122
  test_files: []
123
+ has_rdoc: true