scrolls 0.3.7 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,46 +0,0 @@
1
- require 'syslog'
2
-
3
- module Scrolls
4
-
5
- LOG_FACILITY = ENV['LOG_FACILITY'] || Syslog::LOG_USER
6
- LOG_FACILITY_MAP = {
7
- "auth" => Syslog::LOG_AUTH,
8
- "authpriv" => Syslog::LOG_AUTHPRIV,
9
- "cron" => Syslog::LOG_CRON,
10
- "daemon" => Syslog::LOG_DAEMON,
11
- "ftp" => Syslog::LOG_FTP,
12
- "kern" => Syslog::LOG_KERN,
13
- "mail" => Syslog::LOG_MAIL,
14
- "news" => Syslog::LOG_NEWS,
15
- "syslog" => Syslog::LOG_SYSLOG,
16
- "user" => Syslog::LOG_USER,
17
- "uucp" => Syslog::LOG_UUCP,
18
- "local0" => Syslog::LOG_LOCAL0,
19
- "local1" => Syslog::LOG_LOCAL1,
20
- "local2" => Syslog::LOG_LOCAL2,
21
- "local3" => Syslog::LOG_LOCAL3,
22
- "local4" => Syslog::LOG_LOCAL4,
23
- "local5" => Syslog::LOG_LOCAL5,
24
- "local6" => Syslog::LOG_LOCAL6,
25
- "local7" => Syslog::LOG_LOCAL7,
26
- }
27
-
28
- class SyslogLogger
29
- def initialize(ident = 'scrolls', facility = Syslog::LOG_USER)
30
- options = Syslog::LOG_PID|Syslog::LOG_CONS
31
- if Syslog.opened?
32
- @syslog = Syslog.reopen(ident, options, facility)
33
- else
34
- @syslog = Syslog.open(ident, options, facility)
35
- end
36
- end
37
-
38
- def puts(data)
39
- @syslog.log(Syslog::LOG_INFO, "%s", data)
40
- end
41
-
42
- def self.opened?
43
- Syslog.opened?
44
- end
45
- end
46
- end
data/test/test_atomic.rb DELETED
@@ -1,33 +0,0 @@
1
- require_relative "test_helper"
2
-
3
- class TestAtomic < Test::Unit::TestCase
4
- def test_construct
5
- atomic = Scrolls::Atomic.new
6
- assert_equal nil, atomic.value
7
-
8
- atomic = Scrolls::Atomic.new(0)
9
- assert_equal 0, atomic.value
10
- end
11
-
12
- def test_value
13
- atomic = Scrolls::Atomic.new(0)
14
- atomic.value = 1
15
-
16
- assert_equal 1, atomic.value
17
- end
18
-
19
- def test_update
20
- atomic = Scrolls::Atomic.new(1000)
21
- res = atomic.update {|v| v + 1}
22
-
23
- assert_equal 1001, atomic.value
24
- assert_equal 1001, res
25
- end
26
-
27
- def test_update_retries
28
- tries = 0
29
- atomic = Scrolls::Atomic.new(1000)
30
- atomic.update{|v| tries += 1 ; atomic.value = 1001 ; v + 1}
31
- assert_equal 2, tries
32
- end
33
- end