newman 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +23 -0
- data/Gemfile +3 -0
- data/README.md +126 -7
- data/examples/config/dreamhost.rb.example +5 -1
- data/examples/config/gmail.rb.example +4 -0
- data/examples/live_test.rb +4 -7
- data/examples/simple_mailing_list.rb +2 -2
- data/lib/newman.rb +97 -1
- data/lib/newman/application.rb +238 -1
- data/lib/newman/controller.rb +93 -8
- data/lib/newman/email_logger.rb +54 -0
- data/lib/newman/filters.rb +123 -0
- data/lib/newman/mailer.rb +98 -32
- data/lib/newman/mailing_list.rb +83 -0
- data/lib/newman/recorder.rb +132 -0
- data/lib/newman/request_logger.rb +41 -0
- data/lib/newman/response_logger.rb +41 -0
- data/lib/newman/server.rb +197 -23
- data/lib/newman/settings.rb +72 -4
- data/lib/newman/store.rb +68 -4
- data/lib/newman/test_mailer.rb +79 -6
- data/lib/newman/version.rb +5 -2
- data/test/helper.rb +18 -0
- data/{examples → test/integration}/acid_tests.rb +30 -20
- data/test/integration/skip_response_test.rb +22 -0
- data/test/integration/subject_filter_test.rb +25 -0
- data/test/settings.rb +4 -0
- data/test/suite.rb +6 -0
- metadata +74 -9
- data/lib/newman/commands.rb +0 -72
- data/lib/newman/store/recorder.rb +0 -63
data/test/settings.rb
ADDED
data/test/suite.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mail
|
16
|
-
requirement: &
|
16
|
+
requirement: &2154675600 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.3.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2154675600
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tilt
|
27
|
-
requirement: &
|
27
|
+
requirement: &2154675020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,62 @@ dependencies:
|
|
32
32
|
version: 1.3.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2154675020
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: minitest
|
38
|
+
requirement: &2154674500 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.11.1
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2154674500
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: simplecov
|
49
|
+
requirement: &2154674080 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2154674080
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: purdytest
|
60
|
+
requirement: &2154673560 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2154673560
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rocco
|
71
|
+
requirement: &2154673120 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2154673120
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: rake
|
82
|
+
requirement: &2154672680 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *2154672680
|
36
91
|
description: A microframework for mail-centric applications
|
37
92
|
email:
|
38
93
|
- gregory.t.brown@gmail.com
|
@@ -41,18 +96,20 @@ extensions: []
|
|
41
96
|
extra_rdoc_files: []
|
42
97
|
files:
|
43
98
|
- lib/newman/application.rb
|
44
|
-
- lib/newman/commands.rb
|
45
99
|
- lib/newman/controller.rb
|
100
|
+
- lib/newman/email_logger.rb
|
101
|
+
- lib/newman/filters.rb
|
46
102
|
- lib/newman/mailer.rb
|
47
103
|
- lib/newman/mailing_list.rb
|
104
|
+
- lib/newman/recorder.rb
|
105
|
+
- lib/newman/request_logger.rb
|
106
|
+
- lib/newman/response_logger.rb
|
48
107
|
- lib/newman/server.rb
|
49
108
|
- lib/newman/settings.rb
|
50
|
-
- lib/newman/store/recorder.rb
|
51
109
|
- lib/newman/store.rb
|
52
110
|
- lib/newman/test_mailer.rb
|
53
111
|
- lib/newman/version.rb
|
54
112
|
- lib/newman.rb
|
55
|
-
- examples/acid_tests.rb
|
56
113
|
- examples/config/dreamhost.rb.example
|
57
114
|
- examples/config/gmail.rb.example
|
58
115
|
- examples/config/test.rb
|
@@ -66,7 +123,15 @@ files:
|
|
66
123
|
- examples/views/subscribe-success.erb
|
67
124
|
- examples/views/unsubscribe-error.erb
|
68
125
|
- examples/views/unsubscribe-success.erb
|
126
|
+
- test/helper.rb
|
127
|
+
- test/integration/acid_tests.rb
|
128
|
+
- test/integration/skip_response_test.rb
|
129
|
+
- test/integration/subject_filter_test.rb
|
130
|
+
- test/settings.rb
|
131
|
+
- test/suite.rb
|
69
132
|
- README.md
|
133
|
+
- CHANGELOG.md
|
134
|
+
- Gemfile
|
70
135
|
homepage: http://github.com/mendicant-university/newman
|
71
136
|
licenses: []
|
72
137
|
post_install_message:
|
data/lib/newman/commands.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
module Newman
|
2
|
-
module Commands
|
3
|
-
def use(extension)
|
4
|
-
extensions << extension
|
5
|
-
end
|
6
|
-
|
7
|
-
def helpers(&block)
|
8
|
-
extensions << Module.new(&block)
|
9
|
-
end
|
10
|
-
|
11
|
-
def match(id, pattern)
|
12
|
-
matchers[id.to_s] = pattern
|
13
|
-
end
|
14
|
-
|
15
|
-
def to(pattern_type, pattern, &callback)
|
16
|
-
raise NotImplementedError unless pattern_type == :tag
|
17
|
-
|
18
|
-
pattern = compile_pattern(pattern)
|
19
|
-
|
20
|
-
matcher = lambda do
|
21
|
-
request.to.each do |e|
|
22
|
-
md = e.match(/\+#{pattern}@#{Regexp.escape(domain)}/)
|
23
|
-
return md if md
|
24
|
-
end
|
25
|
-
|
26
|
-
false
|
27
|
-
end
|
28
|
-
|
29
|
-
callbacks << { :matcher => matcher, :callback => callback }
|
30
|
-
end
|
31
|
-
|
32
|
-
def subject(pattern_type, pattern, &callback)
|
33
|
-
raise NotImplementedError unless pattern_type == :match
|
34
|
-
|
35
|
-
pattern = compile_pattern(pattern)
|
36
|
-
|
37
|
-
matcher = lambda do
|
38
|
-
md = request.subject.match(/#{pattern}/)
|
39
|
-
|
40
|
-
md || false
|
41
|
-
end
|
42
|
-
|
43
|
-
callbacks << { :matcher => matcher, :callback => callback }
|
44
|
-
end
|
45
|
-
|
46
|
-
def default(&callback)
|
47
|
-
self.default_callback = callback
|
48
|
-
end
|
49
|
-
|
50
|
-
def trigger_callbacks(controller)
|
51
|
-
matched_callbacks = callbacks.select do |e|
|
52
|
-
matcher = e[:matcher]
|
53
|
-
e[:match_data] = controller.instance_exec(&matcher)
|
54
|
-
end
|
55
|
-
|
56
|
-
if matched_callbacks.empty?
|
57
|
-
controller.instance_exec(&default_callback)
|
58
|
-
else
|
59
|
-
matched_callbacks.each do |e|
|
60
|
-
callback = e[:callback]
|
61
|
-
controller.params = e[:match_data] || {}
|
62
|
-
controller.instance_exec(&callback)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def compile_pattern(pattern)
|
68
|
-
pattern.gsub('.','\.')
|
69
|
-
.gsub(/\{(.*?)\}/) { |m| "(?<#{$1}>#{matchers[$1]})" }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
module Newman
|
2
|
-
class Store
|
3
|
-
Record = Struct.new(:column, :id, :contents)
|
4
|
-
|
5
|
-
class Recorder
|
6
|
-
include Enumerable
|
7
|
-
|
8
|
-
def initialize(column, store)
|
9
|
-
self.column = column
|
10
|
-
self.store = store
|
11
|
-
|
12
|
-
store.write do |data|
|
13
|
-
data[:identifiers][column] ||= 0
|
14
|
-
data[:columns][column] ||= {}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def each
|
19
|
-
store.read do |data|
|
20
|
-
data[:columns][column].each do |id, contents|
|
21
|
-
yield(Record.new(column, id,contents))
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def create(contents)
|
27
|
-
store.write do |data|
|
28
|
-
id = (data[:identifiers][column] += 1)
|
29
|
-
|
30
|
-
data[:columns][column][id] = contents
|
31
|
-
|
32
|
-
Record.new(column, id, contents)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def read(id)
|
37
|
-
store.read do |data|
|
38
|
-
Record.new(column, id, data[:columns][column][id])
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def update(id)
|
43
|
-
store.write do |data|
|
44
|
-
data[:columns][column][id] = yield(data[:columns][column][id])
|
45
|
-
|
46
|
-
Record.new(column, id, data[:columns][column][id])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def destroy(id)
|
51
|
-
store.write do |data|
|
52
|
-
data[:columns][column].delete(id)
|
53
|
-
end
|
54
|
-
|
55
|
-
true
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
attr_accessor :column, :store
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|