text-data-tools 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.0.5
@@ -153,12 +153,12 @@ module TextDataTools
153
153
  column_header = index_array.index(index_array.compact[0])
154
154
  end
155
155
 
156
- # This is a simple class which can interface with the methods of TextFileTools
156
+ # This is a simple class which can interface with the methods of TextDataTools
157
157
  # to prevent the user having to specify the file name and other properties of the
158
158
  # data file for every call. In a
159
159
  # nutshell, create a new instance of this class giving it the filename, and any
160
160
  # appropriate options,
161
- # then call methods from TextFileTools omitting the appropriate arguments.
161
+ # then call methods from TextDataTools omitting the appropriate arguments.
162
162
  class TextDataFile
163
163
  def initialize(filename, has_header_line = false, match = /\S+/, header_match = /\S+/)
164
164
  @filename = filename
@@ -168,32 +168,32 @@ module TextDataTools
168
168
  self
169
169
  end
170
170
  def get_1d_array(column_header)
171
- TextFileTools.get_1d_array(@filename, @has_header_line, column_header, @match, @header_match)
171
+ TextDataTools.get_1d_array(@filename, @has_header_line, column_header, @match, @header_match)
172
172
  end
173
173
  def get_1d_array_float(column_header)
174
- TextFileTools.get_1d_array_float(@filename, @has_header_line, column_header, @match, @header_match)
174
+ TextDataTools.get_1d_array_float(@filename, @has_header_line, column_header, @match, @header_match)
175
175
  end
176
176
  def get_1d_array_integer(column_header)
177
- TextFileTools.get_1d_array_integer(@filename, @has_header_line, column_header, @match, @header_match)
177
+ TextDataTools.get_1d_array_integer(@filename, @has_header_line, column_header, @match, @header_match)
178
178
  end
179
179
  def get_2d_array(column_header, index_header)
180
- TextFileTools.get_2d_array(@filename, @has_header_line, column_header, index_header, @match, @header_match)
180
+ TextDataTools.get_2d_array(@filename, @has_header_line, column_header, index_header, @match, @header_match)
181
181
  end
182
182
  def get_2d_array_float(column_header, index_header)
183
- TextFileTools.get_2d_array(@filename, @has_header_line, column_header, index_header, @match, @header_match)
183
+ TextDataTools.get_2d_array(@filename, @has_header_line, column_header, index_header, @match, @header_match)
184
184
  end
185
185
  def get_2d_array_integer(column_header, index_header)
186
- TextFileTools.get_2d_array(@filename, @has_header_line, column_header, index_header, @match, @header_match)
186
+ TextDataTools.get_2d_array(@filename, @has_header_line, column_header, index_header, @match, @header_match)
187
187
  end
188
188
  def get_variable_value(name, sep)
189
- TextFileTools.get_variable_value(@filename, name, sep)
189
+ TextDataTools.get_variable_value(@filename, name, sep)
190
190
  end
191
191
  #def method_missing(meth, *args)
192
- #if TextFileTools.methods.include? meth
193
- #TextFileTools.send(meth, @filename, *args)
192
+ #if TextDataTools.methods.include? meth
193
+ #TextDataTools.send(meth, @filename, *args)
194
194
  #else
195
195
  #super
196
196
  #end
197
197
  #end
198
198
  end
199
- end # module TextFileTools
199
+ end # module TextDataTools
@@ -1,22 +1,22 @@
1
1
  require 'helper'
2
2
 
3
- class TestTextFileTools < Test::Unit::TestCase
3
+ class TestTextDataTools < Test::Unit::TestCase
4
4
  def test_1d
