search_json_data 0.1.0 → 1.0.0

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: ed8656f42813d4c61e50c4b5777681805b56080a
4
- data.tar.gz: 2be2f7dbc2a12e04e7b1a92552195fb237de85ff
3
+ metadata.gz: 1dcc5bebc971bf6b0904a24c6ef63e4eb7293be3
4
+ data.tar.gz: 2d4c7e8114e547142c44b6e52909d7373b0f5949
5
5
  SHA512:
6
- metadata.gz: 7182e74cbe2bb74d9443fd24ab5b6f8136ebc2d45db0125899cf64c097e6593c741410b8fd5394f34801034ba5364313e236fba2757811b18f167635a56b7f71
7
- data.tar.gz: efbd6dd33693bc4bdd38638747ed414919bf6a64be95220d74f53eb78b9f0ab3ea6dba42b9c38b798f77208a1a34fcdd3dfa196845df5ead81984828641a3c4c
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 [doc/index.html](http://doc/index.html)
121
+ and open this file with your browser doc/index.html
@@ -4,5 +4,5 @@ end
4
4
 
5
5
  Then(/^should match a programming language named "([^"]*)"$/) do |finded|
6
6
 
7
- expect(@results[0]).to include("Name" => finded)
7
+ expect(@results).to all(include("Name" => finded))
8
8
  end
@@ -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 unless match
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
- match = false
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
- match
103
+ all_matches
102
104
  end
103
105
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module SearchJsonData
3
- VERSION = "0.1.0"
3
+ VERSION = "1.0.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: search_json_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Hernán Piccinini Lagos