Module: Zonebie
- Defined in:
- lib/zonebie.rb,
lib/zonebie/version.rb,
lib/zonebie/backends/tzinfo.rb,
lib/zonebie/extras/ascii_map.rb,
lib/zonebie/backends/active_support.rb
Defined Under Namespace
Modules: Backends, Extras
Constant Summary
collapse
- VERSION =
"0.0.4"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.quiet ⇒ Object
Returns the value of attribute quiet.
6
7
8
|
# File 'lib/zonebie.rb', line 6
def quiet
@quiet
end
|
Class Method Details
.add_backend(backend) ⇒ Object
35
36
37
38
|
# File 'lib/zonebie.rb', line 35
def add_backend(backend)
@backends ||= {}
@backends[backend.name] = backend
end
|
.backend ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/zonebie.rb', line 8
def backend
unless @backend
@backend = if @backends[:activesupport].usable?
@backends[:activesupport]
else
@backends.values.detect(&:usable?)
end
end
@backend
end
|
.backend=(backend) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/zonebie.rb', line 20
def backend=(backend)
case backend
when Symbol
@backend = @backends[backend]
else
@backend = backend
end
if !backend.nil? && @backend.nil?
raise ArgumentError, "Unsupported backend: #{backend}"
end
@backend
end
|
.random_timezone ⇒ Object
50
51
52
53
|
# File 'lib/zonebie.rb', line 50
def random_timezone
zones = backend.zones
zones[rand(zones.length)]
end
|
.set_random_timezone(options = {}) ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'lib/zonebie.rb', line 40
def set_random_timezone(options = {})
zone = ENV['TZ'] || random_timezone
unless quiet
$stdout.puts("[Zonebie] Setting timezone to \"#{zone}\"")
$stdout.puts(Zonebie::Extras::AsciiMap.new(zone).to_s) if options[:ascii_map]
end
backend.zone = zone
end
|