reportir 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/reportir/static_site_template/css/main.css +15 -64
  3. data/lib/reportir/static_site_template/css/vendor/owl.carousel.css +216 -0
  4. data/lib/reportir/static_site_template/css/vendor/owl.default.theme.min.css +1 -0
  5. data/lib/reportir/static_site_template/index.html +95 -69
  6. data/lib/reportir/static_site_template/js/{main.js → models.js} +0 -0
  7. data/lib/reportir/static_site_template/js/vendor/owl.carousel.min.js +2 -0
  8. data/lib/reportir/version.rb +1 -1
  9. data/lib/reportir.rb +73 -51
  10. data/reportir.gemspec +1 -0
  11. metadata +20 -30
  12. data/lib/reportir/static_site_template/.editorconfig +0 -13
  13. data/lib/reportir/static_site_template/.gitattributes +0 -1
  14. data/lib/reportir/static_site_template/.gitignore +0 -2
  15. data/lib/reportir/static_site_template/.htaccess +0 -984
  16. data/lib/reportir/static_site_template/404.html +0 -60
  17. data/lib/reportir/static_site_template/LICENSE.txt +0 -19
  18. data/lib/reportir/static_site_template/apple-touch-icon.png +0 -0
  19. data/lib/reportir/static_site_template/css/font/FontAwesome.otf +0 -0
  20. data/lib/reportir/static_site_template/css/font/fontawesome-webfont.eot +0 -0
  21. data/lib/reportir/static_site_template/css/font/fontawesome-webfont.svg +0 -284
  22. data/lib/reportir/static_site_template/css/font/fontawesome-webfont.ttf +0 -0
  23. data/lib/reportir/static_site_template/css/font/fontawesome-webfont.woff +0 -0
  24. data/lib/reportir/static_site_template/css/vendor/font-awesome.min.css +0 -33
  25. data/lib/reportir/static_site_template/doc/TOC.md +0 -29
  26. data/lib/reportir/static_site_template/doc/css.md +0 -162
  27. data/lib/reportir/static_site_template/doc/extend.md +0 -663
  28. data/lib/reportir/static_site_template/doc/faq.md +0 -62
  29. data/lib/reportir/static_site_template/doc/html.md +0 -223
  30. data/lib/reportir/static_site_template/doc/js.md +0 -37
  31. data/lib/reportir/static_site_template/doc/misc.md +0 -175
  32. data/lib/reportir/static_site_template/doc/usage.md +0 -130
  33. data/lib/reportir/static_site_template/humans.txt +0 -15
  34. data/lib/reportir/static_site_template/img/pagination.png +0 -0
  35. data/lib/reportir/static_site_template/robots.txt +0 -5
  36. data/lib/reportir/static_site_template/tile-wide.png +0 -0
  37. data/lib/reportir/static_site_template/tile.png +0 -0
  38. data/reportir-0.2.0.gem +0 -0
data/lib/reportir.rb CHANGED
@@ -3,18 +3,26 @@ require 's3_uploader'
3
3
  require 'aws-sdk'
4
4
 
5
5
  module Reportir
6
- @@static_site_template_path = Gem.find_files('reportir')[1] +'/static_site_template'
7
- @@template_subdirectory_for_test_artifacts = 'test_run'
8
6
  @@step = 0
7
+ @@tests = [] # has to be array for front-end
9
8
 
10
9
  def upload_result_to_s3_as_static_site
11
10
  check_for_env_vars
12
- clone_template
13
- reset_orig_template # TODO: clone before screenshots are possible
14
- save_final_markup_in_clone
15
- write_ractive_models_in_clone(screenshots: screenshot_paths, nav: nav_links)
16
- upload_clone_to_s3
17
- delete_local_clone
11
+ clear_previous_results_from_s3
12
+ save_final_markup
13
+ write_javascript_models
14
+ upload_to_s3
15
+ delete_tmp_files_for_this_test
16
+ 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" }
18
26
  end
19
27
 
20
28
  private
@@ -26,84 +34,98 @@ module Reportir
26
34
  raise Reportir::Error.new 'Missing ENV AWS_DEFAULT_REGION' unless ENV['AWS_DEFAULT_REGION']
27
35
  end
28
36
 
29
- def clone_template
30
- FileUtils.cp_r "#{@@static_site_template_path}/.", clone_dir_path
37
+ def delete_tmp_files_for_this_test
38
+ FileUtils.rm_rf local_test_root
31
39
  end
32
40
 
33
- def reset_orig_template
34
- FileUtils.rm_rf "#{@@static_site_template_path}/#{@@template_subdirectory_for_test_artifacts}"
41
+ def save_final_markup
42
+ s3_screenshot('final')
43
+ path = "#{local_test_root}/final.html"
44
+ File.open(path, 'w') { |f| f.write @browser.html }
45
+ current_test[:add_links] << { name: 'Markup from Last Page', path: "#{public_path_for_this_test}/final.html" }
35
46
  end
