faucet 0.1.0

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.
Files changed (101) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +39 -0
  4. data/app/assets/images/faucet/droplet.png +0 -0
  5. data/app/assets/javascripts/faucet/application.js +9 -0
  6. data/app/assets/javascripts/faucet/emails.js +2 -0
  7. data/app/assets/stylesheets/faucet/application.css +10 -0
  8. data/app/assets/stylesheets/faucet/emails.css +40 -0
  9. data/app/assets/stylesheets/faucet/fonts.css +35 -0
  10. data/app/assets/stylesheets/faucet/reset.css +48 -0
  11. data/app/controllers/faucet/application_controller.rb +4 -0
  12. data/app/controllers/faucet/emails_controller.rb +24 -0
  13. data/app/helpers/faucet/application_helper.rb +4 -0
  14. data/app/helpers/faucet/emails_helper.rb +4 -0
  15. data/app/models/faucet/email.rb +13 -0
  16. data/app/views/faucet/emails/drip.html.erb +7 -0
  17. data/app/views/faucet/emails/index.html.erb +41 -0
  18. data/app/views/layouts/faucet/application.html.erb +14 -0
  19. data/config/routes.rb +4 -0
  20. data/db/migrate/20120216201711_create_faucet_emails.rb +10 -0
  21. data/db/migrate/20120216214357_add_description_to_emails.rb +5 -0
  22. data/db/migrate/20120216214548_add_email_to_emails.rb +5 -0
  23. data/db/migrate/20120216215258_add_sent_to_faucet_emails.rb +5 -0
  24. data/lib/faucet.rb +4 -0
  25. data/lib/faucet/engine.rb +5 -0
  26. data/lib/faucet/version.rb +3 -0
  27. data/lib/tasks/faucet_tasks.rake +5 -0
  28. data/test/dummy/Rakefile +7 -0
  29. data/test/dummy/app/assets/javascripts/application.js +9 -0
  30. data/test/dummy/app/assets/javascripts/simulate.js +2 -0
  31. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  32. data/test/dummy/app/assets/stylesheets/simulate.css +4 -0
  33. data/test/dummy/app/controllers/application_controller.rb +3 -0
  34. data/test/dummy/app/controllers/simulate_controller.rb +5 -0
  35. data/test/dummy/app/helpers/application_helper.rb +2 -0
  36. data/test/dummy/app/helpers/simulate_helper.rb +2 -0
  37. data/test/dummy/app/mailers/user_mailer.rb +15 -0
  38. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  39. data/test/dummy/app/views/simulate/schedule.html.erb +2 -0
  40. data/test/dummy/app/views/user_mailer/one_week.text.erb +3 -0
  41. data/test/dummy/config.ru +4 -0
  42. data/test/dummy/config/application.rb +45 -0
  43. data/test/dummy/config/boot.rb +10 -0
  44. data/test/dummy/config/database.yml +25 -0
  45. data/test/dummy/config/environment.rb +5 -0
  46. data/test/dummy/config/environments/development.rb +30 -0
  47. data/test/dummy/config/environments/production.rb +60 -0
  48. data/test/dummy/config/environments/test.rb +39 -0
  49. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  50. data/test/dummy/config/initializers/inflections.rb +10 -0
  51. data/test/dummy/config/initializers/mime_types.rb +5 -0
  52. data/test/dummy/config/initializers/secret_token.rb +7 -0
  53. data/test/dummy/config/initializers/session_store.rb +8 -0
  54. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  55. data/test/dummy/config/locales/en.yml +5 -0
  56. data/test/dummy/config/routes.rb +6 -0
  57. data/test/dummy/db/development.sqlite3 +0 -0
  58. data/test/dummy/db/schema.rb +26 -0
  59. data/test/dummy/log/development.log +6118 -0
  60. data/test/dummy/public/404.html +26 -0
  61. data/test/dummy/public/422.html +26 -0
  62. data/test/dummy/public/500.html +26 -0
  63. data/test/dummy/public/favicon.ico +0 -0
  64. data/test/dummy/script/rails +6 -0
  65. data/test/dummy/test/functional/simulate_controller_test.rb +9 -0
  66. data/test/dummy/test/functional/user_mailer_test.rb +12 -0
  67. data/test/dummy/test/unit/helpers/simulate_helper_test.rb +4 -0
  68. data/test/dummy/tmp/cache/assets/C01/070/sprockets%2F13f11507371557e72767f9f48e977020 +0 -0
  69. data/test/dummy/tmp/cache/assets/C77/AC0/sprockets%2Fa4efc69673820c7071215318b750c24b +0 -0
  70. data/test/dummy/tmp/cache/assets/C85/C90/sprockets%2Fa810fb95bb723e491a3934787194516b +0 -0
  71. data/test/dummy/tmp/cache/assets/CCC/1C0/sprockets%2Fb1d59ee6c042207757cf132a466ab111 +0 -0
  72. data/test/dummy/tmp/cache/assets/CD0/B30/sprockets%2Fe8dbe214a4ca2158173b8c506800317f +0 -0
  73. data/test/dummy/tmp/cache/assets/CE7/DB0/sprockets%2F0e836a17637addb8971526971aee72b4 +0 -0
  74. data/test/dummy/tmp/cache/assets/CEE/990/sprockets%2F47575f33258ea5724ebc66559c4cce53 +0 -0
  75. data/test/dummy/tmp/cache/assets/CEF/DC0/sprockets%2F259864f99aed9436e151922a65ea34af +0 -0
  76. data/test/dummy/tmp/cache/assets/D06/E20/sprockets%2F8d56c3f6d80078f3c2020d62131eacc9 +0 -0
  77. data/test/dummy/tmp/cache/assets/D0E/500/sprockets%2F6fc616b77265fda3c2f90e5112bc4655 +0 -0
  78. data/test/dummy/tmp/cache/assets/D21/4D0/sprockets%2Fafc3514c81488866cfd67424f8c8a3a8 +0 -0
  79. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  80. data/test/dummy/tmp/cache/assets/D38/920/sprockets%2F24e11a38c9ffef5ca6308319f33a0f06 +0 -0
  81. data/test/dummy/tmp/cache/assets/D3D/0F0/sprockets%2F1d94971d5b584c4a7bc24aa46ce6036e +0 -0
  82. data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +0 -0
  83. data/test/dummy/tmp/cache/assets/D66/920/sprockets%2Fe4462e36bcc1d2f6727ac95d43a9d00a +0 -0
  84. data/test/dummy/tmp/cache/assets/D70/A40/sprockets%2F0ad63f1fbc19e630783e00f8485f2dfd +0 -0
  85. data/test/dummy/tmp/cache/assets/D70/B40/sprockets%2F7d4145d3d240513f476bd9bfeafd80d7 +0 -0
  86. data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +0 -0
  87. data/test/dummy/tmp/cache/assets/DAA/6E0/sprockets%2Ffdc85097d4de3566cb0f9b8f424bb8b3 +0 -0
  88. data/test/dummy/tmp/cache/assets/DC9/E40/sprockets%2Fa3ed9b085aa940ee68a2ac75caf6118d +0 -0
  89. data/test/dummy/tmp/cache/assets/E02/EE0/sprockets%2F8f1b0dd1f6529a3de1f74ba78dec72df +0 -0
  90. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  91. data/test/dummy/tmp/cache/assets/E06/D90/sprockets%2F6d5edaba333f84df2d92efd7ce22558d +0 -0
  92. data/test/dummy/tmp/cache/assets/E19/E50/sprockets%2F2d7bd8aaffab07cb41eb27d3ef604a21 +0 -0
  93. data/test/dummy/tmp/pids/server.pid +1 -0
  94. data/test/faucet_test.rb +7 -0
  95. data/test/fixtures/faucet/emails.yml +9 -0
  96. data/test/functional/faucet/emails_controller_test.rb +11 -0
  97. data/test/integration/navigation_test.rb +10 -0
  98. data/test/test_helper.rb +10 -0
  99. data/test/unit/faucet/email_test.rb +9 -0
  100. data/test/unit/helpers/faucet/emails_helper_test.rb +6 -0
  101. metadata +246 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
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
+ = Faucet
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,39 @@
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 = 'Faucet'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+ Bundler::GemHelper.install_tasks
28
+
29
+ require 'rake/testtask'
30
+
31
+ Rake::TestTask.new(:test) do |t|
32
+ t.libs << 'lib'
33
+ t.libs << 'test'
34
+ t.pattern = 'test/**/*_test.rb'
35
+ t.verbose = false
36
+ end
37
+
38
+
39
+ task :default => :test
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,10 @@
1
+ @import "foundation.css";
2
+ @import "reset.css";
3
+ @import "emails.css";
4
+ @import "fonts.css";
5
+
6
+ .content{
7
+ width: 900px;
8
+ margin: auto;
9
+ margin-top: 20px;
10
+ }
@@ -0,0 +1,40 @@
1
+ .column-left{
2
+ width: 200px;
3
+ display: inline-block;
4
+ vertical-align: top;
5
+ text-align: center;
6
+ padding-top: 130px;
7
+ }
8
+
9
+ .column-right{
10
+ width: 400px;
11
+ display: inline-block;
12
+ vertical-align: top;
13
+ }
14
+
15
+ .float-left{
16
+ float: left;
17
+ vertical-align: top;
18
+ text-align: top;
19
+ }
20
+
21
+ .subhead{
22
+ font-size: 14px;
23
+ position: relative;
24
+ bottom: 20px;
25
+ left: 70px;
26
+ }
27
+
28
+ .subhead a{
29
+ text-decoration: none;
30
+ color: #54b0f0;
31
+ }
32
+
33
+ .email-header{
34
+ background-color: #2f2f2f;
35
+ padding: 10px;
36
+ color: #fff;
37
+ border-radius: 5px;
38
+ -moz-border-radius: 5px;
39
+ margin-bottom: 10px;
40
+ }
@@ -0,0 +1,35 @@
1
+ /* ---------------------------- FONTS PAGE ---------------------------- */
2
+ h1{
3
+ font: 90px Helvetica;
4
+ color: #303030;
5
+ font-weight: bold;
6
+ }
7
+
8
+ h2{
9
+ font: 24px Helvetica;
10
+ color: #4b4b4b;
11
+ font-weight: bold;
12
+ }
13
+
14
+ h4{
15
+ font: 18px Helvetica;
16
+ color: #4b4b4b;
17
+ margin-bottom: 20px;
18
+ margin-top: 20px;
19
+ }
20
+
21
+ b{
22
+ font: 18px Helvetica;
23
+ color: #4b4b4b;
24
+ font-weight: bold;
25
+ }
26
+
27
+ body{
28
+ color: #4b4b4b;
29
+ font: 18px Helvetica;
30
+ }
31
+
32
+ p{
33
+ margin-top: 22px;
34
+ margin-bottom: 22px;
35
+ }
@@ -0,0 +1,48 @@
1
+ /* http://meyerweb.com/eric/tools/css/reset/
2
+ v2.0 | 20110126
3
+ License: none (public domain)
4
+ */
5
+
6
+ html, body, div, span, applet, object, iframe,
7
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8
+ a, abbr, acronym, address, big, cite, code,
9
+ del, dfn, em, img, ins, kbd, q, s, samp,
10
+ small, strike, strong, sub, sup, tt, var,
11
+ b, u, i, center,
12
+ dl, dt, dd, ol, ul, li,
13
+ fieldset, form, label, legend,
14
+ table, caption, tbody, tfoot, thead, tr, th, td,
15
+ article, aside, canvas, details, embed,
16
+ figure, figcaption, footer, header, hgroup,
17
+ menu, nav, output, ruby, section, summary,
18
+ time, mark, audio, video {
19
+ margin: 0;
20
+ padding: 0;
21
+ border: 0;
22
+ font-size: 100%;
23
+ font: inherit;
24
+ vertical-align: baseline;
25
+ }
26
+ /* HTML5 display-role reset for older browsers */
27
+ article, aside, details, figcaption, figure,
28
+ footer, header, hgroup, menu, nav, section {
29
+ display: block;
30
+ }
31
+ body {
32
+ line-height: 1;
33
+ }
34
+ ol, ul {
35
+ list-style: none;
36
+ }
37
+ blockquote, q {
38
+ quotes: none;
39
+ }
40
+ blockquote:before, blockquote:after,
41
+ q:before, q:after {
42
+ content: '';
43
+ content: none;
44
+ }
45
+ table {
46
+ border-collapse: collapse;
47
+ border-spacing: 0;
48
+ }
@@ -0,0 +1,4 @@
1
+ module Faucet
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,24 @@
1
+ module Faucet
2
+ class EmailsController < ApplicationController
3
+ def index
4
+ @emails_today = Email.where(:sent => false, :time => Faucet.today)
5
+ @emails_sent_yesterday = Email.where(:sent => true, :time => Faucet.yesterday)
6
+ @sent_emails = Email.where(:sent => true)
7
+ @unsent_emails = Email.where(:sent => false)
8
+ end
9
+
10
+ def drip
11
+ @emails = Email.where(:sent => false, :time => Faucet.today)
12
+ @sent = []
13
+ @emails.each do |email|
14
+ puts "Running: #{email.description}."
15
+ puts eval("::" + email.function)
16
+
17
+ @sent << email
18
+
19
+ email.sent = true
20
+ email.save
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,4 @@
1
+ module Faucet
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Faucet
2
+ module EmailsHelper
3
+ end
4
+ end
@@ -0,0 +1,13 @@
1
+ module Faucet
2
+ class Email < ActiveRecord::Base
3
+ validates_presence_of :email, :function, :time, :description
4
+ end
5
+
6
+ def self.today
7
+ (Time.now.midnight)..Time.now.end_of_day
8
+ end
9
+
10
+ def self.yesterday
11
+ (1.day.ago.midnight)..1.day.ago.end_of_day
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ <ul>
2
+ <% @sent.each do |email| %>
3
+ <li>Sent email to: <%= email.email %></li>
4
+ <%= email.description %>
5
+ <br>
6
+ <% end %>
7
+ </ul>
@@ -0,0 +1,41 @@
1
+
2
+ <div class="column-left">
3
+ <h2><%= @sent_emails.count %></h2>
4
+ emails sent all-time
5
+ <br><br>
6
+ <h2><%= @unsent_emails.count %></h2>
7
+ emails scheduled
8
+ </div>
9
+ <div class="column-right">
10
+
11
+ <%= image_tag "faucet/droplet.png", :class => "float-left"%>
12
+ <div class="header-right">
13
+ <h1>Faucet</h1>
14
+ <span class="subhead">brought to you by <%= link_to "Airtime for Email", "http://www.airtimehq.com" %></span>
15
+ </div>
16
+
17
+ <div class="emails">
18
+ <div class="email-header">Emails scheduled for today</div>
19
+ <ul>
20
+ <% for email in @emails_today %>
21
+ <li>Description: <%= email.description %></li>
22
+ To: <%= email.email %><br>
23
+ Function: <%= email.function %><br>
24
+ Time: <%= email.time.to_s %><br>
25
+ Sent: <%= email.sent.to_s %><br><br>
26
+ <% end %>
27
+ </ul>
28
+
29
+ <div class="email-header">Emails sent yesterday</div>
30
+ <ul>
31
+ <% for email in @emails_sent_yesterday %>
32
+ <li>Description: <%= email.description %></li>
33
+ To: <%= email.email %><br>
34
+ Function: <%= email.function %><br>
35
+ Time: <%= email.time.to_s %><br>
36
+ Sent: <%= email.sent.to_s %><br><br>
37
+ <% end %>
38
+ </ul>
39
+
40
+ </div>
41
+ </div>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Faucet</title>
5
+ <%= stylesheet_link_tag "faucet/application" %>
6
+ <%= javascript_include_tag "faucet/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+ <div class="content">
11
+ <%= yield %>
12
+ </div>
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ Faucet::Engine.routes.draw do
2
+ match 'drip' => "emails#drip"
3
+ root :to => "emails#index"
4
+ end
@@ -0,0 +1,10 @@
1
+ class CreateFaucetEmails < ActiveRecord::Migration
2
+ def change
3
+ create_table :faucet_emails do |t|
4
+ t.datetime :time
5
+ t.string :function
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class AddDescriptionToEmails < ActiveRecord::Migration
2
+ def change
3
+ add_column :faucet_emails, :description, :string
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddEmailToEmails < ActiveRecord::Migration
2
+ def change
3
+ add_column :faucet_emails, :email, :string
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddSentToFaucetEmails < ActiveRecord::Migration
2
+ def change
3
+ add_column :faucet_emails, :sent, :boolean, :default => false
4
+ end
5
+ end
data/lib/faucet.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "faucet/engine"
2
+
3
+ module Faucet
4
+ end
@@ -0,0 +1,5 @@
1
+ module Faucet
2
+ class Engine < Rails::Engine
3
+ isolate_namespace Faucet
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Faucet
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ namespace :faucet do
2
+ desc "Send all Faucet emails that need to be sent"
3
+ task :send => :environment do
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.