textme 0.0.3 → 0.0.4
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 +4 -4
- data/lib/textme.rb +175 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a53fd8046fb011d979e066e8ef25d731e3eda658
|
4
|
+
data.tar.gz: 02ed991441303154c7b4cf7cd54150c43e28c8af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6b7a040ae235c4361019c07da38677d82527525368c28b3f0e61005f9b03b10c20dfdce20a1eaf0271c92e05255365107858eb004f3eb5ac747d6a7021f9de9
|
7
|
+
data.tar.gz: dd34a43ba0f7d582b95544f4adf7d17b1fa18dcf51a32dfbb19492f18d05eb61b3de1dd5b64701dae3b9e759b110547772882e6213edb8802f023121ebfcaf9c
|
data/lib/textme.rb
CHANGED
@@ -5,7 +5,6 @@
|
|
5
5
|
|
6
6
|
require 'twilio-ruby' #The Twilio gem
|
7
7
|
require 'metainspector' #Gem to help extract the open graph data
|
8
|
-
require_relative 'bible-extractor'
|
9
8
|
|
10
9
|
module TextMe
|
11
10
|
class Core
|
@@ -28,7 +27,7 @@ module TextMe
|
|
28
27
|
#Output: A hash with the (always) 'verse' => (verse name + verse text),
|
29
28
|
# (optional) 'image_url' => image verse
|
30
29
|
def meta_extractor(name)
|
31
|
-
extractor = BibleExtractor
|
30
|
+
extractor = TextMe::BibleExtractor.new
|
32
31
|
url = extractor.verse_url_generator(name)
|
33
32
|
#Use a Hash to store the verse and image url
|
34
33
|
metadata = Hash.new
|
@@ -51,9 +50,9 @@ module TextMe
|
|
51
50
|
#What: Take the recievers number and the verse url. Calls the meta_extractor helper method
|
52
51
|
#Input: 'To' number, You version url of the verse
|
53
52
|
#Output: No actual output. Send's a text containing verse name(always), verse text(always) and verse image(optional) to the 'To' number
|
54
|
-
def send_message(reciever_number,
|
53
|
+
def send_message(reciever_number, name)
|
55
54
|
#A call to the meta_extractor to get the verse name, verse text and verse image(optional)
|
56
|
-
verse_data = meta_extractor(
|
55
|
+
verse_data = meta_extractor(name)
|
57
56
|
|
58
57
|
#If: There is a verse image for the verse
|
59
58
|
#Else: There is no image
|
@@ -76,4 +75,176 @@ module TextMe
|
|
76
75
|
end
|
77
76
|
end
|
78
77
|
end
|
78
|
+
|
79
|
+
class BibleExtractor
|
80
|
+
def verse_meta_extractor(verse_name)
|
81
|
+
bookList =["Genesis", "Exodus", "Leviticus", "Numbers", "Deuteronomy", "Joshua", "Judges", "Ruth", "1 Samuel", "2 Samuel", "1 Kings", "2 Kings", "1 Chronicles", "2 Chronicles", "Ezra", "Nehemiah", "Esther", "Job", "Psalms", "Proverbs", "Ecclesiastes", "Song of Songs", "Isaiah", "Jeremiah", "Lamentations", "Ezekiel", "Daniel", "Hosea", "Joel", "Amos", "Obadiah", "Jonah", "Micah", "Nahum", "Habakkuk", "Zephaniah", "Haggai", "Zechariah", "Malachi", "Matthew", "Mark", "Luke", "John", "Acts", "Romans", "1 Corinthians", "2 Corinthians", "Galatians", "Ephesians", "Philippians", "Colossians", "1 Thessalonians", "2 Thessalonians", "1 Timothy", "2 Timothy", "Titus", "Philemon", "Hebrews", "James", "1 Peter", "2 Peter", "1 John", "2 John", "3 John", "Jude", "Revelation"]
|
82
|
+
verse_meta = {}
|
83
|
+
for book in bookList
|
84
|
+
if verse_name.downcase.include? book.downcase
|
85
|
+
verse_meta["book"] = book
|
86
|
+
|
87
|
+
verse_number = verse_name.split(book)[1].strip
|
88
|
+
|
89
|
+
if verse_number.include? ':'
|
90
|
+
verse_meta['chapter_number'] = verse_number.split(':')[0].strip
|
91
|
+
verse_meta['specific_verse'] = verse_number.split(':')[1].strip
|
92
|
+
else
|
93
|
+
verse_meta['chapter_number'] = verse_number
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
return verse_meta
|
98
|
+
end
|
99
|
+
|
100
|
+
def verse_url_generator(verse_meta)
|
101
|
+
url = 'https://bible.com/bible/59/'
|
102
|
+
url = url + book_name_formatter(verse_meta['book']) + '/'
|
103
|
+
url = url + verse_meta["chapter_number"] + '/'
|
104
|
+
if verse_meta['specific_verse']
|
105
|
+
url = url + verse_meta['specific_verse']
|
106
|
+
end
|
107
|
+
return url
|
108
|
+
end
|
109
|
+
|
110
|
+
def book_name_formatter(book_name)
|
111
|
+
transformed_name = nil
|
112
|
+
|
113
|
+
case book_name
|
114
|
+
when"Genesis"
|
115
|
+
transformed_name = "gen"
|
116
|
+
when"Exodus"
|
117
|
+
transformed_name = "exo"
|
118
|
+
when"Leviticus"
|
119
|
+
transformed_name = "lev"
|
120
|
+
when"Numbers"
|
121
|
+
transformed_name = "num"
|
122
|
+
when"Deuteronomy"
|
123
|
+
transformed_name = "deu"
|
124
|
+
when"Joshua"
|
125
|
+
transformed_name = "jos"
|
126
|
+
when"Judges"
|
127
|
+
transformed_name = "jdg"
|
128
|
+
when"Ruth"
|
129
|
+
transformed_name = "rut"
|
130
|
+
when"1 Samuel"
|
131
|
+
transformed_name = "1sa"
|
132
|
+
when"2 Samuel"
|
133
|
+
transformed_name = "2sa"
|
134
|
+
when"1 Kings"
|
135
|
+
transformed_name = "1ki"
|
136
|
+
when"2 Kings"
|
137
|
+
transformed_name = "2ki"
|
138
|
+
when"1 Chronicles"
|
139
|
+
transformed_name = "1ch"
|
140
|
+
when"2 Chronicles"
|
141
|
+
transformed_name = "2ch"
|
142
|
+
when"Ezra"
|
143
|
+
transformed_name = "ezr"
|
144
|
+
when"Nehemiah"
|
145
|
+
transformed_name = "neh"
|
146
|
+
when"Esther"
|
147
|
+
transformed_name = "est"
|
148
|
+
when "Job"
|
149
|
+
transformed_name = "job"
|
150
|
+
when "Psalms"
|
151
|
+
transformed_name = "psa"
|
152
|
+
when "Proverbs"
|
153
|
+
transformed_name = "pro"
|
154
|
+
when "Ecclesiastes"
|
155
|
+
transformed_name = "ecc"
|
156
|
+
when "Song of Songs"
|
157
|
+
transformed_name = "sng"
|
158
|
+
when "Isaiah"
|
159
|
+
transformed_name = "isa"
|
160
|
+
when "Jeremiah"
|
161
|
+
transformed_name = "jer"
|
162
|
+
when "Lamentations"
|
163
|
+
transformed_name = "lam"
|
164
|
+
when "Ezekiel"
|
165
|
+
transformed_name = "ezk"
|
166
|
+
when "Daniel"
|
167
|
+
transformed_name = "dan"
|
168
|
+
when "Hosea"
|
169
|
+
transformed_name = "hos"
|
170
|
+
when "Joel"
|
171
|
+
transformed_name = "jol"
|
172
|
+
when "Amos"
|
173
|
+
transformed_name = "amo"
|
174
|
+
when "Obadiah"
|
175
|
+
transformed_name = "oba"
|
176
|
+
when "Jonah"
|
177
|
+
transformed_name = "jon"
|
178
|
+
when "Micah"
|
179
|
+
transformed_name = "mic"
|
180
|
+
when "Nahum"
|
181
|
+
transformed_name = "nam"
|
182
|
+
when "Habakkuk"
|
183
|
+
transformed_name = "hab"
|
184
|
+
when "Zephaniah"
|
185
|
+
transformed_name = "zep"
|
186
|
+
when "Haggai"
|
187
|
+
transformed_name = "hag"
|
188
|
+
when "Zechariah"
|
189
|
+
transformed_name = "zec"
|
190
|
+
when "Malachi"
|
191
|
+
transformed_name = "mal"
|
192
|
+
when "Matthew"
|
193
|
+
transformed_name = "mat"
|
194
|
+
when "Mark"
|
195
|
+
transformed_name = "mek"
|
196
|
+
when "Luke"
|
197
|
+
transformed_name = "luk"
|
198
|
+
when "John"
|
199
|
+
transformed_name = "jhn"
|
200
|
+
when "Acts"
|
201
|
+
transformed_name = "act"
|
202
|
+
when "Romans"
|
203
|
+
transformed_name = "rom"
|
204
|
+
when "1 Corinthians"
|
205
|
+
transformed_name = "1co"
|
206
|
+
when "2 Corinthians"
|
207
|
+
transformed_name = "2co"
|
208
|
+
when "Galatians"
|
209
|
+
transformed_name = "gal"
|
210
|
+
when "Ephesians"
|
211
|
+
transformed_name = "eph"
|
212
|
+
when "Philippians"
|
213
|
+
transformed_name = "php"
|
214
|
+
when "Colossians"
|
215
|
+
transformed_name = "col"
|
216
|
+
when "1 Thessalonians"
|
217
|
+
transformed_name = "1th"
|
218
|
+
when "2 Thessalonians"
|
219
|
+
transformed_name = "2th"
|
220
|
+
when "1 Timothy"
|
221
|
+
transformed_name = "1ti"
|
222
|
+
when "2 Timothy"
|
223
|
+
transformed_name = "2ti"
|
224
|
+
when "Titus"
|
225
|
+
transformed_name = "tit"
|
226
|
+
when "Philemon"
|
227
|
+
transformed_name = "phm"
|
228
|
+
when "Hebrews"
|
229
|
+
transformed_name = "heb"
|
230
|
+
when "James"
|
231
|
+
transformed_name = "jas"
|
232
|
+
when "1 Peter"
|
233
|
+
transformed_name = "1pe"
|
234
|
+
when "2 Peter"
|
235
|
+
transformed_name = "2pe"
|
236
|
+
when "1 John"
|
237
|
+
transformed_name = "1jn"
|
238
|
+
when "2 John"
|
239
|
+
transformed_name = "2jn"
|
240
|
+
when "3 John"
|
241
|
+
transformed_name = "3jn"
|
242
|
+
when "Jude"
|
243
|
+
transformed_name = "jud"
|
244
|
+
when "Revelation"
|
245
|
+
transformed_name = "rev"
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
79
250
|
end
|