spiderfw 0.6.18 → 0.6.19

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ = 0.6.19
2
+ == 21 September, 2011
3
+ * Fixes: DbMapper join logic, configuration editor, js files compilation, Rack set_body_io (used by SOAP)
4
+
1
5
  = 0.6.18
2
6
  == 16 September, 2011
3
7
  * Thread management (keeps track of threads to wait for when exiting)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.18
1
+ 0.6.19
@@ -43,7 +43,7 @@ Spider::Template.define_named_asset 'jquery-ui-core', [
43
43
  [:js, 'js/jquery/jquery-ui-1.8.11/ui/jquery.ui.mouse.js', Spider::Components],
44
44
  [:js, 'js/jquery/jquery-ui-1.8.11/ui/jquery.ui.position.js', Spider::Components],
45
45
  [:css, 'js/jquery/jquery-ui-1.8.11/css/Aristo/jquery-ui.custom.css', Spider::Components]
46
- ]
46
+ ], :depends => ['jquery']
47
47
 
48
48
  Spider::Template.define_named_asset 'jquery-ui-draggable', [
49
49
  [:js, 'js/jquery/jquery-ui-1.8.11/ui/jquery.ui.draggable.js', Spider::Components]
@@ -113,7 +113,7 @@ module Spider
113
113
  end
114
114
  add_next = nil
115
115
  end
116
- if line =~ /(\s*)(\w[^:]+):\s*(.+)?$/
116
+ if line =~ /^(\s*)(\w[^:]+):\s*(.+)?$/
117
117
  indent = $1
118
118
  key = $2
119
119
  value = $3
@@ -175,6 +175,8 @@ module Spider
175
175
  end
176
176
  curr = data
177
177
  res << line
178
+ elsif line =~ /^\s*#/
179
+ res << line
178
180
  else # value line
179
181
  curr_val << line
180
182
  end
@@ -200,4 +202,4 @@ module Spider
200
202
 
201
203
  end
202
204
 
203
- end
205
+ end
@@ -55,7 +55,11 @@ module Spider; module HTTP
55
55
 
56
56
  def set_body_io(io)
57
57
  return super if headers_sent?
58
- @response.body = io
58
+ begin
59
+ @response[:body].close
60
+ rescue => exc
61
+ end
62
+ @response[:body] = io
59
63
  send_headers
60
64
  end
61
65
 
@@ -34,7 +34,7 @@ module Spider; module Model
34
34
  return c
35
35
  end
36
36
 
37
- @comparison_operators = %w{= > < >= <= <> != like}
37
+ @comparison_operators = %w{= > < >= <= <> like}
38
38
  @comparison_operators_regexp = @comparison_operators.inject('') do |str, op|
39
39
  str += '|' unless str.empty?
40
40
  str += Regexp.quote(op)
@@ -173,11 +173,11 @@ module Spider; module Model
173
173
  value = value.to_a
174
174
  end
175
175
  if value.is_a?(Array) && comparison != 'between'
176
- or_cond = self.class.or
176
+ multi_cond = comparison == '<>' ? self.class.and : self.class.or
177
177
  value.uniq.each do |v|
178
- or_cond.set(field, comparison, v)
178
+ multi_cond.set(field, comparison, v)
179
179
  end
180
- @subconditions << or_cond
180
+ @subconditions << multi_cond
181
181
  return self
182
182
  end
183
183
  parts = []
@@ -454,7 +454,7 @@ module Spider; module Model
454
454
  :== => '=',
455
455
  :not => '<>'
456
456
  }
457
- if (replace[op])
457
+ if replace[op]
458
458
  op = replace[op]
459
459
  end
460
460
  op = op.to_s
@@ -494,7 +494,7 @@ module Spider; module Model; module Mappers
494
494
  cond[:values] = []
495
495
 
496
496
 
497
-
497
+ # Returns an hash of elements that need an "inner" join
498
498
  def get_join_info(model, condition)
499
499
  join_info = {}
500
500
  condition.each_with_comparison do |k, v, comp|
@@ -503,31 +503,50 @@ module Spider; module Model; module Mappers
503
503
  next unless element
504
504
  next unless model.mapper.mapped?(element)
505
505
  next unless element.model?
506
- join_info[k.to_s] = true if !v.nil? || (comp != '=' && comp != 'like' && comp != 'ilike')
506
+ join_info[k.to_s] = if v.nil?
507
+ comp == '<>' ? true : false
508
+ else
509
+ comp == '<>' ? false : true
510
+ end
507
511
  if v.is_a?(Spider::Model::Condition)
508
512
  el_join_info = get_join_info(element.model, v)
513
+ has_true = false
514
+ has_false = false
509
515
  el_join_info.each do |jk, jv|
510
516
  join_info["#{k}.#{jk}"] = jv
517
+ has_true = true if jv
518
+ has_false = true unless jv
519
+ end
520
+ if (v.conjunction == :and && has_true) || (has_true && !has_false)
521
+ join_info[k.to_s] = true
522
+ elsif (v.conjunction == :or && has_false) || (has_false && !has_true)
523
+ join_info[k.to_s] = false
511
524
  end
512
525
  end
513
526
  end
527
+ sub = {}
514
528
  condition.subconditions.each do |sub_cond|
529
+ next if sub_cond.empty?
515
530
  sub_join_info = get_join_info(model, sub_cond)
516
- if condition.conjunction == :or
517
- join_info.each_key do |k|
518
- join_info.delete(k) unless sub_join_info[k]
531
+ sub_join_info.each_key do |k|
532
+ if condition.conjunction == :or
533
+ sub[k] = true if sub_join_info[k] && sub[k] != false
534
+ sub[k] = false unless sub_join_info
535
+ else
536
+ sub[k] = true if sub_join_info[k]
519
537
  end
520
- else
521
- join_info.merge!(sub_join_info)
522
538
  end
523
539
  end
540
+ join_info.merge!(sub)
524
541
  join_info
525
542
  end
543
+
544
+
526
545
 
527
546
  join_info = options[:join_info]
528
547
  join_info ||= get_join_info(@model, condition)
529
548
 
530
-
549
+
531
550
  condition.each_with_comparison do |k, v, comp|
532
551
  if k.is_a?(QueryFuncs::Function)
533
552
  field = prepare_queryfunc(k)
@@ -541,7 +560,7 @@ module Spider; module Model; module Mappers
541
560
  el_join_info = {}
542
561
  join_info.each do |jk, jv|
543
562
  if jk.index(k.to_s+'.') == 0
544
- el_join_info[jk[k.to_s.length..-1]] = jv
563
+ el_join_info[jk[k.to_s.length+1..-1]] = jv
545
564
  end
546
565
  end
