Compare hashes and report where the change was

Hi,
I have two arrays of hashes :

"----- table name == EMessages <--------------> ID == ID"
---------arr1 ----target-----------------
[{"ID"=>"11562", "EmailType"=>"2", "ContentKey"=>"1113", "ExtraKey1"=>"1",
"CreationDate"=>"2009-07-06 09:36:01.303", "EmailSent"=>nil},
{"ID"=>"11574", "EmailType"=>"2", "ContentKey"=>"8833", "ExtraKey1"=>"0",
"CreationDate"=>"2009-07-06 11:38:52.613", "EmailSent"=>nil}]

---------arr2 ----source-----------------
[{"ID"=>11562, "EmailType"=>2, "ContentKey"=>"1113", "ExtraKey1"=>"1",
"CreationDate"=>2009-07-06 09:36:01 -0400, "EmailSent"=>nil}, {"ID"=>11574,
"EmailType"=>2, "ContentKey"=>"8833", "ExtraKey1"=>"0",
"CreationDate"=>2009-07-06 11:38:52 -0400, "EmailSent"=>nil}]

"----- table name == Empl <--------------> ID == EmployeeID"

---------array1 ----source-----------------
[{"EmployeeID"=>3, "LicenseeID"=>00325, "ProgramID"=>2841, "Status"=>2,
"Comments"=>"", "DateCreated"=>2008-06-23 12:05:41 -0400,
"DateModified"=>2016-10-21 15:27:13 -0400, "CreatedByUserID"=>38342,
"ModifiedByUserID"=>41096, "statuschangedate"=>#<Date: 2016-10-21
((2457683j,0s,0n),+0s,2299161j)>}, {"EmployeeID"=>4, "LicenseeID"=>2222,
"ProgramID"=>211755, "Status"=>1, "Comments"=>nil,
"DateCreated"=>2008-06-23 12:06:05 -0400, "DateModified"=>nil,
"CreatedByUserID"=>36306, "ModifiedByUserID"=>nil, "statuschangedate"=>nil}]

---------array2 ----target-----------------
[{"EmployeeID"=>"3", "LicenseeID"=>"00325", "ProgramID"=>"2333",
"Status"=>"2", "Comments"=>"", "DateCreated"=>"2008-06-23 12:05:41.173",
"DateModified"=>"2016-10-21 15:27:13.59", "CreatedByUserID"=>"38342",
"ModifiedByUserID"=>"41096", "statuschangedate"=>"2016-10-21"},
{"EmployeeID"=>"4", "LicenseeID"=>"2222", "ProgramID"=>"211755",
"Status"=>"1", "Comments"=>nil, "DateCreated"=>"2008-06-23 12:06:05.8",
"DateModified"=>nil, "CreatedByUserID"=>"36306", "ModifiedByUserID"=>nil,
"statuschangedate"=>nil}]

I want to have :

def compare_rows(array1,array2,id)

...

end

I want to report like this :

ID: 3: Key [ ProgramID] changed value from [ 2841 ] to [ 2333].
Thanks, your help is appreciated.

This might help hash_compare | RubyGems.org | your community gem host

···

On Tue, Apr 10, 2018 at 6:29 PM, Abdelmajid Lotfi <akramakom@gmail.com> wrote:

Hi,
I have two arrays of hashes :

"----- table name == EMessages <--------------> ID == ID"
---------arr1 ----target-----------------
[{"ID"=>"11562", "EmailType"=>"2", "ContentKey"=>"1113", "ExtraKey1"=>"1",
"CreationDate"=>"2009-07-06 09:36:01.303", "EmailSent"=>nil},
{"ID"=>"11574", "EmailType"=>"2", "ContentKey"=>"8833", "ExtraKey1"=>"0",
"CreationDate"=>"2009-07-06 11:38:52.613", "EmailSent"=>nil}]

---------arr2 ----source-----------------
[{"ID"=>11562, "EmailType"=>2, "ContentKey"=>"1113", "ExtraKey1"=>"1",
"CreationDate"=>2009-07-06 09:36:01 -0400, "EmailSent"=>nil}, {"ID"=>11574,
"EmailType"=>2, "ContentKey"=>"8833", "ExtraKey1"=>"0",
"CreationDate"=>2009-07-06 11:38:52 -0400, "EmailSent"=>nil}]

"----- table name == Empl <--------------> ID == EmployeeID"

---------array1 ----source-----------------
[{"EmployeeID"=>3, "LicenseeID"=>00325, "ProgramID"=>2841, "Status"=>2,
"Comments"=>"", "DateCreated"=>2008-06-23 12:05:41 -0400,
"DateModified"=>2016-10-21 15:27:13 -0400, "CreatedByUserID"=>38342,
"ModifiedByUserID"=>41096, "statuschangedate"=>#<Date: 2016-10-21
((2457683j,0s,0n),+0s,2299161j)>}, {"EmployeeID"=>4, "LicenseeID"=>2222,
"ProgramID"=>211755, "Status"=>1, "Comments"=>nil,
"DateCreated"=>2008-06-23 12:06:05 -0400, "DateModified"=>nil,
"CreatedByUserID"=>36306, "ModifiedByUserID"=>nil, "statuschangedate"=>nil}]

---------array2 ----target-----------------
[{"EmployeeID"=>"3", "LicenseeID"=>"00325", "ProgramID"=>"2333",
"Status"=>"2", "Comments"=>"", "DateCreated"=>"2008-06-23 12:05:41.173",
"DateModified"=>"2016-10-21 15:27:13.59", "CreatedByUserID"=>"38342",
"ModifiedByUserID"=>"41096", "statuschangedate"=>"2016-10-21"},
{"EmployeeID"=>"4", "LicenseeID"=>"2222", "ProgramID"=>"211755",
"Status"=>"1", "Comments"=>nil, "DateCreated"=>"2008-06-23 12:06:05.8",
"DateModified"=>nil, "CreatedByUserID"=>"36306", "ModifiedByUserID"=>nil,
"statuschangedate"=>nil}]

I want to have :

def compare_rows(array1,array2,id)

...

end

I want to report like this :

ID: 3: Key [ ProgramID] changed value from [ 2841 ] to [ 2333].
Thanks, your help is appreciated.

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
Karthikeyan A K
Author of I Love Ruby - Free Ruby programming book

thank you
Karthikeyan,

Can you please show me how to use it ?
Thanks,

···

On Tue, Apr 10, 2018 at 9:54 AM, Karthikeyan A K <77minds@gmail.com> wrote:

This might help hash_compare | RubyGems.org | your community gem host

On Tue, Apr 10, 2018 at 6:29 PM, Abdelmajid Lotfi <akramakom@gmail.com> > wrote:

Hi,
I have two arrays of hashes :

"----- table name == EMessages <--------------> ID == ID"
---------arr1 ----target-----------------
[{"ID"=>"11562", "EmailType"=>"2", "ContentKey"=>"1113",
"ExtraKey1"=>"1", "CreationDate"=>"2009-07-06 09:36:01.303",
"EmailSent"=>nil}, {"ID"=>"11574", "EmailType"=>"2", "ContentKey"=>"8833",
"ExtraKey1"=>"0", "CreationDate"=>"2009-07-06 11:38:52.613",
"EmailSent"=>nil}]

---------arr2 ----source-----------------
[{"ID"=>11562, "EmailType"=>2, "ContentKey"=>"1113", "ExtraKey1"=>"1",
"CreationDate"=>2009-07-06 09:36:01 -0400, "EmailSent"=>nil}, {"ID"=>11574,
"EmailType"=>2, "ContentKey"=>"8833", "ExtraKey1"=>"0",
"CreationDate"=>2009-07-06 11:38:52 -0400, "EmailSent"=>nil}]

"----- table name == Empl <--------------> ID == EmployeeID"

---------array1 ----source-----------------
[{"EmployeeID"=>3, "LicenseeID"=>00325, "ProgramID"=>2841, "Status"=>2,
"Comments"=>"", "DateCreated"=>2008-06-23 12:05:41 -0400,
"DateModified"=>2016-10-21 15:27:13 -0400, "CreatedByUserID"=>38342,
"ModifiedByUserID"=>41096, "statuschangedate"=>#<Date: 2016-10-21
((2457683j,0s,0n),+0s,2299161j)>}, {"EmployeeID"=>4, "LicenseeID"=>2222,
"ProgramID"=>211755, "Status"=>1, "Comments"=>nil,
"DateCreated"=>2008-06-23 12:06:05 -0400, "DateModified"=>nil,
"CreatedByUserID"=>36306, "ModifiedByUserID"=>nil, "statuschangedate"=>nil}]

