xcellus 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.editorconfig +14 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Dockerfile +10 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +65 -0
- data/Gopkg.lock +15 -0
- data/Gopkg.toml +34 -0
- data/LICENSE +21 -0
- data/Makefile +25 -0
- data/README.md +89 -0
- data/Rakefile +8 -0
- data/bin/console +8 -0
- data/ext/xcellus/Makefile +263 -0
- data/ext/xcellus/extconf.h +4 -0
- data/ext/xcellus/extconf.rb +23 -0
- data/ext/xcellus/libxcbindings.h +85 -0
- data/ext/xcellus/xcellus.c +27 -0
- data/golang/xcellus.go +80 -0
- data/lib/xcellus.rb +20 -0
- data/script/build-golang +9 -0
- data/script/build-ruby +8 -0
- data/xcellus.gemspec +34 -0
- metadata +161 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ac9dd9607a05490e8fa49733ed3f3f21a4f6ce0cc1737a5f9c5f08c62dfe7c8d
|
|
4
|
+
data.tar.gz: 015e5b9f0c72f098c6a2cfe649f8cdb3aeb775ccf9f93330da8cc65ebaa6939a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e0d0ba54d0bfef72d0737ea55ce518e31ea9626e9333b4322f7ef903f54248579c093e8cce1e9d2d3cbdf8f18571097a523f785737ac089da343414cb155544e
|
|
7
|
+
data.tar.gz: 662a9a972ea457c6ecd4ed4b315edafa0ec57c4fd1f6c18e485bc126b2a0783525d261479dc2e93f32e539b862b1e73b50b19b33091343dc0332c8c2885bef78
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at hey@vito.io. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Dockerfile
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
xcellus (0.1)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ast (2.4.0)
|
|
10
|
+
codecov (0.1.10)
|
|
11
|
+
json
|
|
12
|
+
simplecov
|
|
13
|
+
url
|
|
14
|
+
diff-lcs (1.3)
|
|
15
|
+
docile (1.3.1)
|
|
16
|
+
json (2.1.0)
|
|
17
|
+
parallel (1.12.1)
|
|
18
|
+
parser (2.5.1.0)
|
|
19
|
+
ast (~> 2.4.0)
|
|
20
|
+
powerpack (0.1.2)
|
|
21
|
+
rainbow (3.0.0)
|
|
22
|
+
rake (10.5.0)
|
|
23
|
+
rspec (3.7.0)
|
|
24
|
+
rspec-core (~> 3.7.0)
|
|
25
|
+
rspec-expectations (~> 3.7.0)
|
|
26
|
+
rspec-mocks (~> 3.7.0)
|
|
27
|
+
rspec-core (3.7.1)
|
|
28
|
+
rspec-support (~> 3.7.0)
|
|
29
|
+
rspec-expectations (3.7.0)
|
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
31
|
+
rspec-support (~> 3.7.0)
|
|
32
|
+
rspec-mocks (3.7.0)
|
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
34
|
+
rspec-support (~> 3.7.0)
|
|
35
|
+
rspec-support (3.7.1)
|
|
36
|
+
rubocop (0.55.0)
|
|
37
|
+
parallel (~> 1.10)
|
|
38
|
+
parser (>= 2.5)
|
|
39
|
+
powerpack (~> 0.1)
|
|
40
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
41
|
+
ruby-progressbar (~> 1.7)
|
|
42
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
43
|
+
ruby-progressbar (1.9.0)
|
|
44
|
+
simplecov (0.16.1)
|
|
45
|
+
docile (~> 1.1)
|
|
46
|
+
json (>= 1.8, < 3)
|
|
47
|
+
simplecov-html (~> 0.10.0)
|
|
48
|
+
simplecov-html (0.10.2)
|
|
49
|
+
unicode-display_width (1.4.0)
|
|
50
|
+
url (0.3.2)
|
|
51
|
+
|
|
52
|
+
PLATFORMS
|
|
53
|
+
ruby
|
|
54
|
+
|
|
55
|
+
DEPENDENCIES
|
|
56
|
+
bundler (~> 1.16)
|
|
57
|
+
codecov
|
|
58
|
+
rake (~> 10.0)
|
|
59
|
+
rspec (~> 3.0)
|
|
60
|
+
rubocop (~> 0.55.0)
|
|
61
|
+
simplecov (~> 0.16.1)
|
|
62
|
+
xcellus!
|
|
63
|
+
|
|
64
|
+
BUNDLED WITH
|
|
65
|
+
1.16.1
|
data/Gopkg.lock
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
[[projects]]
|
|
5
|
+
name = "github.com/tealeg/xlsx"
|
|
6
|
+
packages = ["."]
|
|
7
|
+
revision = "8be35264fa75a1bbe954ce51eba04f273e2c59e5"
|
|
8
|
+
version = "v1.0.3"
|
|
9
|
+
|
|
10
|
+
[solve-meta]
|
|
11
|
+
analyzer-name = "dep"
|
|
12
|
+
analyzer-version = 1
|
|
13
|
+
inputs-digest = "ac8a23a08b92cf25234b5b72dbefae4e8a6dd453d9affff27b41d610802d1649"
|
|
14
|
+
solver-name = "gps-cdcl"
|
|
15
|
+
solver-version = 1
|
data/Gopkg.toml
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Gopkg.toml example
|
|
2
|
+
#
|
|
3
|
+
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
|
|
4
|
+
# for detailed Gopkg.toml documentation.
|
|
5
|
+
#
|
|
6
|
+
# required = ["github.com/user/thing/cmd/thing"]
|
|
7
|
+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
|
8
|
+
#
|
|
9
|
+
# [[constraint]]
|
|
10
|
+
# name = "github.com/user/project"
|
|
11
|
+
# version = "1.0.0"
|
|
12
|
+
#
|
|
13
|
+
# [[constraint]]
|
|
14
|
+
# name = "github.com/user/project2"
|
|
15
|
+
# branch = "dev"
|
|
16
|
+
# source = "github.com/myfork/project2"
|
|
17
|
+
#
|
|
18
|
+
# [[override]]
|
|
19
|
+
# name = "github.com/x/y"
|
|
20
|
+
# version = "2.4.0"
|
|
21
|
+
#
|
|
22
|
+
# [prune]
|
|
23
|
+
# non-go = false
|
|
24
|
+
# go-tests = true
|
|
25
|
+
# unused-packages = true
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
[[constraint]]
|
|
29
|
+
name = "github.com/tealeg/xlsx"
|
|
30
|
+
version = "1.0.3"
|
|
31
|
+
|
|
32
|
+
[prune]
|
|
33
|
+
go-tests = true
|
|
34
|
+
unused-packages = true
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Victor Gama
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/Makefile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|
2
|
+
|
|
3
|
+
all:
|
|
4
|
+
echo "Please specify what to build"
|
|
5
|
+
exit 1
|
|
6
|
+
|
|
7
|
+
go:
|
|
8
|
+
docker run -v $(ROOT_DIR):/source --rm golang:1.10 /source/script/build-golang
|
|
9
|
+
|
|
10
|
+
ruby:
|
|
11
|
+
docker run -v $(ROOT_DIR):/source --rm victorgama/ruby-base:2.4 /source/script/build-ruby
|
|
12
|
+
|
|
13
|
+
darwin: clean
|
|
14
|
+
go build -o ext/xcellus/libxcbindings.a -buildmode=c-archive golang/xcellus.go
|
|
15
|
+
cd ext/xcellus && ruby extconf.rb && make
|
|
16
|
+
cd pkg && rm *
|
|
17
|
+
|
|
18
|
+
linux: clean go ruby
|
|
19
|
+
|
|
20
|
+
release: linux
|
|
21
|
+
gem push $(shell ls pkg)
|
|
22
|
+
|
|
23
|
+
clean:
|
|
24
|
+
cd ext/xcellus && \
|
|
25
|
+
rm -f extconf.h libxcbindings.* Makefile mkmf.* *.so *.o *.bundle
|
data/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Xcellus
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.com/victorgama/xcellus)
|
|
4
|
+
[](https://codecov.io/gh/victorgama/xcellus)
|
|
5
|
+
[](https://badge.fury.io/rb/xcellus)
|
|
6
|
+
|
|
7
|
+
**Xcellus** is an ugly XLSX generator. It leverages a native extension to create
|
|
8
|
+
XLSX files. It is said to be an 'ugly' generator because it lacks all styling
|
|
9
|
+
mechanisms to make your XLSX pretty (such as fonts, borders, and the likes).
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
> **WARNING**: Xcellus is targeted for Linux (amd64). It won't work on other architectures and support for them is not planned.
|
|
14
|
+
|
|
15
|
+
Add this line to your application's Gemfile:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
gem 'xcellus'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
And then execute:
|
|
22
|
+
|
|
23
|
+
$ bundle
|
|
24
|
+
|
|
25
|
+
Or install it yourself as:
|
|
26
|
+
|
|
27
|
+
$ gem install xcellus
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Xcellus transforms a list of hashes (acting as worksheets) into a XLSX workbook:
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
require 'xcellus'
|
|
35
|
+
io = Xcellus.transform [
|
|
36
|
+
{
|
|
37
|
+
title: 'Brian\'s Worksheet',
|
|
38
|
+
headers: [:Artist, :Track, :Playcount],
|
|
39
|
+
rows: [
|
|
40
|
+
['Metallica', 'Hero of the Day', 242],
|
|
41
|
+
['Metallica', 'The Shortest Straw', 186],
|
|
42
|
+
['Queens of the Stone Age', 'My God Is the Sun', 276],
|
|
43
|
+
['Queens of the Stone Age', 'I Sat by the Ocean', 270],
|
|
44
|
+
['Gorillaz', 'On Melancholy Hill', 203],
|
|
45
|
+
['Gorillaz', 'Kids With Guns', 184],
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
# => #<StringIO:0x000000000245cc78>
|
|
50
|
+
|
|
51
|
+
File.open('BrianosMusic.xlsx', 'wb') do |f|
|
|
52
|
+
f.write(io.string)
|
|
53
|
+
end
|
|
54
|
+
# => 6377
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Contributing
|
|
58
|
+
|
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/victorgama/xcellus. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
60
|
+
|
|
61
|
+
## Code of Conduct
|
|
62
|
+
|
|
63
|
+
Everyone interacting in the Pagu project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/victorgama/xcellus/blob/master/CODE_OF_CONDUCT.md).
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
The MIT License (MIT)
|
|
69
|
+
|
|
70
|
+
Copyright (c) 2018 Victor Gama
|
|
71
|
+
|
|
72
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
73
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
74
|
+
in the Software without restriction, including without limitation the rights
|
|
75
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
76
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
77
|
+
furnished to do so, subject to the following conditions:
|
|
78
|
+
|
|
79
|
+
The above copyright notice and this permission notice shall be included in
|
|
80
|
+
all copies or substantial portions of the Software.
|
|
81
|
+
|
|
82
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
83
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
84
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
85
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
86
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
87
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
88
|
+
THE SOFTWARE.
|
|
89
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
|
|
2
|
+
SHELL = /bin/sh
|
|
3
|
+
|
|
4
|
+
# V=0 quiet, V=1 verbose. other values don't work.
|
|
5
|
+
V = 0
|
|
6
|
+
Q1 = $(V:1=)
|
|
7
|
+
Q = $(Q1:0=@)
|
|
8
|
+
ECHO1 = $(V:1=@ :)
|
|
9
|
+
ECHO = $(ECHO1:0=@ echo)
|
|
10
|
+
NULLCMD = :
|
|
11
|
+
|
|
12
|
+
#### Start of system configuration section. ####
|
|
13
|
+
|
|
14
|
+
srcdir = .
|
|
15
|
+
topdir = /usr/local/include/ruby-2.4.0
|
|
16
|
+
hdrdir = $(topdir)
|
|
17
|
+
arch_hdrdir = /usr/local/include/ruby-2.4.0/x86_64-linux
|
|
18
|
+
PATH_SEPARATOR = :
|
|
19
|
+
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
|
|
20
|
+
prefix = $(DESTDIR)/usr/local
|
|
21
|
+
rubysitearchprefix = $(rubylibprefix)/$(sitearch)
|
|
22
|
+
rubyarchprefix = $(rubylibprefix)/$(arch)
|
|
23
|
+
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
|
|
24
|
+
exec_prefix = $(prefix)
|
|
25
|
+
vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
|
|
26
|
+
sitearchhdrdir = $(sitehdrdir)/$(sitearch)
|
|
27
|
+
rubyarchhdrdir = $(rubyhdrdir)/$(arch)
|
|
28
|
+
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
|
|
29
|
+
sitehdrdir = $(rubyhdrdir)/site_ruby
|
|
30
|
+
rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
|
|
31
|
+
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
|
32
|
+
vendorlibdir = $(vendordir)/$(ruby_version)
|
|
33
|
+
vendordir = $(rubylibprefix)/vendor_ruby
|
|
34
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
|
35
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
|
36
|
+
sitedir = $(rubylibprefix)/site_ruby
|
|
37
|
+
rubyarchdir = $(rubylibdir)/$(arch)
|
|
38
|
+
rubylibdir = $(rubylibprefix)/$(ruby_version)
|
|
39
|
+
sitearchincludedir = $(includedir)/$(sitearch)
|
|
40
|
+
archincludedir = $(includedir)/$(arch)
|
|
41
|
+
sitearchlibdir = $(libdir)/$(sitearch)
|
|
42
|
+
archlibdir = $(libdir)/$(arch)
|
|
43
|
+
ridir = $(datarootdir)/$(RI_BASE_NAME)
|
|
44
|
+
mandir = $(datarootdir)/man
|
|
45
|
+
localedir = $(datarootdir)/locale
|
|
46
|
+
libdir = $(exec_prefix)/lib
|
|
47
|
+
psdir = $(docdir)
|
|
48
|
+
pdfdir = $(docdir)
|
|
49
|
+
dvidir = $(docdir)
|
|
50
|
+
htmldir = $(docdir)
|
|
51
|
+
infodir = $(datarootdir)/info
|
|
52
|
+
docdir = $(datarootdir)/doc/$(PACKAGE)
|
|
53
|
+
oldincludedir = $(DESTDIR)/usr/include
|
|
54
|
+
includedir = $(prefix)/include
|
|
55
|
+
localstatedir = $(prefix)/var
|
|
56
|
+
sharedstatedir = $(prefix)/com
|
|
57
|
+
sysconfdir = $(prefix)/etc
|
|
58
|
+
datadir = $(datarootdir)
|
|
59
|
+
datarootdir = $(prefix)/share
|
|
60
|
+
libexecdir = $(exec_prefix)/libexec
|
|
61
|
+
sbindir = $(exec_prefix)/sbin
|
|
62
|
+
bindir = $(exec_prefix)/bin
|
|
63
|
+
archdir = $(rubyarchdir)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
CC = gcc
|
|
67
|
+
CXX = g++
|
|
68
|
+
LIBRUBY = $(LIBRUBY_SO)
|
|
69
|
+
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
|
70
|
+
LIBRUBYARG_SHARED = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
|
|
71
|
+
LIBRUBYARG_STATIC = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
|
|
72
|
+
empty =
|
|
73
|
+
OUTFLAG = -o $(empty)
|
|
74
|
+
COUTFLAG = -o $(empty)
|
|
75
|
+
CSRCFLAG = $(empty)
|
|
76
|
+
|
|
77
|
+
RUBY_EXTCONF_H = extconf.h
|
|
78
|
+
cflags = $(optflags) $(debugflags) $(warnflags)
|
|
79
|
+
cxxflags = $(optflags) $(debugflags) $(warnflags)
|
|
80
|
+
optflags = -O3 -fno-fast-math
|
|
81
|
+
debugflags = -ggdb3
|
|
82
|
+
warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format
|
|
83
|
+
CCDLFLAGS = -fPIC
|
|
84
|
+
CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
|
|
85
|
+
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
|
|
86
|
+
DEFS =
|
|
87
|
+
CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" -I/source/ext/xcellus $(DEFS) $(cppflags)
|
|
88
|
+
CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
|
|
89
|
+
ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic -L/source/ext/xcellus
|
|
90
|
+
dldflags =
|
|
91
|
+
ARCH_FLAG =
|
|
92
|
+
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
|
|
93
|
+
LDSHARED = $(CC) -shared
|
|
94
|
+
LDSHAREDXX = $(CXX) -shared
|
|
95
|
+
AR = ar
|
|
96
|
+
EXEEXT =
|
|
97
|
+
|
|
98
|
+
RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
|
|
99
|
+
RUBY_SO_NAME = ruby
|
|
100
|
+
RUBYW_INSTALL_NAME =
|
|
101
|
+
RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
|
|
102
|
+
RUBYW_BASE_NAME = rubyw
|
|
103
|
+
RUBY_BASE_NAME = ruby
|
|
104
|
+
|
|
105
|
+
arch = x86_64-linux
|
|
106
|
+
sitearch = $(arch)
|
|
107
|
+
ruby_version = 2.4.0
|
|
108
|
+
ruby = $(bindir)/$(RUBY_BASE_NAME)
|
|
109
|
+
RUBY = $(ruby)
|
|
110
|
+
ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
|
|
111
|
+
|
|
112
|
+
RM = rm -f
|
|
113
|
+
RM_RF = $(RUBY) -run -e rm -- -rf
|
|
114
|
+
RMDIRS = rmdir --ignore-fail-on-non-empty -p
|
|
115
|
+
MAKEDIRS = /bin/mkdir -p
|
|
116
|
+
INSTALL = /usr/bin/install -c
|
|
117
|
+
INSTALL_PROG = $(INSTALL) -m 0755
|
|
118
|
+
INSTALL_DATA = $(INSTALL) -m 644
|
|
119
|
+
COPY = cp
|
|
120
|
+
TOUCH = exit >
|
|
121
|
+
|
|
122
|
+
#### End of system configuration section. ####
|
|
123
|
+
|
|
124
|
+
preload =
|
|
125
|
+
libpath = . $(libdir) /source/ext/xcellus
|
|
126
|
+
LIBPATH = -L. -L$(libdir) -Wl,-rpath,$(libdir) -L/source/ext/xcellus -Wl,-rpath,/source/ext/xcellus
|
|
127
|
+
DEFFILE =
|
|
128
|
+
|
|
129
|
+
CLEANFILES = mkmf.log
|
|
130
|
+
DISTCLEANFILES =
|
|
131
|
+
DISTCLEANDIRS =
|
|
132
|
+
|
|
133
|
+
extout =
|
|
134
|
+
extout_prefix =
|
|
135
|
+
target_prefix =
|
|
136
|
+
LOCAL_LIBS =
|
|
137
|
+
LIBS = $(LIBRUBYARG_SHARED) -lxcbindings -lpthread -ldl -lcrypt -lm -lc
|
|
138
|
+
ORIG_SRCS = xcellus.c
|
|
139
|
+
SRCS = $(ORIG_SRCS)
|
|
140
|
+
OBJS = xcellus.o
|
|
141
|
+
HDRS = $(srcdir)/extconf.h $(srcdir)/libxcbindings.h
|
|
142
|
+
LOCAL_HDRS =
|
|
143
|
+
TARGET = xcellus
|
|
144
|
+
TARGET_NAME = xcellus
|
|
145
|
+
TARGET_ENTRY = Init_$(TARGET_NAME)
|
|
146
|
+
DLLIB = $(TARGET).so
|
|
147
|
+
EXTSTATIC =
|
|
148
|
+
STATIC_LIB =
|
|
149
|
+
|
|
150
|
+
TIMESTAMP_DIR = .
|
|
151
|
+
BINDIR = $(bindir)
|
|
152
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
|
153
|
+
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
|
154
|
+
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
|
155
|
+
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
|
|
156
|
+
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
|
|
157
|
+
TARGET_SO_DIR =
|
|
158
|
+
TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
|
|
159
|
+
CLEANLIBS = $(TARGET_SO)
|
|
160
|
+
CLEANOBJS = *.o *.bak
|
|
161
|
+
|
|
162
|
+
all: $(DLLIB)
|
|
163
|
+
static: $(STATIC_LIB)
|
|
164
|
+
.PHONY: all install static install-so install-rb
|
|
165
|
+
.PHONY: clean clean-so clean-static clean-rb
|
|
166
|
+
|
|
167
|
+
clean-static::
|
|
168
|
+
clean-rb-default::
|
|
169
|
+
clean-rb::
|
|
170
|
+
clean-so::
|
|
171
|
+
clean: clean-so clean-static clean-rb-default clean-rb
|
|
172
|
+
-$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
|
|
173
|
+
|
|
174
|
+
distclean-rb-default::
|
|
175
|
+
distclean-rb::
|
|
176
|
+
distclean-so::
|
|
177
|
+
distclean-static::
|
|
178
|
+
distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
|
|
179
|
+
-$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
|
180
|
+
-$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
|
181
|
+
-$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
|
|
182
|
+
|
|
183
|
+
realclean: distclean
|
|
184
|
+
install: install-so install-rb
|
|
185
|
+
|
|
186
|
+
install-so: $(DLLIB) $(TIMESTAMP_DIR)/.sitearchdir.time
|
|
187
|
+
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
|
188
|
+
clean-static::
|
|
189
|
+
-$(Q)$(RM) $(STATIC_LIB)
|
|
190
|
+
install-rb: pre-install-rb do-install-rb install-rb-default
|
|
191
|
+
install-rb-default: pre-install-rb-default do-install-rb-default
|
|
192
|
+
pre-install-rb: Makefile
|
|
193
|
+
pre-install-rb-default: Makefile
|
|
194
|
+
do-install-rb:
|
|
195
|
+
do-install-rb-default:
|
|
196
|
+
pre-install-rb-default:
|
|
197
|
+
@$(NULLCMD)
|
|
198
|
+
$(TIMESTAMP_DIR)/.sitearchdir.time:
|
|
199
|
+
$(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
|
|
200
|
+
$(Q) $(TOUCH) $@
|
|
201
|
+
|
|
202
|
+
site-install: site-install-so site-install-rb
|
|
203
|
+
site-install-so: install-so
|
|
204
|
+
site-install-rb: install-rb
|
|
205
|
+
|
|
206
|
+
.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
|
|
207
|
+
|
|
208
|
+
.cc.o:
|
|
209
|
+
$(ECHO) compiling $(<)
|
|
210
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
|
|
211
|
+
|
|
212
|
+
.cc.S:
|
|
213
|
+
$(ECHO) translating $(<)
|
|
214
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
|
|
215
|
+
|
|
216
|
+
.mm.o:
|
|
217
|
+
$(ECHO) compiling $(<)
|
|
218
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
|
|
219
|
+
|
|
220
|
+
.mm.S:
|
|
221
|
+
$(ECHO) translating $(<)
|
|
222
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
|
|
223
|
+
|
|
224
|
+
.cxx.o:
|
|
225
|
+
$(ECHO) compiling $(<)
|
|
226
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
|
|
227
|
+
|
|
228
|
+
.cxx.S:
|
|
229
|
+
$(ECHO) translating $(<)
|
|
230
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
|
|
231
|
+
|
|
232
|
+
.cpp.o:
|
|
233
|
+
$(ECHO) compiling $(<)
|
|
234
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
|
|
235
|
+
|
|
236
|
+
.cpp.S:
|
|
237
|
+
$(ECHO) translating $(<)
|
|
238
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
|
|
239
|
+
|
|
240
|
+
.c.o:
|
|
241
|
+
$(ECHO) compiling $(<)
|
|
242
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
|
|
243
|
+
|
|
244
|
+
.c.S:
|
|
245
|
+
$(ECHO) translating $(<)
|
|
246
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
|
|
247
|
+
|
|
248
|
+
.m.o:
|
|
249
|
+
$(ECHO) compiling $(<)
|
|
250
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
|
|
251
|
+
|
|
252
|
+
.m.S:
|
|
253
|
+
$(ECHO) translating $(<)
|
|
254
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
|
|
255
|
+
|
|
256
|
+
$(TARGET_SO): $(OBJS) Makefile
|
|
257
|
+
$(ECHO) linking shared-object $(DLLIB)
|
|
258
|
+
-$(Q)$(RM) $(@)
|
|
259
|
+
$(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
$(OBJS): $(HDRS) $(ruby_headers)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'mkmf'
|
|
2
|
+
|
|
3
|
+
def darwin?
|
|
4
|
+
RbConfig::CONFIG['target_os'] =~ /darwin/
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
unless have_header 'libxcbindings.h'
|
|
8
|
+
abort 'missing libxcbindings. Did you build the go project?'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
$LDFLAGS << " -L#{Dir.pwd} "
|
|
12
|
+
dir_config('xcbindings', Dir.pwd, Dir.pwd)
|
|
13
|
+
|
|
14
|
+
# if darwin?
|
|
15
|
+
|
|
16
|
+
# else
|
|
17
|
+
# $LDFLAGS = '-Wl,-rpath \'-Wl,$$ORIGIN\''
|
|
18
|
+
# end
|
|
19
|
+
|
|
20
|
+
have_library 'xcbindings'
|
|
21
|
+
|
|
22
|
+
create_header
|
|
23
|
+
create_makefile 'xcellus'
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/* Created by "go tool cgo" - DO NOT EDIT. */
|
|
2
|
+
|
|
3
|
+
/* package command-line-arguments */
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
#line 1 "cgo-builtin-prolog"
|
|
7
|
+
|
|
8
|
+
#include <stddef.h> /* for ptrdiff_t below */
|
|
9
|
+
|
|
10
|
+
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
|
11
|
+
#define GO_CGO_EXPORT_PROLOGUE_H
|
|
12
|
+
|
|
13
|
+
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
|
|
14
|
+
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
/* Start of preamble from import "C" comments. */
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
#line 3 "/go/src/app/xcellus.go"
|
|
21
|
+
|
|
22
|
+
#include <stdlib.h>
|
|
23
|
+
|
|
24
|
+
#line 1 "cgo-generated-wrapper"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/* End of preamble from import "C" comments. */
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
/* Start of boilerplate cgo prologue. */
|
|
31
|
+
#line 1 "cgo-gcc-export-header-prolog"
|
|
32
|
+
|
|
33
|
+
#ifndef GO_CGO_PROLOGUE_H
|
|
34
|
+
#define GO_CGO_PROLOGUE_H
|
|
35
|
+
|
|
36
|
+
typedef signed char GoInt8;
|
|
37
|
+
typedef unsigned char GoUint8;
|
|
38
|
+
typedef short GoInt16;
|
|
39
|
+
typedef unsigned short GoUint16;
|
|
40
|
+
typedef int GoInt32;
|
|
41
|
+
typedef unsigned int GoUint32;
|
|
42
|
+
typedef long long GoInt64;
|
|
43
|
+
typedef unsigned long long GoUint64;
|
|
44
|
+
typedef GoInt64 GoInt;
|
|
45
|
+
typedef GoUint64 GoUint;
|
|
46
|
+
typedef __SIZE_TYPE__ GoUintptr;
|
|
47
|
+
typedef float GoFloat32;
|
|
48
|
+
typedef double GoFloat64;
|
|
49
|
+
typedef float _Complex GoComplex64;
|
|
50
|
+
typedef double _Complex GoComplex128;
|
|
51
|
+
|
|
52
|
+
/*
|
|
53
|
+
static assertion to make sure the file is being used on architecture
|
|
54
|
+
at least with matching size of GoInt.
|
|
55
|
+
*/
|
|
56
|
+
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
|
57
|
+
|
|
58
|
+
typedef _GoString_ GoString;
|
|
59
|
+
typedef void *GoMap;
|
|
60
|
+
typedef void *GoChan;
|
|
61
|
+
typedef struct { void *t; void *v; } GoInterface;
|
|
62
|
+
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
|
63
|
+
|
|
64
|
+
#endif
|
|
65
|
+
|
|
66
|
+
/* End of boilerplate cgo prologue. */
|
|
67
|
+
|
|
68
|
+
#ifdef __cplusplus
|
|
69
|
+
extern "C" {
|
|
70
|
+
#endif
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
/* Return type for go_xcellus_process */
|
|
74
|
+
struct go_xcellus_process_return {
|
|
75
|
+
GoUint8 r0; /* failed */
|
|
76
|
+
char* r1; /* err */
|
|
77
|
+
GoInt r2; /* len */
|
|
78
|
+
char* r3; /* buf */
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
extern struct go_xcellus_process_return go_xcellus_process(char* p0);
|
|
82
|
+
|
|
83
|
+
#ifdef __cplusplus
|
|
84
|
+
}
|
|
85
|
+
#endif
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#include <stdbool.h>
|
|
2
|
+
#include <ruby.h>
|
|
3
|
+
#include "extconf.h"
|
|
4
|
+
#include "libxcbindings.h"
|
|
5
|
+
|
|
6
|
+
VALUE rb_process(VALUE self, VALUE str) {
|
|
7
|
+
if (RB_TYPE_P(str, T_STRING) == 0) return Qnil;
|
|
8
|
+
struct go_xcellus_process_return result = go_xcellus_process(RSTRING_PTR(str));
|
|
9
|
+
bool failed = result.r0 == 1;
|
|
10
|
+
char *error_description = result.r1;
|
|
11
|
+
GoInt buffer_len = result.r2;
|
|
12
|
+
char *buffer = result.r3;
|
|
13
|
+
if(failed) {
|
|
14
|
+
VALUE errObj = rb_exc_new2(rb_eStandardError, error_description);
|
|
15
|
+
free(error_description);
|
|
16
|
+
rb_exc_raise(errObj);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
VALUE retval = rb_str_new(buffer, buffer_len);
|
|
20
|
+
free(buffer);
|
|
21
|
+
return retval;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
void Init_xcellus() {
|
|
25
|
+
VALUE module = rb_define_module("Xcellus");
|
|
26
|
+
rb_define_singleton_method(module, "process", rb_process, 1);
|
|
27
|
+
}
|
data/golang/xcellus.go
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
*/
|
|
6
|
+
import "C"
|
|
7
|
+
|
|
8
|
+
import (
|
|
9
|
+
"bufio"
|
|
10
|
+
"bytes"
|
|
11
|
+
"encoding/json"
|
|
12
|
+
"fmt"
|
|
13
|
+
|
|
14
|
+
"github.com/tealeg/xlsx"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
func main() {}
|
|
18
|
+
|
|
19
|
+
type worksheet struct {
|
|
20
|
+
Title string `json:"title"`
|
|
21
|
+
Headers []string `json:"headers"`
|
|
22
|
+
Rows [][]interface{} `json:"rows"`
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//export go_xcellus_process
|
|
26
|
+
func go_xcellus_process(data *C.char) (failed bool, err *C.char, len int, buf *C.char) {
|
|
27
|
+
synthesizedData := C.GoString(data)
|
|
28
|
+
var wb []*worksheet
|
|
29
|
+
goErr := json.Unmarshal([]byte(synthesizedData), &wb)
|
|
30
|
+
|
|
31
|
+
if goErr != nil {
|
|
32
|
+
return true, C.CString(fmt.Sprintf("%s\x00", goErr)), 0, nil
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
file := xlsx.NewFile()
|
|
36
|
+
var sheetPtr *xlsx.Sheet
|
|
37
|
+
var rowPtr *xlsx.Row
|
|
38
|
+
var cellPtr *xlsx.Cell
|
|
39
|
+
|
|
40
|
+
for _, sheet := range wb {
|
|
41
|
+
sheetPtr, goErr = file.AddSheet(sheet.Title)
|
|
42
|
+
if goErr != nil {
|
|
43
|
+
return true, C.CString(fmt.Sprintf("%s\x00", goErr)), 0, nil
|
|
44
|
+
}
|
|
45
|
+
rowPtr = sheetPtr.AddRow()
|
|
46
|
+
for _, v := range sheet.Headers {
|
|
47
|
+
cellPtr = rowPtr.AddCell()
|
|
48
|
+
cellPtr.SetValue(v)
|
|
49
|
+
}
|
|
50
|
+
for _, r := range sheet.Rows {
|
|
51
|
+
rowPtr = sheetPtr.AddRow()
|
|
52
|
+
for _, c := range r {
|
|
53
|
+
cellPtr = rowPtr.AddCell()
|
|
54
|
+
cellPtr.SetValue(c)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
tmpBuffer := &bytes.Buffer{}
|
|
60
|
+
writer := bufio.NewWriter(tmpBuffer)
|
|
61
|
+
goErr = file.Write(writer)
|
|
62
|
+
|
|
63
|
+
if goErr != nil {
|
|
64
|
+
return true, C.CString(fmt.Sprintf("%s\x00", goErr)), 0, nil
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
len = tmpBuffer.Len()
|
|
68
|
+
p := C.malloc(C.size_t(len))
|
|
69
|
+
|
|
70
|
+
// copy the data into the buffer, by converting it to a Go array
|
|
71
|
+
cBuf := (*[1 << 30]byte)(p)
|
|
72
|
+
copy(cBuf[:], tmpBuffer.Bytes())
|
|
73
|
+
|
|
74
|
+
failed = false
|
|
75
|
+
err = nil
|
|
76
|
+
buf = (*C.char)(p) // Ownership of P will be changed to Ruby's after
|
|
77
|
+
// being received from the counterpart C code.
|
|
78
|
+
// DO NOT free IT.
|
|
79
|
+
return
|
|
80
|
+
}
|
data/lib/xcellus.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require_relative '../ext/xcellus/xcellus.so'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
require_relative '../ext/xcellus/xcellus.bundle'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'json'
|
|
8
|
+
|
|
9
|
+
module Xcellus
|
|
10
|
+
VERSION = '0.1'.freeze
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
def transform(input)
|
|
14
|
+
unless input.kind_of? Array
|
|
15
|
+
raise ArgumentError, 'Xcellus.transform only accepts Arrays'
|
|
16
|
+
end
|
|
17
|
+
StringIO.new(Xcellus::process(input.to_json))
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/script/build-golang
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
|
4
|
+
mkdir -p /go/src/app
|
|
5
|
+
cd /go/src/app && \
|
|
6
|
+
cp /source/Gopkg* /go/src/app && \
|
|
7
|
+
cp /source/golang/* /go/src/app && \
|
|
8
|
+
dep ensure && \
|
|
9
|
+
go build -o /source/ext/xcellus/libxcbindings.so -buildmode=c-shared /go/src/app/xcellus.go
|
data/script/build-ruby
ADDED
data/xcellus.gemspec
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require 'xcellus'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = 'xcellus'
|
|
9
|
+
spec.version = Xcellus::VERSION
|
|
10
|
+
spec.authors = ['Victor Gama']
|
|
11
|
+
spec.email = ['hey@vito.io']
|
|
12
|
+
|
|
13
|
+
spec.summary = %q{Xcellus is an ugly XLSX generator}
|
|
14
|
+
spec.description = <<-description
|
|
15
|
+
Xcellus leverages a native extension to create XLSX files. It is an 'ugly'
|
|
16
|
+
generator because it lacks all styling mechanisms to make your XLSX pretty.
|
|
17
|
+
description
|
|
18
|
+
spec.homepage = 'https://github.com/victorgama/xcellus'
|
|
19
|
+
spec.license = 'MIT'
|
|
20
|
+
|
|
21
|
+
spec.files = (`git ls-files -z`.split("\x0").reject do |f|
|
|
22
|
+
f.match(%r{^(test|spec|features|coverage)/})
|
|
23
|
+
end + ['ext/xcellus/xcellus.so'])
|
|
24
|
+
spec.bindir = 'ext/xcellus'
|
|
25
|
+
spec.executables = spec.files.grep(%r{^ext/xcellus/}) { |f| File.basename(f) }
|
|
26
|
+
spec.require_paths = ['lib']
|
|
27
|
+
|
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
31
|
+
spec.add_development_dependency 'simplecov', '~> 0.16.1'
|
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 0.55.0'
|
|
33
|
+
spec.add_development_dependency 'codecov'
|
|
34
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: xcellus
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '0.1'
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Victor Gama
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: ext/xcellus
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-07-04 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: simplecov
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 0.16.1
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 0.16.1
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rubocop
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 0.55.0
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 0.55.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: codecov
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description: |2
|
|
98
|
+
Xcellus leverages a native extension to create XLSX files. It is an 'ugly'
|
|
99
|
+
generator because it lacks all styling mechanisms to make your XLSX pretty.
|
|
100
|
+
email:
|
|
101
|
+
- hey@vito.io
|
|
102
|
+
executables:
|
|
103
|
+
- Makefile
|
|
104
|
+
- extconf.h
|
|
105
|
+
- extconf.rb
|
|
106
|
+
- libxcbindings.h
|
|
107
|
+
- xcellus.c
|
|
108
|
+
- xcellus.so
|
|
109
|
+
extensions: []
|
|
110
|
+
extra_rdoc_files: []
|
|
111
|
+
files:
|
|
112
|
+
- ".editorconfig"
|
|
113
|
+
- ".gitignore"
|
|
114
|
+
- ".rspec"
|
|
115
|
+
- CODE_OF_CONDUCT.md
|
|
116
|
+
- Dockerfile
|
|
117
|
+
- Gemfile
|
|
118
|
+
- Gemfile.lock
|
|
119
|
+
- Gopkg.lock
|
|
120
|
+
- Gopkg.toml
|
|
121
|
+
- LICENSE
|
|
122
|
+
- Makefile
|
|
123
|
+
- README.md
|
|
124
|
+
- Rakefile
|
|
125
|
+
- bin/console
|
|
126
|
+
- ext/xcellus/Makefile
|
|
127
|
+
- ext/xcellus/extconf.h
|
|
128
|
+
- ext/xcellus/extconf.rb
|
|
129
|
+
- ext/xcellus/libxcbindings.h
|
|
130
|
+
- ext/xcellus/xcellus.c
|
|
131
|
+
- ext/xcellus/xcellus.so
|
|
132
|
+
- golang/xcellus.go
|
|
133
|
+
- lib/xcellus.rb
|
|
134
|
+
- script/build-golang
|
|
135
|
+
- script/build-ruby
|
|
136
|
+
- xcellus.gemspec
|
|
137
|
+
homepage: https://github.com/victorgama/xcellus
|
|
138
|
+
licenses:
|
|
139
|
+
- MIT
|
|
140
|
+
metadata: {}
|
|
141
|
+
post_install_message:
|
|
142
|
+
rdoc_options: []
|
|
143
|
+
require_paths:
|
|
144
|
+
- lib
|
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
|
+
requirements:
|
|
147
|
+
- - ">="
|
|
148
|
+
- !ruby/object:Gem::Version
|
|
149
|
+
version: '0'
|
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
|
+
requirements:
|
|
152
|
+
- - ">="
|
|
153
|
+
- !ruby/object:Gem::Version
|
|
154
|
+
version: '0'
|
|
155
|
+
requirements: []
|
|
156
|
+
rubyforge_project:
|
|
157
|
+
rubygems_version: 2.7.6
|
|
158
|
+
signing_key:
|
|
159
|
+
specification_version: 4
|
|
160
|
+
summary: Xcellus is an ugly XLSX generator
|
|
161
|
+
test_files: []
|