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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecc3df9a14b6e88e79402ef6f27f4f5fa9a451bf
4
- data.tar.gz: 2d3fed1bdaed9630f5f518eeeab491fbf4aa041d
3
+ metadata.gz: 9542f9292a6cf6f2d12a033170e70a181235d49f
4
+ data.tar.gz: 4615571fbee275ea5cf7527236d97e440c4fda53
5
5
  SHA512:
6
- metadata.gz: f0f459bcfacda6e99aeef4a7850e07db3722506c9142ac56f19a16db97e2f71486ebdc80487d47fc1e5639f16c6cb085526672d672bac99121bed08f5073e75f
7
- data.tar.gz: 21b249d660c826e3ccfeb4503681bb40105c7ff97e7bccd6f37091a0ba539d3f95656a45b524727a10727f55537f4eeea9f39ccfb92e00e37e8ec63e732ef73a
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
- attr_hash = {}
16
-
17
- names.each_with_index do |name, i|
18
- attr_hash[name] =
19
- if i < size && self[i]
20
- options[:strip] ? self[i].to_s.strip : self[i]
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
@@ -17,20 +17,20 @@ module Loady
17
17
  def read(filename, options = {}, &block)
18
18
  @logger = options.delete(:logger) || default_logger
19
19
 
20
- file = File.new(filename)
21
- file.autoclose = true
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
- file.each do |line|
25
- readline line, options, &block
26
- end
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
- self.new.read(*args, &block)
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
@@ -1,3 +1,3 @@
1
1
  module Loady
2
- VERSION = "0.8.2"
2
+ VERSION = "0.9.0"
3
3
  end
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.8.2
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: 2014-11-26 00:00:00.000000000 Z
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.0'
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.0'
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.1'
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.1'
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.2'
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.2'
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.4
89
+ rubygems_version: 2.4.5
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: File loader with simple logging