Class: Pericope::CLI
- Inherits:
-
Object
- Object
- Pericope::CLI
- Defined in:
- lib/pericope/cli.rb
Constant Summary collapse
- ALLOWED_COMMANDS =
%w{help normalize parse substitute reverse-substitute usage}
Class Method Summary collapse
Instance Method Summary collapse
- #help ⇒ Object
- #normalize ⇒ Object
- #parse ⇒ Object
- #reverse_substitute ⇒ Object
- #substitute ⇒ Object
- #usage ⇒ Object
Class Method Details
.run(command, *args) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/pericope/cli.rb', line 13 def self.run(command, *args) if ALLOWED_COMMANDS.member?(command) command = command.gsub(/-/, '_').to_sym CLI.new(*args).send(command) else CLI.new(*args).usage end end |
Instance Method Details
#help ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pericope/cli.rb', line 24 def help print <<-HELP Glossary pericope A Bible reference (e.g. Romans 3:6-11) verse ID An integer that uniquely identifies a Bible verse HELP end |
#normalize ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/pericope/cli.rb', line 37 def normalize begin pericope = Pericope.new(input) print pericope.to_s rescue print $!.to_s end end |
#parse ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/pericope/cli.rb', line 48 def parse begin pericope = Pericope.new(input) print pericope.to_a.join("\n") rescue print $!.to_s end end |
#reverse_substitute ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/pericope/cli.rb', line 69 def reverse_substitute begin print Pericope.rsub(input) rescue print $!.to_s end end |
#substitute ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/pericope/cli.rb', line 59 def substitute begin print Pericope.sub(input) rescue print $!.to_s end end |
#usage ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/pericope/cli.rb', line 79 def usage print <<-USAGE Usage pericope [Command] [Input] Commands help Prints more information about pericope normalize Accepts a pericope and returns a properly-formatted pericope parse Accepts a pericope and returns a list of verse IDs substitute Accepts a block of text and replaces all pericopes in the text with verse IDs reverse-substitute Accepts a block of text and replaces collections of verse IDs with pericopes usage Prints this message USAGE end |