mailee 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/mailee.rb +34 -4
- data/mailee.gemspec +10 -9
- data/spec/mailee-api.rb +151 -0
- data/spec/spec.opts +1 -0
- data/{test/helper.rb → spec/spec_helper.rb} +6 -6
- metadata +14 -8
- data/test/test_mailee.rb +0 -7
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/mailee.rb
CHANGED
@@ -7,14 +7,45 @@ module Mailee
|
|
7
7
|
def self.find_by_internal_id iid
|
8
8
|
find(:first, :params => {:internal_id => iid})
|
9
9
|
end
|
10
|
+
def self.find_by_email email
|
11
|
+
find(:first, :params => {:email => email})
|
12
|
+
end
|
13
|
+
def self.search keyword, page=1
|
14
|
+
find(:all, :params => {:page => page, :by_keyword => keyword })
|
15
|
+
end
|
10
16
|
def unsubscribe(data={})
|
11
17
|
#E.g. data --> {:reason => 'Trip to nowhere', :spam => false}
|
12
18
|
put(:unsubscribe, :unsubscribe => {:reason => 'Motivo não especificado'}.merge(data))
|
13
19
|
end
|
20
|
+
def subscribe(list)
|
21
|
+
put(:subscribe, :list => {:name => list})
|
22
|
+
end
|
14
23
|
end
|
15
24
|
class List < Config
|
16
25
|
end
|
17
|
-
|
26
|
+
class Template < Config
|
27
|
+
end
|
28
|
+
class Quick < Config
|
29
|
+
self.collection_name = "quick"
|
30
|
+
def self.import contacts
|
31
|
+
create :contacts => contacts
|
32
|
+
end
|
33
|
+
end
|
34
|
+
class Message < Config
|
35
|
+
def test contacts
|
36
|
+
put(:test, :contacts => contacts)
|
37
|
+
end
|
38
|
+
def ready date=nil, hour=0
|
39
|
+
if date && date.is_a?(Date)
|
40
|
+
put(:ready, :when => 'after', :date => date.strftime("%d/%m/%Y"), :hour => hour)
|
41
|
+
else
|
42
|
+
put(:ready, :when => 'now')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
class Report < Config
|
47
|
+
end
|
48
|
+
|
18
49
|
module Sync
|
19
50
|
def self.included(base) # :nodoc:
|
20
51
|
base.extend ClassMethods
|
@@ -45,8 +76,7 @@ module Mailee
|
|
45
76
|
self.included_modules.include?(InstanceMethods)
|
46
77
|
end
|
47
78
|
end
|
48
|
-
|
49
|
-
|
79
|
+
|
50
80
|
module InstanceMethods #:nodoc:
|
51
81
|
def self.included(base) # :nodoc:
|
52
82
|
base.extend ClassMethods
|
@@ -139,4 +169,4 @@ module Mailee
|
|
139
169
|
end
|
140
170
|
end
|
141
171
|
end
|
142
|
-
ActiveRecord::Base.send(:include, Mailee::Sync)
|
172
|
+
ActiveRecord::Base.send(:include, Mailee::Sync)
|
data/mailee.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mailee}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Juan Maiz"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-05}
|
13
13
|
s.description = %q{Permite sincronizar automaticamente seus modelos com o Mailee.me, inclusive com gerenciamento de optin.}
|
14
14
|
s.email = %q{suporte@mailee.me}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -31,25 +31,26 @@ Gem::Specification.new do |s|
|
|
31
31
|
"pkg/mailee-0.1.0.gem",
|
32
32
|
"pkg/mailee-0.1.1.gem",
|
33
33
|
"pkg/mailee-0.1.2.gem",
|
34
|
-
"
|
35
|
-
"
|
36
|
-
"
|
34
|
+
"spec/mailee-api.rb",
|
35
|
+
"spec/spec.opts",
|
36
|
+
"spec/spec_helper.rb",
|
37
|
+
"tasks/mailee_tasks.rake"
|
37
38
|
]
|
38
39
|
s.homepage = %q{http://help.mailee.me/integration_rails.html}
|
39
40
|
s.rdoc_options = ["--charset=UTF-8"]
|
40
41
|
s.require_paths = ["lib"]
|
41
|
-
s.rubygems_version = %q{1.3.
|
42
|
+
s.rubygems_version = %q{1.3.7}
|
42
43
|
s.summary = %q{Gem de integração do Mailee.me}
|
43
44
|
s.test_files = [
|
44
|
-
"
|
45
|
-
"
|
45
|
+
"spec/mailee-api.rb",
|
46
|
+
"spec/spec_helper.rb"
|
46
47
|
]
|
47
48
|
|
48
49
|
if s.respond_to? :specification_version then
|
49
50
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
51
|
s.specification_version = 3
|
51
52
|
|
52
|
-
if Gem::Version.new(Gem::
|
53
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
54
|
else
|
54
55
|
end
|
55
56
|
else
|
data/spec/mailee-api.rb
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
#INSERT INTO "unsubscribes" ("created_at", "contact_id", "reason", "spam", "message_id") VALUES('2010-10-05 22:52:25.657597', 2082562, default, 'f', default) RETURNING "id"
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
4
|
+
|
5
|
+
describe "Mailee" do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
Mailee::Config.site = "http://api.bdb28c0a0a4a3.softa.server:3000"
|
9
|
+
@moment = Time.now.strftime('%Y%m%d%H%M%S')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should import (quick)" do
|
13
|
+
result = Mailee::Quick.create :contacts => "rest_test_#{@moment}@test.com\nrest_test_2_#{@moment}@test.com\nrest_test_3_#{@moment}@test.com"
|
14
|
+
result.should
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have appropriate classes" do
|
18
|
+
Mailee.should
|
19
|
+
Mailee::Config.should
|
20
|
+
Mailee::Contact.should
|
21
|
+
Mailee::List.should
|
22
|
+
Mailee::Quick.should
|
23
|
+
Mailee::Message.should
|
24
|
+
Mailee::Template.should
|
25
|
+
Mailee::Report.should
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should get first contact" do
|
29
|
+
contact = Mailee::Contact.first
|
30
|
+
contact.id.should
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should create contact" do
|
34
|
+
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
|
35
|
+
contact.id.should
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should get all contacts" do
|
39
|
+
Array.new(25){|i| Mailee::Contact.create :email => "rest_test_#{@moment}_#{i}@test.com"}
|
40
|
+
contacts = Mailee::Contact.find(:all)
|
41
|
+
contacts.size.should be(15)
|
42
|
+
contacts = Mailee::Contact.find(:all, :params => {:page => 2, :by_keyword => "rest_test_#{@moment}" })
|
43
|
+
contacts.size.should be(10)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should create contact - and find by id" do
|
47
|
+
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
|
48
|
+
contact.id.should
|
49
|
+
found_contact = Mailee::Contact.find(contact.id)
|
50
|
+
found_contact.id.should be(contact.id)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should create contact - and find by internal_id" do
|
54
|
+
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com", :internal_id => @moment
|
55
|
+
contact.id.should
|
56
|
+
contact.internal_id.should == @moment
|
57
|
+
contact = Mailee::Contact.find(:first, :params => { :internal_id => @moment })
|
58
|
+
contact.internal_id.should == @moment
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should create contact - with dynamic attributes" do
|
62
|
+
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com", :dynamic_attributes => {:foo => 'bar'}
|
63
|
+
contact.id.should
|
64
|
+
contact.dynamic_attributes.attributes['foo'].should == 'bar'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should create list - and find by id" do
|
68
|
+
list = Mailee::List.create :name => "rest_test_#{@moment}"
|
69
|
+
list.id.should
|
70
|
+
list = Mailee::List.find(list.id)
|
71
|
+
list.id.should
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should create contact - and subscribe" do
|
75
|
+
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
|
76
|
+
contact.put(:subscribe, :list => "rest_test_#{@moment}").should
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should create contact - and unsubscribe" do
|
80
|
+
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
|
81
|
+
contact.put(:unsubscribe).should
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should create message" do
|
85
|
+
list = Mailee::List.create :name => "rest_test_#{@moment}"
|
86
|
+
message = Mailee::Message.create :title => "rest_test_#{@moment}", :subject => "rest_test_#{@moment}", :from_name => "rest_test_#{@moment}", :from_email => "rest_test_#{@moment}@test.com", :html => "rest_test_#{@moment}", :list_id => list.id
|
87
|
+
message.id.should
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should create message - with emails" do
|
91
|
+
list = Mailee::List.create :name => "rest_test_#{@moment}"
|
92
|
+
message = Mailee::Message.create :title => "rest_test_#{@moment}", :subject => "rest_test_#{@moment}", :from_name => "rest_test_#{@moment}", :from_email => "rest_test_#{@moment}@test.com", :html => "rest_test_#{@moment}", :emails => 'foo@bar.com bar@foo.com'
|
93
|
+
#raise message.inspect
|
94
|
+
message.id.should
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should create, test and send message" do
|
98
|
+
list = Mailee::List.create :name => "rest_test_#{@moment}"
|
99
|
+
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
|
100
|
+
contact.put(:subscribe, :list => list.name)
|
101
|
+
message = Mailee::Message.create :title => "rest_test_#{@moment}", :subject => "rest_test_#{@moment}", :from_name => "rest_test_#{@moment}", :from_email => "rest_test_#{@moment}@test.com", :html => "rest_test_#{@moment}", :list_id => list.id
|
102
|
+
message.put(:test, :contacts => [contact.id]).should
|
103
|
+
message.put(:ready, :when => 'now').should
|
104
|
+
end
|
105
|
+
|
106
|
+
# API specific methods
|
107
|
+
|
108
|
+
it "should create, subscribe and unsubscribe a contact" do
|
109
|
+
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
|
110
|
+
contact.subscribe("rest_test_#{@moment}").should
|
111
|
+
contact.unsubscribe.should
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should search contacts" do
|
115
|
+
Mailee::Contact.search("rest_test").should
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should create and find by internal id" do
|
119
|
+
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com", :internal_id => @moment
|
120
|
+
found = Mailee::Contact.find_by_internal_id(@moment)
|
121
|
+
found.id.should be(contact.id)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should create and find by email" do
|
125
|
+
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
|
126
|
+
found = Mailee::Contact.find_by_email("rest_test_#{@moment}@test.com")
|
127
|
+
found.id.should be(contact.id)
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should create, test and send message - specific methods" do
|
131
|
+
list = Mailee::List.create :name => "rest_test_#{@moment}"
|
132
|
+
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
|
133
|
+
contact.put(:subscribe, :list => list.name)
|
134
|
+
message = Mailee::Message.create :title => "rest_test_#{@moment}", :subject => "rest_test_#{@moment}", :from_name => "rest_test_#{@moment}", :from_email => "rest_test_#{@moment}@test.com", :html => "rest_test_#{@moment}", :list_id => list.id
|
135
|
+
message.test([contact.id]).should
|
136
|
+
message.ready.should
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should create, test and send after message - specific methods" do
|
140
|
+
list = Mailee::List.create :name => "rest_test_#{@moment}"
|
141
|
+
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
|
142
|
+
contact.put(:subscribe, :list => list.name)
|
143
|
+
message = Mailee::Message.create :title => "rest_test_#{@moment}", :subject => "rest_test_#{@moment}", :from_name => "rest_test_#{@moment}", :from_email => "rest_test_#{@moment}@test.com", :html => "rest_test_#{@moment}", :list_id => list.id
|
144
|
+
message.test([contact.id]).should
|
145
|
+
message.ready(10.days.from_now).should
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should import (quick) - specific methods" do Mailee::Quick.import("rest_test_#{@moment}@test.com\nrest_test_2_#{@moment}@test.com\nrest_test_3_#{@moment}@test.com").should
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'test/unit'
|
3
|
-
require 'shoulda'
|
4
|
-
|
5
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'active_record'
|
7
4
|
require 'mailee'
|
5
|
+
require 'spec'
|
6
|
+
require 'spec/autorun'
|
8
7
|
|
9
|
-
|
8
|
+
Spec::Runner.configure do |config|
|
9
|
+
|
10
10
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
- 1
|
8
8
|
- 2
|
9
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Juan Maiz
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-10-05 00:00:00 -04:00
|
18
19
|
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|
@@ -42,9 +43,10 @@ files:
|
|
42
43
|
- pkg/mailee-0.1.0.gem
|
43
44
|
- pkg/mailee-0.1.1.gem
|
44
45
|
- pkg/mailee-0.1.2.gem
|
46
|
+
- spec/mailee-api.rb
|
47
|
+
- spec/spec.opts
|
48
|
+
- spec/spec_helper.rb
|
45
49
|
- tasks/mailee_tasks.rake
|
46
|
-
- test/helper.rb
|
47
|
-
- test/test_mailee.rb
|
48
50
|
has_rdoc: true
|
49
51
|
homepage: http://help.mailee.me/integration_rails.html
|
50
52
|
licenses: []
|
@@ -55,26 +57,30 @@ rdoc_options:
|
|
55
57
|
require_paths:
|
56
58
|
- lib
|
57
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
58
61
|
requirements:
|
59
62
|
- - ">="
|
60
63
|
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
61
65
|
segments:
|
62
66
|
- 0
|
63
67
|
version: "0"
|
64
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
65
70
|
requirements:
|
66
71
|
- - ">="
|
67
72
|
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
68
74
|
segments:
|
69
75
|
- 0
|
70
76
|
version: "0"
|
71
77
|
requirements: []
|
72
78
|
|
73
79
|
rubyforge_project:
|
74
|
-
rubygems_version: 1.3.
|
80
|
+
rubygems_version: 1.3.7
|
75
81
|
signing_key:
|
76
82
|
specification_version: 3
|
77
83
|
summary: "Gem de integra\xC3\xA7\xC3\xA3o do Mailee.me"
|
78
84
|
test_files:
|
79
|
-
-
|
80
|
-
-
|
85
|
+
- spec/mailee-api.rb
|
86
|
+
- spec/spec_helper.rb
|