Removed posix-spawn dependency, used open3 instead (core funciontality), JRuby compatible (#24)

This commit is contained in:
Johanderson Mogollon 2016-05-25 04:07:34 +02:00 committed by Jason Lee
parent 7f51c67f13
commit e4daa11309
4 changed files with 12 additions and 9 deletions

3
.gitignore vendored
View File

@ -10,6 +10,9 @@
/tmp/ /tmp/
.DS_Store .DS_Store
## RubyMine Ide files
.idea/
## Specific to RubyMotion: ## Specific to RubyMotion:
.dat* .dat*
.repl_history .repl_history

View File

@ -2,7 +2,6 @@ PATH
remote: . remote: .
specs: specs:
rucaptcha (0.4.4) rucaptcha (0.4.4)
posix-spawn (>= 0.3.0)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
@ -45,12 +44,14 @@ GEM
arel (6.0.3) arel (6.0.3)
builder (3.2.2) builder (3.2.2)
concurrent-ruby (1.0.2) concurrent-ruby (1.0.2)
concurrent-ruby (1.0.2-java)
diff-lcs (1.2.5) diff-lcs (1.2.5)
erubis (2.7.0) erubis (2.7.0)
globalid (0.3.6) globalid (0.3.6)
activesupport (>= 4.1.0) activesupport (>= 4.1.0)
i18n (0.7.0) i18n (0.7.0)
json (1.8.3) json (1.8.3)
json (1.8.3-java)
loofah (2.0.3) loofah (2.0.3)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.6.4) mail (2.6.4)
@ -63,7 +64,7 @@ GEM
minitest (5.9.0) minitest (5.9.0)
nokogiri (1.6.7.2) nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2) mini_portile2 (~> 2.0.0.rc2)
posix-spawn (0.3.11) nokogiri (1.6.7.2-java)
rack (1.6.4) rack (1.6.4)
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
@ -114,10 +115,12 @@ GEM
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
thread_safe (0.3.5-java)
tzinfo (1.2.2) tzinfo (1.2.2)
thread_safe (~> 0.1) thread_safe (~> 0.1)
PLATFORMS PLATFORMS
java
ruby ruby
DEPENDENCIES DEPENDENCIES
@ -128,4 +131,4 @@ DEPENDENCIES
rucaptcha! rucaptcha!
BUNDLED WITH BUNDLED WITH
1.11.2 1.12.4

View File

@ -1,4 +1,4 @@
require 'posix-spawn' require 'open3'
module RuCaptcha module RuCaptcha
class Captcha class Captcha
@ -77,11 +77,9 @@ module RuCaptcha
png_file_path png_file_path
else else
command.strip! command.strip!
pid, _, stdout, stderr = POSIX::Spawn.popen4(command) out, err, st = Open3.capture3(command)
Process.waitpid(pid)
err = stderr.read
raise "RuCaptcha: #{err.strip}" if err.present? raise "RuCaptcha: #{err.strip}" if err.present?
stdout.read out
end end
end end
end end

View File

@ -13,7 +13,6 @@ Gem::Specification.new do |s|
s.require_paths = ['lib'] s.require_paths = ['lib']
s.summary = 'This is a Captcha gem for Rails Application. It run ImageMagick command to draw Captcha image.' s.summary = 'This is a Captcha gem for Rails Application. It run ImageMagick command to draw Captcha image.'
s.add_dependency 'posix-spawn', '>= 0.3.0'
s.add_development_dependency 'rake' s.add_development_dependency 'rake'
s.add_development_dependency 'rails' s.add_development_dependency 'rails'