sheetsy 1.0.0 → 1.2.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
  SHA256:
3
- metadata.gz: 5187487347d0e1505b9e40889c488ab8341fb55d866d6af96487addcb0a60150
4
- data.tar.gz: 863582071eb4b16b551b034ea0ceb5b380603fff767f2ac4314a55c3d3789d95
3
+ metadata.gz: 46b076008cee61a9a62811da5a448d4d67584867944789863fad1c8ed9463e7c
4
+ data.tar.gz: 3d61813f2caa7d34308f6cdced0458ff88964fdda77496197747f37c1eecaf4d
5
5
  SHA512:
6
- metadata.gz: be8be3a1ae1e007f319cc65b4f400e95a8acba69715ea17b8844693799d95bce5b95791f5db51bcc2fb9a6e2a98269b626c5c11218279d7bf929612171de2ed3
7
- data.tar.gz: 399dea79e08ecdbee1ee49268511a0e2ab1e3a4228706ec59c2db8f520b2c393557710f4df452ffd94f927389b5fd9414bca6556832629bcc3b8a68205406c79
6
+ metadata.gz: 9bed1161ce8242f20335fc8ad03bff03629936bd2f965bc25570d351b542f6b178abb4df7c186c67b70a0543d451cf1398fab32db635b3ebad6873de698911bd
7
+ data.tar.gz: f71ddaf63e56078256009e72fdadd539c53069d9bbb5e615907e2b2c152059c0f9b442d7dac3c1d9d2820990101bce2307b5e0476ee42d257f59609fafbe29e2
data/Gemfile CHANGED
@@ -5,16 +5,6 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in sheetsy.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
9
-
10
- gem "rspec", "~> 3.0"
11
-
12
- gem "rubocop", "~> 1.21"
13
-
14
- gem "roo"
15
- gem "ruby-progressbar"
16
- gem "thor"
17
-
18
8
  group :development, :test do
19
9
  gem "pd_ruby"
20
10
  end
data/Gemfile.lock CHANGED
@@ -1,23 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sheetsy (1.0.0)
4
+ sheetsy (1.2.0)
5
+ rake (~> 13.0)
6
+ roo
7
+ rspec (~> 3.0)
8
+ rubocop (~> 1.21)
9
+ ruby-progressbar
10
+ thor
5
11
 
6
12
  GEM
7
13
  remote: https://rubygems.org/
8
14
  specs:
9
15
  ast (2.4.2)
10
- base64 (0.1.1)
11
16
  coderay (1.1.3)
12
17
  colorize (1.1.0)
13
- diff-lcs (1.5.0)
14
- json (2.6.3)
18
+ diff-lcs (1.5.1)
19
+ json (2.7.1)
15
20
  language_server-protocol (3.17.0.3)
16
21
  method_source (1.0.0)
17
- nokogiri (1.15.4-arm64-darwin)
22
+ nokogiri (1.16.2-arm64-darwin)
18
23
  racc (~> 1.4)
19
- parallel (1.23.0)
20
- parser (3.2.2.4)
24
+ parallel (1.24.0)
25
+ parser (3.3.0.5)
21
26
  ast (~> 2.4.1)
22
27
  racc
23
28
  pd_ruby (0.2.3)
@@ -25,44 +30,43 @@ GEM
25
30
  pry (0.14.2)
26
31
  coderay (~> 1.1)
27
32
  method_source (~> 1.0)
28
- racc (1.7.1)
33
+ racc (1.7.3)
29
34
  rainbow (3.1.1)
30
- rake (13.0.6)
31
- regexp_parser (2.8.2)
35
+ rake (13.1.0)
36
+ regexp_parser (2.9.0)
32
37
  rexml (3.2.6)
33
- roo (2.10.0)
38
+ roo (2.10.1)
34
39
  nokogiri (~> 1)
35
40
  rubyzip (>= 1.3.0, < 3.0.0)
36
- rspec (3.12.0)
37
- rspec-core (~> 3.12.0)
38
- rspec-expectations (~> 3.12.0)
39
- rspec-mocks (~> 3.12.0)
40
- rspec-core (3.12.2)
41
- rspec-support (~> 3.12.0)
42
- rspec-expectations (3.12.3)
41
+ rspec (3.13.0)
42
+ rspec-core (~> 3.13.0)
43
+ rspec-expectations (~> 3.13.0)
44
+ rspec-mocks (~> 3.13.0)
45
+ rspec-core (3.13.0)
46
+ rspec-support (~> 3.13.0)
47
+ rspec-expectations (3.13.0)
43
48
  diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.12.0)
45
- rspec-mocks (3.12.6)
49
+ rspec-support (~> 3.13.0)
50
+ rspec-mocks (3.13.0)
46
51
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.12.0)
48
- rspec-support (3.12.1)
49
- rubocop (1.57.1)
50
- base64 (~> 0.1.1)
52
+ rspec-support (~> 3.13.0)
53
+ rspec-support (3.13.0)
54
+ rubocop (1.60.2)
51
55
  json (~> 2.3)
52
56
  language_server-protocol (>= 3.17.0)
53
57
  parallel (~> 1.10)
