diffux_ci 0.3.2 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5143ca3e39e34a1ea00043f6f20814a72971b16
4
- data.tar.gz: 6fced8ad6eccd338a886769b2ca755768ab9c0f9
3
+ metadata.gz: 17dabfe7fd58267914a299a9483ab949641d6257
4
+ data.tar.gz: 2fc79ba700188b7aba82f43d34ab7962e78f65d9
5
5
  SHA512:
6
- metadata.gz: 758fe05b11a9edcc343acc0cd9988615e2035432675e88de8b2837941f2c1704de1b9d6cd2a31102df05fd1b5276dc0a7b439b83a987a7e421e0b0177e7a8679
7
- data.tar.gz: feb1f5d30adea55fc3fc0f467f1079eb629d09b15a6b0248ebfe60a91d2f2679a9e086a789c5822fbac5cf7611831358090be701aaa4ea7378e97859df8fe114
6
+ metadata.gz: 46723a8efa95283c6d95201f45a2075d7afa47f9ee2aeea3a7cfe85f6ccfe7904473ac0345d9c7132827dcb0009a8c3f1b0c4ea3b6811c79aa8fd53de2131baa
7
+ data.tar.gz: 4ac1e9e47de90dae7dc9771b318a7c1c058555d05f8d3189423294d0e0fe224e18e0d06aa6625bee86832337bbc1c5b268fe6700e51ac0acf7acca5aa2425849
@@ -121,7 +121,7 @@ begin
121
121
  screenshot = ChunkyPNG::Image.from_blob(driver.screenshot_as(:png))
122
122
  print '.'
123
123
 
124
- # In our JavScript we are rounding up, which can sometimes give us a
124
+ # In our JavaScript we are rounding up, which can sometimes give us a
125
125
  # dimensions that are larger than the screenshot dimensions. We need to
126
126
  # guard against that here.
127
127
  crop_width = [
@@ -133,11 +133,13 @@ begin
133
133
  screenshot.height - rendered['top']
134
134
  ].min
135
135
 
136
- screenshot.crop!(rendered['left'],
137
- rendered['top'],
138
- crop_width,
139
- crop_height)
140
- print '.'
136
+ if crop_width < screenshot.width || crop_height < screenshot.height
137
+ screenshot.crop!(rendered['left'],
138
+ rendered['top'],
139
+ crop_width,
140
+ crop_height)
141
+ print '.'
142
+ end
141
143
 
142
144
  # Run the diff if needed
143
145
  baseline_path = DiffuxCIUtils.path_to(
@@ -3,11 +3,10 @@ require 's3'
3
3
  require 'securerandom'
4
4
 
5
5
  class DiffuxCIUploader
6
- BUCKET_NAME = 'diffux_ci-diffs'
7
-
8
6
  def initialize
9
7
  @s3_access_key_id = DiffuxCIUtils.config['s3_access_key_id']
10
8
  @s3_secret_access_key = DiffuxCIUtils.config['s3_secret_access_key']
9
+ @s3_bucket_name = DiffuxCIUtils.config['s3_bucket_name']
11
10
  end
12
11
 
13
12
  def upload_diffs
@@ -42,10 +41,10 @@ class DiffuxCIUploader
42
41
  def find_or_build_bucket
43
42
  service = S3::Service.new(access_key_id: @s3_access_key_id,
44
43
  secret_access_key: @s3_secret_access_key)
45
- bucket = service.buckets.find(BUCKET_NAME)
44
+ bucket = service.buckets.find(@s3_bucket_name)
46
45
 
47
46
  if bucket.nil?
48
- bucket = service.buckets.build(BUCKET_NAME)
47
+ bucket = service.buckets.build(@s3_bucket_name)
49
48
  bucket.save(location: :us)
50
49
  end
51
50
 
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module DiffuxCI
3
- VERSION = '0.3.2'
3
+ VERSION = '0.4.0'
4
4
  end
@@ -28,15 +28,9 @@ window.diffux = {
28
28
  * @return {Array.<Object>}
29
29
  */
30
30
  getAllExamples: function() {
31
- var descriptions = Object.keys(this.defined);
32
-
33
- if (this.fdefined.length) {
34
- // Some examples have been focused, so we want to filter out anything that
35
- // has not been focused.
36
- descriptions = descriptions.filter(function(description) {
37
- return this.fdefined.indexOf(description) !== -1;
38
- }.bind(this));
39
- }
31
+ var descriptions = this.fdefined.length ?
32
+ this.fdefined :
33
+ Object.keys(this.defined);
40
34
 
41
35
  return descriptions.map(function(description) {
42
36
  var example = this.defined[description];
@@ -49,23 +43,6 @@ window.diffux = {
49
43
  }.bind(this));
50
44
  },
51
45
 
52
- isElementVisible: function(element) {
53
- // element.offsetParent is a cheap way to determine visibility for most
54
- // elements, but it doesn't work for elements with fixed positioning so we
55
- // will need to fall back to the more expensive getComputedStyle.
56
- return element.offsetParent ||
57
- window.getComputedStyle(element).display !== 'none';
58
- },
59
-
60
- clearVisibleElements: function() {
61
- var allElements = document.querySelectorAll('body > *');
62
- for (var element of allElements) {
63
- if (this.isElementVisible(element)) {
64
- element.parentNode.removeChild(element);
65
- }
66
- }
67
- },
68
-
69
46
  handleError: function(currentExample, error) {
70
47
  console.error(error);
71
48
  return {
@@ -108,6 +85,9 @@ window.diffux = {
108
85
 
109
86
  /**
110
87
  * Clean up the DOM for a rendered element that has already been processed.
88
+ * This can be overridden by consumers to define their own clean out method,
89
+ * which can allow for this to be used to unmount React components, for
90
+ * example.
111
91
  *
112
92
  * @param {Object} renderedElement
113
93
  */
@@ -116,21 +96,28 @@ window.diffux = {
116
96
  },
117
97
 
118
98
  /**
99
+ * This function is called from Ruby asynchronously. Therefore, we need to
100
+ * call doneFunc when the method has completed so that Ruby knows to continue.
101
+ *
119
102
  * @param {String} exampleDescription
120
103
  * @param {Function} doneFunc injected by driver.execute_async_script in
121
104
  * diffux_ci_runner.rb
122
105
  */
123
106
  renderExample: function(exampleDescription, doneFunc) {
124
- var currentExample = this.defined[exampleDescription];
125
- if (!currentExample) {
126
- throw 'No example found with description "' + exampleDescription + '"';
127
- }
128
-
129
107
  try {
108
+ var currentExample = this.defined[exampleDescription];
109
+ if (!currentExample) {
110
+ throw new Error(
111
+ 'No example found with description "' + exampleDescription + '"');
112
+ }
113
+
114
+ // Clear out the body of the document
130
115
  if (this.currentRenderedElement) {
131
116
  this.cleanOutElement(this.currentRenderedElement);
132
117
  }
133
- this.clearVisibleElements();
118
+ while (document.body.firstChild) {
119
+ document.body.removeChild(document.body.firstChild);
120
+ }
134
121
 
135
122
  var func = currentExample.func;
136
123
  if (func.length) {
data/lib/views/index.erb CHANGED
@@ -17,11 +17,11 @@
17
17
  <link rel="stylesheet" type="text/css"
18
18
  href="/resource?file=<%= ERB::Util.url_encode(stylesheet) %>">
19
19
  <% end %>
20
- </head>
21
- <body style="background-color: #fff; margin: 0; pointer-events: none;">
22
20
  <script src="/diffux_ci-runner.js"></script>
23
21
  <% @config['source_files'].each do |source_file| %>
24
22
  <script src="/resource?file=<%= ERB::Util.url_encode(source_file) %>"></script>
25
23
  <% end %>
24
+ </head>
25
+ <body style="background-color: #fff; margin: 0; pointer-events: none;">
26
26
  </body>
27
27
  </html>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diffux_ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henric Trotzig
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-19 00:00:00.000000000 Z
12
+ date: 2015-11-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: diffux-core
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  version: '0'
168
168
  requirements: []
169
169
  rubyforge_project:
170
- rubygems_version: 2.4.5.1
170
+ rubygems_version: 2.4.5
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: Diffux-CI