search_json_data 0.1.0 → 1.0.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dcc5bebc971bf6b0904a24c6ef63e4eb7293be3
|
4
|
+
data.tar.gz: 2d4c7e8114e547142c44b6e52909d7373b0f5949
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dd480779b765b4c4affbb051771bd9868fadeaa81d3fceb6365065b81fe3a56ad3dada2b7ab87359707921f62033c4f8c8f0b3216b0e15118429a211a6985cc
|
7
|
+
data.tar.gz: 63adcdd9b2dff0ed5def439719528a9c72ba7b447a2a20fe3650def520ecc2a19c2aa9e49b4f70e5c603cf961ac2ef0f78de61ee39773adc7c2cf8a58a108e97
|
data/README.md
CHANGED
@@ -79,7 +79,7 @@ you will get this results
|
|
79
79
|
=begin
|
80
80
|
you will get this results
|
81
81
|
=> [{"Name"=>"JScript", "Type"=>"Curly-bracket, Procedural, Reflective, Scripting", "Designed by"=>"Microsoft"}, {"Name"=>"VBScript", "Type"=>"Interpreted, Procedural, Scripting, Object-oriented class-based", "Designed by"=>"Microsoft"}, {"Name"=>"Windows PowerShell", "Type"=>"Command line interface, Curly-bracket, Interactive mode, Interpreted, Scripting", "Designed by"=>"Microsoft"}, {"Name"=>"AppleScript", "Type"=>"Scripting", "Designed by"=>"Apple Inc."}, {"Name"=>"Delphi", "Type"=>"Compiled, Object-oriented class-based, Reflective", "Designed by"=>"Apple, Niklaus Wirth, Anders Hejlsberg"}, {"Name"=>"Swift", "Type"=>"Compiled", "Designed by"=>"Chris Lattner, Apple Inc."}]
|
82
|
-
|
82
|
+
=end
|
83
83
|
# serching negative
|
84
84
|
@data.search_by "Scripting -Microsoft"
|
85
85
|
=begin
|
@@ -118,4 +118,4 @@ Run
|
|
118
118
|
```bash
|
119
119
|
yard doc
|
120
120
|
```
|
121
|
-
and open this file with your browser
|
121
|
+
and open this file with your browser doc/index.html
|
@@ -49,7 +49,7 @@ module SearchJsonData
|
|
49
49
|
# if match one or more words
|
50
50
|
match = is_match words_to_match, data_for_search, nil, precision
|
51
51
|
# if match one or more exactly phrases
|
52
|
-
match = is_match exactly_phrases, data_for_search, nil, precision
|
52
|
+
match = match & (is_match exactly_phrases, data_for_search, nil, precision)
|
53
53
|
|
54
54
|
# when match is true add the data_hash to the results
|
55
55
|
results << data_hash if match
|
@@ -85,9 +85,10 @@ module SearchJsonData
|
|
85
85
|
# @param precision [Boolean, false] false by default, true is case sensitive
|
86
86
|
# @return [Boolean] true is any value or phrase match, otherwise false
|
87
87
|
def is_match(collection, data_hash, condition = nil, precision = false)
|
88
|
-
|
89
|
-
|
88
|
+
all_matches = true
|
90
89
|
collection.each do |text|
|
90
|
+
match = false
|
91
|
+
# in this loop if only one match return true
|
91
92
|
data_hash.each_value do |value|
|
92
93
|
if precision
|
93
94
|
match = true if value.include? text
|
@@ -97,7 +98,8 @@ module SearchJsonData
|
|
97
98
|
# to exclude array in negative search
|
98
99
|
match = false if condition == "-" and value.include? ',' and text=='array'
|
99
100
|
end
|
101
|
+
all_matches = all_matches & match # if only one doesn't match return false
|
100
102
|
end
|
101
|
-
|
103
|
+
all_matches
|
102
104
|
end
|
103
105
|
end
|