Permalink
Browse files

clean up cruft

  • Loading branch information...
1 parent 2828c90 commit 564347652eedf2f134ea300304899b9e6b61a56b @amro committed Jun 8, 2012
Showing with 62 additions and 182 deletions.
  1. +1 −16 Gemfile
  2. +1 −1 LICENSE.txt
  3. +8 −10 README.markdown
  4. +6 −44 Rakefile
  5. +0 −1 VERSION
  6. +21 −82 gibbon.gemspec
  7. +1 −28 lib/gibbon.rb
  8. +24 −0 lib/gibbon_export.rb
View
17 Gemfile
@@ -1,18 +1,3 @@
source "http://rubygems.org"
-gem "json", "> 1.4.0"
-gem "httparty", "> 0.6.0"
-gem "rdoc"
-
-group :development, :test do
- gem "shoulda", ">= 0"
- gem "bundler", "~> 1.0.0"
- gem "jeweler", "~> 1.5.1"
- gem 'simplecov', :require => false
- gem "mocha", "> 0.9.11"
-
- unless ENV["CI"]
- gem "ruby-debug19", :require => "ruby-debug", :platforms => [:ruby_19]
- gem "ruby-debug", :platforms => [:ruby_18]
- end
-end
+gemspec
View
@@ -1,4 +1,4 @@
-Copyright (c) 2010 Amro Mousa
+Copyright (c) 2010-2012 Amro Mousa
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
@@ -1,6 +1,6 @@
# gibbon
-Gibbon is a simple API wrapper for interacting with [MailChimp API](http://www.mailchimp.com/api) 1.3.
+Gibbon is a simple wrapper for MailChimp's [Primary and Export APIs](http://www.mailchimp.com/api).
[![Build Status](https://secure.travis-ci.org/amro/gibbon.png)](http://travis-ci.org/amro/gibbon)
@@ -25,7 +25,7 @@ You can set your api_key globally and call class methods:
Gibbon.api_key = "your_api_key"
Gibbon.lists
-You can also set the environment variable 'MC_API_KEY' and Gibbon will use it when you create an instance:
+You can also set the environment variable `MC_API_KEY` and Gibbon will use it when you create an instance:
u = Gibbon.new
@@ -73,16 +73,14 @@ Gibbon defaults to a 30 second timeout. You can optionally set your own timeout
### Export API usage
-In addition to the standard API you can make calls to the
-[MailChimp Export API](http://apidocs.mailchimp.com/export/1.0/) using a GibbonExport object. Given an existing
-Gibbon object you can request a new GibbonExporter object:
+In addition to the primary API, you can make calls to the [Export API](http://apidocs.mailchimp.com/export/1.0/) using an instance of GibbonExport. Given an existing instance of Gibbon, you can request a new GibbonExporter object:
- g = Gibbon.new(@api_key)
+ g = Gibbon.new("your_api_key")
gibbon_export = g.get_exporter
or you can construct a new object directly:
- gibbon_export = GibbonExport.new(@api_key)
+ gibbon_export = GibbonExport.new("your_api_key")
Calling Export API functions is identical to making standard API calls but the
return value is an Enumerator which loops over the lines returned from the
@@ -111,7 +109,7 @@ Gibbon will attempt to intercept the errors and raise an exception.
* [Michael Klishin](https://github.com/michaelklishin)
* Rails for camelize gsub
-##Copyrights
+##Copyright
-* Copyright (c) 2010 Amro Mousa. See LICENSE.txt for details.
-* MailChimp (c) 2001-2010 The Rocket Science Group.
+* Copyright (c) 2010-2012 Amro Mousa. See LICENSE.txt for details.
+* MailChimp (c) 2001-2012 The Rocket Science Group.
View
@@ -1,47 +1,9 @@
-require 'rubygems'
-require 'bundler'
-begin
- Bundler.setup(:default, :development)
-rescue Bundler::BundlerError => e
- $stderr.puts e.message
- $stderr.puts "Run `bundle install` to install missing gems"
- exit e.status_code
-end
-require 'rake'
-
-require 'jeweler'
-Jeweler::Tasks.new do |gem|
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
- gem.name = "gibbon"
- gem.homepage = "http://github.com/amro/gibbon"
- gem.license = "MIT"
- gem.summary = %Q{Gibbon is a simple API wrapper for interacting with MailChimp API 1.3}
- gem.description = %Q{Gibbon is a simple API wrapper for interacting with MailChimp API version 1.3.}
- gem.email = "amromousa@gmail.com"
- gem.authors = ["Amro Mousa"]
- # Include your dependencies below. Runtime dependencies are required when using your gem,
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
- gem.add_runtime_dependency 'httparty', '> 0.6.0'
- gem.add_runtime_dependency 'json', '> 1.4.0'
- gem.add_development_dependency 'mocha', '> 0.9.11'
-end
-Jeweler::RubygemsDotOrgTasks.new
-
+require "bundler/gem_tasks"
require 'rake/testtask'
-Rake::TestTask.new(:test) do |test|
- test.libs << 'lib' << 'test'
- test.pattern = 'test/**/test_*.rb'
- test.verbose = true
-end
-
-task :default => :test
-require 'rdoc/task'
-Rake::RDocTask.new do |rdoc|
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
-
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = "gibbon #{version}"
- rdoc.rdoc_files.include('README*')
- rdoc.rdoc_files.include('lib/**/*.rb')
+Rake::TestTask.new do |t|
+ t.libs << 'test'
end
+
+desc "Run tests"
+task :default => :test
View
@@ -1 +0,0 @@
-0.3.6
View
@@ -1,90 +1,29 @@
-# Generated by jeweler
-# DO NOT EDIT THIS FILE DIRECTLY
-# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
Gem::Specification.new do |s|
- s.name = "gibbon"
- s.version = "0.3.5"
+ s.name = "gibbon"
+ s.version = "0.4.0"
+ s.authors = ["Amro Mousa"]
+ s.email = ["amromousa@gmail.com"]
+ s.homepage = "http://github.com/amro/gibbon"
+ s.summary = %q{A simple wrapper for MailChimp's primary and export APIs}
+ s.description = %q{A simple wrapper for MailChimp's primary and export APIs}
+ s.license = "MIT"
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Amro Mousa"]
- s.date = "2011-12-09"
- s.description = "Gibbon is a simple API wrapper for interacting with MailChimp API version 1.3."
- s.email = "amromousa@gmail.com"
- s.extra_rdoc_files = [
- "LICENSE.txt",
- "README.markdown"
- ]
- s.files = [
- ".document",
- ".travis.yml",
- "Gemfile",
- "LICENSE.txt",
- "README.markdown",
- "Rakefile",
- "VERSION",
- "gibbon.gemspec",
- "lib/gibbon.rb",
- "test/helper.rb",
- "test/test_gibbon.rb"
- ]
- s.homepage = "http://github.com/amro/gibbon"
- s.licenses = ["MIT"]
- s.require_paths = ["lib"]
- s.rubygems_version = "1.8.10"
- s.summary = "Gibbon is a simple API wrapper for interacting with MailChimp API 1.3"
- s.test_files = [
- "test/helper.rb",
- "test/test_gibbon.rb"
- ]
+ s.rubyforge_project = "gibbon"
- if s.respond_to? :specification_version then
- s.specification_version = 3
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<json>, ["> 1.4.0"])
- s.add_runtime_dependency(%q<httparty>, ["> 0.6.0"])
- s.add_runtime_dependency(%q<rdoc>, [">= 0"])
- s.add_development_dependency(%q<shoulda>, [">= 0"])
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
- s.add_development_dependency(%q<simplecov>, [">= 0"])
- s.add_development_dependency(%q<mocha>, ["> 0.9.11"])
- s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
- s.add_development_dependency(%q<ruby-debug>, [">= 0"])
- s.add_runtime_dependency(%q<httparty>, ["> 0.6.0"])
- s.add_runtime_dependency(%q<json>, ["> 1.4.0"])
- s.add_development_dependency(%q<mocha>, ["> 0.9.11"])
- else
- s.add_dependency(%q<json>, ["> 1.4.0"])
- s.add_dependency(%q<httparty>, ["> 0.6.0"])
- s.add_dependency(%q<rdoc>, [">= 0"])
- s.add_dependency(%q<shoulda>, [">= 0"])
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
- s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
- s.add_dependency(%q<simplecov>, [">= 0"])
- s.add_dependency(%q<mocha>, ["> 0.9.11"])
- s.add_dependency(%q<ruby-debug19>, [">= 0"])
- s.add_dependency(%q<ruby-debug>, [">= 0"])
- s.add_dependency(%q<httparty>, ["> 0.6.0"])
- s.add_dependency(%q<json>, ["> 1.4.0"])
- s.add_dependency(%q<mocha>, ["> 0.9.11"])
- end
- else
- s.add_dependency(%q<json>, ["> 1.4.0"])
- s.add_dependency(%q<httparty>, ["> 0.6.0"])
- s.add_dependency(%q<rdoc>, [">= 0"])
- s.add_dependency(%q<shoulda>, [">= 0"])
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
- s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
- s.add_dependency(%q<simplecov>, [">= 0"])
- s.add_dependency(%q<mocha>, ["> 0.9.11"])
- s.add_dependency(%q<ruby-debug19>, [">= 0"])
- s.add_dependency(%q<ruby-debug>, [">= 0"])
- s.add_dependency(%q<httparty>, ["> 0.6.0"])
- s.add_dependency(%q<json>, ["> 1.4.0"])
- s.add_dependency(%q<mocha>, ["> 0.9.11"])
- end
+ s.add_dependency('httparty')
+ s.add_dependency('json')
+
+ s.add_development_dependency('shoulda')
+ s.add_development_dependency('simplecov')
+ s.add_development_dependency('mocha')
+ s.add_development_dependency('debugger')
end
View
@@ -28,8 +28,7 @@ def base_api_url
"https://#{dc_from_api_key}api.mailchimp.com/1.3/?method="
end
-protected
-
+ protected
def call(method, params = {})
api_url = base_api_url + method
params = @default_params.merge(params)
@@ -64,32 +63,6 @@ def dc_from_api_key
(@api_key.nil? || @api_key.empty? || @api_key !~ /-/) ? '' : "#{@api_key.split("-").last}."
end
end
-
-class GibbonExport < Gibbon
- def initialize(api_key = nil, extra_params = {})
- super(api_key, extra_params)
- end
-
-protected
-
- def export_api_url
- "http://#{dc_from_api_key}api.mailchimp.com/export/1.0/"
- end
-
- def call(method, params = {})
- api_url = export_api_url + method + "/"
- params = @default_params.merge(params)
- response = self.class.post(api_url, :body => params, :timeout => @timeout)
-
- lines = response.body.lines
- if @throws_exceptions
- first_line_object = JSON.parse(lines.first) if lines.first
- raise "Error from MailChimp Export API: #{first_line_object["error"]} (code #{first_line_object["code"]})" if first_line_object.is_a?(Hash) && first_line_object["error"]
- end
-
- lines
- end
-end
module HTTParty
module HashConversions
View
@@ -0,0 +1,24 @@
+class GibbonExport < Gibbon
+ def initialize(api_key = nil, extra_params = {})
+ super(api_key, extra_params)
+ end
+
+ protected
+ def export_api_url
+ "http://#{dc_from_api_key}api.mailchimp.com/export/1.0/"
+ end
+
+ def call(method, params = {})
+ api_url = export_api_url + method + "/"
+ params = @default_params.merge(params)
+ response = self.class.post(api_url, :body => params, :timeout => @timeout)
+
+ lines = response.body.lines
+ if @throws_exceptions
+ first_line_object = JSON.parse(lines.first) if lines.first
+ raise "Error from MailChimp Export API: #{first_line_object["error"]} (code #{first_line_object["code"]})" if first_line_object.is_a?(Hash) && first_line_object["error"]
+ end
+
+ lines
+ end
+end

0 comments on commit 5643476

Please sign in to comment.