cnd_excel2yaml 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 23b4287c52692cdea3ee23ab1637506bce3e1f06a342aafeaedfdc786c7856fc
4
+ data.tar.gz: 9f6dbd8151af0d2b3cd012284490bd3cab56ced11747cf9b8f6b864a9ab4000a
5
+ SHA512:
6
+ metadata.gz: 52ae263b2b7ca76297ca46ab8e334fd910dc7bfe1b0c7c44ffd059e595067f0597f7db7d26618d29e3bcf6193b916c770a5f1312ceb34358bb3ba14d4ca54016
7
+ data.tar.gz: f83316048c832c40cb606e7b2bc09dfa39fe5fc534767c5846150a191a3db29cfb3377a0d1d25dcc155e52a53f743bebc820747f7b2f761a8e3aaa67755933c4
@@ -0,0 +1,47 @@
1
+ module Excel2Yaml
2
+ class Convert
3
+ def initialize()
4
+ @sheets = {}
5
+ end
6
+
7
+ def process(source, main_sheet, ref_column)
8
+ self.source = source
9
+ self.main_sheet = main_sheet
10
+ @ref_column = ref_column
11
+ self.read
12
+ self.process_main
13
+ end
14
+
15
+ def process_main
16
+ @sheets[@main_sheet].rows.each(headers: true) do |row|
17
+ file_path = "outputs/#{@target}"
18
+ row["details"] = []
19
+ @sheets[row[@ref_column]].rows.each(headers: true) do |sub_row|
20
+ row["details"] << sub_row
21
+ end
22
+ save(file_path, row[@ref_column], row)
23
+ end
24
+ end
25
+
26
+ def save(file_path, file_name, content)
27
+ FileUtils.mkdir_p(file_path) unless File.directory?(file_path)
28
+ File.open("#{file_path}/#{file_name}.yml", 'w') {|f| f.write content.to_yaml }
29
+ end
30
+
31
+ def read
32
+ doc = SimpleXlsxReader.open(@source)
33
+ doc.sheets.each do |sheet|
34
+ @sheets[sheet.name] = sheet
35
+ end
36
+ end
37
+
38
+ def main_sheet=(value)
39
+ @main_sheet = value
40
+ end
41
+
42
+ def source=(value)
43
+ @target = value.split('/').last.split('.').first
44
+ @source = value
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module Excel2Yaml
2
+ VERSION = "0.0.2".freeze
3
+ end
data/lib/excel2yaml.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'yaml'
2
+ require "colorize"
3
+ require "simple_xlsx_reader"
4
+
5
+ module Excel2Yaml
6
+ require "excel2yaml/version"
7
+ require "excel2yaml/convert"
8
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cnd_excel2yaml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Denis Fabien
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.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: 3.13.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: simple_xlsx_reader
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-expectations
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.13.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.13.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: colorize
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
69
+ description: Gem lib convert exell file to yaml
70
+ email: denis@changendevops.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - lib/excel2yaml.rb
76
+ - lib/excel2yaml/convert.rb
77
+ - lib/excel2yaml/version.rb
78
+ homepage: https://changendevops.com
79
+ licenses:
80
+ - MIT
81
+ metadata:
82
+ source_code_uri: https://gitlab.com/changendevops/cndexcel2yaml
83
+ post_install_message: Thanks for installing CnDExcel2Yaml 0.0.2
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubygems_version: 3.4.10
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: CndExcel2Yaml
102
+ test_files: []