qooxview 1.9.11 → 1.9.13.pre.10

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
2
  SHA1:
3
- metadata.gz: 9c23748472d694e11be55e85c959055bd08158c5
4
- data.tar.gz: 24f715cfadda8ffc48cc41f81b6e05b5890164cd
3
+ metadata.gz: b9dc1d652ab06b076f0a8c32b3ec1c26d7b0ebb4
4
+ data.tar.gz: 5dc2b0fe255e8273113bedc2a40d849fefee3b5c
5
5
  SHA512:
6
- metadata.gz: a76c27f533696e75d974f9b8655c1115bea68c5c485867b75785cc0fbc0702b9366573dc043d9020223fba5f7f853220bcfc789aa82ba5868dceb9430845c971
7
- data.tar.gz: 49d5c59baa85e88e0f55115517f8c19893ec3db8605b42bd14e6c55bae4124e2af0737d6381e416b8f507c464d015b3661da506fe0cc92414d79aa9846f95c13
6
+ metadata.gz: 805aab3ebb9df5f49ea40dabd5e40ee3aa338686ceeb9c770174716590c5de955977d9c88e423b44b4d870f524c864d6bf1df2646feac64869c19926e0a4eefd
7
+ data.tar.gz: 83862647d06e66de41811fb6239d84770907365c06aa863d874e94c7f1832d34660c71b30238a141f819e59821c04522ca79c5000c1ccc5d6771e7bfd8eb4ef0
@@ -21,7 +21,8 @@ class Array
21
21
  end
22
22
 
23
23
  def to_frontend(arg = nil)
24
- collect { |a| a.to_frontend(arg) }.sort { |a, b| a[1]<=>b[1] }
24
+ collect { |a| a.to_frontend(arg) }.compact.reject{|e| e[1] == nil}.
25
+ sort { |a, b| a[1]<=>b[1] }
25
26
  end
26
27
 
27
28
  def to_s
@@ -31,7 +31,7 @@ class Entities < RPCQooxdooService
31
31
  def initialize
32
32
  begin
33
33
  @data_class = eval(singular(self.class.name))
34
- rescue Exception => e
34
+ rescue Exception
35
35
  # Just in case the data-class is not created yet
36
36
  eval("class #{singular(self.class.name)} < Entity\nend", TOPLEVEL_BINDING)
37
37
  @data_class = eval(singular(self.class.name))
@@ -173,7 +173,7 @@ class Entities < RPCQooxdooService
173
173
  # instantiated - useful for stuff like long LDAP-lists...
174
174
  def get_data_instance(k)
175
175
  return nil if !k
176
- if k.class != Integer
176
+ if k.class.to_s !~ /(Integer|Fixnum)/
177
177
  dputs(0) { 'This is very bad' }
178
178
  dputs(0) { "value k is #{k.inspect} - #{k.class}" }
179
179
  dputs(0) { "caller-stack is #{caller}" }
@@ -582,7 +582,7 @@ class Entity
582
582
  if not raw and e
583
583
  v = @proxy.get_value(f)
584
584
 
585
- if e.class == Integer and v and v.dtype == 'entity'
585
+ if (e.class.to_s =~ /(Integer|Fixnum)/) && v && v.dtype == 'entity'
586
586
  dputs(5) { "Getting instance for #{v.inspect}" }
587
587
  dputs(5) { "Getting instance with #{e.class} - #{e.inspect}" }
588
588
  dputs(5) { "Field = #{field}; id = #{@id}" }
@@ -150,7 +150,7 @@ class ConfigBase < Entity
150
150
  end
151
151
 
152
152
  def save_block_to_object(block, obj)
