smerp-exporter-excel 0.1.0

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: 42d219df97a9da3e3c611a4e1c6ebc7f6b1b197e5d35d6a258f66dc9baa99206
4
+ data.tar.gz: db64814fec2d7624db2982e3dc6743bb61d0bb37b3ba54b666449d063f63af4f
5
+ SHA512:
6
+ metadata.gz: 9d8739bb227b7f997acf7337a8a0c424025d23a15696a65ee0a6af793b94afac388dd2ae51f548e0fd7410dfeedf4eceac2f344de567170c9a436130a81a3bfb
7
+ data.tar.gz: 38b5848a000c5e4b551349a9e2a6cd8efe78c4fd29518833155775cc9ca1b8059a178fbcea8e78f2a4f1c69b80752caebc29a3ef5a2bf14d840ece4ca6d6e6de
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in smerp-exporter-excel.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,82 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ smerp-exporter-excel (0.1.0)
5
+ axlsx
6
+ teLogger
7
+ toolrack
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ axlsx (2.0.1)
13
+ htmlentities (~> 4.3.1)
14
+ nokogiri (>= 1.4.1)
15
+ rubyzip (~> 1.0.0)
16
+ base58 (0.2.3)
17
+ devops_assist (0.3.1)
18
+ git_cli
19
+ git_cli_prompt
20
+ gvcs
21
+ teLogger
22
+ toolrack
23
+ tty-prompt
24
+ diff-lcs (1.5.0)
25
+ git_cli (0.10.0)
26
+ gvcs
27
+ ptools (~> 1.4.0)
28
+ teLogger
29
+ toolrack
30
+ git_cli_prompt (0.3.1)
31
+ teLogger
32
+ toolrack
33
+ tty-prompt
34
+ gvcs (0.1.0)
35
+ htmlentities (4.3.4)
36
+ nokogiri (1.13.8-x86_64-linux)
37
+ racc (~> 1.4)
38
+ pastel (0.8.0)
39
+ tty-color (~> 0.5)
40
+ ptools (1.4.2)
41
+ racc (1.6.0)
42
+ rake (13.0.6)
43
+ rspec (3.11.0)
44
+ rspec-core (~> 3.11.0)
45
+ rspec-expectations (~> 3.11.0)
46
+ rspec-mocks (~> 3.11.0)
47
+ rspec-core (3.11.0)
48
+ rspec-support (~> 3.11.0)
49
+ rspec-expectations (3.11.1)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.11.0)
52
+ rspec-mocks (3.11.1)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.11.0)
55
+ rspec-support (3.11.1)
56
+ rubyzip (1.0.0)
57
+ teLogger (0.2.0)
58
+ toolrack (0.19.1)
59
+ base58
60
+ tty-color (0.6.0)
61
+ tty-cursor (0.7.1)
62
+ tty-prompt (0.23.1)
63
+ pastel (~> 0.8)
64
+ tty-reader (~> 0.8)
65
+ tty-reader (0.9.0)
66
+ tty-cursor (~> 0.7)
67
+ tty-screen (~> 0.8)
68
+ wisper (~> 2.0)
69
+ tty-screen (0.8.1)
70
+ wisper (2.0.1)
71
+
72
+ PLATFORMS
73
+ x86_64-linux
74
+
75
+ DEPENDENCIES
76
+ devops_assist
77
+ rake (~> 13.0)
78
+ rspec (~> 3.0)
79
+ smerp-exporter-excel!
80
+
81
+ BUNDLED WITH
82
+ 2.2.28
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Smerp::Exporter::Excel
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/smerp/exporter/excel`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'smerp-exporter-excel'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install smerp-exporter-excel
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/smerp-exporter-excel.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ require 'devops_assist'
7
+
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "smerp/exporter/excel"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,18 @@
1
+
2
+ module Smerp
3
+ module Exporter
4
+ module Excel
5
+ class Column
6
+
7
+ def initialize(col)
8
+ @col = col
9
+ end
10
+
11
+ def method_missing(mtd, *args, &block)
12
+ @col.send(mtd, *args, &block)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+
2
+
3
+ module Smerp
4
+ module Exporter
5
+ module Excel
6
+ class Row
7
+
8
+ def initialize(row)
9
+ @row = row
10
+ end
11
+
12
+ def method_missing(mtd, *args, &block)
13
+ @row.send(mtd, *args, &block)
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,88 @@
1
+
2
+ require 'axlsx'
3
+ require_relative 'workbook'
4
+
5
+ module Smerp
6
+ module Exporter
7
+ module Excel
8
+
9
+ class ExporterConfig
10
+ attr_accessor :source
11
+ attr_accessor :start_row, :start_col
12
+
13
+ def initialize
14
+ @start_row = 0
15
+ @start_col = 0
16
+ end
17
+ end
18
+
19
+ class Exporter
20
+ include TR::CondUtils
21
+
22
+ def self.instance
23
+ Exporter.new
24
+ end
25
+
26
+ def initialize
27
+ @wbRec = {}
28
+ end
29
+
30
+ def start_cell(row, col = 0)
31
+ config.start_row = row
32
+ config.start_col = col
33
+
34
+ trigger_config_changed
35
+ end
36
+
37
+ def start_col=(col)
38
+ config.start_col = col
39
+ trigger_config_changed
40
+ end
41
+
42
+ def start_row=(row)
43
+ config.start_row = row
44
+ trigger_config_changed
45
+ end
46
+
47
+ def worksheet(name, *args, &block)
48
+ raise ExporterException, "Name is required" if is_empty?(name)
49
+ workbook.worksheet(name, *args, &block)
50
+ end
51
+
52
+ def save_to(output)
53
+ writer.serialize(output)
54
+ end
55
+
56
+ def config
57
+ if @_config.nil?
58
+ @_config = ExporterConfig.new
59
+ end
60
+ @_config
61
+ end
62
+
63
+ def writer
64
+ if @_writer.nil?
65
+ @_writer = Axlsx::Package.new
66
+ end
67
+ @_writer
68
+ end
69
+
70
+ def workbook
71
+ if @_workbook.nil?
72
+ wb = writer.workbook
73
+ @_workbook = Workbook.new(wb, config)
74
+ end
75
+ @_workbook
76
+ end
77
+
78
+ def trigger_config_changed
79
+ @wbRec.each do |k,v|
80
+ v.config = config
81
+ end
82
+ end
83
+
84
+
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Smerp
4
+ module Exporter
5
+ module Excel
6
+ VERSION = "0.1.0"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,43 @@
1
+
2
+ require_relative 'worksheet'
3
+
4
+ module Smerp
5
+ module Exporter
6
+ module Excel
7
+ class Workbook
8
+
9
+ attr_reader :inst
10
+ attr_accessor :config
11
+ def initialize(wb, config)
12
+ @inst = wb
13
+ @config = config
14
+ @wsRec = {}
15
+ end
16
+
17
+ def worksheet(name, *args, &block)
18
+ ws = @inst.add_worksheet(name: name)
19
+ wsProxy = Worksheet.new(ws, @config)
20
+ @wsRec[name] = wsProxy
21
+
22
+ if block
23
+ block.call(wsProxy)
24
+ else
25
+ ws
26
+ end
27
+ end
28
+
29
+ def config=(conf)
30
+ @config = conf
31
+ @wsRec.each do |k,v|
32
+ v.config = conf
33
+ end
34
+ end
35
+
36
+ def method_missing(mtd, *args, &block)
37
+ @inst.send(mtd, *args, &block)
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,44 @@
1
+
2
+
3
+ module Smerp
4
+ module Exporter
5
+ module Excel
6
+ class Worksheet
7
+
8
+ attr_reader :inst
9
+ attr_accessor :config
10
+ def initialize(ws, config)
11
+ @inst = ws
12
+ @config = config
13
+ @curRow = 0
14
+ @curCol = 0
15
+
16
+ if @config.start_row != @curRow
17
+ (0...@config.start_row-1).each do |i|
18
+ @inst.add_row
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ def start_col=(col)
25
+ @config.start_col = col
26
+ end
27
+
28
+ def insert_row(val = [], *args, &block)
29
+
30
+ if @config.start_col != 0
31
+ patch = Array.new(@config.start_col).collect { |e| "" }
32
+ val = patch.concat(val)
33
+ end
34
+ @inst.add_row(val, *args)
35
+ end
36
+
37
+ def method_missing(mtd, *args, &block)
38
+ @inst.send(mtd, *args, &block)
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'toolrack'
4
+ require 'teLogger'
5
+
6
+ require_relative "excel/version"
7
+ require_relative "excel/exporter"
8
+
9
+ module Smerp
10
+ module Exporter
11
+ module Excel
12
+ class Error < StandardError; end
13
+ # Your code goes here...
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/smerp/exporter/excel/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "smerp-exporter-excel"
7
+ spec.version = Smerp::Exporter::Excel::VERSION
8
+ spec.authors = ["Ian"]
9
+ spec.email = ["cameronian0@protonmail.com"]
10
+
11
+ spec.summary = ""
12
+ spec.description = ""
13
+ spec.homepage = ""
14
+ spec.required_ruby_version = ">= 2.4.0"
15
+
16
+ #spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
+
18
+ #spec.metadata["homepage_uri"] = spec.homepage
19
+ #spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
20
+ #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency 'toolrack'
34
+ spec.add_dependency 'teLogger'
35
+
36
+ #spec.add_dependency 'rubyXL'
37
+ spec.add_dependency 'axlsx'
38
+
39
+ spec.add_development_dependency 'devops_assist'
40
+
41
+ # Uncomment to register a new dependency of your gem
42
+ # spec.add_dependency "example-gem", "~> 1.0"
43
+
44
+ # For more information and examples about making a new gem, checkout our
45
+ # guide at: https://bundler.io/guides/creating_gem.html
46
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smerp-exporter-excel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ian
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-10-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: toolrack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: teLogger
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: axlsx
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: devops_assist
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: ''
70
+ email:
71
+ - cameronian0@protonmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".rspec"
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - README.md
80
+ - Rakefile
81
+ - bin/console
82
+ - bin/setup
83
+ - lib/smerp/exporter/excel.rb
84
+ - lib/smerp/exporter/excel/excel_col.rb
85
+ - lib/smerp/exporter/excel/excel_row.rb
86
+ - lib/smerp/exporter/excel/exporter.rb
87
+ - lib/smerp/exporter/excel/version.rb
88
+ - lib/smerp/exporter/excel/workbook.rb
89
+ - lib/smerp/exporter/excel/worksheet.rb
90
+ - smerp-exporter-excel.gemspec
91
+ homepage: ''
92
+ licenses: []
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 2.4.0
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubygems_version: 3.2.22
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: ''
113
+ test_files: []