shattered_machine 0.0.6 → 0.1.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 +4 -4
- data/CHANGELOG +34 -0
- data/Gemfile +1 -1
- data/README.md +19 -0
- data/doc/ShatteredMachine.html +5 -7
- data/doc/ShatteredMachine/Brush.html +2 -2
- data/doc/ShatteredMachine/ChangeByte.html +1 -1
- data/doc/ShatteredMachine/Converter.html +2 -2
- data/doc/ShatteredMachine/Defect.html +1 -1
- data/doc/ShatteredMachine/Exchange.html +1 -1
- data/doc/ShatteredMachine/Glitcher.html +13 -13
- data/doc/ShatteredMachine/Io.html +23 -44
- data/doc/ShatteredMachine/Io/Paths.html +1 -187
- data/doc/ShatteredMachine/PixelSorter.html +2 -2
- data/doc/ShatteredMachine/ProgressivePixelSorter.html +318 -0
- data/doc/ShatteredMachine/Sampler.html +14 -29
- data/doc/ShatteredMachine/Slim.html +3 -3
- data/doc/ShatteredMachine/Transpose.html +1 -1
- data/doc/ShatteredMachine/WrongFilter.html +1 -1
- data/doc/_index.html +5 -13
- data/doc/class_list.html +1 -1
- data/doc/index.html +50 -17
- data/doc/method_list.html +48 -48
- data/doc/top-level-namespace.html +1 -1
- data/icon.png +0 -0
- data/icon.svg +122 -0
- data/lib/shattered_machine.rb +2 -1
- data/lib/shattered_machine/glitcher.rb +8 -0
- data/lib/shattered_machine/io.rb +4 -4
- data/lib/shattered_machine/pixel_sorter.rb +1 -1
- data/lib/shattered_machine/progressive_pixel_sorter.rb +66 -0
- data/lib/shattered_machine/sampler.rb +4 -5
- data/lib/shattered_machine/slim.rb +4 -2
- data/lib/shattered_machine/transpose.rb +2 -2
- data/shattered_machine.gemspec +9 -3
- metadata +7 -22
- data/spec/brush_spec.rb +0 -25
- data/spec/change_byte_spec.rb +0 -25
- data/spec/converter_spec.rb +0 -23
- data/spec/defect_spec.rb +0 -25
- data/spec/exchange_spec.rb +0 -25
- data/spec/glitcher_spec.rb +0 -25
- data/spec/images/bar.PNG +0 -0
- data/spec/images/bar.jpeg +0 -0
- data/spec/images/foo.jpg +0 -0
- data/spec/images/foo.png +0 -0
- data/spec/images/fuzz.JPG +0 -0
- data/spec/images/pouet.JPEG +0 -0
- data/spec/io_spec.rb +0 -73
- data/spec/pixel_sorter_spec.rb +0 -25
- data/spec/sampler_spec.rb +0 -45
- data/spec/slim_spec.rb +0 -25
- data/spec/spec_helper.rb +0 -27
- data/spec/transpose_spec.rb +0 -25
- data/spec/wrong_filter_spec.rb +0 -25
    
        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 | 
    
        data/spec/images/pouet.JPEG
    DELETED
    
    | 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
         | 
    
        data/spec/pixel_sorter_spec.rb
    DELETED
    
    | @@ -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
         | 
    
        data/spec/transpose_spec.rb
    DELETED
    
    | @@ -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
         | 
    
        data/spec/wrong_filter_spec.rb
    DELETED
    
    | @@ -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
         |