maily_herald 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/.gitignore +11 -0
  2. data/Gemfile +19 -0
  3. data/Gemfile.lock +149 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.rdoc +3 -0
  6. data/Rakefile +23 -0
  7. data/app/assets/images/maily_herald/.gitkeep +0 -0
  8. data/app/assets/javascripts/maily_herald/application.js +15 -0
  9. data/app/assets/stylesheets/maily_herald/application.css +13 -0
  10. data/app/controllers/maily_herald/application_controller.rb +4 -0
  11. data/app/helpers/maily_herald/application_helper.rb +4 -0
  12. data/app/helpers/maily_herald_helper.rb +9 -0
  13. data/app/models/maily_herald/mailing.rb +12 -0
  14. data/app/models/maily_herald/mailing_record.rb +6 -0
  15. data/app/models/maily_herald/sequence.rb +5 -0
  16. data/app/views/layouts/maily_herald/application.html.erb +14 -0
  17. data/config/locales/en.yml +13 -0
  18. data/config/routes.rb +2 -0
  19. data/db/migrate/20130711124555_create_maily_herald_tables.rb +38 -0
  20. data/lib/generators/maily_herald/install_generator.rb +21 -0
  21. data/lib/generators/templates/maily_herald.rb +2 -0
  22. data/lib/maily_herald.rb +29 -0
  23. data/lib/maily_herald/context.rb +79 -0
  24. data/lib/maily_herald/engine.rb +5 -0
  25. data/lib/maily_herald/utils.rb +7 -0
  26. data/lib/maily_herald/version.rb +3 -0
  27. data/lib/maily_herald/worker.rb +15 -0
  28. data/lib/tasks/maily_herald_tasks.rake +4 -0
  29. data/maily_herald.gemspec +29 -0
  30. data/script/rails +8 -0
  31. data/spec/dummy/README.rdoc +261 -0
  32. data/spec/dummy/Rakefile +7 -0
  33. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  34. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  35. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  36. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  37. data/spec/dummy/app/mailers/.gitkeep +0 -0
  38. data/spec/dummy/app/models/.gitkeep +0 -0
  39. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  40. data/spec/dummy/config.ru +4 -0
  41. data/spec/dummy/config/application.rb +65 -0
  42. data/spec/dummy/config/boot.rb +10 -0
  43. data/spec/dummy/config/database.yml +25 -0
  44. data/spec/dummy/config/environment.rb +5 -0
  45. data/spec/dummy/config/environments/development.rb +37 -0
  46. data/spec/dummy/config/environments/production.rb +67 -0
  47. data/spec/dummy/config/environments/test.rb +37 -0
  48. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  49. data/spec/dummy/config/initializers/inflections.rb +15 -0
  50. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  51. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  52. data/spec/dummy/config/initializers/session_store.rb +8 -0
  53. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  54. data/spec/dummy/config/locales/en.yml +5 -0
  55. data/spec/dummy/config/routes.rb +4 -0
  56. data/spec/dummy/lib/assets/.gitkeep +0 -0
  57. data/spec/dummy/log/.gitkeep +0 -0
  58. data/spec/dummy/public/404.html +26 -0
  59. data/spec/dummy/public/422.html +26 -0
  60. data/spec/dummy/public/500.html +25 -0
  61. data/spec/dummy/public/favicon.ico +0 -0
  62. data/spec/dummy/script/rails +6 -0
  63. data/spec/spec_helper.rb +28 -0
  64. metadata +269 -0
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/log/*.log
6
+ test/dummy/tmp/
7
+ test/dummy/.sass-cache
8
+
9
+ *.swo
10
+ *.swp
11
+ *.rvmrc
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in maily_herald.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # jquery-rails is used by the dummy application
9
+ gem "jquery-rails"
10
+
11
+ gem "liquid", "~> 2.6.0", :git => "git@github.com:Shopify/liquid.git"
12
+
13
+ # Declare any dependencies that are still in development here instead of in
14
+ # your gemspec. These might include edge Rails or gems from your path or
15
+ # Git. Remember to move these dependencies to your gemspec before releasing
16
+ # your gem to rubygems.org.
17
+
18
+ # To use debugger
19
+ # gem 'debugger'
data/Gemfile.lock ADDED
@@ -0,0 +1,149 @@
1
+ GIT
2
+ remote: git@github.com:Shopify/liquid.git
3
+ revision: fbfda1a1895bfb5bd9477248008f60fc1953c297
4
+ specs:
5
+ liquid (2.6.0)
6
+
7
+ PATH
8
+ remote: .
9
+ specs:
10
+ maily_herald (0.0.1)
11
+ liquid (~> 2.6.0)
12
+ rails (~> 3.2.8)
13
+ sidekiq (~> 2.13.0)
14
+
15
+ GEM
16
+ remote: http://rubygems.org/
17
+ specs:
18
+ actionmailer (3.2.13)
19
+ actionpack (= 3.2.13)
20
+ mail (~> 2.5.3)
21
+ actionpack (3.2.13)
22
+ activemodel (= 3.2.13)
23
+ activesupport (= 3.2.13)
24
+ builder (~> 3.0.0)
25
+ erubis (~> 2.7.0)
26
+ journey (~> 1.0.4)
27
+ rack (~> 1.4.5)
28
+ rack-cache (~> 1.2)
29
+ rack-test (~> 0.6.1)
30
+ sprockets (~> 2.2.1)
31
+ activemodel (3.2.13)
32
+ activesupport (= 3.2.13)
33
+ builder (~> 3.0.0)
34
+ activerecord (3.2.13)
35
+ activemodel (= 3.2.13)
36
+ activesupport (= 3.2.13)
37
+ arel (~> 3.0.2)
38
+ tzinfo (~> 0.3.29)
39
+ activeresource (3.2.13)
40
+ activemodel (= 3.2.13)
41
+ activesupport (= 3.2.13)
42
+ activesupport (3.2.13)
43
+ i18n (= 0.6.1)
44
+ multi_json (~> 1.0)
45
+ arel (3.0.2)
46
+ bourne (1.5.0)
47
+ mocha (>= 0.13.2, < 0.15)
48
+ builder (3.0.4)
49
+ celluloid (0.14.1)
50
+ timers (>= 1.0.0)
51
+ connection_pool (1.1.0)
52
+ database_cleaner (1.0.1)
53
+ diff-lcs (1.2.4)
54
+ erubis (2.7.0)
55
+ factory_girl (4.2.0)
56
+ activesupport (>= 3.0.0)
57
+ factory_girl_rails (4.2.1)
58
+ factory_girl (~> 4.2.0)
59
+ railties (>= 3.0.0)
60
+ hike (1.2.3)
61
+ i18n (0.6.1)
62
+ journey (1.0.4)
63
+ jquery-rails (3.0.2)
64
+ railties (>= 3.0, < 5.0)
65
+ thor (>= 0.14, < 2.0)
66
+ json (1.8.0)
67
+ mail (2.5.4)
68
+ mime-types (~> 1.16)
69
+ treetop (~> 1.4.8)
70
+ metaclass (0.0.1)
71
+ mime-types (1.23)
72
+ mocha (0.14.0)
73
+ metaclass (~> 0.0.1)
74
+ multi_json (1.7.7)
75
+ polyglot (0.3.3)
76
+ rack (1.4.5)
77
+ rack-cache (1.2)
78
+ rack (>= 0.4)
79
+ rack-ssl (1.3.3)
80
+ rack
81
+ rack-test (0.6.2)
82
+ rack (>= 1.0)
83
+ rails (3.2.13)
84
+ actionmailer (= 3.2.13)
85
+ actionpack (= 3.2.13)
86
+ activerecord (= 3.2.13)
87
+ activeresource (= 3.2.13)
88
+ activesupport (= 3.2.13)
89
+ bundler (~> 1.0)
90
+ railties (= 3.2.13)
91
+ railties (3.2.13)
92
+ actionpack (= 3.2.13)
93
+ activesupport (= 3.2.13)
94
+ rack-ssl (~> 1.3.2)
95
+ rake (>= 0.8.7)
96
+ rdoc (~> 3.4)
97
+ thor (>= 0.14.6, < 2.0)
98
+ rake (10.1.0)
99
+ rdoc (3.12.2)
100
+ json (~> 1.4)
101
+ redis (3.0.4)
102
+ redis-namespace (1.3.0)
103
+ redis (~> 3.0.0)
104
+ rspec-core (2.13.1)
105
+ rspec-expectations (2.13.0)
106
+ diff-lcs (>= 1.1.3, < 2.0)
107
+ rspec-mocks (2.13.1)
108
+ rspec-rails (2.13.2)
109
+ actionpack (>= 3.0)
110
+ activesupport (>= 3.0)
111
+ railties (>= 3.0)
112
+ rspec-core (~> 2.13.0)
113
+ rspec-expectations (~> 2.13.0)
114
+ rspec-mocks (~> 2.13.0)
115
+ shoulda-matchers (1.5.6)
116
+ activesupport (>= 3.0.0)
117
+ bourne (~> 1.3)
118
+ sidekiq (2.13.0)
119
+ celluloid (>= 0.14.1)
120
+ connection_pool (>= 1.0.0)
121
+ json
122
+ redis (>= 3.0)
123
+ redis-namespace
124
+ sprockets (2.2.2)
125
+ hike (~> 1.2)
126
+ multi_json (~> 1.0)
127
+ rack (~> 1.0)
128
+ tilt (~> 1.1, != 1.3.0)
129
+ sqlite3 (1.3.7)
130
+ thor (0.18.1)
131
+ tilt (1.4.1)
132
+ timers (1.1.0)
133
+ treetop (1.4.14)
134
+ polyglot
135
+ polyglot (>= 0.3.1)
136
+ tzinfo (0.3.37)
137
+
138
+ PLATFORMS
139
+ ruby
140
+
141
+ DEPENDENCIES
142
+ database_cleaner
143
+ factory_girl_rails
144
+ jquery-rails
145
+ liquid (~> 2.6.0)!
146
+ maily_herald!
147
+ rspec-rails
148
+ shoulda-matchers (~> 1.0)
149
+ sqlite3
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Łukasz Jachymczyk (lukasz@sology.pl) with initial development sponsored by Smart Language Apps Ltd (www.smartlanguageapps.com).
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = MailyHerald
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'MailyHerald'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ Bundler::GemHelper.install_tasks
File without changes
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ module MailyHerald
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module MailyHerald
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ module MailyHeraldHelper
2
+ def maily_herald_context_options_for_select selected = nil, options = {}
3
+ MailyHerald.contexts.keys.collect {|c| [c, c] }
4
+ end
5
+
6
+ def maily_herald_context_attributes_list name
7
+ MailyHerald.context(name).each
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ module MailyHerald
2
+ class Mailing < ActiveRecord::Base
3
+ attr_accessible :name, :context, :sequence, :conditions, :title, :sender, :delay, :template
4
+
5
+ belongs_to :sequence, :class_name => "MailyHerald::Sequence"
6
+ has_many :records, :as => :mailing, :class_name => "MailyHerald::MailingRecord"
7
+
8
+ def has_conditions?
9
+ !conditions.empty?
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ module MailyHerald
2
+ class MailingRecord < ActiveRecord::Base
3
+ belongs_to :entity, :polymorphic => true
4
+ belongs_to :mailing, :polymorphic => true
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module MailyHerald
2
+ class Sequence < ActiveRecord::Base
3
+ has_many :records, :as => :mailing, :class_name => "MailingRecord"
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>MailyHerald</title>
5
+ <%= stylesheet_link_tag "maily_herald/application", :media => "all" %>
6
+ <%= javascript_include_tag "maily_herald/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,13 @@
1
+ en:
2
+ activerecord:
3
+ attributes:
4
+ mailing:
5
+ name: Name
6
+ context: Context
7
+ sequence: Sequence
8
+ conditions: Conditions
9
+ title: Title
10
+ sender: Sender
11
+ delay: Delay
12
+ token: Token
13
+ template: Template
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ MailyHerald::Engine.routes.draw do
2
+ end
@@ -0,0 +1,38 @@
1
+ class CreateMailyHeraldTables < ActiveRecord::Migration
2
+ def change
3
+ create_table :maily_herald_mailings do |t|
4
+ t.integer :sequence_id
5
+ t.string :context_name
6
+ t.text :conditions
7
+ t.string :name
8
+ t.string :title
9
+ t.string :sender
10
+ t.text :template
11
+ t.integer :delay
12
+
13
+ t.timestamps
14
+ end
15
+
16
+ create_table :maily_herald_sequences do |t|
17
+ t.string :context_name
18
+ t.string :name
19
+ t.integer :mode
20
+ t.datetime :start
21
+ t.text :start_expr
22
+ t.integer :period
23
+
24
+ t.timestamps
25
+ end
26
+
27
+ create_table :maily_herald_mailing_records do |t|
28
+ t.integer :entity_id
29
+ t.string :entity_type
30
+ t.integer :mailing_id
31
+ t.string :mailing_type
32
+ t.string :token
33
+ t.text :settings
34
+ t.text :status
35
+ t.datetime :last_delivery
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,21 @@
1
+ module MailyHerald
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ desc "Creates a MailyHerald initializer and copy locale files to your application."
7
+
8
+ def copy_initializer
9
+ template "maily_herald.rb", "config/initializers/maily_herald.rb"
10
+ end
11
+
12
+ def copy_locale
13
+ copy_file "../../../config/locales/en.yml", "config/locales/maily_handler.en.yml"
14
+ end
15
+
16
+ def show_readme
17
+ readme "README" if behavior == :invoke
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,2 @@
1
+ MailyHerald.setup do |config|
2
+ end
@@ -0,0 +1,29 @@
1
+ require "maily_herald/engine"
2
+
3
+ module MailyHerald
4
+ autoload :Utils, 'maily_herald/utils'
5
+ autoload :Context, 'maily_herald/context'
6
+ autoload :Worker, 'maily_herald/worker'
7
+
8
+ def self.setup
9
+ yield self
10
+ end
11
+
12
+ def self.context name, &block
13
+ name = name.to_s
14
+
15
+ if block_given?
16
+ @@contexts ||= {}
17
+ @@contexts[name] ||= MailyHerald::Context.new
18
+ yield @@contexts[name]
19
+ else
20
+ @@contexts[name]
21
+ end
22
+ end
23
+
24
+ def self.contexts
25
+ @@contexts
26
+ end
27
+ end
28
+
29
+ require 'liquid'