mailee 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ mailee-api-test.db
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/README.markdown CHANGED
@@ -42,7 +42,7 @@ Instalação
42
42
  Compatibilidade
43
43
  =
44
44
 
45
- Rails 3. 'Nuff said. Se você precisa de suporte aoRails 2, baixe a versão 0.1.0, mas ela possui muito menos funcionalidades do que a versão atual.
45
+ Rails 3. 'Nuff said. Se você precisa de suporte ao Rails 2, baixe a versão 0.1.0, mas ela possui muito menos funcionalidades do que a versão atual.
46
46
 
47
47
  Uso
48
48
  =
@@ -93,6 +93,11 @@ Uso
93
93
  sync_with_mailee :name => :my_name_column
94
94
  end
95
95
  Se o valor do campo "news" (ou o que você utilizar para optin) for false, a gem não cadastrará o contato no Mailee. Se o contato já estiver cadastrado e o valor deste campo mudar para falso, o contato será descadastrado e _não_ poderá ser mais cadastrado no Mailee (normas de privacidade). Se ele estiver falso e mudar para verdadeiro, ele irá cadastrá-lo.
96
+ =code
97
+ class Contact < ActiveRecord::Base
98
+ sync_with_mailee :list => "Nome da sua lista"
99
+ end
100
+ Você também pode (e a gente recomenda que você o faça) informar a lista na qual você quer que o contato seja inscrito quando ele for cadastrado no Mailee.me. Assim, quando você for criar uma campanha todos seus contatos cadastrados pelo seu sistema já estarão em uma lista. Aí é só enviar para esta lista e pronto.
96
101
 
97
102
  * Com mailers (ActionMailer)
98
103
 
data/Rakefile CHANGED
@@ -18,29 +18,13 @@ rescue LoadError
18
18
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
19
  end
20
20
 
21
- require 'rake/testtask'
22
- Rake::TestTask.new(:test) do |test|
23
- test.libs << 'lib' << 'test'
24
- test.pattern = 'test/**/test_*.rb'
25
- test.verbose = true
21
+ require 'rspec/core'
22
+ require 'rspec/core/rake_task'
23
+ RSpec::Core::RakeTask.new(:spec) do |spec|
24
+ spec.pattern = FileList['spec/*_spec.rb']
26
25
  end
27
26
 
28
- begin
29
- require 'rcov/rcovtask'
30
- Rcov::RcovTask.new do |test|
31
- test.libs << 'test'
32
- test.pattern = 'test/**/test_*.rb'
33
- test.verbose = true
34
- end
35
- rescue LoadError
36
- task :rcov do
37
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
- end
39
- end
40
-
41
- task :test => :check_dependencies
42
-
43
- task :default => :test
27
+ task :default => :spec
44
28
 
45
29
  require 'rake/rdoctask'
46
30
  Rake::RDocTask.new do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.5.0
data/app/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'rails', '3.0.0'
4
- gem 'mailee', '0.4.0'
4
+ gem 'mailee', '0.4.3'
5
5
  # Bundle edge Rails instead:
6
6
  # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
7
 
data/app/Gemfile.lock CHANGED
@@ -38,7 +38,7 @@ GEM
38
38
  activesupport (>= 2.3.6)
39
39
  mime-types
40
40
  treetop (>= 1.4.5)
41
- mailee (0.4.0)
41
+ mailee (0.4.3)
42
42
  mime-types (1.16)
43
43
  polyglot (0.3.1)
44
44
  rack (1.2.1)
@@ -70,6 +70,6 @@ PLATFORMS
70
70
  ruby
71
71
 
72
72
  DEPENDENCIES
73
- mailee (= 0.4.0)
73
+ mailee (= 0.4.3)
74
74
  rails (= 3.0.0)
75
75
  sqlite3-ruby
@@ -6,7 +6,7 @@ class Foo < ActionMailer::Base
6
6
 
7
7
  def bar(date=Time.now)
8
8
  @greeting = "Hi"
9
- mail :date => date, :to => ["juanmaiz@gmail.com"]
9
+ mail :date => date, :to => ["juanmaiz@gmail.com"], :subject => "Bar"
10
10
  end
11
11
 
12
12
  end
@@ -1 +1 @@
1
- Mailee::Config.site = 'http://api.bdb28c0a0a4a3.softa.mailee.me'
1
+ Mailee::Config.site = "http://api.869a72b17b05a.mailee-api.mailee.me"
data/app/db/schema.rb ADDED
@@ -0,0 +1,15 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 0) do
14
+
15
+ end
@@ -4,16 +4,8 @@ class FooTest < ActionMailer::TestCase
4
4
  test "bar" do
5
5
  mail = Foo.bar
6
6
  assert_equal "Bar", mail.subject
7
- assert_equal ["to@example.org"], mail.to
8
- assert_equal ["from@example.com"], mail.from
9
- assert_match "Hi", mail.body.encoded
10
- end
11
-
12
- test "baz" do
13
- mail = Foo.baz
14
- assert_equal "Baz", mail.subject
15
- assert_equal ["to@example.org"], mail.to
16
- assert_equal ["from@example.com"], mail.from
7
+ assert_equal ["juanmaiz@gmail.com"], mail.to
8
+ assert_equal ["maiz@softa.com.br"], mail.from
17
9
  assert_match "Hi", mail.body.encoded
18
10
  end
19
11
 
data/lib/mailee.rb CHANGED
@@ -5,4 +5,4 @@ module Mailee; end
5
5
  require 'mailee/active_resource'
6
6
  require 'mailee/railties' if defined?(Rails)
7
7
  require 'mailee/active_record' if defined?(ActiveRecord)
8
- require 'mailee/action_mailer' if defined?(ActionMailer)
8
+ require 'mailee/action_mailer' if defined?(ActionMailer)
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  # The Sync module is responsible for keeping a model syncd with Mailee.
2
3
  # It's behaviour is still too rails-twooish. But soon I'll make it more
3
4
  # treeish using Railties and stuff. But it works.
@@ -42,6 +43,10 @@ module Mailee
42
43
  unless self.column_names.include?(self.sync_options[:news].to_s)
43
44
  self.sync_options[:news] = nil
44
45
  end
46
+ if self.sync_options[:list]
47
+ lists = List.find(:all).map(&:name)
48
+ raise "A lista '#{self.sync_options[:list]}' não existe no Mailee.me." unless lists.include?(self.sync_options[:list])
49
+ end
45
50
  end
46
51
  include InstanceMethods
47
52
  end
@@ -66,6 +71,7 @@ module Mailee
66
71
  contact.email = send(sync_options[:email])
67
72
  contact.name = send(sync_options[:name]) if sync_options[:name]
68
73
  contact.save
74
+ contact.put(:subscribe, :list => sync_options[:list]) if sync_options[:list]
69
75
  end
70
76
  rescue
71
77
  logger.warn "MAILEE-API: Falhou ao criar o contato #{id} no Mailee"
@@ -82,6 +88,7 @@ module Mailee
82
88
  contact.email = send(sync_options[:email])
83
89
  contact.name = send(sync_options[:name]) if sync_options[:name]
84
90
  contact.save
91
+ contact.put(:subscribe, :list => sync_options[:list]) if sync_options[:list]
85
92
  end
86
93
  else
87
94
  create_in_mailee # Se não achou o contato tem q inserir.
@@ -150,4 +157,4 @@ module Mailee
150
157
  end
151
158
  end
152
159
  end
153
- ActiveRecord::Base.send(:include, Mailee::Sync) if defined?(ActiveRecord)
160
+ ActiveRecord::Base.send(:include, Mailee::Sync) if defined?(ActiveRecord)
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module Mailee
2
4
 
3
5
  # The Config class is used to set your api url.
@@ -20,7 +22,11 @@ module Mailee
20
22
  # If you use mailee gem to sync a model, it will always set the internal_id
21
23
  # to your "local" model id and then search based on it to update de remote
22
24
  # record.
25
+ #
26
+ # Writable attributes:
27
+ # :name, :email, :internal_id, :sex, :birthday, :age, :phone, :mobile, :address, :notes, :photo, :company, :position
23
28
  class Contact < Config
29
+
24
30
  def self.find_by_internal_id iid
25
31
  find(:first, :params => {:internal_id => iid})
26
32
  end
@@ -40,11 +46,21 @@ module Mailee
40
46
  end
41
47
 
42
48
  # The List class gives you default access to your lists (all, first, create, update, destroy)
49
+ # Writable attributes:
50
+ # :name, :active, :company, :description, :address, :phone, :site
43
51
  class List < Config
44
52
  end
45
53
 
46
54
  # The Template class gives you default access to your templates (all, first, create, update, destroy)
55
+ # Writable attributes:
56
+ # :title, :html
47
57
  class Template < Config
58
+ def self.writable_attributes
59
+ [:title, :html]
60
+ end
61
+ def thumb
62
+ "http://assets.mailee.me/system/templates/#{id}/thumbs/thumb/#{id}.png"
63
+ end
48
64
  end
49
65
 
50
66
  # The Quick class allows you to import contacts to mailee just like
@@ -75,12 +91,27 @@ module Mailee
75
91
  # # Creating a message (still a draft):
76
92
  # message = Mailee::Message.create :title => "TITLE", :subject => "SUBJ", :from_name => "NAME", :from_email => "your@email.com", :html => "<h1>Hello</h1>", :list_id => 666
77
93
  # # Sending tests. 33, 44 and 55 are contact's ids.
78
- # message.test([33,44,55]).should_not be nil
94
+ # message.test([33,44,55])
79
95
  # # Sending the message now ...
80
96
  # message.ready
81
97
  # # ... or sending the message 10 days from now
82
98
  # message.ready(10.days.from_now)
99
+ #
100
+ # Writeable attributes:
101
+ # :newsletter_id, :template_id, :list_id, :segment_id, :title, :subject, :from_name, :from_email, :reply_email, :html, :analytics
83
102
  class Message < Config
103
+ def self.writeable_attributes
104
+ [:newsletter_id, :template_id, :list_id, :contacts, :segment_id, :title, :subject, :from_name, :from_email, :reply_email, :html, :analytics]
105
+ end
106
+ def human_status
107
+ ['','draft','sending','sent','generating'][status]
108
+ end
109
+ def signature
110
+ "#{from_name} <#{from_email}>"
111
+ end
112
+ def thumb(size='thumb')
113
+ "http://assets.mailee.me/system/messages/#{id}/thumbs/#{size}/#{id}.png"
114
+ end
84
115
  def test contacts
85
116
  put(:test, :contacts => contacts)
86
117
  end
@@ -99,4 +130,4 @@ module Mailee
99
130
  class Report < Config
100
131
  end
101
132
 
102
- end
133
+ end
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.4.3"
8
+ s.version = "0.5.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-10-16}
12
+ s.date = %q{2011-03-28}
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 = [
@@ -19,7 +19,9 @@ Gem::Specification.new do |s|
19
19
  "README.rdoc"
20
20
  ]
21
21
  s.files = [
22
- "LICENSE",
22
+ ".gitignore",
23
+ ".rspec",
24
+ "LICENSE",
23
25
  "MIT-LICENSE",
24
26
  "README.markdown",
25
27
  "README.rdoc",
@@ -52,6 +54,7 @@ Gem::Specification.new do |s|
52
54
  "app/config/initializers/session_store.rb",
53
55
  "app/config/locales/en.yml",
54
56
  "app/config/routes.rb",
57
+ "app/db/schema.rb",
55
58
  "app/db/seeds.rb",
56
59
  "app/doc/README_FOR_APP",
57
60
  "app/lib/tasks/.gitkeep",
@@ -86,12 +89,12 @@ Gem::Specification.new do |s|
86
89
  "pkg/mailee-0.1.0.gem",
87
90
  "pkg/mailee-0.1.1.gem",
88
91
  "pkg/mailee-0.1.2.gem",
92
+ "pkg/mailee-0.4.4.gem",
89
93
  "spec/am_spec_helper.rb",
90
94
  "spec/ar_spec_helper.rb",
91
- "spec/mailee-api-am.rb",
92
- "spec/mailee-api-ar.rb",
93
- "spec/mailee-api.rb",
94
- "spec/spec.opts",
95
+ "spec/mailee-api-am_spec.rb",
96
+ "spec/mailee-api-ar_spec.rb",
97
+ "spec/mailee-api_spec.rb",
95
98
  "spec/spec_helper.rb",
96
99
  "tasks/mailee_tasks.rake"
97
100
  ]
@@ -103,9 +106,9 @@ Gem::Specification.new do |s|
103
106
  s.test_files = [
104
107
  "spec/am_spec_helper.rb",
105
108
  "spec/ar_spec_helper.rb",
106
- "spec/mailee-api-am.rb",
107
- "spec/mailee-api-ar.rb",
108
- "spec/mailee-api.rb",
109
+ "spec/mailee-api-am_spec.rb",
110
+ "spec/mailee-api-ar_spec.rb",
111
+ "spec/mailee-api_spec.rb",
109
112
  "spec/spec_helper.rb"
110
113
  ]
111
114
 
Binary file
@@ -1,15 +1,14 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
-
3
+ require 'rspec'
4
4
  require 'action_mailer'
5
5
  require 'mailee'
6
- require 'spec'
7
- require 'spec/autorun'
8
6
 
9
- Spec::Runner.configure do |config|
7
+ RSpec.configure do |config|
8
+ Mailee::Config.site = "http://api.869a72b17b05a.mailee-api.mailee.me"
10
9
  end
11
10
 
12
- class Foo < ActionMailer::Base
11
+ class FooMailer < ActionMailer::Base
13
12
 
14
13
  send_with_mailee
15
14
 
@@ -1,13 +1,12 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'rspec'
3
4
  require 'sqlite3'
4
5
  require 'active_record'
5
6
  require 'mailee'
6
- require 'spec'
7
- require 'spec/autorun'
8
7
 
9
- Spec::Runner.configure do |config|
10
-
8
+ RSpec.configure do |config|
9
+ Mailee::Config.site = "http://api.869a72b17b05a.mailee-api.mailee.me"
11
10
  end
12
11
 
13
12
  db = "mailee-api-test.db"
@@ -33,4 +32,17 @@ end
33
32
 
34
33
  class Bar < ActiveRecord::Base
35
34
  sync_with_mailee :email => :other_email, :name => :other_name, :news => :other_news
36
- end
35
+ end
36
+
37
+ class FooList < ActiveRecord::Base
38
+ set_table_name 'foos'
39
+ @@moment = Time.now.strftime('%Y%m%d%H%M%S')
40
+ @@list = Mailee::List.create :name => "Foo List #{@@moment}"
41
+ sync_with_mailee :list => @@list.name
42
+ def self.list
43
+ @@list
44
+ end
45
+ def self.contacts_count
46
+ Mailee::List.find(@@list.id).lists_contacts_count
47
+ end
48
+ end
@@ -2,20 +2,16 @@ require File.expand_path(File.dirname(__FILE__) + '/am_spec_helper')
2
2
 
3
3
  describe "Mailee" do
4
4
 
5
- before(:each) do
6
- Mailee::Config.site = "http://api.bdb28c0a0a4a3.softa.server:3000"
7
- end
8
-
9
5
  it "should respond to send_with_mailee" do
10
6
  ActionMailer::Base.should respond_to(:send_with_mailee)
11
7
  end
12
8
 
13
9
  it "should use Mailee::Mailer as the delivery method" do
14
- Foo.delivery_method.should be(Mailee::Mailer)
10
+ FooMailer.delivery_method.should be(Mailee::Mailer)
15
11
  end
16
12
 
17
13
  it "should deliver" do
18
- result = Foo.bar.deliver
14
+ result = FooMailer.bar.deliver
19
15
  result.should_not be(false)
20
16
  result.class.should be(Mail::Message)
21
17
  result.delivery_method.class.should be(Mailee::Mailer)
@@ -1,9 +1,8 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/ar_spec_helper')
2
-
2
+
3
3
  describe "Mailee" do
4
4
 
5
5
  before(:each) do
6
- Mailee::Config.site = "http://api.bdb28c0a0a4a3.softa.server:3000"
7
6
  @moment = Time.now.strftime('%Y%m%d%H%M%S')
8
7
  end
9
8
 
@@ -11,7 +10,6 @@ describe "Mailee" do
11
10
  ActiveRecord::Base.should respond_to(:sync_with_mailee)
12
11
  end
13
12
 
14
-
15
13
  it "should create if news is checked" do
16
14
  foo = Foo.create :name => "rest_test_foo_#{@moment}", :email => "rest_test_foo_#{@moment}@test.com", :news => true
17
15
  found = Mailee::Contact.find_by_email("rest_test_foo_#{@moment}@test.com")
@@ -44,4 +42,9 @@ describe "Mailee" do
44
42
  found.internal_id.to_i.should be bar.id
45
43
  end
46
44
 
45
+ it "should subscribe to a list if :list is set" do
46
+ foo = FooList.create :name => "rest_test_foo_#{@moment}", :email => "rest_test_foo_#{@moment}@test.com", :news => true
47
+ # TODO I really cannot know if the email was subscribed successfully :S
48
+ end
49
+
47
50
  end
@@ -3,7 +3,6 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe "Mailee" do
4
4
 
5
5
  before(:each) do
6
- Mailee::Config.site = "http://api.bdb28c0a0a4a3.softa.server:3000"
7
6
  @moment = Time.now.strftime('%Y%m%d%H%M%S')
8
7
  end
9
8
 
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- #require 'active_record'
3
+ require 'rspec'
4
+ require 'active_record'
4
5
  require 'mailee'
5
- require 'spec'
6
- require 'spec/autorun'
7
6
 
8
- Spec::Runner.configure do |config|
9
-
7
+ RSpec.configure do |config|
8
+ Mailee::Config.site = "http://api.869a72b17b05a.mailee-api.mailee.me"
10
9
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailee
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 3
10
- version: 0.4.3
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Juan Maiz
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-16 00:00:00 -04:00
18
+ date: 2011-03-28 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -31,6 +31,8 @@ extra_rdoc_files:
31
31
  - README.markdown.pt
32
32
  - README.rdoc
33
33
  files:
34
+ - .gitignore
35
+ - .rspec
34
36
  - LICENSE
35
37
  - MIT-LICENSE
36
38
  - README.markdown
@@ -64,6 +66,7 @@ files:
64
66
  - app/config/initializers/session_store.rb
65
67
  - app/config/locales/en.yml
66
68
  - app/config/routes.rb
69
+ - app/db/schema.rb
67
70
  - app/db/seeds.rb
68
71
  - app/doc/README_FOR_APP
69
72
  - app/lib/tasks/.gitkeep
@@ -98,12 +101,12 @@ files:
98
101
  - pkg/mailee-0.1.0.gem
99
102
  - pkg/mailee-0.1.1.gem
100
103
  - pkg/mailee-0.1.2.gem
104
+ - pkg/mailee-0.4.4.gem
101
105
  - spec/am_spec_helper.rb
102
106
  - spec/ar_spec_helper.rb
103
- - spec/mailee-api-am.rb
104
- - spec/mailee-api-ar.rb
105
- - spec/mailee-api.rb
106
- - spec/spec.opts
107
+ - spec/mailee-api-am_spec.rb
108
+ - spec/mailee-api-ar_spec.rb
109
+ - spec/mailee-api_spec.rb
107
110
  - spec/spec_helper.rb
108
111
  - tasks/mailee_tasks.rake
109
112
  - README.markdown.pt
@@ -144,7 +147,7 @@ summary: "Gem de integra\xC3\xA7\xC3\xA3o do Mailee.me"
144
147
  test_files:
145
148
  - spec/am_spec_helper.rb
146
149
  - spec/ar_spec_helper.rb
147
- - spec/mailee-api-am.rb
148
- - spec/mailee-api-ar.rb
149
- - spec/mailee-api.rb
150
+ - spec/mailee-api-am_spec.rb
151
+ - spec/mailee-api-ar_spec.rb
152
+ - spec/mailee-api_spec.rb
150
153
  - spec/spec_helper.rb
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --color