loady 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/loady/attribute_array.rb +6 -9
- data/lib/loady/csv_loader.rb +9 -9
- data/lib/loady/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9542f9292a6cf6f2d12a033170e70a181235d49f
|
4
|
+
data.tar.gz: 4615571fbee275ea5cf7527236d97e440c4fda53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0d25286af535b360d361355ce5fc1dce248a760fd4c06d2515d6acf9df1165540ea7ee8656658daae7402032e58c73fe2ade6c92664f5c7f20338b19ddd2023
|
7
|
+
data.tar.gz: 19c248583518f999a7eafe890d5ae36c1a23bf69948b65584461e2724190738e3d0af815576971afe93e30d1998e957ae141f77a328f8ccdcdf12819f56d1cb3
|
@@ -12,16 +12,13 @@ module Loady
|
|
12
12
|
def to_attributes(names, options = {})
|
13
13
|
options = { strip: true }.merge(options)
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
15
|
+
{}.tap do |attr_hash|
|
16
|
+
names.each_with_index do |name, i|
|
17
|
+
attr_hash[name] = if i < size && self[i]
|
18
|
+
options[:strip] ? self[i].to_s.strip : self[i]
|
19
|
+
end
|
20
|
+
end
|
22
21
|
end
|
23
|
-
|
24
|
-
attr_hash
|
25
22
|
end
|
26
23
|
|
27
24
|
end
|
data/lib/loady/csv_loader.rb
CHANGED
@@ -17,20 +17,20 @@ module Loady
|
|
17
17
|
def read(filename, options = {}, &block)
|
18
18
|
@logger = options.delete(:logger) || default_logger
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
file.gets if options.delete(:skip_first_row)
|
20
|
+
File.open(filename, "r") do |file|
|
21
|
+
file.gets if options.delete(:skip_first_row)
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
file.each do |line|
|
24
|
+
readline line, options, &block
|
25
|
+
end
|
26
|
+
end
|
27
27
|
|
28
|
-
@logger.info "Finished. Loaded #{@success} rows. #{@warning} unprocessed rows."
|
28
|
+
@logger.info "Finished. Loaded #{ @success } rows. #{ @warning } unprocessed rows."
|
29
29
|
end
|
30
30
|
|
31
31
|
class << self
|
32
32
|
def read(*args, &block)
|
33
|
-
|
33
|
+
new.read(*args, &block)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -46,7 +46,7 @@ module Loady
|
|
46
46
|
end
|
47
47
|
rescue Exception => ex
|
48
48
|
@warning += 1
|
49
|
-
@logger.warn "#{ex.to_s.gsub("line 1", "line #{@line_number}")}\n#{line}"
|
49
|
+
@logger.warn "#{ ex.to_s.gsub("line 1", "line #{ @line_number }") }\n#{ line }"
|
50
50
|
end
|
51
51
|
|
52
52
|
def default_logger
|
data/lib/loady/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loady
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tee Parham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mocha
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '10.
|
33
|
+
version: '10.4'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '10.
|
40
|
+
version: '10.4'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '5.
|
47
|
+
version: '5.5'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '5.
|
54
|
+
version: '5.5'
|
55
55
|
description: File loader with simple logging
|
56
56
|
email:
|
57
57
|
- tee@neighborland.com
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
88
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.4.
|
89
|
+
rubygems_version: 2.4.5
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: File loader with simple logging
|