5
- assert_raise(ArgumentError){TextFileTools.get_1d_array('test/test_dat.dat', true, 2.2)}
6
- assert_raise(ArgumentError){TextFileTools.get_1d_array('test/test_dat.dat',true, /ii\+ temp/, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)}
7
- array = TextFileTools.get_1d_array('test/test_dat.dat', true, /i\+ temp/, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
5
+ assert_raise(ArgumentError){TextDataTools.get_1d_array('test/test_dat.dat', true, 2.2)}
6
+ assert_raise(ArgumentError){TextDataTools.get_1d_array('test/test_dat.dat',true, /ii\+ temp/, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)}
7
+ array = TextDataTools.get_1d_array('test/test_dat.dat', true, /i\+ temp/, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
8
8
  #puts array
9
9
  assert_equal(array.size, 18)
10
10
  assert_equal(array[9].to_f, 0.9753E+09)
11
- array = TextFileTools.get_1d_array_float('test/test_dat.dat', true, /i\+ temp/, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
11
+ array = TextDataTools.get_1d_array_float('test/test_dat.dat', true, /i\+ temp/, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
12
12
  assert_equal(array[9], 0.9753E+09)
13
13
  end
14
14
  def test_2d
15
- array = TextFileTools.get_2d_array('test/test_dat.dat', true, /i\+ temp/, 0, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
15
+ array = TextDataTools.get_2d_array('test/test_dat.dat', true, /i\+ temp/, 0, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
16
16
  assert_equal(array.size, 2)
17
- array = TextFileTools.get_2d_array('test/test_dat.dat', true, /i\+ temp/, 1, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
17
+ array = TextDataTools.get_2d_array('test/test_dat.dat', true, /i\+ temp/, 1, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
18
18
  assert_equal(array.size, 18)
19
- array = TextFileTools.get_2d_array_float('test/test_dat.dat', true, /i\+ temp/, 0, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
19
+ array = TextDataTools.get_2d_array_float('test/test_dat.dat', true, /i\+ temp/, 0, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
20
20
  assert_equal(array[0].size, 9)
21
21
  assert_equal(array[1][0], 0.9753E+09)
22
22
 
@@ -24,15 +24,15 @@ class TestTextFileTools < Test::Unit::TestCase
24
24
 
25
25
  end
26
26
  def test_get_variable
27
- variable = TextFileTools.get_variable_value('test/test_dat_2.dat', 'Q', ':')
27
+ variable = TextDataTools.get_variable_value('test/test_dat_2.dat', 'Q', ':')
28
28
  assert_equal(variable.to_f, 11.989644168449118)
29
- variable = TextFileTools.get_variable_value('test/test_dat_2.dat', 'Fusion power', ':')
29
+ variable = TextDataTools.get_variable_value('test/test_dat_2.dat', 'Fusion power', ':')
30
30
  assert_equal(variable.to_f, 484.34196189744871)
31
31
  end
32
32
  def test_texdatafile_class
33
- file = TextFileTools::TextDataFile.new('test/test_dat_2.dat')
33
+ file = TextDataTools::TextDataFile.new('test/test_dat_2.dat')
34
34
  assert_equal(file.get_variable_value('Alpha power', ':').to_f, 116.90499891894469 )
35
- file = TextFileTools::TextDataFile.new('test/test_dat.dat', true, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
35
+ file = TextDataTools::TextDataFile.new('test/test_dat.dat', true, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:)/)
36
36
  array = file.get_2d_array(/i\+ temp/, /1.*time/)
37
37
  assert_equal(array.size, 2)
38
38
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "text-data-tools"
8
- s.version = "1.0.4"
8
+ s.version = "1.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Edmund Highcock"]
12
- s.date = "2013-06-14"
12
+ s.date = "2013-06-17"
13
13
  s.description = "A small set of tools for reading text based data files into arrays. Works ee.g. for simple columnar data with or without headings."
14
14
  s.email = "edmundhighcock@sourceforge.net"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: text-data-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-14 00:00:00.000000000 Z
12
+ date: 2013-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
@@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  segments:
113
113
  - 0
114
- hash: -2216339992991240693
114
+ hash: 728842535758122685
115
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements: