maily_herald 0.8.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +1 -0
  3. data/.travis.yml +3 -0
  4. data/Gemfile +0 -2
  5. data/Gemfile.lock +5 -13
  6. data/README.md +186 -69
  7. data/app/mailers/maily_herald/mailer.rb +44 -26
  8. data/app/models/maily_herald/ad_hoc_mailing.rb +109 -0
  9. data/app/models/maily_herald/dispatch.rb +97 -4
  10. data/app/models/maily_herald/list.rb +36 -7
  11. data/app/models/maily_herald/log.rb +79 -0
  12. data/app/models/maily_herald/mailing.rb +149 -24
  13. data/app/models/maily_herald/one_time_mailing.rb +114 -9
  14. data/app/models/maily_herald/periodical_mailing.rb +76 -47
  15. data/app/models/maily_herald/sequence.rb +57 -18
  16. data/app/models/maily_herald/sequence_mailing.rb +29 -20
  17. data/app/models/maily_herald/subscription.rb +23 -2
  18. data/config/routes.rb +2 -2
  19. data/lib/maily_herald.rb +57 -18
  20. data/lib/maily_herald/autonaming.rb +8 -0
  21. data/lib/maily_herald/context.rb +6 -2
  22. data/lib/maily_herald/logging.rb +2 -0
  23. data/lib/maily_herald/manager.rb +15 -31
  24. data/lib/maily_herald/utils.rb +65 -24
  25. data/lib/maily_herald/version.rb +1 -1
  26. data/maily_herald.gemspec +1 -1
  27. data/spec/controllers/maily_herald/tokens_controller_spec.rb +13 -13
  28. data/spec/dummy/app/mailers/ad_hoc_mailer.rb +11 -0
  29. data/spec/dummy/app/mailers/custom_one_time_mailer.rb +11 -0
  30. data/spec/dummy/config/application.rb +1 -1
  31. data/spec/dummy/config/environments/test.rb +1 -1
  32. data/spec/dummy/config/initializers/maily_herald.rb +3 -69
  33. data/spec/dummy/config/maily_herald.yml +3 -0
  34. data/spec/dummy/db/seeds.rb +73 -0
  35. data/spec/lib/context_spec.rb +7 -7
  36. data/spec/lib/maily_herald_spec.rb +7 -8
  37. data/spec/lib/utils_spec.rb +65 -25
  38. data/spec/mailers/maily_herald/mailer_spec.rb +20 -13
  39. data/spec/models/maily_herald/ad_hoc_mailing_spec.rb +169 -0
  40. data/spec/models/maily_herald/list_spec.rb +2 -1
  41. data/spec/models/maily_herald/log_spec.rb +10 -10
  42. data/spec/models/maily_herald/mailing_spec.rb +9 -8
  43. data/spec/models/maily_herald/one_time_mailing_spec.rb +212 -39
  44. data/spec/models/maily_herald/periodical_mailing_spec.rb +158 -92
  45. data/spec/models/maily_herald/sequence_mailing_spec.rb +2 -2
  46. data/spec/models/maily_herald/sequence_spec.rb +152 -139
  47. data/spec/models/maily_herald/subscription_spec.rb +21 -4
  48. metadata +17 -8
  49. data/lib/maily_herald/condition_evaluator.rb +0 -82
  50. data/lib/maily_herald/config.rb +0 -5
  51. data/spec/dummy/app/mailers/test_mailer.rb +0 -11
@@ -11,10 +11,10 @@ describe MailyHerald::Subscription do
11
11
 
12
12
  describe "Associations" do
13
13
  it "should have valid associations" do
14
- @subscription.entity.should eq(@entity)
15
- @subscription.list.should eq(@list)
16
- @subscription.should be_valid
17
- @subscription.should_not be_a_new_record
14
+ expect(@subscription.entity).to eq(@entity)
15
+ expect(@subscription.list).to eq(@list)
16
+ expect(@subscription).to be_valid
17
+ expect(@subscription).not_to be_a_new_record
18
18
  end
19
19
  end
20
20
 
@@ -29,4 +29,21 @@ describe MailyHerald::Subscription do
29
29
  expect {@mailing.render_template(@entity)}.to raise_error
30
30
  end
31
31
  end
32
+
33
+ it "should instantiate subscription object from joined attributes" do
34
+ list = MailyHerald.list(:generic_list)
35
+ list.subscribe!(@entity)
36
+
37
+ entity = list.subscribers.first
38
+
39
+ expect(entity).to be_a(User)
40
+ expect(entity).to have_attribute(:maily_subscription_id)
41
+ expect(entity.maily_subscription_active).to be_truthy
42
+
43
+ subscription = MailyHerald::Subscription.get_from(entity)
44
+
45
+ expect(subscription).to be_a(MailyHerald::Subscription)
46
+ expect(subscription).to be_readonly
47
+ expect(subscription).to be_active
48
+ end
32
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maily_herald
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Łukasz Jachymczyk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -206,7 +206,7 @@ dependencies:
206
206
  - - ! '>='
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
- description: Email marketing solution for Ruby on Rails applications
209
+ description: Email processing solution for Ruby on Rails applications
210
210
  email:
