reportir 0.3.1 → 0.3.3

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: 2cb01b1a604f9888f722f21013657a051b495665
4
- data.tar.gz: f553df14eab79c36afda261583c4467a540ca483
3
+ metadata.gz: 984561d1c0d5ce2d7d61d43bc6da95651679cd6c
4
+ data.tar.gz: bc8caa6a3a64650fa85194017ca2551c2f02264c
5
5
  SHA512:
6
- metadata.gz: 093c01da36eb90fe37576e18c18b1a83bbcaa99d4c20f26e0cf453778dfe9603d159f3ad77765bd09154e1c9cfd1c8fc72b5ff15f3a3ae1416475807a377a54f
7
- data.tar.gz: fa969ce3129bb88e7fe4550cb9cf009d847711f32bd1c9542d513f69bff14b37a78ae2cfca13467b34fb8b36d385adbc3cb68b47b46b81f35510cf572311259b
6
+ metadata.gz: 05fb3a93750af32b5c528a886d868ae14be35e85b34ad52ede3517b5c9b4a9864ebbaf74293c65482bce33c75ad4b2e3f34cdbb72f0a78b72ab882fb413194c7
7
+ data.tar.gz: df018eeb4a717cc113f78ea55e158df646e90248702b275156d65b5c83517b079862703472dcae19f04a59757343d5d1d76433885c7bd2b3a635e9e0a856d583
@@ -1,3 +1,3 @@
1
1
  module Reportir
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.3"
3
3
  end
data/lib/reportir.rb CHANGED
@@ -8,25 +8,27 @@ module Reportir
8
8
 
9
9
  def upload_result_to_s3_as_static_site
10
10
  check_for_env_vars
11
+ upload_template unless template_uploaded?
11
12
  clear_previous_results_from_s3
12
13
  save_final_markup
13
14
  write_javascript_models
14
15
  upload_to_s3
15
16
  delete_tmp_files_for_this_test
16
17
  end
17
-
18
- def s3_screenshot(method)
19
- create_current_test #TODO: before-filter??
20
- @@step = @@step+=1
21
- image_name = "#{@@step}-#{method}"
22
- local_path = "#{local_test_root}/#{image_name}.png"
23
- FileUtils.mkdir_p(local_test_root) unless Dir.exists?(local_test_root)
24
- @browser.screenshot.save(local_path)
25
- current_test[:screenshots] << { name: image_name, src: "#{public_path_for_this_test}/#{image_name}.png" }
26
- end
27
18
 
28
19
  private
29
20
 
21
+ def upload_template
22
+ puts ''
23
+ puts ''
24
+ puts '====== UPLOADING TEMPLATE ========='
25
+ upload_directory(static_site_template_path, '')
26
+ end
27
+
28
+ def template_uploaded?
29
+ bucket.object('index.html').exists?
30
+ end
31
+
30
32
  def check_for_env_vars
31
33
  raise Reportir::Error.new 'Missing ENV AWS_DEFAULT_BUCKET' unless ENV['AWS_DEFAULT_BUCKET']
32
34
  raise Reportir::Error.new 'Missing ENV AWS_SECRET_ACCESS_KEY' unless ENV['AWS_SECRET_ACCESS_KEY']
@@ -66,15 +68,10 @@ module Reportir
66
68
  def upload_to_s3
67
69
  puts ''
68
70
  puts ''
69
- puts '====== STARTING S3 UPLOAD ========='
70
- ::Aws::S3::Resource.new.bucket(ENV['AWS_DEFAULT_BUCKET']).object('js/models.js').upload_file(local_model_file_path)
71
+ puts '====== UPLOADING RESULTS ========='
72
+ bucket.object('js/models.js').upload_file(local_model_file_path)
71
73
  puts "Uploading #{local_model_file_path} to /js/models.js"
72
- ::S3Uploader.upload_directory(local_test_root, ENV['AWS_DEFAULT_BUCKET'], {
73
- :destination_dir => public_path_for_this_test,
74
- :threads => 5,
75
- s3_key: ENV['AWS_ACCESS_KEY_ID'],
76
- s3_secret: ENV['AWS_SECRET_ACCESS_KEY'],
77
- region: ENV['AWS_DEFAULT_REGION'] })
74
+ upload_directory(local_test_root, public_path_for_this_test)
78
75
  puts ''
79
76
  puts ''
80
77
  puts '====== S3 UPLOAD COMPLETE ========='
@@ -84,6 +81,33 @@ module Reportir
84
81
  puts ''
85
82
  end
86
83
 
84
+ def s3_screenshot(method)
85
+ create_current_test #TODO: before-filter??
86
+ @@step = @@step+=1
87
+ image_name = "#{@@step}-#{method}"
88
+ local_path = "#{local_test_root}/#{image_name}.png"
89
+ FileUtils.mkdir_p(local_test_root) unless Dir.exists?(local_test_root)
90
+ @browser.screenshot.save(local_path)
91
+ current_test[:screenshots] << { name: image_name, src: "#{public_path_for_this_test}/#{image_name}.png" }
92
+ end
93
+
94
+ def bucket
95
+ @bucket ||= ::Aws::S3::Resource.new.bucket(ENV['AWS_DEFAULT_BUCKET'])
96
+ end
97
+
98
+ def upload_directory(local, remote)
99
+ ::S3Uploader.upload_directory(local, ENV['AWS_DEFAULT_BUCKET'], {
100
+ :destination_dir => remote,
101
+ :threads => 5,
102
+ s3_key: ENV['AWS_ACCESS_KEY_ID'],
103
+ s3_secret: ENV['AWS_SECRET_ACCESS_KEY'],
104
+ region: ENV['AWS_DEFAULT_REGION'] })
105
+ end
106
+
107
+ def static_site_template_path
108
+ Gem.find_files('reportir')[1] +'/static_site_template'
109
+ end
110
+
87
111
  def current_test
88
112
  @@tests.select{ |test| test[:name] == test_name }.first
89
113
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reportir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Shelton