shattered_machine 0.0.1

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 (78) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +1 -0
  4. data/.yardoc/checksums +14 -0
  5. data/.yardoc/complete +0 -0
  6. data/.yardoc/object_types +0 -0
  7. data/.yardoc/objects/root.dat +0 -0
  8. data/.yardoc/proxy_types +0 -0
  9. data/Gemfile +8 -0
  10. data/LICENSE +9 -0
  11. data/README.md +51 -0
  12. data/doc/ShatteredMachine.html +135 -0
  13. data/doc/ShatteredMachine/Brush.html +375 -0
  14. data/doc/ShatteredMachine/ChangeByte.html +367 -0
  15. data/doc/ShatteredMachine/Converter.html +327 -0
  16. data/doc/ShatteredMachine/Defect.html +369 -0
  17. data/doc/ShatteredMachine/Exchange.html +373 -0
  18. data/doc/ShatteredMachine/Glitcher.html +365 -0
  19. data/doc/ShatteredMachine/Io.html +569 -0
  20. data/doc/ShatteredMachine/Io/Paths.html +310 -0
  21. data/doc/ShatteredMachine/PixelSorter.html +381 -0
  22. data/doc/ShatteredMachine/RustyEngine.html +111 -0
  23. data/doc/ShatteredMachine/Sampler.html +361 -0
  24. data/doc/ShatteredMachine/Slim.html +389 -0
  25. data/doc/ShatteredMachine/Transpose.html +369 -0
  26. data/doc/ShatteredMachine/WrongFilter.html +367 -0
  27. data/doc/_index.html +288 -0
  28. data/doc/class_list.html +51 -0
  29. data/doc/css/common.css +1 -0
  30. data/doc/css/full_list.css +58 -0
  31. data/doc/css/style.css +497 -0
  32. data/doc/file_list.html +56 -0
  33. data/doc/frames.html +17 -0
  34. data/doc/index.html +123 -0
  35. data/doc/js/app.js +314 -0
  36. data/doc/js/full_list.js +216 -0
  37. data/doc/js/jquery.js +4 -0
  38. data/doc/method_list.html +275 -0
  39. data/doc/top-level-namespace.html +110 -0
  40. data/lib/rusty_engine/librusty_engine.dll +0 -0
  41. data/lib/rusty_engine/librusty_engine.dylib +0 -0
  42. data/lib/rusty_engine/librusty_engine.so +0 -0
  43. data/lib/rusty_engine/rusty_engine.rb +39 -0
  44. data/lib/shattered_machine.rb +11 -0
  45. data/lib/shattered_machine/brush.rb +28 -0
  46. data/lib/shattered_machine/change_byte.rb +41 -0
  47. data/lib/shattered_machine/converter.rb +20 -0
  48. data/lib/shattered_machine/defect.rb +38 -0
  49. data/lib/shattered_machine/exchange.rb +59 -0
  50. data/lib/shattered_machine/glitcher.rb +35 -0
  51. data/lib/shattered_machine/io.rb +74 -0
  52. data/lib/shattered_machine/pixel_sorter.rb +50 -0
  53. data/lib/shattered_machine/sampler.rb +100 -0
  54. data/lib/shattered_machine/slim.rb +55 -0
  55. data/lib/shattered_machine/transpose.rb +50 -0
  56. data/lib/shattered_machine/wrong_filter.rb +39 -0
  57. data/shattered_machine.gemspec +16 -0
  58. data/spec/brush_spec.rb +28 -0
  59. data/spec/change_byte_spec.rb +26 -0
  60. data/spec/converter_spec.rb +24 -0
  61. data/spec/defect_spec.rb +26 -0
  62. data/spec/exchange_spec.rb +26 -0
  63. data/spec/glitcher_spec.rb +26 -0
  64. data/spec/images/bar.PNG +0 -0
  65. data/spec/images/bar.jpeg +0 -0
  66. data/spec/images/foo.jpg +0 -0
  67. data/spec/images/foo.png +0 -0
  68. data/spec/images/fuzz.JPG +0 -0
  69. data/spec/images/pouet.JPEG +0 -0
  70. data/spec/io_spec.rb +74 -0
  71. data/spec/lib/rusty_engine_spec.rb +20 -0
  72. data/spec/pixel_sorter_spec.rb +26 -0
  73. data/spec/sampler_spec.rb +37 -0
  74. data/spec/slim_spec.rb +26 -0
  75. data/spec/spec_helper.rb +61 -0
  76. data/spec/transpose_spec.rb +26 -0
  77. data/spec/wrong_filter_spec.rb +26 -0
  78. metadata +147 -0
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # brush_spec.rb
4
+ require 'spec_helper'
5
+
6
+ RSpec.describe ShatteredMachine::Glitcher do
7
+ describe '#call' do
8
+ let(:output_file) { 'spec/images/glitch.png' }
9
+ let(:input_file) { 'spec/images/foo.png' }
10
+ let(:io) do
11
+ ShatteredMachine::Io.new(input_file, 'spec/images', 'glitch')
12
+ end
13
+ subject do
14
+ ShatteredMachine::Glitcher.new('Slim', io).call
15
+ end
16
+
17
+ after do
18
+ File.delete(output_file) if File.exist?(output_file)
19
+ end
20
+
21
+ it 'slim image' do
22
+ subject
23
+ expect(File.exist?(output_file)).to be true
24
+ end
25
+ end
26
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/spec/io_spec.rb ADDED
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ # io_spec.rb
4
+ require 'spec_helper'
5
+
6
+ RSpec.describe ShatteredMachine::Io do
7
+ describe '#png_images' do
8
+ subject do
9
+ ShatteredMachine::Io.new(input_path, 'spec/images', output_filename).png_images
10
+ end
11
+
12
+ context 'input path is a directory' do
13
+ let(:input_path) { 'spec/images' }
14
+ let(:output_filename) { 'pif' }
15
+
16
+ it 'find two png images' do
17
+ expect(subject.count).to eq(2)
18
+ expect(subject.first.input).to eq('spec/images/foo.png')
19
+ expect(subject.first.output).to eq('spec/images/piffoo.png')
20
+ end
21
+ end
22
+
23
+ context 'input path is an image' do
24
+ context 'output path is available' do
25
+ let(:input_path) { 'spec/images/foo.png' }
26
+ let(:output_filename) { 'paf' }
27
+
28
+ it 'find the correct png image' do
29
+ expect(subject.count).to eq(1)
30
+ expect(subject.first.input).to eq('spec/images/foo.png')
31
+ expect(subject.first.output).to eq('spec/images/paf.png')
32
+ end
33
+ end
34
+
35
+ context 'output path is not available' do
36
+ let(:input_path) { 'spec/images/foo.png' }
37
+ let(:output_filename) { 'foo' }
38
+
39
+ it 'find the correct png image' do
40
+ expect(subject.count).to eq(1)
41
+ expect(subject.first.output).to match %r(spec/images/foo_(\d{8})_(\d{6}).png)
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '#jpg_images' do
48
+ subject do
49
+ ShatteredMachine::Io.new(input_path, 'spec/images', output_filename).jpg_images
50
+ end
51
+
52
+ context 'input path is a directory' do
53
+ let(:input_path) { 'spec/images' }
54
+ let(:output_filename) { 'pouf' }
55
+
56
+ it 'find four jpg images' do
57
+ expect(subject.count).to eq(4)
58
+ expect(subject.first.input).to eq('spec/images/fuzz.JPG')
59
+ expect(subject.first.output).to eq('spec/images/pouffuzz.png')
60
+ end
61
+ end
62
+
63
+ context 'input path is an image' do
64
+ let(:input_path) { 'spec/images/foo.jpg' }
65
+ let(:output_filename) { 'pouet' }
66
+
67
+ it 'find the correct jpg image' do
68
+ expect(subject.count).to eq(1)
69
+ expect(subject.first.input).to eq('spec/images/foo.jpg')
70
+ expect(subject.first.output).to eq('spec/images/pouet.png')
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rusty_engine.rb
4
+ require 'spec_helper'
5
+
6
+ RSpec.describe ShatteredMachine::RustyEngine do
7
+ describe '.convert' do
8
+ let(:converted_file) { 'spec/images/converted.png' }
9
+ subject { ShatteredMachine::RustyEngine.convert('spec/images/foo.jpg', converted_file) }
10
+
11
+ after do
12
+ File.delete(converted_file) if File.exist?(converted_file)
13
+ end
14
+
15
+ it 'convert image' do
16
+ subject
17
+ expect(File.exist?(converted_file)).to be true
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # pixel_sorter_spec.rb
4
+ require 'spec_helper'
5
+
6
+ RSpec.describe ShatteredMachine::PixelSorter do
7
+ describe '#call' do
8
+ let(:output_file) { 'spec/images/sorter.png' }
9
+ let(:input_file) { 'spec/images/foo.png' }
10
+ let(:io) do
11
+ ShatteredMachine::Io.new(input_file, 'spec/images', 'sorter')
12
+ end
13
+ let(:in_img) { io.png_images.first.input }
14
+ let(:out_img) { io.png_images.first.output }
15
+ subject { ShatteredMachine::PixelSorter.new.call(in_img, out_img) }
16
+
17
+ after do
18
+ File.delete(output_file) if File.exist?(output_file)
19
+ end
20
+
21
+ it 'sort image' do
22
+ subject
23
+ expect(File.exist?(output_file)).to be true
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,37 @@
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 ADDED
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # slim_spec.rb
4
+ require 'spec_helper'
5
+
6
+ RSpec.describe ShatteredMachine::Slim do
7
+ describe '#call' do
8
+ let(:output_file) { 'spec/images/slim.png' }
9
+ let(:input_file) { 'spec/images/foo.png' }
10
+ let(:io) do
11
+ ShatteredMachine::Io.new(input_file, 'spec/images', 'slim')
12
+ end
13
+ let(:in_img) { io.png_images.first.input }
14
+ let(:out_img) { io.png_images.first.output }
15
+ subject { ShatteredMachine::Slim.new.call(in_img, out_img) }
16
+
17
+ after do
18
+ File.delete(output_file) if File.exist?(output_file)
19
+ end
20
+
21
+ it 'slim image' do
22
+ subject
23
+ expect(File.exist?(output_file)).to be true
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,61 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+ RSpec.configure do |config|
17
+ # rspec-expectations config goes here. You can use an alternate
18
+ # assertion/expectation library such as wrong or the stdlib/minitest
19
+ # assertions if you prefer.
20
+ config.expect_with :rspec do |expectations|
21
+ # This option will default to `true` in RSpec 4. It makes the `description`
22
+ # and `failure_message` of custom matchers include text for helper methods
23
+ # defined using `chain`, e.g.:
24
+ # be_bigger_than(2).and_smaller_than(4).description
25
+ # # => "be bigger than 2 and smaller than 4"
26
+ # ...rather than:
27
+ # # => "be bigger than 2"
28
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29
+ end
30
+
31
+ # rspec-mocks config goes here. You can use an alternate test double
32
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
33
+ config.mock_with :rspec do |mocks|
34
+ # Prevents you from mocking or stubbing a method that does not exist on
35
+ # a real object. This is generally recommended, and will default to
36
+ # `true` in RSpec 4.
37
+ mocks.verify_partial_doubles = true
38
+ end
39
+
40
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41
+ # have no way to turn it off -- the option exists only for backwards
42
+ # compatibility in RSpec 3). It causes shared context metadata to be
43
+ # inherited by the metadata hash of host groups and examples, rather than
44
+ # triggering implicit auto-inclusion in groups with matching metadata.
45
+ config.shared_context_metadata_behavior = :apply_to_host_groups
46
+
47
+ $LOAD_PATH.unshift File.expand_path('..', __dir__)
48
+ require 'lib/rusty_engine/rusty_engine'
49
+ require 'lib/shattered_machine/converter'
50
+ require 'lib/shattered_machine/brush'
51
+ require 'lib/shattered_machine/change_byte'
52
+ require 'lib/shattered_machine/defect'
53
+ require 'lib/shattered_machine/exchange'
54
+ require 'lib/shattered_machine/io'
55
+ require 'lib/shattered_machine/glitcher'
56
+ require 'lib/shattered_machine/pixel_sorter'
57
+ require 'lib/shattered_machine/sampler'
58
+ require 'lib/shattered_machine/slim'
59
+ require 'lib/shattered_machine/transpose'
60
+ require 'lib/shattered_machine/wrong_filter'
61
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # transpose_spec.rb
4
+ require 'spec_helper'
5
+
6
+ RSpec.describe ShatteredMachine::Transpose do
7
+ describe '#call' do
8
+ let(:output_file) { 'spec/images/transpose.png' }
9
+ let(:input_file) { 'spec/images/foo.png' }
10
+ let(:io) do
11
+ ShatteredMachine::Io.new(input_file, 'spec/images', 'transpose')
12
+ end
13
+ let(:in_img) { io.png_images.first.input }
14
+ let(:out_img) { io.png_images.first.output }
15
+ subject { ShatteredMachine::Transpose.new.call(in_img, out_img) }
16
+
17
+ after do
18
+ File.delete(output_file) if File.exist?(output_file)
19
+ end
20
+
21
+ it 'transpose image' do
22
+ subject
23
+ expect(File.exist?(output_file)).to be true
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # wrong_filter_spec.rb
4
+ require 'spec_helper'
5
+
6
+ RSpec.describe ShatteredMachine::WrongFilter do
7
+ describe '#call' do
8
+ let(:output_file) { 'spec/images/wrong_filter.png' }
9
+ let(:input_file) { 'spec/images/foo.png' }
10
+ let(:io) do
11
+ ShatteredMachine::Io.new(input_file, 'spec/images', 'wrong_filter')
12
+ end
13
+ let(:in_img) { io.png_images.first.input }
14
+ let(:out_img) { io.png_images.first.output }
15
+ subject { ShatteredMachine::WrongFilter.new.call(in_img, out_img) }
16
+
17
+ after do
18
+ File.delete(output_file) if File.exist?(output_file)
19
+ end
20
+
21
+ it 'wrong filter image' do
22
+ subject
23
+ expect(File.exist?(output_file)).to be true
24
+ end
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shattered_machine
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Flo Girardo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-05-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: yard
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
41
+ description: Shattered Machine is an easy way to glitch PNG images using different
42
+ algorithms
43
+ email: florian@barbrousse.net
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - ".yardoc/checksums"
51
+ - ".yardoc/complete"
52
+ - ".yardoc/object_types"
53
+ - ".yardoc/objects/root.dat"
54
+ - ".yardoc/proxy_types"
55
+ - Gemfile
56
+ - LICENSE
57
+ - README.md
58
+ - doc/ShatteredMachine.html
59
+ - doc/ShatteredMachine/Brush.html
60
+ - doc/ShatteredMachine/ChangeByte.html
61
+ - doc/ShatteredMachine/Converter.html
62
+ - doc/ShatteredMachine/Defect.html
63
+ - doc/ShatteredMachine/Exchange.html
64
+ - doc/ShatteredMachine/Glitcher.html
65
+ - doc/ShatteredMachine/Io.html
66
+ - doc/ShatteredMachine/Io/Paths.html
67
+ - doc/ShatteredMachine/PixelSorter.html
68
+ - doc/ShatteredMachine/RustyEngine.html
69
+ - doc/ShatteredMachine/Sampler.html
70
+ - doc/ShatteredMachine/Slim.html
71
+ - doc/ShatteredMachine/Transpose.html
72
+ - doc/ShatteredMachine/WrongFilter.html
73
+ - doc/_index.html
74
+ - doc/class_list.html
75
+ - doc/css/common.css
76
+ - doc/css/full_list.css
77
+ - doc/css/style.css
78
+ - doc/file_list.html
79
+ - doc/frames.html
80
+ - doc/index.html
81
+ - doc/js/app.js
82
+ - doc/js/full_list.js
83
+ - doc/js/jquery.js
84
+ - doc/method_list.html
85
+ - doc/top-level-namespace.html
86
+ - lib/rusty_engine/librusty_engine.dll
87
+ - lib/rusty_engine/librusty_engine.dylib
88
+ - lib/rusty_engine/librusty_engine.so
89
+ - lib/rusty_engine/rusty_engine.rb
90
+ - lib/shattered_machine.rb
91
+ - lib/shattered_machine/brush.rb
92
+ - lib/shattered_machine/change_byte.rb
93
+ - lib/shattered_machine/converter.rb
94
+ - lib/shattered_machine/defect.rb
95
+ - lib/shattered_machine/exchange.rb
96
+ - lib/shattered_machine/glitcher.rb
97
+ - lib/shattered_machine/io.rb
98
+ - lib/shattered_machine/pixel_sorter.rb
99
+ - lib/shattered_machine/sampler.rb
100
+ - lib/shattered_machine/slim.rb
101
+ - lib/shattered_machine/transpose.rb
102
+ - lib/shattered_machine/wrong_filter.rb
103
+ - shattered_machine.gemspec
104
+ - spec/brush_spec.rb
105
+ - spec/change_byte_spec.rb
106
+ - spec/converter_spec.rb
107
+ - spec/defect_spec.rb
108
+ - spec/exchange_spec.rb
109
+ - spec/glitcher_spec.rb
110
+ - spec/images/bar.PNG
111
+ - spec/images/bar.jpeg
112
+ - spec/images/foo.jpg
113
+ - spec/images/foo.png
114
+ - spec/images/fuzz.JPG
115
+ - spec/images/pouet.JPEG
116
+ - spec/io_spec.rb
117
+ - spec/lib/rusty_engine_spec.rb
118
+ - spec/pixel_sorter_spec.rb
119
+ - spec/sampler_spec.rb
120
+ - spec/slim_spec.rb
121
+ - spec/spec_helper.rb
122
+ - spec/transpose_spec.rb
123
+ - spec/wrong_filter_spec.rb
124
+ homepage: https://glitchedfactory.com/
125
+ licenses:
126
+ - MIT
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubygems_version: 3.1.4
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: Shattered Machine core engine
147
+ test_files: []