scrappy 0.1.21 → 0.1.22
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.
- data/History.txt +4 -0
- data/bin/scrappy +3 -3
- data/lib/scrappy.rb +1 -1
- data/lib/scrappy/server.rb +3 -3
- data/scrappy.gemspec +1 -1
- metadata +2 -2
data/History.txt
CHANGED
data/bin/scrappy
CHANGED
@@ -36,7 +36,7 @@ module Scrappy
|
|
36
36
|
opts.on('-D', '--dump') { Agent::Options.dump = true; Agent::Options.format = :rdf }
|
37
37
|
opts.on('-u', '--debug') { Agent::Options.debug = true }
|
38
38
|
opts.on('-i', '--interactive') { Options.shell = true; Agent::Options.format_header = false }
|
39
|
-
opts.on('-s', '--server')
|
39
|
+
opts.on('-s', '--server [ROOT]') { |url| Options.server = true; Options.root = url }
|
40
40
|
opts.on('-S', '--proxy-server') { Options.proxy = true }
|
41
41
|
opts.on('-P P', '--port P') { |p| Options.port = p }
|
42
42
|
opts.on('-c C', '--concurrence C') { |c| Agent::Options.workers = c.to_i }
|
@@ -65,7 +65,7 @@ module Scrappy
|
|
65
65
|
puts "Launching Scrappy Web Server..."
|
66
66
|
require 'scrappy/server'
|
67
67
|
Thin::Logging.silent = true
|
68
|
-
Scrappy::Server.run! :host => 'localhost', :port => Options.port, :environment=>:production
|
68
|
+
Scrappy::Server.run! :host => 'localhost', :port => Options.port, :environment=>:production, :root=>Options.root
|
69
69
|
elsif Options.shell
|
70
70
|
puts "Launching Scrappy Shell..."
|
71
71
|
require 'scrappy/shell'
|
@@ -105,7 +105,7 @@ Options
|
|
105
105
|
-D, --dump Dumps RDF data to disk
|
106
106
|
-u, --debug Shows debugging traces
|
107
107
|
-i, --interactive Runs interactive shell
|
108
|
-
-s, --server
|
108
|
+
-s, --server [ROOT] Runs web server (optionally specify server's root url)
|
109
109
|
-S, --proxy-server Runs web proxy
|
110
110
|
-P, --port PORT Selects port number (default is 3434)
|
111
111
|
-v, --visual Uses visual agent (slow)
|
data/lib/scrappy.rb
CHANGED
data/lib/scrappy/server.rb
CHANGED
@@ -24,7 +24,7 @@ module Scrappy
|
|
24
24
|
response = agent.proxy :method=>method, :uri=>url, :inputs=>inputs, :format=>format.to_sym
|
25
25
|
case response.status
|
26
26
|
when :redirect
|
27
|
-
redirect "/#{format}/#{CGI::escape(response.uri).gsub('%2F','/').gsub('%3A',':')}#{textual_inputs}"
|
27
|
+
redirect "#{settings.root}/#{format}/#{CGI::escape(response.uri).gsub('%2F','/').gsub('%3A',':')}#{textual_inputs}"
|
28
28
|
when :ok
|
29
29
|
headers 'Content-Type' => response.content_type
|
30
30
|
callback ? "#{callback}(#{response.output})" : response.output
|
@@ -48,8 +48,8 @@ module Scrappy
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def textual_inputs
|
51
|
-
return '' if inputs.merge('callback'=>params[:callback]).empty?
|
52
|
-
"?" + (inputs.merge('callback'=>params[:callback]).map{|k,v| "#{CGI.escape(k)}=#{CGI.escape(v)}"}*'')
|
51
|
+
return '' if inputs.merge('callback'=>params[:callback]).reject{|k,v| v.nil?}.empty?
|
52
|
+
"?" + (inputs.merge('callback'=>params[:callback]).reject{|k,v| v.nil?}.map{|k,v| "#{CGI.escape(k)}=#{CGI.escape(v)}"}*'')
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
data/scrappy.gemspec
CHANGED