153
- dputs(3) { "Pushing block #{block} to object #{obj.name}" }
153
+ dputs(3) { "Pushing block #{block} to object #{obj}" }
154
154
  ConfigBases.get_block_fields(block).each { |f|
155
155
  value = data_get(f)
156
156
  dputs(3) { "Setting #{f} in #{block} to #{value}" }
@@ -82,6 +82,7 @@ class Permission
82
82
  end
83
83
 
84
84
  def self.can_view( permission, view )
85
+ # dputs_func
85
86
  action = view.to_s.gsub( /^View\./, '' )
86
87
  dputs( 4 ){ "Does #{permission.inspect} allow to do #{action} knowing #{@@view.inspect} and #{@@parent.inspect}" }
87
88
  if not permission or permission.length == 0
@@ -89,7 +90,7 @@ class Permission
89
90
  end
90
91
 
91
92
  permission.to_a.each{|p|
92
- perm_list = self.getViewParent( p )
93
+ perm_list = self.getViewParent( p.to_s )
93
94
  dputs( 5 ){ "p is #{p} and perm_list is #{perm_list.inspect}" }
94
95
  perm_list.each{|pl|
95
96
  type, data = pl.split(':')
@@ -217,6 +217,7 @@ module StorageHandler
217
217
  end
218
218
 
219
219
  def create(args, allow_double = false)
220
+ # dputs_func
220
221
  oldload = @loading
221
222
  @loading = true
222
223
  if args.class != Hash
@@ -263,7 +264,7 @@ module StorageHandler
263
264
  end
264
265
 
265
266
  def save_data(d)
266
- #dputs_func
267
+ # dputs_func
267
268
  dputs(5) { "Saving #{d.inspect}" }
268
269
  d.to_sym!
269
270
  if d.has_key? @data_field_id
@@ -292,6 +293,10 @@ module StorageHandler
292
293
  dputs(3) { "Deleting id #{id}" }
293
294
  @data.delete(id)
294
295
  @data_instances.delete(id)
296
+ @storage.each{|k, di|
297
+ di.delete id
298
+ }
299
+ @changed = true
295
300
  end
296
301
 
297
302
  def set_entry(id, field, v)
@@ -416,7 +421,7 @@ module StorageHandler
416
421
  @keys = {}
417
422
  @storage.each { |k, di|
418
423
  dputs(5) { "Loading #{k} at #{di.name} with #{di.inspect}" }
419
- @data.merge!(di.load) { |k, o, n| o.merge(n) }
424
+ @data.merge!(di.load) { |_, o, n| o.merge(n) }
420
425
  dputs(5) { "Loaded #{@data.inspect} for #{self.name}" }
421
426
  }
422
427
  if @data.length == 0 && respond_to?(:init)
@@ -102,6 +102,9 @@ class StorageType
102
102
  # If a double-entry has been detected after creation
103
103
  def data_double( data )
104
104
  end
105
+
106
+ def delete(id)
107
+ end
105
108
 
106
109
  def self.new_st( st, entity, config = {} )
107
110
  if StorageType.has? st
@@ -30,7 +30,7 @@ class CSV < StorageType
30
30
  # Saves the data stored, optionally takes an index to say
31
31
  # which data needs to be saved
32
32
  def save(data)
33
- #dputs_func
33
+ # dputs_func
34
34
  @add_only ?
35
35
  dputs(5) { "Not saving data for #{@name}" } :
36
36
  @mutex.synchronize {
@@ -54,12 +54,16 @@ class CSV < StorageType
54
54
 
55
55
  tmpfile = "#{@csv_file}_tmp"
56
56
  File.open(tmpfile, 'w') { |f|
57
- data_each(data) { |d|
58
- write_line(f, d)
59
- if di = @entity.data_instances[d[@data_field_id]]
60
- di.changed = false
61
- end
62
- }
57
+ if data.length == 0
58
+ f << '{}'
59
+ else
60
+ data_each(data) { |d|
61
+ write_line(f, d)
62
+ if di = @entity.data_instances[d[@data_field_id]]
63
+ di.changed = false
64
+ end
65
+ }
66
+ end
63
67
  }
64
68
  FileUtils.mv tmpfile, @csv_file
65
69
  #%x[ sync ]
@@ -115,6 +119,7 @@ class CSV < StorageType
115
119
  # loads the data
116
120
  def load
117
121
  # Go and fetch eventual existing data from the file
122
+ # dputs_func
118
123
  dputs(3) { "Starting to load #{@csv_file}" }
119
124
  @mutex.synchronize {
120
125
  cleanup if Dir.glob("#{@csv_file}*").size > 1
@@ -125,6 +130,7 @@ class CSV < StorageType
125
130
  data = {}
126
131
  File.open(file, 'r').readlines().each { |l|
127
132
  dputs(5) { "Reading line #{l}" }
133
+ l == '{}' and next
128
134
  # Convert the keys in the lines back to Symbols
129
135
  data_parse = JSON.parse(l)
130
136
  data_csv = {}
@@ -23,9 +23,9 @@ class SQLite < StorageType
23
23
  FileUtils.mkdir_p(@sqlite_dir)
24
24
  @name_file = name_file
25
25
  @db_file = File.join(@sqlite_dir, @name_file)
26
- # ActiveRecord::Base.logger = Logger.new('debug.log')
26
+ # ActiveRecord::Base.logger = Logger.new('debug.log')
27
27
  ActiveRecord::Migration.verbose = false
28
- #ActiveRecord::Base.logger = Logger.new(STDERR)
28
+ # ActiveRecord::Base.logger = Logger.new(STDERR)
29
29
 
30
30
  @mutex_es = Mutex.new
31
31
 
@@ -66,6 +66,7 @@ class SQLite < StorageType
66
66
  @mutex_es.synchronize {
67
67
  dputs(3) { "Saving #{@entries_save.count} entries in #{@db_class}" }
68
68
  @entries_save.each_value { |v|
69
+ dputs(4){"Saving #{db_class} #{v.inspect} - #{v.id}"}
69
70
  v.save
70
71
  }
71
72
  @entries_save = {}
@@ -74,11 +75,12 @@ class SQLite < StorageType
74
75
 
75
76
  def set_entry(data, field, value)
76
77
  @mutex_es.synchronize {
78
+ # dp "#{db_class} #{data.inspect} #{field} #{value}"
77
79
  dputs(5) { "Searching id #{data.inspect}" }
78
80
  if @entries[data]
79
81
  @entries[data].save
80
82
  end
81
- dat = @db_class.first(data).first
83
+ dat = @db_class.find(data)
82
84
  # dat = @db_class.first(:conditions => {@data_field_id => data})
83
85
  # dp @entries[data]
84
86
  # dp dat
@@ -98,6 +100,7 @@ class SQLite < StorageType
98
100
  # Each new entry is directly stored, helping somewhat if the program or the
99
101
  # computer crashes
100
102
  def data_create(data)
103
+ # dputs_func
101
104
  dputs(5) { "Creating early data #{data.inspect} with #{data.class}" }
102
105
  dputs(5) { "hello for #{data.inspect}" }
103
106
  dputs(5) { "db_class is #{@db_class.inspect}" }
@@ -170,6 +173,17 @@ class SQLite < StorageType
170
173
  end
171
174
  end
172
175
 
176
+ def delete(id)
177
+ entry = @db_class.find_by(id: id)
178
+ if entry != nil
179
+ entry.destroy
180
+ @entries[id].delete
181
+ if e = @entries_save[id]
182
+ e.delete
183
+ end
184
+ end
185
+ end
186
+
173
187
  def self.with_all_sqlites
174
188
  RPCQooxdooService.entities { |e|
175
189
  e.storage.each { |storage_name, storage_class|
@@ -204,6 +218,7 @@ class SQLite < StorageType
204
218
  e.load
205
219
  e.loading = false
206
220
  u = Users.match_by_name('local')
221
+ dputs(2){"User is #{u}"}
207
222
  end
208
223
  }
209
224
  end
data/lib/qooxview/view.rb CHANGED
@@ -36,7 +36,7 @@ class Object
36
36
  begin
37
37
  @deep_cloning = true
38
38
  val = val.deep_clone
39
- rescue TypeError
39
+ rescue TypeError, RuntimeError
40
40
  next
41
41
  ensure
42
42
  @deep_cloning = false
@@ -596,7 +596,7 @@ class View < RPCQooxdooService
596
596
  ret = []
597
597
  args.keys.each { |a|
598
598
  if l = layout_find(a)
599
- dputs(3) { "found layout for #{a}" }
599
+ dputs(3) { "found layout #{l} for #{a}" }
600
600
  ret += reply(:update, a => args[a])
601
601
  end
602
602
  }
@@ -824,7 +824,7 @@ class View < RPCQooxdooService
824
824
  end
825
825
 
826
826
  # Gets the request and converts the ids of the Entites back to
827
- # the objects they once were - which makes life much more easy...
827
+ # the objects they once were - which makes life much more easy...
828
828
  def parse_request(method, session, params)
829
829
  #dputs_func
830
830
  dputs(3) { "Parsing #{params.inspect}" }
data/qooxview.gemspec CHANGED
@@ -4,14 +4,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'qooxview'
7
- spec.version = '1.9.11'
7
+ spec.version = '1.9.13-10'
8
8
  spec.authors = ['Linus Gasser']
9
- spec.email = ['ineiti@linusetviviane.ch']
9
+ spec.email = 'ineiti.blue'
10
10
  spec.summary = %q{Implements a ruby-backend for QooxDoo.org}
11
11
  spec.description = %q{This is a very simple framework to create small
12
12
  frontends in a webserver}
13
13
  spec.homepage = 'https://github.com/ineiti/qooxview'
14
- spec.license = 'GPLv3'
14
+ spec.license = 'GPL-3.0'
15
15
 
16
16
  spec.files = `if [ -d '.git' ]; then git ls-files -z; fi`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -1,7 +1,7 @@
1
1
  class Movements < Entities
2
2
  def setup_data
3
3
  @default_type = :SQLite
4
-
4
+
5
5
  value_str :desc
6
6
  value_int :money
7
7
  end
data/test/qv_sqlite.rb CHANGED
@@ -70,4 +70,17 @@ class TC_SQLite < Test::Unit::TestCase
70
70
  assert_equal 300, one.money
71
71
  assert_equal 500, two.money
72
72
  end
73
+
74
+ def test_rm_add
75
+ dp 'deleting'
76
+ assert_not_equal nil, Entities.Movements.find_by_desc('pain')
77
+ @m2.delete
78
+ assert_equal nil, Entities.Movements.find_by_desc('pain')
79
+ Entities.delete_all_data(true)
80
+ Entities.load_all
81
+ assert_equal nil, Entities.Movements.find_by_desc('pain')
82
+ dp 'recreating'
83
+ @m2 = Entities.Movements.create( :desc => 'mappa', :money => 250 )
84
+ assert_equal 250, @m2.money
85
+ end
73
86
  end
data/test/qv_store_csv.rb CHANGED
@@ -7,12 +7,12 @@ class TC_Store_CSV < Test::Unit::TestCase
7
7
 
8
8
  dputs(2) { 'Setting up data' }
9
9
  @admin = Persons.create(:first_name => 'admin', :pass => 'super123',
10
- :address => 'cdlf 24', :credit => 10000)
10
+ :address => 'cdlf 24', :credit => 10000)
11
11
  Courses.create(:first_name => 'base_1010', :start => '1.10.2010')
12
12
  @base_1011 = Courses.create(:first_name => 'base_1011', :start => '1.11.2010',
13
- :teacher => @admin)
13
+ :teacher => @admin)
14
14
  @dummies_one = Dummies.create(:first_name => 'one', :phone => '111',
15
- :no_cache => '123')
15
+ :no_cache => '123')
16
16
  dputs(2) { 'Finished setting up data' }
17
17
  end
18
18
 
@@ -43,8 +43,8 @@ class TC_Store_CSV < Test::Unit::TestCase
43
43
 
44
44
  def test_backup_count
45
45
  (0..5).each { |i|
46
- assert( get_persons_csv.size == i,
47
- "We don't have #{i} files, but #{get_persons_csv.size}: #{get_persons_csv.inspect}")
46
+ assert(get_persons_csv.size == i,
47
+ "We don't have #{i} files, but #{get_persons_csv.size}: #{get_persons_csv.inspect}")
48
48
  @admin.first_name = "admin#{i}"
49
49
  Entities.save_all
50
50
  }
@@ -53,8 +53,8 @@ class TC_Store_CSV < Test::Unit::TestCase
53
53
 
54
54
  def test_dirty_data
55
55
  (0..5).each { |i|
56
- assert( get_persons_csv.size == i,
57
- "We don't have #{i} files, but #{get_persons_csv.size}: #{get_persons_csv.inspect}")
56
+ assert(get_persons_csv.size == i,
57
+ "We don't have #{i} files, but #{get_persons_csv.size}: #{get_persons_csv.inspect}")
58
58
  @admin.first_name = "admin#{i}"
59
59
  Entities.save_all
60
60
  }
@@ -83,4 +83,18 @@ class TC_Store_CSV < Test::Unit::TestCase
83
83
  Entities.load_all
84
84
  assert_equal 1, get_persons_csv.count, get_persons_csv
85
85
  end
86
+
87
+ def test_empty_file
88
+ assert_equal 1, Persons.search_all_.length
89
+ Entities.save_all
90
+
91
+ dputs(2) { 'deleting admin' }
92
+ @admin.delete
93
+ assert_equal 0, Persons.search_all_.length
94
+ Entities.save_all
95
+
96
+ dputs(2) { 'loading everything again' }
97
+ Entities.load_all
98
+ assert_equal 0, Persons.search_all_.length
99
+ end
86
100
  end
data/test/test.rb CHANGED
@@ -23,7 +23,7 @@ QooxView.init('entities', 'views')
23
23
 
24
24
  tests = Dir.glob('qv_*.rb')
25
25
  #tests = %w( permission )
26
- #tests = %w( entity )
26
+ #tests = %w( store_csv )
27
27
  #tests = %w( configbase )
28
28
 
29
29
  tests.each { |t|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qooxview
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.11
4
+ version: 1.9.13.pre.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linus Gasser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-01 00:00:00.000000000 Z
11
+ date: 2017-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: helper_classes
@@ -349,15 +349,13 @@ dependencies:
349
349
  description: |-
350
350
  This is a very simple framework to create small
351
351
  frontends in a webserver
352
- email:
353
- - ineiti@linusetviviane.ch
352
+ email: ineiti.blue
354
353
  executables:
355
354
  - test_ldap.rb
356
355
  extensions: []
357
356
  extra_rdoc_files: []
358
357
  files:
359
358
  - ".project"
360
- - ".ruby-version"
361
359
  - Gemfile
362
360
  - Gemfile.lock
363
361
  - LICENSE.txt
@@ -967,7 +965,7 @@ files:
967
965
  - test/views/print.rb
968
966
  homepage: https://github.com/ineiti/qooxview
969
967
  licenses:
970
- - GPLv3
968
+ - GPL-3.0
971
969
  metadata: {}
972
970
  post_install_message:
973
971
  rdoc_options: []
@@ -980,12 +978,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
980
978
  version: '0'
981
979
  required_rubygems_version: !ruby/object:Gem::Requirement
982
980
  requirements:
983
- - - ">="
981
+ - - ">"
984
982
  - !ruby/object:Gem::Version
985
- version: '0'
983
+ version: 1.3.1
986
984
  requirements: []
987
985
  rubyforge_project:
988
- rubygems_version: 2.6.11
986
+ rubygems_version: 2.6.13
989
987
  signing_key:
990
988
  specification_version: 4
991
989
  summary: Implements a ruby-backend for QooxDoo.org
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.4.1