chupa-text 1.1.8 → 1.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99f896b313c052ecad3ea86ac6009c161cb2b3216b828aaec67da9dc886c5fbe
4
- data.tar.gz: 986e35e1c19faa63652d0d8f43c9bd73e527e1d7af2593eea4525ee473414aa1
3
+ metadata.gz: 16a8f0167ee54c9339de2a91a3ca5dcd5550a19daac95228c57869a67e09f54c
4
+ data.tar.gz: 14d0a81b1f75aef784e20fc895037397c15f0dd88dbdcda0dbed58d7f7d16f58
5
5
  SHA512:
6
- metadata.gz: 962932aed44748ca3c4809434d3e943ab5a113a6f57f058d29f7c60e6d1090f07d272d85221a5f62e9459f8a84f05725c7d5d33b15564d224dadb20215c155ae
7
- data.tar.gz: 65face75476f34016b17b64cd0d843e305b87052192d944f2e60f5f06ea91b218e6d4fce1271eacf8f4de7152113fb87de86665b12b9fc479e80789dd0e428dd
6
+ metadata.gz: b6abd29982245d2817af96ef24bc2000ea99fcf89758c3eed0de8de70b3a1d25691d41898bc20c2661d5e521cb8c8d1b23fe6adeeea83b6f8515b3e9a298379f
7
+ data.tar.gz: 3afc26b51edff767f8b86a3cbfa55405e07217f2b42a69a00c698f97a3e0fc2b567ef0f25b39cf645d434876f52ad246ea00c1af71faa0fc926d3fe617b2143f
data/doc/text/news.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # News
2
2
 
3
+ ## 1.1.9: 2019-03-03
4
+
5
+ ### Improvements
6
+
7
+ * Added `ChupaText::CaptureLogger`.
8
+
3
9
  ## 1.1.8: 2019-03-03
4
10
 
5
11
  ### Improvements
data/lib/chupa-text.rb CHANGED
@@ -20,6 +20,7 @@ require "chupa-text/error"
20
20
 
21
21
  require "chupa-text/size-parser"
22
22
  require "chupa-text/default-logger"
23
+ require "chupa-text/capture-logger"
23
24
  require "chupa-text/logger"
24
25
 
25
26
  require "chupa-text/loggable"
@@ -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
@@ -15,5 +15,5 @@
15
15
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
  module ChupaText
18
- VERSION = "1.1.8"
18
+ VERSION = "1.1.9"
19
19
  end
data/test/helper.rb CHANGED
@@ -33,31 +33,8 @@ module Helper
33
33
  URI.parse("file://#{path}")
34
34
  end
35
35
 
36
-
37
- class CaptureLogger
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.8
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