Skip to content

Commit

Permalink
more careful checking, updated test, command-line option
Browse files Browse the repository at this point in the history
  • Loading branch information
jmay committed May 11, 2012
1 parent c06aba7 commit 1905bf0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/assimilate/command.rb
Expand Up @@ -31,6 +31,10 @@ def initialize
opts.on("--domain STRING", String, "Domain value to apply to each record") do |s|
@options[:domain] = s
end

opts.on("--compare FIELDNAME", String, "(*extend* only) Optional field to check whether an update is current (e.g. timestamp)") do |f|
@options[:compare] = f
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/assimilate/extender.rb
Expand Up @@ -37,7 +37,7 @@ def is_newer(current_data, new_data)
# if there is a field to compare on (i.e. a timestamp), then apply the update if the timestamp is newer;
# otherwise (no timestamp) compare the hashes and apply if there are any differences.
def apply_this_update(current_record, new_data)
if @comparison_field
if @comparison_field && current_record[@keyfield]
is_newer(current_record[@keyfield], new_data)
else
current_record[@keyfield] != new_data
Expand Down
2 changes: 1 addition & 1 deletion lib/assimilate/version.rb
@@ -1,3 +1,3 @@
module Assimilate
VERSION = "0.2"
VERSION = "0.2.1"
end
2 changes: 1 addition & 1 deletion spec/lib/extend_spec.rb
Expand Up @@ -74,7 +74,7 @@ def import_extended_data(datestamp, filename, opts = {})
before(:all) do
reset_catalog
import_base_data("20120501")
import_extended_data("20120505", "logs1.csv")
import_extended_data("20120505", "logs1.csv", :compare => 'timestamp')
end


Expand Down

0 comments on commit 1905bf0

Please sign in to comment.