211
211
  - lukasz@sology.eu
212
212
  executables:
@@ -216,6 +216,7 @@ extra_rdoc_files: []
216
216
  files:
217
217
  - .gitignore
218
218
  - .rspec
219
+ - .travis.yml
219
220
  - Gemfile
220
221
  - Gemfile.lock
221
222
  - Guardfile
@@ -226,6 +227,7 @@ files:
226
227
  - app/controllers/maily_herald/tokens_controller.rb
227
228
  - app/helpers/maily_herald/tokens_helper.rb
228
229
  - app/mailers/maily_herald/mailer.rb
230
+ - app/models/maily_herald/ad_hoc_mailing.rb
229
231
  - app/models/maily_herald/dispatch.rb
230
232
  - app/models/maily_herald/list.rb
231
233
  - app/models/maily_herald/log.rb
@@ -243,6 +245,7 @@ files:
243
245
  - db/migrate/20150205120443_create_maily_herald_tables.rb
244
246
  - db/migrate_legacy/20130711124555_create_maily_herald_tables.rb
245
247
  - db/migrate_legacy/20140612101023_create_lists.rb
248
+ - doc/webui.png
246
249
  - lib/generators/maily_herald/install_generator.rb
247
250
  - lib/generators/templates/README
248
251
  - lib/generators/templates/maily_herald.rb
@@ -252,8 +255,6 @@ files:
252
255
  - lib/maily_herald/capistrano/tasks.cap
253
256
  - lib/maily_herald/capistrano/tasks2.rb
254
257
  - lib/maily_herald/cli.rb
255
- - lib/maily_herald/condition_evaluator.rb
256
- - lib/maily_herald/config.rb
257
258
  - lib/maily_herald/context.rb
258
259
  - lib/maily_herald/engine.rb
259
260
  - lib/maily_herald/logging.rb
@@ -274,7 +275,8 @@ files:
274
275
  - spec/dummy/app/controllers/application_controller.rb
275
276
  - spec/dummy/app/helpers/application_helper.rb
276
277
  - spec/dummy/app/mailers/.gitkeep
277
- - spec/dummy/app/mailers/test_mailer.rb
278
+ - spec/dummy/app/mailers/ad_hoc_mailer.rb
279
+ - spec/dummy/app/mailers/custom_one_time_mailer.rb
278
280
  - spec/dummy/app/models/.gitkeep
279
281
  - spec/dummy/app/models/product.rb
280
282
  - spec/dummy/app/models/user.rb
@@ -301,9 +303,11 @@ files:
301
303
  - spec/dummy/config/initializers/wrap_parameters.rb
302
304
  - spec/dummy/config/locales/en.yml
303
305
  - spec/dummy/config/locales/maily_herald.en.yml
306
+ - spec/dummy/config/maily_herald.yml
304
307
  - spec/dummy/config/routes.rb
305
308
  - spec/dummy/db/migrate/20130723074347_create_users.rb
306
309
  - spec/dummy/db/schema.rb
310
+ - spec/dummy/db/seeds.rb
307
311
  - spec/dummy/lib/assets/.gitkeep
308
312
  - spec/dummy/log/.gitkeep
309
313
  - spec/dummy/public/404.html
@@ -317,6 +321,7 @@ files:
317
321
  - spec/lib/maily_herald_spec.rb
318
322
  - spec/lib/utils_spec.rb
319
323
  - spec/mailers/maily_herald/mailer_spec.rb
324
+ - spec/models/maily_herald/ad_hoc_mailing_spec.rb
320
325
  - spec/models/maily_herald/list_spec.rb
321
326
  - spec/models/maily_herald/log_spec.rb
322
327
  - spec/models/maily_herald/mailing_spec.rb
@@ -349,7 +354,7 @@ rubyforge_project:
349
354
  rubygems_version: 2.1.11
350
355
  signing_key:
351
356
  specification_version: 4
352
- summary: Email marketing solution for Ruby on Rails applications
357
+ summary: Email processing solution for Ruby on Rails applications
353
358
  test_files:
354
359
  - spec/controllers/maily_herald/tokens_controller_spec.rb
355
360
  - spec/dummy/Guardfile
@@ -360,7 +365,8 @@ test_files:
360
365
  - spec/dummy/app/controllers/application_controller.rb
361
366
  - spec/dummy/app/helpers/application_helper.rb
362
367
  - spec/dummy/app/mailers/.gitkeep
363
- - spec/dummy/app/mailers/test_mailer.rb
368
+ - spec/dummy/app/mailers/ad_hoc_mailer.rb
369
+ - spec/dummy/app/mailers/custom_one_time_mailer.rb
364
370
  - spec/dummy/app/models/.gitkeep
365
371
  - spec/dummy/app/models/product.rb
366
372
  - spec/dummy/app/models/user.rb
@@ -387,9 +393,11 @@ test_files:
387
393
  - spec/dummy/config/initializers/wrap_parameters.rb
388
394
  - spec/dummy/config/locales/en.yml
389
395
  - spec/dummy/config/locales/maily_herald.en.yml
396
+ - spec/dummy/config/maily_herald.yml
390
397
  - spec/dummy/config/routes.rb
391
398
  - spec/dummy/db/migrate/20130723074347_create_users.rb
392
399
  - spec/dummy/db/schema.rb
400
+ - spec/dummy/db/seeds.rb
393
401
  - spec/dummy/lib/assets/.gitkeep
394
402
  - spec/dummy/log/.gitkeep
395
403
  - spec/dummy/public/404.html
@@ -403,6 +411,7 @@ test_files:
403
411
  - spec/lib/maily_herald_spec.rb
404
412
  - spec/lib/utils_spec.rb
405
413
  - spec/mailers/maily_herald/mailer_spec.rb
414
+ - spec/models/maily_herald/ad_hoc_mailing_spec.rb
406
415
  - spec/models/maily_herald/list_spec.rb
407
416
  - spec/models/maily_herald/log_spec.rb
408
417
  - spec/models/maily_herald/mailing_spec.rb
@@ -1,82 +0,0 @@
1
- module MailyHerald
2
- #module ConditionEvaluator
3
- #class DummyDrop < Liquid::Drop
4
- #def has_key?(name)
5
- #true
6
- #end
7
-
8
- #def invoke_drop name
9
- #true
10
- #end
11
-
12
- #alias :[] :invoke_drop
13
- #end
14
-
15
- #def self.included(base)
16
- #base.validate :validate_conditions
17
-
18
- #base.send :include, MailyHerald::ConditionEvaluator::InstanceMethods
19
- #end
20
-
21
- #module InstanceMethods
22
- #def has_conditions?
23
- #self.conditions && !self.conditions.empty?
24
- #end
25
-
26
- #def evaluate_conditions_for entity
27
- #if has_conditions?
28
- #condition = create_liquid_condition self.conditions
29
- #template = Liquid::Template.parse(self.conditions)
30
- #drop = context.drop_for entity, subscription_for(entity)
31
-
32
- #liquid_context = Liquid::Context.new([drop, template.assigns], template.instance_assigns, template.registers, true, {})
33
- #drop.context = liquid_context
34
-
35
- #condition.evaluate liquid_context
36
- #else
37
- #true
38
- #end
39
- #end
40
-
41
- #def test_conditions
42
- #return true unless self.conditions
43
-
44
- #condition = create_liquid_condition self.conditions
45
- #template = Liquid::Template.parse(self.conditions)
46
- #return false unless template.errors.empty?
47
-
48
- #drop = DummyDrop.new
49
- #liquid_context = Liquid::Context.new([drop, template.assigns], template.instance_assigns, template.registers, true, {})
50
- #drop.context = liquid_context
51
-
52
- #condition.evaluate liquid_context
53
- #end
54
-
55
- #private
56
-
57
- #def create_liquid_condition markup
58
- #expressions = markup.scan(Liquid::If::ExpressionsAndOperators).reverse
59
- #raise(Liquid::SyntaxError, Liquid::SyntaxHelp) unless expressions.shift =~ Liquid::If::Syntax
60
-
61
- #condition = Liquid::Condition.new($1, $2, $3)
62
- #while not expressions.empty?
63
- #operator = (expressions.shift).to_s.strip
64
-
65
- #raise(Liquid::SyntaxError, Liquid::SyntaxHelp) unless expressions.shift.to_s =~ Liquid::If::Syntax
66
-
67
- #new_condition = Liquid::Condition.new($1, $2, $3)
68
- #new_condition.send(operator.to_sym, condition)
69
- #condition = new_condition
70
- #end
71
-
72
- #condition
73
- #end
74
-
75
- #def validate_conditions
76
- #test_conditions
77
- #rescue StandardError => e
78
- #errors.add(:conditions, e.to_s)
79
- #end
80
- #end
81
- #end
82
- end
@@ -1,5 +0,0 @@
1
- require 'maily_herald'
2
- module MailyHerald
3
- module Config
4
- end
5
- end
@@ -1,11 +0,0 @@
1
- class TestMailer < MailyHerald::Mailer
2
- default from: "no-reply@flossmarket.com"
3
-
4
- def sample_mail user
5
- mail to: user.email, subject: "Test"
6
- end
7
-
8
- def sample_mail_error user
9
- mail to: user.email, subject: "Test"
10
- end
11
- end