cobhan 0.1.0 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 309e7e9e4dc297cca788ad4a722c4b5e686e21f071f1faff64d9256ca5eec267
4
- data.tar.gz: 3a2f819a9bb2d1d67ea99e3739cadfeb80a27354a2deebd007e57b366d21ebc4
3
+ metadata.gz: 236a2f8255bfff1d864296be21eeb788aa7e2eda4b6ec351c2acc5c1fdfea8b3
4
+ data.tar.gz: c7a666719c503f2ab16b72cd5c1e26973aba29a410445de80376703213c1b397
5
5
  SHA512:
6
- metadata.gz: 91c3c544862b16a4b4a41312bcd3ce5208f75f9fc738e3940bada7c7fac08f899e5cb3fbadd4731ab512e34adcb5a0b0cfd11e9560ef51aa82200a48660d04ef
7
- data.tar.gz: 9498b1799ec6834e1659f2183b1d05b9a5e0bbdaa53856facd7200228e3e285b27639124d8edc29e5aeb66f967d2e20a2b8e0aa35e4803d48aaa68b0ecb93d79
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
- Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
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 "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in cobhan.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
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 "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- require "rubocop/rake_task"
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
- $script = <<-SCRIPT
4
+ SCRIPT = <<~SCRIPT
5
5
  set -e
6
6
 
7
+ # Update system
8
+ sudo apt-get update
9
+
7
10
  echo "Install RVM"
8
- gpg --keyserver hkp://pgp.mit.edu --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
9
- # If key add does not work, see https://rvm.io/rvm/security for alternatives.
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 yum install git -y
21
+ sudo apt-get install git -y
19
22
 
20
23
  echo "Install docker"
21
- sudo yum install -y yum-utils
22
- sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
23
- sudo yum install docker-ce -y
24
- sudo usermod -aG docker $USER
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("2") do |config|
29
- config.vm.box = "centos/7"
30
- config.vm.provision "shell", inline: $script, privileged: false
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 "lib/cobhan/version"
3
+ require_relative 'lib/cobhan/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "cobhan"
6
+ spec.name = 'cobhan'
7
7
  spec.version = Cobhan::VERSION
8
- spec.authors = ["GoDaddy"]
9
- spec.email = ["oss@godaddy.com"]
8
+ spec.authors = ['GoDaddy']
9
+ spec.email = ['oss@godaddy.com']
10
10
 
11
- spec.summary = "Ruby wrapper library for the Cobhan FFI system"
12
- spec.description = "Cobhan FFI is a proof of concept system for enabling shared code to be written in Rust or Go and consumed from all major languages/platforms in a safe and effective way, using easy helper functions to manage any unsafe data marshaling."
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.summary = 'Wrapper sample for Golang c-shared build'
15
- spec.description = 'Wrapper sample for Golang c-shared build implementation'
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.homepage = "https://github.com/godaddy/cobhan-ruby"
18
- spec.license = "MIT"
19
- spec.required_ruby_version = ">= 2.5.0"
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 = "exe"
34
+ spec.bindir = 'exe'
33
35
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
- spec.require_paths = ["lib"]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cobhan
4
- VERSION = "0.1.0"
4
+ VERSION = '0.1.3'
5
5
  end
data/lib/cobhan.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "cobhan/version"
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 = IO.binread(filename)
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.0
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-01 00:00:00.000000000 Z
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
- description: Wrapper sample for Golang c-shared build implementation
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
- post_install_message:
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.3
101
- signing_key:
131
+ rubygems_version: 3.3.7
132
+ signing_key:
102
133
  specification_version: 4
103
- summary: Wrapper sample for Golang c-shared build
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