cannikin-postal 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +8 -0
- data/LICENSE +20 -0
- data/README.rdoc +28 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/lib/postal/base.rb +47 -0
- data/lib/postal/list.rb +28 -0
- data/lib/postal/lmapi/lmapi.rb +1311 -0
- data/lib/postal/lmapi/lmapi_driver.rb +687 -0
- data/lib/postal/lmapi/lmapi_mapping_registry.rb +1237 -0
- data/lib/postal/mailing.rb +171 -0
- data/lib/postal/member.rb +115 -0
- data/lib/postal.rb +47 -0
- data/postal.gemspec +63 -0
- data/test/list_test.rb +20 -0
- data/test/lmapiClient.rb +854 -0
- data/test/lyris_sample.yml +14 -0
- data/test/mailing_test.rb +45 -0
- data/test/member_test.rb +67 -0
- data/test/postal_suite.rb +4 -0
- data/test/test_helper.rb +22 -0
- metadata +80 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Rob Cameron
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
= Introduction
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
== Thanks
|
10
|
+
|
11
|
+
Special thanks to this article: http://markthomas.org/2007/09/12/getting-started-with-soap4r/
|
12
|
+
Mark details how to use SOAP4R (for which there is very little documentation in the world) and
|
13
|
+
his example includes talking to Lyris! Postal probably couldn't have happened without his article.
|
14
|
+
|
15
|
+
== Note on Patches/Pull Requests
|
16
|
+
|
17
|
+
* Fork the project.
|
18
|
+
* Make your feature addition or bug fix.
|
19
|
+
* Add tests for it. This is important so I don't break it in a
|
20
|
+
future version unintentionally.
|
21
|
+
* Commit, do not mess with rakefile, version, or history.
|
22
|
+
(if you want to have your own version, that is fine but
|
23
|
+
bump version in a commit by itself I can ignore when I pull)
|
24
|
+
* Send me a pull request. Bonus points for topic branches.
|
25
|
+
|
26
|
+
== Copyright
|
27
|
+
|
28
|
+
Copyright (c) 2009 Rob Cameron. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "postal"
|
8
|
+
gem.summary = %Q{Gem for talking to the Lyris API}
|
9
|
+
gem.description = %Q{Lyris is an enterprise email service. Postal makes it easy for Ruby to talk to Lyris's API.}
|
10
|
+
gem.email = "cannikinn@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/cannikin/postal"
|
12
|
+
gem.authors = ["Rob Cameron"]
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
end
|
15
|
+
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'rake/testtask'
|
21
|
+
Rake::TestTask.new(:test) do |test|
|
22
|
+
test.libs << 'lib' << 'test'
|
23
|
+
test.pattern = 'test/**/*_test.rb'
|
24
|
+
test.verbose = true
|
25
|
+
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
require 'rcov/rcovtask'
|
29
|
+
Rcov::RcovTask.new do |test|
|
30
|
+
test.libs << 'test'
|
31
|
+
test.pattern = 'test/**/*_test.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
rescue LoadError
|
35
|
+
task :rcov do
|
36
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
if File.exist?('VERSION.yml')
|
48
|
+
config = YAML.load(File.read('VERSION.yml'))
|
49
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
50
|
+
else
|
51
|
+
version = ""
|
52
|
+
end
|
53
|
+
|
54
|
+
rdoc.rdoc_dir = 'rdoc'
|
55
|
+
rdoc.title = "postal #{version}"
|
56
|
+
rdoc.rdoc_files.include('README*')
|
57
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
58
|
+
end
|
59
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/postal/base.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
module Postal
|
2
|
+
class Base
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
# Find objects based on some options
|
7
|
+
def find(*args)
|
8
|
+
options = extract_options(args)
|
9
|
+
case args.first
|
10
|
+
when :all then find_all(options)
|
11
|
+
else find_some(args,options)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
# Alias for find(:all)
|
17
|
+
def all
|
18
|
+
find(:all)
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
# Make a new user and immediately save to Lyris
|
23
|
+
def create(*args)
|
24
|
+
instance = self.new(*args)
|
25
|
+
instance.save
|
26
|
+
return instance
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# Make a new user and immediately save to Lyris, but throw an error if the save fails.
|
31
|
+
def create!(*args)
|
32
|
+
instance = self.new(*args)
|
33
|
+
instance.save!
|
34
|
+
return instance
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def extract_options(opts)
|
41
|
+
opts.last.is_a?(::Hash) ? opts.pop : {}
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
data/lib/postal/list.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Postal
|
2
|
+
class List < Postal::Base
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
protected
|
7
|
+
|
8
|
+
# Find one or more lists by name
|
9
|
+
def find_some(names,options={})
|
10
|
+
return Postal.driver.selectLists(names,'')
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
# Find all lists
|
15
|
+
def find_all(options)
|
16
|
+
return Postal.driver.selectLists('','')
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def extract_options(opts)
|
22
|
+
opts.last.is_a?(::Hash) ? opts.pop : {}
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|