36
47
 
37
- def save_final_markup_in_clone
38
- s3_screenshot('final')
39
- File.open("#{deletable_data_path}/final.html", 'w') {|f| f.write @browser.html }
48
+ def write_javascript_models
49
+ string = %{
50
+ var navigation = #{array_of_test_names.to_json};\n
51
+ var tests = #{@@tests.to_json};\n
52
+ }
53
+ File.open(local_model_file_path, "w") { |f| f.write(string) }
40
54
  end
41
55
 
42
- def write_ractive_models_in_clone(data)
43
- data.each do |k,v|
44
- model = {el: "##{k}_container", template: "##{k}_template", data: {k => v}}
45
- File.open("#{clone_dir_path}/js/main.js", "a") { |f| f.write("var #{k} = new Ractive(#{model.to_json});\n") }
46
- end
56
+ def clear_previous_results_from_s3
57
+ puts "deleting all previous test data from s3"
58
+ ::Aws::S3::Bucket.new(ENV['AWS_DEFAULT_BUCKET']).delete_objects({
59
+ delete: {
60
+ objects: [{ key: "#{public_path_for_this_test}" }],
61
+ quiet: true
62
+ }
63
+ })
47
64
  end
48
65
 
49
- def upload_clone_to_s3
50
- puts '====== STARTING S3 UPLOAD ========='
66
+ def upload_to_s3
67
+ puts ''
51
68
  puts ''
52
- ::Aws::S3::Bucket.new(ENV['AWS_DEFAULT_BUCKET']).clear!
53
- ::S3Uploader.upload_directory(clone_dir_path, ENV['AWS_DEFAULT_BUCKET'], {
54
- :destination_dir => test_name,
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 #{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,
55
74
  :threads => 5,
56
75
  s3_key: ENV['AWS_ACCESS_KEY_ID'],
57
76
  s3_secret: ENV['AWS_SECRET_ACCESS_KEY'],
58
77
  region: ENV['AWS_DEFAULT_REGION'] })
59
78
  puts ''
79
+ puts ''
60
80
  puts '====== S3 UPLOAD COMPLETE ========='
61
81
  puts 'URL: ' + static_site_url
62
82
  puts '==================================='
83
+ puts ''
84
+ puts ''
63
85
  end
64
86
 
65
- def delete_local_clone
66
- FileUtils.rm_rf clone_dir_path
87
+ def current_test
88
+ @@tests.select{ |test| test[:name] == test_name }.first
67
89
  end
68
90
 
69
- def test_name
70
- RSpec.current_example.metadata[:full_description].gsub(/[^\w\s]/,'').gsub(/\s/,'_')
91
+ def create_current_test
92
+ if !current_test || current_test.empty?
93
+ @@tests << { name: test_name, screenshots: [], add_links: [] }
94
+ end
71
95
  end
72
96
 
73
- def clone_dir_path
74
- "./tmp/#{test_name}"
97
+ def array_of_test_names
98
+ @@tests.map{|t| t[:name] }
75
99
  end
76
100
 
77
- def static_site_url
78
- "http://#{ENV['AWS_DEFAULT_BUCKET']}.s3-website-#{ENV['AWS_DEFAULT_REGION']}.amazonaws.com/#{test_name}"
101
+ def local_model_file_path
102
+ "#{local_root}/models.js"
79
103
  end
80
104
 
81
- def s3_screenshot(method)
82
- @@step = @@step+=1
83
- image_name = "#{@@step}-#{method}"
84
- FileUtils.mkdir_p(deletable_data_path) unless Dir.exists?(deletable_data_path)
85
- @browser.screenshot.save("#{deletable_data_path}/#{image_name}.png")
105
+ def local_test_root
106
+ "#{local_root}/#{public_path_for_this_test}"
86
107
  end
87
108
 
88
- def deletable_data_path
89
- "#{clone_dir_path}/#{@@template_subdirectory_for_test_artifacts}"
109
+ def local_root
110
+ "./tmp/reportir"
90
111
  end
91
112
 
92
- def nav_links
93
- {'Last Page as Markup' => "#{@@template_subdirectory_for_test_artifacts}/final.html"}
113
+ def public_path_for_this_test
114
+ "#{public_artifact_root}/#{test_name}"
94
115
  end
95
116
 
96
- def screenshot_paths
97
- images = []
98
- Dir["#{deletable_data_path}/**/*.png"].sort_by { |x| x[/\d+/].to_i }.each do |src|
99
- images << "#{@@template_subdirectory_for_test_artifacts}/#{Pathname.new(src).basename}"
100
- end
101
- images
117
+ def public_artifact_root
118
+ "test_artifacts"
119
+ end
120
+
121
+ def test_name
122
+ ::RSpec.current_example.metadata[:test_name] || ::RSpec.current_example.metadata[:full_description].gsub(/[^\w\s]/,'').gsub(/\s/,'_')
102
123
  end
