scrolls 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. data/lib/scrolls/version.rb +1 -1
  2. data/lib/scrolls.rb +14 -32
  3. metadata +2 -2
@@ -1,3 +1,3 @@
1
1
  module Scrolls
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/scrolls.rb CHANGED
@@ -17,6 +17,7 @@ module Scrolls
17
17
  extend self
18
18
 
19
19
  def start
20
+ $stdout.sync = $stderr.sync = true
20
21
  log(:log => true, :start => true)
21
22
  end
22
23
 
@@ -24,37 +25,28 @@ module Scrolls
24
25
  @mtx ||= Mutex.new
25
26
  end
26
27
 
27
- def sync_stdout
28
- $stdout.sync = true
29
- $stdout
30
- end
31
-
32
- def sync_stderr
33
- $stderr.sync = true
34
- $stderr
35
- end
36
-
37
- def stdout
38
- @stdout ||= sync_stdout
39
- end
40
-
41
- def stderr
42
- @stderr ||= sync_stderr
28
+ def write(data)
29
+ msg = unparse(data)
30
+ mtx.synchronize do
31
+ $stdout.puts(msg)
32
+ end
43
33
  end
44
34
 
45
35
  def unparse(data)
46
36
  data.map do |(k, v)|
47
37
  if (v == true)
48
38
  k.to_s
49
- elsif (v == false)
50
- "#{k}=false"
51
- elsif v.is_a?(String) # escape and quote v with ' or \ or multiple words
52
- v = v.gsub(/\\|'/) { |c| "\\#{c}" }
53
- "#{k}='#{v}'"
54
39
  elsif v.is_a?(Float)
55
40
  "#{k}=#{format("%.3f", v)}"
41
+ elsif v.nil?
42
+ nil
56
43
  else
57
- "#{k}=#{v}"
44
+ v_str = v.to_s
45
+ if (v_str =~ /^[a-zA-Z0-9\:\.\-\_\/\@]+$/)
46
+ "#{k}=#{v_str}"
47
+ else
48
+ "#{k}=\"#{v_str.sub(/".*/, "...")}\""
49
+ end
58
50
  end
59
51
  end.compact.join(" ")
60
52
  end
@@ -100,15 +92,5 @@ module Scrolls
100
92
  ))
101
93
  end
102
94
  end
103
-
104
- private
105
-
106
- def write(data, output=stdout)
107
- msg = unparse(data)
108
- mtx.synchronize do
109
- output.puts(msg)
110
- output.flush
111
- end
112
- end
113
95
  end
114
96
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrolls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-27 00:00:00.000000000 Z
12
+ date: 2012-03-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Logging, easier, more consistent.
15
15
  email: