verser 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +13 -2
- data/lib/verser/reference.rb +17 -12
- data/lib/verser/version.rb +1 -1
- data/spec/verser_spec.rb +78 -27
- data/verser.gemspec +4 -1
- metadata +66 -46
data/Gemfile.lock
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
verser (0.0.
|
4
|
+
verser (0.0.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
|
+
awesome_print (0.4.0)
|
9
10
|
diff-lcs (1.1.2)
|
11
|
+
fuubar (0.0.5)
|
12
|
+
rspec (~> 2.0)
|
13
|
+
rspec-instafail (~> 0.1.4)
|
14
|
+
ruby-progressbar (~> 0.0.10)
|
15
|
+
rake (0.9.2)
|
10
16
|
rspec (2.2.0)
|
11
17
|
rspec-core (~> 2.2)
|
12
18
|
rspec-expectations (~> 2.2)
|
@@ -14,11 +20,16 @@ GEM
|
|
14
20
|
rspec-core (2.2.1)
|
15
21
|
rspec-expectations (2.2.0)
|
16
22
|
diff-lcs (~> 1.1.2)
|
23
|
+
rspec-instafail (0.1.8)
|
17
24
|
rspec-mocks (2.2.0)
|
25
|
+
ruby-progressbar (0.0.10)
|
18
26
|
|
19
27
|
PLATFORMS
|
20
28
|
ruby
|
21
29
|
|
22
30
|
DEPENDENCIES
|
23
|
-
|
31
|
+
awesome_print
|
32
|
+
fuubar
|
33
|
+
rake
|
34
|
+
rspec
|
24
35
|
verser!
|
data/lib/verser/reference.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Verser
|
4
4
|
class Reference
|
5
|
-
attr_reader :book, :
|
5
|
+
attr_reader :book, :from_chapter, :to_chapter, :from_verse, :to_verse, :input
|
6
6
|
|
7
7
|
def initialize(input)
|
8
8
|
@input = input
|
@@ -14,28 +14,33 @@ module Verser
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def parse
|
17
|
-
@input.downcase.gsub(/\s/,'').match /(\d)?([a-zéèïëô]+)\s*(\d+)([.,:](\d+)-?(\d+)?)?/
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
@input.downcase.gsub(/\s/,'').match /(\d)?([a-zéèïëô]+)\s*(\d+)([.,:](\d+)-?((\d+)[.,:])?(\d+)?)?/
|
18
|
+
|
19
|
+
@book = $1.nil? ? $2 : $1+$2
|
20
|
+
@from_chapter = $3.to_i == 0 ? nil : $3.to_i
|
21
|
+
@to_chapter = $7.to_i == 0 ? nil : $7.to_i
|
22
|
+
|
23
|
+
if $5.to_i > 0
|
24
|
+
@from_verse = $5.to_i
|
25
|
+
@to_verse = $8.to_i > 0 ? $8.to_i : nil
|
21
26
|
else
|
22
|
-
@
|
27
|
+
@from_verse = @to_verse = nil
|
23
28
|
end
|
24
29
|
|
25
|
-
@chapter = $3.to_i
|
26
|
-
@from = $5.to_i
|
27
|
-
@to = $6.to_i
|
28
|
-
|
29
30
|
validate!
|
30
31
|
end
|
31
32
|
|
32
33
|
def validate!
|
33
34
|
@valid = true
|
34
35
|
@valid = false if @book.nil? or @book.empty?
|
36
|
+
@valid = false if @from_chapter.nil?
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
+
if @to_chapter.nil?
|
39
|
+
unless @from_verse.nil? or @to_verse.nil?
|
40
|
+
@valid &&= (@from_verse < @to_verse)
|
41
|
+
end
|
38
42
|
end
|
43
|
+
|
39
44
|
|
40
45
|
@valid
|
41
46
|
end
|
data/lib/verser/version.rb
CHANGED
data/spec/verser_spec.rb
CHANGED
@@ -3,80 +3,131 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
describe Verser::Reference do
|
6
|
-
it "reads the format : <book>[ ]<chapter>[:.,]<verse>[-<verse>]" do
|
6
|
+
it "reads the format : <book>[ ]<chapter>[:.,]<verse>[-<chapter>[:.,]<verse>]" do
|
7
7
|
r = Verser::Reference.new 'genèse 1.1-6'
|
8
8
|
r.should be_valid
|
9
9
|
r.book.should == 'genèse'
|
10
|
-
r.
|
11
|
-
r.
|
12
|
-
r.
|
10
|
+
r.from_chapter.should == 1
|
11
|
+
r.to_chapter.should be_nil
|
12
|
+
r.from_verse.should == 1
|
13
|
+
r.to_verse.should == 6
|
14
|
+
|
15
|
+
r = Verser::Reference.new 'genèse 1.1-2.6'
|
16
|
+
r.should be_valid
|
17
|
+
r.book.should == 'genèse'
|
18
|
+
r.from_chapter.should == 1
|
19
|
+
r.from_verse.should == 1
|
20
|
+
r.to_chapter.should == 2
|
21
|
+
r.to_verse.should == 6
|
13
22
|
|
14
23
|
r = Verser::Reference.new 'genèse 1:1-6'
|
15
24
|
r.should be_valid
|
16
25
|
r.book.should == 'genèse'
|
17
|
-
r.
|
18
|
-
r.
|
19
|
-
r.
|
26
|
+
r.from_chapter.should == 1
|
27
|
+
r.to_chapter.should be_nil
|
28
|
+
r.from_verse.should == 1
|
29
|
+
r.to_verse.should == 6
|
30
|
+
|
31
|
+
r = Verser::Reference.new 'genèse 1:7-2:6'
|
32
|
+
r.should be_valid
|
33
|
+
r.book.should == 'genèse'
|
34
|
+
r.from_chapter.should == 1
|
35
|
+
r.from_verse.should == 7
|
36
|
+
r.to_chapter.should == 2
|
37
|
+
r.to_verse.should == 6
|
20
38
|
|
21
39
|
r = Verser::Reference.new "genèse\t1,1"
|
22
40
|
r.should be_valid
|
23
41
|
r.book.should == 'genèse'
|
24
|
-
r.
|
25
|
-
r.
|
26
|
-
r.
|
42
|
+
r.from_chapter.should == 1
|
43
|
+
r.to_chapter.should be_nil
|
44
|
+
r.from_verse.should == 1
|
45
|
+
r.to_verse.should be_nil
|
27
46
|
|
28
47
|
r = Verser::Reference.new 'genèse1,1'
|
29
48
|
r.should be_valid
|
30
49
|
r.book.should == 'genèse'
|
31
|
-
r.
|
32
|
-
r.
|
33
|
-
r.
|
50
|
+
r.from_chapter.should == 1
|
51
|
+
r.to_chapter.should be_nil
|
52
|
+
r.from_verse.should == 1
|
53
|
+
r.to_verse.should be_nil
|
34
54
|
end
|
35
55
|
|
36
|
-
it "reads the format : <number>[ ]<book> <chapter>[:.,]<verse>[-<verse>]" do
|
56
|
+
it "reads the format : <number>[ ]<book> <chapter>[:.,]<verse>[-<chapter>[:.,]<verse>]" do
|
37
57
|
r = Verser::Reference.new '1 jean 1.1-6'
|
38
58
|
r.should be_valid
|
39
59
|
r.book.should == '1jean'
|
40
|
-
r.
|
41
|
-
r.
|
42
|
-
r.
|
60
|
+
r.from_chapter.should == 1
|
61
|
+
r.to_chapter.should be_nil
|
62
|
+
r.from_verse.should == 1
|
63
|
+
r.to_verse.should == 6
|
64
|
+
|
65
|
+
r = Verser::Reference.new '1 jean 1.1-2.6'
|
66
|
+
r.should be_valid
|
67
|
+
r.book.should == '1jean'
|
68
|
+
r.from_chapter.should == 1
|
69
|
+
r.from_verse.should == 1
|
70
|
+
r.to_chapter.should == 2
|
71
|
+
r.to_verse.should == 6
|
43
72
|
|
44
73
|
r = Verser::Reference.new '2rois 1:1-6'
|
45
74
|
r.should be_valid
|
46
75
|
r.book.should == '2rois'
|
47
|
-
r.
|
48
|
-
r.
|
49
|
-
r.
|
76
|
+
r.from_chapter.should == 1
|
77
|
+
r.to_chapter.should be_nil
|
78
|
+
r.from_verse.should == 1
|
79
|
+
r.to_verse.should == 6
|
80
|
+
|
81
|
+
r = Verser::Reference.new '2rois 1:1-2:6'
|
82
|
+
r.should be_valid
|
83
|
+
r.book.should == '2rois'
|
84
|
+
r.from_chapter.should == 1
|
85
|
+
r.from_verse.should == 1
|
86
|
+
r.to_chapter.should == 2
|
87
|
+
r.to_verse.should == 6
|
50
88
|
|
51
89
|
r = Verser::Reference.new '1 Samuel 1,1'
|
52
90
|
r.should be_valid
|
53
91
|
r.book.should == '1samuel'
|
54
|
-
r.
|
55
|
-
r.
|
56
|
-
r.
|
92
|
+
r.from_chapter.should == 1
|
93
|
+
r.to_chapter.should be_nil
|
94
|
+
r.from_verse.should == 1
|
95
|
+
r.to_verse.should be_nil
|
57
96
|
end
|
58
97
|
|
59
98
|
it "reads the format : <book>[ ]<chapter>" do
|
60
99
|
r = Verser::Reference.new 'genèse1'
|
61
100
|
r.should be_valid
|
62
101
|
r.book.should == "genèse"
|
63
|
-
r.
|
102
|
+
r.from_chapter.should == 1
|
103
|
+
r.to_chapter.should be_nil
|
104
|
+
r.from_verse.should be_nil
|
105
|
+
r.to_verse.should be_nil
|
64
106
|
|
65
107
|
r = Verser::Reference.new 'genèse 1'
|
66
108
|
r.should be_valid
|
67
109
|
r.book.should == "genèse"
|
68
|
-
r.
|
110
|
+
r.from_chapter.should == 1
|
111
|
+
r.to_chapter.should be_nil
|
112
|
+
r.from_verse.should be_nil
|
113
|
+
r.to_verse.should be_nil
|
69
114
|
end
|
70
115
|
|
71
116
|
it "reads the format : <number>[ ]<book> <chapter>" do
|
72
117
|
r = Verser::Reference.new '1samuel 1'
|
73
118
|
r.should be_valid
|
74
119
|
r.book.should == "1samuel"
|
75
|
-
r.
|
120
|
+
r.from_chapter.should == 1
|
121
|
+
r.to_chapter.should be_nil
|
122
|
+
r.from_verse.should be_nil
|
123
|
+
r.to_verse.should be_nil
|
76
124
|
|
77
125
|
r = Verser::Reference.new '1 samuel 1'
|
78
126
|
r.should be_valid
|
79
127
|
r.book.should == "1samuel"
|
80
|
-
r.
|
128
|
+
r.from_chapter.should == 1
|
129
|
+
r.to_chapter.should be_nil
|
130
|
+
r.from_verse.should be_nil
|
131
|
+
r.to_verse.should be_nil
|
81
132
|
end
|
82
133
|
end
|
data/verser.gemspec
CHANGED
@@ -13,7 +13,10 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.description = %q{Verser is a bible verse/chapter reference parser}
|
14
14
|
|
15
15
|
s.rubyforge_project = "verser"
|
16
|
-
s.add_development_dependency "
|
16
|
+
s.add_development_dependency "rake"
|
17
|
+
s.add_development_dependency "rspec"
|
18
|
+
s.add_development_dependency "fuubar"
|
19
|
+
s.add_development_dependency "awesome_print"
|
17
20
|
|
18
21
|
s.files = `git ls-files`.split("\n")
|
19
22
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,47 +1,68 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: verser
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 0.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Rawane ZOSSOU
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
date: 2010-12-09 00:00:00 +01:00
|
12
|
+
date: 2011-07-15 00:00:00.000000000 +02:00
|
18
13
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
requirement: &2153465380 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2153465380
|
26
|
+
- !ruby/object:Gem::Dependency
|
21
27
|
name: rspec
|
28
|
+
requirement: &2153464900 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
22
35
|
prerelease: false
|
23
|
-
|
36
|
+
version_requirements: *2153464900
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: fuubar
|
39
|
+
requirement: &2153445060 !ruby/object:Gem::Requirement
|
24
40
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 2
|
30
|
-
- 2
|
31
|
-
- 0
|
32
|
-
version: 2.2.0
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
33
45
|
type: :development
|
34
|
-
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *2153445060
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: awesome_print
|
50
|
+
requirement: &2153444240 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *2153444240
|
35
59
|
description: Verser is a bible verse/chapter reference parser
|
36
|
-
email:
|
60
|
+
email:
|
37
61
|
- dev@raw1z.fr
|
38
62
|
executables: []
|
39
|
-
|
40
63
|
extensions: []
|
41
|
-
|
42
64
|
extra_rdoc_files: []
|
43
|
-
|
44
|
-
files:
|
65
|
+
files:
|
45
66
|
- .gitignore
|
46
67
|
- Gemfile
|
47
68
|
- Gemfile.lock
|
@@ -55,35 +76,34 @@ files:
|
|
55
76
|
has_rdoc: true
|
56
77
|
homepage: http://rubygems.org/gems/verser
|
57
78
|
licenses: []
|
58
|
-
|
59
79
|
post_install_message:
|
60
80
|
rdoc_options: []
|
61
|
-
|
62
|
-
require_paths:
|
81
|
+
require_paths:
|
63
82
|
- lib
|
64
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
84
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
segments:
|
70
90
|
- 0
|
71
|
-
|
72
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
hash: -1977891811613380311
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
93
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
segments:
|
78
99
|
- 0
|
79
|
-
|
100
|
+
hash: -1977891811613380311
|
80
101
|
requirements: []
|
81
|
-
|
82
102
|
rubyforge_project: verser
|
83
|
-
rubygems_version: 1.
|
103
|
+
rubygems_version: 1.6.2
|
84
104
|
signing_key:
|
85
105
|
specification_version: 3
|
86
106
|
summary: Verser is a bible verse/chapter reference parser
|
87
|
-
test_files:
|
107
|
+
test_files:
|
88
108
|
- spec/spec_helper.rb
|
89
109
|
- spec/verser_spec.rb
|