spiderfw 0.6.26 → 0.6.27
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/CHANGELOG +4 -0
- data/VERSION +1 -1
- data/apps/core/forms/_init.rb +1 -0
- data/apps/core/forms/public/date_time.js +0 -1
- data/apps/core/forms/public/html_area.js +1 -1
- data/apps/core/forms/public/text_area.js +2 -2
- data/apps/core/forms/widgets/form/form.rb +40 -38
- data/apps/core/forms/widgets/inputs/checkbox_list/checkbox_list.rb +71 -0
- data/apps/core/forms/widgets/inputs/checkbox_list/checkbox_list.shtml +5 -0
- data/apps/core/forms/widgets/inputs/date_time/date_time.rb +1 -1
- data/apps/core/forms/widgets/inputs/search_select/search_select.shtml +2 -2
- data/apps/messenger/backends/sms/mobyt.rb +72 -0
- data/apps/messenger/config/options.rb +6 -1
- data/apps/messenger/controllers/mixins/messenger_helper.rb +6 -4
- data/apps/messenger/lib/backends/mobyt.rb +43 -4
- data/apps/messenger/test/features/mobyt.feature +29 -0
- data/apps/messenger/test/features/step_definitions/mobyt_steps.rb +59 -0
- data/lib/spiderfw/app.rb +0 -2
- data/lib/spiderfw/cmd/commands/model.rb +10 -6
- data/lib/spiderfw/config/configuration.rb +1 -4
- data/lib/spiderfw/config/options/spider.rb +4 -3
- data/lib/spiderfw/controller/http_controller.rb +5 -1
- data/lib/spiderfw/http/adapters/rack.rb +5 -1
- data/lib/spiderfw/model/base_model.rb +5 -5
- data/lib/spiderfw/model/identity_mapper.rb +4 -2
- data/lib/spiderfw/model/mappers/db_mapper.rb +5 -2
- data/lib/spiderfw/model/mappers/mapper.rb +15 -8
- data/lib/spiderfw/model/storage/db/adapters/mysql.rb +48 -44
- data/lib/spiderfw/model/storage/db/connectors/mysql.rb +16 -0
- data/lib/spiderfw/model/storage/db/connectors/mysql2.rb +9 -0
- data/lib/spiderfw/setup/app_manager.rb +0 -5
- data/lib/spiderfw/spider.rb +34 -5
- data/lib/spiderfw/templates/layout.rb +6 -6
- data/lib/spiderfw/templates/resources/sass.rb +1 -2
- data/lib/spiderfw/templates/template.rb +5 -1
- metadata +161 -248
- data/apps/core/components/public/js/jquery/plugins/jquery.ui.nestedSortable.js +0 -356
- data/apps/messenger/test/features/sms_mobyt.feature +0 -24
- data/apps/messenger/test/features/step_definitions/sms_mobyt.rb +0 -21
- data/blueprints/.DS_Store +0 -0
- data/blueprints/home/.DS_Store +0 -0
- data/blueprints/install/.DS_Store +0 -0
- data/data/keys/spider.rsa +0 -27
- data/data/keys/spider.rsa.pub +0 -1
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.27
|
data/apps/core/forms/_init.rb
CHANGED
@@ -20,6 +20,7 @@ require 'apps/core/forms/widgets/inputs/select/select'
|
|
20
20
|
require 'apps/core/forms/widgets/inputs/search_select/search_select'
|
21
21
|
require 'apps/core/forms/widgets/inputs/password/password'
|
22
22
|
require 'apps/core/forms/widgets/inputs/checkbox/checkbox'
|
23
|
+
require 'apps/core/forms/widgets/inputs/checkbox_list/checkbox_list'
|
23
24
|
require 'apps/core/forms/widgets/inputs/file_input/file_input'
|
24
25
|
require 'apps/core/forms/widgets/inputs/time_span/time_span'
|
25
26
|
require 'apps/core/forms/widgets/inputs/html_area/html_area'
|
@@ -13,7 +13,6 @@ Spider.defineWidget('Spider.Forms.DateTime', {
|
|
13
13
|
if (cl.substr(0, 10) == 'year-range'){
|
14
14
|
var range = cl.substr(11).split('-');
|
15
15
|
conf.yearRange = range[0].replace("m", "-")+":"+range[1].replace('p', '+');
|
16
|
-
a = 3;
|
17
16
|
}
|
18
17
|
}
|
19
18
|
if (this.input.is('.date')) this.input.datepicker(conf);
|
@@ -97,6 +97,18 @@ module Spider; module Forms
|
|
97
97
|
@model.each_element do |el|
|
98
98
|
@labels[el.name] = el.label
|
99
99
|
end
|
100
|
+
#passo nome_elemento: full_class nella stringa
|
101
|
+
#es tariffa: Spider::Forms::CheckboxList
|
102
|
+
wt_string = @widget_types
|
103
|
+
if @widget_types.is_a?(String)
|
104
|
+
@widget_types = {}
|
105
|
+
parts = wt_string.split(/\s*,\s*/)
|
106
|
+
parts.each do |part|
|
107
|
+
el_id, class_name = part.split(/\s*:\s+/)
|
108
|
+
@widget_types[el_id] = class_name
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
100
112
|
wt = @widget_types || {}
|
101
113
|
@widget_types = {}
|
102
114
|
wt.each do |key, value|
|
@@ -152,41 +164,30 @@ module Spider; module Forms
|
|
152
164
|
|
153
165
|
def load_widgets(template=@template)
|
154
166
|
super
|
155
|
-
if @action == :sub
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
@sub_element.
|
166
|
-
cond[@sub_element.reverse.to_s+'.'+key.name.to_s] = @obj.get("#{@sub_element.integrated_from.name}.#{key.name}")
|
167
|
-
end
|
168
|
-
else
|
169
|
-
@model.primary_keys.each do |key|
|
170
|
-
cond[@sub_element.reverse.to_s+'.'+key.name.to_s] = @obj.get(key)
|
171
|
-
end
|
167
|
+
if (@action == :sub)
|
168
|
+
@crud = Spider::Components::Crud.new(@request, @response)
|
169
|
+
@crud.id = "crud_#{@sub_element.name.to_s}"
|
170
|
+
@crud.model = @sub_element.model
|
171
|
+
add_widget(@crud)
|
172
|
+
@scene.crud = @crud
|
173
|
+
@obj = load
|
174
|
+
cond = {}
|
175
|
+
if @sub_element.integrated?
|
176
|
+
@sub_element.integrated_from.model.primary_keys.each do |key|
|
177
|
+
cond[@sub_element.reverse.to_s+'.'+key.name.to_s] = @obj.get("#{@sub_element.integrated_from.name}.#{key.name}")
|
172
178
|
end
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
@sub_element.model.elements_array.each do |el|
|
177
|
-
sub_elements << el.name unless el.integrated? || el.model == @model
|
179
|
+
else
|
180
|
+
@model.primary_keys.each do |key|
|
181
|
+
cond[@sub_element.reverse.to_s+'.'+key.name.to_s] = @obj.get(key)
|
178
182
|
end
|
179
|
-
@crud.attributes[:table_elements] = sub_elements
|
180
|
-
# else
|
181
|
-
# @crud = Spider::Forms::Form.new(@request, @response)
|
182
|
-
# @form.id = "crud_#{@sub_element.name.to_s}"
|
183
|
-
# @form.model = @sub_element.model
|
184
|
-
# add_widget(@crud)
|
185
|
-
# @scene.crud = @crud
|
186
|
-
# @obj.load
|
187
|
-
# debugger
|
188
|
-
# @form.pk = @obj.get(@sub_element).id
|
189
183
|
end
|
184
|
+
@crud.fixed = cond
|
185
|
+
sub_elements = []
|
186
|
+
#sub_elements += @sub_element.model.primary_keys.map{ |k| k.name }
|
187
|
+
@sub_element.model.elements_array.each do |el|
|
188
|
+
sub_elements << el.name unless el.integrated? || el.model == @model
|
189
|
+
end
|
190
|
+
@crud.attributes[:table_elements] = sub_elements
|
190
191
|
else
|
191
192
|
create_inputs
|
192
193
|
end
|
@@ -267,7 +268,7 @@ module Spider; module Forms
|
|
267
268
|
if ([:choice, :multiple_choice, :state, :multiple_state].include?(el.association) && !el.extended?)
|
268
269
|
widget_type = el.type.attributes[:estimated_size] && el.type.attributes[:estimated_size] > 30 ?
|
269
270
|
SearchSelect : Select
|
270
|
-
elsif @attributes[:show_related] && @pk
|
271
|
+
elsif @attributes[:show_related] && @pk && el.multiple?
|
271
272
|
@sub_links[el.name] = sub_link(el)
|
272
273
|
end
|
273
274
|
end
|
@@ -300,8 +301,8 @@ module Spider; module Forms
|
|
300
301
|
input = create_widget(type, el.name)
|
301
302
|
input.css_classes << "el-#{el.name}"
|
302
303
|
case type.name
|
303
|
-
when 'Spider::Forms::Select', 'Spider::Forms::SearchSelect'
|
304
|
-
input.multiple = true if el.multiple?
|
304
|
+
when 'Spider::Forms::Select', 'Spider::Forms::SearchSelect', 'Spider::Forms::CheckboxList'
|
305
|
+
input.multiple = true if el.multiple? and type.name != 'Spider::Forms::CheckboxList'
|
305
306
|
input.model = el.type if input.respond_to?(:model)
|
306
307
|
input.condition = el.attributes[:choice_condition] || el.condition
|
307
308
|
end
|
@@ -379,8 +380,7 @@ module Spider; module Forms
|
|
379
380
|
end
|
380
381
|
end
|
381
382
|
if inputs_done && !@error
|
382
|
-
if
|
383
|
-
# FIXME: lock!
|
383
|
+
if @free_keys
|
384
384
|
save_mode = obj.in_storage? ? :update : :insert
|
385
385
|
else
|
386
386
|
save_mode = obj.primary_keys_set? ? :update : :insert
|
@@ -388,6 +388,8 @@ module Spider; module Forms
|
|
388
388
|
before_save(obj, save_mode)
|
389
389
|
@before_save.call(obj, save_mode) if @before_save
|
390
390
|
trigger(:before_save, obj)
|
391
|
+
end
|
392
|
+
if inputs_done && !@error
|
391
393
|
begin
|
392
394
|
save_mode == :update ? obj.update : obj.insert
|
393
395
|
#debug("SAVED")
|
@@ -396,7 +398,7 @@ module Spider; module Forms
|
|
396
398
|
rescue => exc
|
397
399
|
if exc.is_a?(Spider::Model::MapperElementError)
|
398
400
|
Spider::Logger.error(exc)
|
399
|
-
exc_element = exc.element.name
|
401
|
+
exc_element = exc.element.is_a?(Spider::Model::Element) ? exc.element.name : exc_element
|
400
402
|
add_error(exc.message, exc_element, exc)
|
401
403
|
else
|
402
404
|
raise
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Spider; module Forms
|
2
|
+
|
3
|
+
class CheckboxList < Input
|
4
|
+
tag 'checkbox_list'
|
5
|
+
i_attr_accessor :model
|
6
|
+
is_attr_accessor :condition
|
7
|
+
attr_accessor :data
|
8
|
+
|
9
|
+
def widget_init(action='')
|
10
|
+
super
|
11
|
+
@model = const_get_full(@model) if @model.is_a?(String)
|
12
|
+
end
|
13
|
+
|
14
|
+
def prepare_value(p)
|
15
|
+
return @value unless p['val']
|
16
|
+
qs = Spider::Model::QuerySet.static(@model)
|
17
|
+
p['val'].each do |key, value|
|
18
|
+
if value == '1'
|
19
|
+
obj = @model.new(str_to_pks(key))
|
20
|
+
qs << obj
|
21
|
+
end
|
22
|
+
end
|
23
|
+
@value = qs
|
24
|
+
@value
|
25
|
+
end
|
26
|
+
|
27
|
+
def prepare
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def run
|
32
|
+
@scene.data = @data || @model.all
|
33
|
+
if @condition
|
34
|
+
@scene.data.condition = @condition
|
35
|
+
end
|
36
|
+
@scene.values = {}
|
37
|
+
@scene.selected = {}
|
38
|
+
if @value
|
39
|
+
val = @value
|
40
|
+
val.each do |v|
|
41
|
+
@scene.selected[@model.primary_keys.map{|k| v.get(k) }.join(',')] = true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
@scene.data.each_index do |i|
|
45
|
+
@scene.values[i] = @model.primary_keys.map{|k| @scene.data[i][k] }.join(',')
|
46
|
+
end
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def obj_to_key_str(obj)
|
52
|
+
@model.primary_keys.map{|k| obj.get(k) }.join(',')
|
53
|
+
end
|
54
|
+
|
55
|
+
def str_to_pks(val)
|
56
|
+
if (val.is_a?(String))
|
57
|
+
parts = val.split(',')
|
58
|
+
pk = {}
|
59
|
+
@model.primary_keys.each{ |k| pk[k.name] = parts.shift}
|
60
|
+
else
|
61
|
+
pk = val
|
62
|
+
end
|
63
|
+
return pk
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
end;end
|
@@ -8,7 +8,7 @@ module Spider; module Forms
|
|
8
8
|
i_attr_accessor :lformat, :type => Symbol, :default => :short
|
9
9
|
attribute :"change-month", :type => Spider::Bool, :default => false
|
10
10
|
attribute :"change-year", :type => Spider::Bool, :default => false
|
11
|
-
attribute :"year-range", :type => String, :default => "
|
11
|
+
attribute :"year-range", :type => String, :default => "m150:p10"
|
12
12
|
|
13
13
|
def prepare_value(val)
|
14
14
|
return val if val.respond_to?(:strftime)
|
@@ -20,7 +20,7 @@
|
|
20
20
|
</option>
|
21
21
|
</select>
|
22
22
|
<div sp:if="@value_desc" class="value-desc{ (@clear ? ' changing' : '') }">
|
23
|
-
<tpl:pass sp:if="@clear">({ @value_desc })</tpl:pass>
|
23
|
+
<tpl:pass sp:if="@clear && !@value_desc.blank?">({ @value_desc })</tpl:pass>
|
24
24
|
<tpl:pass sp:if="!@clear">{ @value_desc }</tpl:pass>
|
25
25
|
<span sp:if="!@next_step">
|
26
26
|
<span class="change_action">
|
@@ -39,4 +39,4 @@
|
|
39
39
|
-->
|
40
40
|
<input sp:if="@multiple" class="hidden-val" type="hidden" name="{ @value_param }" sp:each="@keys |key|" value="{ key }" />
|
41
41
|
<input sp:if="!@multiple" class="hidden-val" type="hidden" name="{ @value_param }" value="{ @key }" />
|
42
|
-
</div>
|
42
|
+
</div>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'apps/messenger/lib/sms_backend'
|
2
|
+
require 'apps/messenger/lib/backends/mobyt'
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
module Spider; module Messenger; module Backends; module SMS
|
8
|
+
|
9
|
+
module Mobyt
|
10
|
+
include Messenger::SMSBackend
|
11
|
+
|
12
|
+
def self.send_message(msg)
|
13
|
+
Spider.logger.debug("**Sending SMS with mobyt**")
|
14
|
+
username = Spider.conf.get('messenger.mobyt.username')
|
15
|
+
password = Spider.conf.get('messenger.mobyt.password')
|
16
|
+
from = Spider.conf.get('messenger.mobyt.from')
|
17
|
+
to = msg.to
|
18
|
+
text = msg.text
|
19
|
+
uri = URI('http://smsweb.mobyt.it/sms-gw/sendsmart')
|
20
|
+
|
21
|
+
testi = Hash.new
|
22
|
+
#se mando messaggio lungo spezzo in più messaggi
|
23
|
+
if text.size > 160
|
24
|
+
percorso_contatore = File.join(Spider.paths[:var], "contatore_mobyt")
|
25
|
+
sequence_index = ""
|
26
|
+
File.open(percorso_contatore, File::RDWR|File::CREAT) do |f|
|
27
|
+
f.flock(File::LOCK_EX)
|
28
|
+
sequence_index = f.read.to_i + 1
|
29
|
+
f.rewind
|
30
|
+
sequence_index = sequence_index % 99
|
31
|
+
f.write("#{sequence_index}")
|
32
|
+
f.flush
|
33
|
+
f.truncate(f.pos)
|
34
|
+
end
|
35
|
+
tot_response = true
|
36
|
+
operation="MULTI"
|
37
|
+
cnt = 0
|
38
|
+
index = 1
|
39
|
+
mes = ""
|
40
|
+
(text + " ").scan(/.{1,153}\s/).map{ |s|
|
41
|
+
testi[index] = s
|
42
|
+
index += 1
|
43
|
+
}
|
44
|
+
tot_testi = testi.size
|
45
|
+
#tolgo lo spazio che era stato aggiunto al testo nell'ultimo messaggio
|
46
|
+
testi[tot_testi] = testi[tot_testi].strip
|
47
|
+
#invio sms con testi in hash testi
|
48
|
+
testi.each{ |key,testo|
|
49
|
+
sequence_index = sequence_index.to_s.rjust(2, '0')
|
50
|
+
tot_testi = tot_testi.to_s.rjust(2, '0')
|
51
|
+
key = key.to_s.rjust(2, '0')
|
52
|
+
# udh=aabbcc: aa=id sequenza, bb=tot messaggi, cc=id del messaggio nella sequenza
|
53
|
+
udh = "#{sequence_index}#{tot_testi}#{key}"
|
54
|
+
uri_params = Spider::Messenger::Mobyt.parametri(username,password,to,from,testo,operation,udh)
|
55
|
+
response = Spider::Messenger::Mobyt.do_post_request(uri, uri_params)
|
56
|
+
Spider::Messenger::Mobyt.check_response_http(response)
|
57
|
+
}
|
58
|
+
|
59
|
+
else
|
60
|
+
uri_params = Spider::Messenger::Mobyt.parametri(username,password,to,from,text)
|
61
|
+
response = Spider::Messenger::Mobyt.do_post_request(uri, uri_params)
|
62
|
+
Spider::Messenger::Mobyt.check_response_http(response)
|
63
|
+
end
|
64
|
+
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
end; end; end; end
|
@@ -39,5 +39,10 @@ module Spider
|
|
39
39
|
config_option 'messenger.smstools.log_path', _("Smsd logfile"), :default => '/var/log/smsd.log'
|
40
40
|
config_option 'messenger.send_immediate', _("Send messages right after the controller action instead of waiting for worker"),
|
41
41
|
:type => Spider::Bool, :default => true
|
42
|
-
|
42
|
+
config_option 'messenger.mobyt.username', _("Username for the Mobyt service"),
|
43
|
+
:type => String
|
44
|
+
config_option 'messenger.mobyt.password', _("Password for the Mobyt service"),
|
45
|
+
:type => String
|
46
|
+
config_option 'messenger.mobyt.from', _("From parameter for the Mobyt service"),
|
47
|
+
:type => String
|
43
48
|
end
|
@@ -54,13 +54,15 @@ module Spider; module Messenger
|
|
54
54
|
end
|
55
55
|
|
56
56
|
if html
|
57
|
-
mail.text_part do
|
58
|
-
body text
|
59
|
-
end
|
60
57
|
mail.html_part do
|
61
58
|
content_type 'text/html; charset=UTF-8'
|
62
59
|
body html
|
63
|
-
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
if attachments && !attachments.empty?
|
63
|
+
mail.text_part do
|
64
|
+
body text
|
65
|
+
end
|
64
66
|
else
|
65
67
|
mail.body = text
|
66
68
|
end
|
@@ -1,11 +1,50 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
require 'net/http'
|
3
|
+
require 'iconv'
|
4
|
+
|
1
5
|
module Spider::Messenger
|
2
6
|
|
3
|
-
|
7
|
+
module Mobyt
|
8
|
+
|
9
|
+
def self.parametri(username,password,to,from,testo,operation="TEXT",udh="")
|
10
|
+
#cambio la codifica per gli accenti e caratteri particolari
|
11
|
+
testo_codificato = Iconv.conv('ISO-8859-15', 'UTF-8', testo)
|
12
|
+
string_digest = [username, operation, to, from, testo_codificato, password].map{ |val|
|
13
|
+
val.to_s
|
14
|
+
}.join("")
|
15
|
+
ticket = Digest::MD5.hexdigest(string_digest).downcase
|
16
|
+
hash_parametri = {
|
17
|
+
'rcpt' => to,
|
18
|
+
'operation' => operation,
|
19
|
+
'from' => from,
|
20
|
+
'data' => testo_codificato,
|
21
|
+
'id' => username,
|
22
|
+
'qty' => "h",
|
23
|
+
'ticket' => ticket,
|
24
|
+
'udh' => udh
|
25
|
+
}
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.do_post_request(uri,data)
|
30
|
+
response = Net::HTTP.post_form(uri,data)
|
31
|
+
end
|
4
32
|
|
5
|
-
def self.parametri(username, password, from, to, testo)
|
6
33
|
|
7
|
-
|
34
|
+
def self.check_response_http(response)
|
35
|
+
case response
|
36
|
+
when Net::HTTPSuccess
|
37
|
+
if response.body !~ /^OK/
|
38
|
+
raise response.body
|
39
|
+
else
|
40
|
+
return true
|
41
|
+
end
|
42
|
+
else
|
43
|
+
#solleva un eccezione
|
44
|
+
raise response.class.to_s
|
45
|
+
end
|
46
|
+
end
|
8
47
|
|
9
|
-
|
48
|
+
end
|
10
49
|
|
11
50
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# language: it
|
2
|
+
|
3
|
+
Funzionalità: Invio di sms con mobyt
|
4
|
+
|
5
|
+
Scenario: restituzione parametri semplice
|
6
|
+
|
7
|
+
Dato che lo username è "aaaa"
|
8
|
+
E che la password è "bbbb"
|
9
|
+
Quando invio un sms con i seguenti dati
|
10
|
+
| to | from | testo |
|
11
|
+
| +39123456789 | mittente-prova | Ciao |
|
12
|
+
Allora il backend deve restituire i seguenti dati
|
13
|
+
| operation | TEXT |
|
14
|
+
| from | mittente-prova |
|
15
|
+
| data | Ciao |
|
16
|
+
| id | aaaa |
|
17
|
+
| qty | a |
|
18
|
+
| password | |
|
19
|
+
| ticket | 3ad6bd5c1d3ea7b021b3f7ddad2398bd |
|
20
|
+
|
21
|
+
Scenario: invio messaggio con backend mobyt
|
22
|
+
|
23
|
+
Dato che il backend è solo di tipo "mobyt"
|
24
|
+
E che lo username è "aaaa"
|
25
|
+
E che la password è "bbbb"
|
26
|
+
E che il from è "mittente-prova"
|
27
|
+
Quando invio un messaggio con messenger
|
28
|
+
E faccio girare la coda dei messaggi
|
29
|
+
Allora deve essere fatta una chiamata in "POST" all'url "http://smsweb.mobyt.it/sms-gw/sendsmart"
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'apps/messenger/lib/backends/mobyt'
|
2
|
+
|
3
|
+
|
4
|
+
Dato /^che lo username è "([^\"]*)"$/ do |username|
|
5
|
+
@username = username
|
6
|
+
Spider.conf.set('messenger.mobyt.username',username)
|
7
|
+
end
|
8
|
+
|
9
|
+
Dato /^che la password è "([^\"]*)"$/ do |password|
|
10
|
+
@password = password
|
11
|
+
Spider.conf.set('messenger.mobyt.password',password)
|
12
|
+
end
|
13
|
+
|
14
|
+
Quando /^invio un sms con i seguenti dati$/ do |table|
|
15
|
+
to = table.hashes.first["to"]
|
16
|
+
from = table.hashes.first["from"]
|
17
|
+
testo = table.hashes.first["testo"]
|
18
|
+
@risultato = Spider::Messenger::Mobyt.parametri(@username,@password,to,from,testo)
|
19
|
+
end
|
20
|
+
|
21
|
+
Allora /^il backend deve restituire i seguenti dati$/ do |table|
|
22
|
+
table.rows_hash.each do |key, value|
|
23
|
+
@risultato[key.to_sym].should eq value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Dato /^che il backend è solo di tipo "([^\"]*)"$/ do |backend|
|
28
|
+
require "apps/messenger/backends/sms/#{backend}"
|
29
|
+
Spider.conf.set('messenger.sms.backends', [backend])
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
Dato /^che il from è "([^\"]*)"$/ do |from|
|
34
|
+
Spider.conf.set('messenger.mobyt.from',from)
|
35
|
+
end
|
36
|
+
|
37
|
+
Quando /^invio un messaggio con messenger$/ do
|
38
|
+
Spider::Messenger.sms("+39123456789", "Ciao")
|
39
|
+
end
|
40
|
+
|
41
|
+
Quando /^faccio girare la coda dei messaggi$/ do
|
42
|
+
require "net/http"
|
43
|
+
|
44
|
+
module Net
|
45
|
+
class HTTP
|
46
|
+
def self.post_form(uri, data)
|
47
|
+
$uri_http = uri
|
48
|
+
$data_http = data
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
Spider::Messenger.process_queue(:sms)
|
55
|
+
end
|
56
|
+
|
57
|
+
Allora /^deve essere fatta una chiamata in "([^\"]*)" all.url "([^\"]*)"$/ do |post, url|
|
58
|
+
$uri_http.to_s.should eq url
|
59
|
+
end
|
data/lib/spiderfw/app.rb
CHANGED
@@ -38,18 +38,22 @@ module Spider::CommandLine
|
|
38
38
|
req_models.each do |model_or_app|
|
39
39
|
models = []
|
40
40
|
mod = model_or_app.is_a?(Module) ? model_or_app : const_get_full(model_or_app)
|
41
|
-
|
41
|
+
|
42
|
+
if mod.is_a?(Module) && mod.include?(Spider::App)
|
42
43
|
mod.models.each do |m|
|
43
|
-
|
44
|
+
storage_instance = m.storage.respond_to?(:instance_name) ? m.storage.instance_name : nil
|
45
|
+
if @non_managed || m < Spider::Model::Managed #|| storage_instance == 'default'
|
46
|
+
models << m
|
47
|
+
else
|
44
48
|
unless m < Spider::Model::InlineModel || m.attributes[:sub_model]
|
45
49
|
Spider.logger.warn("Skipping #{m} because it's non managed (use -m to override)")
|
46
50
|
end
|
47
51
|
next
|
48
52
|
end
|
49
|
-
models << m
|
50
53
|
end
|
51
|
-
elsif
|
52
|
-
|
54
|
+
elsif mod.subclass_of?(Spider::Model::BaseModel)
|
55
|
+
storage_instance = mod.storage.respond_to?(:instance_name) ? mod.storage.instance_name : nil
|
56
|
+
if @non_managed || mod < Spider::Model::Managed #|| storage_instance == 'default'
|
53
57
|
models << mod
|
54
58
|
else
|
55
59
|
Spider.logger.warn("Skipping #{mod} because it's non managed (use -m to override)")
|
@@ -136,4 +140,4 @@ module Spider::CommandLine
|
|
136
140
|
|
137
141
|
end
|
138
142
|
|
139
|
-
end
|
143
|
+
end
|
@@ -85,9 +85,10 @@ module Spider
|
|
85
85
|
config_option 'profiling.enable', _("Enable on-request profiling"), :type => Spider::DataTypes::Bool
|
86
86
|
config_option 'request.mutex', _("Respond to requests sequentially"), :default => false
|
87
87
|
|
88
|
-
config_option 'locale', _("The locale to use")
|
89
|
-
Spider.locale =
|
90
|
-
|
88
|
+
config_option 'locale', _("The locale to use"), :process => lambda{ |val|
|
89
|
+
Spider.locale = val
|
90
|
+
val
|
91
|
+
}
|
91
92
|
config_option 'i18n.rails_path', _("Path where rails-style locales are found"), :default => lambda{ Spider.paths[:root]+'/locales' }
|
92
93
|
config_option 'i18n.default_locale', _("Fallback locale"), :default => 'en'
|
93
94
|
|
@@ -97,7 +97,11 @@ module Spider
|
|
97
97
|
end
|
98
98
|
Locale.clear
|
99
99
|
Locale.init(:driver => :cgi)
|
100
|
-
|
100
|
+
if Spider.conf.get('locale')
|
101
|
+
Spider.locale = Spider.conf.get('locale')
|
102
|
+
else
|
103
|
+
Locale.set_request(@request.params['lang'], @request.cookies['lang'], @request.env['HTTP_ACCEPT_LANGUAGE'], @request.env['HTTP_ACCEPT_CHARSET'])
|
104
|
+
end
|
101
105
|
@request.locale = Locale.current[0]
|
102
106
|
l = @request.locale.to_s
|
103
107
|
l = $1 if l =~ /(\w\w)_+/
|
@@ -84,7 +84,11 @@ module Spider; module HTTP
|
|
84
84
|
|
85
85
|
w = nil
|
86
86
|
controller_response = Spider::Response.new
|
87
|
-
|
87
|
+
if RUBY_PLATFORM =~ /mingw32/
|
88
|
+
multithread = false
|
89
|
+
else
|
90
|
+
multithread = env['rack.multithread'] || Spider.conf.get('webserver.force_threads')
|
91
|
+
end
|
88
92
|
if multithread
|
89
93
|
r, w = IO.pipe
|
90
94
|
rack_response_hash = {:body => r}
|