diatheke 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5b7ae5fc4f88ee0fa647202198780d172c53b1a
4
- data.tar.gz: bf21942929da6a63e5279c0ac61abce6c30b8b4b
3
+ metadata.gz: 2bb793eaf473921eaa0daf081dc2361f86b9af35
4
+ data.tar.gz: 0220a2355cb328882df3d89ea20ac2595c701187
5
5
  SHA512:
6
- metadata.gz: 8a7cefb85adff3b1970eb7dcf1099dfe03e2594db75239a4d6505459e80a928a93926cbf45e1923a0357029e70cfb207d957388bc3c1602f8abecf3324156284
7
- data.tar.gz: 6c5279f2f648312fc4c39471a32a4eca487d7e58eac58a932bcecb9969075a4c0bf0edb57a63220087d94b1083680ac34220aa5571672ea3810cf63acf4a4bd6
6
+ metadata.gz: 39d969e16e7f8062bf51efa6dc7c0ec0f77e545b80d10b1d6b14d0249ea196c7b63c559ad5906714cbb80f3f77cd9077c276901ba477d1a10c132a79a807e573
7
+ data.tar.gz: ff34f6dff4074b7868c78f911e71eeac78d9fde96366f60618e251542a9ada92a1a5277b413f99e8e2f1a050084fc38acb866a90cb8e937579558efb0435efef
data/Changelog CHANGED
@@ -1,3 +1,6 @@
1
+ 0.2.0
2
+ Support output format option.
3
+
1
4
  0.1.2
2
5
  Split passages at reference key to ensure correct handling of line breaks.
3
6
 
data/README.md CHANGED
@@ -19,13 +19,13 @@ This library is a wrapper of the
19
19
  puts Diatheke.passage('KJV', 'John 1').to_yaml
20
20
 
21
21
  # Search a phrase
22
- p Diatheke.search('KJV', 'with God', :range => 'Joh 1')
22
+ p Diatheke.search('KJV', 'with God', range: 'Joh 1')
23
23
 
24
24
  # Search with method "multi word"
25
- p Diatheke.search('KJV', %w(God Jesus), :range => 'Joh 1')
25
+ p Diatheke.search('KJV', %w(God Jesus), range: 'Joh 1')
26
26
 
27
27
  # Search with regular expression
28
- p Diatheke.search('KJV', /Jesus.+Jesus/, :range => 'Joh 1')
28
+ p Diatheke.search('KJV', /Jesus.+Jesus/, range: 'Joh 1')
29
29
 
30
30
  ## Author
31
31
 
data/Rakefile CHANGED
@@ -5,6 +5,6 @@ Rim.setup do
5
5
  name 'diatheke'
6
6
  authors 'Jan Friedrich'
7
7
  email 'janfri26@gmail.com'
8
- version '0.1.2'
8
+ version '0.2.0'
9
9
  summary 'This library is a wrapper of the diatheke command-line client of the sword project.'
10
10
  end
@@ -19,18 +19,18 @@ module Diatheke
19
19
  call('system', 'modulelistnames').split(/\n/)
20
20
  end
21
21
 
22
- def passage(mod, key)
23
- s = call(mod, key)
22
+ def passage(mod, key, **opts)
23
+ s = call(mod, key, opts)
24
24
  parse_passage s
25
25
  end
26
26
 
27
- def search(mod, key, opts={})
27
+ def search(mod, key, **opts)
28
28
  search_type = :phrase
29
29
  search_key = key
30
30
  case key
31
31
  when Regexp
32
32
  search_type = :regex
33
- search_key = key.inspect.sub(%r(^/), '').sub(%r(/$), '')
33
+ search_key = key.source
34
34
  when Array
35
35
  search_type = :multiword
36
36
  search_key = key.join(' ')
@@ -42,8 +42,11 @@ module Diatheke
42
42
 
43
43
  private
44
44
 
45
- def call(mod, key, opts={})
45
+ def call(mod, key, **opts)
46
46
  args = []
47
+ if f = opts[:format]
48
+ args << '-f' << f
49
+ end
47
50
  if s = opts[:search_type]
48
51
  args << '-s' << s
49
52
  end
@@ -9,24 +9,27 @@ class TestDiatheke < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  def test_passage
12
- res = Diatheke.passage('KJV', 'Joh 1:1-3')
12
+ res = Diatheke.passage('KJV', 'Joh 1:1-3', format: :plain)
13
13
  assert_equal ['John 1:1', 'John 1:2', 'John 1:3'], res.map {|e| e.key}
14
14
  assert_match /^In the beginning was the Word/, res.first.text
15
+ res = Diatheke.passage('KJV', 'Joh 1:1-3', format: :CGI)
16
+ assert_equal ['John 1:1', 'John 1:2', 'John 1:3'], res.map {|e| e.key}
17
+ assert_match %r(^<span >: In the beginning was the Word.+the Word was God.</span><br />$), res.first.text
15
18
  end
16
19
 
17
20
  def test_search_phrase
18
- res = Diatheke.search('KJV', 'with God', :range => 'Joh 1')
21
+ res = Diatheke.search('KJV', 'with God', range: 'Joh 1')
19
22
  assert_equal ['John 1:1', 'John 1:2'], res
20
23
  end
21
24
 
22
25
  def test_search_multiword
23
- res = Diatheke.search('KJV', %w(God Jesus), :range => 'Joh 1')
26
+ res = Diatheke.search('KJV', %w(God Jesus), range: 'Joh 1')
24
27
  assert_equal ['John 1:29', 'John 1:36'], res
25
28
  end
26
29
 
27
30
  def test_search_regex
28
- res = Diatheke.search('KJV', /Jesus.+Jesus/, :range => 'Joh 1')
29
- assert_equal ['John 1:42'], res
31
+ res = Diatheke.search('KJV', /witness.+witness/, range: 'Joh 1')
32
+ assert_equal ['John 1:7'], res
30
33
  end
31
34
 
32
35
  def test_correct_split_with_colon_in_text
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diatheke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Friedrich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-08 00:00:00.000000000 Z
11
+ date: 2017-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rim
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.6'
19
+ version: '2.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.6'
26
+ version: '2.10'
27
27
  description: ''
28
28
  email: janfri26@gmail.com
29
29
  executables: []
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  version: '0'
56
56
  requirements: []
57
57
  rubyforge_project:
58
- rubygems_version: 2.5.2
58
+ rubygems_version: 2.6.12
59
59
  signing_key:
60
60
  specification_version: 4
61
61
  summary: This library is a wrapper of the diatheke command-line client of the sword