nisetegami 0.5.0 → 0.5.1
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.
- data/README.md +1 -1
- data/app/assets/stylesheets/nisetegami/templates.css.scss +4 -0
- data/app/controllers/nisetegami/templates_controller.rb +0 -1
- data/app/models/nisetegami/template.rb +5 -5
- data/app/views/nisetegami/templates/_field.html.erb +3 -0
- data/lib/generators/initializers/nisetegami.rb +14 -0
- data/lib/generators/{nisetegami/templates/migrations → migrations}/001_create_nisetegami_templates.rb +1 -1
- data/lib/generators/{nisetegami/templates_generator.rb → nisetegami_generator.rb} +6 -2
- data/lib/nisetegami.rb +10 -2
- data/lib/nisetegami/version.rb +1 -1
- data/lib/tasks/nisetegami_tasks.rake +1 -1
- metadata +5 -4
data/README.md
CHANGED
@@ -24,11 +24,11 @@ class Nisetegami::Template < ActiveRecord::Base
|
|
24
24
|
|
25
25
|
address_re = "(?:[^<@]+\\s+<#{Nisetegami.email_re}>|#{Nisetegami.email_re})"
|
26
26
|
addresses_re = /^#{address_re}(?:\s*,\s*#{address_re})*$/i
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
validate
|
31
|
-
validate
|
27
|
+
validates :from, :reply_to, :cc, :bcc, format: {with: addresses_re}, allow_blank: true
|
28
|
+
validates :name, :subject, :body_text, presence: true
|
29
|
+
validates :body_html, presence: true, unless: :only_text?
|
30
|
+
validate :check_template_syntax
|
31
|
+
validate :check_mailer
|
32
32
|
|
33
33
|
## callbacks
|
34
34
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
<div class="control-group">
|
2
2
|
<%= f.label attr, class: 'control-label' %>
|
3
3
|
<div class="controls">
|
4
|
+
<% if f.object.errors[attr] %>
|
5
|
+
<span class="red"><%= f.object.errors[attr].join(', ') %></span>
|
6
|
+
<% end %>
|
4
7
|
<%= (input = yield).present? ? input : f.text_field(attr) %>
|
5
8
|
</div>
|
6
9
|
</div>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Nisetegami.configure do |config|
|
2
|
+
# Cast variables types
|
3
|
+
# config.cast do |klass|
|
4
|
+
# begin
|
5
|
+
# "#{klass}Decorator".constantize
|
6
|
+
# rescue
|
7
|
+
# klass.constantize
|
8
|
+
# end
|
9
|
+
# end
|
10
|
+
|
11
|
+
# Mailers mapping
|
12
|
+
# config.register 'UserMailer', :signup, user, temporary_password, created_at: 'DateTime'
|
13
|
+
# config.register 'UserMailer', :notice, user, notice, additional_attributes: 'Hash'
|
14
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'rails/generators'
|
2
2
|
require 'rails/generators/migration'
|
3
3
|
|
4
|
-
class
|
4
|
+
class NisetegamiGenerator < Rails::Generators::Base
|
5
5
|
include Rails::Generators::Migration
|
6
6
|
|
7
|
-
source_root File.
|
7
|
+
source_root File.dirname(__FILE__)
|
8
8
|
|
9
9
|
def self.next_migration_number(dirname)
|
10
10
|
if ActiveRecord::Base.timestamped_migrations
|
@@ -14,6 +14,10 @@ class Nisetegami::TemplatesGenerator < Rails::Generators::Base
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
def create_config_file
|
18
|
+
template 'initializers/nisetegami.rb', 'config/initializers/nisetegami.rb'
|
19
|
+
end
|
20
|
+
|
17
21
|
def create_migrations
|
18
22
|
Dir[File.join(self.class.source_root, 'migrations/*.rb')].sort.each do |template|
|
19
23
|
basename = File.basename(template).gsub(/^\d+_/, '')
|
data/lib/nisetegami.rb
CHANGED
@@ -19,7 +19,7 @@ module Nisetegami
|
|
19
19
|
mattr_reader :mapping
|
20
20
|
@@mapping = Nisetegami::Mapping.new
|
21
21
|
|
22
|
-
|
22
|
+
mattr_reader :email_re
|
23
23
|
@@email_re = /[-a-z0-9_+\.]+@([-a-z0-9]+\.)+[a-z0-9]{2,}/
|
24
24
|
|
25
25
|
def self.configure
|
@@ -29,7 +29,15 @@ module Nisetegami
|
|
29
29
|
# optional block to cast a thing (String, Symbol)
|
30
30
|
# into a class with liquid_methods
|
31
31
|
def self.cast(&block)
|
32
|
-
@@cast ||= ->(thing)
|
32
|
+
@@cast ||= ->(thing) do
|
33
|
+
if defined?(thing) == 'constant'
|
34
|
+
thing
|
35
|
+
elsif const_defined?(thing.to_s)
|
36
|
+
thing.to_s.constantize
|
37
|
+
else
|
38
|
+
String
|
39
|
+
end
|
40
|
+
end
|
33
41
|
block_given? ? @@cast = block : @@cast
|
34
42
|
end
|
35
43
|
|
data/lib/nisetegami/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nisetegami
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-11-
|
13
|
+
date: 2012-11-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -169,8 +169,9 @@ files:
|
|
169
169
|
- config/locales/nisetegami.en.yml
|
170
170
|
- config/locales/nisetegami.ru.yml
|
171
171
|
- config/routes.rb
|
172
|
-
- lib/generators/nisetegami
|
173
|
-
- lib/generators/
|
172
|
+
- lib/generators/initializers/nisetegami.rb
|
173
|
+
- lib/generators/migrations/001_create_nisetegami_templates.rb
|
174
|
+
- lib/generators/nisetegami_generator.rb
|
174
175
|
- lib/nisetegami/action_mailer_extensions.rb
|
175
176
|
- lib/nisetegami/ar_template_resolver.rb
|
176
177
|
- lib/nisetegami/asset_provider.rb
|