mailmanager 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  pkg/mailmanager-*.gem
3
3
  html/*
4
4
  doc/*
5
+ results/*
data/Changelog CHANGED
@@ -1,4 +1,8 @@
1
- Current version is 1.0.12
1
+ Current version is 1.0.13
2
+
3
+ changes since 1.0.12
4
+ - added list description= setter method to List class
5
+ - added subject_prefix & subject_prefix= methods to List class
2
6
 
3
7
  changes since 1.0.11
4
8
  - should now be compatible with Python 2.4+ (was 2.6+); 2.4 requires simplejson
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mailmanager (1.0.11)
4
+ mailmanager (1.0.13)
5
5
  json (~> 1.4.6)
6
6
  open4 (~> 1.0.1)
7
7
 
@@ -10,6 +10,9 @@ GEM
10
10
  specs:
11
11
  ZenTest (4.4.2)
12
12
  archive-tar-minitar (0.5.2)
13
+ builder (3.0.0)
14
+ ci_reporter (1.6.4)
15
+ builder (>= 2.1.2)
13
16
  columnize (0.3.2)
14
17
  diff-lcs (1.1.2)
15
18
  json (1.4.6)
@@ -40,8 +43,7 @@ PLATFORMS
40
43
 
41
44
  DEPENDENCIES
42
45
  ZenTest (~> 4.4.2)
43
- json (~> 1.4.6)
46
+ ci_reporter
44
47
  mailmanager!
45
- open4 (~> 1.0.1)
46
48
  rspec (~> 2.4.0)
47
49
  ruby-debug19
data/Rakefile CHANGED
@@ -1,7 +1,12 @@
1
+ APP_ROOT = File.expand_path( File.dirname(__FILE__) )
1
2
  $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
3
  require 'mailmanager/version'
3
4
  require 'rake'
4
5
  require 'rake/rdoctask'
6
+ require 'rspec/core/rake_task'
7
+
8
+ # load all .rake files in the tasks dir
9
+ Dir["#{APP_ROOT}/tasks/**/*.rake"].each { |task| load task }
5
10
 
6
11
  desc "Build gem locally"
7
12
  task :build do
@@ -25,7 +30,13 @@ task :release => :build do
25
30
  system "gem push pkg/mailmanager-#{MailManager::VERSION}.gem"
26
31
  end
27
32
 
33
+ desc "Generate rdoc html"
28
34
  Rake::RDocTask.new do |rd|
29
35
  rd.main = "lib/mailmanager.rb"
30
36
  rd.rdoc_files.include("lib/**/*.rb")
31
37
  end
38
+
39
+ desc "Run all specs"
40
+ RSpec::Core::RakeTask.new(:spec) do |spec|
41
+ spec.pattern = 'spec/**/*_spec.rb'
42
+ end
@@ -99,6 +99,8 @@ module MailManager
99
99
  command(cmd, params)
100
100
  end
101
101
 
102
+ # TODO: DRY this up!
103
+
102
104
  def web_page_url(list)
103
105
  cmd = :withlist
104
106
  out = command(cmd, :name => list.name, :wlcmd => 'web_page_url')
@@ -117,6 +119,24 @@ module MailManager
117
119
  parse_json_output(out)
118
120
  end
119
121
 
122
+ def subject_prefix(list)
123
+ cmd = :withlist
124
+ out = command(cmd, :name => list.name, :wlcmd => :subject_prefix)
125
+ parse_json_output(out)
126
+ end
127
+
128
+ def set_description(list, desc)
129
+ cmd = :withlist
130
+ out = command(cmd, :name => list.name, :wlcmd => :description, :arg => desc)
131
+ parse_json_output(out)
132
+ end
133
+
134
+ def set_subject_prefix(list, sp)
135
+ cmd = :withlist
136
+ out = command(cmd, :name => list.name, :wlcmd => :subject_prefix, :arg => sp)
137
+ parse_json_output(out)
138
+ end
139
+
120
140
  def command(cmd, opts = {})
121
141
  mailman_cmd = "#{mailmanager.root}/bin/#{cmd.to_s} "
122
142
  # delete opts as we handle them explicitly
@@ -118,16 +118,37 @@ EOF
118
118
  "#{root}listinfo/#{name}"
119
119
  end
120
120
 
121
+ # Returns the request email address for the list
121
122
  def request_email
122
123
  result = lib.request_email(self)
123
124
  result['return']
124
125
  end
125
126
 
127
+ # Returns the list description
126
128
  def description
127
129
  result = lib.description(self)
128
130
  result['return']
129
131
  end
130
132
 
133
+ # Sets the list description to a new value
134
+ def description=(desc)
135
+ result = lib.set_description(self, desc)
136
+ result['result'].to_sym
137
+ end
138
+
139
+ # Returns the list's subject prefix
140
+ def subject_prefix
141
+ result = lib.subject_prefix(self)
142
+ result['return']
143
+ end
144
+
145
+ # Sets the list's subject prefix to a new value. Remember to leave a space
146
+ # at the end (assuming you want one, and you probably do).
147
+ def subject_prefix=(sp)
148
+ result = lib.set_subject_prefix(self, sp)
149
+ result['result'].to_sym
150
+ end
151
+
131
152
  private
132
153
 
133
154
  def add_member_using(method, email, name)
@@ -1,16 +1,16 @@
1
1
  try:
2
- import json
2
+ import json
3
3
  except ImportError:
4
- import simplejson as json
4
+ import simplejson as json
5
5
  from email.Utils import parseaddr
6
6
  try:
7
- from collections import Callable
7
+ from collections import Callable
8
8
  except ImportError:
