cobhan 0.1.0 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +26 -8
- data/CHANGELOG.md +17 -0
- data/Gemfile +2 -6
- data/README.md +15 -0
- data/Rakefile +7 -3
- data/Vagrantfile +19 -11
- data/cobhan.gemspec +21 -17
- data/lib/cobhan/version.rb +1 -1
- data/lib/cobhan.rb +13 -2
- metadata +40 -9
- data/Gemfile.lock +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 236a2f8255bfff1d864296be21eeb788aa7e2eda4b6ec351c2acc5c1fdfea8b3
|
4
|
+
data.tar.gz: c7a666719c503f2ab16b72cd5c1e26973aba29a410445de80376703213c1b397
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18447be1bb9676bfd0d66ad6c84d91c229181a75775c16b174e52241659ccc43a9083001bf3e0ed2db1bb3d6542c489d1201582a5ae01903084bb1ee189e9079
|
7
|
+
data.tar.gz: ec03eb376934045aec087c9b72ce9a831aee5c74f75fbf185c6a89c51569e798e238686e9737489eeafa9720dfc5ba8885c69570ed93082cc003a1233bd61247
|
data/.rubocop.yml
CHANGED
@@ -1,13 +1,31 @@
|
|
1
1
|
AllCops:
|
2
2
|
TargetRubyVersion: 2.5
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
Style/StringLiteralsInInterpolation:
|
9
|
-
Enabled: true
|
10
|
-
EnforcedStyle: double_quotes
|
3
|
+
NewCops: enable
|
4
|
+
SuggestExtensions: false
|
5
|
+
Exclude:
|
6
|
+
- 'Vagrantfile'
|
7
|
+
- 'vendor/**/*' # Github Actions
|
11
8
|
|
12
9
|
Layout/LineLength:
|
13
10
|
Max: 120
|
11
|
+
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Metrics/MethodLength:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/WordArray:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/SymbolArray:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/MultilineBlockChain:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Style/BlockDelimiters:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Style/HashAsLastArrayItem:
|
31
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.3] - 2022-03-14
|
4
|
+
|
5
|
+
- Switch from `centos/7` to `ubuntu/focal64` vagrant box
|
6
|
+
- Add ARM64 build and test script for vagrant
|
7
|
+
- Add ARM64 build for Github Actions
|
8
|
+
- Add coverage report
|
9
|
+
|
10
|
+
## [0.1.2] - 2022-03-07
|
11
|
+
|
12
|
+
- Configure RuboCop
|
13
|
+
- Add `int_to_buffer` and `buffer_to_int`
|
14
|
+
|
15
|
+
## [0.1.1] - 2022-03-01
|
16
|
+
|
17
|
+
- Fix gemspec description
|
18
|
+
- Add Github Actions
|
19
|
+
|
3
20
|
## [0.1.0] - 2022-03-01
|
4
21
|
|
5
22
|
- Initial release
|
data/Gemfile
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in cobhan.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem
|
9
|
-
|
10
|
-
gem "rspec", "~> 3.0"
|
11
|
-
|
12
|
-
gem "rubocop", "~> 1.21"
|
8
|
+
gem 'rake', '~> 13.0'
|
data/README.md
CHANGED
@@ -72,12 +72,27 @@ vagrant ssh
|
|
72
72
|
cd /vagrant/
|
73
73
|
bundle install
|
74
74
|
bundle exec rspec spec
|
75
|
+
|
76
|
+
# Or to run specs on arm64 inside vagrant:
|
77
|
+
cd /vagrant/
|
78
|
+
spec/support/libcobhandemo/arm64_build_and_test.sh
|
75
79
|
```
|
76
80
|
|
77
81
|
## Contributing
|
78
82
|
|
79
83
|
Bug reports and pull requests are welcome on GitHub at https://github.com/godaddy/cobhan-ruby.
|
80
84
|
|
85
|
+
## Releasing new gem version
|
86
|
+
|
87
|
+
```
|
88
|
+
# Create and push a version tag
|
89
|
+
git tag -a v$(rake version) -m "Version $(rake version)"
|
90
|
+
git push origin v$(rake version)
|
91
|
+
|
92
|
+
# Create a release in Github to trigger .github/workflows/publish.yml workflow
|
93
|
+
echo "Version $(rake version)"
|
94
|
+
```
|
95
|
+
|
81
96
|
## License
|
82
97
|
|
83
98
|
The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
|
data/Rakefile
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
require
|
8
|
+
require 'rubocop/rake_task'
|
9
9
|
|
10
10
|
RuboCop::RakeTask.new
|
11
11
|
|
12
12
|
task default: %i[spec rubocop]
|
13
|
+
|
14
|
+
task :version do
|
15
|
+
puts Cobhan::VERSION
|
16
|
+
end
|
data/Vagrantfile
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
# -*- mode: ruby -*-
|
2
2
|
# vi: set ft=ruby :
|
3
3
|
|
4
|
-
|
4
|
+
SCRIPT = <<~SCRIPT
|
5
5
|
set -e
|
6
6
|
|
7
|
+
# Update system
|
8
|
+
sudo apt-get update
|
9
|
+
|
7
10
|
echo "Install RVM"
|
8
|
-
|
9
|
-
|
11
|
+
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
|
12
|
+
curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
|
10
13
|
curl -sSL https://get.rvm.io | bash -s stable
|
11
14
|
source /home/vagrant/.rvm/scripts/rvm
|
12
15
|
|
@@ -15,17 +18,22 @@ echo "Install Ruby $RUBY_VERSION"
|
|
15
18
|
rvm install $RUBY_VERSION
|
16
19
|
|
17
20
|
echo "Install git"
|
18
|
-
sudo
|
21
|
+
sudo apt-get install git -y
|
19
22
|
|
20
23
|
echo "Install docker"
|
21
|
-
sudo
|
22
|
-
|
23
|
-
|
24
|
-
sudo
|
24
|
+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
25
|
+
echo \
|
26
|
+
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
|
27
|
+
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
28
|
+
sudo apt-get update
|
29
|
+
sudo apt-get install docker-ce -y
|
30
|
+
|
31
|
+
sudo gpasswd -a $USER docker
|
25
32
|
sudo systemctl restart docker.service
|
33
|
+
sudo systemctl enable docker.service
|
26
34
|
SCRIPT
|
27
35
|
|
28
|
-
Vagrant.configure(
|
29
|
-
config.vm.box =
|
30
|
-
config.vm.provision
|
36
|
+
Vagrant.configure('2') do |config|
|
37
|
+
config.vm.box = 'ubuntu/focal64'
|
38
|
+
config.vm.provision 'shell', inline: SCRIPT, privileged: false
|
31
39
|
end
|
data/cobhan.gemspec
CHANGED
@@ -1,26 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'lib/cobhan/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = 'cobhan'
|
7
7
|
spec.version = Cobhan::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
8
|
+
spec.authors = ['GoDaddy']
|
9
|
+
spec.email = ['oss@godaddy.com']
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
11
|
+
spec.summary = 'Ruby wrapper library for the Cobhan FFI system'
|
12
|
+
spec.description = <<~DESCRIPTION
|
13
|
+
Cobhan FFI is a proof of concept system for enabling shared code to be written
|
14
|
+
in Rust or Go and consumed from all major languages/platforms in a safe and effective way,
|
15
|
+
using easy helper functions to manage any unsafe data marshaling.
|
16
|
+
DESCRIPTION
|
13
17
|
|
14
|
-
spec.
|
15
|
-
spec.
|
18
|
+
spec.homepage = 'https://github.com/godaddy/cobhan-ruby'
|
19
|
+
spec.license = 'MIT'
|
20
|
+
spec.required_ruby_version = '>= 2.5.0'
|
16
21
|
|
17
|
-
spec.
|
18
|
-
spec.
|
19
|
-
spec.
|
20
|
-
|
21
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
-
spec.metadata["source_code_uri"] = "https://github.com/godaddy/cobhan-ruby"
|
23
|
-
spec.metadata["changelog_uri"] = "https://github.com/godaddy/cobhan-ruby/blob/main/CHANGELOG.md"
|
22
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
23
|
+
spec.metadata['source_code_uri'] = 'https://github.com/godaddy/cobhan-ruby'
|
24
|
+
spec.metadata['changelog_uri'] = 'https://github.com/godaddy/cobhan-ruby/blob/main/CHANGELOG.md'
|
25
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
24
26
|
|
25
27
|
# Specify which files should be added to the gem when it is released.
|
26
28
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -29,12 +31,14 @@ Gem::Specification.new do |spec|
|
|
29
31
|
(f == __FILE__) || f.match(%r{\A(?:(?:bin|demo|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
30
32
|
end
|
31
33
|
end
|
32
|
-
spec.bindir =
|
34
|
+
spec.bindir = 'exe'
|
33
35
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
34
|
-
spec.require_paths = [
|
36
|
+
spec.require_paths = ['lib']
|
35
37
|
|
36
38
|
spec.add_dependency 'ffi', '~> 1.15.4'
|
37
39
|
|
38
40
|
spec.add_development_dependency 'rspec', '~> 3.10.0'
|
39
41
|
spec.add_development_dependency 'rubocop', '~> 1.7'
|
42
|
+
spec.add_development_dependency 'simplecov', '~> 0.21.2'
|
43
|
+
spec.add_development_dependency 'simplecov-console', '~> 0.9.1'
|
40
44
|
end
|
data/lib/cobhan/version.rb
CHANGED
data/lib/cobhan.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'cobhan/version'
|
4
4
|
|
5
5
|
require 'ffi'
|
6
6
|
|
7
|
+
# Cobhan module includes helper functions to manage unsafe data marshaling.
|
7
8
|
module Cobhan
|
8
9
|
UnsupportedPlatformError = Class.new(StandardError)
|
9
10
|
|
@@ -58,7 +59,7 @@ module Cobhan
|
|
58
59
|
length = 0 - length
|
59
60
|
filename = buffer.get_bytes(BUFFER_HEADER_SIZE, length)
|
60
61
|
# Read file with name in payload, and replace payload
|
61
|
-
bytes =
|
62
|
+
bytes = File.binread(filename)
|
62
63
|
File.delete(filename)
|
63
64
|
bytes
|
64
65
|
end
|
@@ -70,4 +71,14 @@ module Cobhan
|
|
70
71
|
buffer_ptr.put_int32(SIZEOF_INT32, 0) # Reserved - must be zero
|
71
72
|
buffer_ptr
|
72
73
|
end
|
74
|
+
|
75
|
+
def int_to_buffer(number)
|
76
|
+
buffer_ptr = FFI::MemoryPointer.new(1, SIZEOF_INT32 * 2, false)
|
77
|
+
buffer_ptr.put_int64(0, number)
|
78
|
+
buffer_ptr
|
79
|
+
end
|
80
|
+
|
81
|
+
def buffer_to_int(buffer_ptr)
|
82
|
+
buffer_ptr.get_int64(0)
|
83
|
+
end
|
73
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cobhan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoDaddy
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -52,7 +52,38 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.7'
|
55
|
-
|
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.21.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.21.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov-console
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.9.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.9.1
|
83
|
+
description: |
|
84
|
+
Cobhan FFI is a proof of concept system for enabling shared code to be written
|
85
|
+
in Rust or Go and consumed from all major languages/platforms in a safe and effective way,
|
86
|
+
using easy helper functions to manage any unsafe data marshaling.
|
56
87
|
email:
|
57
88
|
- oss@godaddy.com
|
58
89
|
executables: []
|
@@ -66,7 +97,6 @@ files:
|
|
66
97
|
- CODE_OF_CONDUCT.md
|
67
98
|
- CONTRIBUTING.md
|
68
99
|
- Gemfile
|
69
|
-
- Gemfile.lock
|
70
100
|
- LICENSE.txt
|
71
101
|
- README.md
|
72
102
|
- Rakefile
|
@@ -82,7 +112,8 @@ metadata:
|
|
82
112
|
homepage_uri: https://github.com/godaddy/cobhan-ruby
|
83
113
|
source_code_uri: https://github.com/godaddy/cobhan-ruby
|
84
114
|
changelog_uri: https://github.com/godaddy/cobhan-ruby/blob/main/CHANGELOG.md
|
85
|
-
|
115
|
+
rubygems_mfa_required: 'true'
|
116
|
+
post_install_message:
|
86
117
|
rdoc_options: []
|
87
118
|
require_paths:
|
88
119
|
- lib
|
@@ -97,8 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
128
|
- !ruby/object:Gem::Version
|
98
129
|
version: '0'
|
99
130
|
requirements: []
|
100
|
-
rubygems_version: 3.3.
|
101
|
-
signing_key:
|
131
|
+
rubygems_version: 3.3.7
|
132
|
+
signing_key:
|
102
133
|
specification_version: 4
|
103
|
-
summary:
|
134
|
+
summary: Ruby wrapper library for the Cobhan FFI system
|
104
135
|
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
cobhan (0.1.0)
|
5
|
-
ffi (~> 1.15.4)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
ast (2.4.2)
|
11
|
-
diff-lcs (1.5.0)
|
12
|
-
ffi (1.15.5)
|
13
|
-
parallel (1.21.0)
|
14
|
-
parser (3.1.1.0)
|
15
|
-
ast (~> 2.4.1)
|
16
|
-
rainbow (3.1.1)
|
17
|
-
rake (13.0.6)
|
18
|
-
regexp_parser (2.2.1)
|
19
|
-
rexml (3.2.5)
|
20
|
-
rspec (3.11.0)
|
21
|
-
rspec-core (~> 3.11.0)
|
22
|
-
rspec-expectations (~> 3.11.0)
|
23
|
-
rspec-mocks (~> 3.11.0)
|
24
|
-
rspec-core (3.11.0)
|
25
|
-
rspec-support (~> 3.11.0)
|
26
|
-
rspec-expectations (3.11.0)
|
27
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
-
rspec-support (~> 3.11.0)
|
29
|
-
rspec-mocks (3.11.0)
|
30
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
-
rspec-support (~> 3.11.0)
|
32
|
-
rspec-support (3.11.0)
|
33
|
-
rubocop (1.25.1)
|
34
|
-
parallel (~> 1.10)
|
35
|
-
parser (>= 3.1.0.0)
|
36
|
-
rainbow (>= 2.2.2, < 4.0)
|
37
|
-
regexp_parser (>= 1.8, < 3.0)
|
38
|
-
rexml
|
39
|
-
rubocop-ast (>= 1.15.1, < 2.0)
|
40
|
-
ruby-progressbar (~> 1.7)
|
41
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
42
|
-
rubocop-ast (1.16.0)
|
43
|
-
parser (>= 3.1.1.0)
|
44
|
-
ruby-progressbar (1.11.0)
|
45
|
-
unicode-display_width (2.1.0)
|
46
|
-
|
47
|
-
PLATFORMS
|
48
|
-
x86_64-darwin-20
|
49
|
-
|
50
|
-
DEPENDENCIES
|
51
|
-
cobhan!
|
52
|
-
rake (~> 13.0)
|
53
|
-
rspec (~> 3.0)
|
54
|
-
rubocop (~> 1.21)
|
55
|
-
|
56
|
-
BUNDLED WITH
|
57
|
-
2.3.3
|