edfize 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0e9aa5913a138ac3eed3ee1d87d5c310167368ef
4
- data.tar.gz: 910e7861a4db860a9975419e7d7799f1817c4f11
2
+ SHA256:
3
+ metadata.gz: 21f8f9617f5e6d1c818d67dda16fdb99b21c67e806f75c42370a3343677f4036
4
+ data.tar.gz: 1fd626022ab4a611ed4eb887ae49b95e3170b36fbe973667f15ab59ad09feef0
5
5
  SHA512:
6
- metadata.gz: bb26b2d8cae0de66bd48dd8db154bc3632b2ced0d6ccb51f6049511db108d209b054b02e2398db02148f86efd3e1a53aeecfc713d7ec43ad3b486461e1239ebe
7
- data.tar.gz: 8bd2321dd7d9acf735e06608cddff90e97940f93d5891a2bd2b51f0d5e8896b5ef095bdd7283ab40eae7b80f365561d113ea8033f430fc3de3522bafda9379fb
6
+ metadata.gz: c6700a8b4d773ca43c77898eebd4af4e8f117f7c5a8db812b95fb0c99a0e9905c319e7c377c65e34e7e7786314cfa4afbd7ee74898991bb5656c70a47e3bec1b
7
+ data.tar.gz: e6e83fec87ff8a7eb2c317da7a5114fa9553261d8c4af298d651a75282f198a648534f66ffb060a10f7fe52296900de6d14d66b7a6465f9dfb6e1b11be001bd0
@@ -1,3 +1,11 @@
1
+ ## 0.6.0 (March 1, 2019)
2
+
3
+ ### Enhancements
4
+ - **Gem Changes**
5
+ - Update to ruby 2.6.1
6
+ - Update to simplecov 0.16.1
7
+ - Remove colorize
8
+
1
9
  ## 0.5.0 (April 21, 2017)
2
10
 
3
11
  ### Enhancements
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2017 Remo Mueller
1
+ Copyright (c) 2014-2019 Remo Mueller
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # Edfize
2
2
 
