datacatalog-importer 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/djsun/datacatalog-importer"
12
12
  gem.authors = ["David James"]
13
13
  gem.add_dependency "nokogiri", ">= 1.4.1"
14
+ gem.add_dependency "datacatalog", ">= 0.4.12"
14
15
  gem.add_development_dependency "rspec", ">= 1.2.9"
15
16
  # gem is a Gem::Specification...
16
17
  # see http://www.rubygems.org/read/chapter/20 for additional settings
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.9
1
+ 0.1.10
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{datacatalog-importer}
8
- s.version = "0.1.9"
8
+ s.version = "0.1.10"
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"]
@@ -52,13 +52,16 @@ Gem::Specification.new do |s|
52
52
 
53
53
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
54
54
  s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.1"])
55
+ s.add_runtime_dependency(%q<datacatalog>, [">= 0.4.12"])
55
56
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
56
57
  else
57
58
  s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
59
+ s.add_dependency(%q<datacatalog>, [">= 0.4.12"])
58
60
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
59
61
  end
60
62
  else
61
63
  s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
64
+ s.add_dependency(%q<datacatalog>, [">= 0.4.12"])
62
65
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
63
66
  end
64
67
  end
data/lib/pusher.rb CHANGED
@@ -1,4 +1,6 @@
1
+ gem 'datacatalog', '>= 0.4.12'
1
2
  require 'datacatalog'
3
+ require 'frequency'
2
4
  require File.dirname(__FILE__) + '/shared'
3
5
 
4
6
  module DataCatalog
@@ -112,7 +114,7 @@ module DataCatalog
112
114
 
113
115
  # Important: do not modify data
114
116
  def create_or_update_source(data)
115
- data = data.reject { |k, v| LOOKUP_KEYS.include?(k) }
117
+ data = clean_source_data(data)
116
118
  docs = DataCatalog::Source.all(:url => data[:url])
117
119
  n = docs.length
118
120
  case n
@@ -122,7 +124,8 @@ module DataCatalog
122
124
  DataCatalog::Source.create(data)
123
125
  rescue DataCatalog::BadRequest => e
124
126
  error("Cannot create Source", {
125
- :params => data
127
+ :params => data,
128
+ :errors => e.errors,
126
129
  })
127
130
  end
128
131
  when 1
@@ -132,7 +135,8 @@ module DataCatalog
132
135
  DataCatalog::Source.update(id, data)
133
136
  rescue DataCatalog::BadRequest => e
134
137
  error("Cannot update Source with id : #{id}", {
135
- :params => data
138
+ :params => data,
139
+ :errors => e.errors,
136
140
  })
137
141
  end
138
142
  else
@@ -197,6 +201,15 @@ module DataCatalog
197
201
  end
198
202
 
199
203
  protected
204
+
205
+ # Important: do not modify data
206
+ def clean_source_data(data)
207
+ data = data.reject { |k, v| LOOKUP_KEYS.include?(k) }
208
+
209
+ frequency = Frequency.new(data[:frequency])
210
+ data[:frequency] = "other" unless frequency.valid?
211
+ data
212
+ end
200
213
 
201
214
  def error(text, object)
202
215
  puts "- Failure: #{text}"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 9
9
- version: 0.1.9
8
+ - 10
9
+ version: 0.1.10
10
10
  platform: ruby
11
11
  authors:
12
12
  - David James
@@ -32,9 +32,23 @@ dependencies:
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  - !ruby/object:Gem::Dependency
35
- name: rspec
35
+ name: datacatalog
36
36
  prerelease: false
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 4
44
+ - 12
45
+ version: 0.4.12
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
38
52
  requirements:
39
53
  - - ">="
40
54
  - !ruby/object:Gem::Version
@@ -44,7 +58,7 @@ dependencies:
44
58
  - 9
45
59
  version: 1.2.9
46
60
  type: :development
47
- version_requirements: *id002
61
+ version_requirements: *id003
48
62
  description: This framework makes it easier to write importers for the National Data Catalog.
49
63
  email: djames@sunlightfoundation.com
50
64
  executables: []