henry-container 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source :gemcutter
2
- source 'http://crossselling.servers.despegar.it'
3
2
 
4
3
  gemspec
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.add_dependency('minitest-reporters')
22
22
  gem.add_dependency('colorize')
23
23
  gem.add_dependency('trollop')
24
+ gem.add_dependency('mail')
24
25
 
25
26
  gem.add_development_dependency('yard')
26
27
  end
@@ -3,7 +3,7 @@ module Henry
3
3
  class Container
4
4
 
5
5
  # Current Gem version
6
- VERSION = '0.1.16'
6
+ VERSION = '0.1.17'
7
7
 
8
8
  end
9
9
 
@@ -0,0 +1,32 @@
1
+ require 'mail'
2
+
3
+ module Henry
4
+
5
+ # Email client to send reports by email
6
+ class EmailClient
7
+
8
+ Mail.defaults do
9
+ delivery_method :smtp, { address: 'smtp.gmail.com', port: '587', user_name: 'henry.despegar.reports@gmail.com', password: 'henrydespegarreports', authentication: :plain, enable_starttls_auto: true }
10
+ end
11
+
12
+ def self.send_file(file_path, recipients, subject='')
13
+ Mail.deliver do
14
+ from('Henry Reports <henry.despegar.reports@gmail.com>')
15
+ bcc(recipients.join(','))
16
+ subject(subject)
17
+ add_file(file_path)
18
+ end
19
+ end
20
+
21
+ def self.send_message(message, recipients, subject='')
22
+ Mail.deliver do
23
+ from('Henry Reports <henry.despegar.reports@gmail.com>')
24
+ bcc(recipients.join(','))
25
+ subject(subject)
26
+ body(message)
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -7,6 +7,8 @@ module Henry
7
7
 
8
8
  # The Henry Task implementation for Cucumber
9
9
  class CucumberTask < RakeTask
10
+
11
+ attr_accessor :generated_reports, :report_recipients
10
12
 
11
13
  # The temporary output file path for the RspecTask execution.
12
14
  OUT_PATH = 'cucumber.out'
@@ -30,6 +32,20 @@ module Henry
30
32
  OUT_PATH
31
33
  end
32
34
 
35
+ def after_execute
36
+ if !(self.generated_reports || []).empty? && !(self.report_recipients || []).empty?
37
+ tgz_path = ".henry/#{DateTime.now.strftime(TIME_FORMAT)}_#{self.name}.tgz"
38
+
39
+ `tar czf #{tgz_path} #{self.generated_reports.join(' ')}`
40
+
41
+ Henry::EmailClient.send_file("#{DateTime.now.strftime(TIME_FORMAT)}_#{self.name}.tgz", self.report_recipients.uniq, "[Henry Reports] #{self.name}")
42
+
43
+ `rm #{tgz_path}`
44
+ end
45
+
46
+ super
47
+ end
48
+
33
49
  # Configures the Task.
34
50
  #
35
51
  # @param [Hash] params the task params.
@@ -93,12 +109,19 @@ module Henry
93
109
  #
94
110
  # @return [String]
95
111
  def report_options
112
+ self.generated_reports = []
113
+ self.report_recipients = []
114
+
96
115
  return '' if self.data.reports.nil?
97
116
 
98
117
  self.data.reports.collect do |report_options|
99
118
  report_options['name'] ||= "${DATE}_${TASK_NAME}.#{report_options['format']}"
100
119
 
120
+ self.generated_reports << self.report_file_path(report_options['format'], report_options['name'])
121
+ self.report_recipients += report_options['recipients']
122
+
101
123
  FileUtils.mkdir_p(self.reports_dir(report_options['format']))
124
+
102
125
  "--format #{report_options['format']} --out #{self.report_file_path(report_options['format'], report_options['name'])}"
103
126
  end.join(' ')
104
127
  end
@@ -47,6 +47,7 @@ module Henry
47
47
  end
48
48
 
49
49
  end
50
+
50
51
  require_relative 'cucumber_task'
51
52
  require_relative 'rspec_task'
52
53
  require_relative 'minitest_task'
@@ -7,6 +7,8 @@ module Henry
7
7
 
8
8
  # The Henry Task implementation for Rspec
9
9
  class RspecTask < RakeTask
10
+
11
+ attr_accessor :generated_reports, :report_recipients
10
12
 
11
13
  # The temporary output file path for the RspecTask execution.
12
14
  OUT_PATH = 'rspec.out'
@@ -29,6 +31,20 @@ module Henry
29
31
  def out_path
30
32
  OUT_PATH
31
33
  end
34
+
35
+ def after_execute
36
+ if !(self.generated_reports || []).empty? && !(self.report_recipients || []).empty?
37
+ tgz_path = ".henry/#{DateTime.now.strftime(TIME_FORMAT)}_#{self.name}.tgz"
38
+
39
+ `tar czf #{tgz_path} #{self.generated_reports.join(' ')}`
40
+
41
+ Henry::EmailClient.send_file("#{DateTime.now.strftime(TIME_FORMAT)}_#{self.name}.tgz", self.report_recipients.uniq, "[Henry Reports] #{self.name}")
42
+
43
+ `rm #{tgz_path}`
44
+ end
45
+
46
+ super
47
+ end
32
48
 
33
49
  # Configures the Task.
34
50
  #
@@ -90,10 +106,19 @@ module Henry
90
106
  #
91
107
  # @return [String]
92
108
  def report_options
109
+ self.generated_reports = []
110
+ self.report_recipients = []
111
+
93
112
  return '' if self.data.reports.nil?
94
113
 
95
114
  self.data.reports.collect do |report_options|
115
+ report_options['name'] ||= "${DATE}_${TASK_NAME}.#{report_options['format']}"
116
+
117
+ self.generated_reports << self.report_file_path(report_options['format'], report_options['name'])
118
+ self.report_recipients += report_options['recipients']
119
+
96
120
  FileUtils.mkdir_p(self.reports_dir(report_options['format']))
121
+
97
122
  "--format #{report_options['format']} --out #{self.report_file_path(report_options['format'], report_options['name'])}"
98
123
  end.join(' ')
99
124
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: henry-container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-30 00:00:00.000000000 Z
12
+ date: 2013-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -107,6 +107,22 @@ dependencies:
107
107
  - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: mail
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
110
126
  - !ruby/object:Gem::Dependency
111
127
  name: yard
112
128
  requirement: !ruby/object:Gem::Requirement
@@ -142,6 +158,7 @@ files:
142
158
  - lib/henry.rb
143
159
  - lib/henry/container.rb
144
160
  - lib/henry/container/version.rb
161
+ - lib/henry/email_client.rb
145
162
  - lib/henry/environment.rb
146
163
  - lib/henry/execution.rb
147
164
  - lib/henry/input.rb