output-to-file 1.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.
- data/LICENSE.txt +20 -0
- data/README.rdoc +13 -0
- data/example.rb +30 -0
- data/lib/output-to-file/benchmark.rb +8 -0
- data/lib/output-to-file/html.rb +55 -0
- data/lib/output-to-file/text.rb +55 -0
- data/lib/output-to-file/version.rb +3 -0
- data/lib/output-to-file/xml.rb +55 -0
- data/lib/output-to-file.rb +55 -0
- metadata +57 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Alex Khatilov
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/example.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'output-to-file'
|
2
|
+
|
3
|
+
$script = __FILE__ # Timestamp is appended to the file (YYYYMMDD-HHMMSS)
|
4
|
+
$script_path = "" # Specify the path please Use double slash (\\ or //), Windows: c:\\qa\\ or Mac: ~//qa//) otherwise file will be created in the same folder with the script
|
5
|
+
$description = "This is a description of the script"
|
6
|
+
$name = "Your Name"
|
7
|
+
$email = "your@email.com"
|
8
|
+
|
9
|
+
header
|
10
|
+
|
11
|
+
# Start Benchmark [optional]
|
12
|
+
benchmark do
|
13
|
+
|
14
|
+
# Script starts here -----------------------------------------------------
|
15
|
+
|
16
|
+
a = 10
|
17
|
+
b = 3
|
18
|
+
|
19
|
+
$r.print "Is 'a' (10) in a range (from 1 to 5)? - ", (1 .. 5) === a
|
20
|
+
$r.puts ""
|
21
|
+
$r.print "Is 'b' (10) in a range (from 1 to 5)? - ", (1 .. 5) === b
|
22
|
+
|
23
|
+
# Script ends here -------------------------------------------------------
|
24
|
+
|
25
|
+
# End Benchmark [optional]
|
26
|
+
end
|
27
|
+
footer
|
28
|
+
|
29
|
+
# Printing the result in console [optional]
|
30
|
+
std_output
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "output-to-file/version"
|
2
|
+
require "output-to-file/benchmark"
|
3
|
+
#=================================================================================
|
4
|
+
def std_output()
|
5
|
+
$output_file = File.new($file_name, 'r')
|
6
|
+
$output_file.each {
|
7
|
+
|i|
|
8
|
+
puts i
|
9
|
+
}
|
10
|
+
$output_file.close()
|
11
|
+
end
|
12
|
+
#=================================================================================
|
13
|
+
def header()
|
14
|
+
# time_stamp = Time.new.strftime('%Y-%m-%d_%H%M%S')
|
15
|
+
time_stamp = Time.new.strftime('%Y%m%d-%H%M%S')
|
16
|
+
$file_name = $script_path + time_stamp + "_" + $script.chop.chop.chop + ".html"
|
17
|
+
# $name = ENV['USER']
|
18
|
+
to_file = File.new($file_name, "w+")
|
19
|
+
|
20
|
+
to_file.print "======================================================================\n"
|
21
|
+
to_file.print "= User \s\s\s\s\s\s\s : #{$name}\n"
|
22
|
+
to_file.print "= Email \s\s\s\s\s\s : #{$email}\n"
|
23
|
+
to_file.print "= Date \s\s\s\s\s\s : " + Time.now.to_s[0 .. 18],"\n"
|
24
|
+
|
25
|
+
if RUBY_PLATFORM =~ /linux/ then
|
26
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Linux"
|
27
|
+
elsif RUBY_PLATFORM =~ /32/ then
|
28
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Windows 7"
|
29
|
+
elsif RUBY_PLATFORM =~ /darwin12/ then
|
30
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: OS X 10.8 Mountain Lion"
|
31
|
+
elsif RUBY_PLATFORM =~ /darwin11/ then
|
32
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Mac OS X 10.7 Lion"
|
33
|
+
elsif RUBY_PLATFORM =~ /darwin10/ then
|
34
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Mac OS X 10.6 Snow Leopard"
|
35
|
+
else
|
36
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Unknown"
|
37
|
+
end
|
38
|
+
|
39
|
+
to_file.print "= Ruby version : ", RUBY_VERSION,"\n"
|
40
|
+
to_file.print "= Script\s\s\s\s\s\s : #{$script}\n"
|
41
|
+
to_file.print "= Description\s : #{$description}\n"
|
42
|
+
to_file.print "= Output file\s : #{$file_name}\n"
|
43
|
+
to_file.print "======================================================================\n\n"
|
44
|
+
to_file.close()
|
45
|
+
|
46
|
+
$r = File.new($file_name, "a+")
|
47
|
+
|
48
|
+
end
|
49
|
+
#===================================================================================
|
50
|
+
def footer()
|
51
|
+
$r.print "\n\n======================================================================\n"
|
52
|
+
$r.print "= Respond time : #{$t_total} \t\t\t\t\s\s\s\s\s\s v #{Mygem::VERSION}\n"
|
53
|
+
$r.close()
|
54
|
+
end
|
55
|
+
#====================================================================================
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "output-to-file/version"
|
2
|
+
require "output-to-file/benchmark"
|
3
|
+
#=================================================================================
|
4
|
+
def std_output()
|
5
|
+
$output_file = File.new($file_name, 'r')
|
6
|
+
$output_file.each {
|
7
|
+
|i|
|
8
|
+
puts i
|
9
|
+
}
|
10
|
+
$output_file.close()
|
11
|
+
end
|
12
|
+
#=================================================================================
|
13
|
+
def header()
|
14
|
+
# time_stamp = Time.new.strftime('%Y-%m-%d_%H%M%S')
|
15
|
+
time_stamp = Time.new.strftime('%Y%m%d-%H%M%S')
|
16
|
+
$file_name = $script_path + time_stamp + "_" + $script.chop.chop.chop + ".txt"
|
17
|
+
# $name = ENV['USER']
|
18
|
+
to_file = File.new($file_name, "w+")
|
19
|
+
|
20
|
+
to_file.print "======================================================================\n"
|
21
|
+
to_file.print "= User \s\s\s\s\s\s\s : #{$name}\n"
|
22
|
+
to_file.print "= Email \s\s\s\s\s\s : #{$email}\n"
|
23
|
+
to_file.print "= Date \s\s\s\s\s\s : " + Time.now.to_s[0 .. 18],"\n"
|
24
|
+
|
25
|
+
if RUBY_PLATFORM =~ /linux/ then
|
26
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Linux"
|
27
|
+
elsif RUBY_PLATFORM =~ /32/ then
|
28
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Windows 7"
|
29
|
+
elsif RUBY_PLATFORM =~ /darwin12/ then
|
30
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: OS X 10.8 Mountain Lion"
|
31
|
+
elsif RUBY_PLATFORM =~ /darwin11/ then
|
32
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Mac OS X 10.7 Lion"
|
33
|
+
elsif RUBY_PLATFORM =~ /darwin10/ then
|
34
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Mac OS X 10.6 Snow Leopard"
|
35
|
+
else
|
36
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Unknown"
|
37
|
+
end
|
38
|
+
|
39
|
+
to_file.print "= Ruby version : ", RUBY_VERSION,"\n"
|
40
|
+
to_file.print "= Script\s\s\s\s\s\s : #{$script}\n"
|
41
|
+
to_file.print "= Description\s : #{$description}\n"
|
42
|
+
to_file.print "= Output file\s : #{$file_name}\n"
|
43
|
+
to_file.print "======================================================================\n\n"
|
44
|
+
to_file.close()
|
45
|
+
|
46
|
+
$r = File.new($file_name, "a+")
|
47
|
+
|
48
|
+
end
|
49
|
+
#===================================================================================
|
50
|
+
def footer()
|
51
|
+
$r.print "\n\n======================================================================\n"
|
52
|
+
$r.print "= Respond time : #{$t_total} \t\t\t\t\s\s\s\s\s\s v #{Mygem::VERSION}\n"
|
53
|
+
$r.close()
|
54
|
+
end
|
55
|
+
#====================================================================================
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "output-to-file/version"
|
2
|
+
require "output-to-file/benchmark"
|
3
|
+
#=================================================================================
|
4
|
+
def std_output()
|
5
|
+
$output_file = File.new($file_name, 'r')
|
6
|
+
$output_file.each {
|
7
|
+
|i|
|
8
|
+
puts i
|
9
|
+
}
|
10
|
+
$output_file.close()
|
11
|
+
end
|
12
|
+
#=================================================================================
|
13
|
+
def header()
|
14
|
+
# time_stamp = Time.new.strftime('%Y-%m-%d_%H%M%S')
|
15
|
+
time_stamp = Time.new.strftime('%Y%m%d-%H%M%S')
|
16
|
+
$file_name = $script_path + time_stamp + "_" + $script.chop.chop.chop + ".xml"
|
17
|
+
# $name = ENV['USER']
|
18
|
+
to_file = File.new($file_name, "w+")
|
19
|
+
|
20
|
+
to_file.print "======================================================================\n"
|
21
|
+
to_file.print "= User \s\s\s\s\s\s\s : #{$name}\n"
|
22
|
+
to_file.print "= Email \s\s\s\s\s\s : #{$email}\n"
|
23
|
+
to_file.print "= Date \s\s\s\s\s\s : " + Time.now.to_s[0 .. 18],"\n"
|
24
|
+
|
25
|
+
if RUBY_PLATFORM =~ /linux/ then
|
26
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Linux"
|
27
|
+
elsif RUBY_PLATFORM =~ /32/ then
|
28
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Windows 7"
|
29
|
+
elsif RUBY_PLATFORM =~ /darwin12/ then
|
30
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: OS X 10.8 Mountain Lion"
|
31
|
+
elsif RUBY_PLATFORM =~ /darwin11/ then
|
32
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Mac OS X 10.7 Lion"
|
33
|
+
elsif RUBY_PLATFORM =~ /darwin10/ then
|
34
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Mac OS X 10.6 Snow Leopard"
|
35
|
+
else
|
36
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Unknown"
|
37
|
+
end
|
38
|
+
|
39
|
+
to_file.print "= Ruby version : ", RUBY_VERSION,"\n"
|
40
|
+
to_file.print "= Script\s\s\s\s\s\s : #{$script}\n"
|
41
|
+
to_file.print "= Description\s : #{$description}\n"
|
42
|
+
to_file.print "= Output file\s : #{$file_name}\n"
|
43
|
+
to_file.print "======================================================================\n\n"
|
44
|
+
to_file.close()
|
45
|
+
|
46
|
+
$r = File.new($file_name, "a+")
|
47
|
+
|
48
|
+
end
|
49
|
+
#===================================================================================
|
50
|
+
def footer()
|
51
|
+
$r.print "\n\n======================================================================\n"
|
52
|
+
$r.print "= Respond time : #{$t_total} \t\t\t\t\s\s\s\s\s\s v #{Mygem::VERSION}\n"
|
53
|
+
$r.close()
|
54
|
+
end
|
55
|
+
#====================================================================================
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "output-to-file/version"
|
2
|
+
require "output-to-file/benchmark"
|
3
|
+
#=================================================================================
|
4
|
+
def std_output()
|
5
|
+
$output_file = File.new($file_name, 'r')
|
6
|
+
$output_file.each {
|
7
|
+
|i|
|
8
|
+
puts i
|
9
|
+
}
|
10
|
+
$output_file.close()
|
11
|
+
end
|
12
|
+
#=================================================================================
|
13
|
+
def header()
|
14
|
+
# time_stamp = Time.new.strftime('%Y-%m-%d_%H%M%S')
|
15
|
+
time_stamp = Time.new.strftime('%Y%m%d-%H%M%S')
|
16
|
+
$file_name = $script_path + time_stamp + "_" + $script.chop.chop.chop + ".txt"
|
17
|
+
# $name = ENV['USER']
|
18
|
+
to_file = File.new($file_name, "w+")
|
19
|
+
|
20
|
+
to_file.print "======================================================================\n"
|
21
|
+
to_file.print "= User \s\s\s\s\s\s\s : #{$name}\n"
|
22
|
+
to_file.print "= Email \s\s\s\s\s\s : #{$email}\n"
|
23
|
+
to_file.print "= Date \s\s\s\s\s\s : " + Time.now.to_s[0 .. 18],"\n"
|
24
|
+
|
25
|
+
if RUBY_PLATFORM =~ /linux/ then
|
26
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Linux"
|
27
|
+
elsif RUBY_PLATFORM =~ /32/ then
|
28
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Windows 7"
|
29
|
+
elsif RUBY_PLATFORM =~ /darwin12/ then
|
30
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: OS X 10.8 Mountain Lion"
|
31
|
+
elsif RUBY_PLATFORM =~ /darwin11/ then
|
32
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Mac OS X 10.7 Lion"
|
33
|
+
elsif RUBY_PLATFORM =~ /darwin10/ then
|
34
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Mac OS X 10.6 Snow Leopard"
|
35
|
+
else
|
36
|
+
to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Unknown"
|
37
|
+
end
|
38
|
+
|
39
|
+
to_file.print "= Ruby version : ", RUBY_VERSION,"\n"
|
40
|
+
to_file.print "= Script\s\s\s\s\s\s : #{$script}\n"
|
41
|
+
to_file.print "= Description\s : #{$description}\n"
|
42
|
+
to_file.print "= Output file\s : #{$file_name}\n"
|
43
|
+
to_file.print "======================================================================\n\n"
|
44
|
+
to_file.close()
|
45
|
+
|
46
|
+
$r = File.new($file_name, "a+")
|
47
|
+
|
48
|
+
end
|
49
|
+
#===================================================================================
|
50
|
+
def footer()
|
51
|
+
$r.print "\n\n======================================================================\n"
|
52
|
+
$r.print "= Respond time : #{$t_total} \t\t\t\t\s\s\s\s\s\s v #{Mygem::VERSION}\n"
|
53
|
+
$r.close()
|
54
|
+
end
|
55
|
+
#====================================================================================
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: output-to-file
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alex Khatilov
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-07 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Output of the any script execution will go into the text, html or xml
|
15
|
+
files.
|
16
|
+
email:
|
17
|
+
- alex@alex.cc
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files:
|
21
|
+
- LICENSE.txt
|
22
|
+
- README.rdoc
|
23
|
+
files:
|
24
|
+
- example.rb
|
25
|
+
- lib/output-to-file.rb
|
26
|
+
- lib/output-to-file/text.rb
|
27
|
+
- lib/output-to-file/html.rb
|
28
|
+
- lib/output-to-file/xml.rb
|
29
|
+
- lib/output-to-file/benchmark.rb
|
30
|
+
- lib/output-to-file/version.rb
|
31
|
+
- LICENSE.txt
|
32
|
+
- README.rdoc
|
33
|
+
homepage: https://github.com/khatilov/output-to-file
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 1.8.24
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: The best way to report the output
|
57
|
+
test_files: []
|