loady 1.0.0 → 1.1.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
- SHA1:
3
- metadata.gz: 6a1cc4ddea13a61ba00af056e95092eb9c6befe2
4
- data.tar.gz: 78796d7745d5bf82e71eac66c830829f6247a3e1
2
+ SHA256:
3
+ metadata.gz: f3cbef0a89c61259ad21fb1a9b7b1567b7e109cea5f6c9ea28ade4d86f898165
4
+ data.tar.gz: befe698be1e117b169c47cf0d54b8e44c68f92a5097c57bfa3a8843f147f5547
5
5
  SHA512:
6
- metadata.gz: 4c5b0b8cc7c1e70939459624723780d60dd36510d9bab1e77028e63c065d2e3770bff5395ad843a5dd898e2dc756d6a930165730cde89e16e83cecdc8d17fb5e
7
- data.tar.gz: 1fbd395af9f7cd47dce80860c4ec84002f55bf67254f130adafd83d4796f42e0fe2f821d94051133c047f9bd99c456d8d9601b5137ab7ce2842dfb17e70ae270
6
+ metadata.gz: 732c36b0d0a5c3f74ecf03ccf42c279b9a1c0f63bff6f9c88b93a6bc90bf4856b45f5e44dfe2c838e83cef1ff8430fa00366887ba3108e5823f07a0cc82a5863
7
+ data.tar.gz: d32630555756986ffd055704b47351955421214dc6424ec60e3c17b738af6896c9e49fd1e28cf37163940bcb5263e84a5873153718504d86dbcc0da9c25b774e
@@ -1,12 +1,14 @@
1
- require 'loady/attribute_array'
2
- require 'loady/csv_loader'
3
- require 'loady/memory_logger'
1
+ # frozen_string_literal: true
2
+
3
+ require "loady/attribute_array"
4
+ require "loady/csv_loader"
5
+ require "loady/memory_logger"
4
6
 
5
7
  module Loady
6
8
  def read(*args, &block)
7
9
  Loady::CsvLoader.new.read(*args, &block)
8
10
  end
9
-
11
+
10
12
  alias csv read
11
13
 
12
14
  module_function :read, :csv
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Loady
2
4
  class AttributeArray < Array
3
-
4
5
  # usage:
5
6
  # aa = Loady::AttributeArray.new(['john', 'doe'])
6
7
  # aa.to_attributes([:first, :last])
@@ -20,6 +21,5 @@ module Loady
20
21
  end
21
22
  end
22
23
  end
23
-
24
24
  end
25
25
  end
@@ -1,5 +1,7 @@
1
- require 'csv'
2
- require 'logger'
1
+ # frozen_string_literal: true
2
+
3
+ require "csv"
4
+ require "logger"
3
5
 
4
6
  module Loady
5
7
  class CsvLoader
@@ -19,12 +21,12 @@ module Loady
19
21
  options[:headers] ||= options.delete(:skip_first_row)
20
22
 
21
23
  CSV.foreach(filename, options) do |line|
22
- readline line, options, &block
24
+ readline line, &block
23
25
  end
24
- @logger.info "Finished. Loaded #{ @success } rows. #{ @warning } skipped rows."
25
- rescue CSV::MalformedCSVError => ex
26
- @logger.error ex.message
27
- @logger.error "Stopped Loading after #{ @success } rows. #{ @warning } skipped rows."
26
+ @logger.info "Finished. Loaded #{@success} rows. #{@warning} skipped rows."
27
+ rescue CSV::MalformedCSVError => e
28
+ @logger.error e.message
29
+ @logger.error "Stopped Loading after #{@success} rows. #{@warning} skipped rows."
28
30
  end
29
31
 
30
32
  class << self
@@ -33,9 +35,9 @@ module Loady
33
35
  end
34
36
  end
35
37
 
36
- private
38
+ private
37
39
 
38
- def readline(line, options)
40
+ def readline(line)
39
41
  @line_number += 1
40
42
  row = if line.respond_to?(:to_hash)
41
43
  AttributeArray.new(line.to_hash.values)
@@ -47,9 +49,9 @@ module Loady
47
49
  yield row
48
50
  @success += 1
49
51
  end
50
- rescue Exception => ex
52
+ rescue StandardError => e
51
53
  @warning += 1
52
- @logger.warn "#{ ex.to_s.gsub("line 1", "line #{ @line_number }") }\n#{ line }"
54
+ @logger.warn "#{e.to_s.gsub('line 1', "line #{@line_number}")}\n#{line}"
53
55
  end
54
56
 
55
57
  def default_logger
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Loady
2
4
  class MemoryLogger
3
5
  attr_reader :messages
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Loady
2
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
3
5
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loady
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.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: 2016-01-29 00:00:00.000000000 Z
11
+ date: 2019-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: mocha
14
+ name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.1'
19
+ version: '5.5'
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.1'
26
+ version: '5.5'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: mocha
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.4'
33
+ version: '1.1'
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.4'
40
+ version: '1.1'
41
41
  - !ruby/object:Gem::Dependency
42
- name: minitest
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.5'
47
+ version: '12.0'
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.5'
54
+ version: '12.0'
55
55
  description: File loader with simple logging
56
56
  email:
57
57
  - tee@neighborland.com
@@ -66,7 +66,7 @@ files:
66
66
  - lib/loady/csv_loader.rb
67
67
  - lib/loady/memory_logger.rb
68
68
  - lib/loady/version.rb
69
- homepage: http://github.com/teeparham/loady
69
+ homepage: https://github.com/teeparham/loady
70
70
  licenses:
71
71
  - MIT
72
72
  metadata: {}
@@ -78,17 +78,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: 1.9.3
81
+ version: 2.4.0
82
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  requirements:
84
84
  - - ">="
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  requirements: []
88
- rubyforge_project:
89
- rubygems_version: 2.5.1
88
+ rubygems_version: 3.0.3
90
89
  signing_key:
91
90
  specification_version: 4
92
91
  summary: File loader with simple logging
93
92
  test_files: []
94
- has_rdoc: