nice_hash 1.15.1 → 1.15.2

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
  SHA256:
3
- metadata.gz: 254fdd9381807942132b1de1030e2765053fb5c2cc8e6273f0c9fdd8499c3bdd
4
- data.tar.gz: 53e2e6724bfd6463831db41564c0caa3431a8a669dc7df5fb4efcc2b11ad232b
3
+ metadata.gz: 7b3dfa4920ee6ffc492f91f20f01fdad4e22953a681bd5071d7f7f72ecbed4eb
4
+ data.tar.gz: 357269895379ab1744886a6107493f339820e4a5cf4bd81ddd9ed4f7ecb94de9
5
5
  SHA512:
6
- metadata.gz: 85a4ebab47454bc99bc469bef42815793033b51d4f0e254a1b7681a40a9ab92e6f9aaa739b9c4fdfbe811601a1370041983abaa8fe5383593f13dcb92e19d89c
7
- data.tar.gz: 2b12952c9483fa972dae9ace4305c2fbb08746a2a210bd2cd64e2ec3552cec4abbbea7f598c36a05dd3190903160035e6db2e9711de4878dadebd542cf4efef7
6
+ metadata.gz: acbd759da3e565e4493cd6c6b082e31248124cd93dec40d9572a695d2055ec4c34850c82c19f2e548e8c71c31a0504d6ae4cf0e4b4457d789eb90b299a1d6eee
7
+ data.tar.gz: 80f5adf41b3c01f6c32aff59ff8410c507e53f937aa794523485699afc8ca796934f72b9cc3ec22ec8797265b62d7c96413b4d9d058b58f136943e47367904ef
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # NiceHash
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/nice_hash.svg)](https://rubygems.org/gems/nice_hash)
4
+ [![Build Status](https://travis-ci.com/MarioRuiz/nice_hash.svg?branch=master)](https://github.com/MarioRuiz/nice_hash)
5
+ [![Coverage Status](https://coveralls.io/repos/github/MarioRuiz/nice_hash/badge.svg?branch=master)](https://coveralls.io/github/MarioRuiz/nice_hash?branch=master)
6
+
4
7
 
5
8
  NiceHash creates hashes following certain patterns so your testing will be much easier.
6
9
 
@@ -14,6 +17,30 @@ To generate the strings following a pattern take a look at the documentation for
14
17
 
15
18
  To use nice_hash on Http connections take a look at nice_http gem: https://github.com/MarioRuiz/nice_http
16
19
 
20
+ ## Table of contents
21
+ - [Installation](#installation)
22
+ - [Usage](#usage)
23
+ * [How to access the different keys](#how-to-access-the-different-keys)
24
+ * [Change all values on the keys we specified](#change-all-values-on-the-keys-we-specified)
25
+ * [Filtering / Selecting an specific key on the hash and subhashes](#filtering---selecting-an-specific-key-on-the-hash-and-subhashes)
26
+ * [How to generate the hash with the criteria we want](#how-to-generate-the-hash-with-the-criteria-we-want)
27
+ * [How to generate the hash with wrong values for the string patterns specified on the hash](#how-to-generate-the-hash-with-wrong-values-for-the-string-patterns-specified-on-the-hash)
28
+ * [Return the select_fields or the pattern_fields](#return-the-select-fields-or-the-pattern-fields)
29
+ * [dig and bury Hash methods](#dig-and-bury-hash-methods)
30
+ * [Validating hashes](#validating-hashes)
31
+ * [Change only one value at a time and return an Array of Hashes](#change-only-one-value-at-a-time-and-return-an-array-of-hashes)
32
+ * [Adding other values on run time when calling `generate` method](#adding-other-values-on-run-time-when-calling--generate--method)
33
+ + [Accessing other values of the hash on run time](#accessing-other-values-of-the-hash-on-run-time)
34
+ * [Compare the structure of a replica with the supplied structure](#compare-the-structure-of-a-replica-with-the-supplied-structure)
35
+ * [Other useful methods](#other-useful-methods)
36
+ + [Time stamp](#time-stamp)
37
+ + [Random dates](#random-dates)
38
+ + [Deep copy of a hash](#deep-copy-of-a-hash)
39
+ + [Nested deletion](#nested-deletion)
40
+ + [Boolean class](#boolean-class)
41
+ - [Contributing](#contributing)
42
+ - [License](#license)
43
+
17
44
  ## Installation
18
45
 
19
46
  Add this line to your application's Gemfile:
@@ -652,9 +679,9 @@ array_of_hashes.each {|hash_with_one_wrong_field|
652
679
 
653
680
  Take a look at a full example: https://gist.github.com/MarioRuiz/824d7a462b62fd85f02c1a09455deefb
654
681
 
655
- ### Adding other values on real time when calling `generate` method
682
+ ### Adding other values on run time when calling `generate` method
656
683
 
657
- If you need a value to be supplied for your key on real time every time you call the `generate` method you can use `lambda`
684
+ If you need a value to be supplied for your key on run time every time you call the `generate` method you can use `lambda`
658
685
 
659
686
  ```ruby
660
687
  my_hash = {
@@ -685,9 +712,9 @@ This is the output:
685
712
  :other=>"2019-01-02T13:41:05.536"}
686
713
  ```
687
714
 
688
- #### Accessing other values of the hash on real time
715
+ #### Accessing other values of the hash on run time
689
716
 
690
- If you need for example to access another value of the key to generate a value on real time you can use `NiceHash.values`
717
+ If you need for example to access another value of the key to generate a value on run time you can use `NiceHash.values`
691
718
 
692
719
  Take a look at this example:
693
720
 
@@ -783,6 +810,7 @@ Valid patterns:
783
810
 
784
811
  ### Other useful methods
785
812
 
813
+ #### Time stamp
786
814
  In case you need the time stamp, we added the method `stamp` to the `Time` class
787
815
 
788
816
  ```ruby
@@ -790,6 +818,7 @@ In case you need the time stamp, we added the method `stamp` to the `Time` class
790
818
  #> 2019-01-02T11:03:23.620Z
791
819
  ```
792
820
 
821
+ #### Random dates
793
822
  In class `Date` we added a very handy `random` method you can use to generate random dates.
794
823
 
795
824
  ```ruby
@@ -803,6 +832,7 @@ In class `Date` we added a very handy `random` method you can use to generate ra
803
832
  puts Date.new(2003,10,31).random(Date.today)
804
833
  ```
805
834
 
835
+ #### Deep copy of a hash
806
836
  If you need a clean copy of a hash use the method `deep_copy`
807
837
 
808
838
  ```ruby
@@ -823,6 +853,7 @@ p my_hash
823
853
  #>{:one=>1, :two=>2, :three=>{:car=>"changed"}}
824
854
  ```
825
855
 
856
+ #### Nested deletion
826
857
  If you want to delete a key on a nested hash you can use `delete_nested` and supply the key you want:
827
858
 
828
859
  ```ruby
@@ -841,6 +872,7 @@ If you want to delete a key on a nested hash you can use `delete_nested` and sup
841
872
 
842
873
  ```
843
874
 
875
+ #### Boolean class
844
876
  We added the possibility to check if a value is boolean or not since in Ruby doesn't exist, just TrueClass and FalseClass
845
877
 
846
878
  ```ruby
@@ -252,7 +252,7 @@ class Hash
252
252
  # More info: NiceHash.get_values
253
253
  ###########################################################################
254
254
  def get_values(*keys)
255
- NiceHash.get_values(self, *keys)
255
+ NiceHash.get_values(self, keys.flatten)
256
256
  end
257
257
 
258
258
  ###########################################################################
data/lib/nice_hash.rb CHANGED
@@ -778,7 +778,7 @@ class NiceHash
778
778
  # output:
779
779
  # a Hash of Arrays with all values found.
780
780
  # Example of output with example.get_values("id","name")
781
- # {"id"=>[334],"name"=>["Peter North"]}
781
+ # {"id"=>344, "name"=>["Peter Smith", ["myFavor1", "Special ticket"]]}
782
782
  # Example of output with example.get_values("idt")
783
783
  # {"idt"=>[345,3123,3145]}
784
784
  # Example of output with example.get_values(:'tickets.idt')
@@ -786,6 +786,8 @@ class NiceHash
786
786
  #
787
787
  ####################################################
788
788
  def NiceHash.get_values(hashv, keys)
789
+ #todo: check if we should return {"id"=>344, "name"=>["Peter Smith", "myFavor1", "Special ticket"]} instead of
790
+ # {"id"=>344, "name"=>["Peter Smith", ["myFavor1", "Special ticket"]]}
789
791
  if keys.kind_of?(String) or keys.kind_of?(Symbol)
790
792
  keys = [keys]
791
793
  end
@@ -991,7 +993,7 @@ class NiceHash
991
993
  hash.each do |k, v|
992
994
  if v.is_a?(Hash)
993
995
  keys << k
994
- keys << trans(v)
996
+ keys << transtring(v)
995
997
  else
996
998
  keys << k
997
999
  keys << v
@@ -1011,7 +1013,7 @@ class NiceHash
1011
1013
  # @return [Array]
1012
1014
  #
1013
1015
  # @example
1014
- # my_hash = { uno: {dos: :tres} }
1016
+ # my_hash = { uno: {dos: {tres: 3}} }
1015
1017
  # NiceHash.get_all_keys(my_hash)
1016
1018
  # #>[:uno, :dos, :tres]
1017
1019
  ##################################################
@@ -1028,7 +1030,7 @@ class NiceHash
1028
1030
  end
1029
1031
 
1030
1032
  ##################################################
1031
- # Deletes the supplied key
1033
+ # Deletes the supplied nested key
1032
1034
  #
1033
1035
  # @param hash [Hash] The hash we want
1034
1036
  # @param nested_key [Hash] [String] String with the nested key: 'uno.dos.tres' or a hash { uno: {dos: :tres} }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nice_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.1
4
+ version: 1.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-05 00:00:00.000000000 Z
11
+ date: 2019-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: string_pattern
@@ -30,6 +30,26 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 2.2.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 3.8.0
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '3.8'
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 3.8.0
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '3.8'
33
53
  description: 'NiceHash creates hashes following certain patterns so your testing will
34
54
  be much easier. Parse and filter JSON. You can easily generate all the hashes you
35
55
  want following the criteria you specify. Many other features coming to Hash class