ari_fetch 0.0.4 → 0.0.5

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.
@@ -2,7 +2,7 @@ require "nokogiri"
2
2
 
3
3
  module AriFetch
4
4
  class AriReadFile < ActiveRecord::Base
5
- attr_accessible :name
5
+ attr_accessible :name, :data_read
6
6
 
7
7
  attr_accessor :content, :vehicles
8
8
 
@@ -11,7 +11,7 @@ module AriFetch
11
11
  @content = parse!(File.open(name, "r"))
12
12
  FileUtils.rm name
13
13
  filter_cancel_vehicles! unless include_cancel
14
- result
14
+ result.tap { data_reading_done! }
15
15
  end
16
16
 
17
17
  private
@@ -36,5 +36,9 @@ module AriFetch
36
36
  vehicles.map { |vehicle| vehicle.result }
37
37
  end
38
38
 
39
+ def data_reading_done!
40
+ self.update_attributes(data_read: true)
41
+ end
42
+
39
43
  end
40
44
  end
@@ -8,7 +8,7 @@ module AriFetch
8
8
  end
9
9
 
10
10
  def filter!
11
- map_to_file_name.select{ |e| !useless_files.include?(e) && e.match(/\.xml\Z/) }
11
+ @files = map_to_file_name.select{ |e| !useless_files.include?(e) && e.match(/\.xml\Z/) }
12
12
  self
13
13
  end
14
14
 
@@ -1,3 +1,3 @@
1
1
  module AriFetch
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/ari_fetch.rb CHANGED
@@ -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).fetch_data(ftp_instance, include_cancel?) }.flatten!
31
+ unread_files.first(how_many).map {|file| AriFetch::AriReadFile.create(name: file, data_read: false).fetch_data(ftp_instance, include_cancel?) }.flatten!
32
32
  end
33
33
 
34
34
  private
@@ -2,6 +2,7 @@ class CreateAriReadFiles < ActiveRecord::Migration
2
2
  def self.up
3
3
  create_table :ari_read_files do |t|
4
4
  t.string :name
5
+ t.boolean :data_read
5
6
 
6
7
  t.timestamps
7
8
  end
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.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: