pageflow-linkmap-page 2.4.0 → 2.5.0

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
  SHA256:
3
- metadata.gz: bdf4cd722e530a4c6cd5415a63c213c591b843a48b4bc538750f1ab46c74ee67
4
- data.tar.gz: c1e44bf9e9185529a86f6d6d9507c4f5ab006723a743fd08eb49d5c769723062
3
+ metadata.gz: 20fd794281e40b28b10018b90477fbb17bdac8444e406dca532d0e0fb6b59368
4
+ data.tar.gz: 0ae08ee96055ef4ceb0e005eeb3f498d9640a46cfcdf28e830bef5541dc41b8a
5
5
  SHA512:
6
- metadata.gz: 32e50b565cc8badc9903468b367a2198130c0f25b34e15e480dc24a52a1473d0e5ffa60fbd8e569ecd9d4de1f96703d0d779e123b4190f51f9f43546987f3341
7
- data.tar.gz: e1501cf8952a8b2f35cda9b97c8dc70afee99d92f00612fd6865d236c24de4fdf84f7d04193863af9d947584a8b099fe3f25ca15bc5b5b5ad9825eda8ee71586
6
+ metadata.gz: 356ef2fe7137f4e8050a584923dbe76408937241bbcfa02697b5cef01818f7b21bd0b565e8baa3265f6d313c9355be84dbdbf6692e76790638b4bb0f5c787808
7
+ data.tar.gz: 8fa009d774f3f2db7e5f66e9bbc1573e6dca6fa6a8c83cd0fc726773d1ac0c151303616247a9cf95fc0c43b95eff00a2c75ebba4e2536ba1280da5d82ab318e8
@@ -1,14 +1,18 @@
1
1
  # CHANGELOG
2
2
 
3
- ### Version 2.4.0
3
+ ### Version 2.5.0
4
4
 
5
- 2019-05-20
5
+ 2019-07-24
6
6
 
