see_as_vee 0.4.4 → 0.4.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +8 -56
- data/README.md +23 -0
- data/lib/see_as_vee/producers/hashes.rb +35 -7
- data/lib/see_as_vee/sheet.rb +3 -3
- data/lib/see_as_vee/version.rb +1 -1
- data/lib/see_as_vee.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5799a95416f1f098a5251d0813644f9dea12aad
|
4
|
+
data.tar.gz: 9e0add6027150787f65b7208ac7bfd341a46676d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65166484784b536ec9a28e175075c10d422c912f24de14464ee577c819ef4e475bffd24ef16fad4934850949ad86f8f2dc630866d224fc30fdec60ff97f44471
|
7
|
+
data.tar.gz: 7ab8394d15d285433166571ba86adc2e05c476267a7e8fb438daae183dc1b9d010bb7f0220cf49972f8e3faf6b73e7896bbeb46db6aaa21efbc51d873dec007f
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2017-01-16 15:21:47 +0100 using RuboCop version 0.42.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -8,67 +8,19 @@
|
|
8
8
|
|
9
9
|
# Offense count: 1
|
10
10
|
# Cop supports --auto-correct.
|
11
|
-
# Configuration parameters:
|
12
|
-
Lint/UnusedBlockArgument:
|
13
|
-
Exclude:
|
14
|
-
- 'lib/see_as_vee.rb'
|
15
|
-
|
16
|
-
# Offense count: 3
|
17
|
-
# Cop supports --auto-correct.
|
18
|
-
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
19
|
-
Lint/UnusedMethodArgument:
|
20
|
-
Exclude:
|
21
|
-
- 'lib/see_as_vee.rb'
|
22
|
-
|
23
|
-
# Offense count: 2
|
24
|
-
Lint/UselessAssignment:
|
25
|
-
Exclude:
|
26
|
-
- 'lib/see_as_vee.rb'
|
27
|
-
|
28
|
-
# Offense count: 11
|
29
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
30
|
-
# URISchemes: http, https
|
31
|
-
Metrics/LineLength:
|
32
|
-
Max: 180
|
33
|
-
|
34
|
-
# Offense count: 1
|
35
|
-
# Cop supports --auto-correct.
|
36
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
11
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
37
12
|
# SupportedStyles: with_first_parameter, with_fixed_indentation
|
38
13
|
Style/AlignParameters:
|
39
14
|
Exclude:
|
40
15
|
- 'spec/see_as_vee_spec.rb'
|
41
16
|
|
42
|
-
# Offense count:
|
43
|
-
# Cop supports --auto-correct.
|
44
|
-
Style/EmptyLines:
|
45
|
-
Exclude:
|
46
|
-
- 'lib/see_as_vee.rb'
|
47
|
-
|
48
|
-
# Offense count: 1
|
49
|
-
# Cop supports --auto-correct.
|
50
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
51
|
-
# SupportedStyles: empty_lines, no_empty_lines
|
52
|
-
Style/EmptyLinesAroundBlockBody:
|
53
|
-
Exclude:
|
54
|
-
- 'lib/see_as_vee.rb'
|
55
|
-
|
56
|
-
# Offense count: 1
|
57
|
-
# Cop supports --auto-correct.
|
58
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
|
59
|
-
# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
|
60
|
-
Style/HashSyntax:
|
61
|
-
Enabled: false
|
62
|
-
|
63
|
-
# Offense count: 1
|
64
|
-
# Cop supports --auto-correct.
|
65
|
-
Style/MutableConstant:
|
66
|
-
Exclude:
|
67
|
-
- 'lib/see_as_vee/version.rb'
|
68
|
-
|
69
|
-
# Offense count: 133
|
17
|
+
# Offense count: 160
|
70
18
|
# Cop supports --auto-correct.
|
71
19
|
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
|
72
20
|
# SupportedStyles: single_quotes, double_quotes
|
73
21
|
Style/StringLiterals:
|
74
|
-
|
22
|
+
Exclude:
|
23
|
+
- 'Gemfile'
|
24
|
+
- 'bin/console'
|
25
|
+
- 'lib/see_as_vee/sheet.rb'
|
26
|
+
- 'spec/see_as_vee_spec.rb'
|
data/README.md
CHANGED
@@ -86,8 +86,31 @@ The returned value is an array of [validation results](http://dry-rb.org/gems/dr
|
|
86
86
|
# John 3.14
|
87
87
|
```
|
88
88
|
|
89
|
+
### Expand `GROUP_CONCAT` column
|
90
|
+
|
91
|
+
From the version `0.4.5` we support expanding the column produced by `GROUP_CONCAT`
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
▶ require 'see_as_vee'
|
95
|
+
#⇒ true
|
96
|
+
▶ SeeAsVee.csv(
|
97
|
+
▷ [{name: 'Aleksei', value: 42, nicks: 'matiushkin,mudasobwa,am-kantox'},
|
98
|
+
▷ {name: 'Saverio', value: 3.14, nicks: 'trioni,rewritten,saverio-kantox'}],
|
99
|
+
▷ col_sep: "\t", ungroup: :nicks)
|
100
|
+
#⇒ #<File:/tmp/am/see_as_vee20161109-6031-6he5m7.csv>
|
101
|
+
# -rw------- 1 am am 32 nov 9 07:18 /tmp/am/see_as_vee20161109-6031-6he5m7.csv
|
102
|
+
▶ .cat /tmp/am/see_as_vee20161109-6031-6he5m7.csv
|
103
|
+
#⇒ name value nick 1 nick 2 nick 3
|
104
|
+
# Aleksei 42 matiushkin mudasobwa am-kantox
|
105
|
+
# Saverio 3.14 trioni rewritten saverio-kantox
|
106
|
+
```
|
107
|
+
|
89
108
|
## Changelog
|
90
109
|
|
110
|
+
### `0.4.5` support for expanding `GROUP_CONCAT` column
|
111
|
+
|
112
|
+
|
113
|
+
|
91
114
|
### `0.4.0` support for `Dry::Validation`
|
92
115
|
|
93
116
|
### `0.3.0` support for XLSX options
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module SeeAsVee
|
2
2
|
module Producers
|
3
3
|
class Hashes
|
4
|
+
INTERNAL_PARAMS = %i|ungroup delimiter|.freeze
|
4
5
|
NORMALIZER = ->(symbol, hash) { hash.map { |k, v| [k.public_send(symbol ? :to_sym : :to_s), v] }.to_h }.freeze
|
5
6
|
HUMANIZER = lambda do |hash|
|
6
7
|
hash.map do |k, v|
|
@@ -10,14 +11,13 @@ module SeeAsVee
|
|
10
11
|
|
11
12
|
def initialize *args, **params
|
12
13
|
@hashes = []
|
13
|
-
|
14
|
+
@params = params
|
15
|
+
add(*args)
|
14
16
|
end
|
15
17
|
|
16
|
-
def add *args
|
18
|
+
def add *args
|
17
19
|
@keys, @joined = [nil] * 2
|
18
|
-
|
19
|
-
@hashes << params unless params.size.zero?
|
20
|
-
@hashes |= args.flatten.select(&Hash.method(:===))
|
20
|
+
@hashes |= degroup(args.flatten.select(&Hash.method(:===)), @params[:ungroup], @params[:delimiter] || ',')
|
21
21
|
normalize!(false)
|
22
22
|
end
|
23
23
|
|
@@ -53,6 +53,22 @@ module SeeAsVee
|
|
53
53
|
SeeAsVee::Sheet.new(humanize!.join.map(&:values).unshift(keys))
|
54
54
|
end
|
55
55
|
|
56
|
+
private
|
57
|
+
|
58
|
+
def degroup hashes, columns, delimiter
|
59
|
+
return hashes if (columns = [*columns]).empty?
|
60
|
+
|
61
|
+
hashes.tap do |hs|
|
62
|
+
hs.each do |hash|
|
63
|
+
columns.each do |column|
|
64
|
+
hash.delete(column).split(delimiter).each.with_index(1) do |value, idx|
|
65
|
+
hash["#{column}_#{idx}"] = value
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
56
72
|
class << self
|
57
73
|
def join *args, normalize: :human
|
58
74
|
Hashes.new(*args).join.tap do |result|
|
@@ -65,14 +81,26 @@ module SeeAsVee
|
|
65
81
|
end
|
66
82
|
|
67
83
|
def csv *args, **params
|
68
|
-
|
84
|
+
constructor_params, params = split_params(**params)
|
85
|
+
result, = Hashes.new(*args, **constructor_params).to_sheet.produce csv: true, xlsx: false, **params
|
69
86
|
result
|
70
87
|
end
|
71
88
|
|
72
89
|
def xlsx *args, **params
|
73
|
-
|
90
|
+
constructor_params, params = split_params(**params)
|
91
|
+
_, result = Hashes.new(*args, **constructor_params).to_sheet.produce csv: false, xlsx: true, **params
|
74
92
|
result
|
75
93
|
end
|
94
|
+
|
95
|
+
# **NB** this method is NOT idempotent!
|
96
|
+
def split_params **params
|
97
|
+
[
|
98
|
+
INTERNAL_PARAMS.each_with_object({}) do |param, acc|
|
99
|
+
acc[param] = params.delete(param)
|
100
|
+
end.reject { |_, v| v.nil? },
|
101
|
+
params
|
102
|
+
]
|
103
|
+
end
|
76
104
|
end
|
77
105
|
end
|
78
106
|
end
|
data/lib/see_as_vee/sheet.rb
CHANGED
@@ -4,10 +4,10 @@ module SeeAsVee
|
|
4
4
|
class Sheet
|
5
5
|
CELL_ERROR_MARKER = '⚑ '.freeze
|
6
6
|
CELL_ERROR_STYLE = {
|
7
|
-
bg_color:
|
8
|
-
fg_color:
|
7
|
+
bg_color: 'FF880000',
|
8
|
+
fg_color: 'FFFFFFFF',
|
9
9
|
sz: 14,
|
10
|
-
border: { style: :thin, color:
|
10
|
+
border: { style: :thin, color: 'FFFF0000' }
|
11
11
|
}.freeze
|
12
12
|
WORK_SHEET_NAME = 'Processing errors shown in red'.freeze
|
13
13
|
LEAVE_ERROR_MARKER = true
|
data/lib/see_as_vee/version.rb
CHANGED
data/lib/see_as_vee.rb
CHANGED
@@ -16,13 +16,13 @@ require 'axlsx'
|
|
16
16
|
require 'simple_xlsx_reader'
|
17
17
|
require 'csv'
|
18
18
|
|
19
|
-
require
|
20
|
-
require
|
19
|
+
require 'see_as_vee/version'
|
20
|
+
require 'see_as_vee/exceptions'
|
21
21
|
|
22
|
-
require
|
23
|
-
require
|
22
|
+
require 'see_as_vee/helpers'
|
23
|
+
require 'see_as_vee/sheet'
|
24
24
|
|
25
|
-
require
|
25
|
+
require 'see_as_vee/producers/hashes'
|
26
26
|
|
27
27
|
module SeeAsVee
|
28
28
|
def harvest whatever, formatters: {}, checkers: {}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: see_as_vee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksei Matiushkin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_xlsx_reader
|