lite-report 1.0.0 → 1.0.5

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
  SHA256:
3
- metadata.gz: '01200390e3a06669140612cf102393844a3121b27b71905e3df0adcfa275a299'
4
- data.tar.gz: 808ce98ff9635dcd92d59b09eeec9a397b556f2f4d064e5e76c67ff4e99cc282
3
+ metadata.gz: e19a104989a720b33c1d0be498695c26352a0a607d8a2c89af66705958398ed1
4
+ data.tar.gz: 2df858892aff83bad0042f486e4d9501b7a7ef5886c9139b5496c0c9ac37af73
5
5
  SHA512:
6
- metadata.gz: 53eb09f4960b0aa89e5cc6391cc86bdb674b115a171414bb88ee45992e4724b0a9c467c2e491beb744177c41f7553bc113ba51cf339a4e2159ea0b9db410071e
7
- data.tar.gz: 99ccc7f5f644d53486843984f3211589ce7bd07a3f738dadbfad1de83020d44f52b971ec50cc1857855b8003be4b81510c16d1f5e7f242ea846e08b120035e1b
6
+ metadata.gz: 153acef279ba609c0b02f30b0651fb5c085231dbc22d713499ffd38b254d0881821060bbe02947eadf2f1f2b853ca002e998460bb918a4fccd9bc60484261a97
7
+ data.tar.gz: 6001668ff0e2751a674abaec2331ba43f9aec2eda280ac66b5c40c7f234fcb2f505c0ec1b4d7f9e72f2add92c1469aa6622bf959aee89f558e9596c1310ec227
@@ -2,11 +2,12 @@ require:
2
2
  - rubocop-performance
3
3
  - rubocop-rspec
4
4
  AllCops:
5
- TargetRubyVersion: 2.6
5
+ TargetRubyVersion: 2.7
6
+ NewCops: enable
6
7
  DisplayCopNames: true
7
8
  DisplayStyleGuide: true
8
- LineLength:
9
- Max: 100
9
+ Layout/EmptyLinesAroundAttributeAccessor:
10
+ Enabled: true
10
11
  Layout/EmptyLinesAroundBlockBody:
11
12
  Exclude:
12
13
  - 'spec/**/**/*'
@@ -14,6 +15,14 @@ Layout/EmptyLinesAroundClassBody:
14
15
  EnforcedStyle: empty_lines_except_namespace
15
16
  Layout/EmptyLinesAroundModuleBody:
16
17
  EnforcedStyle: empty_lines_except_namespace
18
+ Layout/LineLength:
19
+ Max: 100
20
+ Layout/SpaceAroundMethodCallOperator:
21
+ Enabled: true
22
+ Lint/RaiseException:
23
+ Enabled: true
24
+ Lint/StructNewOverride:
25
+ Enabled: true
17
26
  Metrics/BlockLength:
18
27
  Exclude:
19
28
  - 'spec/**/**/*'
@@ -4,6 +4,7 @@ cache: bundler
4
4
  rvm:
5
5
  - 2.5
6
6
  - 2.6
7
+ - 2.7
7
8
  - ruby-head
8
9
  matrix:
9
10
  fast_finish: true
@@ -5,6 +5,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
+
9
+ ## [1.0.5] - 2020-07-03
10
+ ### Added
11
+ - Added Ruby 2.7 support
12
+
13
+ ## [1.0.4] - 2020-02-11
14
+ ### Changed
15
+ - Fix record instance not generating
16
+
17
+ ## [1.0.3] - 2019-08-24
18
+ ### Changed
19
+ - Fix broken configuration option
20
+
21
+ ## [1.0.2] - 2019-08-24
22
+ ### Changed
23
+ - Improved how configuration works
24
+
25
+ ## [1.0.1] - 2019-08-15
26
+ ### Changed
27
+ - Underscore initializer file name
28
+
8
29
  ## [1.0.0] - 2019-07-08
9
30
  ### Added
10
31
  - Initial project version
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-report (1.0.0)
4
+ lite-report (1.0.5)
5
5
  activerecord
6
6
  activerecord-import
7
7
  deep_pluck
@@ -9,129 +9,139 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actionpack (5.2.3)
13
- actionview (= 5.2.3)
14
- activesupport (= 5.2.3)
15
- rack (~> 2.0)
12
+ actionpack (6.0.3.2)
13
+ actionview (= 6.0.3.2)
14
+ activesupport (= 6.0.3.2)
15
+ rack (~> 2.0, >= 2.0.8)
16
16
  rack-test (>= 0.6.3)
17
17
  rails-dom-testing (~> 2.0)
18
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
19
- actionview (5.2.3)
20
- activesupport (= 5.2.3)
18
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
19
+ actionview (6.0.3.2)
20
+ activesupport (= 6.0.3.2)
21
21
  builder (~> 3.1)
22
22
  erubi (~> 1.4)
23
23
  rails-dom-testing (~> 2.0)
24
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
25
- activemodel (5.2.3)
26
- activesupport (= 5.2.3)
27
- activerecord (5.2.3)
28
- activemodel (= 5.2.3)
29
- activesupport (= 5.2.3)
30
- arel (>= 9.0)
31
- activerecord-import (1.0.2)
24
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
25
+ activemodel (6.0.3.2)
26
+ activesupport (= 6.0.3.2)
27
+ activerecord (6.0.3.2)
28
+ activemodel (= 6.0.3.2)
29
+ activesupport (= 6.0.3.2)
30
+ activerecord-import (1.0.5)
32
31
  activerecord (>= 3.2)
33
- activesupport (5.2.3)
32
+ activesupport (6.0.3.2)
34
33
  concurrent-ruby (~> 1.0, >= 1.0.2)
35
34
  i18n (>= 0.7, < 2)
36
35
  minitest (~> 5.1)
37
36
  tzinfo (~> 1.1)
38
- arel (9.0.0)
39
- ast (2.4.0)
40
- builder (3.2.3)
37
+ zeitwerk (~> 2.2, >= 2.2.2)
38
+ ast (2.4.1)
39
+ builder (3.2.4)
41
40
  colorize (0.8.1)
42
- concurrent-ruby (1.1.5)
43
- crass (1.0.4)
44
- database_cleaner (1.7.0)
45
- deep_pluck (1.1.1)
41
+ concurrent-ruby (1.1.6)
42
+ crass (1.0.6)
43
+ database_cleaner (1.8.5)
44
+ deep_pluck (1.1.4)
46
45
  activerecord (>= 3)
47
46
  pluck_all (>= 1.2.3)
48
- diff-lcs (1.3)
49
- erubi (1.8.0)
50
- fasterer (0.5.1)
47
+ rails_compatibility (>= 0.0.1)
48
+ diff-lcs (1.4.4)
49
+ erubi (1.9.0)
50
+ fasterer (0.8.3)
51
51
  colorize (~> 0.7)
52
- ruby_parser (>= 3.13.0)
52
+ ruby_parser (>= 3.14.1)
53
53
  generator_spec (0.9.4)
54
54
  activesupport (>= 3.0.0)
55
55
  railties (>= 3.0.0)
56
- i18n (1.6.0)
56
+ i18n (1.8.3)
57
57
  concurrent-ruby (~> 1.0)
58
- jaro_winkler (1.5.3)
59
- loofah (2.2.3)
58
+ loofah (2.6.0)
60
59
  crass (~> 1.0.2)
61
60
  nokogiri (>= 1.5.9)
62
- method_source (0.9.2)
61
+ method_source (1.0.0)
63
62
  mini_portile2 (2.4.0)
64
- minitest (5.11.3)
65
- nokogiri (1.10.3)
63
+ minitest (5.14.1)
64
+ nokogiri (1.10.9)
66
65
  mini_portile2 (~> 2.4.0)
67
- parallel (1.17.0)
68
- parser (2.6.3.0)
69
- ast (~> 2.4.0)
66
+ parallel (1.19.2)
67
+ parser (2.7.1.4)
68
+ ast (~> 2.4.1)
70
69
  pluck_all (2.0.4)
71
70
  activesupport (>= 3.0.0)
72
- rack (2.0.7)
71
+ polyamorous (2.3.2)
72
+ activerecord (>= 5.2.1)
73
+ rack (2.2.3)
73
74
  rack-test (1.1.0)
74
75
  rack (>= 1.0, < 3)
75
76
  rails-dom-testing (2.0.3)
76
77
  activesupport (>= 4.2.0)
77
78
  nokogiri (>= 1.6)
78
- rails-html-sanitizer (1.0.4)
79
- loofah (~> 2.2, >= 2.2.2)
80
- railties (5.2.3)
81
- actionpack (= 5.2.3)
82
- activesupport (= 5.2.3)
79
+ rails-html-sanitizer (1.3.0)
80
+ loofah (~> 2.3)
81
+ rails_compatibility (0.0.2)
82
+ activerecord (>= 3)
83
+ railties (6.0.3.2)
84
+ actionpack (= 6.0.3.2)
85
+ activesupport (= 6.0.3.2)
83
86
  method_source
84
87
  rake (>= 0.8.7)
85
- thor (>= 0.19.0, < 2.0)
88
+ thor (>= 0.20.3, < 2.0)
86
89
  rainbow (3.0.0)
87
- rake (12.3.2)
88
- ransack (2.1.1)
89
- actionpack (>= 5.0)
90
- activerecord (>= 5.0)
91
- activesupport (>= 5.0)
90
+ rake (13.0.1)
91
+ ransack (2.3.2)
92
+ activerecord (>= 5.2.1)
93
+ activesupport (>= 5.2.1)
92
94
  i18n
93
- rspec (3.8.0)
94
- rspec-core (~> 3.8.0)
95
- rspec-expectations (~> 3.8.0)
96
- rspec-mocks (~> 3.8.0)
97
- rspec-core (3.8.2)
98
- rspec-support (~> 3.8.0)
99
- rspec-expectations (3.8.4)
95
+ polyamorous (= 2.3.2)
96
+ regexp_parser (1.7.1)
97
+ rexml (3.2.4)
98
+ rspec (3.9.0)
99
+ rspec-core (~> 3.9.0)
100
+ rspec-expectations (~> 3.9.0)
101
+ rspec-mocks (~> 3.9.0)
102
+ rspec-core (3.9.2)
103
+ rspec-support (~> 3.9.3)
104
+ rspec-expectations (3.9.2)
100
105
  diff-lcs (>= 1.2.0, < 2.0)
101
- rspec-support (~> 3.8.0)
102
- rspec-mocks (3.8.1)
106
+ rspec-support (~> 3.9.0)
107
+ rspec-mocks (3.9.1)
103
108
  diff-lcs (>= 1.2.0, < 2.0)
104
- rspec-support (~> 3.8.0)
105
- rspec-rails (3.8.2)
106
- actionpack (>= 3.0)
107
- activesupport (>= 3.0)
108
- railties (>= 3.0)
109
- rspec-core (~> 3.8.0)
110
- rspec-expectations (~> 3.8.0)
111
- rspec-mocks (~> 3.8.0)
112
- rspec-support (~> 3.8.0)
113
- rspec-support (3.8.2)
114
- rubocop (0.72.0)
115
- jaro_winkler (~> 1.5.1)
109
+ rspec-support (~> 3.9.0)
110
+ rspec-rails (4.0.1)
111
+ actionpack (>= 4.2)
112
+ activesupport (>= 4.2)
113
+ railties (>= 4.2)
114
+ rspec-core (~> 3.9)
115
+ rspec-expectations (~> 3.9)
116
+ rspec-mocks (~> 3.9)
117
+ rspec-support (~> 3.9)
118
+ rspec-support (3.9.3)
119
+ rubocop (0.86.0)
116
120
  parallel (~> 1.10)
117
- parser (>= 2.6)
121
+ parser (>= 2.7.0.1)
118
122
  rainbow (>= 2.2.2, < 4.0)
123
+ regexp_parser (>= 1.7)
124
+ rexml
125
+ rubocop-ast (>= 0.0.3, < 1.0)
119
126
  ruby-progressbar (~> 1.7)
120
- unicode-display_width (>= 1.4.0, < 1.7)
121
- rubocop-performance (1.4.0)
127
+ unicode-display_width (>= 1.4.0, < 2.0)
128
+ rubocop-ast (0.1.0)
129
+ parser (>= 2.7.0.1)
130
+ rubocop-performance (1.6.1)
122
131
  rubocop (>= 0.71.0)
123
- rubocop-rspec (1.33.0)
124
- rubocop (>= 0.60.0)
132
+ rubocop-rspec (1.41.0)
133
+ rubocop (>= 0.68.1)
125
134
  ruby-progressbar (1.10.1)
126
- ruby_parser (3.13.1)
135
+ ruby_parser (3.14.2)
127
136
  sexp_processor (~> 4.9)
128
- sexp_processor (4.12.1)
129
- sqlite3 (1.4.1)
130
- thor (0.20.3)
137
+ sexp_processor (4.15.0)
138
+ sqlite3 (1.4.2)
139
+ thor (1.0.1)
131
140
  thread_safe (0.3.6)
132
- tzinfo (1.2.5)
141
+ tzinfo (1.2.7)
133
142
  thread_safe (~> 0.1)
134
- unicode-display_width (1.6.0)
143
+ unicode-display_width (1.7.0)
144
+ zeitwerk (2.3.1)
135
145
 
136
146
  PLATFORMS
137
147
  ruby
@@ -152,4 +162,4 @@ DEPENDENCIES
152
162
  sqlite3
153
163
 
154
164
  BUNDLED WITH
155
- 2.0.1
165
+ 2.1.4
data/README.md CHANGED
@@ -37,7 +37,7 @@ Or install it yourself as:
37
37
  ## Configurations
38
38
 
39
39
  `rails g lite:report:install` will generate the following file:
40
- `../config/initalizers/lite-report.rb`
40
+ `../config/initalizers/lite_report.rb`
41
41
 
42
42
  Place your default configs in this file.
43
43
 
@@ -9,7 +9,7 @@ module Lite
9
9
  source_root File.expand_path('../templates', __FILE__)
10
10
 
11
11
  def copy_initializer_file
