Skip to content
This repository was archived by the owner on Jul 13, 2023. It is now read-only.

Commit 3218075

Browse files
ykztssidraval
authored andcommitted
Replace cocaine to terrapin
1 parent c695055 commit 3218075

12 files changed

+35
-35
lines changed

lib/paperclip.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
require 'mimemagic'
6868
require 'mimemagic/overlay'
6969
require 'logger'
70-
require 'cocaine'
70+
require 'terrapin'
7171

7272
require 'paperclip/railtie' if defined?(Rails::Railtie)
7373

lib/paperclip/file_command_content_type_detector.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def type_from_file_command
1616
# On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
1717
type = begin
1818
Paperclip.run("file", "-b --mime :file", file: @filename)
19-
rescue Cocaine::CommandLineError => e
19+
rescue Terrapin::CommandLineError => e
2020
Paperclip.log("Error while determining content type: #{e}")
2121
SENSIBLE_DEFAULT
2222
end

lib/paperclip/geometry_detector_factory.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ def geometry_string
2424
:swallow_stderr => true
2525
}
2626
)
27-
rescue Cocaine::ExitStatusError
27+
rescue Terrapin::ExitStatusError
2828
""
29-
rescue Cocaine::CommandNotFoundError => e
29+
rescue Terrapin::CommandNotFoundError => e
3030
raise_because_imagemagick_missing
3131
end
3232
end

lib/paperclip/helpers.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def interpolates key, &block
2727
#
2828
def run(cmd, arguments = "", interpolation_values = {}, local_options = {})
2929
command_path = options[:command_path]
30-
cocaine_path_array = Cocaine::CommandLine.path.try(:split, Cocaine::OS.path_separator)
31-
Cocaine::CommandLine.path = [cocaine_path_array, command_path].flatten.compact.uniq
30+
terrapin_path_array = Terrapin::CommandLine.path.try(:split, Terrapin::OS.path_separator)
31+
Terrapin::CommandLine.path = [terrapin_path_array, command_path].flatten.compact.uniq
3232
if logging? && (options[:log_command] || local_options[:log_command])
3333
local_options = local_options.merge(:logger => logger)
3434
end
35-
Cocaine::CommandLine.new(cmd, arguments, local_options).run(interpolation_values)
35+
Terrapin::CommandLine.new(cmd, arguments, local_options).run(interpolation_values)
3636
end
3737

3838
# Find all instances of the given Active Record model +klass+ with attachment +name+.

lib/paperclip/media_type_spoof_detector.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def type_from_file_command
7474
begin
7575
Paperclip.run("file", "-b --mime :file", file: @file.path).
7676
split(/[:;\s]+/).first
77-
rescue Cocaine::CommandLineError
77+
rescue Terrapin::CommandLineError
7878
""
7979
end
8080
end

lib/paperclip/thumbnail.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ def make
8484
source: "#{File.expand_path(src.path)}#{frame}",
8585
dest: File.expand_path(dst.path),
8686
)
87-
rescue Cocaine::ExitStatusError => e
87+
rescue Terrapin::ExitStatusError => e
8888
raise Paperclip::Error, "There was an error processing the thumbnail for #{@basename}" if @whiny
89-
rescue Cocaine::CommandNotFoundError => e
89+
rescue Terrapin::CommandNotFoundError => e
9090
raise Paperclip::Errors::CommandNotFoundError.new("Could not run the `convert` command. Please install ImageMagick.")
9191
end
9292

@@ -122,9 +122,9 @@ def identified_as_animated?
122122
@identified_as_animated = ANIMATED_FORMATS.include? identify("-format %m :file", :file => "#{@file.path}[0]").to_s.downcase.strip
123123
end
124124
@identified_as_animated
125-
rescue Cocaine::ExitStatusError => e
125+
rescue Terrapin::ExitStatusError => e
126126
raise Paperclip::Error, "There was an error running `identify` for #{@basename}" if @whiny
127-
rescue Cocaine::CommandNotFoundError => e
127+
rescue Terrapin::CommandNotFoundError => e
128128
raise Paperclip::Errors::CommandNotFoundError.new("Could not run the `identify` command. Please install ImageMagick.")
129129
end
130130
end

paperclip.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
2626

2727
s.add_dependency('activemodel', '>= 4.2.0')
2828
s.add_dependency('activesupport', '>= 4.2.0')
29-
s.add_dependency('cocaine', '~> 0.5.5')
29+
s.add_dependency('terrapin', '~> 0.6.0')
3030
s.add_dependency('mime-types')
3131
s.add_dependency('mimemagic', '~> 0.3.0')
3232

spec/paperclip/content_type_detector_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
end
4242

4343
it 'returns a sensible default when the file command is missing' do
44-
Paperclip.stubs(:run).raises(Cocaine::CommandLineError.new)
44+
Paperclip.stubs(:run).raises(Terrapin::CommandLineError.new)
4545
@filename = "/path/to/something"
4646
assert_equal "application/octet-stream", Paperclip::ContentTypeDetector.new(@filename).detect
4747
end

spec/paperclip/file_command_content_type_detector_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
end
1313

1414
it 'returns a sensible default when the file command is missing' do
15-
Paperclip.stubs(:run).raises(Cocaine::CommandLineError.new)
15+
Paperclip.stubs(:run).raises(Terrapin::CommandLineError.new)
1616
@filename = "/path/to/something"
1717
assert_equal "application/octet-stream",
1818
Paperclip::FileCommandContentTypeDetector.new(@filename).detect

