go_version 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f82286c5a009760d278845c33a57be46deed12a1fe7956b2bd0d9e16c1d8f292
4
+ data.tar.gz: 238dda82d020c48e4fad75ea4cfd6e79d403f5c86f112e162b5961d9deaf8a45
5
+ SHA512:
6
+ metadata.gz: 238ad24c3b8a2aa7d7cd6e484042993bc294afd9a8d3ca03e2e38b1e28b8fc2a9f4adb3aa7588c07d2281aa34f4809170f779aa3e6c866e63ceed3ce23f1b8cb
7
+ data.tar.gz: 1f76a0c54ff2fdffee9b63a45f6108141775af546425ca936f2517a298d264c0bf3d69bed01f9eb92a4862510eaecae353e8fcf908ffdcbeb6ef557099bbc366
data/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # go-version-ruby
2
+
3
+ Ruby bindings for [go-version](https://github.com/hashicorp/go-version)
4
+
5
+ ### Building
6
+
7
+ 1. `go build -o go-version.so -buildmode=c-shared .`
@@ -0,0 +1,22 @@
1
+ require "mkmf"
2
+
3
+ find_executable("go")
4
+
5
+ $objs = []
6
+ def $objs.empty?; false; end
7
+
8
+ create_makefile("go_version/go_version")
9
+
10
+ case `#{CONFIG["CC"]} --version`
11
+ when /Free Software Foundation/
12
+ ldflags = '-W1,--unresolved-symbols=ignore-all'
13
+ when /clang/
14
+ ldflags = '-undefined dynamic_lookup'
15
+ end
16
+
17
+ File.open("Makefile", "a") do |f|
18
+ f.write <<-EOS.gsub(/^ {8}/, "\t")
19
+ $(DLLIB):
20
+ CGO_CFLAGS='$(INCFLAGS)' CGO_LDFLAGS='#{ldflags}' go build -buildmode=c-shared -o $(DLLIB) .
21
+ EOS
22
+ end
@@ -0,0 +1,6 @@
1
+ module github.com/hashicorp/go-version/bindings
2
+
3
+ go 1.17
4
+
5
+ require github.com/hashicorp/go-version v1.3.0
6
+
@@ -0,0 +1,2 @@
1
+ github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw=
2
+ github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
@@ -0,0 +1,24 @@
1
+ package main
2
+
3
+ import (
4
+ "C"
5
+
6
+ "github.com/hashicorp/go-version"
7
+ )
8
+
9
+ //export Satisfies
10
+ func Satisfies(constraint *C.char, ver *C.char) bool {
11
+ constraints, err := version.NewConstraint(C.GoString(constraint))
12
+ if err != nil {
13
+ return false
14
+ }
15
+
16
+ checkVersion, err := version.NewVersion(C.GoString(ver))
17
+ if err != nil {
18
+ return false
19
+ }
20
+
21
+ return constraints.Check(checkVersion)
22
+ }
23
+
24
+ func main() {}
@@ -0,0 +1,11 @@
1
+ module GoVersion
2
+ class Constraint
3
+ def initialize(constraint)
4
+ @constraint = constraint
5
+ end
6
+
7
+ def satisfies?(version)
8
+ Wrapper.Satisfies(@constraint, version)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ require "ffi"
2
+
3
+ module GoVersion
4
+ module Wrapper
5
+ extend FFI::Library
6
+
7
+ ffi_lib File.join(File.expand_path(__dir__), "../../ext/go-version/go_version.bundle")
8
+ attach_function :Satisfies, [:string, :string], :bool
9
+ end
10
+ end
data/lib/go_version.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "go_version/wrapper"
2
+ require "go_version/constraint"
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: go_version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Croft
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-10-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake-compiler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ description: wraps native go-version in a ruby library for certain compatibility
42
+ email: bcroft@hashicorp.com
43
+ executables: []
44
+ extensions:
45
+ - ext/go-version/extconf.rb
46
+ extra_rdoc_files: []
47
+ files:
48
+ - README.md
49
+ - ext/go-version/extconf.rb
50
+ - ext/go-version/go.mod
51
+ - ext/go-version/go.sum
52
+ - ext/go-version/main.go
53
+ - lib/go_version.rb
54
+ - lib/go_version/constraint.rb
55
+ - lib/go_version/wrapper.rb
56
+ homepage: https://rubygems.org/gems/go_version
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubygems_version: 3.1.6
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: ruby bindings for the hashicorp/go-version lib
79
+ test_files: []