rodiff 1.0.0-x86_64-darwin → 1.1.1-x86_64-darwin
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/README.md +21 -4
- data/exe/rodiff +2 -17
- data/lib/rodiff/cli.rb +50 -68
- data/lib/rodiff/configuration.rb +98 -0
- data/lib/rodiff/error.rb +5 -0
- data/lib/rodiff/executable.rb +99 -0
- data/lib/rodiff/odiff.rb +1 -1
- data/lib/rodiff/version.rb +1 -1
- data/lib/rodiff.rb +3 -3
- metadata +22 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f10e1bf56b1b97b42115582357141cfe4804c60be4addc3412d561dc0bad3861
|
4
|
+
data.tar.gz: c85a43e2faad0ff8008a5e09abf16eca2fe0446f29abfba55f8eb892e4f469ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12997c9b9ec9600352f609eb74b664a4cc74d4a9f376e84ac1d997d133d224286d85f492f817342bbbde2143cb4e3b361523e7c82d520a1ebeb221618b985dc9
|
7
|
+
data.tar.gz: f3e34a61bd4ad6b793bca3397f7efe2c82299e71debca4c3b3d02d6525f4c7077cb562af0c92e606208e2314f5d7d823df24d5f4bde5f99da19907a9c578ecdc
|
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# rodiff
|
2
2
|
|
3
|
-
|
3
|
+
[![Version][rubygems_badge]][rubygems]
|
4
|
+
[![CI][ci_badge]][ci_workflows]
|
5
|
+
[![Coverage][coverage_badge]][coverage]
|
6
|
+
[![Maintainability][maintainability_badge]][maintainability]
|
4
7
|
|
8
|
+
A ruby image comparison tool powered by [Odiff](https://github.com/dmtrKovalenko/odiff) in OCamel.
|
5
9
|
|
6
10
|
## Motivation
|
7
11
|
|
@@ -27,7 +31,7 @@ This gem wraps the [standalone executable](https://github.com/dmtrKovalenko/odif
|
|
27
31
|
Supported platforms are:
|
28
32
|
- arm64-darwin (macos-arm64)
|
29
33
|
- x64-mingw32 (windows-x64)
|
30
|
-
- x64-mingw-
|
34
|
+
- x64-mingw-ucrt (windows-x64)
|
31
35
|
- x86_64-darwin (macos-x64)
|
32
36
|
- x86_64-linux (linux-x64)
|
33
37
|
|
@@ -35,7 +39,7 @@ Supported platforms are:
|
|
35
39
|
|
36
40
|
If you are not able to use the vendored standalone executables, a local installation of the `Odiff` executable can be configured by setting an environment variable named `ODIFF_INSTALL_DIR` to the directory path containing the executable.
|
37
41
|
|
38
|
-
For example, if you've installed `odiff`
|
42
|
+
For example, if you've installed the [`odiff-bin`](https://github.com/dmtrKovalenko/odiff#cross-platform) npm package and had the binaries downloaded at `/path/to/node_modules/bin/odiff`, then you should set your environment variable like so:
|
39
43
|
|
40
44
|
``` sh
|
41
45
|
ODIFF_INSTALL_DIR=/path/to/node_modules/bin
|
@@ -93,4 +97,17 @@ See https://bundler.io/man/bundle-config.1.html for more information.
|
|
93
97
|
## License
|
94
98
|
|
95
99
|
Rodiff is released under the [MIT License](https://opensource.org/licenses/MIT).
|
96
|
-
Odiff is released under the [MIT License](https://opensource.org/licenses/MIT).
|
100
|
+
Odiff is released under the [MIT License](https://opensource.org/licenses/MIT).
|
101
|
+
|
102
|
+
## Contributing
|
103
|
+
|
104
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/ryancyq/rodiff](https://github.com/ryancyq/rodiff).
|
105
|
+
|
106
|
+
[rubygems_badge]: https://img.shields.io/gem/v/rodiff.svg
|
107
|
+
[rubygems]: https://rubygems.org/gems/rodiff
|
108
|
+
[ci_badge]: https://github.com/ryancyq/rodiff/actions/workflows/ci.yml/badge.svg
|
109
|
+
[ci_workflows]: https://github.com/ryancyq/rodiff/actions/workflows/ci.yml
|
110
|
+
[coverage_badge]: https://codecov.io/gh/ryancyq/rodiff/graph/badge.svg?token=SYR7FSDWT5
|
111
|
+
[coverage]: https://codecov.io/gh/ryancyq/rodiff
|
112
|
+
[maintainability_badge]: https://api.codeclimate.com/v1/badges/d5b1002a1a7162f86a7a/maintainability
|
113
|
+
[maintainability]: https://codeclimate.com/github/ryancyq/rodiff/maintainability
|
data/exe/rodiff
CHANGED
@@ -1,23 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
2
|
|
4
3
|
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
5
4
|
|
6
5
|
require "rodiff/cli"
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
command = [Rodiff::CLI.executable, *ARGV]
|
11
|
-
puts "rodiff: #{command.inspect}" if verbose
|
12
|
-
|
13
|
-
if Gem.win_platform?
|
14
|
-
# use system rather than exec as exec inexplicably fails to find the executable on Windows
|
15
|
-
# see related https://github.com/rubys/sprockets-esbuild/pull/4
|
16
|
-
system(*command, exception: true)
|
17
|
-
else
|
18
|
-
exec(*command)
|
19
|
-
end
|
20
|
-
rescue Rodiff::CLI::CommandError => e
|
21
|
-
warn("ERROR: #{e.message}")
|
22
|
-
exit 1
|
23
|
-
end
|
7
|
+
# set invoked_via_subcommand to ensure default command is used
|
8
|
+
Rodiff::CLI.start(ARGV, invoked_via_subcommand: true)
|
data/lib/rodiff/cli.rb
CHANGED
@@ -1,87 +1,69 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "thor"
|
4
|
+
require "open3"
|
5
|
+
require "shellwords"
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
class CommandError < StandardError; end
|
7
|
+
require "rodiff/configuration"
|
8
|
+
require "rodiff/error"
|
9
|
+
require "rodiff/version"
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
module Rodiff
|
12
|
+
class CLI < Thor
|
13
|
+
package_name "rodiff"
|
14
|
+
|
15
|
+
default_command :compare
|
16
|
+
|
17
|
+
desc "version", "Print version"
|
18
|
+
map ["-v", "--version"] => :version
|
19
|
+
method_option :odiff, type: :boolean, required: false
|
20
|
+
def version
|
21
|
+
if options.odiff?
|
22
|
+
odiff_exec("--version")
|
23
|
+
else
|
24
|
+
say Rodiff::VERSION
|
19
25
|
end
|
20
26
|
end
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
If you're using bundler, please make sure you're on the latest bundler version:
|
29
|
-
|
30
|
-
gem install bundler
|
31
|
-
bundle update --bundler
|
28
|
+
desc "compare [BASELINE] [VARIANT] [DIFF]", "Compare VARIANT against BASELINE, output to DIFF"
|
29
|
+
method_option :verbose, type: :boolean, default: false
|
30
|
+
def compare(baseline = nil, variant = nil, diff = nil)
|
31
|
+
all_present, all_absent = args_presence(baseline, variant, diff)
|
32
|
+
raise ArgumentError, "BASELINE, VARIANT, DIFF must be provided" unless all_present ^ all_absent
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
bundle install
|
37
|
-
|
38
|
-
See `bundle lock --help` output for details.
|
39
|
-
|
40
|
-
If you're still seeing this message after taking those steps, try running
|
41
|
-
`bundle config` and ensure `force_ruby_platform` isn't set to `true`. See
|
42
|
-
https://github.com/ryancyq/rodiff#check-bundle_force_ruby_platform
|
43
|
-
for more details.
|
44
|
-
MSG
|
45
|
-
)
|
46
|
-
end
|
34
|
+
odiff_exec(baseline, variant, diff)
|
35
|
+
rescue Rodiff::Error => e
|
36
|
+
raise Thor::Error, "ERROR: #{e.message}"
|
47
37
|
end
|
48
38
|
|
49
|
-
|
50
|
-
|
51
|
-
super("ODIFF_INSTALL_DIR is set to #{install_dir}, but that directory does not exist.")
|
52
|
-
end
|
39
|
+
def self.exit_on_failure?
|
40
|
+
true
|
53
41
|
end
|
54
42
|
|
55
|
-
|
56
|
-
def platform
|
57
|
-
%i[cpu os].map { |m| Gem::Platform.local.public_send(m) }.join("-")
|
58
|
-
end
|
43
|
+
private
|
59
44
|
|
60
|
-
|
61
|
-
|
45
|
+
def config
|
46
|
+
Rodiff.configuration
|
47
|
+
end
|
62
48
|
|
63
|
-
|
49
|
+
def args_presence(*args)
|
50
|
+
args.each_with_object([true, true]) do |e, acc|
|
51
|
+
acc[0] = false if e.nil? || e == ""
|
52
|
+
acc[1] = false unless e.nil? || e == ""
|
64
53
|
end
|
54
|
+
end
|
65
55
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
exe_file = Dir.glob(exe_files_of_platforms).find do |f|
|
78
|
-
supported_platform?(File.basename(File.dirname(f)))
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
raise ExecutableNotFound.new(platform, exe_path) if exe_file.nil? || !File.exist?(exe_file)
|
83
|
-
|
84
|
-
exe_file
|
56
|
+
def odiff_exec(*cmd)
|
57
|
+
cmd_parts = []
|
58
|
+
cmd_parts << config.odiff_exe_path
|
59
|
+
cmd_parts.push(*cmd)
|
60
|
+
|
61
|
+
stdout, stderr, status = Open3.capture3(*cmd_parts)
|
62
|
+
if block_given?
|
63
|
+
yield stdout, stderr, status
|
64
|
+
else
|
65
|
+
say_error stderr unless stderr.nil? || stderr == ""
|
66
|
+
say stdout unless stdout.nil? || stdout == ""
|
85
67
|
end
|
86
68
|
end
|
87
69
|
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rodiff/error"
|
4
|
+
require "rodiff/executable"
|
5
|
+
|
6
|
+
module Rodiff
|
7
|
+
def self.configuration
|
8
|
+
@configuration ||= Rodiff::Configuration.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.configure
|
12
|
+
yield configuration
|
13
|
+
end
|
14
|
+
|
15
|
+
class Configuration
|
16
|
+
class UnknownConfiguration < Rodiff::Error; end
|
17
|
+
|
18
|
+
ATTRS = Module.new.tap { |mod| include mod }
|
19
|
+
READER_ATTRS = {
|
20
|
+
default_dir: "/"
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
ACCESSOR_ATTRS = {
|
24
|
+
include_pattern: "{*,**/*}.jpg",
|
25
|
+
exclude_pattern: "",
|
26
|
+
compare_pattern: "",
|
27
|
+
|
28
|
+
ignore_antialiasing: false,
|
29
|
+
color_threshold: 0.1,
|
30
|
+
output_diff_mask: false,
|
31
|
+
|
32
|
+
exit_code_odiff: ->(code) { code },
|
33
|
+
exit_code_error: 1,
|
34
|
+
fail_if_no_comparison: false
|
35
|
+
}.freeze
|
36
|
+
|
37
|
+
def self.generate_config(mod, path, line, attrs)
|
38
|
+
mod.module_eval(Array(attrs).join(";").to_s, path, line)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.config_attribute(name, type:)
|
42
|
+
case type
|
43
|
+
when :reader, :writer, :accessor then "attr_#{type} :#{name}"
|
44
|
+
when :proxy
|
45
|
+
<<-RUBY
|
46
|
+
def #{name}
|
47
|
+
value_for(:#{name}) { super() }
|
48
|
+
end
|
49
|
+
RUBY
|
50
|
+
else
|
51
|
+
raise ArgumentError, "unsupported type #{type.inspect}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
generate_config ATTRS, __FILE__, __LINE__, [
|
56
|
+
*READER_ATTRS.keys.map { |key| config_attribute(key, type: :reader) },
|
57
|
+
*ACCESSOR_ATTRS.keys.map { |key| config_attribute(key, type: :accessor) }
|
58
|
+
]
|
59
|
+
|
60
|
+
generate_config self, __FILE__, __LINE__, [
|
61
|
+
*READER_ATTRS.keys.map { |key| config_attribute(key, type: :proxy) },
|
62
|
+
*ACCESSOR_ATTRS.keys.map { |key| config_attribute(key, type: :proxy) }
|
63
|
+
]
|
64
|
+
|
65
|
+
def initialize
|
66
|
+
@config_overrides = {}
|
67
|
+
|
68
|
+
READER_ATTRS.each { |key, value| instance_variable_set("@#{key}", value) }
|
69
|
+
ACCESSOR_ATTRS.each { |key, value| instance_variable_set("@#{key}", value) }
|
70
|
+
end
|
71
|
+
|
72
|
+
def odiff_exe_path
|
73
|
+
@odiff_exe_path ||= Rodiff::Executable.resolve
|
74
|
+
end
|
75
|
+
|
76
|
+
def odiff_exe_path=(path)
|
77
|
+
@odiff_exe_path = Rodiff::Executable.resolve(exe_path: path)
|
78
|
+
end
|
79
|
+
|
80
|
+
def overrides(opts = {})
|
81
|
+
opts.each_key { |key| validate_config_key!(key) }
|
82
|
+
@config_overrides.merge!(opts.transform_keys(&:to_sym))
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def validate_config_key!(key)
|
88
|
+
return if READER_ATTRS.key?(key) || ACCESSOR_ATTRS.key?(key)
|
89
|
+
|
90
|
+
raise UnknownConfiguration, "unknown config #{key.inspect}"
|
91
|
+
end
|
92
|
+
|
93
|
+
def value_for(key, &block)
|
94
|
+
validate_config_key!(key)
|
95
|
+
@config_overrides.fetch(key, &block)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/lib/rodiff/error.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rodiff/odiff"
|
4
|
+
require "rodiff/error"
|
5
|
+
|
6
|
+
module Rodiff
|
7
|
+
class Executable
|
8
|
+
DEFAULT_DIR = File.expand_path(File.join(__dir__, "..", "..", "exe"))
|
9
|
+
LOCAL_INSTALL_DIR_ENV = "ODIFF_INSTALL_DIR"
|
10
|
+
|
11
|
+
class UnsupportedPlatform < Rodiff::Error
|
12
|
+
def initialize(platform)
|
13
|
+
super(
|
14
|
+
<<~MSG
|
15
|
+
odiff does not support the #{platform} platform
|
16
|
+
Please install odiff following instructions at https://github.com/dmtrKovalenko/odiff#installation
|
17
|
+
MSG
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class ExecutableNotFound < Rodiff::Error
|
23
|
+
def initialize(platform, exe_path)
|
24
|
+
super(
|
25
|
+
<<~MSG
|
26
|
+
Cannot find the odiff executable for #{platform} in #{exe_path}
|
27
|
+
|
28
|
+
If you're using bundler, please make sure you're on the latest bundler version:
|
29
|
+
|
30
|
+
gem install bundler
|
31
|
+
bundle update --bundler
|
32
|
+
|
33
|
+
Then make sure your lock file includes this platform by running:
|
34
|
+
|
35
|
+
bundle lock --add-platform #{platform}
|
36
|
+
bundle install
|
37
|
+
|
38
|
+
See `bundle lock --help` output for details.
|
39
|
+
|
40
|
+
If you're still seeing this message after taking those steps, try running
|
41
|
+
`bundle config` and ensure `force_ruby_platform` isn't set to `true`. See
|
42
|
+
https://github.com/ryancyq/rodiff#check-bundle_force_ruby_platform
|
43
|
+
for more details.
|
44
|
+
MSG
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class InstallDirectoryNotFound < Rodiff::Error
|
50
|
+
def initialize(install_dir)
|
51
|
+
super("#{LOCAL_INSTALL_DIR_ENV} is set to #{install_dir}, but that directory does not exist.")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class << self
|
56
|
+
def platform
|
57
|
+
%i[cpu os].map { |m| Gem::Platform.local.public_send(m) }.join("-")
|
58
|
+
end
|
59
|
+
|
60
|
+
def supported_platform?(platform = nil)
|
61
|
+
return Gem::Platform.match_gem?(Gem::Platform.new(platform), "rodiff") unless platform.nil?
|
62
|
+
|
63
|
+
Rodiff::Odiff::PLATFORMS.keys.any? { |p| Gem::Platform.match_gem?(Gem::Platform.new(p), "rodiff") }
|
64
|
+
end
|
65
|
+
|
66
|
+
def resolve(exe_path: DEFAULT_DIR)
|
67
|
+
if (odiff_install_dir = ENV.fetch(LOCAL_INSTALL_DIR_ENV, nil))
|
68
|
+
exe_path = odiff_install_dir
|
69
|
+
exe_file = expand_local_install_dir(odiff_install_dir)
|
70
|
+
elsif supported_platform?
|
71
|
+
exe_file = expand_bundled_dir(exe_path)
|
72
|
+
else
|
73
|
+
raise UnsupportedPlatform, platform
|
74
|
+
end
|
75
|
+
|
76
|
+
raise ExecutableNotFound.new(platform, exe_path) if exe_file.nil? || !File.exist?(exe_file)
|
77
|
+
|
78
|
+
exe_file
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def expand_local_install_dir(local_install_dir)
|
84
|
+
raise InstallDirectoryNotFound, local_install_dir unless File.directory?(local_install_dir)
|
85
|
+
|
86
|
+
warn "NOTE: using #{LOCAL_INSTALL_DIR_ENV} to find odiff executable: #{local_install_dir}"
|
87
|
+
exe_files = File.expand_path(File.join(local_install_dir, "odiff{,.exe}"))
|
88
|
+
Dir.glob(exe_files).first
|
89
|
+
end
|
90
|
+
|
91
|
+
def expand_bundled_dir(bundled_dir)
|
92
|
+
exe_files_of_platforms = File.expand_path(File.join(bundled_dir, "*", "odiff"))
|
93
|
+
Dir.glob(exe_files_of_platforms).find do |f|
|
94
|
+
supported_platform?(File.basename(File.dirname(f)))
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/rodiff/odiff.rb
CHANGED
data/lib/rodiff/version.rb
CHANGED
data/lib/rodiff.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rodiff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: x86_64-darwin
|
6
6
|
authors:
|
7
7
|
- Ryan Chang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
12
|
-
dependencies:
|
11
|
+
date: 2024-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.3.2
|
13
27
|
description:
|
14
28
|
email:
|
15
29
|
- ryancyq@gmail.com
|
@@ -25,6 +39,9 @@ files:
|
|
25
39
|
- exe/x86_64-darwin/odiff
|
26
40
|
- lib/rodiff.rb
|
27
41
|
- lib/rodiff/cli.rb
|
42
|
+
- lib/rodiff/configuration.rb
|
43
|
+
- lib/rodiff/error.rb
|
44
|
+
- lib/rodiff/executable.rb
|
28
45
|
- lib/rodiff/odiff.rb
|
29
46
|
- lib/rodiff/version.rb
|
30
47
|
homepage: https://github.com/ryancyq/rodiff
|
@@ -50,9 +67,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
67
|
- !ruby/object:Gem::Version
|
51
68
|
version: 3.2.0
|
52
69
|
requirements:
|
53
|
-
- odiff,
|
70
|
+
- odiff, >= 3.0
|
54
71
|
rubygems_version: 3.5.16
|
55
72
|
signing_key:
|
56
73
|
specification_version: 4
|
57
|
-
summary: A ruby
|
74
|
+
summary: A ruby image comparison tool powered by ODiff in OCamel
|
58
75
|
test_files: []
|