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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWM3NzM1NmY4YzRiMTFmZGU5MDYyMGM1MGU1M2VmNWU1MWIxNjc4Mg==
4
+ MDY5NTI2NWJlOTFmMTk1YjlmZjVlYWNlNTg5ZjQyODRiNmM2MzI5Yw==
5
5
  data.tar.gz: !binary |-
6
- OWYzOTZkM2ZiMWE2MTljODU0MDczYzJkNjMwNzg1NzhmNDczMWU3ZA==
6
+ MTE3MDQ5OTUyNzE4NzdkZjUxYzIwOTBiZTg3MGMxZTA4MjZlOTZlYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGM1OGY5M2RmM2UxMmI4YTAxZjg1MzFjOWVkNjJiN2UyZWY1MjJjZmY1NzU3
10
- ZGNmOTE4OGFmYTgzNGM4NjI3MjI1OTI0MmI3MDUyZjVhYWU4MTU1N2NkMmI3
11
- MTU2MjU5MjAxYjk2MDk3YTVhMTc5ZGRiZGI4ZTE1YjhkMDYzOTA=
9
+ N2I1Mzk5Yzc5N2U2ZDRlNmRjNWEzYjUxYTFjYmIyYmMyZWQ3OWU4NWNmN2E2
10
+ NDdlMWQzMmVkN2ZhMzFmYmIwN2ZmNjJmODBhMWNjOTFhNDZhM2Y2NmI1N2Mz
11
+ ZjA1NTA3MTM1MmQ1MzI4MjU5MmVmM2ZjYmQ2ZGQyZTE5NDZlNjI=
12
12
  data.tar.gz: !binary |-
13
- YjcyZjc3NzYxOTNlOWFmMDQyYjE2M2FiNmEwYzdhNjFkZTc5MmViNzgzOTU4
14
- MmYyN2Q5NjhiNTdkNmJmN2FjODYyY2FjYTQxMThkZTRjMjY2NGUwZDU5MDY2
15
- ZjUzZmE4YzJhNjllYWNmMzA4MzAwMWFlNTNmZDJiZTlhZjM3ZTg=
13
+ NTM5Yzg1NzUwNmQ2MmQ4ZTE0N2MzNDEwOGY1YjUzZjQ2YzAzMGUyMmYwZmIx
14
+ NDViMGY4OWNhODNjNzVjYjYwYzhiYTFlYTIzYTBiODFiYjI4ZDg4NzZmOTUw
15
+ MzQ0M2NhYzNlZmY0MmI4MDJhYTc0YzlmYTk4YTE5YjQyYzZjZTg=
data/HISTORY.md CHANGED
@@ -1,5 +1,6 @@
1
1
  ## History ##
2
2
 
3
+ * 0.0.5 - Added formal API docs
3
4
  * 0.0.4 - Even more README reference fixes
4
5
  * 0.0.3 - Fixed README to remove s3_logger references
5
6
  * 0.0.2 - Renamed to S3Log to avoid conflict with an existing gem
@@ -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 storage && bucket
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 storage && bucket
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
@@ -1,3 +1,3 @@
1
1
  module S3Log
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
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
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-23 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-aws