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 CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.1.22 2011-02-25
2
+
3
+ * Support for reverse proxy in web server
4
+
1
5
  === 0.1.21 2011-02-25
2
6
 
3
7
  * Fixed missing callback in server redirection
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') { Options.server = true }
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 Runs web 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
@@ -21,7 +21,7 @@ require 'scrappy/agent/agent'
21
21
  Namespace :sc, 'http://lab.gsi.dit.upm.es/scraping.rdf#'
22
22
 
23
23
  module Scrappy
24
- VERSION = '0.1.21'
24
+ VERSION = '0.1.22'
25
25
  end
26
26
 
27
27
  # Require selectors
@@ -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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{scrappy}
5
- s.version = "0.1.21"
5
+ s.version = "0.1.22"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jose Ignacio"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 21
9
- version: 0.1.21
8
+ - 22
9
+ version: 0.1.22
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jose Ignacio