---------array2 ----target-----------------
[{"EmployeeID"=>"3", "LicenseeID"=>"00325", "ProgramID"=>"2333",
"Status"=>"2", "Comments"=>"", "DateCreated"=>"2008-06-23 12:05:41.173",
"DateModified"=>"2016-10-21 15:27:13.59", "CreatedByUserID"=>"38342",
"ModifiedByUserID"=>"41096", "statuschangedate"=>"2016-10-21"},
{"EmployeeID"=>"4", "LicenseeID"=>"2222", "ProgramID"=>"211755",
"Status"=>"1", "Comments"=>nil, "DateCreated"=>"2008-06-23 12:06:05.8",
"DateModified"=>nil, "CreatedByUserID"=>"36306", "ModifiedByUserID"=>nil,
"statuschangedate"=>nil}]

I want to have :

def compare_rows(array1,array2,id)

...

end

I want to report like this :

ID: 3: Key [ ProgramID] changed value from [ 2841 ] to [ 2333].
Thanks, your help is appreciated.

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
Karthikeyan A K
Author of I Love Ruby - Free Ruby programming book

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

I found how to use it here : GitHub - mindaslab/hash_compare: Hash Compare ,
can you please tell me how to iterate two arrays of hashes and use
hash_compare ?
Thanks,

···

On Tue, Apr 10, 2018 at 10:07 AM, Abdelmajid Lotfi <akramakom@gmail.com> wrote:

thank you
Karthikeyan,

Can you please show me how to use it ?
Thanks,

On Tue, Apr 10, 2018 at 9:54 AM, Karthikeyan A K <77minds@gmail.com> > wrote:

This might help hash_compare | RubyGems.org | your community gem host

On Tue, Apr 10, 2018 at 6:29 PM, Abdelmajid Lotfi <akramakom@gmail.com> >> wrote:

Hi,
I have two arrays of hashes :

"----- table name == EMessages <--------------> ID == ID"
---------arr1 ----target-----------------
[{"ID"=>"11562", "EmailType"=>"2", "ContentKey"=>"1113",
"ExtraKey1"=>"1", "CreationDate"=>"2009-07-06 09:36:01.303",
"EmailSent"=>nil}, {"ID"=>"11574", "EmailType"=>"2", "ContentKey"=>"8833",
"ExtraKey1"=>"0", "CreationDate"=>"2009-07-06 11:38:52.613",
"EmailSent"=>nil}]

---------arr2 ----source-----------------
[{"ID"=>11562, "EmailType"=>2, "ContentKey"=>"1113", "ExtraKey1"=>"1",
"CreationDate"=>2009-07-06 09:36:01 -0400, "EmailSent"=>nil}, {"ID"=>11574,
"EmailType"=>2, "ContentKey"=>"8833", "ExtraKey1"=>"0",
"CreationDate"=>2009-07-06 11:38:52 -0400, "EmailSent"=>nil}]

"----- table name == Empl <--------------> ID == EmployeeID"

---------array1 ----source-----------------
[{"EmployeeID"=>3, "LicenseeID"=>00325, "ProgramID"=>2841, "Status"=>2,
"Comments"=>"", "DateCreated"=>2008-06-23 12:05:41 -0400,
"DateModified"=>2016-10-21 15:27:13 -0400, "CreatedByUserID"=>38342,
"ModifiedByUserID"=>41096, "statuschangedate"=>#<Date: 2016-10-21
((2457683j,0s,0n),+0s,2299161j)>}, {"EmployeeID"=>4,
"LicenseeID"=>2222, "ProgramID"=>211755, "Status"=>1, "Comments"=>nil,
"DateCreated"=>2008-06-23 12:06:05 -0400, "DateModified"=>nil,
"CreatedByUserID"=>36306, "ModifiedByUserID"=>nil, "statuschangedate"=>nil}]

