output-to-file 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/example.rb CHANGED
@@ -1,7 +1,18 @@
1
+ # require 'output-to-file/html'
1
2
  require 'output-to-file'
2
3
 
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
4
+ # Timestamp is appended to the file name (YYYYMMDD-HHMMSS)
5
+ $script = __FILE__
6
+
7
+ # Mac example of providing the path to the output file:
8
+ # $script_path = "/Users/#{ENV['USER']}/Desktop/"
9
+
10
+ # Windows example of providing the path to the output file:
11
+ # $script_path = "C:\\QA\\" # Make sure the folder your are specifaing is exist!
12
+
13
+ # Or output file will be created in the same folder with the script
14
+ $script_path = ""
15
+
5
16
  $description = "This is a description of the script"
6
17
  $name = "Your Name"
7
18
  $email = "your@email.com"
@@ -18,7 +29,7 @@ benchmark do
18
29
 
19
30
  $r.print "Is 'a' (10) in a range (from 1 to 5)? - ", (1 .. 5) === a
20
31
  $r.puts ""
21
- $r.print "Is 'b' (10) in a range (from 1 to 5)? - ", (1 .. 5) === b
32
+ $r.print "Is 'b' (3) in a range (from 1 to 5)? - ", (1 .. 5) === b
22
33
 
23
34
  # Script ends here -------------------------------------------------------
24
35
 
@@ -1,4 +1,4 @@
1
- require "output-to-file/version"
1
+ require "output-to-file/version"
2
2
  require "output-to-file/benchmark"
3
3
  #=================================================================================
4
4
  def std_output()
@@ -13,34 +13,48 @@ end
13
13
  def header()
14
14
  # time_stamp = Time.new.strftime('%Y-%m-%d_%H%M%S')
15
15
  time_stamp = Time.new.strftime('%Y%m%d-%H%M%S')
16
- $file_name = $script_path + time_stamp + "_" + $script.chop.chop.chop + ".html"
16
+
17
+ if RUBY_PLATFORM =~ /32/ then
18
+ $file_name = $script_path + time_stamp + "_" + $script.chop.chop.chop + ".html"
19
+ else
20
+ script_mac = $script.split("/").to_a.last
21
+ $file_name = $script_path + time_stamp + "_" + script_mac.chop.chop.chop + ".html"
22
+ end
23
+
17
24
  # $name = ENV['USER']
18
25
  to_file = File.new($file_name, "w+")
19
26
 
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"
27
+ #= HTML ============================================================================
28
+ to_file.print "<html>\n"
29
+ to_file.print "<head>\n"
30
+ to_file.print "<title>Output of: #{$script}</title>\n"
31
+ to_file.print "</head>\n"
32
+ to_file.print "<body bgcolor='\#D4D0C8' leftmargin='0' rightmargin='0' topmargin='0' bottommargin='0' marginheight='0' marginwidth='0'>\n"
33
+ to_file.print "<table bgcolor='\#FFFFFF' width='100%' border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='\#CCCCCC'>\n<tr style='font-family:Verdana, Tahoma; color:0048B0; font-size:12pt;'>\n<td>\n<pre>\n\n"
34
+ #=================================================================================
35
+ to_file.print "User \s\s\s\s\s\s\s : #{$name}\n"
36
+ to_file.print "Email \s\s\s\s\s\s : #{$email}\n"
37
+ to_file.print "Date \s\s\s\s\s\s : " + Time.now.to_s[0 .. 18],"\n"
24
38
 
25
39
  if RUBY_PLATFORM =~ /linux/ then
26
- to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Linux"
40
+ to_file.puts "OS \s\s\s\s\s\s\s\s\s\s: Linux"
27
41
  elsif RUBY_PLATFORM =~ /32/ then
28
- to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Windows 7"
42
+ to_file.puts "OS \s\s\s\s\s\s\s\s\s\s: Windows 7"
29
43
  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"
44
+ to_file.puts "OS \s\s\s\s\s\s\s\s\s\s: OS X 10.8 Mountain Lion"
31
45
  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"
46
+ to_file.puts "OS \s\s\s\s\s\s\s\s\s\s: Mac OS X 10.7 Lion"
33
47
  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"
48
+ to_file.puts "OS \s\s\s\s\s\s\s\s\s\s: Mac OS X 10.6 Snow Leopard"
35
49
  else
36
- to_file.puts "= OS \s\s\s\s\s\s\s\s\s\s: Unknown"
50
+ to_file.puts "OS \s\s\s\s\s\s\s\s\s\s: Unknown"
37
51
  end
38
52
 
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"
53
+ to_file.print "Ruby version : ", RUBY_VERSION,"\n"
54
+ to_file.print "Script\s\s\s\s\s\s : #{$script}\n"
55
+ to_file.print "Description\s : #{$description}\n"
56
+ to_file.print "Output file\s : #{$file_name}\n"
57
+ to_file.print "</pre>\n<hr color='\#D4D0C8' />\n<pre>"
44
58
  to_file.close()
45
59
 
46
60
  $r = File.new($file_name, "a+")
@@ -48,8 +62,13 @@ def header()
48
62
  end
49
63
  #===================================================================================
50
64
  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"
65
+ $r.print "</pre>\n<hr color='\#D4D0C8' />\n<pre>"
66
+ $r.print "Respond time : #{$t_total} \t\t\t\t\t v #{Mygem::VERSION}\n"
67
+
68
+ #= /HTML =============================================================================
69
+ $r.print "</pre>\n</td>\n</tr>\n</table>\n</body>\n</html>\n"
70
+ #===================================================================================
71
+
53
72
  $r.close()
54
73
  end
55
74
  #====================================================================================
@@ -1,3 +1,3 @@
1
1
  module Mygem
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -1,4 +1,4 @@
1
- require "output-to-file/version"
1
+ require "output-to-file/version"
2
2
  require "output-to-file/benchmark"
3
3
  #=================================================================================
4
4
  def std_output()
@@ -13,7 +13,14 @@ end
13
13
  def header()
14
14
  # time_stamp = Time.new.strftime('%Y-%m-%d_%H%M%S')
15
15
  time_stamp = Time.new.strftime('%Y%m%d-%H%M%S')
16
- $file_name = $script_path + time_stamp + "_" + $script.chop.chop.chop + ".txt"
16
+
17
+ if RUBY_PLATFORM =~ /32/ then
18
+ $file_name = $script_path + time_stamp + "_" + $script.chop.chop.chop + ".txt"
19
+ else
20
+ script_mac = $script.split("/").to_a.last
21
+ $file_name = $script_path + time_stamp + "_" + script_mac.chop.chop.chop + ".txt"
22
+ end
23
+
17
24
  # $name = ENV['USER']
18
25
  to_file = File.new($file_name, "w+")
19
26
 
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.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,9 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-07 00:00:00.000000000 Z
12
+ date: 2012-08-08 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: Output of the any script execution will go into the text, html or xml
15
- files.
14
+ description: Output of the any script execution will go into the text or html files.
16
15
  email:
17
16
  - alex@alex.cc
18
17
  executables: []
@@ -23,9 +22,7 @@ extra_rdoc_files:
23
22
  files:
24
23
  - example.rb
25
24
  - lib/output-to-file.rb
26
- - lib/output-to-file/text.rb
27
25
  - lib/output-to-file/html.rb
28
- - lib/output-to-file/xml.rb
29
26
  - lib/output-to-file/benchmark.rb
30
27
  - lib/output-to-file/version.rb
31
28
  - LICENSE.txt
@@ -1,55 +0,0 @@
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
- #====================================================================================
@@ -1,55 +0,0 @@
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
- #====================================================================================