flexi-json 0.4.0 → 0.4.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +8 -7
- data/lib/flexi/json/version.rb +1 -1
- data/lib/flexi/json.rb +7 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d23543bb36512b335987eb6c12815956d98b170f2148fbbf12b92454064a96c
|
4
|
+
data.tar.gz: 8872ba4b925901cdeee8dcf27e5a409ca3784366dcf64ad370e60cdfe919bc54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7acf01abdf37decc0f5d5d8a230da8b91f542d0dbb6c81efb90d5f229a1245b58764c0ba05fe0aa59b72348e3ef26b3b5484fc12f8700b108a49f3a0a4481c74
|
7
|
+
data.tar.gz: b6d8d236da0e37f0a9fd8a3785403363f5fc783820ea1ba351d7cf2647ec4f5666b24928ccd68a2eac6e0be94d4a41e707deb9acc948402acb8f91d4050a28dd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# Version: 0.4.1 (22-09-2024)
|
2
|
+
|
3
|
+
* [0270c44](https://github.com/GD-Personal/flexi-json/commit/0270c44d7ffabd88ed0b69b09f1e98910257d99b): Update the readme and changelog
|
4
|
+
|
5
|
+
|
6
|
+
# Version: 0.4.0 - 2024-09-22
|
7
|
+
|
8
|
+
* [#15](https://github.com/GD-Personal/flexi-json/pull/15): Add a configuration and renamed matched_all to match_all.
|
9
|
+
|
1
10
|
# Version: 0.3.0 - 2024-09-22
|
2
11
|
|
3
12
|
* [#10](https://github.com/GD-Personal/flexi-json/pull/10): Release 0.2.0
|
data/README.md
CHANGED
@@ -28,18 +28,19 @@ bundle install
|
|
28
28
|
```ruby
|
29
29
|
require 'flexi/json'
|
30
30
|
|
31
|
-
# Load a json data from a local file
|
32
|
-
flexi_json = Flexi::Json::Run.new("some/path/to/file.json")
|
33
|
-
|
34
31
|
# Load a raw json data
|
35
|
-
flexi_json = Flexi::Json
|
36
|
-
# => <Flexi::Json
|
32
|
+
flexi_json = Flexi::Json.new("{\"name\":\"John\",\"address\":\"Sydney Australia\"}")
|
33
|
+
# => <Flexi::Json:0x0000ffffa0f5fc58 @datasets=[#<Flexi::Json::Dataset:0x0000ffffa0f5f668 @address="Sydney Australia", @attributes={:name=>"John", :address=>"Sydney Australia"}, @name="John", @searchable_fields=["name", "address"]>]>
|
37
34
|
|
38
|
-
# Load a json data from
|
39
|
-
flexi_json = Flexi::Json
|
35
|
+
# Load a json data from a local file
|
36
|
+
flexi_json = Flexi::Json.new("some/path/to/file.json")
|
37
|
+
|
38
|
+
# Load a json data from a url
|
39
|
+
flexi_json = Flexi::Json.new("https://raw.githubusercontent.com/GD-Personal/flexi-json/main/spec/data/dataset.json")
|
40
40
|
|
41
41
|
# Search for data
|
42
42
|
flexi_json.search("john")
|
43
|
+
# => [#<Flexi::Json::Dataset:0x0000ffffa0f5f668 @address="Sydney Australia", @attributes={:name=>"John", :address=>"Sydney Australia"}, @name="John", @searchable_fields=["name", "address"]>]
|
43
44
|
|
44
45
|
# Or filter it by your chosen key e.g first_name
|
45
46
|
flexi_json.search("john", "first_name")
|
data/lib/flexi/json/version.rb
CHANGED
data/lib/flexi/json.rb
CHANGED
@@ -19,21 +19,18 @@ module Flexi::Json
|
|
19
19
|
def configure
|
20
20
|
yield(configuration)
|
21
21
|
end
|
22
|
-
end
|
23
22
|
|
24
|
-
|
25
|
-
# Your code goes here...
|
26
|
-
def initialize(data)
|
23
|
+
def new(data)
|
27
24
|
datasets = Flexi::Json::Loader.new(data).load_data
|
28
25
|
@searcher = Flexi::Json::Searcher.new(datasets)
|
29
26
|
end
|
27
|
+
end
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
def search(query = "", fields = nil)
|
30
|
+
@searcher.search(query, fields)
|
31
|
+
end
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
33
|
+
def find_duplicates(keys)
|
34
|
+
@searcher.find_duplicates(keys)
|
38
35
|
end
|
39
36
|
end
|