experiment_arguments_log 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/experiment_arguments_log/auto.rb +3 -0
- data/lib/experiment_arguments_log.rb +55 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 97f8f8607160a33bb4d43f96291f3110d5b88dca
|
4
|
+
data.tar.gz: 71fe3c8de2acdf296bc7173b6aa3b3514921aeba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a19bbd67434716be97000857553454d1990a59acfa5de359c9569e6b7931527584424a2248a99d9aeaf7df78a14628e55e3da1615061c1a0e9f50c43021f4eb1
|
7
|
+
data.tar.gz: 17943e0f588f099f54b0c5761265939fc2d05a1f59381738b734acb914bf63eeff2df1e3c2d13a1ea52ad40d85b7e5bf56631d316f39657039c7c575268924b8
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
def experiment_arguments_log
|
4
|
+
if ENV['RUBY_EXPERIMENT_LOG']
|
5
|
+
path = ENV['RUBY_EXPERIMENT_LOG']
|
6
|
+
else
|
7
|
+
path = 'ruby_experiment_log.txt'
|
8
|
+
end
|
9
|
+
|
10
|
+
File.open(path, 'a') do |output|
|
11
|
+
|
12
|
+
date=Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
13
|
+
working_directory = ENV["PWD"]
|
14
|
+
script_relative_path = $PROGRAM_NAME
|
15
|
+
script_absolute_path = File.expand_path($PROGRAM_NAME)
|
16
|
+
arguments = ARGV
|
17
|
+
|
18
|
+
output.puts ' _ __ __ __ __ __ __ __ __ __ __ __ __ __ __ _'
|
19
|
+
output.puts ' )( )( )( )( )( )( )( )( )( )( )( )( )( )( )( '
|
20
|
+
output.puts ' (__)(__)(__)(__)(__)(__)(__)(__)(__)(__)(__)(__)(__)(__)(__)'
|
21
|
+
output.puts
|
22
|
+
output.puts "%s %s$ %s %s" % [date, working_directory, script_relative_path, arguments.map { |argument| argument.include?(' ') ? '"%s"'%[argument] : argument }.join(' ')]
|
23
|
+
output.puts 'Date: %s' % [date]
|
24
|
+
output.puts 'Working directory: %s' % [working_directory]
|
25
|
+
output.puts 'Script path: %s' % [script_relative_path]
|
26
|
+
output.puts 'Script absolute path: %s' % [script_absolute_path]
|
27
|
+
output.puts 'Script access time: %s' % [File.ctime(script_absolute_path)]
|
28
|
+
output.puts 'Script modification time: %s' % [File.mtime(script_absolute_path)]
|
29
|
+
output.puts 'Arguments: %s' % arguments.to_s
|
30
|
+
output.puts 'Git:'
|
31
|
+
output.puts `git log -1 2>/dev/null`
|
32
|
+
output.puts
|
33
|
+
|
34
|
+
ARGV.each do |argument|
|
35
|
+
begin
|
36
|
+
File.open(argument) do |argument_file|
|
37
|
+
output.puts 'File path: %s' % [argument]
|
38
|
+
output.puts 'File absolute path: %s' % [File.expand_path(argument)]
|
39
|
+
output.puts 'File access time: %s' % [argument_file.atime]
|
40
|
+
output.puts 'File modification time: %s' % [argument_file.mtime]
|
41
|
+
output.puts 'File size: %s' % [argument_file.size]
|
42
|
+
output.puts 'Content:'
|
43
|
+
5.times do
|
44
|
+
output.puts argument_file.gets(1024) || break
|
45
|
+
end
|
46
|
+
|
47
|
+
output.puts
|
48
|
+
end
|
49
|
+
rescue Errno::ENOENT
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
output.puts
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: experiment_arguments_log
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Krzysztof Wróbel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Logs script execution arguments with head of input files.
|
14
|
+
email: djstrong@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/experiment_arguments_log.rb
|
20
|
+
- lib/experiment_arguments_log/auto.rb
|
21
|
+
homepage: http://rubygems.org/gems/
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.4.5
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Logs experiment execution arguments.
|
45
|
+
test_files: []
|