Commits

shl...@iglu.org.il@cec68495-dca5-4e2b-845c-11fdaaa4f967  committed 613f2a6

Convert populate-sqlite to Shlomif::Homepage::FortuneCollections.

  • Participants
  • Parent commits cb2c17c

Comments (0)

Files changed (2)

 $(FORTUNES_ATOM_FEED) $(FORTUNES_RSS_FEED): $(T2_FORTUNES_DIR)/generate-web-feeds.pl $(FORTUNES_XMLS_SRC)
 	perl $< --atom $(FORTUNES_ATOM_FEED) --rss $(FORTUNES_RSS_FEED) --dir $(T2_FORTUNES_DIR)
 
-$(FORTUNES_SQLITE_DB): $(T2_FORTUNES_DIR)/populate-sqlite-database.pl $(FORTUNES_XHTMLS)
-	perl $<
+$(FORTUNES_SQLITE_DB): $(T2_FORTUNES_DIR)/populate-sqlite-database.pl $(FORTUNES_XHTMLS) lib/Shlomif/Homepage/FortuneCollections.pm
+	perl -Ilib $<
 
 $(DOCBOOK4_INSTALLED_INDIVIDUAL_XHTMLS_CSS): %: $(DOCMAKE_STYLE_CSS)
 	cp -f $< $@

File t2/humour/fortunes/populate-sqlite-database.pl

 
 use HTML::TreeBuilder::LibXML;
 use DBI;
-use File::Spec;
-use IO::All;
+
+use Shlomif::Homepage::FortuneCollections;
 
 STDOUT->autoflush(1);
 
 
 my $insert_sth = $dbh->prepare("INSERT INTO fortune_cookies (str_id, text) VALUES(?, ?)");
 
-my @lines = io->file("$script_dir/fortunes-list.mak")->getlines();
-my @file_bases = (map { /(\b[a-z_\-]+\b)/g } @lines);
+my @file_bases =
+(
+    map { $_->id() } 
+    @{Shlomif::Homepage::FortuneCollections->sorted_fortunes()},
+);
 
 # We split the work to 50-items batches per the advice on 
 # Freenode's #perl by tm604 and jql.