-
Notifications
You must be signed in to change notification settings - Fork 1
/
get-verses-mongo.rb
executable file
·74 lines (59 loc) · 1.5 KB
/
get-verses-mongo.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env ruby
require 'optparse'
# using bundler http://gembundler.com/
require 'rubygems'
require 'bundler/setup'
Bundler.require(:default)
# other includes
require './api-key.rb' # BIBLE_KEY
require './models/Pack.rb' # Pack model
require './BibleApi.rb' # Bible API
options = {}
optparse = OptionParser.new do |opts|
opts.banner = "Usage: $0 [options] file"
options[:name] = nil
opts.on( '-n', '--name NAME', 'Required: set the pack name' ) do |name|
options[:name] = name || "nothing"
end
opts.on( '-h', '--help', 'Display help screen' ) do
puts opts
exit
end
end
optparse.parse!
if options[:name].nil?
puts "Required: --name NAME\n"
exit
end
# Setup BibleApi to take options for Mongo connection
bibleApiOpts = {
:useMongo => true,
:overwrite => false,
# Recommendation: TMS has verses in both OT & NT. Pick translations with both.
:translations => [
'eng-CEV',
'eng-ESV', # English Standard Version
'eng-KJV', # King James Version
'eng-MSG',
'eng-NASB',
'spa-RVR1960'
]
}
bibleApi = BibleApi.new(bibleApiOpts)
if(ARGV.size < 1)
print "Please pass in a file\n"
exit
end
if(ARGV.size > 1)
print "Please send in one file at a time\n"
exit
end
File.open(ARGV[0]) do |file|
pack = Pack.new(options[:name])
verses = []
file.readlines.each do |line|
verses.push(line.chomp)
end
pack.verses = verses
bibleApi.get_pack_data(pack)
end