spreader 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/spreader.rb +7 -7
  2. metadata +1 -1
data/lib/spreader.rb CHANGED
@@ -19,10 +19,10 @@ class Spreader
19
19
  return yield data
20
20
  end
21
21
 
22
- def xml?(file)
23
- head = (IO.popen('head -' + IO.popen("wc -l #{file}").gets.split(' ').first + " #{file}"))
24
- while (line = head.gets)
25
- @xml = true if (line.include? '<') && (!@xml)
22
+ def xml?(relative_path)
23
+ head = IO.popen('head -' + IO.popen("wc -l #{relative_path}").gets.split(' ').first + " #{relative_path}")
24
+ while line = head.gets
25
+ @xml = true if (line.include? '<') && !@xml
26
26
  end
27
27
 
28
28
  return @xml
@@ -62,9 +62,9 @@ class Spreader
62
62
  load(transform(data, model_name, latitude_field_name, longitude_field_name))
63
63
  end
64
64
 
65
- def self.seed(filename, model_name, latitude_field_name, longitude_field_name)
65
+ def self.seed(relative_path, model_name, latitude_field_name, longitude_field_name)
66
66
  spreader = Spreader.new
67
- spreader.transformLoad(spreader.extract(filename){|data| XML::Reader.file("#{data}", :options => XML::Parser::Options::NOBLANKS | XML::Parser::Options::NOENT)}, model_name, latitude_field_name, longitude_field_name) if spreader.xml?(filename)
68
- spreader.transformLoad(spreader.extract(filename){|data| File.open("#{data}")}, model_name, latitude_field_name, longitude_field_name) if !spreader.xml?(filename)
67
+ spreader.transformLoad(spreader.extract(relative_path){|data| XML::Reader.file("#{data}", :options => XML::Parser::Options::NOBLANKS | XML::Parser::Options::NOENT)}, model_name, latitude_field_name, longitude_field_name) if spreader.xml?(relative_path)
68
+ spreader.transformLoad(spreader.extract(relative_path){|data| File.open("#{data}")}, model_name, latitude_field_name, longitude_field_name) if !spreader.xml?(relative_path)
69
69
  end
70
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spreader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: