shattered_machine 0.0.3 → 0.0.8

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: 28ad50443747414310eb9007d97f618a1cdd855723df9ab2455b482eb1160b1f
4
- data.tar.gz: fba7f95d7a020f6548f6b154c9cb89cd0b4b55c6d8427ce1b319cbd2c9294e18
3
+ metadata.gz: 1ad75dfc5905cdbc60e533414420bd7846cf67017db482afe5878b7118f9445f
4
+ data.tar.gz: f0b8f2fcb73d96d7f402064e9d4fd0c766158b44ec382665c89020951a28f5ff
5
5
  SHA512:
6
- metadata.gz: 73a2d147f7f27be2db8fb92962448c3fbed6d73cb3ce6933a07234f2b3f04938f614211704e9970c585a956b3e490d366664abf120dbc745b5f3c386a6649c34
7
- data.tar.gz: 7ad0e654382ff1a24a495f7e9ca7e963a0c21ae6765c72f94770ca95c3b49a9171d03a1dd6abd3c0ff5add3f7b17fb0e3e7d48c7518e81822eef920041e30409
6
+ metadata.gz: c3bc4229e1f96bca2d135e157f62dd37b74ca28e2f5f8451fee4a57058f01807a78559ded829ed6815150c2a5a86f4778586e1918161c680838f056740a67fd6
7
+ data.tar.gz: 3e3d91ac8f54480c1179888aff957990d1ce61b65ed262b261589aa00d8ac1445d3c61a40d3133d0bb2d8eec5ae2575da7f778a20ea2893ba06f869ed0342789
data/CHANGELOG CHANGED
@@ -4,6 +4,43 @@ 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.8] - 2021-07-01
8
+ ### Added
9
+ - Icon
10
+
11
+ ### Changed
12
+ - Url of the project
13
+ - In sampler use Io output_filename instead of base_output_filename
14
+
15
+ ## [0.0.7] - 2021-06-06
16
+ ### Changed
17
+ - Privatise PNG_EXTENSIONS, JPG_EXTENSIONS and Paths in Io
18
+
19
+ ### Fixed
20
+ - Transpose algorithm
21
+ - Include missing required files in glitcher
22
+
23
+ ### Removed
24
+ - Spec files from the gem
25
+
26
+ ## [0.0.6] - 2021-05-28
27
+ ### Added
28
+ - Add Sampler in the main lib
29
+
30
+ ## [0.0.5] - 2021-05-28
31
+ ### Added
32
+ - Rusty Engine dependency in gemspec file
33
+
34
+ ## [0.0.4] - 2021-05-28
35
+ ### Added
36
+ - Acknowledgements section in README
37
+
38
+ ### Changed
39
+ - The following Sampler constant are not publically available anymore : FILTERS, SLIM_DIRECTION and BRUSH_DIRECTION
40
+
41
+ ### Fixed
42
+ - By default the Sampler now also run the Brush algorithm
43
+
7
44
  ## [0.0.3] - 2021-05-26
8
45
  ### Changed
9
46
  - Replaces Rusty Engine library with the gem encapsulating those files