54
- parser (>= 3.2.2.4)
58
+ parser (>= 3.3.0.2)
55
59
  rainbow (>= 2.2.2, < 4.0)
56
60
  regexp_parser (>= 1.8, < 3.0)
57
61
  rexml (>= 3.2.5, < 4.0)
58
- rubocop-ast (>= 1.28.1, < 2.0)
62
+ rubocop-ast (>= 1.30.0, < 2.0)
59
63
  ruby-progressbar (~> 1.7)
60
64
  unicode-display_width (>= 2.4.0, < 3.0)
61
- rubocop-ast (1.29.0)
65
+ rubocop-ast (1.30.0)
62
66
  parser (>= 3.2.1.0)
63
67
  ruby-progressbar (1.13.0)
64
68
  rubyzip (2.3.2)
65
- thor (1.2.2)
69
+ thor (1.3.0)
66
70
  unicode-display_width (2.5.0)
67
71
 
68
72
  PLATFORMS
@@ -71,13 +75,7 @@ PLATFORMS
71
75
  DEPENDENCIES
72
76
  pd_ruby
73
77
  pry
74
- rake (~> 13.0)
75
- roo
76
- rspec (~> 3.0)
77
- rubocop (~> 1.21)
78
- ruby-progressbar
79
78
  sheetsy!
80
- thor
81
79
 
82
80
  BUNDLED WITH
83
81
  2.3.26
data/lib/sheetsy/cli.rb CHANGED
@@ -31,6 +31,21 @@ module Sheetsy
31
31
  Sheetsy::Converter.new(source, destination, options).run
32
32
  end
33
33
 
34
+ desc "reader", "Read JSON sheets"
35
+ option :source, type: :string, aliases: :s
36
+ option :debug, type: :boolean, default: false
37
+ def reader
38
+ source = if options[:source]
39
+ options[:source]
40
+ elsif ENV.key?("SOURCE")
41
+ ENV.fetch("SOURCE")
42
+ else
43
+ get_input("Source Directory", Dir.pwd)
44
+ end
45
+
46
+ Sheetsy::Reader.new(source, options).run
47
+ end
48
+
34
49
  private
35
50
 
36
51
  def get_input(text, default)
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sheetsy
4
+ class Reader
5
+ attr_reader :source, :options, :data
6
+
7
+ def initialize(source, options = {})
8
+ @source = source
9
+ @options = options
10
+ end
11
+
12
+ def run
13
+ debug "Files found: #{files.count}"
14
+
15
+ progress_bar.progress = 0
16
+ ret = {}
17
+
18
+ files.each do |file|
19
+ ret[file] = process_file(file)
20
+ progress_bar.increment
21
+ end
22
+
23
+ @data = ret
24
+ end
25
+
26
+ def overwrite?
27
+ @overwrite ||= options[:overwrite]
28
+ end
29
+
30
+ def debug?
31
+ @debug ||= options[:debug]
32
+ end
33
+
34
+ private
35
+
36
+ def files
37
+ @files ||= Dir.glob(File.join(source, "**/*.{json}"))
38
+ end
39
+
40
+ def progress_bar
41
+ @progress_bar ||= ProgressBar.create(title: "Files", total: files.count)
42
+ end
43
+
44
+ def debug(str)
45
+ return unless debug?
46
+
47
+ progress_bar.log str
48
+ 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
+ end
60
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sheetsy
4
- VERSION = "1.0.0"
4
+ VERSION = "1.2.0"
5
5
  end
data/lib/sheetsy.rb CHANGED
@@ -3,11 +3,12 @@
3
3
  require "json"
4
4
  require "roo"
5
5
  require "csv"
6
- require "pry"
6
+ # require "pry"
7
7
  require "ruby-progressbar"
8
8
 
9
9
  require_relative "sheetsy/version"
10
10
  require_relative "sheetsy/converter"
11
+ require_relative "sheetsy/reader"
11
12
  require_relative "sheetsy/cli"
12
13
 
13
14
  module Sheetsy
metadata CHANGED
@@ -1,15 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sheetsy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-30 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2024-02-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.21'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.21'
55
+ - !ruby/object:Gem::Dependency
56
+ name: roo
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: ruby-progressbar
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: thor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
13
97
  description: Easily convert CSV and Excel sheets to JSON
14
98
  email:
15
99
  - sheetsy@rwj.dev
@@ -31,6 +115,7 @@ files:
31
115
  - lib/sheetsy.rb
32
116
  - lib/sheetsy/cli.rb
33
117
  - lib/sheetsy/converter.rb
118
+ - lib/sheetsy/reader.rb
34
119
  - lib/sheetsy/version.rb
35
120
  - sig/sheetsy.rbs
36
121
  homepage: https://github.com/ryanwjackson/sheetsy
@@ -56,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
141
  - !ruby/object:Gem::Version
57
142
  version: '0'
58
143
  requirements: []
59
- rubygems_version: 3.3.26
144
+ rubygems_version: 3.4.22
60
145
  signing_key:
61
146
  specification_version: 4
62
147
  summary: Easily convert CSV and Excel sheets to JSON