Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

more careful checking, updated test, command-line option

  • Loading branch information...
commit 1905bf0b341c5f0619b6afc6c8206088534a3566 1 parent c06aba7
Jason May authored
4 lib/assimilate/command.rb
@@ -31,6 +31,10 @@ def initialize
31 31 opts.on("--domain STRING", String, "Domain value to apply to each record") do |s|
32 32 @options[:domain] = s
33 33 end
  34 +
  35 + opts.on("--compare FIELDNAME", String, "(*extend* only) Optional field to check whether an update is current (e.g. timestamp)") do |f|
  36 + @options[:compare] = f
  37 + end
34 38 end
35 39 end
36 40
2  lib/assimilate/extender.rb
@@ -37,7 +37,7 @@ def is_newer(current_data, new_data)
37 37 # if there is a field to compare on (i.e. a timestamp), then apply the update if the timestamp is newer;
38 38 # otherwise (no timestamp) compare the hashes and apply if there are any differences.
39 39 def apply_this_update(current_record, new_data)
40   - if @comparison_field
  40 + if @comparison_field && current_record[@keyfield]
41 41 is_newer(current_record[@keyfield], new_data)
42 42 else
43 43 current_record[@keyfield] != new_data
2  lib/assimilate/version.rb
... ... @@ -1,3 +1,3 @@
1 1 module Assimilate
2   - VERSION = "0.2"
  2 + VERSION = "0.2.1"
3 3 end
2  spec/lib/extend_spec.rb
@@ -74,7 +74,7 @@ def import_extended_data(datestamp, filename, opts = {})
74 74 before(:all) do
75 75 reset_catalog
76 76 import_base_data("20120501")
77   - import_extended_data("20120505", "logs1.csv")
  77 + import_extended_data("20120505", "logs1.csv", :compare => 'timestamp')
78 78 end
79 79
80 80

0 comments on commit 1905bf0

Please sign in to comment.
Something went wrong with that request. Please try again.