103
124
 
104
- def clear_out_any_old_results
105
- puts "> Cleaning out old #{deletable_data_path} directory"
106
- FileUtils.rm_rf "#{deletable_data_path}/*"
125
+ def static_site_url
126
+ # TODO: use aws-sdk for this.
127
+ "http://#{ENV['AWS_DEFAULT_BUCKET']}.s3-website-#{ENV['AWS_DEFAULT_REGION']}.amazonaws.com"
107
128
  end
129
+
108
130
  class Error < ::StandardError; end
109
131
  end
data/reportir.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.10"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "rubocop"
25
26
  spec.add_runtime_dependency 's3_uploader'
26
27
  spec.add_runtime_dependency 'aws-sdk'
27
28
  spec.add_runtime_dependency 'fileutils'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reportir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Shelton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-09 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: s3_uploader
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -127,48 +141,24 @@ files:
127
141
  - bin/console
128
142
  - bin/setup
129
143
  - lib/reportir.rb
130
- - lib/reportir/static_site_template/.editorconfig
131
- - lib/reportir/static_site_template/.gitattributes
132
- - lib/reportir/static_site_template/.gitignore
133
- - lib/reportir/static_site_template/.htaccess
134
- - lib/reportir/static_site_template/404.html
135
- - lib/reportir/static_site_template/LICENSE.txt
136
- - lib/reportir/static_site_template/apple-touch-icon.png
137
144
  - lib/reportir/static_site_template/browserconfig.xml
138
145
  - lib/reportir/static_site_template/crossdomain.xml
139
- - lib/reportir/static_site_template/css/font/FontAwesome.otf
140
- - lib/reportir/static_site_template/css/font/fontawesome-webfont.eot
141
- - lib/reportir/static_site_template/css/font/fontawesome-webfont.svg
142
- - lib/reportir/static_site_template/css/font/fontawesome-webfont.ttf
143
- - lib/reportir/static_site_template/css/font/fontawesome-webfont.woff
144
146
  - lib/reportir/static_site_template/css/main.css
145
147
  - lib/reportir/static_site_template/css/normalize.css
146
148
  - lib/reportir/static_site_template/css/vendor/bootstrap.min.css
147
- - lib/reportir/static_site_template/css/vendor/font-awesome.min.css
148
- - lib/reportir/static_site_template/doc/TOC.md
149
- - lib/reportir/static_site_template/doc/css.md
150
- - lib/reportir/static_site_template/doc/extend.md
151
- - lib/reportir/static_site_template/doc/faq.md
152
- - lib/reportir/static_site_template/doc/html.md
153
- - lib/reportir/static_site_template/doc/js.md
154
- - lib/reportir/static_site_template/doc/misc.md
155
- - lib/reportir/static_site_template/doc/usage.md
149
+ - lib/reportir/static_site_template/css/vendor/owl.carousel.css
150
+ - lib/reportir/static_site_template/css/vendor/owl.default.theme.min.css
156
151
  - lib/reportir/static_site_template/favicon.ico
157
- - lib/reportir/static_site_template/humans.txt
158
152
  - lib/reportir/static_site_template/img/.gitignore
159
- - lib/reportir/static_site_template/img/pagination.png
160
153
  - lib/reportir/static_site_template/index.html
161
- - lib/reportir/static_site_template/js/main.js
154
+ - lib/reportir/static_site_template/js/models.js
162
155
  - lib/reportir/static_site_template/js/plugins.js
163
156
  - lib/reportir/static_site_template/js/vendor/bootstrap.min.js
164
157
  - lib/reportir/static_site_template/js/vendor/jquery-1.11.3.min.js
165
158
  - lib/reportir/static_site_template/js/vendor/jquery.slides.min.js
166
159
  - lib/reportir/static_site_template/js/vendor/modernizr-2.8.3.min.js
167
- - lib/reportir/static_site_template/robots.txt
168
- - lib/reportir/static_site_template/tile-wide.png
169
- - lib/reportir/static_site_template/tile.png
160
+ - lib/reportir/static_site_template/js/vendor/owl.carousel.min.js
170
161
  - lib/reportir/version.rb
171
- - reportir-0.2.0.gem
172
162
  - reportir.gemspec
173
163
  homepage: http://github.com/reportir
174
164
  licenses:
@@ -1,13 +0,0 @@
1
- # editorconfig.org
2
-
3
- root = true
4
-
5
- [*]
6
- charset = utf-8
7
- indent_size = 4
8
- indent_style = space
9
- insert_final_newline = true
10
- trim_trailing_whitespace = true
11
-
12
- [*.md]
13
- trim_trailing_whitespace = false
@@ -1 +0,0 @@
1
- * text=auto
@@ -1,2 +0,0 @@
1
- # Include your project-specific ignores in this file
2
- # Read about how to use .gitignore: https://help.github.com/articles/ignoring-files