---------array2 ----target-----------------
[{"EmployeeID"=>"3", "LicenseeID"=>"00325", "ProgramID"=>"2333",
"Status"=>"2", "Comments"=>"", "DateCreated"=>"2008-06-23 12:05:41.173",
"DateModified"=>"2016-10-21 15:27:13.59", "CreatedByUserID"=>"38342",
"ModifiedByUserID"=>"41096", "statuschangedate"=>"2016-10-21"},
{"EmployeeID"=>"4", "LicenseeID"=>"2222", "ProgramID"=>"211755",
"Status"=>"1", "Comments"=>nil, "DateCreated"=>"2008-06-23 12:06:05.8",
"DateModified"=>nil, "CreatedByUserID"=>"36306", "ModifiedByUserID"=>nil,
"statuschangedate"=>nil}]

I want to have :

def compare_rows(array1,array2,id)

...

end

I want to report like this :

ID: 3: Key [ ProgramID] changed value from [ 2841 ] to [ 2333].
Thanks, your help is appreciated.

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
Karthikeyan A K
Author of I Love Ruby - Free Ruby programming book

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

This list is mostly for people who want to learn Ruby. If you want to learn, write some code and put it up on Github in a gist or similar. Many e-mail clients mess up indentation for code.

If you just need the problem solved a freelance coder-for-hire site might be useful.

Leam

···

On 04/10/2018 10:07 AM, Abdelmajid Lotfi wrote:

thank you

      Karthikeyan

,

Can you please show me how to use it ?
Thanks,

On Tue, Apr 10, 2018 at 9:54 AM, Karthikeyan A K <77minds@gmail.com > <mailto:77minds@gmail.com>> wrote:

    This might help hash_compare | RubyGems.org | your community gem host
    <https://rubygems.org/gems/hash_compare&gt;

    On Tue, Apr 10, 2018 at 6:29 PM, Abdelmajid Lotfi > <akramakom@gmail.com <mailto:akramakom@gmail.com>> wrote:

        Hi,
        I have two arrays of hashes :

        "----- table name == EMessages <--------------> ID == ID"
          ---------arr1 ----target-----------------
        [{"ID"=>"11562", "EmailType"=>"2", "ContentKey"=>"1113",
        "ExtraKey1"=>"1", "CreationDate"=>"2009-07-06 09:36:01.303",
        "EmailSent"=>nil}, {"ID"=>"11574", "EmailType"=>"2",
        "ContentKey"=>"8833", "ExtraKey1"=>"0",
        "CreationDate"=>"2009-07-06 11:38:52.613", "EmailSent"=>nil}]

          ---------arr2 ----source-----------------
        [{"ID"=>11562, "EmailType"=>2, "ContentKey"=>"1113",
        "ExtraKey1"=>"1", "CreationDate"=>2009-07-06 09:36:01 -0400,
        "EmailSent"=>nil}, {"ID"=>11574, "EmailType"=>2,
        "ContentKey"=>"8833", "ExtraKey1"=>"0",
        "CreationDate"=>2009-07-06 11:38:52 -0400, "EmailSent"=>nil}]

        "----- table name == Empl <--------------> ID == EmployeeID"

        ---------array1 ----source-----------------
        [{"EmployeeID"=>3, "LicenseeID"=>00325, "ProgramID"=>2841,
        "Status"=>2, "Comments"=>"", "DateCreated"=>2008-06-23 12:05:41
        -0400, "DateModified"=>2016-10-21 15:27:13 -0400,
        "CreatedByUserID"=>38342, "ModifiedByUserID"=>41096,
        "statuschangedate"=>#<Date: 2016-10-21
        ((2457683j,0s,0n),+0s,2299161j)>}, {"EmployeeID"=>4,
        "LicenseeID"=>2222, "ProgramID"=>211755, "Status"=>1,
        "Comments"=>nil, "DateCreated"=>2008-06-23 12:06:05 -0400,
        "DateModified"=>nil, "CreatedByUserID"=>36306,
        "ModifiedByUserID"=>nil, "statuschangedate"=>nil}]

          ---------array2 ----target-----------------
        [{"EmployeeID"=>"3", "LicenseeID"=>"00325", "ProgramID"=>"2333",
        "Status"=>"2", "Comments"=>"", "DateCreated"=>"2008-06-23
        12:05:41.173", "DateModified"=>"2016-10-21 15:27:13.59",
        "CreatedByUserID"=>"38342", "ModifiedByUserID"=>"41096",
        "statuschangedate"=>"2016-10-21"}, {"EmployeeID"=>"4",
        "LicenseeID"=>"2222", "ProgramID"=>"211755", "Status"=>"1",
        "Comments"=>nil, "DateCreated"=>"2008-06-23 12:06:05.8",
        "DateModified"=>nil, "CreatedByUserID"=>"36306",
        "ModifiedByUserID"=>nil, "statuschangedate"=>nil}]

        I want to have :

        def compare_rows(array1,array2,id)

        ...

        end

        I want to report like this :

        ID: 3: Key [ ProgramID] changed value from [ 2841 ] to [ 2333].

        Thanks, your help is appreciated.

        Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
        <mailto:ruby-talk-request@ruby-lang.org>?subject=unsubscribe>
        <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk
        <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;&gt;

    -- Karthikeyan A K
    Author of I Love Ruby - Free Ruby programming book
    <https://mindaslab.github.io/I-Love-Ruby/&gt;

    Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
    <mailto:ruby-talk-request@ruby-lang.org>?subject=unsubscribe>
    <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk
    <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

