jsgoecke-echi_files 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +12 -0
- data/echi_files.gemspec +9 -2
- data/lib/echi_files.rb +10 -6
- data/test/proper_ascii.yml +1044 -0
- data/test/proper_stripped.yml +105799 -0
- data/test/proper_unstripped.yml +52900 -0
- data/test/test_echi_files.rb +53 -0
- metadata +8 -1
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'lib/echi_files'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class EchiFiles_Test < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
#Provide a filename to process as an argument on the commandline
|
9
|
+
binary_file = File.open(File.expand_path("test/example_binary_file"))
|
10
|
+
ascii_file = File.open(File.expand_path("test/example_ascii_file"))
|
11
|
+
@proper_unstripped = YAML::load(File.open(File.expand_path("test/proper_unstripped.yml")))
|
12
|
+
@proper_stripped = YAML::load(File.open(File.expand_path("test/proper_stripped.yml")))
|
13
|
+
@proper_ascii = YAML::load(File.open(File.expand_path("test/proper_ascii.yml")))
|
14
|
+
|
15
|
+
#Create a new EchiFiles object
|
16
|
+
echi_handler = EchiFiles.new
|
17
|
+
|
18
|
+
#Use this to process a binary file
|
19
|
+
file_type = 'BINARY'
|
20
|
+
format = 'EXTENDED'
|
21
|
+
#In some cases the extra_byte is needed
|
22
|
+
extra_byte = true
|
23
|
+
@binary_data = echi_handler.process_file(binary_file, file_type, format, extra_byte)
|
24
|
+
#If you need to strip in characters from the asaiuui field
|
25
|
+
@stripped_data = Array.new
|
26
|
+
@binary_data.each do |data|
|
27
|
+
@stripped_data << echi_handler.strip_special_characters(data, [ "asaiuui" ], [ 0 ])
|
28
|
+
end
|
29
|
+
|
30
|
+
#Use this to process an ASCII file
|
31
|
+
file_type = 'ASCII'
|
32
|
+
format = 'EXTENDED'
|
33
|
+
@ascii_data = echi_handler.process_file(ascii_file, file_type, format, extra_byte)
|
34
|
+
end
|
35
|
+
|
36
|
+
def teardown
|
37
|
+
end
|
38
|
+
|
39
|
+
#Test that processing a binary file works
|
40
|
+
def test_binary_file
|
41
|
+
assert_equal(@proper_unstripped, @binary_data)
|
42
|
+
end
|
43
|
+
|
44
|
+
#Test that characters are stripped properly
|
45
|
+
def test_stripping_characters
|
46
|
+
assert_equal(@proper_stripped, @stripped_data)
|
47
|
+
end
|
48
|
+
|
49
|
+
#Test that processing an ascii file works
|
50
|
+
def test_ascii_file
|
51
|
+
assert_equal(@ascii_data, @proper_ascii)
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsgoecke-echi_files
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Goecke
|
@@ -37,6 +37,13 @@ files:
|
|
37
37
|
- lib/echi_files.rb
|
38
38
|
- lib/extended-definition.yml
|
39
39
|
- lib/standard-definition.yml
|
40
|
+
- test/example_ascii_file
|
41
|
+
- test/example_binary_file
|
42
|
+
- test/proper_ascii.yml
|
43
|
+
- test/proper_stripped.yml
|
44
|
+
- test/proper_unstripped.yml
|
45
|
+
- test/test_echi_files.rb
|
46
|
+
- History.txt
|
40
47
|
- LICENSE
|
41
48
|
- README.textile
|
42
49
|
- echi_files.gemspec
|