feidee_utils 0.0.5.2 → 0.0.5.3

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: 1de248b25404a51294532bce5b317e4c7bb8bc52
4
- data.tar.gz: 1207e7caf079f5e73c68e8095347f5dfb29c53d4
3
+ metadata.gz: 52939cfeaaed123fbd26ae21d28323de5e4f9315
4
+ data.tar.gz: e9fea8a9ebda721a02a0a71a49a4aed8b4382bad
5
5
  SHA512:
6
- metadata.gz: c1758936bfd77bfe716459cb8151898766b0c50b07d526ebe1f3e8f2dc48a1cbd86993f2c059315f70f6a3c2030057c6bfd4271cb6ea7b1a473cc0675f6918aa
7
- data.tar.gz: 22cde31f522334fc6e436eadcef31c0a888aa4450dc00233455c7a861c9ffd9a2200ff74e19516b13a997e0f4f29dd64e6f356617e9685509afbda2315062098
6
+ metadata.gz: 262d1e6c897f1ad951605df672c58d1f2058eb5d28554754100e8ee5e340606533a0e0dad838d01db0738b960df6b6912be520a60367a67e34a41ed1055c0331
7
+ data.tar.gz: 74daf0b8276450c6359668881731ba86f2339a882340098457e91c2dabcd251fc2c0cfd231057de214de03acc626adedb5588e831f163dd511587e5fa13bf85a
data/README.md CHANGED
@@ -59,7 +59,7 @@ Sometimes we have to compare the content of two backups and must open them at
59
59
  the same time. Only one database can be opened using ActiveRecord. It is not
60
60
  designed to be used in such a way.
61
61
 
62
- Why Feidee Utils At All
62
+ Why Feidee Utils at all
63
63
  -----------
64
64
  Originally the Feidee Android and iOS app let users export their personal data
65
65
  recorded by the app. Since some version last year (2014), the export
@@ -5,18 +5,18 @@ require 'bigdecimal'
5
5
  module FeideeUtils
6
6
  class Account < Record
7
7
  def validate_integrity
8
- unless not field["type"] or field["type"] == 0
9
- raise "Account type should always be 0, but it's #{field["type"]}.\n" +
8
+ unless not column("type") or column("type") == 0
9
+ raise "Account type should always be 0, but it's #{column("type")}.\n" +
10
10
  inspect
11
11
  end
12
- unless field["usedCount"] == 0
12
+ unless column("usedCount") == 0
13
13
  raise "Account usedCount should always be 0," +
14
- " but it's #{field["usedCount"]}.\n"+
14
+ " but it's #{column("usedCount")}.\n"+
15
15
  inspect
16
16
  end
17
- unless field["uuid"].to_s.empty?
17
+ unless column("uuid").to_s.empty?
18
18
  raise "Account uuid should always be empty,"+
19
- " but it's #{field["uuid"]}.\n" +
19
+ " but it's #{column("uuid")}.\n" +
20
20
  inspect
21
21
  end
22
22
  unless flat_parent_hierachy?
@@ -10,9 +10,9 @@ module FeideeUtils
10
10
  def validate_integrity
11
11
  validate_depth_integrity
12
12
  validate_one_level_path_integrity
13
- unless field["usedCount"] == 0
13
+ unless column("usedCount") == 0
14
14
  raise "Category usedCount should always be 0, " +
15
- "but it's #{field["usedCount"]}.\n" +
15
+ "but it's #{column("usedCount")}.\n" +
16
16
  inspect
17
17
  end
18
18
  end
@@ -2,11 +2,11 @@ module FeideeUtils
2
2
  class Record
3
3
  module Accessors
4
4
  def poid
5
- @field[self.class.id_field_name]
5
+ column(self.class.id_field_name)
6
6
  end
7
7
 
8
8
  def last_update_time
9
- timestamp_to_time(@field["lastUpdateTime"])
9
+ timestamp_to_time(column("lastUpdateTime"))
10
10
  end
11
11
 
12
12
  module ClassMethods
@@ -15,7 +15,7 @@ module FeideeUtils
15
15
  if method_defined? name
16
16
  raise "Accessor #{name} already exists in #{self.name}."
17
17
  end
18
- define_method name do field[key] end
18
+ define_method name do column(key) end
19
19
  end
20
20
  end
21
21
 
@@ -23,12 +23,10 @@ module FeideeUtils
23
23
  # is created in a new namepsace. For each subclass of Record, a new subclass
24
24
  # is copied to the new namespace, with it's database method overloaded.
25
25
  class Record
26
- attr_reader :field, :field_type
27
-
28
26
  public
29
- def initialize(columns, types, raw_row)
30
- @field = Hash[ columns.zip(raw_row) ]
31
- @field_type = Hash[ columns.zip(types) ]
27
+ def initialize(columns, types, row)
28
+ @columns = columns.freeze
29
+ @row = row.freeze
32
30
 
33
31
  validate_integrity
34
32
  end
@@ -68,5 +66,18 @@ module FeideeUtils
68
66
  extend Persistent::ClassMethods
69
67
  # Helper methods to convert data types.
70
68
  include Utils
69
+
70
+ protected
71
+ def column key
72
+ # Looking up index is not as slow as it appears. The size of the array is
73
+ # usually less than 20 and the strings are usually different in the first
74
+ # few characters. The overhead is relatively low.
75
+ # In fact, a downstream benchmark showed that it is faster than building a
76
+ # hash upfront and lookup the hash here.
77
+ index = @columns.index key
78
+ return nil if index.nil?
79
+ @row[index]
80
+ end
81
+
71
82
  end
72
83
  end
@@ -1,3 +1,3 @@
1
1
  module FeideeUtils
2
- VERSION = '0.0.5.2'
2
+ VERSION = '0.0.5.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feidee_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5.2
4
+ version: 0.0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liqing Muyi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-08 00:00:00.000000000 Z
11
+ date: 2018-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  version: '0'
160
160
  requirements: []
161
161
  rubyforge_project:
162
- rubygems_version: 2.5.2
162
+ rubygems_version: 2.5.2.3
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: Utils to extract useful information from Feidee Mymoney backup.