what happened when the two arrays have not the same size ?

it that case I got :

C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rspec-expectations-3.7.0/lib/rspec/matchers.rb:960:in
`method_missing': undefined method `each' for nil:NilClass (NoMethodError)

is there any way how to tweak this hash_compare ?
Thanks,

···

On Tue, Apr 10, 2018 at 9:54 AM, Karthikeyan A K <77minds@gmail.com> wrote:

This might help hash_compare | RubyGems.org | your community gem host

On Tue, Apr 10, 2018 at 6:29 PM, Abdelmajid Lotfi <akramakom@gmail.com> > wrote:

Hi,
I have two arrays of hashes :

"----- table name == EMessages <--------------> ID == ID"
---------arr1 ----target-----------------
[{"ID"=>"11562", "EmailType"=>"2", "ContentKey"=>"1113",
"ExtraKey1"=>"1", "CreationDate"=>"2009-07-06 09:36:01.303",
"EmailSent"=>nil}, {"ID"=>"11574", "EmailType"=>"2", "ContentKey"=>"8833",
"ExtraKey1"=>"0", "CreationDate"=>"2009-07-06 11:38:52.613",
"EmailSent"=>nil}]

---------arr2 ----source-----------------
[{"ID"=>11562, "EmailType"=>2, "ContentKey"=>"1113", "ExtraKey1"=>"1",
"CreationDate"=>2009-07-06 09:36:01 -0400, "EmailSent"=>nil}, {"ID"=>11574,
"EmailType"=>2, "ContentKey"=>"8833", "ExtraKey1"=>"0",
"CreationDate"=>2009-07-06 11:38:52 -0400, "EmailSent"=>nil}]

"----- table name == Empl <--------------> ID == EmployeeID"

---------array1 ----source-----------------
[{"EmployeeID"=>3, "LicenseeID"=>00325, "ProgramID"=>2841, "Status"=>2,
"Comments"=>"", "DateCreated"=>2008-06-23 12:05:41 -0400,
"DateModified"=>2016-10-21 15:27:13 -0400, "CreatedByUserID"=>38342,
"ModifiedByUserID"=>41096, "statuschangedate"=>#<Date: 2016-10-21
((2457683j,0s,0n),+0s,2299161j)>}, {"EmployeeID"=>4, "LicenseeID"=>2222,
"ProgramID"=>211755, "Status"=>1, "Comments"=>nil,
"DateCreated"=>2008-06-23 12:06:05 -0400, "DateModified"=>nil,
"CreatedByUserID"=>36306, "ModifiedByUserID"=>nil, "statuschangedate"=>nil}]

---------array2 ----target-----------------
[{"EmployeeID"=>"3", "LicenseeID"=>"00325", "ProgramID"=>"2333",
"Status"=>"2", "Comments"=>"", "DateCreated"=>"2008-06-23 12:05:41.173",
"DateModified"=>"2016-10-21 15:27:13.59", "CreatedByUserID"=>"38342",
"ModifiedByUserID"=>"41096", "statuschangedate"=>"2016-10-21"},
{"EmployeeID"=>"4", "LicenseeID"=>"2222", "ProgramID"=>"211755",
"Status"=>"1", "Comments"=>nil, "DateCreated"=>"2008-06-23 12:06:05.8",
"DateModified"=>nil, "CreatedByUserID"=>"36306", "ModifiedByUserID"=>nil,
"statuschangedate"=>nil}]

I want to have :

def compare_rows(array1,array2,id)

...

end

I want to report like this :

ID: 3: Key [ ProgramID] changed value from [ 2841 ] to [ 2333].
Thanks, your help is appreciated.

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
Karthikeyan A K
Author of I Love Ruby - Free Ruby programming book

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

I agree with Leam.

This is more than a "Hey I have a problem so give me a solution" list.
It would be better if you create a Gist (https://gist.github.com/\) and then
share it so we can have more context with what you want to do.

what happened when the two arrays have not the same size ?

it that case I got :

C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rspec-expectations-3.7.0/lib/rspec/matchers.rb:960:in
`method_missing': undefined method `each' for nil:NilClass (NoMethodError)

is there any way how to tweak this hash_compare ?
Thanks,

···

On 10. April 2018 at 19:56:35, Abdelmajid Lotfi (akramakom@gmail.com) wrote:

On Tue, Apr 10, 2018 at 9:54 AM, Karthikeyan A K <77minds@gmail.com> wrote:

This might help hash_compare | RubyGems.org | your community gem host

On Tue, Apr 10, 2018 at 6:29 PM, Abdelmajid Lotfi <akramakom@gmail.com> > wrote:

Hi,
I have two arrays of hashes :

"----- table name == EMessages <--------------> ID == ID"
---------arr1 ----target-----------------
[{"ID"=>"11562", "EmailType"=>"2", "ContentKey"=>"1113",
"ExtraKey1"=>"1", "CreationDate"=>"2009-07-06 09:36:01.303",
"EmailSent"=>nil}, {"ID"=>"11574", "EmailType"=>"2", "ContentKey"=>"8833",
"ExtraKey1"=>"0", "CreationDate"=>"2009-07-06 11:38:52.613",
"EmailSent"=>nil}]

---------arr2 ----source-----------------
[{"ID"=>11562, "EmailType"=>2, "ContentKey"=>"1113", "ExtraKey1"=>"1",
"CreationDate"=>2009-07-06 09:36:01 -0400, "EmailSent"=>nil}, {"ID"=>11574,
"EmailType"=>2, "ContentKey"=>"8833", "ExtraKey1"=>"0",
"CreationDate"=>2009-07-06 11:38:52 -0400, "EmailSent"=>nil}]

"----- table name == Empl <--------------> ID == EmployeeID"

---------array1 ----source-----------------
[{"EmployeeID"=>3, "LicenseeID"=>00325, "ProgramID"=>2841, "Status"=>2,
"Comments"=>"", "DateCreated"=>2008-06-23 12:05:41 -0400,
"DateModified"=>2016-10-21 15:27:13 -0400, "CreatedByUserID"=>38342,
"ModifiedByUserID"=>41096, "statuschangedate"=>#<Date: 2016-10-21
((2457683j,0s,0n),+0s,2299161j)>}, {"EmployeeID"=>4, "LicenseeID"=>2222,
"ProgramID"=>211755, "Status"=>1, "Comments"=>nil,
"DateCreated"=>2008-06-23 12:06:05 -0400, "DateModified"=>nil,
"CreatedByUserID"=>36306, "ModifiedByUserID"=>nil, "statuschangedate"=>nil}]

---------array2 ----target-----------------
[{"EmployeeID"=>"3", "LicenseeID"=>"00325", "ProgramID"=>"2333",
"Status"=>"2", "Comments"=>"", "DateCreated"=>"2008-06-23 12:05:41.173",
"DateModified"=>"2016-10-21 15:27:13.59", "CreatedByUserID"=>"38342",
"ModifiedByUserID"=>"41096", "statuschangedate"=>"2016-10-21"},
{"EmployeeID"=>"4", "LicenseeID"=>"2222", "ProgramID"=>"211755",
"Status"=>"1", "Comments"=>nil, "DateCreated"=>"2008-06-23 12:06:05.8",
"DateModified"=>nil, "CreatedByUserID"=>"36306", "ModifiedByUserID"=>nil,
"statuschangedate"=>nil}]

I want to have :

def compare_rows(array1,array2,id)

...

end

I want to report like this :

ID: 3: Key [ ProgramID] changed value from [ 2841 ] to [ 2333].
Thanks, your help is appreciated.

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
Karthikeyan A K
Author of I Love Ruby - Free Ruby programming book

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Thanks, I hash_compare <https://rubygems.org/gems/hash_compare&gt; worked for
me.

···

On Tue, Apr 10, 2018 at 1:59 PM, Feña Agar <ferliagno@gmail.com> wrote:

I agree with Leam.

This is more than a "Hey I have a problem so give me a solution" list.
It would be better if you create a Gist (https://gist.github.com/\) and
then share it so we can have more context with what you want to do.

On 10. April 2018 at 19:56:35, Abdelmajid Lotfi (akramakom@gmail.com) > wrote:

what happened when the two arrays have not the same size ?

it that case I got :

C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rspec-expectations-3.
7.0/lib/rspec/matchers.rb:960:in `method_missing': undefined method
`each' for nil:NilClass (NoMethodError)

is there any way how to tweak this hash_compare ?
Thanks,

On Tue, Apr 10, 2018 at 9:54 AM, Karthikeyan A K <77minds@gmail.com> > wrote:

This might help hash_compare | RubyGems.org | your community gem host

On Tue, Apr 10, 2018 at 6:29 PM, Abdelmajid Lotfi <akramakom@gmail.com> >> wrote:

Hi,
I have two arrays of hashes :

"----- table name == EMessages <--------------> ID == ID"
---------arr1 ----target-----------------
[{"ID"=>"11562", "EmailType"=>"2", "ContentKey"=>"1113",
"ExtraKey1"=>"1", "CreationDate"=>"2009-07-06 09:36:01.303",
"EmailSent"=>nil}, {"ID"=>"11574", "EmailType"=>"2", "ContentKey"=>"8833",
"ExtraKey1"=>"0", "CreationDate"=>"2009-07-06 11:38:52.613",
"EmailSent"=>nil}]

---------arr2 ----source-----------------
[{"ID"=>11562, "EmailType"=>2, "ContentKey"=>"1113", "ExtraKey1"=>"1",
"CreationDate"=>2009-07-06 09:36:01 -0400, "EmailSent"=>nil}, {"ID"=>11574,
"EmailType"=>2, "ContentKey"=>"8833", "ExtraKey1"=>"0",
"CreationDate"=>2009-07-06 11:38:52 -0400, "EmailSent"=>nil}]

"----- table name == Empl <--------------> ID == EmployeeID"

---------array1 ----source-----------------
[{"EmployeeID"=>3, "LicenseeID"=>00325, "ProgramID"=>2841, "Status"=>2,
"Comments"=>"", "DateCreated"=>2008-06-23 12:05:41 -0400,
"DateModified"=>2016-10-21 15:27:13 -0400, "CreatedByUserID"=>38342,
"ModifiedByUserID"=>41096, "statuschangedate"=>#<Date: 2016-10-21
((2457683j,0s,0n),+0s,2299161j)>}, {"EmployeeID"=>4,
"LicenseeID"=>2222, "ProgramID"=>211755, "Status"=>1, "Comments"=>nil,
"DateCreated"=>2008-06-23 12:06:05 -0400, "DateModified"=>nil,
"CreatedByUserID"=>36306, "ModifiedByUserID"=>nil, "statuschangedate"=>nil}]

---------array2 ----target-----------------
[{"EmployeeID"=>"3", "LicenseeID"=>"00325", "ProgramID"=>"2333",
"Status"=>"2", "Comments"=>"", "DateCreated"=>"2008-06-23 12:05:41.173",
"DateModified"=>"2016-10-21 15:27:13.59", "CreatedByUserID"=>"38342",
"ModifiedByUserID"=>"41096", "statuschangedate"=>"2016-10-21"},
{"EmployeeID"=>"4", "LicenseeID"=>"2222", "ProgramID"=>"211755",
"Status"=>"1", "Comments"=>nil, "DateCreated"=>"2008-06-23 12:06:05.8",
"DateModified"=>nil, "CreatedByUserID"=>"36306", "ModifiedByUserID"=>nil,
"statuschangedate"=>nil}]

I want to have :

def compare_rows(array1,array2,id)

...

end

I want to report like this :

ID: 3: Key [ ProgramID] changed value from [ 2841 ] to [ 2333].
Thanks, your help is appreciated.

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
Karthikeyan A K
Author of I Love Ruby - Free Ruby programming book

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;