spiderfw 0.5.14 → 0.5.15
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/VERSION +1 -1
- data/lib/spiderfw/cmd/cmd.rb +3 -0
- data/lib/spiderfw/cmd/commands/app.rb +2 -2
- data/lib/spiderfw/model/base_model.rb +20 -0
- data/lib/spiderfw/model/mappers/db_mapper.rb +1 -1
- data/lib/spiderfw/requires.rb +1 -0
- data/lib/spiderfw/setup/app_server_client.rb +11 -2
- data/lib/spiderfw/utils/http_client.rb +16 -0
- metadata +5 -4
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.15
|
data/lib/spiderfw/cmd/cmd.rb
CHANGED
@@ -34,6 +34,9 @@ module Spider; module CommandLine
|
|
34
34
|
$SPIDER_RUNMODE = 'devel'
|
35
35
|
Spider.runmode = 'devel' if Spider && Spider.respond_to?(:runmode=)
|
36
36
|
end
|
37
|
+
opt.on("--http-proxy [PROXY]", _("Proxy server to use for http operations (http://user:pass@host:port)")){ |p|
|
38
|
+
ENV['http_proxy'] = p
|
39
|
+
}
|
37
40
|
end
|
38
41
|
|
39
42
|
@cmd.add_command(CmdParse::HelpCommand.new, true)
|
@@ -8,10 +8,10 @@ class AppCommand < CmdParse::Command
|
|
8
8
|
@server_url = 'http://www.soluzionipa.it/euroservizi/spider/app_server'
|
9
9
|
|
10
10
|
self.options = CmdParse::OptionParserWrapper.new do |opt|
|
11
|
-
opt.on("--proxy", _("Proxy server to use (http://user:pass@host:port)"), "-p"){ |p|
|
11
|
+
opt.on("--proxy [SERVER]", _("Proxy server to use (http://user:pass@host:port)"), "-p"){ |p|
|
12
12
|
ENV['http_proxy'] = p
|
13
13
|
}
|
14
|
-
opt.on("--server", _("App server"), "-s") { |s|
|
14
|
+
opt.on("--server [SERVER]", _("App server"), "-s") { |s|
|
15
15
|
@server_url = s
|
16
16
|
}
|
17
17
|
end
|
@@ -740,6 +740,7 @@ module Spider; module Model
|
|
740
740
|
attributes[:hidden] = true unless (params[:hide_integrated] == false)
|
741
741
|
attributes[:delete_cascade] = params[:delete_cascade]
|
742
742
|
attributes[:extended_model] = true
|
743
|
+
attributes[:add_reverse] = params[:reverse]
|
743
744
|
integrated = element(integrated_name, model, attributes)
|
744
745
|
integrate_options = {:keep_pks => true}.merge((params[:integrate_options] || {}))
|
745
746
|
integrate(integrated_name, integrate_options)
|
@@ -2463,6 +2464,25 @@ module Spider; module Model
|
|
2463
2464
|
h
|
2464
2465
|
end
|
2465
2466
|
|
2467
|
+
def self.from_hash_dump(h)
|
2468
|
+
obj = self.static
|
2469
|
+
h.each do |key, val|
|
2470
|
+
el = self.elements[key.to_sym]
|
2471
|
+
next unless el
|
2472
|
+
if el.multiple? && val
|
2473
|
+
qs = obj.get(el)
|
2474
|
+
val.each do |v|
|
2475
|
+
v = el.model.from_hash_dump(v) if v.is_a?(Hash)
|
2476
|
+
qs << v
|
2477
|
+
end
|
2478
|
+
else
|
2479
|
+
val = el.model.from_hash_dump(val) if val.is_a?(Hash)
|
2480
|
+
obj.set(el, val)
|
2481
|
+
end
|
2482
|
+
end
|
2483
|
+
obj
|
2484
|
+
end
|
2485
|
+
|
2466
2486
|
def dump_to_all_data_hash(options={}, h={}, seen={})
|
2467
2487
|
Spider::Model.with_identity_mapper do |im|
|
2468
2488
|
clname = self.class.name.to_sym
|
@@ -1076,7 +1076,7 @@ module Spider; module Model; module Mappers
|
|
1076
1076
|
|
1077
1077
|
# Modifies the storage according to the schema.
|
1078
1078
|
def sync_schema(force=false, options={})
|
1079
|
-
compute_foreign_key_constraints
|
1079
|
+
compute_foreign_key_constraints unless options[:no_foreign_key_constraints] || !storage.supports?(:foreign_keys)
|
1080
1080
|
schema_description = schema.get_schemas
|
1081
1081
|
sequences = {}
|
1082
1082
|
sequences[schema.table] = schema.sequences
|
data/lib/spiderfw/requires.rb
CHANGED
@@ -23,6 +23,7 @@ require 'spiderfw/utils/profiling'
|
|
23
23
|
require 'spiderfw/utils/ordered_hash'
|
24
24
|
require 'spiderfw/utils/memory'
|
25
25
|
require 'spiderfw/utils/secure_random'
|
26
|
+
require 'spiderfw/utils/http_client'
|
26
27
|
require 'spiderfw/config/configuration'
|
27
28
|
require 'spiderfw/config/configurable'
|
28
29
|
require 'spiderfw/model/model'
|
@@ -20,7 +20,14 @@ module Spider
|
|
20
20
|
def http_get(url)
|
21
21
|
uri = URI.parse(url)
|
22
22
|
proxy = uri.find_proxy
|
23
|
-
klass =
|
23
|
+
klass = nil
|
24
|
+
if proxy
|
25
|
+
proxy_user, proxy_pass = nil
|
26
|
+
proxy_user, proxy_pass = proxy.userinfo.split(/:/) if proxy.userinfo
|
27
|
+
klass = Net::HTTP::Proxy(proxy.host, proxy.port, proxy_user, proxy_pass)
|
28
|
+
else
|
29
|
+
klass = Net::HTTP
|
30
|
+
end
|
24
31
|
result = klass.get_response(uri)
|
25
32
|
raise "#{result.code} #{result.message} #{uri}" if result.is_a?(Net::HTTPClientError)
|
26
33
|
result.body
|
@@ -47,9 +54,11 @@ module Spider
|
|
47
54
|
end
|
48
55
|
|
49
56
|
def fetch_app(app_id)
|
50
|
-
tmp = Tempfile.
|
57
|
+
tmp = Tempfile.new("spider-app-archive")
|
58
|
+
tmp.binmode
|
51
59
|
res = http_get(@url+"/pack/#{app_id}")
|
52
60
|
tmp << res
|
61
|
+
tmp.flush
|
53
62
|
tmp.path
|
54
63
|
end
|
55
64
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Spider
|
2
|
+
|
3
|
+
def self.http_client
|
4
|
+
uri = URI.parse('http://www.test.com')
|
5
|
+
proxy = uri.find_proxy
|
6
|
+
klass = nil
|
7
|
+
if proxy
|
8
|
+
proxy_user, proxy_pass = nil
|
9
|
+
proxy_user, proxy_pass = proxy.userinfo.split(/:/) if proxy.userinfo
|
10
|
+
Net::HTTP::Proxy(proxy.host, proxy.port, proxy_user, proxy_pass)
|
11
|
+
else
|
12
|
+
Net::HTTP
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spiderfw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 15
|
10
|
+
version: 0.5.15
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ivan Pirlik
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-26 00:00:00 +01:00
|
19
19
|
default_executable: spider
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -1058,6 +1058,7 @@ files:
|
|
1058
1058
|
- lib/spiderfw/utils/events/event_source.rb
|
1059
1059
|
- lib/spiderfw/utils/fork.rb
|
1060
1060
|
- lib/spiderfw/utils/hash_comparison.rb
|
1061
|
+
- lib/spiderfw/utils/http_client.rb
|
1061
1062
|
- lib/spiderfw/utils/inflector.rb
|
1062
1063
|
- lib/spiderfw/utils/json.rb
|
1063
1064
|
- lib/spiderfw/utils/logger.rb
|