tasci_merger 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +22 -22
- data/README.md +77 -77
- data/bin/merge_tasci +8 -9
- data/lib/labtime.rb +110 -110
- data/lib/man_merger.rb +344 -344
- data/lib/tasci_merger.rb +336 -333
- data/tasci_merger.gemspec +21 -21
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00fc6d54856de52b4177c2e01db4583748854a53
|
4
|
+
data.tar.gz: 4097c9807bef4d820121ddb49a5cc33e672ba4fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bbe88091909e0b08395e202f120cf9104e8eda3ca94da48343a46e1e0f8ab253c10d6d7bc6e6ced2b58fcee145c838a6db197535b3f66fde39d957e05dfff53
|
7
|
+
data.tar.gz: dd4753c3782d6e844d4836650e27c798340f1ad8616e47a88253809a3540f0a5e7537297d1e81fb6ed75c3d066c7e85d27c9aaf5d2548dd9fda7165b5e7a2cbf
|
data/LICENSE
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2015 Piotr Mankowski
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
22
|
-
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Piotr Mankowski
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
CHANGED
@@ -1,77 +1,77 @@
|
|
1
|
-
# Instructions for Tasci File Merger
|
2
|
-
|
3
|
-
## Installation
|
4
|
-
1. Install Ruby.
|
5
|
-
- [http://rubyinstaller.org/](http://rubyinstaller.org/)
|
6
|
-
- Download Ruby 2.1.5 (x64) installer.
|
7
|
-
- Install to desired *RUBY_DIRECTORY*
|
8
|
-
- Choose option to add ruby to *PATH*
|
9
|
-
- Choose option to associate *.rb files with Ruby
|
10
|
-
|
11
|
-
2. Verify ruby installation.
|
12
|
-
- Go into command line.
|
13
|
-
- Enter `ruby -v`
|
14
|
-
- Ouput should look like `ruby 2.1.5p273...`
|
15
|
-
- Enter `gem -v`
|
16
|
-
- Output should look like `2.2.2`
|
17
|
-
|
18
|
-
3. Fix potential RubyGems certificate bug, as documented on [this page](https://gist.github.com/luislavena/f064211759ee0f806c88)
|
19
|
-
- Try running `gem install activesupport --no-ri --no-rdoc`
|
20
|
-
- Click `Allow access` if prompted by Windows Firewall message, choosing option for *Private networks*
|
21
|
-
- If installation fails with an `SSL_error`, follow the following steps:
|
22
|
-
- Save certificate file from [this website](https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem) to the Downloads directory.
|
23
|
-
- **Make sure file is saved with the *.pem extension**
|
24
|
-
- Find rubygems folder location by typing `gem which rubygems` into the console. You should get output like `C:/Ruby21/lib/ruby/2.1.0/rubygems.rb`
|
25
|
-
- Locate the directory and open it in an explorer window. For the above path, the directory would be `C:\Ruby21\lib\ruby\2.1.0\rubygems`
|
26
|
-
- Open the `ssl_certs` directory, and copy the previously-downloaded `*.pem` file into this directory.
|
27
|
-
- Close and re-open a console window.
|
28
|
-
|
29
|
-
4. Install required gem.
|
30
|
-
- Run:
|
31
|
-
|
32
|
-
```
|
33
|
-
gem install tasci_merger
|
34
|
-
```
|
35
|
-
|
36
|
-
## Usage in IRB
|
37
|
-
|
38
|
-
1. Open console and run `irb` to open interactive ruby console.
|
39
|
-
|
40
|
-
2. Run `require 'tasci_merger'`
|
41
|
-
|
42
|
-
3. Create tasci merger object:
|
43
|
-
|
44
|
-
```ruby
|
45
|
-
tm = TasciMerger.new("SUBJECT_CODE", "TASCI_DIRECTORY", "OUTPUT_DIRECTORY")
|
46
|
-
```
|
47
|
-
|
48
|
-
4. Create master file:
|
49
|
-
|
50
|
-
```ruby
|
51
|
-
tm.create_master_list
|
52
|
-
```
|
53
|
-
|
54
|
-
5. Create 2 merged files:
|
55
|
-
|
56
|
-
```ruby
|
57
|
-
tm.merge_files
|
58
|
-
```
|
59
|
-
|
60
|
-
## Command-line Usage
|
61
|
-
|
62
|
-
The ruby gem makes the `tasci_merger` command available.
|
63
|
-
|
64
|
-
The command takes the following parameters:
|
65
|
-
- SUBJECT_CODE
|
66
|
-
- TASCI_DIRECTORY
|
67
|
-
- OUTPUT_DIRECTORY
|
68
|
-
|
69
|
-
The command creates a master file and two merged files in the output directory.
|
70
|
-
|
71
|
-
**Example Usage:**
|
72
|
-
|
73
|
-
```
|
74
|
-
merge_tasci 3441GX X:/TasciFilesFor3441GX C:/Circadian
|
75
|
-
```
|
76
|
-
|
77
|
-
This command would create the 2 files in the `C:/Circadian` directory.
|
1
|
+
# Instructions for Tasci File Merger
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
1. Install Ruby.
|
5
|
+
- [http://rubyinstaller.org/](http://rubyinstaller.org/)
|
6
|
+
- Download Ruby 2.1.5 (x64) installer.
|
7
|
+
- Install to desired *RUBY_DIRECTORY*
|
8
|
+
- Choose option to add ruby to *PATH*
|
9
|
+
- Choose option to associate *.rb files with Ruby
|
10
|
+
|
11
|
+
2. Verify ruby installation.
|
12
|
+
- Go into command line.
|
13
|
+
- Enter `ruby -v`
|
14
|
+
- Ouput should look like `ruby 2.1.5p273...`
|
15
|
+
- Enter `gem -v`
|
16
|
+
- Output should look like `2.2.2`
|
17
|
+
|
18
|
+
3. Fix potential RubyGems certificate bug, as documented on [this page](https://gist.github.com/luislavena/f064211759ee0f806c88)
|
19
|
+
- Try running `gem install activesupport --no-ri --no-rdoc`
|
20
|
+
- Click `Allow access` if prompted by Windows Firewall message, choosing option for *Private networks*
|
21
|
+
- If installation fails with an `SSL_error`, follow the following steps:
|
22
|
+
- Save certificate file from [this website](https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem) to the Downloads directory.
|
23
|
+
- **Make sure file is saved with the *.pem extension**
|
24
|
+
- Find rubygems folder location by typing `gem which rubygems` into the console. You should get output like `C:/Ruby21/lib/ruby/2.1.0/rubygems.rb`
|
25
|
+
- Locate the directory and open it in an explorer window. For the above path, the directory would be `C:\Ruby21\lib\ruby\2.1.0\rubygems`
|
26
|
+
- Open the `ssl_certs` directory, and copy the previously-downloaded `*.pem` file into this directory.
|
27
|
+
- Close and re-open a console window.
|
28
|
+
|
29
|
+
4. Install required gem.
|
30
|
+
- Run:
|
31
|
+
|
32
|
+
```
|
33
|
+
gem install tasci_merger
|
34
|
+
```
|
35
|
+
|
36
|
+
## Usage in IRB
|
37
|
+
|
38
|
+
1. Open console and run `irb` to open interactive ruby console.
|
39
|
+
|
40
|
+
2. Run `require 'tasci_merger'`
|
41
|
+
|
42
|
+
3. Create tasci merger object:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
tm = TasciMerger.new("SUBJECT_CODE", "TASCI_DIRECTORY", "OUTPUT_DIRECTORY")
|
46
|
+
```
|
47
|
+
|
48
|
+
4. Create master file:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
tm.create_master_list
|
52
|
+
```
|
53
|
+
|
54
|
+
5. Create 2 merged files:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
tm.merge_files
|
58
|
+
```
|
59
|
+
|
60
|
+
## Command-line Usage
|
61
|
+
|
62
|
+
The ruby gem makes the `tasci_merger` command available.
|
63
|
+
|
64
|
+
The command takes the following parameters:
|
65
|
+
- SUBJECT_CODE
|
66
|
+
- TASCI_DIRECTORY
|
67
|
+
- OUTPUT_DIRECTORY
|
68
|
+
|
69
|
+
The command creates a master file and two merged files in the output directory.
|
70
|
+
|
71
|
+
**Example Usage:**
|
72
|
+
|
73
|
+
```
|
74
|
+
merge_tasci 3441GX X:/TasciFilesFor3441GX C:/Circadian
|
75
|
+
```
|
76
|
+
|
77
|
+
This command would create the 2 files in the `C:/Circadian` directory.
|
data/bin/merge_tasci
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
tm
|
7
|
-
tm.
|
8
|
-
|
9
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'tasci_merger'
|
3
|
+
|
4
|
+
# SUBJECT_CODE, TASCI_DIR
|
5
|
+
tm = TasciMerger.new(ARGV[0], ARGV[1], ARGV[2])
|
6
|
+
tm.create_master_list
|
7
|
+
tm.merge_files
|
8
|
+
|
10
9
|
m = TasciMerger.new("3232GX", "/T/IPM/CSR_32d_FD_20h/3232GX/PSG/Scored/TASCI", "/home/pwm4/Desktop/")
|
data/lib/labtime.rb
CHANGED
@@ -1,111 +1,111 @@
|
|
1
|
-
require('active_support/values/time_zone')
|
2
|
-
require('active_support/time_with_zone')
|
3
|
-
require 'active_support/core_ext/time/zones'
|
4
|
-
require 'active_support/core_ext/time'
|
5
|
-
require 'active_support/core_ext/numeric/time'
|
6
|
-
|
7
|
-
class Labtime
|
8
|
-
include Comparable
|
9
|
-
|
10
|
-
attr_accessor :year, :hour, :min, :sec, :time_zone
|
11
|
-
DEFAULT_TIME_ZONE = ActiveSupport::TimeZone.new("Eastern Time (US & Canada)")
|
12
|
-
|
13
|
-
def self.parse(realtime)
|
14
|
-
# Return nil if nil parameter
|
15
|
-
return nil if realtime.nil?
|
16
|
-
|
17
|
-
# Make sure datetime is an ActiveSupport:TimeWithZone object
|
18
|
-
raise ArgumentError, "realtime class #{realtime.class} is not ActiveSupport::TimeWithZone" unless realtime.is_a?(ActiveSupport::TimeWithZone)
|
19
|
-
|
20
|
-
# year is easy
|
21
|
-
year = realtime.year
|
22
|
-
|
23
|
-
# Reference fo labtime is start of year
|
24
|
-
Time.zone = realtime.time_zone
|
25
|
-
reference_time = Time.zone.local(year)
|
26
|
-
|
27
|
-
# find difference between reference and
|
28
|
-
second_difference = realtime.to_i - reference_time.to_i
|
29
|
-
|
30
|
-
# convert second difference to labtime
|
31
|
-
hour = second_difference / 3600
|
32
|
-
min = (second_difference - (hour * 3600)) / 60
|
33
|
-
sec = (second_difference - (hour * 3600) - (min * 60))
|
34
|
-
|
35
|
-
self.new(year, hour, min, sec, realtime.time_zone)
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.from_decimal(decimal_labtime, year, time_zone = ActiveSupport::TimeZone.new("Eastern Time (US & Canada)"))
|
39
|
-
raise ArguementError, "No year supplied!" if year.blank?
|
40
|
-
|
41
|
-
hour = decimal_labtime.to_i
|
42
|
-
remainder = decimal_labtime - hour.to_f
|
43
|
-
min_labtime = 60.0 * remainder
|
44
|
-
min = min_labtime.to_i
|
45
|
-
remainder = min_labtime - min.to_f
|
46
|
-
sec = (60 * remainder).round.to_i
|
47
|
-
|
48
|
-
self.new(year, hour, min, sec, time_zone)
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.from_seconds(sec_time, year, time_zone = DEFAULT_TIME_ZONE)
|
52
|
-
hour = (sec_time / 3600.0).to_i
|
53
|
-
sec_time = sec_time - (hour * 3600)
|
54
|
-
min = (sec_time / 60.0).to_i
|
55
|
-
sec_time = sec_time - (min * 60)
|
56
|
-
sec = sec_time
|
57
|
-
|
58
|
-
self.new(year, hour, min, sec, time_zone)
|
59
|
-
end
|
60
|
-
|
61
|
-
def self.from_s(str, time_params = {}, time_zone = DEFAULT_TIME_ZONE)
|
62
|
-
time_captures = /(\d+)\:(\d{1,2})(\:(\d{1,2}))?(\s(\d\d\d\d))?\z/.match(str).captures
|
63
|
-
|
64
|
-
time_params[:hour] ||= time_captures[0]
|
65
|
-
time_params[:min] ||= time_captures[1]
|
66
|
-
time_params[:sec] ||= time_captures[3]
|
67
|
-
time_params[:year] ||= time_captures[5]
|
68
|
-
|
69
|
-
self.new(time_params[:year], time_params[:hour], time_params[:min], time_params[:sec], time_zone)
|
70
|
-
end
|
71
|
-
|
72
|
-
def initialize(year, hour, min, sec, time_zone = nil)
|
73
|
-
@year = year.to_i
|
74
|
-
@hour = hour.to_i
|
75
|
-
@min = min.to_i
|
76
|
-
@sec = sec.to_i
|
77
|
-
@time_zone = time_zone || DEFAULT_TIME_ZONE
|
78
|
-
end
|
79
|
-
|
80
|
-
def to_time
|
81
|
-
reference_time = time_zone.local(year)
|
82
|
-
reference_time + time_in_seconds
|
83
|
-
end
|
84
|
-
|
85
|
-
def <=>(other)
|
86
|
-
to_time <=> other.to_time
|
87
|
-
end
|
88
|
-
|
89
|
-
def to_s
|
90
|
-
"#{year} #{hour}:#{min}:#{sec} #{time_zone.to_s}"
|
91
|
-
end
|
92
|
-
|
93
|
-
def to_short_s
|
94
|
-
"#{hour}:#{min}:#{sec}"
|
95
|
-
end
|
96
|
-
|
97
|
-
def time_in_seconds
|
98
|
-
hour * 3600 + min * 60 + sec
|
99
|
-
end
|
100
|
-
|
101
|
-
def add_seconds(sec)
|
102
|
-
self.class.from_seconds(self.time_in_seconds + sec, self.year, self.time_zone)
|
103
|
-
end
|
104
|
-
|
105
|
-
def to_decimal
|
106
|
-
hour.to_f + (min.to_f/60.0) + (sec.to_f/3600.0)
|
107
|
-
end
|
108
|
-
|
109
|
-
private
|
110
|
-
|
1
|
+
require('active_support/values/time_zone')
|
2
|
+
require('active_support/time_with_zone')
|
3
|
+
require 'active_support/core_ext/time/zones'
|
4
|
+
require 'active_support/core_ext/time'
|
5
|
+
require 'active_support/core_ext/numeric/time'
|
6
|
+
|
7
|
+
class Labtime
|
8
|
+
include Comparable
|
9
|
+
|
10
|
+
attr_accessor :year, :hour, :min, :sec, :time_zone
|
11
|
+
DEFAULT_TIME_ZONE = ActiveSupport::TimeZone.new("Eastern Time (US & Canada)")
|
12
|
+
|
13
|
+
def self.parse(realtime)
|
14
|
+
# Return nil if nil parameter
|
15
|
+
return nil if realtime.nil?
|
16
|
+
|
17
|
+
# Make sure datetime is an ActiveSupport:TimeWithZone object
|
18
|
+
raise ArgumentError, "realtime class #{realtime.class} is not ActiveSupport::TimeWithZone" unless realtime.is_a?(ActiveSupport::TimeWithZone)
|
19
|
+
|
20
|
+
# year is easy
|
21
|
+
year = realtime.year
|
22
|
+
|
23
|
+
# Reference fo labtime is start of year
|
24
|
+
Time.zone = realtime.time_zone
|
25
|
+
reference_time = Time.zone.local(year)
|
26
|
+
|
27
|
+
# find difference between reference and
|
28
|
+
second_difference = realtime.to_i - reference_time.to_i
|
29
|
+
|
30
|
+
# convert second difference to labtime
|
31
|
+
hour = second_difference / 3600
|
32
|
+
min = (second_difference - (hour * 3600)) / 60
|
33
|
+
sec = (second_difference - (hour * 3600) - (min * 60))
|
34
|
+
|
35
|
+
self.new(year, hour, min, sec, realtime.time_zone)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.from_decimal(decimal_labtime, year, time_zone = ActiveSupport::TimeZone.new("Eastern Time (US & Canada)"))
|
39
|
+
raise ArguementError, "No year supplied!" if year.blank?
|
40
|
+
|
41
|
+
hour = decimal_labtime.to_i
|
42
|
+
remainder = decimal_labtime - hour.to_f
|
43
|
+
min_labtime = 60.0 * remainder
|
44
|
+
min = min_labtime.to_i
|
45
|
+
remainder = min_labtime - min.to_f
|
46
|
+
sec = (60 * remainder).round.to_i
|
47
|
+
|
48
|
+
self.new(year, hour, min, sec, time_zone)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.from_seconds(sec_time, year, time_zone = DEFAULT_TIME_ZONE)
|
52
|
+
hour = (sec_time / 3600.0).to_i
|
53
|
+
sec_time = sec_time - (hour * 3600)
|
54
|
+
min = (sec_time / 60.0).to_i
|
55
|
+
sec_time = sec_time - (min * 60)
|
56
|
+
sec = sec_time
|
57
|
+
|
58
|
+
self.new(year, hour, min, sec, time_zone)
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.from_s(str, time_params = {}, time_zone = DEFAULT_TIME_ZONE)
|
62
|
+
time_captures = /(\d+)\:(\d{1,2})(\:(\d{1,2}))?(\s(\d\d\d\d))?\z/.match(str).captures
|
63
|
+
|
64
|
+
time_params[:hour] ||= time_captures[0]
|
65
|
+
time_params[:min] ||= time_captures[1]
|
66
|
+
time_params[:sec] ||= time_captures[3]
|
67
|
+
time_params[:year] ||= time_captures[5]
|
68
|
+
|
69
|
+
self.new(time_params[:year], time_params[:hour], time_params[:min], time_params[:sec], time_zone)
|
70
|
+
end
|
71
|
+
|
72
|
+
def initialize(year, hour, min, sec, time_zone = nil)
|
73
|
+
@year = year.to_i
|
74
|
+
@hour = hour.to_i
|
75
|
+
@min = min.to_i
|
76
|
+
@sec = sec.to_i
|
77
|
+
@time_zone = time_zone || DEFAULT_TIME_ZONE
|
78
|
+
end
|
79
|
+
|
80
|
+
def to_time
|
81
|
+
reference_time = time_zone.local(year)
|
82
|
+
reference_time + time_in_seconds
|
83
|
+
end
|
84
|
+
|
85
|
+
def <=>(other)
|
86
|
+
to_time <=> other.to_time
|
87
|
+
end
|
88
|
+
|
89
|
+
def to_s
|
90
|
+
"#{year} #{hour}:#{min}:#{sec} #{time_zone.to_s}"
|
91
|
+
end
|
92
|
+
|
93
|
+
def to_short_s
|
94
|
+
"#{hour}:#{min}:#{sec}"
|
95
|
+
end
|
96
|
+
|
97
|
+
def time_in_seconds
|
98
|
+
hour * 3600 + min * 60 + sec
|
99
|
+
end
|
100
|
+
|
101
|
+
def add_seconds(sec)
|
102
|
+
self.class.from_seconds(self.time_in_seconds + sec, self.year, self.time_zone)
|
103
|
+
end
|
104
|
+
|
105
|
+
def to_decimal
|
106
|
+
hour.to_f + (min.to_f/60.0) + (sec.to_f/3600.0)
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
111
|
end
|