547
566
  if (v && model.mapper.have_references?(element.name) && v.select{ |key, value|
@@ -557,7 +576,7 @@ module Spider; module Model; module Mappers
557
576
  end
558
577
  cond[:values] << element_cond
559
578
  else
560
- if (element.storage == model.mapper.storage)
579
+ if element.storage == model.mapper.storage
561
580
  join_type = join_info[element.name.to_s] ? :inner : :left
562
581
  sub_join = model.mapper.get_join(element, join_type)
563
582
  # FIXME! cleanup, and apply the check to joins acquired in other places, too (maybe pass the current joins to get_join)
@@ -566,6 +585,7 @@ module Spider; module Model; module Mappers
566
585
  had_join = false
567
586
  existent.each do |j|
568
587
  if sub_join[:to] == j[:to] && sub_join[:keys] == j[:keys] && sub_join[:conditions] == j[:conditions]
588
+ # if any condition allows a left join, then a left join should be used here as well
569
589
  j[:type] = :left if sub_join[:type] == :left
570
590
  sub_join = j
571
591
  had_join = true
@@ -595,7 +615,6 @@ module Spider; module Model; module Mappers
595
615
  end
596
616
  cond[:values] << element_cond
597
617
  elsif v
598
- v = element.model.mapper.preprocess_condition(v)
599
618
  sub_condition, sub_joins = element.mapper.prepare_condition(v, :table => sub_join[:as], :joins => joins, :join_info => el_join_info)
600
619
  sub_condition[:table] = sub_join[:as] if sub_join[:as]
601
620
  joins = sub_joins
@@ -345,7 +345,7 @@ module Spider; module Model
345
345
  if element.attributes[:junction_id]
346
346
  val.each do |row|
347
347
  next unless row_id = row.get(element.attributes[:junction_id])
348
- condition.set(:id, '<>', row_id)
348
+ condition.set(element.attributes[:junction_id], '<>', row_id)
349
349
  end
350
350
  end
351
351
  element.model.mapper.delete(condition)
@@ -930,25 +930,33 @@ module Spider; module Model
930
930
  condition.conditions_array.each do |k, v, c|
931
931
  next if k.is_a?(Spider::QueryFuncs::Function)
932
932
  next unless element = model.elements[k]
933
- if (element.integrated?)
934
- condition.delete(k)
935
- integrated_from = element.integrated_from
936
- integrated_from_element = element.integrated_from_element
937
- condition.set("#{integrated_from.name}.#{integrated_from_element}", c, v)
938
- elsif (element.junction? && !v.is_a?(BaseModel) && !v.is_a?(Hash) && !v.nil?) # conditions on junction id don't make sense
939
- condition.delete(k)
940
- condition.set("#{k}.#{element.attributes[:junction_their_element]}", c, v)
941
- end
942
- if (element.type < Spider::DataType && !v.is_a?(element.type))
933
+ changed_v = false
934
+ if element.type < Spider::DataType && !v.is_a?(element.type)
943
935
  condition.delete(k)
944
936
  begin
945
- condition.set(k, c, element.type.from_value(v))
937
+ v = element.type.from_value(v)
938
+ changed_v = true
946
939
  rescue TypeError => exc
947
940
  raise TypeError, "Can't convert #{v} to #{element.type} for element #{k} (#{exc.message})"
948
941
  end
949
942
  elsif element.type == DateTime && v && !v.is_a?(Date) && !v.is_a?(Time)
943
+ v = DateTime.parse(v)
944
+ changed_v = true
945
+ elsif element.model? && v.is_a?(Spider::Model::Condition)
946
+ v = element.mapper.preprocess_condition(v)
947
+ changed_v = true
948
+ end
949
+ if element.integrated?
950
+ condition.delete(k)
951
+ integrated_from = element.integrated_from
952
+ integrated_from_element = element.integrated_from_element
953
+ condition.set("#{integrated_from.name}.#{integrated_from_element}", c, v)
954
+ elsif element.junction? && !v.is_a?(BaseModel) && !v.is_a?(Hash) && !v.nil? # conditions on junction id don't make sense
955
+ condition.delete(k)
956
+ condition.set("#{k}.#{element.attributes[:junction_their_element]}", c, v)
957
+ elsif changed_v
950
958
  condition.delete(k)
951
- condition.set(k, c, DateTime.parse(v))
959
+ condition.set(k, c, v)
952
960
  end
953
961
  end
954
962
  end
@@ -233,8 +233,8 @@ module Spider
233
233
  curr = Dir.glob(pub_dest+"/._#{name}.*.js")
234
234
  unless curr.empty?
235
235
  curr.each do |f|
236
- name = File.basename(f)
237
- if name =~ /(\d+)\.js$/
236
+ currname = File.basename(f)
237
+ if currname =~ /(\d+)\.js$/
238
238
  version = $1.to_i if $1.to_i > version
239
239
  File.unlink(f)
240
240
  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: 35
4
+ hash: 33
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 18
10
- version: 0.6.18
9
+ - 19
10
+ version: 0.6.19
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: 2011-09-16 00:00:00 +02:00
18
+ date: 2011-09-21 00:00:00 +02:00
19
19
  default_executable: spider
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency