require_from_drive 1.0.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 +7 -0
- data/lib/require_from_drive.rb +43 -0
- metadata +45 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: cabf5993aaab28ad03b3c0357e5244f081c5fd03c9a430ffec480d9d89ee59c7
|
|
4
|
+
data.tar.gz: a9b6fa3a95f1e788e19149d53dab389faf7657f4908f8ab8039988b029bc6afa
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ca723ff64767b96a43cad0afe5894e09e5f6cf26fa049e3c7b478d9600a4544c359d06a21bbeb065ed9a0b59f6ffc3eeda7bf8c279180f8248a3bfdaae57bd97
|
|
7
|
+
data.tar.gz: f628207ba566aff4dc2e80aca3ca03cde3e4584a104716f1ff74498de2f7e37fa3edfd05a21a18f4d41a53a5eda6260f9f83920e62ed88605f2f7651ec445c98
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
class RequireFromDrive
|
|
5
|
+
SERVER_ADDRESS_ENVIRONMENT_VARIABLE_NAME = 'REQUIRE_FROM_DRIVE_SERVER_ADDRESS'
|
|
6
|
+
SERVER_TOKEN_ENVIRONMENT_VARIABLE_NAME = 'REQUIRE_FROM_DRIVE_SERVER_TOKEN'
|
|
7
|
+
SERVER_ADDRESS = ENV[SERVER_ADDRESS_ENVIRONMENT_VARIABLE_NAME]
|
|
8
|
+
SERVER_TOKEN = ENV[SERVER_TOKEN_ENVIRONMENT_VARIABLE_NAME]
|
|
9
|
+
|
|
10
|
+
if SERVER_ADDRESS.nil?
|
|
11
|
+
fail "The #{SERVER_ADDRESS_ENVIRONMENT_VARIABLE_NAME} environment variable must be set"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
if SERVER_TOKEN.nil?
|
|
15
|
+
fail "The #{SERVER_TOKEN} environment variable must be set"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.load(path)
|
|
19
|
+
response_string = self.get("#{SERVER_ADDRESS}?token=#{SERVER_TOKEN}&path=#{path}")
|
|
20
|
+
|
|
21
|
+
if /^Error: / =~ response_string
|
|
22
|
+
raise response_string
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# In the future, this could `eval` the string if it's not JSON. This would make the behavior more similar to that of the Javascript implementation. But I'm not sure how `eval` works in ruby, and there's no current demand for the feature.
|
|
26
|
+
JSON.parse(response_string)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def self.get(uri)
|
|
32
|
+
response = Net::HTTP.get_response(URI(uri))
|
|
33
|
+
|
|
34
|
+
case response
|
|
35
|
+
when Net::HTTPSuccess then
|
|
36
|
+
response.body
|
|
37
|
+
when Net::HTTPRedirection then
|
|
38
|
+
self.get(response['location'])
|
|
39
|
+
else
|
|
40
|
+
response.value # raise an error if it's not a success
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: require_from_drive
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Tyler Murphy
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-02-04 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
14
|
+
email:
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/require_from_drive.rb
|
|
20
|
+
homepage: https://github.com/Tyler-Murphy/require-from-drive
|
|
21
|
+
licenses:
|
|
22
|
+
- ISC
|
|
23
|
+
metadata:
|
|
24
|
+
source_code_uri: https://github.com/Tyler-Murphy/require-from-drive
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubyforge_project:
|
|
41
|
+
rubygems_version: 2.7.6
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: load configuration files from Google Drive
|
|
45
|
+
test_files: []
|