kj 0.0.8 → 0.0.9

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: 42a1e80beefbcf7e559c40b5ba4248e677029cbb
4
- data.tar.gz: c2daad390ff7d1f156524ca772186c4d969f16ca
3
+ metadata.gz: e45f86e95960f2689fd8ef651a3e27a0f2627e4f
4
+ data.tar.gz: b672cc88bae40353455de0d68252b0fe4847a065
5
5
  SHA512:
6
- metadata.gz: fec0b308a60ae96bc89c5a0a9794e6aad0d8db73fcee80bc9e05d3bd7219ce520f8f2e870a042f4cada2d78a91fbad438f7e4440462060ab71965c4cd7b4d96c
7
- data.tar.gz: 7857cef3003d19c876a48ed59ae92336d7a14bf8b14da2e71f0493124ae66492fa945fbb6bbade058f822534003bf4216af7f9669acca5a180ffc5222b70dc14
6
+ metadata.gz: 05301cdf85de9d9c0b49c9bc1d3c0bac0260157228751b8974fe99d33a5ce90aeaf045c5c5fb93bbd7cb048169e7dd61884fbb45a4945233fd972e38cb77dd70
7
+ data.tar.gz: 4dd30a962a6632ee99bb6cf7320957376680a0392497179bec43693b825c9b3003bc90c65af38d893b09a3610b4d76b67450752741427285f069e1f86f1a9c30
data/README.md CHANGED
@@ -46,6 +46,8 @@ puts chapter.number
46
46
  => 1
47
47
  puts chapter.title
48
48
  => "Genesis 1"
49
+ chapter.next # returns the next Chapter
50
+ chapter.prev # returns the previous Chapter
49
51
  ```
50
52
  ### Verses
51
53
  All return an array of Verse objects.
@@ -62,6 +64,8 @@ puts verse.title
62
64
  => "Genesis 1:1"
63
65
  puts verse.text
64
66
  => "In the beginning God..."
67
+ verse.next # returns the next Verse
68
+ verse.prev # returns the previous Verse
65
69
  ```
66
70
  ### Random
67
71
  ```ruby
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.9
data/kj.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: kj 0.0.8 ruby lib
5
+ # stub: kj 0.0.9 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "kj"
9
- s.version = "0.0.8"
9
+ s.version = "0.0.9"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
data/lib/kj/chapter.rb CHANGED
@@ -30,6 +30,26 @@ module Kj
30
30
  title
31
31
  end
32
32
 
33
+ def next
34
+ @next ||= begin
35
+ c = Db.query("SELECT id, book_id, number FROM chapters WHERE id > ? order by id asc limit 1", [@id], true)
36
+ self.class.new(id: c['id'], book_id: c['book_id'], number: c['number'])
37
+ rescue Kj::Iniquity
38
+ c = Db.query("SELECT id, book_id, number FROM chapters WHERE id = ?", [1], true)
39
+ self.class.new(id: c['id'], book_id: c['book_id'], number: c['number'])
40
+ end
41
+ end
42
+
43
+ def prev
44
+ @prev ||= begin
45
+ c = Db.query("SELECT id, book_id, number FROM chapters WHERE id < ? order by id desc limit 1", [@id], true)
46
+ self.class.new(id: c['id'], book_id: c['book_id'], number: c['number'])
47
+ rescue Kj::Iniquity
48
+ c = Db.query("SELECT id, book_id, number FROM chapters WHERE id = ?", [self.class.count], true)
49
+ self.class.new(id: c['id'], book_id: c['book_id'], number: c['number'])
50
+ end
51
+ end
52
+
33
53
  def self.count
34
54
  1184
35
55
  end
data/lib/kj/verse.rb CHANGED
@@ -43,6 +43,26 @@ module Kj
43
43
  text
44
44
  end
45
45
 
46
+ def next
47
+ @next ||= begin
48
+ v = Db.query("SELECT id, chapter_id, text, number FROM verses WHERE id > ? order by id asc limit 1", [@id], true)
49
+ self.class.new(id: v['id'], chapter_id: v['chapter_id'], text: v['text'], number: v['number'])
50
+ rescue Kj::Iniquity
51
+ v = Db.query("SELECT id, chapter_id, text, number FROM verses WHERE id = ?", [1], true)
52
+ self.class.new(id: v['id'], chapter_id: v['chapter_id'], text: v['text'], number: v['number'])
53
+ end
54
+ end
55
+
56
+ def prev
57
+ @prev ||= begin
58
+ v = Db.query("SELECT id, chapter_id, text, number FROM verses WHERE id < ? order by id desc limit 1", [@id], true)
59
+ self.class.new(id: v['id'], chapter_id: v['chapter_id'], text: v['text'], number: v['number'])
60
+ rescue Kj::Iniquity
61
+ v = Db.query("SELECT id, chapter_id, text, number FROM verses WHERE id = ?", [self.class.count], true)
62
+ self.class.new(id: v['id'], chapter_id: v['chapter_id'], text: v['text'], number: v['number'])
63
+ end
64
+ end
65
+
46
66
  def text
47
67
  @text ||= begin
48
68
  verse = Db.query("SELECT chapter_id, text FROM verses WHERE id = ?", [@id], true)
data/spec/chapter_spec.rb CHANGED
@@ -25,6 +25,18 @@ describe "Kj" do
25
25
  end
26
26
  end
27
27
 
28
+ describe '#prev' do
29
+ it 'returns the previous Chapter' do
30
+ expect(chapter.prev.number).to eq(22) # Rev 22
31
+ end
32
+ end
33
+
34
+ describe '#next' do
35
+ it 'returns the next Chapter' do
36
+ expect(chapter.next.number).to eq(2)
37
+ end
38
+ end
39
+
28
40
  end
29
41
 
30
42
  end
data/spec/verse_spec.rb CHANGED
@@ -20,6 +20,18 @@ describe "Kj" do
20
20
  end
21
21
  end
22
22
 
23
+ describe '#prev' do
24
+ it 'returns the previous Verse' do
25
+ expect(verse.prev.number).to eq(21) # Rev 22:21
26
+ end
27
+ end
28
+
29
+ describe '#next' do
30
+ it 'returns the next Verse' do
31
+ expect(verse.next.number).to eq(2)
32
+ end
33
+ end
34
+
23
35
  end
24
36
 
25
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David John