rutie 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/lib/rutie.rb +82 -0
- data/rutie.gemspec +6 -6
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53721797a0e4d835f955fac13c5c8be041487c649ea2c44d3fb88e9dcacc2fa7
|
4
|
+
data.tar.gz: 0d2d200c160e22e590e0307611342b5571b9ba5f9bd0cb71fb5d6852e48a3b89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58df44a97fc197b5a050a3f49029c84e2ada78e751af76893df26b3822987e50f5b930c5c2425ed585cff820342932334cc9d36faded8b01507db86f6030579f
|
7
|
+
data.tar.gz: 61904bcb590ca6683608e95bca93a22ea03c86cfe437b72ae3aa23b3fd1d77085505f7125dc3ef829a8bf1ecd7af1643249a92472a635b60ee35f3490ba589d1
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Daniel P. Clark
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/lib/rutie.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
class Rutie
|
2
|
+
def initialize(project_name, **opts)
|
3
|
+
@os = opts.fetch(:os) { nil } # for testing purposes
|
4
|
+
|
5
|
+
@project_name = ProjectName.new(project_name)
|
6
|
+
@lib_prefix = opts.fetch(:lib_prefix) { set_prefix }
|
7
|
+
@lib_suffix = opts.fetch(:lib_suffix) { set_suffix }
|
8
|
+
@release = opts.fetch(:release) { 'release' }
|
9
|
+
@full_lib_path = opts.fetch(:lib_path) { nil }
|
10
|
+
end
|
11
|
+
|
12
|
+
def ffi_library
|
13
|
+
file = [ @lib_prefix, @project_name, '.', @lib_suffix ]
|
14
|
+
|
15
|
+
File.join(lib_path, file.join())
|
16
|
+
end
|
17
|
+
|
18
|
+
def init(c_init_method_name)
|
19
|
+
require 'fiddle'
|
20
|
+
|
21
|
+
Fiddle::Function.new(Fiddle.dlopen(ffi_library)[c_init_method_name], [], Fiddle::TYPE_VOIDP).call
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def lib_path
|
26
|
+
path = @full_lib_path || "../target/#{@release}"
|
27
|
+
|
28
|
+
File.expand_path(path, __dir__)
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_prefix
|
32
|
+
case operating_system()
|
33
|
+
when /windows/ then ''
|
34
|
+
when /cygwin/ then 'cyg'
|
35
|
+
else 'lib'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def set_suffix
|
40
|
+
case operating_system()
|
41
|
+
when /darwin/ then 'dylib'
|
42
|
+
when /windows|cygwin/ then 'dll'
|
43
|
+
else 'so'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def host_os
|
48
|
+
@os || RbConfig::CONFIG['host_os'].downcase
|
49
|
+
end
|
50
|
+
|
51
|
+
def operating_system
|
52
|
+
case host_os()
|
53
|
+
when /linux|bsd|solaris/ then 'linux'
|
54
|
+
when /darwin/ then 'darwin'
|
55
|
+
when /mingw|mswin/ then 'windows'
|
56
|
+
else host_os()
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class ProjectName
|
61
|
+
def initialize(name)
|
62
|
+
@name = "#{name}"
|
63
|
+
raise InvalidProjectName unless valid_name?(@name)
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_str
|
67
|
+
@name
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
def valid_name?(project)
|
72
|
+
project.chars.all? {|c| c[/[a-z_]/] }
|
73
|
+
end
|
74
|
+
|
75
|
+
class InvalidProjectName < StandardError
|
76
|
+
def message
|
77
|
+
"Invalid project name. Please use snake_case naming."
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
private_constant :ProjectName
|
82
|
+
end
|
data/rutie.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
3
|
-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'rutie'
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.2'
|
8
8
|
spec.authors = ['Daniel P. Clark']
|
9
9
|
spec.email = ['6ftdan@gmail.com']
|
10
|
-
spec.summary = '
|
11
|
-
spec.description = 'Rutie — The Tie Between Ruby and Rust.
|
10
|
+
spec.summary = 'Rutie helper methods.'
|
11
|
+
spec.description = 'Rutie — The Tie Between Ruby and Rust. Helper methods gem for Rutie.'
|
12
12
|
spec.homepage = 'https://github.com/danielpclark/rutie'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
|
15
|
-
spec.files = [
|
15
|
+
spec.files = %w[rutie.gemspec lib/rutie.rb LICENSE]
|
16
16
|
|
17
17
|
spec.add_dependency 'bundler', '~> 1.16'
|
18
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rutie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,14 +24,15 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.16'
|
27
|
-
description: Rutie — The Tie Between Ruby and Rust.
|
28
|
-
gem for Rutie.
|
27
|
+
description: Rutie — The Tie Between Ruby and Rust. Helper methods gem for Rutie.
|
29
28
|
email:
|
30
29
|
- 6ftdan@gmail.com
|
31
30
|
executables: []
|
32
31
|
extensions: []
|
33
32
|
extra_rdoc_files: []
|
34
33
|
files:
|
34
|
+
- LICENSE
|
35
|
+
- lib/rutie.rb
|
35
36
|
- rutie.gemspec
|
36
37
|
homepage: https://github.com/danielpclark/rutie
|
37
38
|
licenses:
|
@@ -56,5 +57,5 @@ rubyforge_project:
|
|
56
57
|
rubygems_version: 2.7.6
|
57
58
|
signing_key:
|
58
59
|
specification_version: 4
|
59
|
-
summary:
|
60
|
+
summary: Rutie helper methods.
|
60
61
|
test_files: []
|