native_ext_fetcher 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/lib/native_ext_fetcher/fetcher.rb +20 -10
- data/lib/native_ext_fetcher/http.rb +2 -2
- data/lib/native_ext_fetcher/platform.rb +19 -0
- data/lib/native_ext_fetcher/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5900074441769b6286c0912b8b6ee114e7f38d55
|
4
|
+
data.tar.gz: a4e9ac16a2158deb70a21c125b75c0d155d9665b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ca720bcb2ae582ac942caf6b810c05d2cb61c44a48718f4591172dbb3a3030615095074c4bb8b67d9d257297b602ed1e7131dad7ecea0bd5edfcfbca228b91f
|
7
|
+
data.tar.gz: eb2b6c72f45431cd120e942c2ce61bbbd2a2be2ef02d0126b8f5cbecaaddc3e6bcfcef45a42e4840ed1d5ee2d841052cfaa36a8c363d6c31aa75d3243b59d2be
|
data/.gitignore
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2016
|
3
|
+
Copyright (c) 2016 DefWare LLC (michael@defware.io)
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
53
53
|
|
54
54
|
## Contributing
|
55
55
|
|
56
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
56
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/DefWare/native_ext_fetcher. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
57
57
|
|
58
58
|
|
59
59
|
## License
|
@@ -15,6 +15,14 @@ module NativeExtFetcher
|
|
15
15
|
@options = options
|
16
16
|
|
17
17
|
@download_path = expand_download_path
|
18
|
+
|
19
|
+
if options[:static]
|
20
|
+
@file_ext = Platform.native_extension_static_file_ext
|
21
|
+
@file_postfix = Platform.native_extension_static_file_postfix
|
22
|
+
else
|
23
|
+
@file_ext = Platform.native_extension_file_ext
|
24
|
+
@file_postfix = Platform.native_extension_file_postfix
|
25
|
+
end
|
18
26
|
end
|
19
27
|
|
20
28
|
def fetch!(library)
|
@@ -32,26 +40,28 @@ module NativeExtFetcher
|
|
32
40
|
|
33
41
|
protected
|
34
42
|
|
35
|
-
def http_client
|
36
|
-
@http_client ||= Http.new(@options)
|
37
|
-
end
|
38
|
-
|
39
43
|
def expected_digest
|
40
44
|
@checksums[Platform.native_extension_key]
|
41
45
|
end
|
42
46
|
|
47
|
+
def expand_download_path
|
48
|
+
File.join(@lib_path, 'native', *Platform.native_extension_tuple).tap do |native_path|
|
49
|
+
FileUtils.mkdir_p native_path
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
43
53
|
def library_local_path(library)
|
44
|
-
File.join @download_path, "#{library}#{
|
54
|
+
File.join @download_path, "#{library}#{@file_ext}"
|
45
55
|
end
|
46
56
|
|
47
57
|
def library_request_uri(library)
|
48
|
-
"https://#{@host}/#{library}#{
|
58
|
+
"https://#{@host}/#{library}#{@file_postfix}"
|
49
59
|
end
|
50
60
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
61
|
+
private
|
62
|
+
|
63
|
+
def http_client
|
64
|
+
@http_client ||= Http.new(@options)
|
55
65
|
end
|
56
66
|
end
|
57
67
|
end
|
@@ -46,11 +46,11 @@ module NativeExtFetcher
|
|
46
46
|
retry
|
47
47
|
end
|
48
48
|
|
49
|
-
raise MaxRetries, "max retries; #{e.message}"
|
49
|
+
raise MaxRetries, "max retries; #{e.message} (#{uri})"
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
raise MaxRedirect,
|
53
|
+
raise MaxRedirect, "max redirects hit (#{uri})"
|
54
54
|
end
|
55
55
|
|
56
56
|
protected
|
@@ -43,12 +43,23 @@ module NativeExtFetcher
|
|
43
43
|
def determine_host_dlext
|
44
44
|
RbConfig::CONFIG['DLEXT'].downcase
|
45
45
|
end
|
46
|
+
|
47
|
+
def determine_host_static_ext(os)
|
48
|
+
case os
|
49
|
+
when 'windows'
|
50
|
+
'lib'
|
51
|
+
else
|
52
|
+
'a'
|
53
|
+
end
|
54
|
+
end
|
46
55
|
end
|
47
56
|
|
48
57
|
HOST_OS = determine_host_os.freeze
|
49
58
|
HOST_ARCH = determine_host_arch.freeze
|
50
59
|
HOST_DLEXT = determine_host_dlext.freeze
|
51
60
|
|
61
|
+
HOST_STATIC_EXT = determine_host_static_ext(HOST_OS).freeze
|
62
|
+
|
52
63
|
def self.native_extension_key
|
53
64
|
:"#{HOST_OS}_#{HOST_ARCH}"
|
54
65
|
end
|
@@ -57,10 +68,18 @@ module NativeExtFetcher
|
|
57
68
|
"-#{HOST_OS}-#{HOST_ARCH}.#{HOST_DLEXT}"
|
58
69
|
end
|
59
70
|
|
71
|
+
def self.native_extension_static_file_postfix
|
72
|
+
"-#{HOST_OS}-#{HOST_ARCH}.#{HOST_STATIC_EXT}"
|
73
|
+
end
|
74
|
+
|
60
75
|
def self.native_extension_file_ext
|
61
76
|
".#{HOST_DLEXT}"
|
62
77
|
end
|
63
78
|
|
79
|
+
def self.native_extension_static_file_ext
|
80
|
+
".#{HOST_STATIC_EXT}"
|
81
|
+
end
|
82
|
+
|
64
83
|
def self.native_extension_tuple
|
65
84
|
[HOST_OS, HOST_ARCH]
|
66
85
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: native_ext_fetcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DefWare LLC
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|