Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CSV to Gmail Rules conversion

  • Loading branch information...
commit cac095650435692ce64b882a36d124c227fdc386 1 parent 85a164a
@iloveitaly authored
Showing with 36 additions and 0 deletions.
  1. +36 −0 convert.rb
View
36 convert.rb
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'fastercsv'
+
+# rule data is formatted in a "email, email box path" format
+rule_data = FasterCSV.table("sample_rules.csv", :force_quotes => true)
+
+# example gmail rules:
+# <entry>
+# <category term='filter'></category>
+# <title>Mail Filter</title>
+# <id>tag:mail.google.com,2008:filter:1326039218652</id>
+# <updated>2012-01-12T19:19:49Z</updated>
+# <content></content>
+# <apps:property name='from' value='donotreply@airbrake.io'/>
+# <apps:property name='label' value='Services'/>
+# <apps:property name='shouldArchive' value='true'/>
+# </entry>
+
+gmail_rules = ""
+template = %Q(
+<entry>
+ <category term='filter'></category>
+ <title>%s</title>
+ <apps:property name='from' value='%s/>
+ <apps:property name='label' value='%s'/>
+ <apps:property name='shouldArchive' value='true'/>
+</entry>
+)
+
+rule_data.each do |row|
+ gmail_rules += template % ["", row[0], row[1]]
+end
+
+puts gmail_rules
Please sign in to comment.
Something went wrong with that request. Please try again.