feidee_utils 0.0.6.1 → 0.0.6.2

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: 13652aed513e122b73d0f6a0c8444038f62e6ce7
4
- data.tar.gz: 7e6471828e9b63c29d0509cbe0a4623fdfcb1447
3
+ metadata.gz: 319e55e5339d503de7cacd974b4973fb61047055
4
+ data.tar.gz: 96b926526884bcfdd95b0d660e21f06d0ed6ed1d
5
5
  SHA512:
6
- metadata.gz: 9850f54ef6101377e427e5074e7070660283713b9333ee8f289471fcf01f6817adc40989e161ab35e945b9ba494d9be52c74e67fb97485428e09833a5555d581
7
- data.tar.gz: 463fba9a6616c73a0333338eee7610a22476dfea791be9acc5e4152313f286f7b5fe1da28d973c100966e23fa1cfba7dd774dddadd06292ec9b4d77760a558e1
6
+ metadata.gz: 8b288bf8bba784ce501e979a871f514ae293f0d6ab83b3641b201e0f0b7f48ac22b2c87eabcd922583400216e4b9787d109f36f88e1245a30c42d810b0390ea4
7
+ data.tar.gz: b0d87edaef250212a95e60c5fb9776e4cf318420d6de6631fb01990a59adf6b57a275459994e9727129b862cce7dfaff466d14c05d3ffcf5df57daf952327256
@@ -121,16 +121,6 @@ module FeideeUtils
121
121
  "#{name} (Account/#{poid})"
122
122
  end
123
123
 
124
- class ModifiedAccount < Record::ModifiedRecord
125
- define_custom_methods([
126
- :balance,
127
- :credit,
128
- :debit,
129
- :parent,
130
- ])
131
- define_default_methods(FieldMappings)
132
- end
133
-
134
124
  # Schema:
135
125
  # accountPOID LONG NOT NULL,
136
126
  # name varchar(100) NOT NULL,
@@ -12,6 +12,7 @@ module FeideeUtils
12
12
 
13
13
  metadata: "t_metadata",
14
14
  profile: "t_profile",
15
+ id_seed: "t_id_seed",
15
16
  }.freeze
16
17
 
17
18
  PotentialUsefulTables = %w(
@@ -133,6 +134,22 @@ module FeideeUtils
133
134
  sqlite_file.fsync
134
135
  sqlite_file
135
136
  end
137
+
138
+ def sqlite_to_feidee(sqlite, feidee_file = nil, platform = :iOS)
139
+ sqlite.read(Header.length)
140
+ private_header = if platform == :iOS
141
+ FeideeHeader_iOS
142
+ else
143
+ FeideeHeader_Android
144
+ end
145
+
146
+ feidee_file ||= Tempfile.new("feidee_sqlite", binmode: true)
147
+ feidee_file.binmode
148
+ feidee_file.write(private_header)
149
+ feidee_file.write(sqlite.read)
150
+ feidee_file.fsync
151
+ feidee_file
152
+ end
136
153
  end
137
154
 
138
155
  class << self
@@ -46,7 +46,7 @@ module FeideeUtils
46
46
  end
47
47
 
48
48
  protected
49
- # NOTE: Here we assume the underlaying database schema does not change.
49
+ # NOTE: Here we assume the underlying database schema does not change.
50
50
  # The assumption is safe in the sense that it is generally expected to
51
51
  # restart and/or recompile your application after updating the schema.
52
52
  def define_indexed_accessors
@@ -3,7 +3,6 @@ require 'feidee_utils/record/computed'
3
3
  require 'feidee_utils/record/namespaced'
4
4
  require 'feidee_utils/record/persistent'
5
5
  require 'feidee_utils/record/utils'
6
- require 'feidee_utils/record/modified_record'
7
6
 
8
7
  module FeideeUtils
9
8
  # The implementation here is wired.
@@ -212,20 +212,6 @@ module FeideeUtils
212
212
  str + " at #{trade_at} (Transaction #{poid})";
213
213
  end
214
214
 
215
- class ModifiedTransaction < ModifiedRecord
216
- define_custom_methods([
217
- :created_at,
218
- :modified_at,
219
- :trade_at,
220
- :type,
221
- :category_poid,
222
- :buyer_deduction,
223
- :seller_addition,
224
- :amount,
225
- ])
226
- define_default_methods(FieldMappings)
227
- end
228
-
229
215
  private
230
216
  def sign_by_type num
231
217
  # This is awkward. For transactions of type positive_initial_balance, the
@@ -1,3 +1,3 @@
1
1
  module FeideeUtils
2
- VERSION = '0.0.6.1'
2
+ VERSION = '0.0.6.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feidee_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6.1
4
+ version: 0.0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liqing Muyi
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '1.2'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 1.2.0
42
+ version: 1.2.2
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '1.2'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 1.2.0
52
+ version: 1.2.2
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: sqlite3
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -133,7 +133,6 @@ files:
133
133
  - lib/feidee_utils/record.rb
134
134
  - lib/feidee_utils/record/accessors.rb
135
135
  - lib/feidee_utils/record/computed.rb
136
- - lib/feidee_utils/record/modified_record.rb
137
136
  - lib/feidee_utils/record/namespaced.rb
138
137
  - lib/feidee_utils/record/persistent.rb
139
138
  - lib/feidee_utils/record/utils.rb
@@ -1,76 +0,0 @@
1
- module FeideeUtils
2
- class Record
3
- # TODO: Reconsider this class and ship full support to all entities.
4
- class ModifiedRecord
5
- attr_reader :poid
6
- attr_reader :base, :head
7
- attr_reader :modified_fields
8
-
9
- def initialize(poid, base, head)
10
- raise "Base row doesn't have the given poid." if base.poid != poid
11
- raise "Head row doesn't have the given poid." if head.poid != poid
12
- @poid = poid
13
- @base = base
14
- @head = head
15
- @modified_fields = self.class.fields_diff(base.field, head.field)
16
- end
17
-
18
- class ValuePair
19
- attr_reader :old_value, :new_value
20
- def initialize(old_value, new_value)
21
- @old = old_value
22
- @new = new_value
23
- end
24
- end
25
-
26
- def self.fields_diff base, head
27
- (base.keys.sort | head.keys.sort).inject({}) do |hash, key|
28
- if base[key] != head[key]
29
- hash[key] = ValuePair.new(base[key], head[key])
30
- end
31
- hash
32
- end
33
- end
34
-
35
- def touched?
36
- !modified_fields.empty?
37
- end
38
-
39
- def changed?
40
- methods.inject(false) do |acc, name|
41
- if name.to_s.end_with? "_changed?"
42
- acc ||= send name
43
- end
44
- acc
45
- end
46
- end
47
-
48
- protected
49
- def self.define_custom_methods fields
50
- fields.each do |name|
51
- if !respond_to? name
52
- define_method name do
53
- ValuePair.new((base.send name), (head.send name))
54
- end
55
- define_method (name.to_s + "_changed?").to_sym do
56
- (base.send name) != (head.send name)
57
- end
58
- end
59
- end
60
- end
61
-
62
- def self.define_default_methods field_mappings
63
- field_mappings.each do |name, key|
64
- if !respond_to? name
65
- define_method name do
66
- modified_fields[key]
67
- end
68
- define_method (name.to_s + "_changed?").to_sym do
69
- modified_fields.has_key? key
70
- end
71
- end
72
- end
73
- end
74
- end
75
- end
76
- end