mailmatic 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'haml'
4
+ gem 'sass'
5
+ gem 'staticmatic'
6
+ gem 'premailer'
7
+ gem 'nokogiri'
8
+
9
+ group :development, :test do
10
+ gem 'rake', '0.8.7'
11
+ gem 'rspec', '~> 2.3.0'
12
+ gem 'bundler', '~> 1.0.0'
13
+ gem 'jeweler', '~> 1.6.4'
14
+ gem 'rcov', '>= 0'
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,53 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ chunky_png (1.2.1)
5
+ compass (0.11.5)
6
+ chunky_png (~> 1.2)
7
+ fssm (>= 0.2.7)
8
+ sass (~> 3.1)
9
+ css_parser (1.1.9)
10
+ diff-lcs (1.1.2)
11
+ fssm (0.2.7)
12
+ git (1.2.5)
13
+ haml (3.1.2)
14
+ htmlentities (4.3.0)
15
+ jeweler (1.6.4)
16
+ bundler (~> 1.0)
17
+ git (>= 1.2.5)
18
+ rake
19
+ nokogiri (1.5.0)
20
+ premailer (1.7.1)
21
+ css_parser (>= 1.1.9)
22
+ htmlentities (>= 4.0.0)
23
+ rack (1.3.2)
24
+ rake (0.8.7)
25
+ rcov (0.9.10)
26
+ rspec (2.3.0)
27
+ rspec-core (~> 2.3.0)
28
+ rspec-expectations (~> 2.3.0)
29
+ rspec-mocks (~> 2.3.0)
30
+ rspec-core (2.3.1)
31
+ rspec-expectations (2.3.0)
32
+ diff-lcs (~> 1.1.2)
33
+ rspec-mocks (2.3.0)
34
+ sass (3.1.7)
35
+ staticmatic (0.11.1)
36
+ compass (>= 0.10.0)
37
+ haml (>= 2.0.0)
38
+ rack (>= 1.0)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ bundler (~> 1.0.0)
45
+ haml
46
+ jeweler (~> 1.6.4)
47
+ nokogiri
48
+ premailer
49
+ rake (= 0.8.7)
50
+ rcov
51
+ rspec (~> 2.3.0)
52
+ sass
53
+ staticmatic
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Scott W. Bradley
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,19 @@
1
+ = MailMatic
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to MailMatic
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Scott W. Bradley. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "mailmatic"
18
+ gem.homepage = "http://github.com/scottwb/mailmatic"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{StaticMatic + Premailer: Generate HTML emails with inlined styles from Haml and Sass.}
21
+ gem.description = %Q{StaticMatic + Premailer: Generate HTML emails with inlined styles from Haml and Sass.}
22
+ gem.email = "scottwb@gmail.com"
23
+ gem.authors = ["Scott W. Bradley"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "MailMatic #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/mailmatic ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require 'mailmatic'
4
+ exit MailMatic::Application.run!(*ARGV)
data/lib/mailmatic.rb ADDED
@@ -0,0 +1,118 @@
1
+ require 'rubygems'
2
+ require 'premailer'
3
+
4
+ module MailMatic
5
+ class Generator
6
+ STATICMATIC_SETUP_COMMAND = "staticmatic setup \"%s\""
7
+ STATICMATIC_BUILD_COMMAND = "staticmatic build \"%s\""
8
+ STATICMATIC_OUTPUT_SUBDIR = "site"
9
+ EMAILS_SUBDIR = "emails"
10
+ DEFAULT_LAYOUT_SUBPATH = "src/layouts/default.haml"
11
+ DEFAULT_PAGE_SUBPATH = "src/pages/index.haml"
12
+ PREMAILER_WARN_LEVEL = Premailer::Warnings::SAFE
13
+
14
+ attr_accessor :root_dir
15
+ def initialize(root_dir)
16
+ @root_dir = root_dir
17
+ end
18
+
19
+ def generate_email(infile, outfile)
20
+ outdir = File.dirname(outfile)
21
+ Dir.mkdir(outdir) if !File.directory?(outdir)
22
+
23
+ premailer = Premailer.new(
24
+ infile,
25
+ :warn_level => PREMAILER_WARN_LEVEL
26
+ )
27
+
28
+ File.open(outfile, "wb") do |f|
29
+ f << premailer.to_inline_css
30
+ end
31
+ puts "created #{outfile}"
32
+ return 0
33
+ rescue Exception => e
34
+ puts "failed to create #{outfile}"
35
+ puts e.inspect
36
+ return -1
37
+ end
38
+
39
+ def generate_emails
40
+ html_dir = File.expand_path(STATICMATIC_OUTPUT_SUBDIR, root_dir)
41
+ emails_dir = File.expand_path(EMAILS_SUBDIR, root_dir)
42
+ Dir.mkdir(emails_dir) if !File.directory?(emails_dir)
43
+ Dir.chdir(html_dir) do
44
+ Dir.glob("**/*.html").each do |html_file|
45
+ email_file = File.expand_path(html_file, "../#{EMAILS_SUBDIR}")
46
+ status = generate_email(html_file, email_file)
47
+ return status if status != 0
48
+ end
49
+ end
50
+ return 0
51
+ end
52
+
53
+ def generate_pages
54
+ result = system(STATICMATIC_BUILD_COMMAND % root_dir)
55
+ return result ? 0 : -1
56
+ end
57
+
58
+ def setup
59
+ # Run StaticMatic setup then hack a few files with sed
60
+ result = system(STATICMATIC_SETUP_COMMAND % root_dir)
61
+ return -1 unless result
62
+
63
+ i_opt = "-i"
64
+ if `uname` =~ /darwin/i
65
+ i_opt = '-i ""'
66
+ end
67
+
68
+ result = system("sed #{i_opt} -e \"s/StaticMatic/MailMatic/g\" \"#{root_dir}/#{DEFAULT_LAYOUT_SUBPATH}\"")
69
+ return -1 unless result
70
+
71
+ result = system("sed #{i_opt} -e \"s/= stylesheets/%link\\{:rel => 'stylesheet', :href => 'stylesheets\\/screen.css'\\}/g\" \"#{root_dir}/#{DEFAULT_LAYOUT_SUBPATH}\"")
72
+ return -1 unless result
73
+
74
+ result = system("sed #{i_opt} -e \"s/StaticMatic/MailMatic/g\" \"#{root_dir}/#{DEFAULT_PAGE_SUBPATH}\"")
75
+ return -1 unless result
76
+
77
+ return 0
78
+ end
79
+
80
+ def build
81
+ puts "Building #{root_dir}"
82
+
83
+ status = generate_pages
84
+ return status if status != 0
85
+
86
+ status = generate_emails
87
+
88
+ return status
89
+ end
90
+ end
91
+
92
+ class Application
93
+ def self.run!(*args)
94
+ command = args.shift
95
+ args.push(Dir.pwd) if args.empty?
96
+
97
+ case command
98
+ when 'setup'
99
+ args.each do |arg|
100
+ status = MailMatic::Generator.new(arg).setup
101
+ return status if status != 0
102
+ end
103
+ return 0
104
+
105
+ when 'build'
106
+ args.each do |arg|
107
+ status = MailMatic::Generator.new(arg).build
108
+ return status if status != 0
109
+ end
110
+ return 0
111
+
112
+ else
113
+ puts "ERROR: Invalid command"
114
+ return -1
115
+ end
116
+ end
117
+ end
118
+ end
data/mailmatic.gemspec ADDED
@@ -0,0 +1,81 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{mailmatic}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Scott W. Bradley"]
12
+ s.date = %q{2011-08-15}
13
+ s.default_executable = %q{mailmatic}
14
+ s.description = %q{StaticMatic + Premailer: Generate HTML emails with inlined styles from Haml and Sass.}
15
+ s.email = %q{scottwb@gmail.com}
16
+ s.executables = ["mailmatic"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "bin/mailmatic",
31
+ "lib/mailmatic.rb",
32
+ "mailmatic.gemspec",
33
+ "spec/mailmatic_spec.rb",
34
+ "spec/spec_helper.rb"
35
+ ]
36
+ s.homepage = %q{http://github.com/scottwb/mailmatic}
37
+ s.licenses = ["MIT"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = %q{1.6.2}
40
+ s.summary = %q{StaticMatic + Premailer: Generate HTML emails with inlined styles from Haml and Sass.}
41
+
42
+ if s.respond_to? :specification_version then
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<haml>, [">= 0"])
47
+ s.add_runtime_dependency(%q<sass>, [">= 0"])
48
+ s.add_runtime_dependency(%q<staticmatic>, [">= 0"])
49
+ s.add_runtime_dependency(%q<premailer>, [">= 0"])
50
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
51
+ s.add_development_dependency(%q<rake>, ["= 0.8.7"])
52
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
53
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
54
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
55
+ s.add_development_dependency(%q<rcov>, [">= 0"])
56
+ else
57
+ s.add_dependency(%q<haml>, [">= 0"])
58
+ s.add_dependency(%q<sass>, [">= 0"])
59
+ s.add_dependency(%q<staticmatic>, [">= 0"])
60
+ s.add_dependency(%q<premailer>, [">= 0"])
61
+ s.add_dependency(%q<nokogiri>, [">= 0"])
62
+ s.add_dependency(%q<rake>, ["= 0.8.7"])
63
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
64
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
66
+ s.add_dependency(%q<rcov>, [">= 0"])
67
+ end
68
+ else
69
+ s.add_dependency(%q<haml>, [">= 0"])
70
+ s.add_dependency(%q<sass>, [">= 0"])
71
+ s.add_dependency(%q<staticmatic>, [">= 0"])
72
+ s.add_dependency(%q<premailer>, [">= 0"])
73
+ s.add_dependency(%q<nokogiri>, [">= 0"])
74
+ s.add_dependency(%q<rake>, ["= 0.8.7"])
75
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
76
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
77
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
78
+ s.add_dependency(%q<rcov>, [">= 0"])
79
+ end
80
+ end
81
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "MailMatic" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'mailmatic'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,227 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mailmatic
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Scott W. Bradley
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-15 00:00:00 -07:00
19
+ default_executable: mailmatic
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :runtime
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ name: haml
33
+ version_requirements: *id001
34
+ prerelease: false
35
+ - !ruby/object:Gem::Dependency
36
+ type: :runtime
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ name: sass
47
+ version_requirements: *id002
48
+ prerelease: false
49
+ - !ruby/object:Gem::Dependency
50
+ type: :runtime
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ name: staticmatic
61
+ version_requirements: *id003
62
+ prerelease: false
63
+ - !ruby/object:Gem::Dependency
64
+ type: :runtime
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ name: premailer
75
+ version_requirements: *id004
76
+ prerelease: false
77
+ - !ruby/object:Gem::Dependency
78
+ type: :runtime
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ name: nokogiri
89
+ version_requirements: *id005
90
+ prerelease: false
91
+ - !ruby/object:Gem::Dependency
92
+ type: :development
93
+ requirement: &id006 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - "="
97
+ - !ruby/object:Gem::Version
98
+ hash: 49
99
+ segments:
100
+ - 0
101
+ - 8
102
+ - 7
103
+ version: 0.8.7
104
+ name: rake
105
+ version_requirements: *id006
106
+ prerelease: false
107
+ - !ruby/object:Gem::Dependency
108
+ type: :development
109
+ requirement: &id007 !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ~>
113
+ - !ruby/object:Gem::Version
114
+ hash: 3
115
+ segments:
116
+ - 2
117
+ - 3
118
+ - 0
119
+ version: 2.3.0
120
+ name: rspec
121
+ version_requirements: *id007
122
+ prerelease: false
123
+ - !ruby/object:Gem::Dependency
124
+ type: :development
125
+ requirement: &id008 !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ~>
129
+ - !ruby/object:Gem::Version
130
+ hash: 23
131
+ segments:
132
+ - 1
133
+ - 0
134
+ - 0
135
+ version: 1.0.0
136
+ name: bundler
137
+ version_requirements: *id008
138
+ prerelease: false
139
+ - !ruby/object:Gem::Dependency
140
+ type: :development
141
+ requirement: &id009 !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ~>
145
+ - !ruby/object:Gem::Version
146
+ hash: 7
147
+ segments:
148
+ - 1
149
+ - 6
150
+ - 4
151
+ version: 1.6.4
152
+ name: jeweler
153
+ version_requirements: *id009
154
+ prerelease: false
155
+ - !ruby/object:Gem::Dependency
156
+ type: :development
157
+ requirement: &id010 !ruby/object:Gem::Requirement
158
+ none: false
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ hash: 3
163
+ segments:
164
+ - 0
165
+ version: "0"
166
+ name: rcov
167
+ version_requirements: *id010
168
+ prerelease: false
169
+ description: "StaticMatic + Premailer: Generate HTML emails with inlined styles from Haml and Sass."
170
+ email: scottwb@gmail.com
171
+ executables:
172
+ - mailmatic
173
+ extensions: []
174
+
175
+ extra_rdoc_files:
176
+ - LICENSE.txt
177
+ - README.rdoc
178
+ files:
179
+ - .document
180
+ - .rspec
181
+ - Gemfile
182
+ - Gemfile.lock
183
+ - LICENSE.txt
184
+ - README.rdoc
185
+ - Rakefile
186
+ - VERSION
187
+ - bin/mailmatic
188
+ - lib/mailmatic.rb
189
+ - mailmatic.gemspec
190
+ - spec/mailmatic_spec.rb
191
+ - spec/spec_helper.rb
192
+ has_rdoc: true
193
+ homepage: http://github.com/scottwb/mailmatic
194
+ licenses:
195
+ - MIT
196
+ post_install_message:
197
+ rdoc_options: []
198
+
199
+ require_paths:
200
+ - lib
201
+ required_ruby_version: !ruby/object:Gem::Requirement
202
+ none: false
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ hash: 3
207
+ segments:
208
+ - 0
209
+ version: "0"
210
+ required_rubygems_version: !ruby/object:Gem::Requirement
211
+ none: false
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ hash: 3
216
+ segments:
217
+ - 0
218
+ version: "0"
219
+ requirements: []
220
+
221
+ rubyforge_project:
222
+ rubygems_version: 1.6.2
223
+ signing_key:
224
+ specification_version: 3
225
+ summary: "StaticMatic + Premailer: Generate HTML emails with inlined styles from Haml and Sass."
226
+ test_files: []
227
+