dreamy 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
- ---
1
+ ---
2
2
  :minor: 5
3
- :patch: 2
3
+ :patch: 3
4
4
  :major: 0
5
+ :build:
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dreamy}
8
- s.version = "0.5.2"
8
+ s.version = "0.5.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jerod Santo"]
12
- s.date = %q{2009-12-29}
12
+ s.date = %q{2010-01-12}
13
13
  s.default_executable = %q{dh}
14
14
  s.email = %q{jerod.santo@gmail.com}
15
15
  s.executables = ["dh"]
@@ -39,6 +39,7 @@ Gem::Specification.new do |s|
39
39
  "lib/dreamy/dns.rb",
40
40
  "lib/dreamy/domain.rb",
41
41
  "lib/dreamy/easy_class_maker.rb",
42
+ "lib/dreamy/mail_filter.rb",
42
43
  "lib/dreamy/mysql/db.rb",
43
44
  "lib/dreamy/mysql/host.rb",
44
45
  "lib/dreamy/mysql/user.rb",
@@ -49,6 +50,7 @@ Gem::Specification.new do |s|
49
50
  "test/base_test.rb",
50
51
  "test/dns_test.rb",
51
52
  "test/domain_test.rb",
53
+ "test/mail_filter_test.rb",
52
54
  "test/mysql_db_test.rb",
53
55
  "test/mysql_host_test.rb",
54
56
  "test/mysql_user_test.rb",
@@ -67,6 +69,7 @@ Gem::Specification.new do |s|
67
69
  "test/base_test.rb",
68
70
  "test/dns_test.rb",
69
71
  "test/domain_test.rb",
72
+ "test/mail_filter_test.rb",
70
73
  "test/mysql_db_test.rb",
71
74
  "test/mysql_host_test.rb",
72
75
  "test/mysql_user_test.rb",
@@ -16,6 +16,7 @@ require 'dreamy/announce_list'
16
16
  require 'dreamy/private_server'
17
17
  require 'dreamy/subscriber'
18
18
  require 'dreamy/user'
19
+ require 'dreamy/mail_filter'
19
20
  require 'dreamy/mysql/db'
20
21
  require 'dreamy/mysql/host'
21
22
  require 'dreamy/mysql/user'
@@ -90,7 +90,45 @@ module Dreamy
90
90
  api_error?(doc)
91
91
  true
92
92
  end
93
-
93
+
94
+ def mail_list_filters
95
+ doc = request("mail-list_filters")
96
+ api_error?(doc)
97
+ (doc/:data).inject([]) { |filters, filter| filters << MailFilter.new_from_xml(filter); filters }
98
+ end
99
+
100
+ def mail_add_filter(address,filter_on,filter,action,action_value,contains="",stop="",rank="")
101
+ doc = request("mail-add_filter",
102
+ {
103
+ "address" => address,
104
+ "filter_on" => filter_on,
105
+ "filter" => filter,
106
+ "action" => action,
107
+ "action_value" => action_value,
108
+ "contains" => contains,
109
+ "stop" => stop,
110
+ "rank" => rank
111
+ })
112
+ api_error?(doc)
113
+ true
114
+ end
115
+
116
+ def mail_remove_filter(address,filter_on,filter,action,action_value,contains,stop,rank)
117
+ doc = request("mail-remove_filter",
118
+ {
119
+ "address" => address,
120
+ "filter_on" => filter_on,
121
+ "filter" => filter,
122
+ "action" => action,
123
+ "action_value" => action_value,
124
+ "contains" => contains,
125
+ "stop" => stop,
126
+ "rank" => rank
127
+ })
128
+ api_error?(doc)
129
+ true
130
+ end
131
+
94
132
  def mysql_dbs
95
133
  doc = request("mysql-list_dbs")
96
134
  api_error?(doc)
@@ -231,4 +269,4 @@ module Dreamy
231
269
  end
232
270
 
233
271
  end
234
- end
272
+ end
@@ -0,0 +1,21 @@
1
+ module Dreamy
2
+ class MailFilter
3
+ include EasyClassMaker
4
+
5
+ attributes :account_id, :address, :rank, :filter, :filter_on, :action_value, :action, :contains, :stop
6
+
7
+ def self.new_from_xml(xml)
8
+ f = new
9
+ f.account_id = (xml).at('account_id').innerHTML.to_i
10
+ f.address = (xml).at('address').innerHTML
11
+ f.rank = (xml).at('rank').innerHTML.to_i
12
+ f.filter = (xml).at('filter').innerHTML
13
+ f.filter_on = (xml).at('filter_on').innerHTML
14
+ f.action = (xml).at('action').innerHTML
15
+ f.action_value = (xml).at('action_value').innerHTML
16
+ f.contains = (xml).at('contains').innerHTML
17
+ f.stop = (xml).at('stop').innerHTML
18
+ f
19
+ end
20
+ end
21
+ end
@@ -136,6 +136,44 @@ class DreamyBaseTest < Test::Unit::TestCase
136
136
 
137
137
  end # announcement lists
