mail_nerd 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3bb515cdbd3e27454a7aca0bfbd5685761e2f61d
4
- data.tar.gz: c4b418217fbe64ea83de8792632e5e54b1ca31da
5
- SHA512:
6
- metadata.gz: 23181386eac1ea38b2582234ae09654dc0efd68000d41cf0d46d140763a725cdd9fbffafe6aa1d2310b1f9bfa2e45d68f0d60eeaeb4a668249d741f4ba58cf83
7
- data.tar.gz: 8a7e2592ef08441c10a7875ab0027e265179dbcd7f4156d699147c54ae9b5ae7f686190e53f7f2d1974a87e698b4e9e437ba4df90b9c12a28891dbc9fd64d599
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDhhNDUxMWYxYzkwZDc4OGYwZDhhMWE0MGZhNjgwMmRlOWVhYTQ0Yg==
5
+ data.tar.gz: !binary |-
6
+ NjU3OGJmMWY5YmZiMzcxZWUwZTg1Mzg4ZjIyMzYxNjZjZjMwZjU1ZQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OThhODNjMjY5N2MyNDY2NGZlNDdjMjIwMjE0NjM4ZDAxNjYzZTk5ODA1NmE5
10
+ ZWUyY2RiN2I2ODc3ZjMwYmRjYzhhNGUzMjI5YzE4OGM4MWIyNDRlNzg2MTQ0
11
+ ODk1ZTA4ZmE5OTE2ODM1YTM5ZGVjOWNlZDkxMTFlZWZmMGVkYjY=
12
+ data.tar.gz: !binary |-
13
+ NjYyNTgxNGY2NTczYjI0M2I2NTQ2YjBkOGE2YzAzNDNkMDIyMTZmOTcyODY1
14
+ YmEyMjAwZDFmMTZmZWEzNGNkMTMwNGU2OTBkMzU5NzgwOGVhODI3MmQwZDRi
15
+ YTYxZjM3NjhhMGZmYzBkMDA5ZWQ3NDc1MTUwNmJmYTFjYWE5ZmQ=
data/Rakefile CHANGED
@@ -1,7 +1,18 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
1
+ ENV['RAILS_ROOT'] ||= 'spec/dummy'
2
+ require File.expand_path('spec/dummy/config/application')
3
+
4
+ Dir.glob("lib/tasks/**.rake").each do |path| load(path) end
6
5
 
7
6
  Bundler::GemHelper.install_tasks
7
+
8
+ require 'rake/testtask'
9
+
10
+ Rake::TestTask.new(:test) do |t|
11
+ t.libs << 'lib'
12
+ t.libs << 'test'
13
+ t.pattern = 'test/**/*_test.rb'
14
+ t.verbose = false
15
+ end
16
+
17
+
18
+ task default: [:test,:cucumber]
@@ -0,0 +1,8 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> --tags ~@naughty features
7
+ wip: --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -0,0 +1,16 @@
1
+ require 'mandrill_mailer'
2
+
3
+ begin
4
+ raw_config = File.read("#{Rails.root}/config/mail_nerd_config.yml")
5
+ MAIL_NERD_CONFIG = YAML.load(raw_config)[Rails.env].symbolize_keys
6
+ rescue => e
7
+ warn "You haven't configured mail_nerd for #{Rails.env}"
8
+ end
9
+
10
+ MandrillMailer.configure do |config|
11
+ begin
12
+ config.api_key = ENV['MANDRILL_APIKEY'] ||= MAIL_NERD_CONFIG[:password]
13
+ rescue => e
14
+ warn "You haven't configured mail_nerd for #{Rails.env} or through ENV"
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate mailer Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,76 @@
1
+ require 'nokogiri'
2
+ require 'mandrill'
3
+
4
+ class MailNerd::MailerGenerator < Rails::Generators::NamedBase
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ argument :name, type: :string, banner: 'class name'
8
+ argument :template_name, type: :string, banner: 'template name'
9
+
10
+ def create_mailer
11
+ template "mailer_class.rb", "app/mailers/#{mailer_file_name}.rb"
12
+ end
13
+
14
+ private
15
+ def api_key
16
+ @api_key ||= ENV['MANDRILL_APIKEY'] ||= (
17
+ begin
18
+ MAIL_NERD_CONFIG[:password]
19
+ rescue NameError => e
20
+ nil
21
+ end )
22
+ end
23
+
24
+ def mandrill
25
+ @mandril ||= Mandrill::API.new(api_key)
26
+ end
27
+
28
+ def mandrill_template
29
+ @template_response ||= mandrill.templates.info(template_slug)
30
+ end
31
+
32
+ def mailer_file_name
33
+ name.underscore
34
+ end
35
+
36
+ def mailer_class_name
37
+ name.camelize
38
+ end
39
+
40
+ def template_method_name
41
+ template_name.underscore.gsub(' ','_')
42
+ end
43
+
44
+ def template_slug
45
+ template_name.gsub(' ','-')
46
+ end
47
+
48
+ def translation_key(leaf="subject")
49
+ [mailer_class_name.underscore,template_method_name,leaf].join('.')
50
+ end
51
+
52
+ def default_from
53
+ mandrill_template["from_email"]
54
+ end
55
+
56
+ def default_name
57
+ mandrill_template["from_name"]
58
+ end
59
+
60
+ def default_subject
61
+ mandrill_template["subject"]
62
+ end
63
+
64
+ def code
65
+ @parsed ||= Nokogiri.parse(mandrill_template["code"])
66
+ end
67
+
68
+ def vars
69
+ code.xpath("//*[@*]").map do |e|
70
+ name = e.attributes["mc:edit"].value
71
+ default = e.text
72
+
73
+ OpenStruct.new(argument: name,symbol: name.to_sym,default: default,option_key: name.to_sym.inspect)
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,21 @@
1
+ class <%= mailer_class_name %> < MandrillMailer::TemplateMailer
2
+ default from: <%= default_from.inspect %>,
3
+ from_name: <%= default_name.inspect %>
4
+
5
+ def <%= template_method_name %>(<%= vars.map{|v| "#{v.argument}=#{v.default.inspect}"}.join(', ') %>, recipients=[{email: "guest@honor.com", name: 'Honored Guest'}])
6
+ mandrill_mail template: <%= template_name.inspect %>,
7
+ subject: I18n.t(<%= translation_key('subject').inspect %>, default: <%= default_subject.inspect %>),
8
+ to: recipients,
9
+ vars: {
10
+ <% vars.each do |var| -%>
11
+ <%= var.symbol %>: <%= var.argument %>
12
+ <% end -%>
13
+ },
14
+ important: true,
15
+ inline_css: true
16
+ end
17
+
18
+ test_setup_for <%= template_method_name.to_sym.inspect %> do |mailer, options|
19
+ mailer.<%= template_method_name %>(*options.values_at(<%= vars.map(&:option_key).join(', ') %>), [options.select{|k| [:name,:email].include?(k)}]).deliver
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module MailNerd
2
- VERSION = "0.0.0"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,63 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+
8
+ unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
9
+
10
+ vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
11
+ $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
12
+
13
+ begin
14
+ require 'cucumber/rake/task'
15
+
16
+ namespace :cucumber do
17
+ Cucumber::Rake::Task.new({:ok => 'test:prepare'}, 'Run features that should pass') do |t|
18
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
19
+ t.fork = true # You may get faster startup if you set this to false
20
+ t.profile = 'default'
21
+ end
22
+
23
+ Cucumber::Rake::Task.new({:wip => 'test:prepare'}, 'Run features that are being worked on') do |t|
24
+ t.binary = vendored_cucumber_bin
25
+ t.fork = true # You may get faster startup if you set this to false
26
+ t.profile = 'wip'
27
+ end
28
+
29
+ Cucumber::Rake::Task.new({:rerun => 'test:prepare'}, 'Record failing features and run only them if any exist') do |t|
30
+ t.binary = vendored_cucumber_bin
31
+ t.fork = true # You may get faster startup if you set this to false
32
+ t.profile = 'rerun'
33
+ end
34
+
35
+ desc 'Run all features'
36
+ task :all => [:ok, :wip]
37
+
38
+ task :statsetup do
39
+ require 'rails/code_statistics'
40
+ ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
41
+ ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
42
+ end
43
+ end
44
+ desc 'Alias for cucumber:ok'
45
+ task :cucumber => 'cucumber:ok'
46
+
47
+ task :features => :cucumber do
48
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
49
+ end
50
+
51
+ # In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon.
52
+ task 'test:prepare' do
53
+ end
54
+
55
+ task :stats => 'cucumber:statsetup'
56
+ rescue LoadError
57
+ desc 'cucumber rake task not available (cucumber not installed)'
58
+ task :cucumber do
59
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
60
+ end
61
+ end
62
+
63
+ end
@@ -1,4 +1,20 @@
1
- # desc "Explaining what the task does"
2
- # task :mail_nerd do
3
- # # Task goes here
4
- # end
1
+ require 'highline/import'
2
+ require 'yaml'
3
+
4
+ namespace :mail_nerd do
5
+
6
+ task :config, %w(host port username password) do |t, args|
7
+ configuration = args.to_hash.stringify_keys
8
+ configuration['host'] ||= ask("What's the host of the service?").to_s
9
+ configuration['port'] ||= ask("What's the port of the service?").to_i
10
+ configuration['username'] ||= ask("What's your username for the service?").to_s
11
+ configuration['password'] ||= ask("What's your password for the service?").to_s
12
+
13
+ say "Thanks!"
14
+
15
+ FileUtils.mkdir_p('config')
16
+ File.open('config/mail_nerd_config.yml','w') do |file|
17
+ file.write(YAML::dump({'development' => configuration}))
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail_nerd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Buxton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-03 00:00:00.000000000 Z
11
+ date: 2013-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: highline
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rails
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +38,20 @@ dependencies:
24
38
  - - ~>