3
- [![Build Status](https://travis-ci.org/sleepepi/edfize.svg?branch=master)](https://travis-ci.org/sleepepi/edfize)
4
- [![Dependency Status](https://gemnasium.com/sleepepi/edfize.svg)](https://gemnasium.com/sleepepi/edfize)
3
+ [![Build Status](https://travis-ci.com/sleepepi/edfize.svg?branch=master)](https://travis-ci.com/sleepepi/edfize)
5
4
  [![Code Climate](https://codeclimate.com/github/sleepepi/edfize/badges/gpa.svg)](https://codeclimate.com/github/sleepepi/edfize)
6
5
 
7
6
  Ruby gem used to load, validate, and parse European Data Format files. Used for
8
- batch testing EDFs for errors. Ruby 2.2+ compatible.
7
+ batch testing EDFs for errors. Ruby 2.6+ compatible.
9
8
 
10
9
  ## Installation
11
10
 
@@ -69,10 +68,10 @@ start date of 1st Jan 1985.
69
68
  # gem install edfize --no-document
70
69
  # ruby rewrite_signal_date.rb
71
70
 
72
- require 'rubygems'
73
- require 'edfize'
71
+ require "rubygems"
72
+ require "edfize"
74
73
 
75
- CLIPPING_DATE = '01.01.85'
74
+ CLIPPING_DATE = "01.01.85"
76
75
 
77
76
  Edfize.edfs do |edf|
78
77
  edf.update(start_date_of_recording: CLIPPING_DATE)
@@ -97,23 +96,23 @@ EDF signals into arrays for analysis.
97
96
  # https://sleepdata.org/datasets/shhs/files/edfs/shhs1?f=shhs1-200001.edf
98
97
  #
99
98
 
100
- require 'rubygems'
101
- require 'edfize'
99
+ require "rubygems"
100
+ require "edfize"
102
101
 
103
102
  # Loads the file and reads the EDF Header
104
- edf = Edfize::Edf.new('shhs1-200001.edf')
103
+ edf = Edfize::Edf.new("shhs1-200001.edf")
105
104
 
106
105
  # Loads the data section of the EDF into Signal objects
107
106
  edf.load_signals
108
107
 
109
108
  # Print out information on the signals
110
- puts "EDF #{edf.filename} contains the following #{edf.signals.count} signal#{'s' unless edf.signals.count == 1}:\n\n"
109
+ puts "EDF #{edf.filename} contains the following #{edf.signals.count} signal#{"s" unless edf.signals.count == 1}:\n\n"
111
110
 
112
111
  edf.signals.each do |signal|
113
112
  puts "Signal"
114
113
  puts " Label : #{signal.label}"
115
114
  puts " Samples Per Data Record : #{signal.samples_per_data_record}"
116
- puts " First 10 Physical Values : #{(signal.physical_values[0..10] + ['...']).inspect}\n\n"
115
+ puts " First 10 Physical Values : #{(signal.physical_values[0..10] + ["..."]).inspect}\n\n"
117
116
  end
118
117
  ```
119
118
 
data/Rakefile CHANGED
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
3
+ require "bundler/gem_tasks"
4
4
 
5
- require 'rake/testtask'
5
+ require "rake/testtask"
6
6
 
7
7
  Rake::TestTask.new(:test) do |t|
8
- t.libs << 'lib'
9
- t.libs << 'test'
10
- t.pattern = 'test/**/*_test.rb'
8
+ t.libs << "lib"
9
+ t.libs << "test"
10
+ t.pattern = "test/**/*_test.rb"
11
11
  t.warning = false
12
12
  t.verbose = false
13
13
  end
data/bin/edfize CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require File.expand_path('../../lib/edfize', __FILE__)
4
+ require File.expand_path("../lib/edfize", __dir__)
5
5
 
6
6
  Edfize.launch(ARGV)
@@ -8,27 +8,26 @@
8
8
  # gem list -r edfize
9
9
  # gem install edfize
10
10
 
11
- lib = File.expand_path('../lib', __FILE__)
11
+ lib = File.expand_path("lib", __dir__)
12
12
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
13
- require 'edfize/version'
13
+ require "edfize/version"
14
14
 
15
15
  Gem::Specification.new do |spec|
16
- spec.name = 'edfize'
16
+ spec.name = "edfize"
17
17
  spec.version = Edfize::VERSION::STRING
18
- spec.authors = ['Remo Mueller']
19
- spec.email = ['remosm@gmail.com']
20
- spec.summary = 'Load, validate, and parse European Data Format files. Used for batch testing EDFs for errors.'
21
- spec.description = 'Load, validate, and parse European Data Format files. Used for batch testing EDFs for errors. \
22
- Run `edfize` on command line to view full list of options.'
23
- spec.homepage = 'https://github.com/sleepepi/edfize'
24
- spec.license = 'MIT'
18
+ spec.authors = ["Remo Mueller"]
19
+ spec.email = ["remosm@gmail.com"]
20
+ spec.summary = "Load, validate, and parse European Data Format files. Used for batch testing EDFs for errors."
21
+ spec.description = "Load, validate, and parse European Data Format files. Used for batch testing EDFs for errors. \
22
+ Run `edfize` on command line to view full list of options."
23
+ spec.homepage = "https://github.com/sleepepi/edfize"
24
+ spec.license = "MIT"
25
25
 
26
- spec.files = Dir['{bin,lib}/**/*'] + %w(CHANGELOG.md LICENSE Rakefile README.md edfize.gemspec)
26
+ spec.files = Dir["{bin,lib}/**/*"] + %w(CHANGELOG.md LICENSE Rakefile README.md edfize.gemspec)
27
27
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
28
28
  spec.test_files = spec.files.grep(%r{^(test)/})
29
- spec.require_paths = ['lib']
29
+ spec.require_paths = ["lib"]
30
30
 
31
- spec.add_dependency 'bundler', '~> 1.13'
32
- spec.add_dependency 'colorize', '~> 0.8.1'
33
- spec.add_dependency 'rake'
31
+ spec.add_dependency "bundler", ">= 1.3.0"
32
+ spec.add_dependency "rake"
34
33
  end
@@ -1,20 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'edfize/edf'
4
- require 'edfize/tests'
5
- require 'edfize/version'
6
-
7
- require 'colorize'
3
+ require "edfize/edf"
4
+ require "edfize/tests"
5
+ require "edfize/version"
6
+ require "edfize/color"
8
7
 
9
8
  # Loads EDFs, prints information, runs tests
10
9
  module Edfize
11
10
  def self.launch(argv)
12
11
  case argv.first.to_s.scan(/\w/).first
13
- when 'v'
12
+ when "v"
14
13
  version
15
- when 'c', 't'
14
+ when "c", "t"
16
15
  check(argv[1..-1])
17
- when 'r'
16
+ when "r"
18
17
  print_headers
19
18
  else
20
19
  help
@@ -22,10 +21,10 @@ module Edfize
22
21
  end
23
22
 
24
23
  def self.print_headers
25
- puts '----------------'
24
+ puts "----------------"
26
25
  edfs.each do |edf|
27
26
  edf.print_header
28
- puts '----------------'
27
+ puts "----------------"
29
28
  end
30
29
  end
31
30
 
@@ -39,7 +38,7 @@ module Edfize
39
38
  test_count = 0
40
39
  failure_count = 0
41
40
  total_edfs = edf_paths.count
42
- show_passing = argv.include?('--failing') ? false : true
41
+ show_passing = argv.include?("--failing") ? false : true
43
42
  puts "Started\n"
44
43
  edfs.each do |edf|
45
44
  runner = Edfize::Tests::Runner.new(edf, argv)
@@ -50,7 +49,7 @@ module Edfize
50
49
  print "\rChecked EDF #{edf_count} of #{total_edfs}" unless show_passing || !runner.tests_failed.zero?
51
50
  end
52
51
  puts "\nFinished in #{Time.now - test_start_time}s"
53
- puts "#{edf_count} EDF#{'s' unless edf_count == 1}, #{test_count} test#{'s' unless test_count == 1}, " + "#{failure_count} failure#{'s' unless failure_count == 1}".colorize(failure_count == 0 ? :green : :red)
52
+ puts "#{edf_count} EDF#{"s" unless edf_count == 1}, #{test_count} test#{"s" unless test_count == 1}, " + "#{failure_count} failure#{"s" unless failure_count == 1}".send(failure_count == 0 ? :green : :red)
54
53
  end
55
54
 
56
55
  def self.help
@@ -81,7 +80,7 @@ EOT
81
80
  end
82
81
 
83
82
  def self.edf_paths(recursive: true)
84
- path = "#{'**/' if recursive}*.edf"
83
+ path = "#{"**/" if recursive}*.edf"
85
84
  Dir.glob(path, File::FNM_CASEFOLD)
86
85
  end
87
86
  end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Adds ANSI colors to string class.
4
+ class String
5
+ def black
6
+ "\e[30m#{self}\e[0m"
7
+ end
8
+
9
+ def red
10
+ "\e[31m#{self}\e[0m"
11
+ end
12
+
13
+ def green
14
+ "\e[32m#{self}\e[0m"
15
+ end
16
+
17
+ def brown
18
+ "\e[33m#{self}\e[0m"
19
+ end
20
+
21
+ def yellow
22
+ brown
23
+ end
24
+
25
+ def blue
26
+ "\e[34m#{self}\e[0m"
27
+ end
28
+
29
+ def magenta
30
+ "\e[35m#{self}\e[0m"
31
+ end
32
+
33
+ def cyan
34
+ "\e[36m#{self}\e[0m"
35
+ end
36
+
37
+ def gray
38
+ "\e[37m#{self}\e[0m"
39
+ end
40
+
41
+ def white
42
+ "\e[39m#{bold}\e[0m"
43
+ end
44
+
45
+ def bg_black
46
+ "\e[40m#{self}\e[0m"
47
+ end
48
+
49
+ def bg_red
50
+ "\e[41m#{self}\e[0m"
51
+ end
52
+
53
+ def bg_green
54
+ "\e[42m#{self}\e[0m"
55
+ end
56
+
57
+ def bg_brown
58
+ "\e[43m#{self}\e[0m"
59
+ end
60
+
61
+ def bg_blue
62
+ "\e[44m#{self}\e[0m"
63
+ end
64
+
65
+ def bg_magenta
66
+ "\e[45m#{self}\e[0m"
67
+ end
68
+
69
+ def bg_cyan
70
+ "\e[46m#{self}\e[0m"
71
+ end
72
+
73
+ def bg_gray
74
+ "\e[47m#{self}\e[0m"
75
+ end
76
+
77
+ def bold
78
+ "\e[1m#{self}\e[22m"
79
+ end
80
+
81
+ def italic
82
+ "\e[3m#{self}\e[23m"
83
+ end
84
+
85
+ def underline
86
+ "\e[4m#{self}\e[24m"
87
+ end
88
+
89
+ def blink
90
+ "\e[5m#{self}\e[25m"
91
+ end
92
+
93
+ def reverse_color
94
+ "\e[7m#{self}\e[27m"
95
+ end
96
+
97
+ def colorless
98
+ gsub(/\e\[\d{1,2}m/, "")
99
+ end
100
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'edfize/signal'
4
- require 'date'
3
+ require "edfize/signal"
4
+ require "date"
5
5
 
6
6
  module Edfize
7
7
  # Class used to load and manipulate EDFs
@@ -24,16 +24,16 @@ module Edfize
24
24
  attr_accessor :signals
25
25
 
26
26
  HEADER_CONFIG = {
27
- version: { size: 8, after_read: :to_i, name: 'Version' },
28
- local_patient_identification: { size: 80, after_read: :strip, name: 'Local Patient Identification' },
29
- local_recording_identification: { size: 80, after_read: :strip, name: 'Local Recording Identification' },
30
- start_date_of_recording: { size: 8, name: 'Start Date of Recording', description: '(dd.mm.yy)' },
31
- start_time_of_recording: { size: 8, name: 'Start Time of Recording', description: '(hh.mm.ss)'},
32
- number_of_bytes_in_header: { size: 8, after_read: :to_i, name: 'Number of Bytes in Header' },
33
- reserved: { size: 44, name: 'Reserved' },
34
- number_of_data_records: { size: 8, after_read: :to_i, name: 'Number of Data Records' },
35
- duration_of_a_data_record: { size: 8, after_read: :to_i, name: 'Duration of a Data Record', units: 'second' },
36
- number_of_signals: { size: 4, after_read: :to_i, name: 'Number of Signals' }
27
+ version: { size: 8, after_read: :to_i, name: "Version" },
28
+ local_patient_identification: { size: 80, after_read: :strip, name: "Local Patient Identification" },
29
+ local_recording_identification: { size: 80, after_read: :strip, name: "Local Recording Identification" },
30
+ start_date_of_recording: { size: 8, name: "Start Date of Recording", description: "(dd.mm.yy)" },
31
+ start_time_of_recording: { size: 8, name: "Start Time of Recording", description: "(hh.mm.ss)"},
32
+ number_of_bytes_in_header: { size: 8, after_read: :to_i, name: "Number of Bytes in Header" },
33
+ reserved: { size: 44, name: "Reserved" },
34
+ number_of_data_records: { size: 8, after_read: :to_i, name: "Number of Data Records" },
35
+ duration_of_a_data_record: { size: 8, after_read: :to_i, name: "Duration of a Data Record", units: "second" },
36
+ number_of_signals: { size: 4, after_read: :to_i, name: "Number of Signals" }
37
37
  }
38
38
 
39
39
  HEADER_OFFSET = HEADER_CONFIG.collect{|k,h| h[:size]}.inject(:+)
@@ -97,17 +97,17 @@ module Edfize
97
97
 
98
98
  def section_units(section)
99
99
  units = HEADER_CONFIG[section][:units].to_s
100
- if units == ''
101
- ''
100
+ if units == ""
101
+ ""
102
102
  else
103
- " #{units}" + (instance_variable_get("@#{section}") == 1 ? '' : 's')
103
+ " #{units}" + (instance_variable_get("@#{section}") == 1 ? "" : "s")
104
104
  end
105
105
  end
106
106
 
107
107
  def section_description(section)
108
108
  description = HEADER_CONFIG[section][:description].to_s
109
- if description == ''
110
- ''
109
+ if description == ""
110
+ ""
111
111
  else
112
112
  " #{description}"
113
113
  end
@@ -118,7 +118,7 @@ module Edfize
118
118
  puts "Total File Size : #{edf_size} bytes"
119
119
  puts "\nHeader Information"
120
120
  HEADER_CONFIG.each do |section, hash|
121
- puts "#{hash[:name]}#{' '*(31 - hash[:name].size)}: " + section_value_to_string(section) + section_units(section) + section_description(section)
121
+ puts "#{hash[:name]}#{" "*(31 - hash[:name].size)}: " + section_value_to_string(section) + section_units(section) + section_description(section)
122
122
  end
123
123
  puts "\nSignal Information"
124
124
  signals.each_with_index do |signal, index|
@@ -136,7 +136,7 @@ module Edfize
136
136
  end
137
137
 
138
138
  def start_date
139
- (dd, mm, yy) = start_date_of_recording.split('.')
139
+ (dd, mm, yy) = start_date_of_recording.split(".")
140
140
  dd = parse_integer(dd)
141
141
  mm = parse_integer(mm)
142
142
  yy = parse_integer(yy)
@@ -145,13 +145,13 @@ module Edfize
145
145
  else
146
146
  yy + 2000
147
147
  end
148
- Date.strptime("#{mm}/#{dd}/#{yyyy}", '%m/%d/%Y')
148
+ Date.strptime("#{mm}/#{dd}/#{yyyy}", "%m/%d/%Y")
149
149
  rescue
150
150
  nil
151
151
  end
152
152
 
153
153
  def parse_integer(string)
154
- Integer(format('%g', string))
154
+ Integer(format("%g", string))
155
155
  rescue
156
156
  nil
157
157
  end
@@ -181,7 +181,7 @@ module Edfize
181
181
 
182
182
  def read_header_section(section)
183
183
  result = IO.binread(@filename, HEADER_CONFIG[section][:size], compute_offset(section) )
184
- result = result.to_s.send(HEADER_CONFIG[section][:after_read]) unless HEADER_CONFIG[section][:after_read].to_s == ''
184
+ result = result.to_s.send(HEADER_CONFIG[section][:after_read]) unless HEADER_CONFIG[section][:after_read].to_s == ""
185
185
  self.instance_variable_set("@#{section}", result)
186
186
  end
187
187
 
@@ -230,7 +230,7 @@ module Edfize
230
230
  (0..ns-1).to_a.each do |signal_number|
231
231
  section_size = Signal::SIGNAL_CONFIG[section][:size]
232
232
  result = IO.binread(@filename, section_size, offset+(signal_number*section_size))
233
- result = result.to_s.send(Signal::SIGNAL_CONFIG[section][:after_read]) unless Signal::SIGNAL_CONFIG[section][:after_read].to_s == ''
233
+ result = result.to_s.send(Signal::SIGNAL_CONFIG[section][:after_read]) unless Signal::SIGNAL_CONFIG[section][:after_read].to_s == ""
234
234
  @signals[signal_number].send("#{section}=", result)
235
235
  end
236
236
  end
@@ -246,7 +246,7 @@ module Edfize
246
246
  length_of_bytes_to_read = (data_records_to_retrieve+1) * size_of_data_record_in_bytes
247
247
  epoch_offset_size = epoch_number * epoch_size * size_of_data_record_in_bytes # TODO: The size in bytes of an epoch
248
248
 
249
- all_signal_data = (IO.binread(@filename, length_of_bytes_to_read, size_of_header + epoch_offset_size).unpack('s<*') rescue [])
249
+ all_signal_data = (IO.binread(@filename, length_of_bytes_to_read, size_of_header + epoch_offset_size).unpack("s<*") rescue [])
250
250
  load_signal_data(all_signal_data, data_records_to_retrieve+1)
251
251
  end
252
252
 
@@ -254,7 +254,7 @@ module Edfize
254
254
  # 16-bit signed integer in "Little Endian" format (least significant byte first)
255
255
  # unpack: s< 16-bit signed, (little-endian) byte order
256
256
  def load_digital_signals
257
- all_signal_data = IO.binread(@filename, nil, size_of_header).unpack('s<*')
257
+ all_signal_data = IO.binread(@filename, nil, size_of_header).unpack("s<*")
258
258
  load_signal_data(all_signal_data, @number_of_data_records)
259
259
  end
260
260
 
@@ -9,16 +9,16 @@ module Edfize
9
9
  :reserved_area, :digital_values, :physical_values
10
10
 
11
11
  SIGNAL_CONFIG = {
12
- label: { size: 16, after_read: :strip, name: 'Label' },
13
- transducer_type: { size: 80, after_read: :strip, name: 'Transducer Type' },
14
- physical_dimension: { size: 8, after_read: :strip, name: 'Physical Dimension' },
15
- physical_minimum: { size: 8, after_read: :to_f, name: 'Physical Minimum' },
16
- physical_maximum: { size: 8, after_read: :to_f, name: 'Physical Maximum' },
17
- digital_minimum: { size: 8, after_read: :to_i, name: 'Digital Minimum' },
18
- digital_maximum: { size: 8, after_read: :to_i, name: 'Digital Maximum' },
19
- prefiltering: { size: 80, after_read: :strip, name: 'Prefiltering' },
20
- samples_per_data_record: { size: 8, after_read: :to_i, name: 'Samples Per Data Record' },
21
- reserved_area: { size: 32, name: 'Reserved Area' }
12
+ label: { size: 16, after_read: :strip, name: "Label" },
13
+ transducer_type: { size: 80, after_read: :strip, name: "Transducer Type" },
14
+ physical_dimension: { size: 8, after_read: :strip, name: "Physical Dimension" },
15
+ physical_minimum: { size: 8, after_read: :to_f, name: "Physical Minimum" },
16
+ physical_maximum: { size: 8, after_read: :to_f, name: "Physical Maximum" },
17
+ digital_minimum: { size: 8, after_read: :to_i, name: "Digital Minimum" },
18
+ digital_maximum: { size: 8, after_read: :to_i, name: "Digital Maximum" },
19
+ prefiltering: { size: 80, after_read: :strip, name: "Prefiltering" },
20
+ samples_per_data_record: { size: 8, after_read: :to_i, name: "Samples Per Data Record" },
21
+ reserved_area: { size: 32, name: "Reserved Area" }
22
22
  }
23
23
 
24
24
  def initialize
@@ -35,13 +35,13 @@ module Edfize
35
35
 
36
36
  def print_header
37
37
  SIGNAL_CONFIG.each do |section, hash|
38
- puts " #{hash[:name]}#{' '*(29 - hash[:name].size)}: " + self.send(section).to_s
38
+ puts " #{hash[:name]}#{" " * (29 - hash[:name].size)}: " + self.send(section).to_s
39
39
  end
40
40
  end
41
41
 
42
42
  # Physical value (dimension PhysiDim) = (ASCIIvalue-DigiMin)*(PhysiMax-PhysiMin)/(DigiMax-DigiMin) + PhysiMin.
43
43
  def calculate_physical_values!
44
- @physical_values = @digital_values.collect{|sample| (( sample - @digital_minimum ) * ( @physical_maximum - @physical_minimum ) / ( @digital_maximum - @digital_minimum) + @physical_minimum rescue nil) }
44
+ @physical_values = @digital_values.collect{|sample| ((sample - @digital_minimum) * (@physical_maximum - @physical_minimum) / (@digital_maximum - @digital_minimum) + @physical_minimum rescue nil) }
45
45
  end
46
46
 
47
47
  def samples
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'edfize/tests/result'
4
- require 'edfize/tests/runner'
5
- require 'edfize/tests/check_length'
6
- require 'edfize/tests/check_reserved_area'
7
- require 'edfize/tests/check_reserved_signal_areas'
8
- require 'edfize/tests/check_valid_date'
3
+ require "edfize/color"
4
+ require "edfize/tests/result"
5
+ require "edfize/tests/runner"
6
+ require "edfize/tests/check_length"
7
+ require "edfize/tests/check_reserved_area"
8
+ require "edfize/tests/check_reserved_signal_areas"
9
+ require "edfize/tests/check_valid_date"
9
10
 
10
11
  module Edfize
11
12
  module Tests
@@ -8,7 +8,7 @@ module Edfize
8
8
  def test_expected_length(runner)
9
9
  result = Result.new
10
10
  result.passes = (runner.edf.expected_edf_size == runner.edf.edf_size)
11
- result.pass_fail = " #{result.passes ? 'PASS' : 'FAIL'}".colorize(result.passes ? :green : :red) + ' Expected File Size'
11
+ result.pass_fail = " #{result.passes ? "PASS" : "FAIL"}".send(result.passes ? :green : :red) + " Expected File Size"
12
12
  result.expected = " Expected : #{runner.edf.expected_edf_size} bytes"
13
13
  result.actual = " Actual : #{runner.edf.edf_size} bytes"
14
14
  result
@@ -6,9 +6,9 @@ module Edfize
6
6
  module CheckReservedArea
7
7
  def test_reserved_area_blank(runner)
8
8
  result = Result.new
9
- result.passes = (runner.edf.reserved == ' ' * Edf::RESERVED_SIZE)
10
- result.pass_fail = " #{result.passes ? 'PASS' : 'FAIL'}".colorize(result.passes ? :green : :red) + ' Reserved Area Blank'
11
- result.expected = " Expected : #{(' ' * Edf::RESERVED_SIZE).inspect}"
9
+ result.passes = (runner.edf.reserved == " " * Edf::RESERVED_SIZE)
10
+ result.pass_fail = " #{result.passes ? "PASS" : "FAIL"}".send(result.passes ? :green : :red) + " Reserved Area Blank"
11
+ result.expected = " Expected : #{(" " * Edf::RESERVED_SIZE).inspect}"
12
12
  result.actual = " Actual : #{runner.edf.reserved.to_s.inspect}"
13
13
  result
14
14
  end
@@ -8,9 +8,9 @@ module Edfize
8
8
  reserved_areas = runner.edf.signals.collect(&:reserved_area)
9
9
 
10
10
  result = Result.new
11
- result.passes = (reserved_areas.reject{|r| r.to_s.strip == ''}.count == 0)
12
- result.pass_fail = " #{result.passes ? 'PASS' : 'FAIL'}".colorize(result.passes ? :green : :red) + ' Signal Reserved Area Blank'
13
- result.expected = " Expected : #{[''] * runner.edf.signals.count}"
11
+ result.passes = (reserved_areas.reject{|r| r.to_s.strip == ""}.count == 0)
12
+ result.pass_fail = " #{result.passes ? "PASS" : "FAIL"}".send(result.passes ? :green : :red) + " Signal Reserved Area Blank"
13
+ result.expected = " Expected : #{[""] * runner.edf.signals.count}"
14
14
  result.actual = " Actual : #{reserved_areas}"
15
15
  result
16
16
  end
@@ -7,17 +7,17 @@ module Edfize
7
7
  def test_valid_date(runner)
8
8
  result = Result.new
9
9
  result.passes = !runner.edf.start_date.nil?
10
- result.pass_fail = pass_fail(result.passes, 'Valid Date')
11
- result.expected = ' Expected : dd.mm.yy'
10
+ result.pass_fail = pass_fail(result.passes, "Valid Date")
11
+ result.expected = " Expected : dd.mm.yy"
12
12
  result.actual = " Actual : #{runner.edf.start_date_of_recording}"
13
13
  result
14
14
  end
15
15
 
16
16
  def pass_fail(passes, message)
17
17
  if passes
18
- ' PASS'.colorize(:green) + " #{message}"
18
+ " PASS".green + " #{message}"
19
19
  else
20
- ' FAIL'.colorize(:red) + " #{message}"
20
+ " FAIL".red + " #{message}"
21
21
  end
22
22
  end
23
23
  end
@@ -12,8 +12,8 @@ module Edfize
12
12
  @tests_run = 0
13
13
  @tests_failed = 0
14
14
  @edf = edf
15
- @verbose = argv.include?('--quiet') ? false : true
16
- @show_passing = argv.include?('--failing') ? false : true
15
+ @verbose = argv.include?("--quiet") ? false : true
16
+ @show_passing = argv.include?("--failing") ? false : true
17
17
  end
18
18
 
19
19
  def run_tests
@@ -3,10 +3,10 @@
3
3
  module Edfize
4
4
  module VERSION #:nodoc:
5
5
  MAJOR = 0
6
- MINOR = 5
6
+ MINOR = 6
7
7
  TINY = 0
8
8
  BUILD = nil
9
9
 
10
- STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
10
+ STRING = [MAJOR, MINOR, TINY, BUILD].compact.join(".")
11
11
  end
12
12
  end
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edfize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Remo Mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-21 00:00:00.000000000 Z
11
+ date: 2019-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.13'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.13'
27
- - !ruby/object:Gem::Dependency
28
- name: colorize
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: 0.8.1
19
+ version: 1.3.0
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - "~>"
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: 0.8.1
26
+ version: 1.3.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,9 +38,8 @@ dependencies:
52
38
  - - ">="
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
- description: |-
56
- Load, validate, and parse European Data Format files. Used for batch testing EDFs for errors. \
57
- Run `edfize` on command line to view full list of options.
41
+ description: Load, validate, and parse European Data Format files. Used for batch
42
+ testing EDFs for errors. Run `edfize` on command line to view full list of options.
58
43
  email:
59
44
  - remosm@gmail.com
60
45
  executables:
@@ -69,6 +54,7 @@ files:
69
54
  - bin/edfize
70
55
  - edfize.gemspec
71
56
  - lib/edfize.rb
57
+ - lib/edfize/color.rb
72
58
  - lib/edfize/edf.rb
73
59
  - lib/edfize/signal.rb
74
60
  - lib/edfize/tests.rb
@@ -98,8 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
84
  - !ruby/object:Gem::Version
99
85
  version: '0'
100
86
  requirements: []
101
- rubyforge_project:
102
- rubygems_version: 2.6.11
87
+ rubygems_version: 3.0.2
103
88
  signing_key:
104
89
  specification_version: 4
105
90
  summary: Load, validate, and parse European Data Format files. Used for batch testing