12
- copy_file('install.rb', 'config/initializers/lite-report.rb')
12
+ copy_file('install.rb', 'config/initializers/lite_report.rb')
13
13
  end
14
14
 
15
15
  end
@@ -7,7 +7,7 @@ class Lite::Report::Array < Lite::Report::Base
7
7
  end
8
8
 
9
9
  def import
10
- CSV.foreach(@data, @csv_options)
10
+ CSV.foreach(@data, **@csv_options)
11
11
  .with_object([]) do |row, array|
12
12
  row = convert_to_array!(row)
13
13
  array << process_import_row!(row)
@@ -10,21 +10,27 @@ module Lite
10
10
  def initialize
11
11
  @csv_options = {}
12
12
  @data_options = {}
13
- @import_adapter = {}
13
+ @import_options = {}
14
14
  end
15
15
 
16
16
  end
17
17
 
18
- def self.configuration
19
- @configuration ||= Configuration.new
20
- end
18
+ class << self
21
19
 
22
- def self.configuration=(config)
23
- @configuration = config
24
- end
20
+ attr_writer :configuration
21
+
22
+ def configuration
23
+ @configuration ||= Configuration.new
24
+ end
25
+
26
+ def configure
27
+ yield(configuration)
28
+ end
29
+
30
+ def reset_configuration!
31
+ @configuration = Configuration.new
32
+ end
25
33
 
26
- def self.configure
27
- yield(configuration)
28
34
  end
29
35
 
30
36
  end
@@ -8,7 +8,7 @@ class Lite::Report::Hash < Lite::Report::Base
8
8
  end
9
9
 
10
10
  def import
11
- CSV.foreach(@data, @csv_options)
11
+ CSV.foreach(@data, **@csv_options)
12
12
  .with_object([]) do |row, array|
13
13
  next if header_row?(row)
14
14
 
@@ -10,7 +10,14 @@ module Lite
10
10
  def encode(cell)
11
11
  return cell unless cell.is_a?(String)
12
12
 
13
- cell.tr('"', '').encode!(*@data_options[:encode])
13
+ cell = cell.tr('"', '')
14
+ return cell if @data_options[:encode].empty?
15
+
16
+ cell.encode!(
17
+ @data_options[:encode][0],
18
+ @data_options[:encode][1],
19
+ **@data_options[:encode][2]
20
+ )
14
21
  end
15
22
 
16
23
  def encode?(delete: false)
@@ -10,7 +10,7 @@ module Lite
10
10
  def class_columns(data)
11
11
  return data.klass.column_names if ransack_class?(data)
12
12
 
13
- data.column_names
13
+ data.try(:column_names) || data.class.column_names
14
14
  end
15
15
 
16
16
  def klass
@@ -8,7 +8,7 @@ module Lite
8
8
  private
9
9
 
10
10
  def generate_export!
11
- CSV.generate(@csv_options) do |csv|
11
+ CSV.generate(**@csv_options) do |csv|
12
12
  @data.each do |row|
13
13
  csv << process_export_row!(row)
14
14
  end
@@ -33,7 +33,7 @@ module Lite
33
33
 
34
34
  @data.each do |row|
35
35
  row = process_export_row!(row)
36
- csv << CSV.generate_line(row, @csv_options)
36
+ csv << CSV.generate_line(row, **@csv_options)
37
37
  end
38
38
  end
39
39
  end
@@ -43,6 +43,7 @@ class Lite::Report::Record < Lite::Report::Base
43
43
  columns = class_columns(@data)
44
44
  @data = @data.result if ransack_class?(@data)
45
45
  @data = @data.deep_pluck(*columns)
46
+ @data = [@data] unless @data.is_a?(Array)
46
47
  end
47
48
 
48
49
  def generate_export!
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Report
5
5
 
6
- VERSION ||= '1.0.0'
6
+ VERSION ||= '1.0.5'
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-report
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-08 00:00:00.000000000 Z
11
+ date: 2020-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -220,7 +220,7 @@ dependencies:
220
220
  - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
- description:
223
+ description:
224
224
  email:
225
225
  - j.gomez@drexed.com
226
226
  executables: []
@@ -264,7 +264,7 @@ homepage: http://drexed.github.io/lite-report
264
264
  licenses:
265
265
  - MIT
266
266
  metadata: {}
267
- post_install_message:
267
+ post_install_message:
268
268
  rdoc_options: []
269
269
  require_paths:
270
270
  - lib
@@ -279,8 +279,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
279
279
  - !ruby/object:Gem::Version
280
280
  version: '0'
281
281
  requirements: []
282
- rubygems_version: 3.0.4
283
- signing_key:
282
+ rubygems_version: 3.1.4
283
+ signing_key:
284
284
  specification_version: 4
285
285
  summary: Import and export Ruby and Rails objects to flat files and vice versa
286
286
  test_files: []