Class: NativeExtFetcher::Fetcher
- Inherits:
-
Object
- Object
- NativeExtFetcher::Fetcher
- Defined in:
- lib/native_ext_fetcher/fetcher.rb
Constant Summary collapse
- InvalidDigest =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#download_path ⇒ Object
readonly
Returns the value of attribute download_path.
Instance Method Summary collapse
Instance Attribute Details
#download_path ⇒ Object (readonly)
Returns the value of attribute download_path.
5 6 7 |
# File 'lib/native_ext_fetcher/fetcher.rb', line 5 def download_path @download_path end |
Instance Method Details
#config(host, path, checksums, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/native_ext_fetcher/fetcher.rb', line 7 def config(host, path, checksums, = {}) @lib_path = File.(File.join(path, '..', '..', 'lib')) raise ArgumentError, 'Checksums must be a hash' unless Hash === checksums raise ArgumentError, 'Library path not found ' unless Dir.exists?(@lib_path) @host = host @checksums = checksums = @download_path = if [:static] @file_ext = Platform.native_extension_static_file_ext @file_postfix = Platform.native_extension_static_file_postfix else @file_ext = Platform.native_extension_file_ext @file_postfix = Platform.native_extension_file_postfix end end |
#fetch!(library) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/native_ext_fetcher/fetcher.rb', line 28 def fetch!(library) File.open(library_local_path(library), 'w+') do |file| file.truncate 0 # empty file uri = library_request_uri(library) digest = http_client.get_file(file, uri) unless digest == expected_digest raise InvalidDigest, "invalid checksums for #{library} from #{uri}" end end end |