chupa-text 1.1.8 → 1.1.9
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 +4 -4
- data/doc/text/news.md +6 -0
- data/lib/chupa-text.rb +1 -0
- data/lib/chupa-text/capture-logger.rb +57 -0
- data/lib/chupa-text/version.rb +1 -1
- data/test/helper.rb +2 -25
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16a8f0167ee54c9339de2a91a3ca5dcd5550a19daac95228c57869a67e09f54c
|
4
|
+
data.tar.gz: 14d0a81b1f75aef784e20fc895037397c15f0dd88dbdcda0dbed58d7f7d16f58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6abd29982245d2817af96ef24bc2000ea99fcf89758c3eed0de8de70b3a1d25691d41898bc20c2661d5e521cb8c8d1b23fe6adeeea83b6f8515b3e9a298379f
|
7
|
+
data.tar.gz: 3afc26b51edff767f8b86a3cbfa55405e07217f2b42a69a00c698f97a3e0fc2b567ef0f25b39cf645d434876f52ad246ea00c1af71faa0fc926d3fe617b2143f
|
data/doc/text/news.md
CHANGED
data/lib/chupa-text.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Copyright (C) 2019 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module ChupaText
|
18
|
+
class CaptureLogger
|
19
|
+
class << self
|
20
|
+
def capture
|
21
|
+
original_logger = ChupaText.logger
|
22
|
+
begin
|
23
|
+
output = []
|
24
|
+
ChupaText.logger = new(output)
|
25
|
+
yield
|
26
|
+
output
|
27
|
+
ensure
|
28
|
+
ChupaText.logger = original_logger
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(output)
|
34
|
+
@output = output
|
35
|
+
end
|
36
|
+
|
37
|
+
def debug(message=nil)
|
38
|
+
@output << [:debu, message || yield]
|
39
|
+
end
|
40
|
+
|
41
|
+
def info(message=nil)
|
42
|
+
@output << [:info, message || yield]
|
43
|
+
end
|
44
|
+
|
45
|
+
def warn(message=nil)
|
46
|
+
@output << [:warn, message || yield]
|
47
|
+
end
|
48
|
+
|
49
|
+
def error(message=nil)
|
50
|
+
@output << [:error, message || yield]
|
51
|
+
end
|
52
|
+
|
53
|
+
def fatal(message=nil)
|
54
|
+
@output << [:fatal, message || yield]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/chupa-text/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -33,31 +33,8 @@ module Helper
|
|
33
33
|
URI.parse("file://#{path}")
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
def initialize(output)
|
39
|
-
@output = output
|
40
|
-
end
|
41
|
-
|
42
|
-
def error(message=nil)
|
43
|
-
@output << [:error, message || yield]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def capture_log
|
48
|
-
original_logger = ChupaText.logger
|
49
|
-
begin
|
50
|
-
output = []
|
51
|
-
ChupaText.logger = CaptureLogger.new(output)
|
52
|
-
yield
|
53
|
-
normalize_log(output)
|
54
|
-
ensure
|
55
|
-
ChupaText.logger = original_logger
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def normalize_log(log)
|
60
|
-
log.collect do |level, message|
|
36
|
+
def capture_log(&block)
|
37
|
+
ChupaText::CaptureLogger.capture(&block).collect do |level, message|
|
61
38
|
message = message.split("\n", 2)[0]
|
62
39
|
[level, message]
|
63
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chupa-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- doc/text/news.md
|
148
148
|
- lib/chupa-text.rb
|
149
149
|
- lib/chupa-text/attributes.rb
|
150
|
+
- lib/chupa-text/capture-logger.rb
|
150
151
|
- lib/chupa-text/command.rb
|
151
152
|
- lib/chupa-text/command/chupa-text-generate-decomposer.rb
|
152
153
|
- lib/chupa-text/command/chupa-text.rb
|