mail_view_processor 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +68 -0
- data/Rakefile +10 -0
- data/exe/mail_view_processor +5 -0
- data/lib/mail_view_processor.rb +70 -0
- data/lib/mail_view_processor/version.rb +3 -0
- data/mail_view_processor.gemspec +33 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5a0be1dde1b935354e3a3605f96d0cdd39ff86f0
|
4
|
+
data.tar.gz: 5a202eec219aa03fb8ff315739aafe9505613935
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0ed9b23ae8c43b25ce9a56c6bb8f5e96ee90fe7da14c3b3bc5863a3813413806ce37b3442ebbc9d278a40a7fae354146d60b0994cb70d6d18636bffdc5d3f83c
|
7
|
+
data.tar.gz: 8f0eab13ba101f7d6f7bdf6cc9af2c4eeb108fdf3b951579774b20d90c305e1bd4107840d25a67a6c677bb0a88dbbca53f14701ec94ba9633fd0d5a2d014e636
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 kelly felkins
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# MailViewProcessor
|
2
|
+
|
3
|
+
Mail view files are files that combine html and text views together so that
|
4
|
+
two views can be maintained together.
|
5
|
+
|
6
|
+
Here's a simple partial that's used to generate a list of events, using links
|
7
|
+
in the html version with just text in the text version.
|
8
|
+
|
9
|
+
app/mail_views/mailman/_event.mail_view
|
10
|
+
|
11
|
+
> html.haml
|
12
|
+
%li
|
13
|
+
= link_to("#{event.event_on.to_s(:micro)} #{event.subject}", message_url(event))
|
14
|
+
> text.erb
|
15
|
+
--- * <%= event.event_on.to_s(:micro) %> <%= event.subject %>
|
16
|
+
|
17
|
+
MailViewProcessor is a simple gem that provides a script that spits app/mail_view/*.mail_view files
|
18
|
+
into appropriate app/view files.
|
19
|
+
|
20
|
+
The example above would generate these files:
|
21
|
+
|
22
|
+
app/views/mailman/_event.html.haml
|
23
|
+
|
24
|
+
-# AUTO GENERATED FILE / DO NOT EDIT (instead, edit /app/mail_views/_event.mail_view)
|
25
|
+
%li
|
26
|
+
= link_to("#{event.event_on.to_s(:micro)} #{event.subject}", message_url(event))
|
27
|
+
|
28
|
+
app/views/mailman/_event.text.erb
|
29
|
+
|
30
|
+
<%# AUTO GENERATED FILE / DO NOT EDIT (instead, edit /app/mail_views/_event.mail_view) -%>
|
31
|
+
--- * <%= event.event_on.to_s(:micro) %> <%= event.subject %>
|
32
|
+
|
33
|
+
## Installation
|
34
|
+
|
35
|
+
Add this line to your application's Gemfile:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
gem 'mail_view_processor'
|
39
|
+
```
|
40
|
+
|
41
|
+
And then execute:
|
42
|
+
|
43
|
+
$ bundle
|
44
|
+
|
45
|
+
Or install it yourself as:
|
46
|
+
|
47
|
+
$ gem install mail_view_processor
|
48
|
+
|
49
|
+
## Usage
|
50
|
+
|
51
|
+
$ mail_view_processor
|
52
|
+
|
53
|
+
## Development
|
54
|
+
|
55
|
+
There are no dependencies. Just check out the repo and make your changes.
|
56
|
+
|
57
|
+
I'm embarassed to say, but there are no tests.
|
58
|
+
|
59
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kellyfelkins/mail_view_processor.
|
64
|
+
|
65
|
+
## License
|
66
|
+
|
67
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
68
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require "mail_view_processor/version"
|
2
|
+
|
3
|
+
class MailViewProcessor
|
4
|
+
def run
|
5
|
+
project_full_dir = File.expand_path('.')
|
6
|
+
mail_views_full_dir = File.join(project_full_dir, "/app/mail_views")
|
7
|
+
views_full_dir = File.join(project_full_dir, "/app/views")
|
8
|
+
|
9
|
+
Dir.new(mail_views_full_dir).each do |mailer_dir|
|
10
|
+
next if mailer_dir =~ /^\.\.?$/
|
11
|
+
|
12
|
+
puts "processing #{mailer_dir}"
|
13
|
+
|
14
|
+
mail_view_mailer_full_dir = File.join(mail_views_full_dir, mailer_dir)
|
15
|
+
|
16
|
+
view_mailer_full_dir = File.join(views_full_dir, mailer_dir)
|
17
|
+
|
18
|
+
Dir.new(mail_view_mailer_full_dir).each do |mail_view_file_name|
|
19
|
+
next if mail_view_file_name =~ /^\.\.?$/
|
20
|
+
puts " processing #{mail_view_file_name}"
|
21
|
+
|
22
|
+
mail_view_full_file_name = File.join(mail_view_mailer_full_dir, mail_view_file_name)
|
23
|
+
mail_view_relative_file_name = File.join('/app/mail_views', mail_view_file_name)
|
24
|
+
output_file_data = {}
|
25
|
+
File.open(mail_view_full_file_name, 'r') do |f|
|
26
|
+
output_type = nil
|
27
|
+
f.each_line do |line|
|
28
|
+
puts "processing >#{line[0..30]}<"
|
29
|
+
if line =~ /^> (.*)$/
|
30
|
+
output_type = $1
|
31
|
+
puts "handling #{output_type}"
|
32
|
+
output_file_data[output_type] ||= []
|
33
|
+
next
|
34
|
+
end
|
35
|
+
|
36
|
+
output_file_data[output_type] << (line.length > 1 ? line[2..-1] : line)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
base_view_file_name = mail_view_file_name[/^(.*)\.mail_view$/, 1]
|
41
|
+
output_file_data.each do |output_type, lines|
|
42
|
+
|
43
|
+
output_file_name = base_view_file_name + "." + output_type
|
44
|
+
view_full_file = File.join(view_mailer_full_dir, output_file_name)
|
45
|
+
puts "********* writing #{view_full_file}"
|
46
|
+
FileUtils.mkdir_p(view_mailer_full_dir)
|
47
|
+
FileUtils.rm_rf(view_full_file)
|
48
|
+
File.open(view_full_file, "w") do |f|
|
49
|
+
comment_for_type = comment_for(output_type, "AUTO GENERATED FILE / DO NOT EDIT (instead, edit #{mail_view_relative_file_name})")
|
50
|
+
f << comment_for_type + "\n" if comment_for_type
|
51
|
+
f << lines.join
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def comment_for(output_type, text)
|
59
|
+
case output_type
|
60
|
+
when %r|\.haml$|
|
61
|
+
"-# #{text}"
|
62
|
+
when %r|\.erb$|
|
63
|
+
"<%# #{text} -%>"
|
64
|
+
when %r|^text$|
|
65
|
+
nil
|
66
|
+
else
|
67
|
+
raise "unexpected output_type >#{output_type}<"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mail_view_processor/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mail_view_processor"
|
8
|
+
spec.version = MailViewProcessor::VERSION
|
9
|
+
spec.authors = ["kelly felkins"]
|
10
|
+
spec.email = ["kelly@restlater.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Keep your mail text and html views together in .mail_view files}
|
13
|
+
spec.description = %q{A simple script that generates html and text views from .mail_view files.}
|
14
|
+
spec.homepage = "https://github.com/kellyfelkins/mail_view_processor"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
# spec.add_development_dependency "minitest", "~> 5.0"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mail_view_processor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kelly felkins
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: A simple script that generates html and text views from .mail_view files.
|
42
|
+
email:
|
43
|
+
- kelly@restlater.com
|
44
|
+
executables:
|
45
|
+
- mail_view_processor
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- exe/mail_view_processor
|
55
|
+
- lib/mail_view_processor.rb
|
56
|
+
- lib/mail_view_processor/version.rb
|
57
|
+
- mail_view_processor.gemspec
|
58
|
+
homepage: https://github.com/kellyfelkins/mail_view_processor
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.4.8
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Keep your mail text and html views together in .mail_view files
|
82
|
+
test_files: []
|