ari_fetch 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,8 @@ module AriFetch
4
4
  class AriReadFile < ActiveRecord::Base
5
5
  attr_accessible :name, :data_read
6
6
 
7
+ scope :read_done, where("data_read = 1")
8
+
7
9
  attr_accessor :content, :vehicles
8
10
 
9
11
  def fetch_data(ftp_instance, include_cancel)
@@ -20,7 +20,9 @@ module AriFetch
20
20
 
21
21
  def vehicle_data_with_downcased_keys
22
22
  downcased_hash = {}
23
- vehicle.map{|k, v| downcased_hash.merge!({"#{k.downcase}" => v}) }
23
+ vehicle.map{|k, v|
24
+ downcased_hash.merge!({"#{k.downcase}" => v}) if k && v
25
+ }
24
26
  downcased_hash
25
27
  end
26
28
 
@@ -1,3 +1,3 @@
1
1
  module AriFetch
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/ari_fetch.rb CHANGED
@@ -16,7 +16,7 @@ module AriFetch
16
16
  end
17
17
 
18
18
  def read_files
19
- @read_files = AriFetch::AriReadFile.pluck(:name) rescue @read_files = AriFetch::Files.new([]).files
19
+ @read_files = AriFetch::AriReadFile.read_done.pluck(:name) rescue @read_files = AriFetch::Files.new([]).files
20
20
  end
21
21
 
22
22
  def ftp_files
@@ -28,7 +28,7 @@ module AriFetch
28
28
  end
29
29
 
30
30
  def fetch_vehicles_from_files(how_many=1)
31
- unread_files.first(how_many).map {|file| AriFetch::AriReadFile.create(name: file, data_read: false).fetch_data(ftp_instance, include_cancel?) }.flatten!
31
+ unread_files.first(how_many).map {|file| AriFetch::AriReadFile.where(name: file).first_or_create(data_read: false).fetch_data(ftp_instance, include_cancel?) }.flatten!
32
32
  end
33
33
 
34
34
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ari_fetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: