s3_log 0.0.4 → 0.0.5
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 +8 -8
- data/HISTORY.md +1 -0
- data/lib/s3_log.rb +48 -2
- data/lib/s3_log/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDY5NTI2NWJlOTFmMTk1YjlmZjVlYWNlNTg5ZjQyODRiNmM2MzI5Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTE3MDQ5OTUyNzE4NzdkZjUxYzIwOTBiZTg3MGMxZTA4MjZlOTZlYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2I1Mzk5Yzc5N2U2ZDRlNmRjNWEzYjUxYTFjYmIyYmMyZWQ3OWU4NWNmN2E2
|
10
|
+
NDdlMWQzMmVkN2ZhMzFmYmIwN2ZmNjJmODBhMWNjOTFhNDZhM2Y2NmI1N2Mz
|
11
|
+
ZjA1NTA3MTM1MmQ1MzI4MjU5MmVmM2ZjYmQ2ZGQyZTE5NDZlNjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTM5Yzg1NzUwNmQ2MmQ4ZTE0N2MzNDEwOGY1YjUzZjQ2YzAzMGUyMmYwZmIx
|
14
|
+
NDViMGY4OWNhODNjNzVjYjYwYzhiYTFlYTIzYTBiODFiYjI4ZDg4NzZmOTUw
|
15
|
+
MzQ0M2NhYzNlZmY0MmI4MDJhYTc0YzlmYTk4YTE5YjQyYzZjZTg=
|
data/HISTORY.md
CHANGED
data/lib/s3_log.rb
CHANGED
@@ -1,21 +1,49 @@
|
|
1
1
|
require 'fog/aws/storage'
|
2
2
|
require 's3_log/exceptions'
|
3
3
|
|
4
|
+
# This module is a singleton that implements an append-style S3 file writer.
|
5
|
+
|
4
6
|
module S3Log
|
5
7
|
RequiredOptions = [:access_key_id, :secret_access_key, :bucket]
|
6
8
|
|
9
|
+
# Return the singleton's S3 Storage object
|
10
|
+
#
|
11
|
+
# @return [Fog::Storage::AWS] if the logger is configured
|
12
|
+
#
|
13
|
+
# @return [BilClass] if the logger is not configured
|
14
|
+
|
7
15
|
def self.storage
|
8
16
|
@storage
|
9
17
|
end
|
10
18
|
|
19
|
+
# Return the singleton's S3 bucket
|
20
|
+
#
|
21
|
+
# @return [Fog::Storage::AWS::Directory] if the logger is configured
|
22
|
+
#
|
23
|
+
# @return [NilClass] if the logger is not configured
|
24
|
+
|
11
25
|
def self.bucket
|
12
26
|
@bucket
|
13
27
|
end
|
14
28
|
|
29
|
+
# Is the logger configured?
|
30
|
+
#
|
31
|
+
# @return [Boolean] true if the logger is configured, false otherwise
|
32
|
+
|
15
33
|
def self.configured?
|
16
34
|
storage && bucket
|
17
35
|
end
|
18
36
|
|
37
|
+
# Configure the logger so it can be used to write logs
|
38
|
+
#
|
39
|
+
# @param options [Hash] The :access_key_id, :secret_access_key, and :bucket
|
40
|
+
# keys are required
|
41
|
+
#
|
42
|
+
# @return [S3Log] the singleton logger
|
43
|
+
#
|
44
|
+
# @raise [S3Log::InvalidConfigError] if not provided all required
|
45
|
+
# configuration options
|
46
|
+
|
19
47
|
def self.configure(options = {})
|
20
48
|
missing = RequiredOptions - options.keys
|
21
49
|
raise InvalidConfigError.new(missing) unless missing.empty?
|
@@ -34,8 +62,14 @@ module S3Log
|
|
34
62
|
self
|
35
63
|
end
|
36
64
|
|
65
|
+
# Append the given content to the given S3 path
|
66
|
+
#
|
67
|
+
# @return [S3Log] the singleton logger
|
68
|
+
#
|
69
|
+
# @raise [S3Log::Unconfigured] if the logger has not been configured
|
70
|
+
|
37
71
|
def self.write(path, content)
|
38
|
-
unless
|
72
|
+
unless configured?
|
39
73
|
raise Unconfigured
|
40
74
|
end
|
41
75
|
|
@@ -48,8 +82,16 @@ module S3Log
|
|
48
82
|
self
|
49
83
|
end
|
50
84
|
|
85
|
+
# Read the given path
|
86
|
+
#
|
87
|
+
# @return [String] the content of the requested S3 file if present
|
88
|
+
#
|
89
|
+
# @return [String] the empty string if the requested S3 file is not present
|
90
|
+
#
|
91
|
+
# @raise [S3Log::Unconfigured] if the logger has not been configured
|
92
|
+
|
51
93
|
def self.read(path)
|
52
|
-
unless
|
94
|
+
unless configured?
|
53
95
|
raise Unconfigured
|
54
96
|
end
|
55
97
|
|
@@ -57,6 +99,10 @@ module S3Log
|
|
57
99
|
file.nil? ? '' : file.body.to_s
|
58
100
|
end
|
59
101
|
|
102
|
+
# Clear the singleton logger's configuration
|
103
|
+
#
|
104
|
+
# @return [NilClass]
|
105
|
+
|
60
106
|
def self.clear_configuration
|
61
107
|
@bucket = @storage = nil
|
62
108
|
end
|
data/lib/s3_log/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3_log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Walters
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-aws
|