7
- [Compare changes](https://github.com/codevise/pageflow-linkmap-page/compare/2-3-stable...v2.4.0)
7
+ [Compare changes](https://github.com/codevise/pageflow-linkmap-page/compare/2-4-stable...v2.5.0)
8
8
 
9
- - Use theme variable for overlay text color
10
- ([#58](https://github.com/codevise/pageflow-linkmap-page/pull/58))
9
+ - Make processing jobs wait for prerequisites. Prevent cases where
10
+ masked processing already starts before image file has finished
11
+ uploading.
12
+ ([#62](https://github.com/codevise/pageflow-linkmap-page/pull/62))
13
+ - Fix specs depending on color parsing with ImageMagick 6.9
14
+ ([#61](https://github.com/codevise/pageflow-linkmap-page/pull/61))
11
15
 
12
16
  See
13
- [2-3-stable branch](https://github.com/codevise/pageflow-linkmap-page/blob/2-3-stable/CHANGELOG.md)
17
+ [2-4-stable branch](https://github.com/codevise/pageflow-linkmap-page/blob/2-4-stable/CHANGELOG.md)
14
18
  for previous changes.
@@ -19,13 +19,12 @@
19
19
  this.listenTo(
20
20
  this,
21
21
  'change:' + attribute +
22
- ' change:linkmap_color_map_file_id' +
23
- ' change:linkmap_color_map_file_id:ready',
22
+ ' change:linkmap_color_map_file_id',
24
23
  function() {
25
24
  var colorMapFile = colorMapFiles().get(this.get('linkmap_color_map_file_id'));
26
25
  var imageFile = pageflow.imageFiles.get(this.get(attribute));
27
26
 
28
- if (imageFile && colorMapFile && colorMapFile.isReady()) {
27
+ if (imageFile && colorMapFile) {
29
28
  this.setReference('linkmap_masked_' + attribute,
30
29
  maskedImageFiles().findOrCreateBy({
31
30
  source_image_file_id: imageFile.id,
@@ -6,8 +6,12 @@ module Pageflow
6
6
  include StateMachineJob
7
7
 
8
8
  def perform_with_result(file, _options)
9
+ return :error if file.prerequisite_files.any?(&:failed?)
10
+ return :pending unless file.prerequisite_files.all?(&:ready?)
11
+
9
12
  file.attachment = file.source_image_file.attachment
10
13
  file.save!
14
+
11
15
  :ok
12
16
  end
13
17
  end
@@ -39,6 +39,10 @@ module Pageflow
39
39
  color_map_file.present_colors
40
40
  end
41
41
 
42
+ def prerequisite_files
43
+ [color_map_file, source_image_file]
44
+ end
45
+
42
46
  private
43
47
 
44
48
  def update_processing_progress(style)
@@ -23,6 +23,7 @@ module Pageflow
23
23
 
24
24
  job ProcessSourceImageFileJob do
25
25
  on_enter 'processing'
26
+ result :pending, retry_after: 3.seconds
26
27
  result ok: 'processed'
27
28
  result error: 'processing_failed'
28
29
  end
@@ -52,9 +53,17 @@ module Pageflow
52
53
  processed?
53
54
  end
54
55
 
56
+ def failed?
57
+ processing_failed?
58
+ end
59
+
55
60
  def basename
56
61
  'unused'
57
62
  end
63
+
64
+ def prerequisite_files
65
+ [source_image_file]
66
+ end
58
67
  end
59
68
  end
60
69
  end
@@ -186,6 +186,7 @@ module Pageflow
186
186
  .reject { |color| color == TRANSPARENT }
187
187
  .map { |color| color.tr('#', '') }
188
188
  .map(&:downcase)
189
+ .map { |color| color.gsub(/(.{6})ff/, '\1') }
189
190
  .sort
190
191
  end
191
192
 
@@ -1,5 +1,5 @@
1
1
  module Pageflow
2
2
  module LinkmapPage
3
- VERSION = '2.4.0'.freeze
3
+ VERSION = '2.5.0'.freeze
4
4
  end
5
5
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.required_ruby_version = '~> 2.1'
20
20
 
21
- spec.add_runtime_dependency 'pageflow', '~> 14.x'
21
+ spec.add_runtime_dependency 'pageflow', '~> 14.3.x'
22
22
  spec.add_runtime_dependency 'pageflow-external-links', '~> 2.x'
23
23
 
24
24
  spec.add_development_dependency 'bundler', ['>= 1.0', '< 3']
@@ -39,4 +39,7 @@ Gem::Specification.new do |spec|
39
39
 
40
40
  # Semantic versioning rake tasks
41
41
  spec.add_development_dependency 'semmy', '~> 1.0'
42
+
43
+ # Freeze time in tests
44
+ spec.add_development_dependency 'timecop', '~> 0.7.1'
42
45
  end
@@ -2,6 +2,12 @@ FactoryBot.modify do
2
2
  fixtures = Pageflow::LinkmapPage::Engine.root.join('spec', 'support', 'fixtures')
3
3
 
4
4
  factory :image_file do
5
+ trait :not_yet_uploaded do
6
+ attachment { nil }
7
+ file_name { 'image.jpg' }
8
+ state { 'uploading' }
9
+ end
10
+
5
11
  trait :red_fixture do
6
12
  attachment { File.open(fixtures.join('red.png')) }
7
13
  end
@@ -2,11 +2,31 @@ require 'spec_helper'
2
2
 
3
3
  module Pageflow
4
4
  module LinkmapPage
5
- describe ColorMapFile, inline_resque: true do
5
+ describe ColorMapFile, perform_jobs: :except_enqued_at do
6
6
  let(:red_from_palette) { 'f65b57' }
7
7
  let(:green_from_palette) { '69a77b' }
8
8
 
9
9
  describe 'process' do
10
+ it 're-schedules job if source image file is not uploaded yet' do
11
+ image_file = create(:image_file, :not_yet_uploaded)
12
+ color_map_file = create(:color_map_file, source_image_file: image_file)
13
+
14
+ color_map_file.process
15
+
16
+ expect(ProcessSourceImageFileJob)
17
+ .to have_been_enqueued.at(3.seconds.from_now)
18
+ end
19
+
20
+ it 'fails if source image file failed' do
21
+ image_file = create(:image_file, :uploading_failed)
22
+ color_map_file = create(:color_map_file, source_image_file: image_file)
23
+
24
+ color_map_file.process
25
+ color_map_file.reload
26
+
27
+ expect(color_map_file).to be_failed
28
+ end
29
+
10
30
  it 'remaps colors to fixed palette' do
11
31
  image_file = create(:image_file, :red_fixture)
12
32
  color_map_file = create(:color_map_file, source_image_file: image_file)
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module Pageflow
4
4
  module LinkmapPage
5
- describe MaskedImageFile, inline_resque: true do
5
+ describe MaskedImageFile, perform_jobs: :except_enqued_at do
6
6
  let :color_map_file do
7
7
  color_map_image_file = create(:image_file, :color_map_fixture)
8
8
 
@@ -29,6 +29,54 @@ module Pageflow
29
29
  let(:color_of_source_image) { '#ff0000' }
30
30
 
31
31
  describe 'process' do
32
+ it 're-schedules job if source image file is not uploaded yet' do
33
+ image_file = create(:image_file, :not_yet_uploaded)
34
+ masked_image_file = create(:masked_image_file,
35
+ color_map_file: color_map_file,
36
+ source_image_file: image_file)
37
+
38
+ masked_image_file.process
39
+
40
+ expect(ProcessSourceImageFileJob)
41
+ .to have_been_enqueued.at(3.seconds.from_now)
42
+ end
43
+
44
+ it 're-schedules job if color map file is not ready yet' do
45
+ color_map_file = create(:color_map_file, state: 'processing')
46
+ masked_image_file = create(:masked_image_file,
47
+ color_map_file: color_map_file,
48
+ source_image_file: single_color_source_image_file)
49
+
50
+ masked_image_file.process
51
+
52
+ expect(ProcessSourceImageFileJob)
53
+ .to have_been_enqueued.at(3.seconds.from_now)
54
+ end
55
+
56
+ it 'fails if source image file failed' do
57
+ image_file = create(:image_file, :uploading_failed)
58
+ masked_image_file = create(:masked_image_file,
59
+ color_map_file: color_map_file,
60
+ source_image_file: image_file)
61
+
62
+ masked_image_file.process
63
+ masked_image_file.reload
64
+
65
+ expect(masked_image_file).to be_failed
66
+ end
67
+
68
+ it 'fails if color map file failed' do
69
+ color_map_file = create(:color_map_file, state: 'processing_failed')
70
+ masked_image_file = create(:masked_image_file,
71
+ color_map_file: color_map_file,
72
+ source_image_file: single_color_source_image_file)
73
+
74
+ masked_image_file.process
75
+ masked_image_file.reload
76
+
77
+ expect(masked_image_file).to be_failed
78
+ end
79
+
32
80
  it 'creates images for each color in color map masked to the area of that color' do
33
81
  masked_image_file = create(:masked_image_file,
34
82
  color_map_file: color_map_file,
@@ -9,13 +9,47 @@ module Pageflow
9
9
  output = <<-OUTPUT.unindent
10
10
  # ImageMagick pixel enumeration: 3,1,255,srgba
11
11
  0,0: (246,91,87,1) #F65B57 srgba(246,91,87,1)
12
- 1,0: (105,167,123,1) #69A77B srgba(105,167,123,1)
12
+ 1,0: (105,167,123,1) #69A77B66 srgba(105,167,123,0.4)
13
+ OUTPUT
14
+
15
+ result = Colors::ConvertOutput.parse_unique_colors(output)
16
+
17
+ expect(result).to eq(%w(69a77b66 f65b57))
18
+ end
19
+
20
+ it 'filters out transparent color' do
21
+ output = <<-OUTPUT.unindent
22
+ # ImageMagick pixel enumeration: 3,1,255,srgba
23
+ 0,0: (246,91,87,1) #F65B57 srgba(246,91,87,1)
13
24
  2,0: (0,0,0,0) #00000000 none
14
25
  OUTPUT
15
26
 
16
27
  result = Colors::ConvertOutput.parse_unique_colors(output)
17
28
 
18
- expect(result).to eq(%w(69a77b f65b57))
29
+ expect(result).to eq(%w(f65b57))
30
+ end
31
+
32
+ it 'removes trailing FF of rgba string added between ImageMagick 6.7 and 6.9' do
33
+ output = <<-OUTPUT.unindent
34
+ # ImageMagick pixel enumeration: 589,1,65535,srgba
35
+ 0,0: (0,30069,48573,65535) #0075BDFF srgba(0,117,189,1)
36
+ 1,0: (257,30069,48573,65535) #0175BDFF srgba(1,117,189,1)
37
+ OUTPUT
38
+
39
+ result = Colors::ConvertOutput.parse_unique_colors(output)
40
+
41
+ expect(result).to eq(%w(0075bd 0175bd))
42
+ end
43
+
44
+ it 'does not remove trailing FF of rgb string ' do
45
+ output = <<-OUTPUT.unindent
46
+ # ImageMagick pixel enumeration: 589,1,65535,srgba
47
+ 0,0: (0,30069,48573,65535) #0075FF srgba(0,117,255,1)
48
+ OUTPUT
49
+
50
+ result = Colors::ConvertOutput.parse_unique_colors(output)
51
+
52
+ expect(result).to eq(%w(0075ff))
19
53
  end
20
54
  end
21
55
 
@@ -0,0 +1,11 @@
1
+ RSpec.configure do |config|
2
+ config.before(:each) do |example|
3
+ ActiveJob::Base.queue_adapter = :test
4
+ queue_adapter = ActiveJob::Base.queue_adapter
5
+
6
+ queue_adapter.perform_enqueued_jobs = !!example.metadata[:perform_jobs]
7
+
8
+ queue_adapter.perform_enqueued_at_jobs = (example.metadata[:perform_jobs] &&
9
+ example.metadata[:perform_jobs] != :except_enqued_at)
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'timecop'
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:each) do
5
+ Timecop.freeze(Time.local(2013))
6
+ end
7
+
8
+ config.after(:each) do
9
+ Timecop.return
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pageflow-linkmap-page
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Codevise Solutions Ltd.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-20 00:00:00.000000000 Z
11
+ date: 2019-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pageflow
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 14.x
19
+ version: 14.3.x
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 14.x
26
+ version: 14.3.x
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pageflow-external-links
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -184,6 +184,20 @@ dependencies:
184
184
  - - "~>"
185
185
  - !ruby/object:Gem::Version
186
186
  version: '1.0'
187
+ - !ruby/object:Gem::Dependency
188
+ name: timecop
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - "~>"
192
+ - !ruby/object:Gem::Version
193
+ version: 0.7.1
194
+ type: :development
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - "~>"
199
+ - !ruby/object:Gem::Version
200
+ version: 0.7.1
187
201
  description:
188
202
  email:
189
203
  - info@codevise.de
@@ -328,9 +342,10 @@ files:
328
342
  - spec/pageflow/linkmap_page/paperclip_processors/colors_spec.rb
329
343
  - spec/pageflow/linkmap_page/progress_spec.rb
330
344
  - spec/spec_helper.rb
345
+ - spec/support/config/active_job.rb
331
346
  - spec/support/config/devise.rb
332
347
  - spec/support/config/factory_bot.rb
333
- - spec/support/config/resque.rb
348
+ - spec/support/config/timecop.rb
334
349
  - spec/support/fixtures/black_dots.png
335
350
  - spec/support/fixtures/color_map.png
336
351
  - spec/support/fixtures/dots_and_lines.png
@@ -374,9 +389,10 @@ test_files:
374
389
  - spec/pageflow/linkmap_page/paperclip_processors/colors_spec.rb
375
390
  - spec/pageflow/linkmap_page/progress_spec.rb
376
391
  - spec/spec_helper.rb
392
+ - spec/support/config/active_job.rb
377
393
  - spec/support/config/devise.rb
378
394
  - spec/support/config/factory_bot.rb
379
- - spec/support/config/resque.rb
395
+ - spec/support/config/timecop.rb
380
396
  - spec/support/fixtures/black_dots.png
381
397
  - spec/support/fixtures/color_map.png
382
398
  - spec/support/fixtures/dots_and_lines.png
@@ -1,9 +0,0 @@
1
- RSpec.configure do |config|
2
- config.before(:each, inline_resque: true) do
3
- Resque.inline = true
4
- end
5
-
6
- config.after(:each, inline_resque: true) do
7
- Resque.inline = false
8
- end
9
- end