spiderfw 0.6.33 → 0.6.34

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA512:
3
- metadata.gz: 4873d682965b148d70ade3af10f990ce93457765fda2938ee24581e26aed8610763b6bc9c6e07f5d945c53fdaf4fa60283d8d0ec98bd4e69f6532531f45eee38
4
- data.tar.gz: 5fdaa46959c9faceae5a35c09dc82bbfb5f1c2de98225b040a4d22193280f7a58645f3f50de5a1443d760b256408f3d8e1c5a4a1f63c53decfffa5c17f2c3ab9
5
2
  SHA1:
6
- metadata.gz: 29e74e4cba2547d4454dafb8a774f87038a09c15
7
- data.tar.gz: 04caf2f5945b4807d75f4c6843a25a05a2e50dea
3
+ metadata.gz: 4c4bf569cdffcd4f4e64bd82183bbee9d4d10fab
4
+ data.tar.gz: 63357be8bf251700de9f892f52fd6b314c8d2414
5
+ SHA512:
6
+ metadata.gz: b044d2830210abc1e7351259d85d658e2cbe814ec75c9dc6da98a002a6fc704e865aa869cfdf63ba2cf7d35a79d0d69297fa6ef249a564c6cf5d23b8cf07e1b8
7
+ data.tar.gz: 7f404687644cbfd20f3ca935def886e8c42827724addd0ff034cf80e8f7885a2ad32eed2402165a432472833c18b2a7d135507242911772b193a76af16d1e3bf
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.33
1
+ 0.6.34
@@ -33,7 +33,7 @@ module Spider; module AppServer
33
33
  end
34
34
  end
35
35
  @last_modified = repo.commits.first.authored_date # FIXME
36
- @spec.app_server ||= AppServer::AppServerController.http_url
36
+ @spec.app_server ||= AppServer::AppServerController.http_s_url
37
37
  break
38
38
  end
39
39
  @repo = repo
@@ -19,7 +19,7 @@ module Spider; module Admin
19
19
  end
20
20
 
21
21
  def self.logout_redirect
22
- AdminController.http_url('login')
22
+ AdminController.http_s_url('login')
23
23
  end
24
24
  end
25
25
 
@@ -54,7 +54,7 @@ module Spider; module Admin
54
54
  next if app[:options][:users] && (app[:options][:users] & (@request.users.map{ |u| u.class})).empty?
55
55
  next if app[:options][:check] && !@request.users.any?{ |u| app[:options][:check].call(u) }
56
56
  end
57
- url = self.class.http_url(short_name)
57
+ url = self.class.http_s_url(short_name)
58
58
  @scene.apps << {
59
59
  :icon => app[:options][:icon] ? app[:module].pub_url+'/'+app[:options][:icon] : nil,
60
60
  :url => self.class.http_s_url(short_name),
@@ -65,7 +65,7 @@ module Spider; module Admin
65
65
  }
66
66
  end
67
67
  @scene.admin_breadcrumb = []
68
- @scene.admin_breadcrumb << {:url => self.class.http_url, :label => _('Home')} if @scene.apps.length > 1
68
+ @scene.admin_breadcrumb << {:url => self.class.http_s_url, :label => _('Home')} if @scene.apps.length > 1
69
69
 
70
70
  # FIXME
71
71
  @scene.apps.sort!{ |a,b| b[:priority] <=> a[:priority] }
@@ -6,7 +6,7 @@ module Spider; module Admin
6
6
  def before(action='', *params)
7
7
  @scene.admin_breadcrumb ||= []
8
8
  unless @_did_breadcrumb
9
- @scene.admin_breadcrumb << {:url => self.class.http_url, :label => self.class.app.full_name}
9
+ @scene.admin_breadcrumb << {:url => self.class.http_s_url, :label => self.class.app.full_name}
10
10
  end
11
11
  @_did_breadcrumb = true
12
12
  super
@@ -804,3 +804,11 @@ function basename(path){
804
804
  function dirname(path){
805
805
  return path.replace(/\\/g, '/').replace(/\/[^\/]*$/, '');
806
806
  }
807
+
808
+ if(!String.prototype.trim) {
809
+ String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');};
810
+ }
811
+
812
+
813
+
814
+
@@ -19,6 +19,9 @@ module Spider; module Components
19
19
  attribute :link_id, :type => Symbol
20
20
  attribute :link
21
21
  attribute :sort
22
+ #serve per i campi delle tabelle esterne che compaiono per il :reverse nel modello
23
+ #metterlo a false nella view per nascondere i campi
24
+ i_attribute :reverse_element, :type => TrueClass, :default => true
22
25
  i_attr_accessor :queryset
23
26
  i_attr_accessor :model
24
27
  attr_accessor :queryset, :condition, :page
@@ -83,6 +86,8 @@ module Spider; module Components
83
86
  next if el.multiple? && el.association != :multiple_choice
84
87
  next if el.type == Spider::DataTypes::Password
85
88
  next if el.hidden?
89
+ #serve per mostrare o no i campi delle chiavi esterne
90
+ next if el.attributes[:added_reverse] && !@attributes[:reverse_element]
86
91
  end
87
92
  cnt += 1
88
93
  els << el.name
@@ -4,19 +4,16 @@ Spider.defineWidget('Spider.Forms.FileInput', 'Spider.Forms.Input', {
4
4
 
5
5
  ready: function(){
6
6
  var self = this;
7
- var fileLink = $('.file-link', this.el);
7
+ var fileLink = $('.file-link', this.el.parent());
8
8
  if (fileLink.size() == 1){
9
- var changeLabel = $('.change-label', this.el).text();
10
- var changeDiv = $('.change', this.el);
9
+ var changeLabel = $('.change-label', this.el.parent()).text();
10
+ var changeDiv = $('.change', this.el.parent());
11
11
  changeDiv.hide();
12
- $('.clear', this.el).hide();
13
- var clearCheckBox = $('.clear input:checkbox', this.el);
14
- var fileInput = $('.change input', this.el);
12
+ clearCheckBox = $('.clear input:checkbox', this.el.parent());
13
+ fileInput = $('.change input', this.el.parent());
15
14
 
16
15
  var link = $('<a href="#" class="js-change-link"/>');
17
- link.text(changeLabel+'...')
18
- .insertAfter(fileLink)
19
- .click(function(e){
16
+ link.text(changeLabel+'...').insertAfter(fileLink).click(function(e){
20
17
  e.preventDefault();
21
18
  if (clearCheckBox.is(':checked')){
22
19
  link.removeClass('open');
@@ -8,6 +8,13 @@ module Spider; module Forms
8
8
  return val ? true : false
9
9
  end
10
10
 
11
+ def value
12
+ val = super
13
+ return ( val.blank? ? false : true )
14
+ end
15
+
16
+
17
+
11
18
  end
12
19
 
13
20
  end; end
@@ -20,8 +20,8 @@ module Spider; module Forms
20
20
  :image_manager => attributes[:"image-manager"],
21
21
  :link_manager => attributes[:"link-manager"] || attributes[:"file-manager"]
22
22
  }
23
- options[:link_manager] ||= Spider::Files.http_url(:manager) if Spider.app?('spider_files')
24
- options[:image_manager] ||= Spider::Images.http_url(:manager) if Spider.app?('spider_images')
23
+ options[:link_manager] ||= Spider::Files.http_s_url(:manager) if Spider.app?('spider_files')
24
+ options[:image_manager] ||= Spider::Images.http_s_url(:manager) if Spider.app?('spider_images')
25
25
  options[:full_page] = attributes[:"full-page"]
26
26
  @scene.options = options.to_json
27
27
  end
@@ -41,12 +41,12 @@ module Spider; module Messenger
41
41
  model = Spider::Messenger.const_get(q[:model])
42
42
  @scene.queue = @queue
43
43
  @scene.title = q[:label]
44
- @scene.admin_breadcrumb << {:label => @scene.title, :url => self.class.url(@queue)}
44
+ @scene.admin_breadcrumb << {:label => @scene.title, :url => self.class.http_s_url(@queue)}
45
45
 
46
46
  if id
47
47
  return view_message(@queue, id)
48
48
  end
49
- @scene.msg_view_url = self.class.url(@queue)+'/'
49
+ @scene.msg_view_url = self.class.http_s_url(@queue)+'/'
50
50
  @scene.queued = model.queued_messages
51
51
  @scene.sent = model.sent_messages
52
52
  @scene.failed = model.failed_messages
@@ -58,7 +58,7 @@ module Spider; module Messenger
58
58
  model = Spider::Messenger.const_get(details[:model])
59
59
  @scene.message = model.load(:id => id)
60
60
  raise NotFound.new("Message #{queue} #{id}") unless @scene.message
61
- @scene.admin_breadcrumb << {:label => id, :url => self.class.url("#{queue}/#{id}")}
61
+ @scene.admin_breadcrumb << {:label => id, :url => self.class.http_s_url("#{queue}/#{id}")}
62
62
  render("admin/view_#{queue}")
63
63
  end
64
64
 
@@ -62,16 +62,29 @@ module Spider; module Messenger
62
62
  mail[key] = value.convert_object
63
63
  end
64
64
 
65
- if html
65
+ # if html
66
+ # mail.html_part do
67
+ # content_type 'text/html; charset=UTF-8'
68
+ # body html
69
+ # end
70
+ # end
71
+ # if attachments && !attachments.empty?
72
+ # mail.text_part do
73
+ # body text
74
+ # end
75
+ # else
76
+ # mail.body = text
77
+ # end
78
+ #ritornato al vecchio metodo con piu controlli per problema con invio comunicazioni con immagini 5/2/2015
79
+
80
+ if html || text
81
+ mail.text_part do
82
+ body text
83
+ end unless text.blank?
66
84
  mail.html_part do
67
85
  content_type 'text/html; charset=UTF-8'
68
86
  body html
69
- end
70
- end
71
- if attachments && !attachments.empty?
72
- mail.text_part do
73
- body text
74
- end
87
+ end unless html.blank?
75
88
  else
76
89
  mail.body = text
77
90
  end
@@ -79,8 +92,11 @@ module Spider; module Messenger
79
92
  if attachments && !attachments.empty?
80
93
  attachments.each do |att|
81
94
  if att.is_a?(Hash)
82
- filename = att.delete(:filename)
83
- mail.attachments[filename] = att
95
+ #filename = att.delete(:filename)
96
+ filename = att[:filename].dup
97
+ mime_type = att[:mime_type].dup
98
+ content = att[:content].dup
99
+ mail.attachments[filename] = { :mime_type => mime_type, :content => content }
84
100
  else
85
101
  mail.add_file(att)
86
102
  end
@@ -3,10 +3,10 @@
3
3
  <tpl:include src="/core/admin/_app_info" />
4
4
  <ul>
5
5
  <li>
6
- <a href="{ Spider::Messenger::AdminController.url }">_(Queues)</a>
6
+ <a href="{ Spider::Messenger::AdminController.http_s_url }">_(Queues)</a>
7
7
  <ul>
8
8
  <li sp:each="@queues |queue|">
9
- <a href="{ Spider::Messenger::AdminController.url(queue) }">{ @queue_info[queue][:label] }</a>
9
+ <a href="{ Spider::Messenger::AdminController.http_s_url(queue) }">{ @queue_info[queue][:label] }</a>
10
10
  </li>
11
11
  </ul>
12
12
  </li>
@@ -2,7 +2,7 @@
2
2
  <h3>_(Queues)</h3>
3
3
  <ul>
4
4
  <li sp:each="@queues |name|">
5
- <a href="{ Spider::Messenger::AdminController.http_url }/{ name }">{ @queue_info[name][:label] }</a>:
5
+ <a href="{ Spider::Messenger::AdminController.http_s_url }/{ name }">{ @queue_info[name][:label] }</a>:
6
6
  <ul>
7
7
  <li>_(Sent messages): <span class="label success">{ @queue_info[name][:sent] }</span></li>
8
8
  <li>_(Queued messages): <span class="label warning">{ @queue_info[name][:queued] }</span></li>
@@ -141,7 +141,7 @@ module Spider
141
141
  end
142
142
 
143
143
  def self.in(time, proc_string)
144
- secs = Rufus.parse_time_string(time)
144
+ secs = Rufus::Scheduler.parse(time)
145
145
  self.at(Time.now+secs, proc_string)
146
146
  end
147
147
 
data/lib/spiderfw/app.rb CHANGED
@@ -143,18 +143,26 @@ module Spider
143
143
  # The full url used to access the application from the browser, prefixed
144
144
  # with https
145
145
  # @return [String]
146
- def https_url
146
+ def https_url(action=nil)
147
+ if u = Spider.conf.get("#{@dotted_name}.https_url")
148
+ if action
149
+ u += '/' if u[-1].chr != '/'
150
+ u += action.to_s
151
+ end
152
+ return u
153
+ end
147
154
  return nil unless Spider.site && Spider.site.ssl?
148
155
  u = "https://#{Spider.site.domain}"
149
156
  u += ":#{Spider.site.ssl_port}" unless Spider.site.ssl_port == 443
150
157
  u += url
158
+ u += "/"+action.to_s if action
151
159
  u
152
160
  end
153
161
 
154
162
  # @return [String] If the site supports SSL, returns the #https_url; otherwise, the #http_url
155
- def http_s_url
156
- return https_url if Spider.site && Spider.site.ssl?
157
- return http_url
163
+ def http_s_url(action=nil)
164
+ return https_url(action) if Spider.site && Spider.site.ssl?
165
+ return http_url(action)
158
166
  end
159
167
 
160
168
  # @return [String] The url to the app's public content. If the static_content.mode configuration
@@ -18,7 +18,7 @@ module Spider
18
18
  require 'mongrel'
19
19
  'mongrel'
20
20
  rescue LoadError
21
- 'webrick'
21
+ 'thin'
22
22
  end
23
23
  },
24
24
  :type => String, :choices => ['webrick', 'mongrel', 'thin']
@@ -278,11 +278,11 @@ module Spider; module Model
278
278
  create_junction = false
279
279
  elsif (first_model.constant_defined?(assoc_type_name) )
280
280
  assoc_type = first_model.const_get(assoc_type_name)
281
- if (!assoc_type.attributes[:sub_model]) # other kind of inline model
281
+ if (assoc_type.respond_to?(:attributes) && !assoc_type.attributes[:sub_model]) # other kind of inline model
282
282
  assoc_type_name += 'Junction'
283
283
  create_junction = false if (first_model.const_defined?(assoc_type_name))
284
284
  else
285
- create_junction = false
285
+ createP_junction = false
286
286
  end
287
287
  end
288
288
  attributes[:junction] = true
@@ -300,7 +300,12 @@ module Spider; module Model
300
300
  end
301
301
  other_name = attributes[:junction_their_element]
302
302
  if (create_junction)
303
- assoc_type = first_model.const_set(assoc_type_name, Class.new(BaseModel))
303
+ #evita il warning 'already initialized constant News' e 'already initialized constant Contents'
304
+ if first_model.constant_defined?(assoc_type_name)
305
+ return nil
306
+ else
307
+ assoc_type = first_model.const_set(assoc_type_name, Class.new(BaseModel))
308
+ end
304
309
  assoc_type.attributes[:sub_model] = self
305
310
  assoc_type.attributes[:sub_model_element] = name
306
311
  embedder = attributes[:junction_embedded] == false ? false : true
@@ -1638,20 +1643,22 @@ module Spider; module Model
1638
1643
  def set_loaded_value(element, value, mark_loaded=true)
1639
1644
  element_name = element.is_a?(Element) ? element.name : element
1640
1645
  element = self.class.elements[element_name]
1641
- if element.integrated?
1642
- integrated = get(element.integrated_from)
1643
- integrated.set_loaded_value(element.integrated_from_element, value) if integrated
1644
- else
1645
- value = prepare_child(element.name, value)
1646
- current = instance_variable_get("@#{element_name}")
1647
- current.set_parent(nil, nil) if current && current.is_a?(BaseModel)
1648
- value.set_parent(self, element.name) if value.is_a?(BaseModel)
1649
- instance_variable_set("@#{element_name}", value)
1646
+ unless element.blank?
1647
+ if element.integrated?
1648
+ integrated = get(element.integrated_from)
1649
+ integrated.set_loaded_value(element.integrated_from_element, value) if integrated
1650
+ else
1651
+ value = prepare_child(element.name, value)
1652
+ current = instance_variable_get("@#{element_name}")
1653
+ current.set_parent(nil, nil) if current && current.is_a?(BaseModel)
1654
+ value.set_parent(self, element.name) if value.is_a?(BaseModel)
1655
+ instance_variable_set("@#{element_name}", value)
1656
+ end
1657
+ value.loaded = true if (value.is_a?(QuerySet))
1658
+ element_loaded(element_name) if mark_loaded
1659
+ set_reverse(element, value) if element.model? && value
1660
+ @_modified_elements[element_name] = false
1650
1661
  end
1651
- value.loaded = true if (value.is_a?(QuerySet))
1652
- element_loaded(element_name) if mark_loaded
1653
- set_reverse(element, value) if element.model? && value
1654
- @_modified_elements[element_name] = false
1655
1662
  end
1656
1663
 
1657
1664
  # Records that the element has been loaded.
@@ -2392,7 +2399,7 @@ module Spider; module Model
2392
2399
  .map{ |el|
2393
2400
  val = get(el.name).to_s
2394
2401
  if RUBY_VERSION =~ /1.8/
2395
- val = ic.iconv(val + ' ')[0..-2]
2402
+ val = ic.iconv(val + ' ')[0..-2] if val
2396
2403
  else
2397
2404
  begin
2398
2405
  val = ((val+' ').encode('UTF-8', enc, :invalid => :replace, :undef => :replace))[0..-2] if val
@@ -2448,7 +2455,7 @@ module Spider; module Model
2448
2455
 
2449
2456
  if (el.type == String || el.type == Text)
2450
2457
  if RUBY_VERSION =~ /1.8/
2451
- val = ic.iconv(val + ' ')[0..-2]
2458
+ val = ic.iconv(val + ' ')[0..-2] if val
2452
2459
  else
2453
2460
  begin
2454
2461
  val = ((val+' ').encode('UTF-8', enc, :invalid => :replace, :undef => :replace))[0..-2] if val
@@ -1290,6 +1290,14 @@ module Spider; module Model; module Mappers
1290
1290
  end
1291
1291
  end
1292
1292
  end
1293
+ #debugger if ['civiliaopen__persona','civiliaopen__residente'].include?(schema.table.name)
1294
+ @model.elements_array.select{ |el| el.attributes[:index] }.each do |el|
1295
+ found = false
1296
+ schema.table.fields.map{|field| found = (field.name == el.name.to_s); break if found }
1297
+ sql = @storage.create_index(schema.table,el.name.to_s,el.attributes[:index]) if found
1298
+
1299
+ end if @model.extended_models.empty?
1300
+
1293
1301
  seen = {}
1294
1302
  sequences.each do |sequence_table, table_sequences|
1295
1303
  table_sequences.each do |element_name, db_name|
@@ -256,8 +256,8 @@ module Spider
256
256
  unless (options[:no_sync])
257
257
  Spider::Logger.debug("SYNCING #{m}")
258
258
  m.mapper.sync_schema(force, options) if m.mapper.respond_to?(:sync_schema)
259
- m.after_sync if m.respond_to?(:after_sync)
260
- end
259
+ m.after_sync if m.respond_to?(:after_sync)
260
+ end
261
261
  if (options[:drop_tables] && m.mapper.respond_to?(:schema))
262
262
  storages << m.mapper.storage unless storages.include?(m.mapper.storage)
263
263
  tables += m.mapper.schema.get_schemas.keys
@@ -82,7 +82,7 @@ module Spider; module Model; module Storage; module Db
82
82
  bind_vars << query[:limit] + 1
83
83
  end
84
84
  replaced_fields.each do |f, repl|
85
- order = order.gsub(f, repl)
85
+ order = order.gsub(f.to_s, repl)
86
86
  end
87
87
  sql = "SELECT * FROM (#{sql}) as RowConstrainedResult WHERE #{limit} order by #{order}"
88
88
  else
@@ -13,6 +13,7 @@ module Spider; module Model; module Storage; module Db; module Connectors
13
13
  def new_connection(dsn=nil, user=nil, passwd=nil)
14
14
  conn = ::ODBC.connect(dsn, user, passwd)
15
15
  conn.autocommit = true
16
+
16
17
  return conn
17
18
  end
18
19
 
@@ -82,7 +83,15 @@ module Spider; module Model; module Storage; module Db; module Connectors
82
83
  debug("odbc executing:\n#{sql}\n[#{debug_vars_str}]")
83
84
  end
84
85
  @stmt = connection.prepare(sql)
85
- res = @stmt.execute(*bind_vars)
86
+ rebind_vars = []
87
+ bind_vars.each do |var|
88
+ if var.is_a?(Date)
89
+ rebind_vars << var.to_s
90
+ else
91
+ rebind_vars << var
92
+ end
93
+ end
94
+ res = @stmt.execute(*rebind_vars)
86
95
  have_result = (@stmt.ncols != 0)
87
96
  if (have_result)
88
97
  result = []
@@ -543,7 +543,7 @@ module Spider; module Model; module Storage; module Db
543
543
  alter_fields = alter[:alter_fields]
544
544
  alter_attributes = alter[:attributes]
545
545
  sqls = []
546
-
546
+
547
547
  add_fields.each do |field|
548
548
  name, type, attributes = field
549
549
  sqls += sql_add_field(table_name, field[:name], field[:type], field[:attributes])
@@ -576,7 +576,6 @@ module Spider; module Model; module Storage; module Db
576
576
  return sqls
577
577
  end
578
578
 
579
-
580
579
  # Executes a create table structured description.
581
580
  def create_table(create)
582
581
  sqls = sql_create_table(create)
@@ -592,6 +591,28 @@ module Spider; module Model; module Storage; module Db
592
591
  execute(sql)
593
592
  end
594
593
  end
594
+
595
+ # Executes a create index structured description.
596
+ def create_index(table_name, field_name, attribute)
597
+ sqls = sql_add_index(table_name, field_name, attribute)
598
+ begin
599
+ sqls.each{ |sql| execute(sql) }
600
+ rescue StorageException => exc
601
+ Spider.logger.error "Duplicate Key during create unique index into table #{table_name} and referred to column #{field_name}"
602
+ rescue => exc
603
+ drop_index(table_name, field_name)
604
+ retry
605
+ end
606
+ end
607
+
608
+ # Drop the index from DB.
609
+ def drop_index(table_name, field_name)
610
+ sqls = sql_drop_index(table_name, field_name)
611
+ begin
612
+ sqls.each{ |sql| execute(sql) }
613
+ rescue => exc
614
+ end
615
+ end
595
616
 
596
617
  # Drops a field from the DB.
597
618
  def drop_field(table_name, field_name)
@@ -663,6 +684,14 @@ module Spider; module Model; module Storage; module Db
663
684
  def sql_change_field(table_name, field, new_field, type, attributes)
664
685
  ["ALTER TABLE #{table_name} CHANGE #{field} #{sql_table_field(new_field, type, attributes)}"]
665
686
  end
687
+
688
+ def sql_add_index(table_name, field, attribute)
689
+ ["CREATE #{(attribute.to_s.upcase == 'UNIQUE' ? attribute.to_s.upcase : '')} INDEX #{field}_idx ON #{table_name} (#{field})"]
690
+ end
691
+
692
+ def sql_drop_index(table_name, field)
693
+ ["DROP INDEX #{field}_idx ON #{table_name}"]
694
+ end
666
695
 
667
696
  # Checks if a DB field is equal to a schema field.
668
697
  def schema_field_equal?(current, field)
@@ -13,6 +13,7 @@ require 'spiderfw/utils/monkey/exception'
13
13
  require 'spiderfw/utils/monkey/nil_class'
14
14
  require 'spiderfw/utils/monkey/object'
15
15
  require 'spiderfw/utils/json'
16
+ require 'spiderfw/utils/mixins'
16
17
  require 'spiderfw/utils/multi_level_hash'
17
18
  require 'spiderfw/utils/thread_out'
18
19
  require 'spiderfw/utils/inflector'
@@ -25,6 +26,7 @@ require 'spiderfw/utils/memory'
25
26
  require 'spiderfw/utils/secure_random'
26
27
  require 'spiderfw/utils/http_client'
27
28
  require 'spiderfw/utils/gems'
29
+ require 'spiderfw/utils/openssl_wrapper'
28
30
  require 'spiderfw/config/configuration'
29
31
  require 'spiderfw/config/configurable'
30
32
  require 'spiderfw/app'
@@ -1087,18 +1087,33 @@ module Spider
1087
1087
  def init_ruby_debug
1088
1088
  begin
1089
1089
  begin
1090
- require 'ruby-debug'
1091
- rescue
1092
- require 'debugger'
1093
- end
1094
- if File.exists?(File.join($SPIDER_RUN_PATH,'tmp', 'debug.txt'))
1095
- Debugger.wait_connection = true
1096
- Debugger.start_remote
1097
- else
1098
- Debugger.start
1090
+ case RUBY_VERSION
1091
+ when /2/
1092
+ require 'byebug'
1093
+ else
1094
+ require 'ruby-debug'
1095
+ end
1096
+ rescue
1097
+ require 'debugger'
1098
+ end
1099
+ case RUBY_VERSION
1100
+ when /2/
1101
+ if File.exists?(File.join($SPIDER_RUN_PATH,'tmp', 'debug.txt'))
1102
+ Byebug.wait_connection = true
1103
+ Byebug.start
1104
+ else
1105
+ Byebug.start
1106
+ end
1107
+ else
1108
+ if File.exists?(File.join($SPIDER_RUN_PATH,'tmp', 'debug.txt'))
1109
+ Debugger.wait_connection = true
1110
+ Debugger.start_remote
1111
+ else
1112
+ Debugger.start
1113
+ end
1099
1114
  end
1100
1115
  rescue LoadError, RuntimeError => exc
1101
- msg = _('Unable to start debugger. Ensure ruby-debug is installed (or set debugger.start to false).')
1116
+ msg = _('Unable to start debugger. Ensure ruby-debug or byebug is installed (or set debugger.start to false).')
1102
1117
  Spider.output(exc.message)
1103
1118
  Spider.output(msg)
1104
1119
  end
@@ -0,0 +1,7 @@
1
+ class String
2
+ def to_bool
3
+ return true if self == true || self =~ (/(true|Vero|t|yes|si|y|1)$/i)
4
+ return false if self == false || self.blank? || self =~ (/(false|Falso|f|no|n|0)$/i)
5
+ raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
6
+ end
7
+ end
@@ -55,7 +55,8 @@ class Object
55
55
  require 'iconv'
56
56
  self.replace(Iconv.iconv(encoding, encoding, self).first)
57
57
  elsif RUBY_VERSION =~ /1.9/
58
- self.replace(self.force_encoding(encoding))
58
+ self_dup = self.dup
59
+ self.replace(self_dup.force_encoding(encoding)) unless self.frozen?
59
60
  end
60
61
  end
61
62
  end
@@ -0,0 +1,64 @@
1
+ require 'openssl'
2
+
3
+ module Spider
4
+
5
+ module OpenSslWrapper
6
+
7
+ #metodo che verifica che il file sia firmato e che sia stato generato dal file originale passato senza alterazioni
8
+ #ritorna un hash con una chave esito per capire se la verifica ha dato esito positivo e per ritornare o il
9
+ #messaggio d'errore o un hash con i dati dei certificati
10
+ def self.verify_p7m_short(original_file, signed_file)
11
+ signature = OpenSSL::PKCS7.new(File.read(signed_file))
12
+ data = File.read(original_file)
13
+ cert_store = OpenSSL::X509::Store.new
14
+ cert_store.set_default_paths
15
+ #estraggo il certificato con cui viene firmato
16
+ certificati_firmatari = signature.certificates
17
+ firmatari = signature.signers
18
+ #OpenSSL::PKCS7::DETACHED
19
+ esito = signature.verify(certificati_firmatari, cert_store, data, OpenSSL::PKCS7::NOVERIFY)
20
+ if esito
21
+ #array con i dati dei certificati dei firmatari
22
+ array_cert_firmatari = []
23
+ certificati_firmatari.each{ |certificato|
24
+ hash_certificato = {}
25
+ hash_certificato[:issuer] = {}
26
+ certificato.issuer.to_a.each{ |item_of_name|
27
+ hash_certificato[:issuer][item_of_name[0].to_sym] = item_of_name[1]
28
+ }
29
+ hash_certificato[:subject] = {}
30
+ certificato.subject.to_a.each{ |item_of_name|
31
+ hash_certificato[:subject][item_of_name[0].to_sym] = item_of_name[1]
32
+ }
33
+ hash_certificato[:serial] = certificato.serial
34
+ hash_certificato[:not_after] = certificato.not_after
35
+ hash_certificato[:not_before] = certificato.not_before
36
+ array_cert_firmatari << hash_certificato
37
+ }
38
+
39
+ array_firmatari = []
40
+ firmatari.each{ |firmatario|
41
+ hash_firmatario = {}
42
+ hash_firmatario[:issuer] = {}
43
+ firmatario.issuer.to_a.each{ |item_of_name|
44
+ hash_firmatario[:issuer][item_of_name[0].to_sym] = item_of_name[1]
45
+ }
46
+ hash_firmatario[:name] = {}
47
+ firmatario.name.to_a.each{ |item_of_name|
48
+ hash_firmatario[:name][item_of_name[0].to_sym] = item_of_name[1]
49
+ }
50
+ hash_firmatario[:serial] = firmatario.serial
51
+ hash_firmatario[:signed_time] = firmatario.signed_time
52
+ array_firmatari << hash_firmatario
53
+ }
54
+ { :esito => 'true', :firmatari => array_firmatari, :certificati => array_cert_firmatari }
55
+
56
+ else
57
+ { :esito => 'false', :error_string => signature.error_string }
58
+
59
+ end
60
+ end
61
+
62
+
63
+ end
64
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spiderfw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.33
4
+ version: 0.6.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Pirlik
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-11-19 00:00:00 Z
12
+ date: 2015-03-05 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cmdparse
@@ -1503,6 +1503,7 @@ files:
1503
1503
  - lib/spiderfw/utils/logger.rb
1504
1504
  - lib/spiderfw/utils/loggers/apache_commons_logger.rb
1505
1505
  - lib/spiderfw/utils/memory.rb
1506
+ - lib/spiderfw/utils/mixins.rb
1506
1507
  - lib/spiderfw/utils/monkey/class.rb
1507
1508
  - lib/spiderfw/utils/monkey/date_time.rb
1508
1509
  - lib/spiderfw/utils/monkey/debugger.rb
@@ -1515,6 +1516,7 @@ files:
1515
1516
  - lib/spiderfw/utils/monkey/symbol.rb
1516
1517
  - lib/spiderfw/utils/monkey/time.rb
1517
1518
  - lib/spiderfw/utils/multi_level_hash.rb
1519
+ - lib/spiderfw/utils/openssl_wrapper.rb
1518
1520
  - lib/spiderfw/utils/ordered_hash.rb
1519
1521
  - lib/spiderfw/utils/periodic_runner.rb
1520
1522
  - lib/spiderfw/utils/profiling.rb