25
39
  - !ruby/object:Gem::Version
26
40
  version: 4.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: mandrill_mailer
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +66,62 @@ dependencies:
38
66
  - - ~>
39
67
  - !ruby/object:Gem::Version
40
68
  version: '0.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: aruba
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: cucumber-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '1.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '1.4'
97
+ - !ruby/object:Gem::Dependency
98
+ name: nifty-generators
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '0.4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '0.4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '2.14'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '2.14'
41
125
  description: So you don't have to.
42
126
  email:
43
127
  - me@cpb.ca
@@ -45,14 +129,15 @@ executables: []
45
129
  extensions: []
46
130
  extra_rdoc_files: []
47
131
  files:
48
- - app/assets/stylesheets/mail_nerd/application.css
49
- - app/controllers/mail_nerd/application_controller.rb
50
- - app/helpers/mail_nerd/application_helper.rb
51
- - app/views/layouts/mail_nerd/application.html.erb
52
- - config/routes.rb
132
+ - config/cucumber.yml
133
+ - config/initializers/load_mail_nerd_config.rb
134
+ - lib/generators/mail_nerd/mailer/mailer_generator.rb
135
+ - lib/generators/mail_nerd/mailer/templates/mailer_class.rb
136
+ - lib/generators/mail_nerd/mailer/USAGE
53
137
  - lib/mail_nerd/engine.rb
54
138
  - lib/mail_nerd/version.rb
55
139
  - lib/mail_nerd.rb
140
+ - lib/tasks/cucumber.rake
56
141
  - lib/tasks/mail_nerd_tasks.rake
57
142
  - MIT-LICENSE
58
143
  - Rakefile
@@ -65,17 +150,17 @@ require_paths:
65
150
  - lib
66
151
  required_ruby_version: !ruby/object:Gem::Requirement
67
152
  requirements:
68
- - - '>='
153
+ - - ! '>='
69
154
  - !ruby/object:Gem::Version
70
155
  version: '0'
71
156
  required_rubygems_version: !ruby/object:Gem::Requirement
72
157
  requirements:
73
- - - '>='
158
+ - - ! '>='
74
159
  - !ruby/object:Gem::Version
75
160
  version: '0'
76
161
  requirements: []
77
162
  rubyforge_project:
78
- rubygems_version: 2.0.3
163
+ rubygems_version: 2.0.4
79
164
  signing_key:
80
165
  specification_version: 4
81
166
  summary: Take care of the custom email release and delivery cycle.
@@ -1,13 +0,0 @@
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
- */
@@ -1,4 +0,0 @@
1
- module MailNerd
2
- class ApplicationController < ActionController::Base
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module MailNerd
2
- module ApplicationHelper
3
- end
4
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>MailNerd</title>
5
- <%= stylesheet_link_tag "mail_nerd/application", media: "all" %>
6
- <%= javascript_include_tag "mail_nerd/application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
@@ -1,2 +0,0 @@
1
- MailNerd::Engine.routes.draw do
2
- end