shattered_machine 0.0.5 → 0.0.9

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
  SHA256:
3
- metadata.gz: c4126d5c4ce9cf6621bf3dfb32f782e51b5e466a6a240b8a641c4e43035996a4
4
- data.tar.gz: 5234990edd459af1ef262b181538e442cb3b7a04a95885d4365ee99644d9ee95
3
+ metadata.gz: fa2427095f09159dc03f3c1e979b5da0c6ba8f3eeb533ba90f83c833228db1a8
4
+ data.tar.gz: 91cdce766748fc0a91a8adeb034d7f43d3bfad0f648afbf081860728fed58944
5
5
  SHA512:
6
- metadata.gz: 5c2e3a7c80ce5fffa328d92456f9700423f5404b03f850c6acd27fd1a2dfc90b0e99afa5d570ee36a004065c064641aee986c48d8469622bee4408430ae5df0d
7
- data.tar.gz: 4ca3e2a05ebe520d07460e2822787517b4716fd53157cc4a80e004ae0a12b34c03dff57836acaa208e28eb1ebe848873abcb961c286e7a8af8c0a6ed7dcfe561
6
+ metadata.gz: 6ae3646dbe6d48037bd58e6f6309be411f328e84a2c796075ae24221879a3550591ab0fbefc22e51ffaa2c014b09a5786736de6806b0367553bb3a64257cef2f
7
+ data.tar.gz: 54c658e615b37b1513692b3b761f54e5ead92fb728b3203b68e735541fa2e23e9e4637f9800191f29a2f7ae0ef823d691fd3776f9e72b07fbf1de26369575179
data/CHANGELOG CHANGED
@@ -4,8 +4,36 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.0.9] - 2021-08-06
8
+ ### Fixed
9
+ - Pixel sorted sort by attribute
10
+ - Sampler output filename attribute
11
+
12
+ ## [0.0.8] - 2021-07-01
13
+ ### Added
14
+ - Icon
15
+
16
+ ### Changed
17
+ - Url of the project
18
+ - In sampler use Io output_filename instead of base_output_filename
19
+
20
+ ## [0.0.7] - 2021-06-06
21
+ ### Changed
22
+ - Privatise PNG_EXTENSIONS, JPG_EXTENSIONS and Paths in Io
23
+
24
+ ### Fixed
25
+ - Transpose algorithm
26
+ - Include missing required files in glitcher
27
+
28
+ ### Removed
29
+ - Spec files from the gem
30
+
31
+ ## [0.0.6] - 2021-05-28
32
+ ### Added
33
+ - Add Sampler in the main lib
34
+
7
35
  ## [0.0.5] - 2021-05-28
8
- ### Added
36
+ ### Added
9
37
  - Rusty Engine dependency in gemspec file
10
38
 
11
39
  ## [0.0.4] - 2021-05-28
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'ffi'
4
4
  gem 'pnglitch'
5
- gem 'rusty_engine_ffi', '~> 0.0.3'
5
+ gem 'rusty_engine_ffi'
6
6
 
7
7
  group :test do
8
8
  gem 'rspec'