9
- def iscallable(attr):
10
- return callable(attr)
9
+ def iscallable(attr):
10
+ return callable(attr)
11
11
  else:
12
- def iscallable(attr):
13
- return isinstance(attr, Callable)
12
+ def iscallable(attr):
13
+ return isinstance(attr, Callable)
14
14
  from Mailman import MailList
15
15
  from Mailman import Errors
16
16
 
@@ -29,34 +29,44 @@ def userdesc_for(member):
29
29
  userdesc.fullname, userdesc.address = parseaddr(member)
30
30
  return userdesc
31
31
 
32
- def unwindattrs(obj, attrs, *args):
33
- if not attrs.count('.'):
34
- attr = getattr(obj, attrs)
32
+ def unwindattrs(obj, attrname, *args):
33
+ if not attrname.count('.'):
34
+ attr = getattr(obj, attrname)
35
35
  if iscallable(attr):
36
36
  return attr(*args)
37
37
  else:
38
- return attr
38
+ if len(args) > 0:
39
+ # must be a setter
40
+ setattr(obj, attrname, args[0])
41
+ else:
42
+ # must be a getter
43
+ return attr
39
44
  else:
40
- attr, nextattrs = attrs.split('.', 1)
45
+ attr, nextattrname = attrname.split('.', 1)
41
46
  nextobj = getattr(obj, attr)
42
- return unwindattrs(nextobj, nextattrs, *args)
47
+ return unwindattrs(nextobj, nextattrname, *args)
43
48
 
44
49
  needs_userdesc = dict(AddMember=True, ApprovedAddMember=True)
45
50
  needs_save = dict(AddMember=True, ApprovedAddMember=True,
46
51
  DeleteMember=True, ApprovedDeleteMember=True,
47
52
  moderator_append=True, moderator_remove=True)
53
+ needs_save_with_arg = dict(description=True, subject_prefix=True)
48
54
 
49
55
  def command(mlist, cmd, *args):
50
56
  result = {}
51
57
  try:
52
- if needs_save.get(cmd.replace('.','_'), False):
53
- mlist.Lock()
58
+ if (needs_save.get(cmd.replace('.','_'), False) or
59
+ (needs_save_with_arg.get(cmd.replace('.','_'), False) and
60
+ len(args) > 0)):
61
+ mlist.Lock()
54
62
  if needs_userdesc.get(cmd, False):
55
63
  result['return'] = unwindattrs(mlist, cmd, userdesc_for(args[0]))
56
64
  else:
57
65
  result['return'] = unwindattrs(mlist, cmd, *args)
58
- if needs_save.get(cmd.replace('.','_'), False):
59
- mlist.Save()
66
+ if (needs_save.get(cmd.replace('.','_'), False) or
67
+ (needs_save_with_arg.get(cmd.replace('.','_'), False) and
68
+ len(args) > 0)):
69
+ mlist.Save()
60
70
  except TypeError, err:
61
71
  error_msg = '%s' % err
62
72
  print json.dumps({'error': error_msg})
@@ -1,3 +1,3 @@
1
1
  module MailManager
2
- VERSION = '1.0.12'
2
+ VERSION = '1.0.13'
3
3
  end
data/mailmanager.gemspec CHANGED
@@ -26,4 +26,5 @@ spec = Gem::Specification.new do |s|
26
26
  s.add_development_dependency('rspec', '~>2.4.0')
27
27
  s.add_development_dependency('ZenTest', '~>4.4.2')
28
28
  s.add_development_dependency('ruby-debug19')
29
+ s.add_development_dependency('ci_reporter')
29
30
  end
@@ -184,6 +184,12 @@ EOF
184
184
  test_lib_attr(:description, "this is a mailing list")
185
185
  end
186
186
  end
187
+
188
+ describe "#subject_prefix" do
189
+ it "should ask Mailman for the list's subject prefix" do
190
+ test_lib_attr(:subject_prefix, "[Foo] ")
191
+ end
192
+ end
187
193
  end
188
194
 
189
195
  def test_lib_getter(lib_method, return_value, *args)
data/tasks/hudson.rake ADDED
@@ -0,0 +1,15 @@
1
+ if ENV['RUBY_ENV'] == 'test'
2
+
3
+ namespace :hudson do
4
+ task :spec => ["hudson:setup:rspec", 'rake:spec']
5
+
6
+ namespace :setup do
7
+ task :pre_ci do
8
+ ENV["CI_REPORTS"] = 'results/rspec/'
9
+ gem 'ci_reporter'
10
+ require 'ci/reporter/rake/rspec'
11
+ end
12
+ task :rspec => [:pre_ci, "ci:setup:rspec"]
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 12
9
- version: 1.0.12
8
+ - 13
9
+ version: 1.0.13
10
10
  platform: ruby
11
11
  authors:
12
12
  - Wes Morgan
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-26 00:00:00 -05:00
17
+ date: 2011-01-27 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -90,6 +90,19 @@ dependencies:
90
90
  version: "0"
91
91
  type: :development
92
92
  version_requirements: *id005
93
+ - !ruby/object:Gem::Dependency
94
+ name: ci_reporter
95
+ prerelease: false
96
+ requirement: &id006 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ type: :development
105
+ version_requirements: *id006
93
106
  description: Ruby wrapper library for GNU Mailman's admin functions
94
107
  email: MorganW@dnc.org
95
108
  executables: []
@@ -118,6 +131,7 @@ files:
118
131
  - spec/lib/mailmanager/list_spec.rb
119
132
  - spec/lib/mailmanager_spec.rb
120
133
  - spec/spec_helper.rb
134
+ - tasks/hudson.rake
121
135
  has_rdoc: true
122
136
  homepage: http://github.com/dnclabs/mailmanager
123
137
  licenses: []