sheetsy 1.1.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: c1657d9d17ecb875a0ee44347fa799432cfe45d69c96cf4fdde1ddd790b66bfb
4
- data.tar.gz: 817112d9e9c2165564690570c1c32edb8588366776e817484516a6b000a29b86
3
+ metadata.gz: 46b076008cee61a9a62811da5a448d4d67584867944789863fad1c8ed9463e7c
4
+ data.tar.gz: 3d61813f2caa7d34308f6cdced0458ff88964fdda77496197747f37c1eecaf4d
5
5
  SHA512:
6
- metadata.gz: 3ae345e0b375497fa4d5480bbbb2c2979da0d825c97fbba88e1209d094c7e5ef3eec1f2e90a3166c0dfe99bffad112d5fe76fa2cf1c1992db8c9be7bd164fd0d
7
- data.tar.gz: 4d6ce7739558090453106d37cb1a17e114ca7f4ad3b5ffa2f645668df557c3ee6be90a55fcc4b10502a66386b27a299ec426c6e9aca6ed01773fa4bf26e086c8
6
+ metadata.gz: 9bed1161ce8242f20335fc8ad03bff03629936bd2f965bc25570d351b542f6b178abb4df7c186c67b70a0543d451cf1398fab32db635b3ebad6873de698911bd
7
+ data.tar.gz: f71ddaf63e56078256009e72fdadd539c53069d9bbb5e615907e2b2c152059c0f9b442d7dac3c1d9d2820990101bce2307b5e0476ee42d257f59609fafbe29e2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sheetsy (1.1.0)
4
+ sheetsy (1.2.0)
5
5
  rake (~> 13.0)
6
6
  roo
7
7
  rspec (~> 3.0)
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.1.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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sheetsy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan
@@ -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/reader.rb
118
119
  - lib/sheetsy/version.rb
119
120
  - sig/sheetsy.rbs
120
121
  homepage: https://github.com/ryanwjackson/sheetsy