jreport 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db1cd2a36206b50c30fb79c039b47e816a13cc65
4
- data.tar.gz: a257095bc4af0811eadf2af61a022100012cf91c
3
+ metadata.gz: 4477c77b82b085035148ada4786c0940e0f3dd57
4
+ data.tar.gz: 5676630c7eeb0faafd5ea398dd7b189ba3a0eafa
5
5
  SHA512:
6
- metadata.gz: 142474ce6e052aaeb96d77330399c23f379c0b945d7d6e0dc4e8c88a39a4e36ae1778e272ba018ee47baa55def0b8df76ff27b02732eb117544fb3fc65217d52
7
- data.tar.gz: 6c75afc8ff78294a70900f7c8079d617876a1b413c27c4d34fd2271e3df94ed9ea50d2b741a5e8b0a023597f4d3c1ab42f54e6b4e73c62c4580c525021f704a9
6
+ metadata.gz: 7ef6b600e35520f66781c720afe3ada873d2763eea951ecf90ff30f8514d31356e997dbd51162d55dd95d8d86f76a202191ce4810496922bf726b3e8da553869
7
+ data.tar.gz: 2710d3b107057a326f8265c7ca07d9011bc1e87ae7256e5eb209e8dbfe6ce9849791e3e48e90df7705f89915f99ee092fb3ffd2f7e3243281b78e76eea4b69d9
data/README.md CHANGED
@@ -124,10 +124,27 @@ P.S. See all available rake command:
124
124
 
125
125
  rake -T
126
126
 
127
+ ### Mail configuration example(from [mail](https://github.com/mikel/mail))
128
+
129
+ 1. Change default delivery method
130
+
131
+ Change global delivery method it in `example/config/mail_config.rb`, or just change for this report:
132
+
133
+ mail.delivery_method :smtp,address: "localhost", port: 1025
134
+
135
+ 2. Add attachment file
136
+
137
+ mail.add_file '/path/to/file'
138
+ # or
139
+ mail.add_file :filename=>'somefile.png',:content=>'/path/to/f.png'
140
+
141
+ 3. Add cc
142
+
143
+ mail.cc="other@example.com"
127
144
 
128
145
  ### Others
129
146
 
130
- * Email detail configurations, please check [mail](https://github.com/mikel/mail).
147
+ * More email detail configurations, please check [mail](https://github.com/mikel/mail).
131
148
  * View template details, please check [erubis](https://github.com/genki/erubis).
132
149
 
133
150
  ## Contributing
data/jreport.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_runtime_dependency "thor"
26
26
  spec.add_runtime_dependency 'mail'
27
- spec.add_runtime_dependency 'inline-style'
27
+ spec.add_runtime_dependency 'premailer'
28
28
  spec.add_runtime_dependency 'erubis'
29
29
  spec.add_runtime_dependency 'activerecord'
30
30
  end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: UTF-8 -*-
2
2
  require 'erubis'
3
- require 'inline-style'
3
+ require 'premailer'
4
4
  require 'mail'
5
5
 
6
6
  module Jreport
@@ -34,10 +34,7 @@ module Jreport
34
34
  File.open(ctrl.save_to,'w'){|fi| fi.write(html) } if ctrl.save_to
35
35
  # send out report
36
36
  mail.body=html
37
- if mail.to
38
- mail.deliver!
39
- puts "Mail sent!"
40
- end
37
+ send_mail(mail)
41
38
  rescue=>e
42
39
  puts e
43
40
  puts e.backtrace
@@ -51,11 +48,19 @@ module Jreport
51
48
  html=Erubis::Eruby.new(File.read("#{base}.eruby")).result(bindings)
52
49
  if File.exist?("#{base}.css")
53
50
  css=File.read "#{base}.css"
54
- html<<%Q{<style type="text/css" media="screen">#{css}</style>}
55
- html=InlineStyle.process(html)
51
+ p=Premailer.new(html,:with_html_string=>true,:css_string=>css)
52
+ html=p.to_inline_css
56
53
  end
57
54
  html
58
55
  end
59
-
56
+ def send_mail(mail)
57
+ lost=mail.from.nil? ? 'from' : mail.to.nil? ? 'to' : mail.subject.nil? ? 'subject' : nil
58
+ if lost
59
+ puts "Mail '#{lost}' empty, mail wouldn't be sent!"
60
+ return
61
+ end
62
+ mail.deliver!
63
+ puts "Mail sent!"
64
+ end
60
65
  end
61
66
  end
@@ -1,3 +1,3 @@
1
1
  module Jreport
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
data/skel/Gemfile CHANGED
@@ -2,7 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'thor'
4
4
  gem 'mail'
5
- gem 'inline-style'
5
+ gem 'premailer'
6
+ gem 'hpricot'
6
7
  gem 'erubis'
7
8
  gem 'sqlite3'
8
9
  #gem 'activerecord-jdbcsqlite3-adapter'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jreport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - qjpcpu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-21 00:00:00.000000000 Z
11
+ date: 2014-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: inline-style
84
+ name: premailer
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="