sheetsy 1.2.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/lib/sheetsy/converter.rb +8 -4
- data/lib/sheetsy/json_file.rb +23 -0
- data/lib/sheetsy/reader.rb +3 -15
- data/lib/sheetsy/version.rb +1 -1
- data/lib/sheetsy.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 961ad80de96cffaf49ca35df5f2d041c28304f7ada1ca1c8ea615d7165358d33
|
4
|
+
data.tar.gz: 31e77af45fafb194cd03d397360f0cb822778fe42dc1a8cdef60fda9f3bf5ae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 632ecfa2ce5b8acd1a279f31087ec037a2d0db2d62c1cc07c9f89e39cc1bd36df75c3f1050b8e3c75edd84ed39a923a5ca464bc077bf3451ec2793b46caabe52
|
7
|
+
data.tar.gz: ed6813861f014ca1c00c7a5ef04d89c6ccb60f818990fe0a3a75ee60d99493841ad95993adc864945aacb8f55fccb4f5a2fede47431c4d7846e2b89a1b9f50bf
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sheetsy (1.
|
4
|
+
sheetsy (1.3.1)
|
5
5
|
rake (~> 13.0)
|
6
6
|
roo
|
7
7
|
rspec (~> 3.0)
|
@@ -50,8 +50,8 @@ GEM
|
|
50
50
|
rspec-mocks (3.13.0)
|
51
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
52
52
|
rspec-support (~> 3.13.0)
|
53
|
-
rspec-support (3.13.
|
54
|
-
rubocop (1.
|
53
|
+
rspec-support (3.13.1)
|
54
|
+
rubocop (1.61.0)
|
55
55
|
json (~> 2.3)
|
56
56
|
language_server-protocol (>= 3.17.0)
|
57
57
|
parallel (~> 1.10)
|
@@ -62,11 +62,11 @@ GEM
|
|
62
62
|
rubocop-ast (>= 1.30.0, < 2.0)
|
63
63
|
ruby-progressbar (~> 1.7)
|
64
64
|
unicode-display_width (>= 2.4.0, < 3.0)
|
65
|
-
rubocop-ast (1.
|
66
|
-
parser (>= 3.
|
65
|
+
rubocop-ast (1.31.1)
|
66
|
+
parser (>= 3.3.0.4)
|
67
67
|
ruby-progressbar (1.13.0)
|
68
68
|
rubyzip (2.3.2)
|
69
|
-
thor (1.3.
|
69
|
+
thor (1.3.1)
|
70
70
|
unicode-display_width (2.5.0)
|
71
71
|
|
72
72
|
PLATFORMS
|
data/lib/sheetsy/converter.rb
CHANGED
@@ -49,7 +49,7 @@ module Sheetsy
|
|
49
49
|
progress_bar.log str
|
50
50
|
end
|
51
51
|
|
52
|
-
def process_csv(file)
|
52
|
+
def process_csv(file) # rubocop:disable Metrics/MethodLength
|
53
53
|
debug "Processing as CSV"
|
54
54
|
|
55
55
|
output_file_path = File.join(destination, "#{nameify(file)}.json")
|
@@ -57,12 +57,16 @@ module Sheetsy
|
|
57
57
|
|
58
58
|
debug "File #{output_file_path}"
|
59
59
|
|
60
|
-
data =
|
60
|
+
data = begin
|
61
|
+
CSV.read(file, headers: true).map(&:to_h)
|
62
|
+
rescue CSV::MalformedCSVError
|
63
|
+
CSV.read(file, headers: true, encoding: "iso-8859-1:utf-8").map(&:to_h)
|
64
|
+
end
|
61
65
|
write_json(output_file_path, data)
|
62
66
|
debug "Converted #{file} to #{output_file_path}\n\n"
|
63
67
|
end
|
64
68
|
|
65
|
-
def process_excel(file)
|
69
|
+
def process_excel(file) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
66
70
|
debug "Processing as Excel"
|
67
71
|
excel = Roo::Spreadsheet.open(file)
|
68
72
|
|
@@ -99,7 +103,7 @@ module Sheetsy
|
|
99
103
|
process_excel(file)
|
100
104
|
else
|
101
105
|
debug "Unsupported file format: #{file}"
|
102
|
-
|
106
|
+
nil
|
103
107
|
end
|
104
108
|
end
|
105
109
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sheetsy
|
4
|
+
class JSONFile
|
5
|
+
attr_reader :file_path, :data
|
6
|
+
|
7
|
+
def initialize(file_path)
|
8
|
+
@file_path = file_path
|
9
|
+
end
|
10
|
+
|
11
|
+
def data
|
12
|
+
@data ||= JSON.parse(File.read(file_path))
|
13
|
+
end
|
14
|
+
|
15
|
+
def inspect
|
16
|
+
to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
"#<#{self.class}:#{file_path}>"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/sheetsy/reader.rb
CHANGED
@@ -13,14 +13,12 @@ module Sheetsy
|
|
13
13
|
debug "Files found: #{files.count}"
|
14
14
|
|
15
15
|
progress_bar.progress = 0
|
16
|
-
ret = {}
|
17
16
|
|
18
|
-
files.
|
19
|
-
ret
|
17
|
+
@data = files.map do |file|
|
18
|
+
ret = JSONFile.new(file)
|
20
19
|
progress_bar.increment
|
20
|
+
ret
|
21
21
|
end
|
22
|
-
|
23
|
-
@data = ret
|
24
22
|
end
|
25
23
|
|
26
24
|
def overwrite?
|
@@ -46,15 +44,5 @@ module Sheetsy
|
|
46
44
|
|
47
45
|
progress_bar.log str
|
48
46
|
end
|
49
|
-
|
50
|
-
def process_file(file)
|
51
|
-
debug "File: #{file}"
|
52
|
-
|
53
|
-
JSON.parse(File.read(file))
|
54
|
-
end
|
55
|
-
|
56
|
-
def progress_bar
|
57
|
-
@progress_bar ||= ProgressBar.create(title: "Files", total: files.count)
|
58
|
-
end
|
59
47
|
end
|
60
48
|
end
|
data/lib/sheetsy/version.rb
CHANGED
data/lib/sheetsy.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sheetsy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/sheetsy.rb
|
116
116
|
- lib/sheetsy/cli.rb
|
117
117
|
- lib/sheetsy/converter.rb
|
118
|
+
- lib/sheetsy/json_file.rb
|
118
119
|
- lib/sheetsy/reader.rb
|
119
120
|
- lib/sheetsy/version.rb
|
120
121
|
- sig/sheetsy.rbs
|