datacatalog-importer 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.11
1
+ 0.1.12
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{datacatalog-importer}
8
- s.version = "0.1.11"
8
+ s.version = "0.1.12"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David James"]
12
- s.date = %q{2010-04-05}
12
+ s.date = %q{2010-04-07}
13
13
  s.description = %q{This framework makes it easier to write importers for the National Data Catalog.}
14
14
  s.email = %q{djames@sunlightfoundation.com}
15
15
  s.extra_rdoc_files = [
data/lib/pusher.rb CHANGED
@@ -85,30 +85,34 @@ module DataCatalog
85
85
  raise "#{name} has blank URL" if url.blank?
86
86
  docs = DataCatalog::Organization.all(:url => url)
87
87
  n = docs.length
88
- case n
89
- when 0
88
+ if n == 0
90
89
  puts "Creating Organization: #{name}"
91
90
  DataCatalog::Organization.create(data)
92
- when 1
91
+ else
92
+ if n > 1
93
+ warning("Cannot find unique Source with url : #{url}", {
94
+ :warning => "#{n} matches: " + docs.map { |x| x.id }.join(" "),
95
+ :workaround => "Using #{docs[0].id}"
96
+ })
97
+ end
93
98
  puts "Updating Organization: #{name}"
94
99
  DataCatalog::Organization.update(docs[0].id, data)
95
- else
96
- error("Cannot find unique Source with url : #{url}", {
97
- :error => "#{n} matches: " + docs.map { |x| x.id }.join(" ")
98
- })
99
100
  end
100
101
  end
101
102
 
102
103
  def find_organization_by(field, name)
103
104
  docs = DataCatalog::Organization.all(field => name)
104
105
  n = docs.length
105
- case n
106
- when 0 then nil
107
- when 1 then docs[0]
106
+ if n == 0
107
+ nil
108
108
  else
109
- error("Cannot find unique Organization with #{field} : #{name}", {
110
- :error => "#{n} matches: " + docs.map { |x| x.id }.join(" ")
111
- })
109
+ if n > 1
110
+ warning("Cannot find unique Organization with #{field} : #{name}", {
111
+ :warning => "#{n} matches: " + docs.map { |x| x.id }.join(" "),
112
+ :workaround => "Using #{docs[0].id}"
113
+ })
114
+ end
115
+ docs[0]
112
116
  end
113
117
  end
114
118
 
@@ -212,7 +216,15 @@ module DataCatalog
212
216
  end
213
217
 
214
218
  def error(text, object)
215
- puts "- Failure: #{text}"
219
+ report("Error", text, object)
220
+ end
221
+
222
+ def warning(text, object)
223
+ report("Warning", text, object)
224
+ end
225
+
226
+ def report(type, text, object)
227
+ puts "- #{type} : #{text}"
216
228
  puts " Uploading Report to API."
217
229
  DataCatalog::Report.create({
218
230
  :status => "new",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 11
9
- version: 0.1.11
8
+ - 12
9
+ version: 0.1.12
10
10
  platform: ruby
11
11
  authors:
12
12
  - David James
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-05 00:00:00 -04:00
17
+ date: 2010-04-07 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency