img2zpl 1.0.2 → 1.0.3
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.md +16 -1
- data/lib/img2zpl/image.rb +1 -1
- data/lib/img2zpl/version.rb +1 -1
- metadata +2 -19
- data/.github/workflows/lint-and-test.yml +0 -42
- data/.gitignore +0 -52
- data/.rspec +0 -3
- data/.rubocop.yml +0 -41
- data/.ruby-version +0 -1
- data/CONTRIBUTING.md +0 -46
- data/Gemfile +0 -11
- data/Rakefile +0 -14
- data/bin/bundle +0 -109
- data/bin/console +0 -14
- data/bin/rspec +0 -27
- data/bin/rubocop +0 -27
- data/bin/setup +0 -8
- data/img2zpl.gemspec +0 -21
- data/spec/fixtures/default.jpg +0 -0
- data/spec/img2zpl/image_spec.rb +0 -82
- data/spec/spec_helper.rb +0 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42a5f5ead2a3e78f171c686741a83b8519a3733576db28546c31aa1b150d62c5
|
4
|
+
data.tar.gz: f94755deda19a24575a70aba5ee0df8ba8a749b7b4f336fc493565154357e49c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebf7942cf02e5424ee2360eeab8f70984baac265e554071bb7f844fe90770331ff1d9de8fa64100d2db245b2967ad5fce3ddb7d2c969d19fa4128045f14691ec
|
7
|
+
data.tar.gz: 2bb8e47222414015978bb52907be65078a772de1231aedfd5165f5f11c9aa8e72acd6939989ee97725c331fde72dfabd2c6a8b03e223b5f132f3aa1ce6b53ceb
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,22 @@
|
|
1
|
-
### v1.0.
|
1
|
+
### v1.0.4 (next)
|
2
2
|
|
3
3
|
* Your contribution here
|
4
4
|
|
5
|
+
### v1.0.3 (2025/08/22)
|
6
|
+
|
7
|
+
* [#11](https://github.com/mtking2/img2zpl/pull/11): Reduce gem size by excluding test files - [@yuri-zubov](https://github.com/yuri-zubov)
|
8
|
+
* [#10](https://github.com/mtking2/img2zpl/pull/10): Fix line mutation - [@DmytroVasin](https://github.com/DmytroVasin)
|
9
|
+
|
10
|
+
### v1.0.2 (2025/05/22)
|
11
|
+
|
12
|
+
* [#9](https://github.com/mtking2/img2zpl/pull/9): Development updates and fixes - [@mtking2](https://github.com/mtking2).
|
13
|
+
* added rubocop and linted files
|
14
|
+
* added some more binstubs
|
15
|
+
* add a Github Actions workflow for linting/testing
|
16
|
+
* fix string literal issue [#7](https://github.com/mtking2/img2zpl/issues/7)
|
17
|
+
* use unary plus operator to unfreeze string per [rubocop-performance](https://docs.rubocop.org/rubocop-performance/cops_performance.html#performanceunfreezestring) recommendation
|
18
|
+
* [#8](https://github.com/mtking2/img2zpl/pull/8): Loosen mini_magick dependency - [@harmdewit](https://github.com/harmdewit).
|
19
|
+
|
5
20
|
### v1.0.1 (2019/11/05)
|
6
21
|
|
7
22
|
* [#5](https://github.com/mtking2/img2zpl/pull/5): Fix artifact bug & improve compression - [@mtking2](https://github.com/mtking2).
|
data/lib/img2zpl/image.rb
CHANGED
@@ -7,7 +7,7 @@ module Img2Zpl
|
|
7
7
|
def to_zpl(black_threshold: 0.5, invert: false, compress: true)
|
8
8
|
bytes_per_row = (width % 8).positive? ? (width / 8) + 1 : (width / 8)
|
9
9
|
byte_count = bytes_per_row * height
|
10
|
-
data, line, previous_line, byte = Array.new(4
|
10
|
+
data, line, previous_line, byte = Array.new(4) { +"" }
|
11
11
|
|
12
12
|
get_pixels.each do |row|
|
13
13
|
row.each_with_index do |column, i|
|
data/lib/img2zpl/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: img2zpl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael King
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-08-22 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: mini_magick
|
@@ -57,29 +57,12 @@ executables: []
|
|
57
57
|
extensions: []
|
58
58
|
extra_rdoc_files: []
|
59
59
|
files:
|
60
|
-
- ".github/workflows/lint-and-test.yml"
|
61
|
-
- ".gitignore"
|
62
|
-
- ".rspec"
|
63
|
-
- ".rubocop.yml"
|
64
|
-
- ".ruby-version"
|
65
60
|
- CHANGELOG.md
|
66
|
-
- CONTRIBUTING.md
|
67
|
-
- Gemfile
|
68
61
|
- LICENSE
|
69
62
|
- README.md
|
70
|
-
- Rakefile
|
71
|
-
- bin/bundle
|
72
|
-
- bin/console
|
73
|
-
- bin/rspec
|
74
|
-
- bin/rubocop
|
75
|
-
- bin/setup
|
76
|
-
- img2zpl.gemspec
|
77
63
|
- lib/img2zpl.rb
|
78
64
|
- lib/img2zpl/image.rb
|
79
65
|
- lib/img2zpl/version.rb
|
80
|
-
- spec/fixtures/default.jpg
|
81
|
-
- spec/img2zpl/image_spec.rb
|
82
|
-
- spec/spec_helper.rb
|
83
66
|
homepage: https://github.com/mtking2/img2zpl
|
84
67
|
licenses:
|
85
68
|
- MIT
|
@@ -1,42 +0,0 @@
|
|
1
|
-
name: "Lint and Test"
|
2
|
-
on:
|
3
|
-
push:
|
4
|
-
branches: [ "master" ]
|
5
|
-
pull_request:
|
6
|
-
merge_group:
|
7
|
-
workflow_dispatch:
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
|
11
|
-
rubocop:
|
12
|
-
name: Lint Ruby files
|
13
|
-
runs-on: ubuntu-latest
|
14
|
-
steps:
|
15
|
-
- name: Checkout code
|
16
|
-
uses: actions/checkout@v4
|
17
|
-
|
18
|
-
- name: Install Ruby and gems
|
19
|
-
uses: ruby/setup-ruby@v1
|
20
|
-
with:
|
21
|
-
bundler-cache: true
|
22
|
-
|
23
|
-
- name: Run Rubocop
|
24
|
-
run: bin/rubocop --format simple --format github
|
25
|
-
|
26
|
-
rspec:
|
27
|
-
name: Run RSpec
|
28
|
-
runs-on: ubuntu-latest
|
29
|
-
steps:
|
30
|
-
- name: Checkout code
|
31
|
-
uses: actions/checkout@v4
|
32
|
-
|
33
|
-
- name: Install ImageMagick
|
34
|
-
run: sudo apt-get update && sudo apt-get install -y imagemagick
|
35
|
-
|
36
|
-
- name: Install Ruby and gems
|
37
|
-
uses: ruby/setup-ruby@v1
|
38
|
-
with:
|
39
|
-
bundler-cache: true
|
40
|
-
|
41
|
-
- name: Run tests
|
42
|
-
run: bin/rspec
|
data/.gitignore
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
/.config
|
4
|
-
/coverage/
|
5
|
-
/InstalledFiles
|
6
|
-
/pkg/
|
7
|
-
/spec/reports/
|
8
|
-
/spec/examples.txt
|
9
|
-
/test/tmp/
|
10
|
-
/test/version_tmp/
|
11
|
-
/tmp/
|
12
|
-
|
13
|
-
# Used by dotenv library to load environment variables.
|
14
|
-
# .env
|
15
|
-
|
16
|
-
## Specific to RubyMotion:
|
17
|
-
.dat*
|
18
|
-
.repl_history
|
19
|
-
build/
|
20
|
-
*.bridgesupport
|
21
|
-
build-iPhoneOS/
|
22
|
-
build-iPhoneSimulator/
|
23
|
-
|
24
|
-
## Specific to RubyMotion (use of CocoaPods):
|
25
|
-
#
|
26
|
-
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
-
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
-
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
-
#
|
30
|
-
# vendor/Pods/
|
31
|
-
|
32
|
-
## Documentation cache and generated files:
|
33
|
-
/.yardoc/
|
34
|
-
/_yardoc/
|
35
|
-
/doc/
|
36
|
-
/rdoc/
|
37
|
-
|
38
|
-
## Environment normalization:
|
39
|
-
/.bundle/
|
40
|
-
/vendor/bundle
|
41
|
-
/lib/bundler/man/
|
42
|
-
|
43
|
-
# for a library or gem, you might want to ignore these files since the code is
|
44
|
-
# intended to run in multiple environments; otherwise, check them in:
|
45
|
-
Gemfile.lock
|
46
|
-
# .ruby-version
|
47
|
-
# .ruby-gemset
|
48
|
-
|
49
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
-
.rvmrc
|
51
|
-
|
52
|
-
.ruby-lsp/
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require:
|
2
|
-
- standard
|
3
|
-
plugins:
|
4
|
-
- rubocop-rspec
|
5
|
-
- rubocop-performance
|
6
|
-
|
7
|
-
inherit_gem:
|
8
|
-
standard: config/base.yml
|
9
|
-
|
10
|
-
AllCops:
|
11
|
-
NewCops: enable
|
12
|
-
StringLiteralsFrozenByDefault: false
|
13
|
-
Exclude:
|
14
|
-
- bin/**/*
|
15
|
-
- vendor/**/*
|
16
|
-
|
17
|
-
Layout/IndentationStyle:
|
18
|
-
EnforcedStyle: tabs
|
19
|
-
|
20
|
-
Layout/SpaceInsideHashLiteralBraces:
|
21
|
-
EnforcedStyle: space
|
22
|
-
|
23
|
-
Layout/EmptyLinesAroundClassBody:
|
24
|
-
EnforcedStyle: empty_lines
|
25
|
-
|
26
|
-
Layout/EmptyLinesAroundModuleBody:
|
27
|
-
EnforcedStyle: empty_lines
|
28
|
-
|
29
|
-
Layout/IndentationWidth:
|
30
|
-
Width: 1
|
31
|
-
|
32
|
-
RSpec/ExampleLength:
|
33
|
-
Enabled: true
|
34
|
-
Max: 10
|
35
|
-
|
36
|
-
RSpec/MultipleExpectations:
|
37
|
-
Enabled: true
|
38
|
-
Max: 3
|
39
|
-
|
40
|
-
Style/NilComparison:
|
41
|
-
Enabled: false
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
3.4.1
|
data/CONTRIBUTING.md
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
## Contributing
|
2
|
-
|
3
|
-
### Fork & clone the repository
|
4
|
-
|
5
|
-
```
|
6
|
-
git clone git@github.com:<your-username>/img2zpl.git
|
7
|
-
cd img2zpl
|
8
|
-
git remote add upstream git@github.com:mtking2/img2zpl.git
|
9
|
-
bin/setup
|
10
|
-
```
|
11
|
-
|
12
|
-
Then check out a working branch:
|
13
|
-
|
14
|
-
```
|
15
|
-
git checkout -b <my-working-branch>
|
16
|
-
```
|
17
|
-
|
18
|
-
### Write tests
|
19
|
-
|
20
|
-
This project uses `rspec`. After writing your tests, you can run tests with the following command:
|
21
|
-
|
22
|
-
`bundle exec rspec`
|
23
|
-
|
24
|
-
|
25
|
-
### Write code
|
26
|
-
|
27
|
-
Write your code to make your tests pass.
|
28
|
-
|
29
|
-
### Update the CHANGELOG with a description and your name
|
30
|
-
|
31
|
-
Update the CHANGELOG with the description of your code changes and your name on the line after `"* Your contribution here"`.
|
32
|
-
|
33
|
-
### Commit and push your changes
|
34
|
-
|
35
|
-
Commit and push your changes to your working branch.
|
36
|
-
|
37
|
-
```
|
38
|
-
git commit -am 'Add some feature'
|
39
|
-
git push origin <my-working-branch>
|
40
|
-
```
|
41
|
-
|
42
|
-
### Open a pull request
|
43
|
-
|
44
|
-
Open a pull request against upstream master and your working branch. Give a brief description of what your PR does and explain what the code changes do.
|
45
|
-
|
46
|
-
Thank you!
|
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "bundler"
|
3
|
-
require "bundler/gem_tasks"
|
4
|
-
|
5
|
-
Bundler.setup :default, :development
|
6
|
-
|
7
|
-
require "rspec/core"
|
8
|
-
require "rspec/core/rake_task"
|
9
|
-
|
10
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
11
|
-
spec.pattern = FileList["spec/**/*_spec.rb"]
|
12
|
-
end
|
13
|
-
|
14
|
-
task default: %i[spec]
|
data/bin/bundle
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'bundle' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "rubygems"
|
12
|
-
|
13
|
-
m = Module.new do
|
14
|
-
module_function
|
15
|
-
|
16
|
-
def invoked_as_script?
|
17
|
-
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
-
end
|
19
|
-
|
20
|
-
def env_var_version
|
21
|
-
ENV["BUNDLER_VERSION"]
|
22
|
-
end
|
23
|
-
|
24
|
-
def cli_arg_version
|
25
|
-
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
-
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
-
bundler_version = nil
|
28
|
-
update_index = nil
|
29
|
-
ARGV.each_with_index do |a, i|
|
30
|
-
if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
|
31
|
-
bundler_version = a
|
32
|
-
end
|
33
|
-
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
-
bundler_version = $1
|
35
|
-
update_index = i
|
36
|
-
end
|
37
|
-
bundler_version
|
38
|
-
end
|
39
|
-
|
40
|
-
def gemfile
|
41
|
-
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
-
return gemfile if gemfile && !gemfile.empty?
|
43
|
-
|
44
|
-
File.expand_path("../Gemfile", __dir__)
|
45
|
-
end
|
46
|
-
|
47
|
-
def lockfile
|
48
|
-
lockfile =
|
49
|
-
case File.basename(gemfile)
|
50
|
-
when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
|
51
|
-
else "#{gemfile}.lock"
|
52
|
-
end
|
53
|
-
File.expand_path(lockfile)
|
54
|
-
end
|
55
|
-
|
56
|
-
def lockfile_version
|
57
|
-
return unless File.file?(lockfile)
|
58
|
-
lockfile_contents = File.read(lockfile)
|
59
|
-
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
-
Regexp.last_match(1)
|
61
|
-
end
|
62
|
-
|
63
|
-
def bundler_requirement
|
64
|
-
@bundler_requirement ||=
|
65
|
-
env_var_version ||
|
66
|
-
cli_arg_version ||
|
67
|
-
bundler_requirement_for(lockfile_version)
|
68
|
-
end
|
69
|
-
|
70
|
-
def bundler_requirement_for(version)
|
71
|
-
return "#{Gem::Requirement.default}.a" unless version
|
72
|
-
|
73
|
-
bundler_gem_version = Gem::Version.new(version)
|
74
|
-
|
75
|
-
bundler_gem_version.approximate_recommendation
|
76
|
-
end
|
77
|
-
|
78
|
-
def load_bundler!
|
79
|
-
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
80
|
-
|
81
|
-
activate_bundler
|
82
|
-
end
|
83
|
-
|
84
|
-
def activate_bundler
|
85
|
-
gem_error = activation_error_handling do
|
86
|
-
gem "bundler", bundler_requirement
|
87
|
-
end
|
88
|
-
return if gem_error.nil?
|
89
|
-
require_error = activation_error_handling do
|
90
|
-
require "bundler/version"
|
91
|
-
end
|
92
|
-
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
93
|
-
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
|
94
|
-
exit 42
|
95
|
-
end
|
96
|
-
|
97
|
-
def activation_error_handling
|
98
|
-
yield
|
99
|
-
nil
|
100
|
-
rescue StandardError, LoadError => e
|
101
|
-
e
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
m.load_bundler!
|
106
|
-
|
107
|
-
if m.invoked_as_script?
|
108
|
-
load Gem.bin_path("bundler", "bundle")
|
109
|
-
end
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "img2zpl"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/bin/rspec
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'rspec' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
-
|
13
|
-
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
-
|
15
|
-
if File.file?(bundle_binstub)
|
16
|
-
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
-
load(bundle_binstub)
|
18
|
-
else
|
19
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
require "rubygems"
|
25
|
-
require "bundler/setup"
|
26
|
-
|
27
|
-
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/rubocop
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'rubocop' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
-
|
13
|
-
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
-
|
15
|
-
if File.file?(bundle_binstub)
|
16
|
-
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
-
load(bundle_binstub)
|
18
|
-
else
|
19
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
require "rubygems"
|
25
|
-
require "bundler/setup"
|
26
|
-
|
27
|
-
load Gem.bin_path("rubocop", "rubocop")
|
data/bin/setup
DELETED
data/img2zpl.gemspec
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
2
|
-
require "img2zpl/version"
|
3
|
-
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = "img2zpl"
|
6
|
-
spec.version = Img2Zpl::VERSION
|
7
|
-
spec.authors = ["Michael King"]
|
8
|
-
spec.email = "m.king@fastmail.com"
|
9
|
-
spec.summary = "Convert images to ZPL"
|
10
|
-
spec.description = "Ruby library to convert images to usable & printable ZPL code"
|
11
|
-
|
12
|
-
spec.homepage = "https://github.com/mtking2/img2zpl"
|
13
|
-
spec.license = "MIT"
|
14
|
-
|
15
|
-
spec.files = `git ls-files`.split($/)
|
16
|
-
spec.require_paths = ["lib"]
|
17
|
-
|
18
|
-
spec.add_dependency "mini_magick", ">= 4.9"
|
19
|
-
spec.add_development_dependency "rake", "~> 13"
|
20
|
-
spec.add_development_dependency "rspec", "~> 3.9"
|
21
|
-
end
|
data/spec/fixtures/default.jpg
DELETED
Binary file
|
data/spec/img2zpl/image_spec.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Img2Zpl::Image do # rubocop:disable RSpec/SpecFilePathFormat
|
4
|
-
subject(:image) { described_class.open("spec/fixtures/default.jpg") }
|
5
|
-
|
6
|
-
it "inherits from the MiniMagick::Image class" do
|
7
|
-
expect(described_class.respond_to?(:open)).to be true
|
8
|
-
expect(described_class.respond_to?(:read)).to be true
|
9
|
-
end
|
10
|
-
|
11
|
-
it "implements the .to_zpl method" do
|
12
|
-
expect(image.respond_to?(:to_zpl)).to be true
|
13
|
-
end
|
14
|
-
|
15
|
-
it "has the compression map" do # rubocop:disable RSpec/ExampleLength
|
16
|
-
map = image.send(:_compression_map)
|
17
|
-
expect(map).to eq({
|
18
|
-
1 => "G",
|
19
|
-
2 => "H",
|
20
|
-
3 => "I",
|
21
|
-
4 => "J",
|
22
|
-
5 => "K",
|
23
|
-
6 => "L",
|
24
|
-
7 => "M",
|
25
|
-
8 => "N",
|
26
|
-
9 => "O",
|
27
|
-
10 => "P",
|
28
|
-
11 => "Q",
|
29
|
-
12 => "R",
|
30
|
-
13 => "S",
|
31
|
-
14 => "T",
|
32
|
-
15 => "U",
|
33
|
-
16 => "V",
|
34
|
-
17 => "W",
|
35
|
-
18 => "X",
|
36
|
-
19 => "Y",
|
37
|
-
20 => "g",
|
38
|
-
40 => "h",
|
39
|
-
60 => "i",
|
40
|
-
80 => "j",
|
41
|
-
100 => "k",
|
42
|
-
120 => "l",
|
43
|
-
140 => "m",
|
44
|
-
160 => "n",
|
45
|
-
180 => "o",
|
46
|
-
200 => "p",
|
47
|
-
220 => "q",
|
48
|
-
240 => "r",
|
49
|
-
260 => "s",
|
50
|
-
280 => "t",
|
51
|
-
300 => "u",
|
52
|
-
320 => "v",
|
53
|
-
340 => "w",
|
54
|
-
360 => "x",
|
55
|
-
380 => "y",
|
56
|
-
400 => "z"
|
57
|
-
})
|
58
|
-
end
|
59
|
-
|
60
|
-
context "with example data" do
|
61
|
-
let(:example_data_sets) {
|
62
|
-
[
|
63
|
-
{ data: "00000000000000000000000000000000000000000000000000000000008", result: "hX08" },
|
64
|
-
{ data: "5555555555555ADDDDDDDDDDDDDDDDDDDDDDD", result: "S5AgID" },
|
65
|
-
{ data: "00000000FFFFFFFFFFFFFFFFFFFFFFC0000000000000000000007FFFFFFFFF", result: "N0gHFCgG07OF" }
|
66
|
-
]
|
67
|
-
}
|
68
|
-
|
69
|
-
it "properly compresses ASCII data" do
|
70
|
-
example_data_sets.each do |data_set|
|
71
|
-
data = data_set[:data]
|
72
|
-
result = data_set[:result]
|
73
|
-
image.send(:_compress, data)
|
74
|
-
expect(data).to eq(result)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
it "returns a string when calling .to_zpl" do
|
80
|
-
expect(image.to_zpl).to be_a String
|
81
|
-
end
|
82
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,101 +0,0 @@
|
|
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
|
-
require "img2zpl"
|
17
|
-
require "debug"
|
18
|
-
|
19
|
-
RSpec.configure do |config|
|
20
|
-
# rspec-expectations config goes here. You can use an alternate
|
21
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
-
# assertions if you prefer.
|
23
|
-
config.expect_with :rspec do |expectations|
|
24
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
-
# and `failure_message` of custom matchers include text for helper methods
|
26
|
-
# defined using `chain`, e.g.:
|
27
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
-
# # => "be bigger than 2 and smaller than 4"
|
29
|
-
# ...rather than:
|
30
|
-
# # => "be bigger than 2"
|
31
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
-
end
|
33
|
-
|
34
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
-
config.mock_with :rspec do |mocks|
|
37
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
-
# a real object. This is generally recommended, and will default to
|
39
|
-
# `true` in RSpec 4.
|
40
|
-
mocks.verify_partial_doubles = true
|
41
|
-
end
|
42
|
-
|
43
|
-
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
44
|
-
# have no way to turn it off -- the option exists only for backwards
|
45
|
-
# compatibility in RSpec 3). It causes shared context metadata to be
|
46
|
-
# inherited by the metadata hash of host groups and examples, rather than
|
47
|
-
# triggering implicit auto-inclusion in groups with matching metadata.
|
48
|
-
config.shared_context_metadata_behavior = :apply_to_host_groups
|
49
|
-
|
50
|
-
# The settings below are suggested to provide a good initial experience
|
51
|
-
# with RSpec, but feel free to customize to your heart's content.
|
52
|
-
# # This allows you to limit a spec run to individual examples or groups
|
53
|
-
# # you care about by tagging them with `:focus` metadata. When nothing
|
54
|
-
# # is tagged with `:focus`, all examples get run. RSpec also provides
|
55
|
-
# # aliases for `it`, `describe`, and `context` that include `:focus`
|
56
|
-
# # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
57
|
-
# config.filter_run_when_matching :focus
|
58
|
-
#
|
59
|
-
# # Allows RSpec to persist some state between runs in order to support
|
60
|
-
# # the `--only-failures` and `--next-failure` CLI options. We recommend
|
61
|
-
# # you configure your source control system to ignore this file.
|
62
|
-
# config.example_status_persistence_file_path = "spec/examples.txt"
|
63
|
-
#
|
64
|
-
# # Limits the available syntax to the non-monkey patched syntax that is
|
65
|
-
# # recommended. For more details, see:
|
66
|
-
# # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
67
|
-
# # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
68
|
-
# # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
69
|
-
# config.disable_monkey_patching!
|
70
|
-
#
|
71
|
-
# # This setting enables warnings. It's recommended, but in some cases may
|
72
|
-
# # be too noisy due to issues in dependencies.
|
73
|
-
# config.warnings = true
|
74
|
-
#
|
75
|
-
# # Many RSpec users commonly either run the entire suite or an individual
|
76
|
-
# # file, and it's useful to allow more verbose output when running an
|
77
|
-
# # individual spec file.
|
78
|
-
# if config.files_to_run.one?
|
79
|
-
# # Use the documentation formatter for detailed output,
|
80
|
-
# # unless a formatter has already been configured
|
81
|
-
# # (e.g. via a command-line flag).
|
82
|
-
# config.default_formatter = "doc"
|
83
|
-
# end
|
84
|
-
#
|
85
|
-
# # Print the 10 slowest examples and example groups at the
|
86
|
-
# # end of the spec run, to help surface which specs are running
|
87
|
-
# # particularly slow.
|
88
|
-
# config.profile_examples = 10
|
89
|
-
#
|
90
|
-
# # Run specs in random order to surface order dependencies. If you find an
|
91
|
-
# # order dependency and want to debug it, you can fix the order by providing
|
92
|
-
# # the seed, which is printed after each run.
|
93
|
-
# # --seed 1234
|
94
|
-
# config.order = :random
|
95
|
-
#
|
96
|
-
# # Seed global randomization in this process using the `--seed` CLI option.
|
97
|
-
# # Setting this allows you to use `--seed` to deterministically reproduce
|
98
|
-
# # test failures related to randomization by passing the same `--seed` value
|
99
|
-
# # as the one that triggered the failure.
|
100
|
-
# Kernel.srand config.seed
|
101
|
-
end
|