data/README.md CHANGED
@@ -59,3 +59,4 @@ This project uses [Rspec](https://rspec.info/) for writting specs, to run them s
59
59
 
60
60
  This gem is relying heavily on the [pnglitch gem](https://github.com/ucnv/pnglitch) and the [rusty engine gem](https://framagit.org/Radoteur/rusty_engine).
61
61
  The png image used in the specs has been created with [Ronin](https://100r.co/site/ronin.html) while the jpg one is painting from Karl Wiener.
62
+ Icons made by [Freepik](http://www.freepik.com/) from [www.flaticon.com](https://www.flaticon.com/)
data/icon.png ADDED
Binary file
data/icon.svg ADDED
@@ -0,0 +1,122 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
4
+ xmlns:cc="http://creativecommons.org/ns#"
5
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6
+ xmlns:svg="http://www.w3.org/2000/svg"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10
+ id="Layer_1"
11
+ enable-background="new 0 0 512 512"
12
+ height="512"
13
+ viewBox="0 0 512 512"
14
+ width="512"
15
+ version="1.1"
16
+ sodipodi:docname="ice.svg"
17
+ inkscape:version="1.0.2 (e86c8708, 2021-01-15)">
18
+ <metadata
19
+ id="metadata49">
20
+ <rdf:RDF>
21
+ <cc:Work
22
+ rdf:about="">
23
+ <dc:format>image/svg+xml</dc:format>
24
+ <dc:type
25
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
26
+ </cc:Work>
27
+ </rdf:RDF>
28
+ </metadata>
29
+ <defs
30
+ id="defs47" />
31
+ <sodipodi:namedview
32
+ pagecolor="#ffffff"
33
+ bordercolor="#666666"
34
+ borderopacity="1"
35
+ objecttolerance="10"
36
+ gridtolerance="10"
37
+ guidetolerance="10"
38
+ inkscape:pageopacity="0"
39
+ inkscape:pageshadow="2"
40
+ inkscape:window-width="1440"
41
+ inkscape:window-height="847"
42
+ id="namedview45"
43
+ showgrid="false"
44
+ inkscape:zoom="1.2480469"
45
+ inkscape:cx="256"
46
+ inkscape:cy="256"
47
+ inkscape:window-x="0"
48
+ inkscape:window-y="25"
49
+ inkscape:window-maximized="1"
50
+ inkscape:current-layer="g42" />
51
+ <g
52
+ id="g42">
53
+ <path
54
+ d="m235.462 7.504h-146.462l-81.5 72.994v135.887l149.808 69.115 86.841-203.064z"
55
+ fill="#bdf9ff"
56
+ id="path10"
57
+ style="fill:#aa0000" />
58
+ <path
59
+ d="m235.462 7.504h-30l8.687 74.932-80.922 191.954 24.081 11.11 86.841-203.064z"
60
+ fill="#8cf2ff"
61
+ id="path12"
62
+ style="fill:#550000" />
63
+ <path
64
+ d="m275.462 7.504 13.372 79.391-82.185 211.264 181.633 29.648 116.218-64.465v-166.494l-82.059-89.348z"
65
+ fill="#bdf9ff"
66
+ id="path14"
67
+ style="fill:#aa0000" />
68
+ <path
69
+ d="m422.441 7.5h-29.999l82.058 89.348-2.708 158.005-114.938 67.824 31.428 5.13 116.218-64.465v-166.494z"
70
+ fill="#8cf2ff"
71
+ id="path16"
72
+ style="fill:#550000" />
73
+ <path
74
+ d="m7.5 247.633 139.06 75.852 36.622 181.015h-131.72l-43.962-81.962z"
75
+ fill="#bdf9ff"
76
+ id="path18"
77
+ style="fill:#aa0000" />
78
+ <path
79
+ d="m146.56 323.485-139.06-75.852v32.359l109.06 59.488 36.622 165.02h30z"
80
+ fill="#8cf2ff"
81
+ id="path20"
82
+ style="fill:#550000" />
83
+ <path
84
+ d="m213.103 504.5-6.454-162.167 160.3 39.66 21.333 122.507z"
85
+ fill="#bdf9ff"
86
+ id="path22"
87
+ style="fill:#aa0000" />
88
+ <path
89
+ d="m366.949 381.993-160.3-39.66.803 20.176 132.305 35.608 18.525 106.383h30z"
90
+ fill="#8cf2ff"
91
+ id="path24"
92
+ style="fill:#550000" />
93
+ <path
94
+ d="m416.599 504.5-10.266-129.107 98.167-59.726v111.936l-49.083 76.897z"
95
+ fill="#bdf9ff"
96
+ id="path26"
97
+ style="fill:#aa0000" />
98
+ <path
99
+ d="m474.5 333.919v93.684l-49.083 76.897h30l49.083-76.897v-111.936z"
100
+ fill="#8cf2ff"
101
+ id="path28"
102
+ style="fill:#550000" />
103
+ <g
104
+ id="g40">
105
+ <path
106
+ d="m4.358 223.195 149.808 69.115c3.844 1.773 8.382.012 10.037-3.861l11.452-26.779c1.629-3.809-.138-8.217-3.946-9.845-3.812-1.633-8.218.139-9.845 3.946l-8.419 19.687-138.445-63.873v-127.736l76.867-68.845h136.914l7.688 66.315-62.02 145.023c-1.629 3.809.138 8.217 3.946 9.845 3.81 1.632 8.217-.14 9.845-3.946l62.804-146.856c.514-1.201.705-2.516.555-3.813l-8.687-74.932c-.438-3.783-3.643-6.637-7.45-6.637h-146.462c-1.847 0-3.628.682-5.004 1.913l-81.5 72.994c-1.588 1.424-2.496 3.455-2.496 5.588v135.887c0 2.926 1.701 5.584 4.358 6.81z"
107
+ id="path30" />
108
+ <path
109
+ d="m510.023 91.774-28.973-31.546c-2.801-3.051-7.546-3.253-10.597-.45-3.051 2.802-3.252 7.546-.45 10.597l26.997 29.395v159.156l-110.079 61.06-169.925-27.736 78.828-202.635c.49-1.261.63-2.631.405-3.965l-11.898-70.646 134.815-.004 29.222 31.816c2.801 3.051 7.546 3.253 10.597.45 3.051-2.802 3.252-7.546.45-10.597l-31.45-34.243c-1.421-1.546-3.425-2.426-5.525-2.426l-146.978.004c-4.63 0-8.168 4.165-7.396 8.746l13.028 77.353-81.434 209.337c-1.73 4.447 1.081 9.352 5.781 10.121l181.633 29.647c.401.065.806.098 1.208.098 1.267 0 2.52-.32 3.638-.941l116.218-64.465c2.384-1.322 3.862-3.833 3.862-6.559v-166.493c0-1.879-.705-3.69-1.977-5.074z"
110
+ id="path32" />
111
+ <path
112
+ d="m153.91 321.997c-.438-2.171-1.814-4.036-3.759-5.097l-139.06-75.852c-2.323-1.267-5.145-1.216-7.42.135-2.275 1.352-3.671 3.802-3.671 6.45v174.905c0 1.237.306 2.455.891 3.545l43.962 81.962c1.307 2.436 3.846 3.955 6.609 3.955h131.72c2.25 0 4.381-1.01 5.806-2.752 1.424-1.741 1.991-4.03 1.546-6.235zm-97.96 175.003-40.95-76.347v-160.386l124.901 68.129 34.112 168.604z"
113
+ id="path34" />
114
+ <path
115
+ d="m374.337 380.706c-.51-2.929-2.701-5.279-5.587-5.993l-160.299-39.66c-4.842-1.197-9.494 2.586-9.296 7.578l6.453 162.167c.16 4.023 3.468 7.202 7.494 7.202h42.898c4.143 0 7.5-3.357 7.5-7.5s-3.357-7.5-7.5-7.5h-35.69l-5.77-144.988 145.858 36.087 18.965 108.901h-90.773c-4.143 0-7.5 3.357-7.5 7.5s3.357 7.5 7.5 7.5h99.692c2.214 0 4.315-.979 5.74-2.673s2.028-3.933 1.648-6.114z"
116
+ id="path36" />
117
+ <path
118
+ d="m508.175 309.129c-2.363-1.327-5.257-1.278-7.573.131l-98.167 59.726c-2.419 1.472-3.803 4.18-3.578 7.002l10.266 129.107c.311 3.899 3.565 6.905 7.477 6.905h38.818c2.561 0 4.944-1.307 6.322-3.465l49.083-76.897c.769-1.205 1.178-2.605 1.178-4.035v-111.936c-.001-2.71-1.463-5.21-3.826-6.538zm-11.175 116.284-45.693 71.587h-27.78l-9.351-117.6 82.824-50.391z"
119
+ id="path38" />
120
+ </g>
121
+ </g>
122
+ </svg>
@@ -3,10 +3,11 @@
3
3
  require 'shattered_machine/converter'
4
4
  require 'shattered_machine/glitcher'
5
5
  require 'shattered_machine/io'
6
+ require 'shattered_machine/sampler'
6
7
 
7
8
  # main file for ShatteredMachine gem
8
9
  module ShatteredMachine
9
- VERSION = '0.0.5'
10
+ VERSION = '0.0.9'
10
11
 
11
12
  class << self
12
13
  end
@@ -1,5 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'brush'
4
+ require_relative 'change_byte'
5
+ require_relative 'defect'
6
+ require_relative 'exchange'
7
+ require_relative 'pixel_sorter'
8
+ require_relative 'slim'
9
+ require_relative 'transpose'
10
+ require_relative 'wrong_filter'
3
11
  module ShatteredMachine
4
12
  # Main class to call from glitching image.
5
13
  class Glitcher
@@ -6,10 +6,6 @@ module ShatteredMachine
6
6
  class Io
7
7
  attr_accessor :output_filename
8
8
 
9
- PNG_EXTENSIONS = ['.png', '.PNG'].freeze
10
- JPG_EXTENSIONS = ['.jpg', '.jpeg', '.JPG', '.JPEG'].freeze
11
- Paths = Struct.new(:input, :output)
12
-
13
9
  # @param input_path [string] input file or directory
14
10
  # @param output_folder [string] output directory
15
11
  # @param output_filename [string] output file name
@@ -39,6 +35,10 @@ module ShatteredMachine
39
35
 
40
36
  private
41
37
 
38
+ PNG_EXTENSIONS = ['.png', '.PNG'].freeze
39
+ JPG_EXTENSIONS = ['.jpg', '.jpeg', '.JPG', '.JPEG'].freeze
40
+ Paths = Struct.new(:input, :output)
41
+
42
42
  def single_image_io
43
43
  [Paths.new(@input_path, generate_output_filename)]
44
44
  end
@@ -43,7 +43,7 @@ module ShatteredMachine
43
43
  end
44
44
 
45
45
  def rust_formatted_sorting_by
46
- ruby_to_rust_sorting_by = { hue: '0', staturation: '1' }
46
+ ruby_to_rust_sorting_by = { hue: '0', saturation: '1' }
47
47
  ruby_to_rust_sorting_by[@sorting_by]
48
48
  end
49
49
  end
@@ -11,7 +11,7 @@ module ShatteredMachine
11
11
  # @param options [Hash] options for specifying which
12
12
  def initialize(io, options = {})
13
13
  @io = io
14
- @base_output_filename = options[:base_output_filename] || 'sample'
14
+ @base_output_filename = io.output_filename.presence || 'sample'
15
15
  @algorithms_to_sample = options[:algorithms_to_sample] || ALL_ALGORITHMS
16
16
  end
17
17
 
@@ -47,11 +47,11 @@ module ShatteredMachine
47
47
  end
48
48
 
49
49
  def half_transpose(data, qis)
50
- data[0, qis] + data[qis * 2, qis] + data[qis * 1, qis] + data[qis * 3..]
50
+ data[0, qis] + data[qis * 2, qis] + data[qis * 1, qis] + data[qis * 3..-1]
51
51
  end
52
52
 
53
53
  def full_transpose(data, qis)
54
- data[qis * 2, qis] + data[0, qis] + data[qis * 3..] + data[qis * 1, qis]
54
+ data[qis * 2, qis] + data[0, qis] + data[qis * 3..-1] + data[qis * 1, qis]
55
55
  end
56
56
  end
57
57
  end
@@ -1,17 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'English'
4
+
1
5
  Gem::Specification.new do |s|
2
6
  s.name = 'shattered_machine'
3
- s.version = '0.0.5'
7
+ s.version = '0.0.9'
4
8
  s.required_ruby_version = '>= 2.0.0'
5
9
  s.required_rubygems_version = '>= 1.8.11'
6
10
  s.summary = 'Shattered Machine core engine'
7
11
  s.description = 'Shattered Machine is an easy way to glitch PNG images using different algorithms'
8
12
  s.authors = ['Flo Girardo']
9
13
  s.email = 'florian@barbrousse.net'
10
- s.files = `git ls-files`.split($/)
14
+ s.files = `git ls-files`.split($RS).reject do |file|
15
+ file =~ %r{^spec/}
16
+ end
11
17
  s.test_files = ['spec']
12
18
  s.require_paths = ['lib']
13
19
  s.homepage =
14
- 'https://framagit.org/Radoteur/shattered-machine'
20
+ 'https://git.sr.ht/~pouet/shattered_machine'
15
21
  s.license = 'MIT'
16
22
  s.add_dependency 'rusty_engine_ffi', '>=0.0.2'
17
23
  s.add_development_dependency('rspec', '~> 3')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shattered_machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flo Girardo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-28 00:00:00.000000000 Z
11
+ date: 2021-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rusty_engine_ffi
@@ -92,6 +92,8 @@ files:
92
92
  - doc/js/jquery.js
93
93
  - doc/method_list.html
94
94
  - doc/top-level-namespace.html
95
+ - icon.png
96
+ - icon.svg
95
97
  - lib/shattered_machine.rb
96
98
  - lib/shattered_machine/brush.rb
97
99
  - lib/shattered_machine/change_byte.rb
@@ -106,26 +108,7 @@ files:
106
108
  - lib/shattered_machine/transpose.rb
107
109
  - lib/shattered_machine/wrong_filter.rb
108
110
  - shattered_machine.gemspec
109
- - spec/brush_spec.rb
110
- - spec/change_byte_spec.rb
111
- - spec/converter_spec.rb
112
- - spec/defect_spec.rb
113
- - spec/exchange_spec.rb
114
- - spec/glitcher_spec.rb
115
- - spec/images/bar.PNG
116
- - spec/images/bar.jpeg
117
- - spec/images/foo.jpg
118
- - spec/images/foo.png
119
- - spec/images/fuzz.JPG
120
- - spec/images/pouet.JPEG
121
- - spec/io_spec.rb
122
- - spec/pixel_sorter_spec.rb
123
- - spec/sampler_spec.rb
124
- - spec/slim_spec.rb
125
- - spec/spec_helper.rb
126
- - spec/transpose_spec.rb
127
- - spec/wrong_filter_spec.rb
128
- homepage: https://framagit.org/Radoteur/shattered-machine
111
+ homepage: https://git.sr.ht/~pouet/shattered_machine
129
112
  licenses:
130
113
  - MIT
131
114
  metadata: {}
data/spec/brush_spec.rb DELETED
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Brush do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/brush.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'brush')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::Brush.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'brush image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::ChangeByte do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/change_byte.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'change_byte')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::ChangeByte.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'change byte on image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Converter do
6
- describe '#call' do
7
- let(:converted_file) { 'spec/images/converted.png' }
8
- let(:input_file) { 'spec/images/foo.jpg' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'converted')
11
- end
12
- subject { ShatteredMachine::Converter.new(io).call }
13
-
14
- after do
15
- File.delete(converted_file) if File.exist?(converted_file)
16
- end
17
-
18
- it 'convert image' do
19
- subject
20
- expect(File.exist?(converted_file)).to be true
21
- end
22
- end
23
- end
data/spec/defect_spec.rb DELETED
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Defect do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/defect.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'defect')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::Defect.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'defect image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Exchange do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/exchange.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'exchange')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::Exchange.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'exchange image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Glitcher do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/glitch.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'glitch')
11
- end
12
- subject do
13
- ShatteredMachine::Glitcher.new('Slim', io).call
14
- end
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'slim image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
data/spec/images/bar.PNG DELETED
Binary file
data/spec/images/bar.jpeg DELETED
Binary file
data/spec/images/foo.jpg DELETED
Binary file
data/spec/images/foo.png DELETED
Binary file
data/spec/images/fuzz.JPG DELETED
Binary file
Binary file
data/spec/io_spec.rb DELETED
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Io do
6
- describe '#png_images' do
7
- subject do
8
- ShatteredMachine::Io.new(input_path, 'spec/images', output_filename).png_images
9
- end
10
-
11
- context 'input path is a directory' do
12
- let(:input_path) { 'spec/images' }
13
- let(:output_filename) { 'pif' }
14
-
15
- it 'find two png images' do
16
- expect(subject.count).to eq(2)
17
- expect(subject.first.input).to eq('spec/images/foo.png')
18
- expect(subject.first.output).to eq('spec/images/piffoo.png')
19
- end
20
- end
21
-
22
- context 'input path is an image' do
23
- context 'output path is available' do
24
- let(:input_path) { 'spec/images/foo.png' }
25
- let(:output_filename) { 'paf' }
26
-
27
- it 'find the correct png image' do
28
- expect(subject.count).to eq(1)
29
- expect(subject.first.input).to eq('spec/images/foo.png')
30
- expect(subject.first.output).to eq('spec/images/paf.png')
31
- end
32
- end
33
-
34
- context 'output path is not available' do
35
- let(:input_path) { 'spec/images/foo.png' }
36
- let(:output_filename) { 'foo' }
37
-
38
- it 'find the correct png image' do
39
- expect(subject.count).to eq(1)
40
- expect(subject.first.output).to match %r(spec/images/foo_(\d{8})_(\d{6}).png)
41
- end
42
- end
43
- end
44
- end
45
-
46
- describe '#jpg_images' do
47
- subject do
48
- ShatteredMachine::Io.new(input_path, 'spec/images', output_filename).jpg_images
49
- end
50
-
51
- context 'input path is a directory' do
52
- let(:input_path) { 'spec/images' }
53
- let(:output_filename) { 'pouf' }
54
-
55
- it 'find four jpg images' do
56
- expect(subject.count).to eq(4)
57
- expect(subject.first.input).to eq('spec/images/fuzz.JPG')
58
- expect(subject.first.output).to eq('spec/images/pouffuzz.png')
59
- end
60
- end
61
-
62
- context 'input path is an image' do
63
- let(:input_path) { 'spec/images/foo.jpg' }
64
- let(:output_filename) { 'pouet' }
65
-
66
- it 'find the correct jpg image' do
67
- expect(subject.count).to eq(1)
68
- expect(subject.first.input).to eq('spec/images/foo.jpg')
69
- expect(subject.first.output).to eq('spec/images/pouet.png')
70
- end
71
- end
72
- end
73
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::PixelSorter do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/sorter.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'sorter')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::PixelSorter.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'sort image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
data/spec/sampler_spec.rb DELETED
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Sampler do
6
- describe 'ALL_ALGORITHMS' do
7
- subject { ShatteredMachine::Sampler::ALL_ALGORITHMS }
8
- it 'returns all algorithm available in sampler' do
9
- expect(subject).to eq ['brush', 'change_byte', 'defect', 'exchange', 'slim', 'transpose', 'wrong_filter']
10
- end
11
- end
12
-
13
- describe '#call' do
14
- let(:created_files) do
15
- %w[sample_exchange_average.png sample_exchange_up.png sample_slim_up_to_down.png sample_transpose_sub.png
16
- sample_wrong_filter_paeth.png sample_exchange_none.png sample_slim_down_to_up.png sample_transpose_average.png
17
- sample_transpose_up.png sample_wrong_filter_sub.png sample_change_byte.png sample_exchange_paeth.png
18
- sample_slim_left_to_right.png sample_transpose_none.png sample_wrong_filter_average.png
19
- sample_wrong_filter_up.png sample_defect.png sample_exchange_sub.png sample_slim_right_to_left.png
20
- sample_transpose_paeth.png sample_wrong_filter_none.png sample_brush_horizontal_inverted.png
21
- sample_brush_horizontal.png sample_brush_vertical_inverted.png sample_brush_vertical.png]
22
- end
23
- let(:output_file) { 'spec/images/sample.png' }
24
- let(:input_file) { 'spec/images/foo.png' }
25
- let(:io) { ShatteredMachine::Io.new(input_file, 'spec/images', 'sample') }
26
- subject { ShatteredMachine::Sampler.new(io).call }
27
-
28
- def output_image_full_path(file)
29
- "spec/images/#{file}"
30
- end
31
-
32
- after do
33
- created_files.each do |file|
34
- File.delete(output_image_full_path(file)) if File.exist?(output_image_full_path(file))
35
- end
36
- end
37
-
38
- it 'call sampler' do
39
- subject
40
- created_files.each do |file|
41
- expect(File.exist?(output_image_full_path(file))).to be true
42
- end
43
- end
44
- end
45
- end
data/spec/slim_spec.rb DELETED
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Slim do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/slim.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'slim')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::Slim.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'slim image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
data/spec/spec_helper.rb DELETED
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.configure do |config|
4
- config.expect_with :rspec do |expectations|
5
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
6
- end
7
-
8
- config.mock_with :rspec do |mocks|
9
- mocks.verify_partial_doubles = true
10
- end
11
-
12
- config.shared_context_metadata_behavior = :apply_to_host_groups
13
-
14
- $LOAD_PATH.unshift File.expand_path('..', __dir__)
15
- require 'lib/shattered_machine/converter'
16
- require 'lib/shattered_machine/brush'
17
- require 'lib/shattered_machine/change_byte'
18
- require 'lib/shattered_machine/defect'
19
- require 'lib/shattered_machine/exchange'
20
- require 'lib/shattered_machine/io'
21
- require 'lib/shattered_machine/glitcher'
22
- require 'lib/shattered_machine/pixel_sorter'
23
- require 'lib/shattered_machine/sampler'
24
- require 'lib/shattered_machine/slim'
25
- require 'lib/shattered_machine/transpose'
26
- require 'lib/shattered_machine/wrong_filter'
27
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Transpose do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/transpose.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'transpose')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::Transpose.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'transpose image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::WrongFilter do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/wrong_filter.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'wrong_filter')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::WrongFilter.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'wrong filter image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end