138
138
 
139
+
140
+ context "Mail filters" do
141
+
142
+ should "return an array of mail filters" do
143
+ filters = @@base.mail_list_filters
144
+ assert_kind_of Array, filters
145
+ assert_kind_of Dreamy::MailFilter, filters.first unless filters.empty?
146
+ end
147
+
148
+ context "add mail filter" do
149
+ setup { @list_count = @@base.mail_list_filters.size }
150
+
151
+ should "requires 5 arguments " do
152
+ assert_raise(ArgumentError) { @@base.mail_add_filter('example@mydomain.com', 'from', 'sender@mydomain.com', 'add_subject') }
153
+ end
154
+
155
+ should "add filter and return true with valid data" do
156
+ assert @@base.mail_add_filter('seankibler@skiblerspot.net', 'from', 'sender@mydomain.com', 'forward', 'example2@mydomain.com','', '', '')
157
+ assert_equal @list_count + 1, @@base.mail_list_filters.size
158
+ end
159
+ end
160
+
161
+ context "remove mail filter" do
162
+ setup { @list_count = @@base.mail_list_filters.size }
163
+
164
+ should "requires 8 arguments" do
165
+ assert_raise(ArgumentError) { @@base.mail_remove_filter('example@mydomain.com', 'from', 'sender@mydomain.com', 'forward') }
166
+ end
167
+
168
+ should "remove filter and return true with valid data" do
169
+ @list_count = @@base.mail_list_filters.size
170
+ assert @@base.mail_remove_filter('seankibler@skiblerspot.net', 'from', 'sender@mydomain.com', 'forward', 'example2@mydomain.com', '', '', '')
171
+ assert_equal @list_count - 1, @@base.mail_list_filters.size
172
+ end
173
+ end
174
+
175
+ end # mail filters
176
+
139
177
  context "MySQL" do
140
178
 
141
179
  should "return array of MysqlDb records" do
@@ -147,7 +185,7 @@ class DreamyBaseTest < Test::Unit::TestCase
147
185
  should "return array of MysqlHost records" do
148
186
  hosts = @@base.mysql_hosts
149
187
  assert_kind_of Array, hosts
150
- assert_kind_of Dreamy::MysqlDb, hosts.first unless hosts.empty?
188
+ assert_kind_of Dreamy::MysqlHost, hosts.first unless hosts.empty?
151
189
  end
152
190
 
153
191
  should "return array of MysqlUser records" do
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + "/test_helper.rb"
2
+
3
+ class DreamyMailFilterTest < Test::Unit::TestCase
4
+
5
+ context "Creation" do
6
+ setup do
7
+ @xml = <<EOF
8
+ <data>
9
+ <account_id>8675309</account_id>
10
+ <address>test@anessalee.net</address>
11
+ <filter_on>from</filter_on>
12
+ <filter>sender@mydomain.com</filter>
13
+ <action>forward</action>
14
+ <action_value>test2@anessalee.net</action_value>
15
+ <contains></contains>
16
+ <stop></stop>
17
+ <rank>0</rank>
18
+ </data>
19
+ EOF
20
+ end
21
+
22
+ should "create a new user from xml" do
23
+ s = Dreamy::MailFilter.new_from_xml(Hpricot.XML(@xml))
24
+ assert_equal 8675309, s.account_id
25
+ assert_equal "test@anessalee.net", s.address
26
+ assert_equal "from", s.filter_on
27
+ assert_equal "sender@mydomain.com", s.filter
28
+ assert_equal "forward", s.action
29
+ assert_equal "test2@anessalee.net", s.action_value
30
+ assert_equal "", s.contains
31
+ assert_equal "", s.stop
32
+ assert_equal 0, s.rank
33
+ end
34
+ end
35
+
36
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dreamy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerod Santo
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-29 00:00:00 -06:00
12
+ date: 2010-01-12 00:00:00 -06:00
13
13
  default_executable: dh
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -73,6 +73,7 @@ files:
73
73
  - lib/dreamy/dns.rb
74
74
  - lib/dreamy/domain.rb
75
75
  - lib/dreamy/easy_class_maker.rb
76
+ - lib/dreamy/mail_filter.rb
76
77
  - lib/dreamy/mysql/db.rb
77
78
  - lib/dreamy/mysql/host.rb
78
79
  - lib/dreamy/mysql/user.rb
@@ -83,6 +84,7 @@ files:
83
84
  - test/base_test.rb
84
85
  - test/dns_test.rb
85
86
  - test/domain_test.rb
87
+ - test/mail_filter_test.rb
86
88
  - test/mysql_db_test.rb
87
89
  - test/mysql_host_test.rb
88
90
  - test/mysql_user_test.rb
@@ -123,6 +125,7 @@ test_files:
123
125
  - test/base_test.rb
124
126
  - test/dns_test.rb
125
127
  - test/domain_test.rb
128
+ - test/mail_filter_test.rb
126
129
  - test/mysql_db_test.rb
127
130
  - test/mysql_host_test.rb
128
131
  - test/mysql_user_test.rb