Created
February 7, 2012 23:27
Revisions
-
BPScott created this gist
Feb 7, 2012 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #Place in the root of your fuckingawesomesongs.com folder #I convert the current contents of songs.rb into a one file per song structure require 'YAML' require_relative 'lib/songs' def slugify string string.downcase.gsub(/&/, 'and').gsub(/\s+/, '-').gsub(/[^a-z0-9-]/, '') end Songs.all.each do |song| artist = song[:artist] track = song[:track] url = song[:url] yaml_filename = "songs/#{slugify(artist)}-#{slugify(track)}.yml" yaml_content = "artist: #{artist}\ntrack: #{track}\nurl: #{url}" File.open yaml_filename, 'w' do |f| f.write yaml_content end end