ariete 0.0.1

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.
@@ -0,0 +1,54 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
8
+
9
+ <title>File: tb_capture_std.rb [RDoc Documentation]</title>
10
+
11
+ <link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="../js/jquery.js" type="text/javascript"
14
+ charset="utf-8"></script>
15
+ <script src="../js/thickbox-compressed.js" type="text/javascript"
16
+ charset="utf-8"></script>
17
+ <script src="../js/quicksearch.js" type="text/javascript"
18
+ charset="utf-8"></script>
19
+ <script src="../js/darkfish.js" type="text/javascript"
20
+ charset="utf-8"></script>
21
+ </head>
22
+
23
+ <body class="file file-popup">
24
+ <div id="metadata">
25
+ <dl>
26
+ <dt class="modified-date">Last Modified</dt>
27
+ <dd class="modified-date">2012-12-10 14:28:58 +0900</dd>
28
+
29
+
30
+ <dt class="requires">Requires</dt>
31
+ <dd class="requires">
32
+ <ul>
33
+
34
+ <li>test/unit</li>
35
+
36
+ </ul>
37
+ </dd>
38
+
39
+
40
+
41
+ </dl>
42
+ </div>
43
+
44
+ <div id="documentation">
45
+
46
+ <div class="description">
47
+ <h2>Description</h2>
48
+
49
+ </div>
50
+
51
+ </div>
52
+ </body>
53
+ </html>
54
+
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require "stringio"
5
+
6
+ # Ariete $stdout & $stderr Capture Module
7
+ # Author:: Moza USANE (mailto:mozamimy@quellencode.org)
8
+ # Copyright:: Copyright (c) 2012 Moza USANE
9
+ # License:: MIT License (see the LICENSE file)
10
+ module Ariete
11
+
12
+ ["stdout", "stderr"].each do |name|
13
+ ##
14
+ # :method: capture_stdout
15
+ # Capture $stdout's output and return as String.
16
+ # ==== Args
17
+ # &block :: a block that you want to capture
18
+ # ==== Return
19
+ # Captured string
20
+
21
+ ##
22
+ # :method: capture_stderr
23
+ # Capture $stderr's output and return as String.
24
+ # ==== Args
25
+ # &block :: a block that you want to capture
26
+ # ==== Return
27
+ # Captured string
28
+
29
+ ##
30
+
31
+ define_method("capture_#{name}") do |*args, &block|
32
+ original = eval("$#{name}")
33
+ eval("$#{name} = StringIO.new")
34
+
35
+ begin
36
+ block.call(*args)
37
+ ensure
38
+ ret_str = eval("$#{name}").string
39
+ eval("$#{name} = original")
40
+ end
41
+
42
+ ret_str
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require "test/unit"
5
+ require_relative "../lib/ariete"
6
+
7
+ class CaptureStdTest < Test::Unit::TestCase
8
+ include Ariete
9
+
10
+ def test_stdout
11
+ result = capture_stdout {output("Ariete")}
12
+ assert_equal("Ariete is a kind of rabbit.\n", result)
13
+ end
14
+
15
+ def test_stderr
16
+ result = capture_stderr {output("Ariete")}
17
+ assert_equal("Ariete means 'Lop' in Italian\n", result)
18
+ end
19
+
20
+ def output(str)
21
+ puts "#{str} is a kind of rabbit."
22
+ warn "#{str} means 'Lop' in Italian"
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ariete
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Moza USANE
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-10 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: ! "Ariete $stdout & $stderr Capture Module\n=======================================\n\n##
15
+ Introduction\n\nAriete $stdout & $stderr Capture Module is a module that captures
16
+ $stdout($stderr) and return as String. Ariete is useful on unit test.\n\n**usage**\n\n
17
+ \ require \"test/unit\"\n require_relative \"klass\"\n\n class KlassTest
18
+ < Test::Unit::TestCase\n include Ariete\n\n def test_stdout\n result
19
+ = capture_stdout {Klass.output_out(\"Ariete\")}\n assert_equal(\"Ariete is
20
+ a kind of rabbit.\", result)\n end\n\n def test_stderr\n result
21
+ = capture_stderr {Klass.output_err(\"Ariete\")}\n assert_equal(\"Ariete means
22
+ 'Lop' in Italian.\", result)\n end\n end \n\n## Operation Environment\n\nWe
23
+ checked good operation within following environment.\n\n- Linux(openSUSE 12.2)・Mac
24
+ OS X 10.8.2\n- Ruby 1.9.3\n\n## Architectonics\n\n- **bin**\n- **doc** :: Documents
25
+ generated by rdoc\n- **lib**\n - **ariete.rb** :: Main unit of Ariete\n- **LICENSE**\n-
26
+ **Rakefile** :: Rakefile that is used to generate gem file\n- **README.md**\n- **README_jp.md**\n-
27
+ **test** :: Unit tests\n - **tb_capture_std.rb** :: Unit test for Ariete\n \n##
28
+ Install\n\nDownload ariete-x.y.z.gem, then execute following command to install
29
+ Ariete.\n\n`$ sudo gem install ariete-x.y.z.gem`\n\nOn the other hand, you can install
30
+ from RubyGems.org to use following command.\n\n`$ sudo gem install ariete`\n\n##
31
+ Sample code\n\nSee tb_capture_std.rb file. It is an unit test code, and it doubles
32
+ with sample code.\n\n## API document\n\nSee following website: [http://quellencode.org/ariete-doc/](http://quellencode.org/ariete-doc/
33
+ \"\")\n\n## License\n\nHakto is distributed with MIT License. See the LICENSE file
34
+ to read the detail of license.\n\n## About Author\n\nMoza USANE \n[http://blog.quellencode.org/](http://blog.quellencode.org/
35
+ \"\") \nmozamimy@quellencode.org"
36
+ email: mozamimy@quellencode.org
37
+ executables: []
38
+ extensions: []
39
+ extra_rdoc_files: []
40
+ files:
41
+ - CHANGELOG.md
42
+ - CHANGELOG_jp.md
43
+ - doc/Ariete.html
44
+ - doc/CaptureStdTest.html
45
+ - doc/created.rid
46
+ - doc/images/brick.png
47
+ - doc/images/brick_link.png
48
+ - doc/images/bug.png
49
+ - doc/images/bullet_black.png
50
+ - doc/images/bullet_toggle_minus.png
51
+ - doc/images/bullet_toggle_plus.png
52
+ - doc/images/date.png
53
+ - doc/images/find.png
54
+ - doc/images/loadingAnimation.gif
55
+ - doc/images/macFFBgHack.png
56
+ - doc/images/package.png
57
+ - doc/images/page_green.png
58
+ - doc/images/page_white_text.png
59
+ - doc/images/page_white_width.png
60
+ - doc/images/plugin.png
61
+ - doc/images/ruby.png
62
+ - doc/images/tag_green.png
63
+ - doc/images/wrench.png
64
+ - doc/images/wrench_orange.png
65
+ - doc/images/zoom.png
66
+ - doc/index.html
67
+ - doc/js/darkfish.js
68
+ - doc/js/jquery.js
69
+ - doc/js/quicksearch.js
70
+ - doc/js/thickbox-compressed.js
71
+ - doc/lib/ariete_rb.html
72
+ - doc/LICENSE.html
73
+ - doc/Rakefile.html
74
+ - doc/rdoc.css
75
+ - doc/test/tb_capture_std_rb.html
76
+ - lib/ariete.rb
77
+ - LICENSE
78
+ - Rakefile
79
+ - README.md
80
+ - README_jp.md
81
+ - test/tb_capture_std.rb
82
+ homepage: http://blog.quellencode.org/
83
+ licenses: []
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '1.9'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 1.8.23
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Ariete $stdout & $stderr Capture Module.
106
+ test_files: []