Skip to content

Commit

Permalink
setup initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
bbwharris committed Jul 24, 2011
0 parents commit e8a814d
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
*.gem
3 changes: 3 additions & 0 deletions Gemfile
@@ -0,0 +1,3 @@
source :rubygems

gemspec
4 changes: 4 additions & 0 deletions Manifest
@@ -0,0 +1,4 @@
Manifest
README.rdoc
Rakefile
lib/mailchimp_subscriber.rb
Empty file added README.rdoc
Empty file.
11 changes: 11 additions & 0 deletions Rakefile
@@ -0,0 +1,11 @@
require 'rubygems'
require 'rake'
require 'echoe'

Echoe.new('mailchimp_subscriber', '0.1.0') do |p|
p.description = "Sync user emails with MailChimp mailing lists"
p.url = "http://github.com/bbwharris/mailchimp_subscriber"
p.email = "brandon@brandon-harris.com"
p.ignore_pattern = ["tmp/*", "script/*"]
p.development_dependencies = [['hominid','>= 3.0.2']]
end
22 changes: 22 additions & 0 deletions lib/mailchimp_subscriber.rb
@@ -0,0 +1,22 @@
module MailchimpSubscriber
require 'hominid'

def subscribe_to(listname,options={})
after_create do |record|
begin
email = record.send(options[:using][:email])
content_type = options[:using][:content_type] || 'html'
update_existing = options[:using][:update_existing] || false
replace_interests = options[:using][:replace_interests] || false
send_welcome = options[:using][:send_welcome] || false

client = Hominid::API.new(mailchimp_api_key)
list_id = h.find_list_by_name(listname)['id']
client.list_subscribe(list_id, email, {}, type, double_optin, update_existing, replace_interests, send_welcome)
rescue RuntimeError
end
end


end
end
21 changes: 21 additions & 0 deletions mailchimp_subscriber.gemspec
@@ -0,0 +1,21 @@
$:.push File.expand_path("../lib", __FILE__)

Gem::Specification.new do |s|
s.name = "mailchimp_subscriber"
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.authors = ["Brandon Harris"]
s.email = ["brandon@brandon-harris.com"]
s.homepage = "https://github.com/bbwharris/mailchimp_subscriber"
s.summary = %q{Sync user emails with MailChimp mailing lists}
s.description = %q{Sync user emails with MailChimp mailing lists}

s.files = `git ls-files -- {lib/*,vendor/*,*.gemspec}`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_development_dependency 'rails', '>= 3.0.0'
s.add_development_dependency 'hominid', '>= 3.2.0'

ruby_minor_version = RUBY_VERSION.split('.')[1].to_i
end

0 comments on commit e8a814d

Please sign in to comment.