dxlite 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +2 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/dxlite.rb +58 -0
  5. metadata +110 -0
  6. metadata.gz.sig +0 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 23082020cd65c50d0f9bb1565d1edab3e740c37e8e5162c02a4f60b9e29ea78e
4
+ data.tar.gz: 9224232152f762b4d8c1cefd0c4f92ec46b2733dd5a5f0cb77915c05add78739
5
+ SHA512:
6
+ metadata.gz: 884afeeffa6633912460e53cca866e21e0d6c58610a682f2909bf587b214f476410ccd5299d04591daccbfa1984baf7864aa8d6fcee6de8a2f5167f59fbc235c
7
+ data.tar.gz: fb7a06d3ba34a8804ebb04816226beaea8b627a2d543ab6d034507f781a660f592afa9f0a68178bb33c2490316a9414b7a4319f0ab8c147e3f4254443017fe58
@@ -0,0 +1,2 @@
1
+ r[n=p��V2�� ���c�y�P�mki�ݮb�8o����W���G�R���Z
2
+ [��( �>}Br�g��vU'�a��7Y�5�<t?������ �m'���Zs��r-`9b�
Binary file
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: dxlite.rb
4
+
5
+ require 'json'
6
+ require 'recordx'
7
+ require 'rxfhelper'
8
+
9
+ class DxLite
10
+
11
+ attr_accessor :summary
12
+ attr_reader :records
13
+
14
+ def initialize(s, debug: false)
15
+
16
+ @debug = debug
17
+
18
+ buffer, type = RXFHelper.read(s)
19
+ puts 'type: ' + type.inspect if @debug
20
+ h = JSON.parse(buffer, symbolize_names: true)
21
+
22
+ @filepath = s if type == :file
23
+
24
+ @summary = h[:summary]
25
+ @records = h[:records]
26
+ @fields = @summary[:schema][/(?<=\()[^\)]+/].split(',').map(&:strip)
27
+
28
+ @fields.each do |x|
29
+
30
+ define_singleton_method ('find_all_by_' + x).to_sym do |value|
31
+ @records.select {|rec| rec[x.to_sym] == value }
32
+ end
33
+
34
+ define_singleton_method ('find_by_' + x).to_sym do |value|
35
+ @records.find {|rec| rec[x.to_sym] == value }
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+
42
+ def all()
43
+
44
+ @records.map do |h|
45
+ RecordX.new(h, self, h[:id], h[:created], h[:last_modified])
46
+ end
47
+
48
+ end
49
+
50
+ def create(h)
51
+ @records << h
52
+ end
53
+
54
+ def save(file=@filepath)
55
+ File.write file, @records.to_json
56
+ end
57
+
58
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dxlite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAwNjIwMDk1OTIyWhcN
15
+ MjEwNjIwMDk1OTIyWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCcnuff
17
+ 5MVmDII05CloWme8XkTcCkGTFTCGqacPAa5803163oHfU0CovEbdSR8KNVXQ0mVz
18
+ ZkE1kEi/xlAbZHKZTgJNjzXKcTfW0zNI/1l9Jyz59fjOUgO26oWgEJX1iJBUkzAx
19
+ 1jHBvCGvAgKi1gmPovfrnPkXJ4e39Kklay4mrsfRO1qAkyfoUCn8TOc4/xVyB9UV
20
+ zpSfryHT41gM3vUyVyfkLsC8St6oI2j6R45YJIL2Hz1UBZsFk8ICn8MKL84b+nyX
21
+ YiW3BoOh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-----END CERTIFICATE-----
38
+ date: 2020-06-20 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: recordx
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.0.0
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.0'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.0.0
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.0'
60
+ - !ruby/object:Gem::Dependency
61
+ name: rxfhelper
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0.5'
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.5.4
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.5'
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 0.5.4
80
+ description:
81
+ email: james@jamesrobertson.eu
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - lib/dxlite.rb
87
+ homepage: https://github.com/jrobertson/dxlite
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.0.3
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Handles Dynarex documents (in JSON format) faster and with less overheads.
110
+ test_files: []
Binary file