output-to-file 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -20
- data/README.rdoc +13 -13
- data/bin/output-to-file +46 -0
- data/example.rb +43 -41
- data/lib/output-to-file/template.rb +44 -0
- data/lib/output-to-file/version.rb +1 -1
- data/lib/output-to-file.rb +19 -4
- metadata +7 -4
data/LICENSE.txt
CHANGED
@@ -1,20 +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.
|
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
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
= output-to-file
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== output-to-file
|
6
|
-
|
7
|
-
* Check out the latest master
|
8
|
-
|
9
|
-
== Copyright
|
10
|
-
|
11
|
-
Copyright (c) 2012 Alex Khatilov. See LICENSE.txt for
|
12
|
-
further details.
|
13
|
-
|
1
|
+
= output-to-file
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== output-to-file
|
6
|
+
|
7
|
+
* Check out the latest master
|
8
|
+
|
9
|
+
== Copyright
|
10
|
+
|
11
|
+
Copyright (c) 2012 Alex Khatilov. See LICENSE.txt for
|
12
|
+
further details.
|
13
|
+
|
data/bin/output-to-file
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'output-to-file'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
options = "Done!"
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
|
8
|
+
opts.on("-v", "--version") do
|
9
|
+
puts "output-to-file version #{Mygem::VERSION}"
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
opts.on("--hey") do
|
14
|
+
puts "I love you baby!"
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on("-n", "--new") do
|
19
|
+
OutputToFile.perform
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on("-h", "--help") do
|
24
|
+
puts <<HELP
|
25
|
+
|
26
|
+
Usage:
|
27
|
+
output-to-file [option]
|
28
|
+
|
29
|
+
Options:
|
30
|
+
-n, --new Generate template of the script
|
31
|
+
-v, --version Show version
|
32
|
+
-h, --help Show this message
|
33
|
+
|
34
|
+
Examples:
|
35
|
+
output-to-file -v
|
36
|
+
output-to-file new
|
37
|
+
output-to-file -h
|
38
|
+
HELP
|
39
|
+
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
|
43
|
+
end.parse!
|
44
|
+
|
45
|
+
# p options
|
46
|
+
# p ARGV
|
data/example.rb
CHANGED
@@ -1,41 +1,43 @@
|
|
1
|
-
#
|
2
|
-
require 'output-to-file'
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
$
|
18
|
-
$
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
$r.
|
32
|
-
$r.
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
1
|
+
# ========================================================================
|
2
|
+
# require 'output-to-file/html'
|
3
|
+
require 'output-to-file'
|
4
|
+
# ========================================================================
|
5
|
+
# Timestamp is appended to the file name (YYYYMMDD-HHMMSS)
|
6
|
+
$script = __FILE__
|
7
|
+
# ========================================================================
|
8
|
+
# Mac example of providing the path to the output file:
|
9
|
+
# $script_path = "/Users/#{ENV['USER']}/Desktop/"
|
10
|
+
# ========================================================================
|
11
|
+
# Windows example of providing the path to the output file:
|
12
|
+
# $script_path = "C:\\QA\\" # Make sure the folder you are specifying is exist!
|
13
|
+
# ========================================================================
|
14
|
+
# Or output file will be created in the same folder with the script
|
15
|
+
$script_path = ""
|
16
|
+
# ========================================================================
|
17
|
+
$description = "This is a description of the script"
|
18
|
+
$name = "Your Name"
|
19
|
+
$email = "your@email.com"
|
20
|
+
# ========================================================================
|
21
|
+
header
|
22
|
+
|
23
|
+
# Start Benchmark [optional]
|
24
|
+
benchmark do
|
25
|
+
|
26
|
+
# Script starts here -----------------------------------------------------
|
27
|
+
|
28
|
+
a = 10
|
29
|
+
b = 3
|
30
|
+
|
31
|
+
$r.print "Is 'a' (10) in a range (from 1 to 5)? - ", (1 .. 5) === a
|
32
|
+
$r.puts ""
|
33
|
+
$r.print "Is 'b' (3) in a range (from 1 to 5)? - ", (1 .. 5) === b
|
34
|
+
|
35
|
+
# Script ends here -------------------------------------------------------
|
36
|
+
|
37
|
+
# End Benchmark [optional]
|
38
|
+
end
|
39
|
+
footer
|
40
|
+
|
41
|
+
# Printing the result in console [optional]
|
42
|
+
std_output
|
43
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
$template =<<EOS
|
2
|
+
# ========================================================================
|
3
|
+
# require 'output-to-file/html'
|
4
|
+
require 'output-to-file'
|
5
|
+
# ========================================================================
|
6
|
+
# Timestamp is appended to the file name (YYYYMMDD-HHMMSS)
|
7
|
+
$script = __FILE__
|
8
|
+
# ========================================================================
|
9
|
+
# Mac example of providing the path to the output file:
|
10
|
+
# $script_path = "/Users/#{ENV['USER']}/Desktop/"
|
11
|
+
# ========================================================================
|
12
|
+
# Windows example of providing the path to the output file:
|
13
|
+
# $script_path = "C:\\\\QA\\\\" # Make sure the folder you are specifying is exist!
|
14
|
+
# ========================================================================
|
15
|
+
# Or output file will be created in the same folder with the script
|
16
|
+
$script_path = ""
|
17
|
+
# ========================================================================
|
18
|
+
$description = "This is a description of the script"
|
19
|
+
$name = "Your Name"
|
20
|
+
$email = "your@email.com"
|
21
|
+
# ========================================================================
|
22
|
+
header
|
23
|
+
|
24
|
+
# Start Benchmark [optional]
|
25
|
+
benchmark do
|
26
|
+
|
27
|
+
# Script starts here -----------------------------------------------------
|
28
|
+
|
29
|
+
a = 10
|
30
|
+
b = 3
|
31
|
+
|
32
|
+
$r.print "Is 'a' (10) in a range (from 1 to 5)? - ", (1 .. 5) === a
|
33
|
+
$r.puts ""
|
34
|
+
$r.print "Is 'b' (3) in a range (from 1 to 5)? - ", (1 .. 5) === b
|
35
|
+
|
36
|
+
# Script ends here -------------------------------------------------------
|
37
|
+
|
38
|
+
# End Benchmark [optional]
|
39
|
+
end
|
40
|
+
footer
|
41
|
+
|
42
|
+
# Printing the result in console [optional]
|
43
|
+
std_output
|
44
|
+
EOS
|
data/lib/output-to-file.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
require "output-to-file/version"
|
2
2
|
require "output-to-file/benchmark"
|
3
|
+
require "output-to-file/template"
|
3
4
|
#=================================================================================
|
4
5
|
def std_output()
|
5
6
|
$output_file = File.new($file_name, 'r')
|
@@ -11,11 +12,10 @@ def std_output()
|
|
11
12
|
end
|
12
13
|
#=================================================================================
|
13
14
|
def header()
|
14
|
-
|
15
|
-
time_stamp = Time.new.strftime('%Y%m%d-%H%M%S')
|
15
|
+
time_stamp = Time.new.strftime('%Y-%m-%d-%H-%M-%S')
|
16
16
|
|
17
17
|
if RUBY_PLATFORM =~ /32/ then
|
18
|
-
$file_name = $script_path +
|
18
|
+
$file_name = $script_path + "log_" + $script.chop.chop.chop + "_" + time_stamp + ".txt"
|
19
19
|
else
|
20
20
|
script_mac = $script.split("/").to_a.last
|
21
21
|
$file_name = $script_path + time_stamp + "_" + script_mac.chop.chop.chop + ".txt"
|
@@ -60,3 +60,18 @@ def footer()
|
|
60
60
|
$r.close()
|
61
61
|
end
|
62
62
|
#====================================================================================
|
63
|
+
module OutputToFile
|
64
|
+
class << self
|
65
|
+
def perform
|
66
|
+
time_stamp = Time.new.strftime('%M%S')
|
67
|
+
$file_tmp = "template_script_" + time_stamp + ".rb"
|
68
|
+
$to_template = File.new($file_tmp, "w+")
|
69
|
+
$to_template.puts $template
|
70
|
+
puts ""
|
71
|
+
puts "Create: #{$file_tmp}"
|
72
|
+
puts ""
|
73
|
+
puts "To run: ruby #{$file_tmp}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
#====================================================================================
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: output-to-file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,13 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Output of the any script execution will go into the text or html files.
|
15
15
|
email:
|
16
16
|
- alex@alex.cc
|
17
|
-
executables:
|
17
|
+
executables:
|
18
|
+
- output-to-file
|
18
19
|
extensions: []
|
19
20
|
extra_rdoc_files:
|
20
21
|
- LICENSE.txt
|
@@ -25,6 +26,8 @@ files:
|
|
25
26
|
- lib/output-to-file/html.rb
|
26
27
|
- lib/output-to-file/benchmark.rb
|
27
28
|
- lib/output-to-file/version.rb
|
29
|
+
- lib/output-to-file/template.rb
|
30
|
+
- bin/output-to-file
|
28
31
|
- LICENSE.txt
|
29
32
|
- README.rdoc
|
30
33
|
homepage: https://github.com/khatilov/output-to-file
|
@@ -47,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
50
|
version: '0'
|
48
51
|
requirements: []
|
49
52
|
rubyforge_project:
|
50
|
-
rubygems_version: 1.8.
|
53
|
+
rubygems_version: 1.8.23
|
51
54
|
signing_key:
|
52
55
|
specification_version: 3
|
53
56
|
summary: The best way to report the output
|