Class: MtgDb::CLI
Constant Summary
Constants included from MtgDb
ALL_CARDS_DIR, DOUBLE_FACED_DIR, SCHEMA_FILENAME, SQLITE3_HEADER_STRING, SQLITE3_HEADER_STRING_LENGTH, TMP_DIR, VERSION
Instance Method Summary collapse
-
#create(name) ⇒ Object
TODO: Add quiet option option :quiet, :type => :boolean.
- #mangle(name) ⇒ Object
Methods included from MtgDb
add_all_cards_to_db, add_double_faced_cards_to_db, create_db, download_all_cards, download_double_faced_cards, is_sqlite3?, mangle
Instance Method Details
#create(name) ⇒ Object
TODO: Add quiet option option :quiet, :type => :boolean
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mtg_db/cli.rb', line 16 def create(name) name = File.(name) tmp_dir = File.([:tmp_dir]) puts "Creating empty database: #{name}" MtgDb.create_db(name) puts "Downloading all cards to #{tmp_dir}, this will take a while..." MtgDb.download_all_cards(tmp_dir) puts 'Adding cards to the database...' MtgDb.add_all_cards_to_db(name, tmp_dir) # Now that all the cards are in the Db, we need to establish # relationships between them for the double-faced cards puts 'Downloading transformable/double-faced cards...' MtgDb.download_double_faced_cards(name, tmp_dir) MtgDb.add_double_faced_cards_to_db(name, tmp_dir) end |
#mangle(name) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/mtg_db/cli.rb', line 37 def mangle(name) name = File.(name) if not MtgDb.is_sqlite3?(name) puts "File is either already mangled or not an SQLite3 database: #{name}" else puts 'Mangling the SQLite3 file header' MtgDb.mangle(name) end end |