spec/paperclip/paperclip_spec.rb

+13-13
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,40 @@
44
context ".run" do
55
before do
66
Paperclip.options[:log_command] = false
7-
Cocaine::CommandLine.expects(:new).with("convert", "stuff", {}).returns(stub(:run))
8-
@original_command_line_path = Cocaine::CommandLine.path
7+
Terrapin::CommandLine.expects(:new).with("convert", "stuff", {}).returns(stub(:run))
8+
@original_command_line_path = Terrapin::CommandLine.path
99
end
1010

1111
after do
1212
Paperclip.options[:log_command] = true
13-
Cocaine::CommandLine.path = @original_command_line_path
13+
Terrapin::CommandLine.path = @original_command_line_path
1414
end
1515

16-
it "runs the command with Cocaine" do
16+
it "runs the command with Terrapin" do
1717
Paperclip.run("convert", "stuff")
1818
end
1919

20-
it "saves Cocaine::CommandLine.path that set before" do
21-
Cocaine::CommandLine.path = "/opt/my_app/bin"
20+
it "saves Terrapin::CommandLine.path that set before" do
21+
Terrapin::CommandLine.path = "/opt/my_app/bin"
2222
Paperclip.run("convert", "stuff")
23-
expect(Cocaine::CommandLine.path).to match("/opt/my_app/bin")
23+
expect(Terrapin::CommandLine.path).to match("/opt/my_app/bin")
2424
end
2525

26-
it "does not duplicate Cocaine::CommandLine.path on multiple runs" do
27-
Cocaine::CommandLine.expects(:new).with("convert", "more_stuff", {}).returns(stub(:run))
28-
Cocaine::CommandLine.path = nil
26+
it "does not duplicate Terrapin::CommandLine.path on multiple runs" do
27+
Terrapin::CommandLine.expects(:new).with("convert", "more_stuff", {}).returns(stub(:run))
28+
Terrapin::CommandLine.path = nil
2929
Paperclip.options[:command_path] = "/opt/my_app/bin"
3030
Paperclip.run("convert", "stuff")
3131
Paperclip.run("convert", "more_stuff")
3232

3333
cmd_path = Paperclip.options[:command_path]
34-
assert_equal 1, Cocaine::CommandLine.path.scan(cmd_path).count
34+
assert_equal 1, Terrapin::CommandLine.path.scan(cmd_path).count
3535
end
3636
end
3737

3838
it 'does not raise errors when doing a lot of running' do
3939
Paperclip.options[:command_path] = ["/usr/local/bin"] * 1024
40-
Cocaine::CommandLine.path = "/something/else"
40+
Terrapin::CommandLine.path = "/something/else"
4141
100.times do |x|
4242
Paperclip.run("echo", x.to_s)
4343
end
@@ -63,7 +63,7 @@
6363
context "Calling Paperclip.run with a logger" do
6464
it "passes the defined logger if :log_command is set" do
6565
Paperclip.options[:log_command] = true
66-
Cocaine::CommandLine.expects(:new).with("convert", "stuff", logger: Paperclip.logger).returns(stub(:run))
66+
Terrapin::CommandLine.expects(:new).with("convert", "stuff", logger: Paperclip.logger).returns(stub(:run))
6767
Paperclip.run("convert", "stuff")
6868
end
6969
end

spec/paperclip/processor_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
end
1010

1111
context "Calling #convert" do
12-
it "runs the convert command with Cocaine" do
12+
it "runs the convert command with Terrapin" do
1313
Paperclip.options[:log_command] = false
14-
Cocaine::CommandLine.expects(:new).with("convert", "stuff", {}).returns(stub(:run))
14+
Terrapin::CommandLine.expects(:new).with("convert", "stuff", {}).returns(stub(:run))
1515
Paperclip::Processor.new('filename').convert("stuff")
1616
end
1717
end
1818

1919
context "Calling #identify" do
20-
it "runs the identify command with Cocaine" do
20+
it "runs the identify command with Terrapin" do
2121
Paperclip.options[:log_command] = false
22-
Cocaine::CommandLine.expects(:new).with("identify", "stuff", {}).returns(stub(:run))
22+
Terrapin::CommandLine.expects(:new).with("identify", "stuff", {}).returns(stub(:run))
2323
Paperclip::Processor.new('filename').identify("stuff")
2424
end
2525
end

spec/paperclip/thumbnail_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
it "lets us know when a command isn't found versus a processing error" do
4949
old_path = ENV['PATH']
5050
begin
51-
Cocaine::CommandLine.path = ''
51+
Terrapin::CommandLine.path = ''
5252
Paperclip.options[:command_path] = ''
5353
ENV['PATH'] = ''
5454
assert_raises(Paperclip::Errors::CommandNotFoundError) do
@@ -102,7 +102,7 @@
102102

103103
output_file = thumb.make
104104

105-
command = Cocaine::CommandLine.new("identify", "-format %wx%h :file")
105+
command = Terrapin::CommandLine.new("identify", "-format %wx%h :file")
106106
assert_equal "50x50", command.run(file: output_file.path).strip
107107
end
108108

@@ -189,7 +189,7 @@
189189
it "lets us know when a command isn't found versus a processing error" do
190190
old_path = ENV['PATH']
191191
begin
192-
Cocaine::CommandLine.path = ''
192+
Terrapin::CommandLine.path = ''
193193
Paperclip.options[:command_path] = ''
194194
ENV['PATH'] = ''
195195
assert_raises(Paperclip::Errors::CommandNotFoundError) do

0 commit comments

Comments
 (0)