postini 0.1.1 → 0.2.0pre

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ nbproject
2
+ pkg
3
+ doc
4
+ vendor/troelskn-handsoap-*
5
+ *.swp
6
+ .yardoc
7
+ pkg
data/README.txt CHANGED
@@ -13,7 +13,7 @@ Rubyisms.
13
13
 
14
14
  == FEATURES/PROBLEMS:
15
15
 
16
- * Built on top of handsoap[http://github.com/troelskn/handsoap], to
16
+ * Built on top of handsoap[http://github.com/unwire/handsoap], to
17
17
  provide a lite hash-based interface to an otherwise crap API.
18
18
 
19
19
  == SYNOPSIS:
@@ -29,12 +29,15 @@ Rubyisms.
29
29
 
30
30
  * Approved access to the Postini Early Access Program (contact your Postini
31
31
  provider)
32
- * handsoap[http://github.com/troelskn/handsoap]
32
+ * handsoap[http://github.com/unwire/handsoap]
33
+ * nokogiri[http://nokogiri.org]
34
+ * curb[http://github.com/taf2/curb]
33
35
 
34
36
  == INSTALL:
35
37
 
36
- * sudo gem install troelskn-handsoap --source http://gems.github.com
37
- * sudo gem install postini
38
+ The postini gem is available on Gemcutter[http://gemcutter.org]
39
+
40
+ * gem install postini
38
41
 
39
42
  == TRADEMARKS:
40
43
 
data/Rakefile CHANGED
@@ -1,29 +1,38 @@
1
- require 'rubygems' unless ENV['NO_RUBYGEMS']
2
- %w[rake rake/clean fileutils newgem rubigen].each { |f| require f }
3
1
  require File.dirname(__FILE__) + '/lib/postini'
4
2
 
5
- # Generate all the Rake tasks
6
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
7
- $hoe = Hoe.new('postini', Postini::VERSION) do |p|
8
- p.developer('Kenneth Kalmer', 'kenneth.kalmer@gmail.com')
9
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
10
- p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
11
- p.rubyforge_name = 'postini4r' # TODO this is default value
12
- # p.extra_deps = [
13
- # ['activesupport','>= 2.0.2'],
14
- # ]
15
- p.extra_dev_deps = [
16
- ['newgem', ">= #{::Newgem::VERSION}"]
17
- ]
18
-
19
- p.clean_globs |= %w[**/.DS_Store tmp *.log]
20
- path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
21
- p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
22
- p.rsync_args = '-av --delete --ignore-errors'
3
+ Dir['tasks/**/*.rake'].each { |t| load t }
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gemspec|
8
+ gemspec.name = 'postini'
9
+ gemspec.version = Postini::VERSION
10
+ gemspec.summary = 'Library to make the Postini SOAP API more palatable'
11
+ gemspec.description = 'Library to make the Postini SOAP API more palatable'
12
+ gemspec.email = 'kenneth.kalmer@gmail.com'
13
+ gemspec.homepage = 'http://postini4r.rubyforge.org'
14
+ gemspec.authors = ['kenneth.kalmer@gmail.com']
15
+ gemspec.post_install_message = IO.read('PostInstall.txt')
16
+ gemspec.extra_rdoc_files.include '*.txt'
17
+
18
+ gemspec.add_dependency 'handsoap'
19
+ gemspec.add_dependency 'curb'
20
+ gemspec.add_dependency 'nokogiri'
21
+ gemspec.add_development_dependency 'rspec'
22
+ gemspec.add_development_dependency 'cucumber'
23
+ end
24
+ Jeweler::GemcutterTasks.new
25
+ rescue LoadError
26
+ puts "Jeweler not available. Install it with 'gem install jeweler'"
23
27
  end
24
28
 
25
- require 'newgem/tasks' # load /tasks/*.rake
26
- Dir['tasks/**/*.rake'].each { |t| load t }
29
+ begin
30
+ require 'yard'
31
+ YARD::Rake::YardocTask.new
32
+ rescue LoadError
33
+ desc "Build YARD documentation"
34
+ task :yardoc do
35
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
36
+ end
37
+ end
27
38
 
28
- # TODO - want other tests/tasks run by default? Add them to the list
29
- # task :default => [:spec, :features]
@@ -0,0 +1,2 @@
1
+ host: kennethkalmer@rubyforge.org
2
+ remote_dir: /var/www/gforge-projects/kit/postini4r/postini
@@ -202,6 +202,46 @@ module Postini
202
202
  end
203
203
  requires_configured :display_user
204
204
 
205
+ # Return a list of orgs, possibly filtered and sorted. Refer to the Postini
206
+ # Automated Batch Service Manual for an explanation of each field.
207
+ #
208
+ # Possible options are:
209
+ #
210
+ # :targetOrg => string
211
+ # :childorgs => boolean
212
+ # :sort => string
213
+ # :fields => array (strings)
214
+ # :start => integer
215
+ # :end => integer
216
+ #
217
+ # Postini will return a maximum of 15,000 results
218
+ def list_orgs( query_string = 'ALL', options = {} )
219
+ valid_options = {}
220
+
221
+ # vanilla copes
222
+ [ :targetOrg, :sort, :start, :end ].each do |k|
223
+ valid_options[k] = options[k] if options.has_key?(k)
224
+ end
225
+
226
+ # boolean copies
227
+ valid_options[:childorgs] = ( options[:childorgs] ? '1' : '0' ) if options.has_key?(:childorgs)
228
+
229
+ valid_options[:fields] = options[:fields].join('|') if options.has_key?(:fields)
230
+
231
+ response = invoke("aut:listorgs") do |message|
232
+ build_auth!( message )
233
+ message.add('queryString', query_string)
234
+ message.add('queryParams') do |q|
235
+ valid_options.each do |k,v|
236
+ q.add( k.to_s, v )
237
+ end
238
+ end
239
+ end
240
+
241
+ parse_list_orgs_results( response.document.xpath('//tns:listorgsResponse', tns).first )
242
+ end
243
+ requires_configured :list_orgs
244
+
205
245
  # Return a list of users, possibly filtered and sorted. Refer to
206
246
  # the Postini Automated Batch Service Manual for an explanation of
207
247
  # each field.
@@ -514,6 +554,94 @@ module Postini
514
554
  data
515
555
  end
516
556
 
557
+ def parse_list_orgs_results( node )
558
+ # <tns:listorgsResponse>
559
+ # <org>
560
+ # <approved_senders>
561
+ # <archive>
562
+ # <async_bounce>
563
+ # <at_notify_on>
564
+ # <authentication_data>
565
+ # <authentication_type>
566
+ # <autocreate_smtp>
567
+ # <autocreate_web>
568
+ # <blatant_spam>
569
+ # <blocked_senders>
570
+ # <bounce_fragments>
571
+ # <company_name>
572
+ # <create_method>
573
+ # <created_date>
574
+ # <creator>
575
+ # <default_message_limit>
576
+ # <default_user>
577
+ # <disable_first_spam>
578
+ # <disposition_virus>
579
+ # <ext_encrypt>
580
+ # <footer_on>
581
+ # <iid>
582
+ # <im_enable>
583
+ # <im_external_enable>
584
+ # <im_proto_enable>
585
+ # <is_email_config>
586
+ # <lang_locale>
587
+ # <lastmod_date>
588
+ # <max_message_size>
589
+ # <ndr>
590
+ # <non_account_bounce>
591
+ # <non_account_virus_scan>
592
+ # <orgname>
593
+ # <out_at_notify_on>
594
+ # <outbound_max_message_size>
595
+ # <outbound_virus>
596
+ # <outbound_virus_disposition>
597
+ # <parent_org>
598
+ # <qsum_actionable>
599
+ # <qsum_enable>
600
+ # <qtine_redir_atq>
601
+ # <qtine_redir_ndr>
602
+ # <qtine_redir_out_atq>
603
+ # <qtine_redir_out_virus>
604
+ # <qtine_redir_spam>
605
+ # <qtine_redir_virus>
606
+ # <quarantine_links>
607
+ # <remotecmd_secret>
608
+ # <spam_notify_on>
609
+ # <support_contact>
610
+ # <tagonly_spam>
611
+ # <timezone>
612
+ # <tls_notify_admin>
613
+ # <tls_notify_on>
614
+ # <virus_clean>
615
+ # <virus_notify>
616
+ # <welcome_on>
617
+ # <zero_hour_notify_on>
618
+ # <zero_hour_scan>
619
+ # <zero_hour_waiver>
620
+ # </org>
621
+ # <org>
622
+ # ...
623
+ # </org>
624
+ # </tns:listusersResponse>
625
+
626
+ data = {}
627
+
628
+ node.xpath('./org').each do |org|
629
+
630
+ name = org.xpath('./orgname/text()').to_s
631
+ fields = {}
632
+
633
+ org.children.each do |field|
634
+ next if field.node_name == 'orgname'
635
+
636
+ fields[ field.node_name.to_sym ] = field.to_s
637
+ end
638
+
639
+ data[ name ] = fields
640
+ end
641
+
642
+ data
643
+ end
644
+
517
645
  def parse_list_users_results( node )
518
646
  # <tns:listusersResponse>
519
647
  # <user>
@@ -525,7 +653,7 @@ module Postini
525
653
  # </user>
526
654
  # <user>
527
655
  # ...
528
- # </user
656
+ # </user>
529
657
  # </tns:listusersResponse>
530
658
 
531
659
  data = {}
@@ -536,9 +664,9 @@ module Postini
536
664
  fields = {}
537
665
 
538
666
  user.children.each do |field|
539
- next if field.name == 'address'
667
+ next if field.node_name == 'address'
540
668
 
541
- fields[ field.name.to_sym ] = field.content
669
+ fields[ field.node_name.to_sym ] = field.to_s
542
670
  end
543
671
 
544
672
  data[ address ] = fields
data/lib/postini.rb CHANGED
@@ -3,6 +3,8 @@ $:.unshift(File.dirname(__FILE__)) unless
3
3
 
4
4
  # requirements
5
5
  require 'rubygems'
6
+ require 'curb'
7
+ require 'nokogiri'
6
8
  require 'handsoap'
7
9
 
8
10
  require 'postini/exceptions'
@@ -76,7 +78,7 @@ require 'postini/exceptions'
76
78
  # degrees, and allow you to access some soap4r internals as well.
77
79
  #
78
80
  module Postini
79
- VERSION = "0.1.1"
81
+ VERSION = "0.2.0pre"
80
82
 
81
83
  autoload :ConfigurationCheck, "postini/configuration_check"
82
84
  autoload :Endpoints, "postini/endpoints"
@@ -92,9 +94,9 @@ module Postini
92
94
 
93
95
  def configured? #:nodoc:
94
96
  !self.api_key.nil? &&
95
- !self.system_number.nil? &&
96
- !self.username.nil? &&
97
- !self.password.nil?
97
+ !self.system_number.nil? &&
98
+ !self.username.nil? &&
99
+ !self.password.nil?
98
100
  end
99
101
 
100
102
  # Configure the library from yaml configuration file or
@@ -114,6 +116,9 @@ module Postini
114
116
  data.each do |k,v|
115
117
  self.send( "#{k}=", v )
116
118
  end
119
+
120
+ # Cope with trans-continental links
121
+ Handsoap.timeout = 300
117
122
  end
118
123
  end
119
124
  end
data/postini.gemspec ADDED
@@ -0,0 +1,106 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{postini}
8
+ s.version = "0.2.0pre"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["kenneth.kalmer@gmail.com"]
12
+ s.date = %q{2010-09-27}
13
+ s.description = %q{Library to make the Postini SOAP API more palatable}
14
+ s.email = %q{kenneth.kalmer@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "History.txt",
17
+ "License.txt",
18
+ "PostInstall.txt",
19
+ "README.txt",
20
+ "TODO"
21
+ ]
22
+ s.files = [
23
+ ".gitignore",
24
+ "History.txt",
25
+ "License.txt",
26
+ "PostInstall.txt",
27
+ "README.txt",
28
+ "Rakefile",
29
+ "TODO",
30
+ "config/website.yml",
31
+ "features/development.feature",
32
+ "features/step_definitions/common_steps.rb",
33
+ "features/support/common.rb",
34
+ "features/support/env.rb",
35
+ "features/support/matchers.rb",
36
+ "lib/postini.rb",
37
+ "lib/postini/automated_batch_service.rb",
38
+ "lib/postini/configuration_check.rb",
39
+ "lib/postini/endpoint_resolver_service.rb",
40
+ "lib/postini/endpoints.rb",
41
+ "lib/postini/exceptions.rb",
42
+ "postini.gemspec",
43
+ "script/console",
44
+ "script/destroy",
45
+ "script/generate",
46
+ "script/txt2html",
47
+ "spec/exceptions_spec.rb",
48
+ "spec/postini_spec.rb",
49
+ "spec/rcov.opts",
50
+ "spec/spec.opts",
51
+ "spec/spec_helper.rb",
52
+ "tasks/rspec.rake",
53
+ "vendor/automatedbatch.wsdl",
54
+ "vendor/endpointresolver.wsdl",
55
+ "website/index.txt",
56
+ "website/javascripts/rounded_corners_lite.inc.js",
57
+ "website/spam_box.png",
58
+ "website/stylesheets/screen.css",
59
+ "website/template.html.erb"
60
+ ]
61
+ s.homepage = %q{http://postini4r.rubyforge.org}
62
+ s.post_install_message = %q{
63
+ For more information on postini4r's postini gem, see
64
+ http://postini4r.rubyforge.org/postini
65
+
66
+ Remember to contact your Postini provider, or Postini directly, to gain access
67
+ to the Postini Early Access Program. You'll need a unique API key to make use
68
+ of this gem.
69
+
70
+ }
71
+ s.rdoc_options = ["--charset=UTF-8"]
72
+ s.require_paths = ["lib"]
73
+ s.rubygems_version = %q{1.3.7}
74
+ s.summary = %q{Library to make the Postini SOAP API more palatable}
75
+ s.test_files = [
76
+ "spec/exceptions_spec.rb",
77
+ "spec/postini_spec.rb",
78
+ "spec/spec_helper.rb"
79
+ ]
80
+
81
+ if s.respond_to? :specification_version then
82
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
83
+ s.specification_version = 3
84
+
85
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
86
+ s.add_runtime_dependency(%q<handsoap>, [">= 0"])
87
+ s.add_runtime_dependency(%q<curb>, [">= 0"])
88
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
89
+ s.add_development_dependency(%q<rspec>, [">= 0"])
90
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
91
+ else
92
+ s.add_dependency(%q<handsoap>, [">= 0"])
93
+ s.add_dependency(%q<curb>, [">= 0"])
94
+ s.add_dependency(%q<nokogiri>, [">= 0"])
95
+ s.add_dependency(%q<rspec>, [">= 0"])
96
+ s.add_dependency(%q<cucumber>, [">= 0"])
97
+ end
98
+ else
99
+ s.add_dependency(%q<handsoap>, [">= 0"])
100
+ s.add_dependency(%q<curb>, [">= 0"])
101
+ s.add_dependency(%q<nokogiri>, [">= 0"])
102
+ s.add_dependency(%q<rspec>, [">= 0"])
103
+ s.add_dependency(%q<cucumber>, [">= 0"])
104
+ end
105
+ end
106
+
data/website/index.txt ADDED
@@ -0,0 +1,60 @@
1
+ h1. postini Gem
2
+ h2. Part of the postini4r project
3
+
4
+ The postini4r project is a collection of sub-projects that aim to implement a broad range of Postini-related tools.
5
+
6
+ h2. What
7
+
8
+ The postini gem is a Ruby wrapper library for the "Postini":http://www.postini.com/ SOAP API (Early Access Program).
9
+
10
+ The postini gem aims to be fully compliant with the Postini API, starting off with what I need first, and then expanding to eventually cover all the available commands in the Batch Command Reference.
11
+
12
+ h2. Requirements
13
+
14
+ * The postini gem requires that you gain access to the Postini Early Access Program and an API key. You need to contact your Postini Service Provider (or Postini directly if you deal with them).
15
+ * soap4r
16
+
17
+ h2. Installing
18
+
19
+ <pre syntax="ruby">sudo gem install postini</pre>
20
+
21
+ h2. Demonstration of usage
22
+
23
+ TODO - Coming soon, refer to the current specs for some samples
24
+
25
+ h2. Forum
26
+
27
+ "http://groups.google.com/group/postini-ruby":http://groups.google.com/group/postini-ruby
28
+
29
+ Join us in the postini-ruby group for discussing everything aroung Postini and Ruby, and possibly Postini in general.
30
+
31
+ h2. How to submit patches
32
+
33
+ Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
34
+
35
+ You can fetch the source from:
36
+
37
+ * github: "http://github.com/kennethkalmer/postini4r-postini/tree/master":http://github.com/kennethkalmer/postini4r-postini/tree/master
38
+
39
+ <pre>git clone git://github.com/kennethkalmer/postini4r-postini.git</pre>
40
+
41
+
42
+ h3. Build and test instructions
43
+
44
+ <pre>cd postini4r-postini
45
+ rake spec
46
+ rake install_gem</pre>
47
+
48
+
49
+ h2. License
50
+
51
+ This code is free to use under the terms of the MIT license.
52
+
53
+ h2. Contact
54
+
55
+ Comments are welcome. Send an email to "me":mailto:kenneth.kalmer@gmail.com via the "forum":http://groups.google.com/group/postini4r
56
+
57
+ h2. Credits
58
+
59
+ postini4r is developed by "Kenneth Kalmer":http://www.opensourcery.co.za/ for "SPAM in a Box":http://www.spaminabox.co.za who has allowed the library to be released under the MIT License through their sponsorship.
60
+