pericope 0.1.2 → 0.5.1
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.
- data/bin/pericope +9 -0
- data/lib/cli/base.rb +30 -0
- data/lib/cli/command.rb +23 -0
- data/lib/pericope/cli.rb +111 -0
- data/lib/pericope/version.rb +1 -1
- data/lib/pericope.rb +13 -0
- metadata +13 -9
data/bin/pericope
ADDED
data/lib/cli/base.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module CLI
|
2
|
+
class Base
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
def self.command(name, description, &block)
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
def self.print_commands
|
13
|
+
usage = ""
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
def commands
|
24
|
+
@commands || {}
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
data/lib/cli/command.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module CLI
|
2
|
+
class Command
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
def initialize(name, description, &block)
|
7
|
+
@name, @description, @block = name, description, &block
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
attr_reader :name, :description
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
def execute
|
17
|
+
@block.call
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
data/lib/pericope/cli.rb
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'pericope'
|
2
|
+
require 'cli/base'
|
3
|
+
|
4
|
+
class Pericope
|
5
|
+
class CLI
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
ALLOWED_COMMANDS = %w{help normalize parse substitute usage}
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
def self.run(command, *args)
|
14
|
+
if ALLOWED_COMMANDS.member?(command)
|
15
|
+
CLI.new(*args).send(command.to_sym)
|
16
|
+
else
|
17
|
+
CLI.new(*args).usage
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
def help
|
24
|
+
print <<-HELP
|
25
|
+
|
26
|
+
Glossary
|
27
|
+
|
28
|
+
pericope A Bible reference (e.g. Romans 3:6-11)
|
29
|
+
verse ID An integer that uniquely identifies a Bible verse
|
30
|
+
|
31
|
+
HELP
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
def normalize
|
37
|
+
begin
|
38
|
+
pericope = Pericope.new(input)
|
39
|
+
print pericope.to_s
|
40
|
+
rescue
|
41
|
+
print $!.to_s
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
def parse
|
48
|
+
begin
|
49
|
+
pericope = Pericope.new(input)
|
50
|
+
print pericope.to_a.join("\n")
|
51
|
+
rescue
|
52
|
+
print $!.to_s
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
def substitute
|
59
|
+
begin
|
60
|
+
print Pericope.sub(input)
|
61
|
+
rescue
|
62
|
+
print $!.to_s
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
def usage
|
69
|
+
print <<-USAGE
|
70
|
+
|
71
|
+
Usage
|
72
|
+
|
73
|
+
pericope [Command] [Input]
|
74
|
+
|
75
|
+
Commands
|
76
|
+
|
77
|
+
help Prints more information about pericope
|
78
|
+
normalize Accepts a pericope and returns a properly-formatted pericope
|
79
|
+
parse Accepts a pericope and returns a list of verse IDs
|
80
|
+
substitute Accepts a block of text and replaces all pericopes in the text with verse IDs
|
81
|
+
usage Prints this message
|
82
|
+
|
83
|
+
USAGE
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
def initialize(*args)
|
93
|
+
@options = extract_options!(*args)
|
94
|
+
@input = args.first
|
95
|
+
@input = $stdin.read if $stdin.stat.pipe?
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
attr_reader :options, :input
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
def extract_options!(*args)
|
105
|
+
{} # No options accepted yet
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
data/lib/pericope/version.rb
CHANGED
data/lib/pericope.rb
CHANGED
@@ -87,6 +87,19 @@ class Pericope
|
|
87
87
|
|
88
88
|
|
89
89
|
|
90
|
+
def self.sub(text)
|
91
|
+
segments = split(text)
|
92
|
+
segments.inject("") do |text, segment|
|
93
|
+
if segment.is_a?(String)
|
94
|
+
text << segment
|
95
|
+
else
|
96
|
+
text << segment.to_a.join(" ")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
|
90
103
|
def to_s
|
91
104
|
"#{book_name} #{self.well_formatted_reference}"
|
92
105
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pericope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 5
|
8
9
|
- 1
|
9
|
-
|
10
|
-
version: 0.1.2
|
10
|
+
version: 0.5.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bob Lail
|
@@ -15,8 +15,8 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
19
|
-
default_executable:
|
18
|
+
date: 2010-10-12 00:00:00 -05:00
|
19
|
+
default_executable: pericope
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activesupport
|
@@ -34,23 +34,27 @@ dependencies:
|
|
34
34
|
version_requirements: *id001
|
35
35
|
description:
|
36
36
|
email:
|
37
|
-
-
|
38
|
-
executables:
|
39
|
-
|
37
|
+
- bob.lailfamily@gmail.com
|
38
|
+
executables:
|
39
|
+
- pericope
|
40
40
|
extensions: []
|
41
41
|
|
42
42
|
extra_rdoc_files: []
|
43
43
|
|
44
44
|
files:
|
45
|
+
- bin/pericope
|
45
46
|
- data/book_abbreviations.txt
|
46
47
|
- data/chapter_verse_count.txt
|
47
48
|
- data/chapter_verse_count.yml
|
49
|
+
- lib/cli/base.rb
|
50
|
+
- lib/cli/command.rb
|
51
|
+
- lib/pericope/cli.rb
|
48
52
|
- lib/pericope/version.rb
|
49
53
|
- lib/pericope.rb
|
50
54
|
- lib/tasks/pericope_tasks.rake
|
51
55
|
- README.mdown
|
52
56
|
has_rdoc: true
|
53
|
-
homepage:
|
57
|
+
homepage: http://github.com/boblail/Pericope
|
54
58
|
licenses: []
|
55
59
|
|
56
60
|
post_install_message:
|