data/README.md CHANGED
@@ -52,4 +52,11 @@ To install the needed dependencies you need to install the [Ruby language](https
52
52
  Then run `bundle install` to fetch the needed gems.
53
53
 
54
54
  ### Specs
55
+
55
56
  This project uses [Rspec](https://rspec.info/) for writting specs, to run them simply run `bundle rspec`
57
+
58
+ ## Acknowledgements
59
+
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
+ 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.3'
10
+ VERSION = '0.0.8'
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
@@ -5,16 +5,13 @@ module ShatteredMachine
5
5
  # A simple weay ro run one, many or all glitch algotirhm on one specific image.
6
6
  # This create a quick overview of the effect of each algo for the given image.
7
7
  class Sampler
8
- FILTERS = %w[none sub up average paeth].freeze
9
- SLIM_DIRECTION = %w[up_to_down down_to_up left_to_right right_to_left].freeze
10
- BRUSH_DIRECTION = %w[vertical vertical_inverted horizontal horizontal_inverted].freeze
11
- ALL_ALGORITHMS = %w[exchange transpose wrong_filter slim brus change_byte defect].freeze
8
+ ALL_ALGORITHMS = %w[brush change_byte defect exchange slim transpose wrong_filter].freeze
12
9
 
13
10
  # @param io [ShatteredMachine::Io] Io containing paths for images to sample
14
11
  # @param options [Hash] options for specifying which
15
12
  def initialize(io, options = {})
16
13
  @io = io
17
- @base_output_filename = options[:base_output_filename] || 'sample'
14
+ @base_output_filename = io.output_filename || 'sample'
18
15
  @algorithms_to_sample = options[:algorithms_to_sample] || ALL_ALGORITHMS
19
16
  end
20
17
 
@@ -32,6 +29,10 @@ module ShatteredMachine
32
29
 
33
30
  private
34
31
 
32
+ FILTERS = %w[none sub up average paeth].freeze
33
+ SLIM_DIRECTION = %w[up_to_down down_to_up left_to_right right_to_left].freeze
34
+ BRUSH_DIRECTION = %w[vertical vertical_inverted horizontal horizontal_inverted].freeze
35
+
35
36
  def update_io(output_filename_appendix)
36
37
  @io.output_filename = "#{@base_output_filename}_#{output_filename_appendix}"
37
38
  end
@@ -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,16 +1,25 @@
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.3'
7
+ s.version = '0.0.8'
8
+ s.required_ruby_version = '>= 2.0.0'
9
+ s.required_rubygems_version = '>= 1.8.11'
4
10
  s.summary = 'Shattered Machine core engine'
5
11
  s.description = 'Shattered Machine is an easy way to glitch PNG images using different algorithms'
6
12
  s.authors = ['Flo Girardo']
7
13
  s.email = 'florian@barbrousse.net'
8
- s.files = `git ls-files`.split($/)
14
+ s.files = `git ls-files`.split($RS).reject do |file|
15
+ file =~ %r{^spec/}
16
+ end
9
17
  s.test_files = ['spec']
10
18
  s.require_paths = ['lib']
11
19
  s.homepage =
12
- 'https://framagit.org/Radoteur/shattered-machine'
20
+ 'https://git.sr.ht/~pouet/shattered_machine'
13
21
  s.license = 'MIT'
22
+ s.add_dependency 'rusty_engine_ffi', '>=0.0.2'
14
23
  s.add_development_dependency('rspec', '~> 3')
15
24
  s.add_development_dependency('yard', '~> 0.9')
16
25
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shattered_machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.8
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-26 00:00:00.000000000 Z
11
+ date: 2021-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rusty_engine_ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.2
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -78,6 +92,8 @@ files:
78
92
  - doc/js/jquery.js
79
93
  - doc/method_list.html
80
94
  - doc/top-level-namespace.html
95
+ - icon.png
96
+ - icon.svg
81
97
  - lib/shattered_machine.rb
82
98
  - lib/shattered_machine/brush.rb
83
99
  - lib/shattered_machine/change_byte.rb
@@ -92,26 +108,7 @@ files:
92
108
  - lib/shattered_machine/transpose.rb
93
109
  - lib/shattered_machine/wrong_filter.rb
94
110
  - shattered_machine.gemspec
95
- - spec/brush_spec.rb
96
- - spec/change_byte_spec.rb
97
- - spec/converter_spec.rb
98
- - spec/defect_spec.rb
99
- - spec/exchange_spec.rb
100
- - spec/glitcher_spec.rb
101
- - spec/images/bar.PNG
102
- - spec/images/bar.jpeg
103
- - spec/images/foo.jpg
104
- - spec/images/foo.png
105
- - spec/images/fuzz.JPG
106
- - spec/images/pouet.JPEG
107
- - spec/io_spec.rb
108
- - spec/pixel_sorter_spec.rb
109
- - spec/sampler_spec.rb
110
- - spec/slim_spec.rb
111
- - spec/spec_helper.rb
112
- - spec/transpose_spec.rb
113
- - spec/wrong_filter_spec.rb
114
- homepage: https://framagit.org/Radoteur/shattered-machine
111
+ homepage: https://git.sr.ht/~pouet/shattered_machine
115
112
  licenses:
116
113
  - MIT
117
114
  metadata: {}
@@ -123,14 +120,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
120
  requirements:
124
121
  - - ">="
125
122
  - !ruby/object:Gem::Version
126
- version: '0'
123
+ version: 2.0.0
127
124
  required_rubygems_version: !ruby/object:Gem::Requirement
128
125
  requirements:
129
126
  - - ">="
130
127
  - !ruby/object:Gem::Version
131
- version: '0'
128
+ version: 1.8.11
132
129
  requirements: []
133
- rubygems_version: 3.1.4
130
+ rubygems_version: 3.2.18
134
131
  signing_key:
135
132
  specification_version: 4
136
133
  summary: Shattered Machine core engine
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,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Sampler do
6
- describe '#call' do
7
- let(:created_files) do
8
- %w[sample_exchange_average.png sample_exchange_up.png sample_slim_up_to_down.png sample_transpose_sub.png
9
- sample_wrong_filter_paeth.png sample_exchange_none.png sample_slim_down_to_up.png sample_transpose_average.png
10
- sample_transpose_up.png sample_wrong_filter_sub.png sample_change_byte.png sample_exchange_paeth.png
11
- sample_slim_left_to_right.png sample_transpose_none.png sample_wrong_filter_average.png
12
- sample_wrong_filter_up.png sample_defect.png sample_exchange_sub.png sample_slim_right_to_left.png
13
- sample_transpose_paeth.png sample_wrong_filter_none.png]
14
- end
15
- let(:output_file) { 'spec/images/sample.png' }
16
- let(:input_file) { 'spec/images/foo.png' }
17
- let(:io) { ShatteredMachine::Io.new(input_file, 'spec/images', 'sample') }
18
- subject { ShatteredMachine::Sampler.new(io).call }
19
-
20
- def output_image_full_path(file)
21
- "spec/images/#{file}"
22
- end
23
-
24
- after do
25
- created_files.each do |file|
26
- File.delete(output_image_full_path(file)) if File.exist?(output_image_full_path(file))
27
- end
28
- end
29
-
30
- it 'call sampler' do
31
- subject
32
- created_files.each do |file|
33
- expect(File.exist?(output_image_full_path(file))).to be true
34
- end
35
- end
36
- end
37
- 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