Skip to content

Instantly share code, notes, and snippets.

@dodeja
Created February 25, 2009 22:22
Show Gist options
  • Select an option

  • Save dodeja/70472 to your computer and use it in GitHub Desktop.

Select an option

Save dodeja/70472 to your computer and use it in GitHub Desktop.
public_path = File.expand_path("public") + "/assets/sets"
if(!File.directory?(public_path+"/#{@dj_set.podcast.alias}"))
Dir.mkdir(public_path+"/#{@dj_set.podcast.alias}")
end
if(!File.file?(public_path+"/#{@dj_set.podcast.alias}/#{@dj_set.setTitle}.xml"))
xml_file = File.new(public_path+"/#{@dj_set.podcast.alias}/#{@dj_set.setTitle}.xml","w")
xml_file.puts @dj_set.to_xml(@dj_set)
xml_file.close
end
if(!File.file?(public_path+"/#{@dj_set.podcast.alias}/#{@dj_set.setTitle}.json"))
json_file = File.new(public_path+"/#{@dj_set.podcast.alias}/#{@dj_set.setTitle}.json","w")
json_file.puts @dj_set.tracks.to_json( :include => { :artist => { :only => [:name, :large] } })
json_file.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment