sappho-basics 0.0.1

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.
@@ -0,0 +1,65 @@
1
+ # See https://github.com/sappho/sappho-basics/wiki for project documentation.
2
+ # This software is licensed under the GNU Affero General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
4
+ # Copyright 2012 Andrew Heald.
5
+
6
+ module Sappho
7
+
8
+ require 'singleton'
9
+ require 'thread'
10
+ require 'logger'
11
+
12
+ class AutoFlushLog
13
+
14
+ include Singleton
15
+
16
+ def initialize
17
+ @mutex = Mutex.new
18
+ @log = Logger.new $stdout
19
+ @log.level = ENV['application.log.level'] == 'debug' ? Logger::DEBUG : Logger::INFO
20
+ end
21
+
22
+ def info message
23
+ @mutex.synchronize do
24
+ @log.info message
25
+ $stdout.flush
26
+ end if @log.info?
27
+ end
28
+
29
+ def debug message
30
+ @mutex.synchronize do
31
+ @log.debug message
32
+ $stdout.flush
33
+ end if @log.debug?
34
+ end
35
+
36
+ def info warn
37
+ @mutex.synchronize do
38
+ @log.warn message
39
+ $stdout.flush
40
+ end if @log.warn?
41
+ end
42
+
43
+ def error error
44
+ @mutex.synchronize do
45
+ @log.error "error! #{error.message}"
46
+ error.backtrace.each { |error| @log.error error }
47
+ $stdout.flush
48
+ end if @log.error?
49
+ end
50
+
51
+ def debug?
52
+ @log.debug?
53
+ end
54
+
55
+ end
56
+
57
+ module LogUtilities
58
+
59
+ def hexString bytes
60
+ (bytes.collect {|byte| "%02x " % (byte & 0xFF)}).join
61
+ end
62
+
63
+ end
64
+
65
+ end
@@ -0,0 +1,14 @@
1
+ # See https://github.com/sappho/sappho-basics/wiki for project documentation.
2
+ # This software is licensed under the GNU Affero General Public License, version 3.
3
+ # See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
4
+ # Copyright 2012 Andrew Heald.
5
+
6
+ module Sappho
7
+ NAME = 'sappho-basics'
8
+ VERSION = '0.0.1'
9
+ AUTHORS = ['Andrew Heald']
10
+ EMAILS = ['andrew@heald.co.uk']
11
+ HOMEPAGE = 'https://github.com/sappho/sappho-basics/wiki'
12
+ SUMMARY = 'Provides a small set of basic classes and modules to Sapphic apps'
13
+ DESCRIPTION = 'See the project home page for more information'
14
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sappho-basics
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Andrew Heald
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-03-15 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rake
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 11
29
+ segments:
30
+ - 0
31
+ - 9
32
+ - 2
33
+ - 2
34
+ version: 0.9.2.2
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: See the project home page for more information
38
+ email:
39
+ - andrew@heald.co.uk
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - lib/sappho-basics/auto_flush_log.rb
48
+ - lib/sappho-basics/version.rb
49
+ homepage: https://github.com/sappho/sappho-basics/wiki
50
+ licenses: []
51
+
52
+ post_install_message:
53
+ rdoc_options: []
54
+
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ requirements: []
76
+
77
+ rubyforge_project: sappho-basics
78
+ rubygems_version: 1.8.11
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Provides a small set of basic classes and modules to Sapphic apps
82
+ test_files: []
83
+