gubbins-shell 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.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +19 -0
  3. data/LICENSE +289 -0
  4. data/README.md +186 -0
  5. data/lib/gubbins/shell.rb +4 -0
  6. data/lib/shell/all.rb +34 -0
  7. data/lib/shell/base_64.rb +40 -0
  8. data/lib/shell/clam_av.rb +68 -0
  9. data/lib/shell/command.rb +1400 -0
  10. data/lib/shell/convert.rb +312 -0
  11. data/lib/shell/errors.rb +89 -0
  12. data/lib/shell/exiftool.rb +15 -0
  13. data/lib/shell/file.rb +84 -0
  14. data/lib/shell/ghostscript.rb +239 -0
  15. data/lib/shell/identify.rb +111 -0
  16. data/lib/shell/img2_pdf.rb +47 -0
  17. data/lib/shell/magick.rb +111 -0
  18. data/lib/shell/open_ssl.rb +26 -0
  19. data/lib/shell/optional_dependencies.rb +36 -0
  20. data/lib/shell/path.rb +40 -0
  21. data/lib/shell/pdf_detach.rb +86 -0
  22. data/lib/shell/pdffonts.rb +73 -0
  23. data/lib/shell/pdfimages.rb +48 -0
  24. data/lib/shell/pdfinfo.rb +79 -0
  25. data/lib/shell/pdftocairo.rb +24 -0
  26. data/lib/shell/pdftotext.rb +32 -0
  27. data/lib/shell/ping.rb +50 -0
  28. data/lib/shell/power_array.rb +42 -0
  29. data/lib/shell/seven_zip.rb +142 -0
  30. data/lib/shell/tesseract.rb +120 -0
  31. data/lib/shell/testing/mock/shell/clam_av.rb +12 -0
  32. data/lib/shell/testing/mock/shell/command.rb +241 -0
  33. data/lib/shell/testing/mock/shell/configurator.rb +223 -0
  34. data/lib/shell/testing/mock/shell/convert.rb +12 -0
  35. data/lib/shell/testing/mock/shell/file.rb +12 -0
  36. data/lib/shell/testing/mock/shell/ghostscript.rb +13 -0
  37. data/lib/shell/testing/mock/shell/identify.rb +11 -0
  38. data/lib/shell/testing/mock/shell/open_ssl.rb +11 -0
  39. data/lib/shell/testing/mock/shell/tesseract.rb +12 -0
  40. data/lib/shell/testing/mock/shell/unzip.rb +20 -0
  41. data/lib/shell/testing/mock/shell/zip.rb +11 -0
  42. data/lib/shell/testing.rb +15 -0
  43. data/lib/shell/tiff_2_pdf.rb +19 -0
  44. data/lib/shell/unzip.rb +137 -0
  45. data/lib/shell/version.rb +5 -0
  46. data/lib/shell/zbar.rb +123 -0
  47. data/lib/shell/zip.rb +52 -0
  48. data/lib/shell.rb +16 -0
  49. metadata +116 -0
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "command"
4
+
5
+ module Mock
6
+ module Shell
7
+ class ClamAv < Command
8
+ mock_method :safe, default_value: true
9
+ mock_method :safe?, default_value: true, return_command_result: false
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,241 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support"
4
+ require "active_support/core_ext/object/try"
5
+ require "active_support/core_ext/string/inflections"
6
+ require_relative "configurator"
7
+
8
+ module Mock
9
+ module Shell
10
+ # This is a base class for easily making `Shell::Command` wrappers mockable.
11
+ #
12
+ # ## A simple example
13
+ #
14
+ # We have a `Shell::ClamAv` wrapper class we wish to make mockable. The class has
15
+ # two class methods, `.safe` and `.safe?`. `.safe` returns a `Shell::Command::Result`,
16
+ # `.safe?` only returns a Boolean.
17
+ #
18
+ # ```ruby
19
+ # Shell::ClamAv.safe("/path/to/file")
20
+ # # => Shell::Command::Result
21
+ # Shell::ClamAv.safe?("/path/to/file")
22
+ # # => true
23
+ # ```
24
+ #
25
+ # To make it mockable, we create an identically named class in the `Mock::Shell` namespace:
26
+ #
27
+ # ```ruby
28
+ # module Mock
29
+ # module Shell
30
+ # class ClamAv
31
+ # mock_method :safe, default_value: true
32
+ # mock_method :safe?, default_value: true, return_command_result: false
33
+ # end
34
+ # end
35
+ # end
36
+ # ```
37
+ #
38
+ # By default, every value the mock returns is wrapped in a mock of `Shell::Command::Result`,
39
+ # just like the real thing. Since `.safe?` returns a boolean, we disable that wrapping with
40
+ # `return_command_result: false`. We also configure a default value, which will be returned
41
+ # whenever the mock is installed without any other configuration.
42
+ #
43
+ # This mock can now be installed to return the default value "true" with:
44
+ #
45
+ # ```ruby
46
+ # Mock::Shell::ClamAv.new.safe
47
+ # # or, alternatively:
48
+ # Mock::Shell::ClamAv.on(:safe)
49
+ # # ... with the return value being a mock of `Shell::Command::Result`
50
+ #
51
+ # # If we want to further customize the mock, we pass a block
52
+ # Mock::Shell::ClamAv.on(:safe) do |config|
53
+ # # `config` is a `Mock::Shell::Configurator` instance.
54
+ # # Make it return different values on subsequent calls:
55
+ # config.return_value true, false, true
56
+ # end
57
+ # # or, alternatively:
58
+ # Mock::Shell::ClamAv.on(:safe) do
59
+ # # If our block does not accept the `config` parameter, the scope
60
+ # # is set to the `Mock::Shell::Configurator` instance instead.
61
+ # # Make it return different values on subsequent calls:
62
+ # return_value true, false, true
63
+ # end
64
+ #
65
+ # # The returned command result can be made unsuccessful:
66
+ # Mock::Shell::ClamAv.on(:safe, successful: false) do
67
+ # return_value false
68
+ # end
69
+ # ```
70
+ #
71
+ # ```ruby
72
+ # module Mock
73
+ # module Shell
74
+ # class ClamAv
75
+ # # By default, return values are automatically wrapped in a mock of
76
+ # # `Shell::Command::Result`, just like a real return value.
77
+ # # `default_value` is what's being returned in `Shell::Command::Result#value`
78
+ # # if no return value is specified when the mock is installed.
79
+ # mock_method :safe, default_value: true
80
+ # # `.safe?` returns a Boolean, so we turn off the automatic wrapping
81
+ # mock_method :safe?, return_command_result: false, default_value: true
82
+ # end
83
+ # end
84
+ # end
85
+ # ```
86
+ class Command
87
+ class Result
88
+ include RSpec::Mocks::ExampleMethods
89
+
90
+ def self.build(successful: true, value: nil)
91
+ new.build(successful: successful, value: value)
92
+ end
93
+
94
+ def build(successful: true, value: nil)
95
+ instance = instance_double("Shell::Command::Result")
96
+
97
+ allow(instance).to receive(:value).and_return(value)
98
+ allow(instance).to receive(:command).and_return("")
99
+ allow(instance).to receive(:status) { successful ? 0 : 1 }
100
+ allow(instance).to receive(:success?).and_return(successful)
101
+ allow(instance).to receive(:failure?).and_return(!successful)
102
+ allow(instance).to receive(:on_success) { |&block| block.call(instance) if successful }
103
+ allow(instance).to receive(:on_failure) { |&block| block.call(instance) if !successful }
104
+ allow(instance).to receive(:raise_failures) do
105
+ raise Errors::Shell::CommandUnsuccessful unless successful
106
+ instance
107
+ end
108
+
109
+ instance
110
+ end
111
+ end
112
+
113
+ # DSL macro method for quickly mocking a `Shell::Command` class method
114
+ #
115
+ # @example
116
+ # We have a `Shell::ClamAv` class we wish to make mockable. The class has
117
+ # two class methods, `.safe` and `.safe?`. `.safe` returns a `Shell::Command::Result`,
118
+ # `.safe?` only a Boolean.
119
+ #
120
+ # ```ruby
121
+ #
122
+ # module Mock
123
+ # module Shell
124
+ # class ClamAv
125
+ # # By default, return values are automatically wrapped in a mock of
126
+ # # `Shell::Command::Result`, just like a real return value.
127
+ # # `default_value` is what's being returned in `Shell::Command::Result#value`
128
+ # # if no return value is specified when the mock is installed.
129
+ # mock_method :safe, default_value: true
130
+ # # `.safe?` returns a Boolean, so we turn off the automatic wrapping
131
+ # mock_method :safe?, return_command_result: false, default_value: true
132
+ # end
133
+ # end
134
+ # end
135
+ # ```
136
+ #
137
+ # @param method_name [Symbol] the name of the `Shell::Command` class method to mock
138
+ # @param return_command_result [Boolean] wrap any given return value in a mock of
139
+ # a `Shell::Command::Result`, putting the value in `#value`
140
+ # @param default_value [Object] the value this mock will return if no other value
141
+ # is specified when the mock is installed.
142
+ # @param default_yield [Object] the value this mock will yield if no other value
143
+ # is specified when the mock is installed. Procs are supported.
144
+ # @return [void]
145
+ def self.mock_method(method_name, return_command_result: true, default_value: nil, default_yield: nil)
146
+ define_method(method_name) do |successful: true, &block|
147
+ install_mock_on(
148
+ method_name,
149
+ configure_with: block,
150
+ successful: successful,
151
+ return_command_result: return_command_result,
152
+ default_value: default_value,
153
+ default_yield: default_yield
154
+ )
155
+ end
156
+ end
157
+ private_class_method :mock_method
158
+
159
+ def self.on(method_name, successful: true, &block)
160
+ new.send(method_name, successful: successful, &block)
161
+ end
162
+
163
+ private
164
+
165
+ def build_result(successful: true, value: nil)
166
+ Result.build(successful: successful, value: value)
167
+ end
168
+
169
+ # A private method for setting up a standard class method mock
170
+ #
171
+ # @example
172
+ # ```ruby
173
+ # module Mock
174
+ # module Shell
175
+ # class File < Command
176
+ # def mime_type(&block)
177
+ # install_mock_on(:mime_type, configure_with: block, default_value: "image/jpeg")
178
+ # end
179
+ # end
180
+ # end
181
+ # end
182
+ #
183
+ # # This mock can now be installed to return the default value "image/jpeg" with ...
184
+ # Mock::Shell::File.new.mime_type
185
+ # # or, alternatively:
186
+ # Mock::Shell::File.on(:mime_type)
187
+ # # ... with the return value being a mock of `Shell::Command::Result`
188
+ #
189
+ # # If we want to further customize the mock, we pass a block
190
+ # Mock::Shell::File.on(:mime_type) do |config|
191
+ # # `config` is a `Mock::Shell::Configurator` instance
192
+ # config.return_value "image/jpeg", "image/png", "image/gif"
193
+ # end
194
+ # # or, alternatively:
195
+ # Mock::Shell::File.on(:mime_type) do
196
+ # # the scope of this block is a `Mock::Shell::Configurator` instance
197
+ # return_value "image/jpeg", "image/png", "image/gif"
198
+ # end
199
+ # ```
200
+ #
201
+ # @param method_name [Symbol] the name of the `Shell::Command` class method to mock
202
+ # @param configure_with [Proc] a block that is passed along from the outer method;
203
+ # this block will be either passed a `Mock::Shell::Configurator` instance as an argument,
204
+ # or executed in its scope if it does not take a parameter.
205
+ # @param return_command_result [Boolean] wrap any given return value in a mock of
206
+ # a `Shell::Command::Result`, putting the value in `#value`
207
+ # @param successful [Boolean] whether the returned command result is successful.
208
+ # No effect if `return_command_result` is `false`
209
+ # @param default_value [Object] the value this mock will return if no other value
210
+ # is specified when the mock is installed.
211
+ # @param default_yield [Object] the value this mock will yield if no other value
212
+ # is specified when the mock is installed. Procs are supported.
213
+ # @return [void]
214
+ def install_mock_on(method_name, configure_with:, successful: true, return_command_result: true, default_value: nil, default_yield: nil)
215
+ configurator =
216
+ Configurator.new(target: target_klass, method_name: method_name)
217
+
218
+ configurator.transform_values { |value| build_result(value: value, successful: successful) } if return_command_result
219
+
220
+ if block_given?
221
+ yield configurator
222
+ end
223
+
224
+ if configure_with
225
+ if configure_with.arity == 0
226
+ configurator.instance_eval(&configure_with)
227
+ else
228
+ configure_with.call(configurator)
229
+ end
230
+ else
231
+ configurator.return_value(default_value.try(:call) || default_value) if default_value
232
+ configurator.yield_once(default_yield.try(:call) || default_yield) if default_yield
233
+ end
234
+ end
235
+
236
+ def target_klass
237
+ self.class.name.gsub(/^Mock::/, "").constantize
238
+ end
239
+ end
240
+ end
241
+ end
@@ -0,0 +1,223 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A copy of Kitchensink's `Mock::Configurator`, so that this gem does not depend on Kitchensink
4
+ module Mock
5
+ module Shell
6
+ # `Mock::Shell::Configurator` is an interface object for configuring mocks. It
7
+ # is supposed to be yielded by methods which install mocks:
8
+ #
9
+ # ```ruby
10
+ # # We want to create a helper for mocking `SomeClass.some_class_method`:
11
+ # module Mock
12
+ # class SomeClass
13
+ # def self.some_class_method
14
+ # configurator =
15
+ # Mock::Shell::Configurator.new(target: SomeClass, method_name: :some_class_method)
16
+ #
17
+ # yield configurator
18
+ # end
19
+ # end
20
+ # end
21
+ #
22
+ # # We can now configure the mock:
23
+ # Mock::SomeClass.some_class_method do |config|
24
+ # # `config` is our `Mock::Shell::Configurator` instance
25
+ # config.return_value true
26
+ # end
27
+ #
28
+ # # Please not that, different from the example above, `Mock::Shell::` and `Mock::Fs::`
29
+ # # classes also allow you to skip the block argument when configuring a mock:
30
+ # Mock::Shell::File.on(:mime_type) do
31
+ # # Since our block does not take any arguments, the block scope
32
+ # # is set to our `Mock::Shell::Configurator` instance
33
+ # return_value true
34
+ # end
35
+ # ```
36
+ #
37
+ # The instance methods `#return_value`, `#for_arg` and `fail_with` are used
38
+ # to configure the behaviour of the mock method to be installed.
39
+ class Configurator
40
+ include RSpec::Mocks::ExampleMethods
41
+
42
+ attr_reader :target
43
+ attr_reader :method_name
44
+ attr_reader :value_transformer
45
+
46
+ # @param target [Class] the class on which to install the mock
47
+ # @param method_name [Symbol] the method to mock
48
+ def initialize(target:, method_name:)
49
+ @target = target
50
+ @method_name = method_name
51
+ end
52
+
53
+ # Configure a value transformer block
54
+ #
55
+ # The given block will be called for each value the mock is supposed
56
+ # to return, and the block return value will be returned from the mock instead.
57
+ #
58
+ # @example
59
+ # ```ruby
60
+ # # We want to create a helper for mocking `SomeClass.some_class_method`.
61
+ # # `.some_class_method` returns an object with a `.value` method. To make it easier
62
+ # # to configure the mock, we take care of that with `.transform_values`:
63
+ # module Mock
64
+ # class SomeClass
65
+ # def self.some_class_method(&block)
66
+ # configurator =
67
+ # Mock::Shell::Configurator.new(target: SomeClass, method_name: :some_class_method)
68
+ # .transform_values { |value| Struct.new(:value).new(value) }
69
+ # yield configurator
70
+ # end
71
+ # end
72
+ # end
73
+ #
74
+ # Mock::SomeClass.some_class_method { |config| config.return_value "yay", "nay" }
75
+ #
76
+ # SomeClass.some_class_method
77
+ # # => #<struct value="yay">
78
+ # SomeClass.some_class_method
79
+ # # => #<struct value="nay">
80
+ # ```
81
+ # @param block [Proc]
82
+ # @yieldparam value [Object] the value this mock is configured to return
83
+ # @yieldreturn [Object] the value your block has determined should be returned instead
84
+ # @return [self]
85
+ def transform_values(&block)
86
+ @value_transformer = block
87
+
88
+ self
89
+ end
90
+
91
+ # Configure one or more values your mock should return
92
+ #
93
+ # When providing multiple values, each consecutive call to the mock
94
+ # will return the next value. When providing a block, the block
95
+ # return value will be returned instead; the block form is especially useful if you
96
+ # need the parameters that were passed to the mocked method, as they are passed in to
97
+ # the block.
98
+ #
99
+ # See the documentation for `RSpec::Mocks::ExampleMethods#and_return` for the first
100
+ # form, and the docs for `RSpec::Mocks::ExampleMethods#receive` for the block form.
101
+ #
102
+ # @param values [Object] the value or values to be returned by the mock
103
+ # @param block [Proc] alternatively, a block whose return value will be returned from
104
+ # the mock
105
+ # @yield [Object, Object ...] any parameter the mocked method was called with
106
+ # @yieldreturn [Object] the value the mock should return
107
+ # @return [void]
108
+ def return_value(*values, &block)
109
+ if block_given?
110
+ allow(target).to receive(method_name, &block)
111
+ else
112
+ values =
113
+ values.map(&value_transformer) if value_transformer
114
+
115
+ allow(target).to receive(method_name).and_return(*values)
116
+ end
117
+ end
118
+
119
+ # Configure multiple values your mock should pass by yielding multiple times
120
+ #
121
+ # The mock will yield once with a single argument for every value.
122
+ #
123
+ # See the documentation for `RSpec::Mocks::ExampleMethods#and_yield`.
124
+ #
125
+ # @param values [Object] the value or values to be yielded by the mock
126
+ # @return [void]
127
+ def yield_several(*values)
128
+ values =
129
+ values.map(&value_transformer) if value_transformer
130
+
131
+ allow(target).to receive(method_name).tap { |proxy|
132
+ values.each do |value|
133
+ proxy.and_yield(value)
134
+ end
135
+ }
136
+ end
137
+
138
+ # Configure one or more values your mock should yield once
139
+ #
140
+ # The mock will yield a single time with one or more arguments.
141
+ #
142
+ # See the documentation for `RSpec::Mocks::ExampleMethods#and_yield`.
143
+ #
144
+ # @param values [Object] the value or values to be yielded by the mock
145
+ # @return [void]
146
+ def yield_once(*values)
147
+ values =
148
+ values.map(&value_transformer) if value_transformer
149
+
150
+ allow(target).to receive(method_name).and_yield(*values)
151
+ end
152
+
153
+ # Configure a value your mock should respond with if the mock is called with a
154
+ # given parameter
155
+ #
156
+ # When providing a block, the block return value will be returned instead; the
157
+ # block form is especially useful if you need the parameters that were passed
158
+ # to the mocked method, as they are passed in to the block.
159
+ #
160
+ # See the documentation for `RSpec::Mocks::ExampleMethods#and_return` for the first
161
+ # form, and the docs for `RSpec::Mocks::ExampleMethods#receive` for the block form.
162
+ #
163
+ # @example
164
+ # ```ruby
165
+ # Mock::SomeClass.some_class_method do |config|
166
+ # config.for_arg "foo", return_value: true
167
+ # config.for_arg "bar", return_value: false
168
+ # # You also have all of RSPecs argument matchers at your disposal
169
+ # config.for_arg array_including(5), return_value: 10
170
+ # end
171
+ #
172
+ # SomeClass.some_class_method("foo")
173
+ # => true
174
+ # SomeClass.some_class_method("bar")
175
+ # => false
176
+ # SomeClass.some_class_method([1,5,6])
177
+ # => 10
178
+ # ```
179
+ #
180
+ # @param arg [Object] the argument to be passed to the mock for which this
181
+ # value should be returned
182
+ # @param return_value [Object] the value that should be returned by the mock
183
+ # @param yield_value [Object] the value that should be yielded by the mock
184
+ # @param fail_with [StandardError, nil] an exception to be raised when the mock is
185
+ # called
186
+ # @param block [Proc] alternatively, a block whose return value will be returned from
187
+ # the mock
188
+ # @yield [Object, Object ...] any parameter the mocked method was called with
189
+ # @yieldreturn [Object] the value the mock should return
190
+ # @return [void]
191
+ def for_arg(arg, return_value: nil, yield_value: nil, fail_with: false, &block)
192
+ if block_given?
193
+ allow(target).to receive(method_name, &block).with(arg)
194
+ return
195
+ end
196
+
197
+ if fail_with
198
+ allow(target).to receive(method_name).with(arg).and_raise(fail_with)
199
+
200
+ elsif return_value
201
+ return_value =
202
+ value_transformer.call(return_value) if value_transformer
203
+
204
+ allow(target).to receive(method_name).with(arg).and_return(return_value)
205
+
206
+ elsif yield_value
207
+ yield_value =
208
+ value_transformer.call(yield_value) if value_transformer
209
+
210
+ allow(target).to receive(method_name).with(arg).and_yield(yield_value)
211
+ end
212
+ end
213
+
214
+ # Raise an exception `exception_klass` if the mock is called
215
+ #
216
+ # @param exception_klass [Class]
217
+ # @return [void]
218
+ def fail_with(exception_klass)
219
+ allow(target).to receive(method_name).and_raise(fail_with)
220
+ end
221
+ end
222
+ end
223
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "command"
4
+
5
+ module Mock
6
+ module Shell
7
+ class Convert < Command
8
+ mock_method :resample
9
+ mock_method :rotate
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "command"
4
+
5
+ module Mock
6
+ module Shell
7
+ class File < Command
8
+ mock_method :mime_type, default_value: "image/jpeg"
9
+ mock_method :mime_encoding, default_value: "us-ascii"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "command"
4
+
5
+ module Mock
6
+ module Shell
7
+ class Ghostscript < Command
8
+ mock_method :pdf_to_image
9
+ mock_method :pdf_to_images
10
+ mock_method :well_formed?, default_value: true
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "command"
4
+
5
+ module Mock
6
+ module Shell
7
+ class Identify < Command
8
+ mock_method :info, default_value: -> { {} }
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "command"
4
+
5
+ module Mock
6
+ module Shell
7
+ class OpenSsl < Command
8
+ mock_method :sha512_hexdigest, default_value: "123456"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "command"
4
+
5
+ module Mock
6
+ module Shell
7
+ class Tesseract < Command
8
+ mock_method :detect_rotation, default_value: 0
9
+ mock_method :ocr, default_value: "Lorem ipsum dolor"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "command"
4
+
5
+ module Mock
6
+ module Shell
7
+ class Unzip < Command
8
+ mock_method :to_temp,
9
+ default_value: -> { Pathname.new(Dir.tmpdir) },
10
+ default_yield: -> { Pathname.new(Dir.tmpdir) }
11
+ mock_method :to
12
+ mock_method :list,
13
+ default_value: -> { [] }
14
+ mock_method :uncompressed_size_below?,
15
+ default_value: true
16
+ mock_method :valid?,
17
+ default_value: true
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "command"
4
+
5
+ module Mock
6
+ module Shell
7
+ class Zip < Command
8
+ mock_method :from_directory, default_value: true
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Base class
4
+ require_relative "testing/mock/shell/command"
5
+
6
+ # Shell command mocks
7
+ require_relative "testing/mock/shell/clam_av"
8
+ require_relative "testing/mock/shell/convert"
9
+ require_relative "testing/mock/shell/file"
10
+ require_relative "testing/mock/shell/ghostscript"
11
+ require_relative "testing/mock/shell/identify"
12
+ require_relative "testing/mock/shell/open_ssl"
13
+ require_relative "testing/mock/shell/tesseract"
14
+ require_relative "testing/mock/shell/unzip"
15
+ require_relative "testing/mock/shell/zip"
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../shell"
4
+
5
+ module Shell
6
+ class TIFF2PDF < Command
7
+ command_path `which tiff2pdf`
8
+ transform_options output: :o
9
+
10
+ # Convert a TIFF into a PDF
11
+ #
12
+ # @param input [Pathname, Fs::File, String, Array<Pathname, Fs::File, String>] one or multiple image paths
13
+ # @param output [Pathname, Fs::File, String] where to write the output to
14
+ # @return [Shell::Command::Result]
15
+ def self.convert(input:, output:, **kargs)
16
+ exec(input, output: output, **kargs)
17
+ end
18
+ end
19
+ end