Skip to content

Instantly share code, notes, and snippets.

@sixtyfive
Last active February 14, 2018 13:02
Show Gist options
  • Save sixtyfive/2180574730f3f2f28ee1532639c9a9f3 to your computer and use it in GitHub Desktop.
Save sixtyfive/2180574730f3f2f28ee1532639c9a9f3 to your computer and use it in GitHub Desktop.
task :add_exercises do
require Config.lib+'server'
include Wordcabin
Exercise.connection
loop do
print "name ('DONE' to end input): "
name = STDIN.gets.chomp
p(name)
break if name.include? "DONE"
print "html ('NEXT' for next item, precede with 'DONE' to end input): "
html = STDIN.gets("NEXT").chomp
break if html.include? "DONE"
x = Exercise.new(
type: Wordcabin::ExerciseTypes::Fake.to_s,
name: name,
html: html.gsub(/NEXT/, '')
)
x.save; puts "Saved #{x.id}"
end
end
$ rake wordcabin:add_exercises
Configuring database /home/fub/wordcabin/data/aop/databases/all_books.sqlite3
name ('DONE' to end input): joifwjfoiew
"joifwjfoiew"
html ('NEXT' for next item, precede with 'DONE' to end input): oijewjfoioif
NEXT
Saved 118
name ('DONE' to end input): ""
html ('NEXT' for next item, precede with 'DONE' to end input):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment