mailer 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +24 -0
- data/Gemfile +13 -0
- data/LICENSE +22 -0
- data/README.md +76 -0
- data/Rakefile +5 -0
- data/doc/Mailer.html +152 -0
- data/doc/Mailer/Client.html +481 -0
- data/doc/Mailer/Config.html +511 -0
- data/doc/_index.html +132 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +160 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +160 -0
- data/doc/js/app.js +208 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +116 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/mailer.rb +7 -0
- data/lib/mailer/client.rb +61 -0
- data/lib/mailer/config.rb +46 -0
- data/lib/mailer/version.rb +3 -0
- data/mailer.gemspec +20 -0
- data/test/mailer/client_test.rb +72 -0
- data/test/test_helper.rb +2 -0
- metadata +109 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
module Mailer
|
2
|
+
module Config
|
3
|
+
|
4
|
+
# Defaultapi domain
|
5
|
+
DEFAULT_API_DOMAIN = 'http://127.0.0.1:80/api/'
|
6
|
+
|
7
|
+
# Defailt api token
|
8
|
+
DEFAULT_API_TOKEN = nil
|
9
|
+
|
10
|
+
# Valid options keys
|
11
|
+
VALID_OPTIONS_KEYS = [
|
12
|
+
:api_token,
|
13
|
+
:api_domain
|
14
|
+
]
|
15
|
+
|
16
|
+
# Valid options accessor
|
17
|
+
attr_accessor *VALID_OPTIONS_KEYS
|
18
|
+
|
19
|
+
def self.extended(base)
|
20
|
+
base.reset
|
21
|
+
end
|
22
|
+
|
23
|
+
def configure
|
24
|
+
yield self
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
# Create a hash of options and their values
|
29
|
+
#
|
30
|
+
# @return [Hash]
|
31
|
+
def options
|
32
|
+
options = {}
|
33
|
+
VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
|
34
|
+
options
|
35
|
+
end
|
36
|
+
|
37
|
+
# Reset config
|
38
|
+
#
|
39
|
+
# @return [self]
|
40
|
+
def reset
|
41
|
+
self.api_token = DEFAULT_API_TOKEN
|
42
|
+
self.api_domain = DEFAULT_API_DOMAIN
|
43
|
+
self
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/mailer.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/mailer/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "mailer"
|
6
|
+
gem.require_paths = ["lib"]
|
7
|
+
gem.version = Mailer::VERSION
|
8
|
+
gem.authors = ["Andrey Subbota"]
|
9
|
+
gem.email = ["subbota@gmail.com"]
|
10
|
+
gem.description = %q{Mailer interface}
|
11
|
+
gem.summary = %q{Mailer interface}
|
12
|
+
gem.homepage = ""
|
13
|
+
|
14
|
+
gem.add_development_dependency 'undev'
|
15
|
+
gem.add_dependency "unweary", '~> 1.0.2'
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($\)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'webmock/minitest'
|
3
|
+
|
4
|
+
class Mailer::ClientTest < MiniTest::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@api_token = 'token'
|
8
|
+
@api_domain = 'http://127.0.0.1/'
|
9
|
+
|
10
|
+
Mailer.configure do |config|
|
11
|
+
config.api_token = @api_token
|
12
|
+
config.api_domain = @api_domain
|
13
|
+
end
|
14
|
+
@client = Mailer::Client.new(:api_token => @api_token)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_get_instanse
|
18
|
+
assert_kind_of(Mailer::Client, @client)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_send_letter
|
22
|
+
letter = {
|
23
|
+
:reply_email => 'user@example.com',
|
24
|
+
:reply_name => 'user',
|
25
|
+
:id => 1,
|
26
|
+
:body => 'body',
|
27
|
+
:subject => 'subject'
|
28
|
+
}
|
29
|
+
stub_request = stub_request(:post, "#{@api_domain}/api/client/letters.json")
|
30
|
+
.with(:body => {
|
31
|
+
"letter" => {
|
32
|
+
"body" => "body",
|
33
|
+
"reply_email" => "user@example.com",
|
34
|
+
"reply_name" => "user",
|
35
|
+
"subject" => "subject"
|
36
|
+
},
|
37
|
+
"id" => "1",
|
38
|
+
"api_token" => @api_token
|
39
|
+
})
|
40
|
+
@client.send_letter letter
|
41
|
+
|
42
|
+
assert_requested stub_request
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_should_subscribe_user
|
46
|
+
stub_request = stub_request(:put, "#{@api_domain}/api/client/lists/1/subscribe.json")
|
47
|
+
.with(:body => {
|
48
|
+
"email" => "user@example.com",
|
49
|
+
"api_token" => @api_token
|
50
|
+
})
|
51
|
+
.to_return(:status => 200, :body => "", :headers => {})
|
52
|
+
|
53
|
+
@client.subscribe_user :email => 'user@example.com', :id => 1
|
54
|
+
assert_requested stub_request
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_should_create_maillist
|
58
|
+
stub_request = stub_request(:post, "#{@api_domain}/api/client/lists.json")
|
59
|
+
.with(:body => {
|
60
|
+
"list" => {
|
61
|
+
"name" => "name",
|
62
|
+
"id" => "id"
|
63
|
+
},
|
64
|
+
"api_token" => @api_token
|
65
|
+
})
|
66
|
+
.to_return(:status => 200, :body => "", :headers => {})
|
67
|
+
|
68
|
+
@client.create_maillist :name => 'name', :id => 'id'
|
69
|
+
assert_requested stub_request
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mailer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrey Subbota
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: undev
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: unweary
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.0.2
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.0.2
|
46
|
+
description: Mailer interface
|
47
|
+
email:
|
48
|
+
- subbota@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- doc/Mailer.html
|
59
|
+
- doc/Mailer/Client.html
|
60
|
+
- doc/Mailer/Config.html
|
61
|
+
- doc/_index.html
|
62
|
+
- doc/class_list.html
|
63
|
+
- doc/css/common.css
|
64
|
+
- doc/css/full_list.css
|
65
|
+
- doc/css/style.css
|
66
|
+
- doc/file.README.html
|
67
|
+
- doc/file_list.html
|
68
|
+
- doc/frames.html
|
69
|
+
- doc/index.html
|
70
|
+
- doc/js/app.js
|
71
|
+
- doc/js/full_list.js
|
72
|
+
- doc/js/jquery.js
|
73
|
+
- doc/method_list.html
|
74
|
+
- doc/top-level-namespace.html
|
75
|
+
- lib/mailer.rb
|
76
|
+
- lib/mailer/client.rb
|
77
|
+
- lib/mailer/config.rb
|
78
|
+
- lib/mailer/version.rb
|
79
|
+
- mailer.gemspec
|
80
|
+
- test/mailer/client_test.rb
|
81
|
+
- test/test_helper.rb
|
82
|
+
homepage: ''
|
83
|
+
licenses: []
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 1.8.23
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: Mailer interface
|
106
|
+
test_files:
|
107
|
+
- test/mailer/client_test.rb
|
108
|
+
- test/test_helper.rb
|
109
|
+
has_rdoc:
|