syc-spector 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/README +17 -0
  2. data/bin/sycspector +7 -0
  3. data/doc/Inspector/Console.html +256 -0
  4. data/doc/Inspector/Options.html +301 -0
  5. data/doc/Inspector/Runner.html +239 -0
  6. data/doc/Inspector/Separator.html +456 -0
  7. data/doc/Inspector.html +157 -0
  8. data/doc/Object.html +165 -0
  9. data/doc/README.html +119 -0
  10. data/doc/TestConsole.html +143 -0
  11. data/doc/TestOptions.html +246 -0
  12. data/doc/TestSeparator.html +270 -0
  13. data/doc/created.rid +11 -0
  14. data/doc/images/add.png +0 -0
  15. data/doc/images/brick.png +0 -0
  16. data/doc/images/brick_link.png +0 -0
  17. data/doc/images/bug.png +0 -0
  18. data/doc/images/bullet_black.png +0 -0
  19. data/doc/images/bullet_toggle_minus.png +0 -0
  20. data/doc/images/bullet_toggle_plus.png +0 -0
  21. data/doc/images/date.png +0 -0
  22. data/doc/images/delete.png +0 -0
  23. data/doc/images/find.png +0 -0
  24. data/doc/images/loadingAnimation.gif +0 -0
  25. data/doc/images/macFFBgHack.png +0 -0
  26. data/doc/images/package.png +0 -0
  27. data/doc/images/page_green.png +0 -0
  28. data/doc/images/page_white_text.png +0 -0
  29. data/doc/images/page_white_width.png +0 -0
  30. data/doc/images/plugin.png +0 -0
  31. data/doc/images/ruby.png +0 -0
  32. data/doc/images/tag_blue.png +0 -0
  33. data/doc/images/tag_green.png +0 -0
  34. data/doc/images/transparent.png +0 -0
  35. data/doc/images/wrench.png +0 -0
  36. data/doc/images/wrench_orange.png +0 -0
  37. data/doc/images/zoom.png +0 -0
  38. data/doc/index.html +94 -0
  39. data/doc/js/darkfish.js +153 -0
  40. data/doc/js/jquery.js +18 -0
  41. data/doc/js/navigation.js +142 -0
  42. data/doc/js/search.js +94 -0
  43. data/doc/js/search_index.js +1 -0
  44. data/doc/js/searcher.js +228 -0
  45. data/doc/rdoc.css +543 -0
  46. data/doc/table_of_contents.html +109 -0
  47. data/lib/inspector/console.rb +60 -0
  48. data/lib/inspector/options.rb +212 -0
  49. data/lib/inspector/pattern.rb +11 -0
  50. data/lib/inspector/runner.rb +31 -0
  51. data/lib/inspector/separator.rb +182 -0
  52. data/sycspector.gemspec +18 -0
  53. data/test/test_console.rb +26 -0
  54. data/test/test_options.rb +115 -0
  55. data/test/test_separator.rb +118 -0
  56. metadata +140 -0
@@ -0,0 +1,212 @@
1
+ require 'optparse'
2
+ require 'io/wait'
3
+
4
+ require_relative 'pattern.rb'
5
+
6
+ # Module Inspector contains the functions related to the command line parsing.
7
+ # Provides the parsed user input in the options hash.
8
+ module Inspector
9
+
10
+ # Parses the provided command line flags, switches and arguments
11
+ class Options
12
+ # Options hold all the parameters used by the application
13
+ attr_reader :options
14
+
15
+ # Initializes Options and parses the provided user input from the command
16
+ # line
17
+ def initialize(argv)
18
+ parse(argv)
19
+ end
20
+
21
+ # After running the application output files are saved in the history.
22
+ # --get_file_from_history-- retrieves the valid or invalid file from the
23
+ # last application invokation. Where type is eather +valid+ or +invalid+.
24
+ #
25
+ # :call-seq:
26
+ # get_file_from_history(type)
27
+ def get_file_from_history(type)
28
+ pattern = Regexp.new('_'+type.to_s)
29
+ File.open(".sycspector.data", 'r') do |file|
30
+ while name = file.gets.chop
31
+ return name unless name.scan(pattern).empty?
32
+ end
33
+ end
34
+ end
35
+
36
+ # Save the results of the last run of the application to +.sycspector.data+.
37
+ # It contains the valid and invalid file as well as the pattern.
38
+ def save_result_files(opts)
39
+ File.open(".sycspector.data", 'w') do |file|
40
+ file.puts opts[:valid_file]
41
+ file.puts opts[:invalid_file]
42
+ file.puts opts[:pattern].to_s
43
+ file.puts opts[:scan_pattern].to_s
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ # Creates the output files valid and invalid files based on the input file's
50
+ # name. If the filename already exists it is copied with a new timestamp.
51
+ #
52
+ # :call-seq:
53
+ # create_output_files(filename)
54
+ def create_output_files(filename)
55
+ timestamp = Time.now.strftime("%Y%m%d-%H%M%S")
56
+ if filename =~ /\d{8}-\d{6}/
57
+ `cp #{filename} #{filename.sub(/\d{8}-\d{6}/, timestamp)}`
58
+ filename.slice!(/\d{8}-\d{6}_(valid|invalid)_/)
59
+ end
60
+ files = {valid_file: "#{timestamp}_valid_#{filename}",
61
+ invalid_file: "#{timestamp}_invalid_#{filename}"}
62
+ end
63
+
64
+ # Parses the provided arguments and stores the value in @options
65
+ #
66
+ # :call-seq:
67
+ # parse(argv)
68
+ def parse(argv)
69
+ @options = {}
70
+ OptionParser.new do |opts|
71
+ opts.banner = "Usage: sycspector input_file [ options ]"
72
+
73
+ # create a switch
74
+
75
+ @options[:individualize] = false
76
+ opts.on("-i", "--individualize",
77
+ "Remove duplicate values") do
78
+ @options[:individualize] = true
79
+ end
80
+
81
+ @options[:sort] = false
82
+ opts.on("-s", "--sort",
83
+ "Sort values") do
84
+ @options[:sort] = true
85
+ end
86
+
87
+ @options[:fix] = false
88
+ opts.on("-f", "--fix",
89
+ "prompt invalid values for fixing") do
90
+ @options[:fix] = true
91
+ end
92
+
93
+ @options[:mode] = 'w'
94
+ opts.on("-a", "--append",
95
+ "Append values to output file OUTFILE") do
96
+ @options[:mode] = 'a'
97
+ end
98
+
99
+ # Create a flag
100
+
101
+ @options[:pattern] = /\A.*\Z/
102
+ @options[:scan_pattern] = /\A.*\Z/
103
+
104
+ opts.on("-p", "--pattern PATTERN",
105
+ "Values that match the pattern are",
106
+ "considered as valid values.",
107
+ "Default matches all.",
108
+ "'sycspector' -p email matches emails") do |pattern|
109
+ if pattern == 'email'
110
+ @options[:pattern] = EMAIL_PATTERN
111
+ @options[:scan_pattern] = ANY_EMAIL_PATTERN
112
+ else
113
+ @options[:pattern] = Regexp.new(pattern)
114
+ scan_pattern = pattern.match(FULL_LINE).to_s
115
+ puts "'#{scan_pattern}' '#{pattern}'"
116
+ pattern = scan_pattern unless scan_pattern.empty?
117
+ @options[:scan_pattern] = Regexp.new(pattern)
118
+ end
119
+ end
120
+
121
+ @options[:delimiter] = ";"
122
+ opts.on("-d", "--delimiter DELIMITER", String,
123
+ "Delimiter between values.",
124
+ "Default delimiter is ';'") do |delimiter|
125
+ @options[:delimiter] = delimiter || ";"
126
+ end
127
+
128
+ opts.on("-o", "--output OUTFILE", String,
129
+ "File name as basis for creation of valid",
130
+ "and invalid file name.",
131
+ "default '<timestamp>_valid_values,",
132
+ "<timestamp>_invalid_values'",
133
+ "where <timestamp> = 'YYmmDD-HHMMSS'") do |outfile|
134
+
135
+ files = create_output_files outfile
136
+ @options[:valid_file] = files[:valid_file]
137
+ @options[:invalid_file] = files[:invalid_file]
138
+ end
139
+
140
+ opts.on("--show [valid|invalid]", [:valid, :invalid],
141
+ "Show the last valid or invalid file",
142
+ "Default is valid") do |show|
143
+ @options[:show] = show || :valid
144
+
145
+ end
146
+
147
+ opts.on("-h", "--help", "Show this message") do
148
+ puts opts
149
+ exit(0)
150
+ end
151
+
152
+ begin
153
+ argv << "-h" if argv.empty?
154
+ opts.parse!(argv)
155
+
156
+ rescue OptionParser::ParseError => e
157
+ STDERR.puts e.message, "\n", opts
158
+ exit(-1)
159
+ end
160
+
161
+ if @options[:fix] and argv.empty?
162
+
163
+ files = {}
164
+ if File.exist?(".sycspector.data")
165
+ File.open(".sycspector.data", 'r') do |file|
166
+ files = create_output_files file.gets.chomp
167
+ argv << file.gets.chomp
168
+ @options[:pattern] = Regexp.new(file.gets.chomp)
169
+ @options[:scan_pattern] = Regexp.new(file.gets.chomp)
170
+ end
171
+ else
172
+ STDERR.puts "--> no sycspector history.\n" +
173
+ " You first have to run sycspector FILENAME"
174
+ exit(-1)
175
+ end
176
+
177
+ unless files.empty?
178
+ @options[:valid_file] = files[:valid_file]
179
+ @options[:invalid_file] = files[:invalid_file]
180
+ end
181
+
182
+ end
183
+
184
+ if @options[:show] and argv.empty?
185
+ unless File.exist?(".sycspector.data")
186
+ STDERR.puts "--> no sycspector history." +
187
+ " You first have to run 'sycspector FILENAME'"
188
+ exit(-1)
189
+ end
190
+ else
191
+ @options[:infile] = argv.shift
192
+
193
+ if @options[:infile].nil?
194
+ STDERR.puts "--> missing input file"
195
+ exit(-1)
196
+ end
197
+
198
+ unless File.exist?(@options[:infile])
199
+ STDERR.puts "--> infile '#{@options[:infile]}' does not exist"
200
+ exit(-1)
201
+ end
202
+
203
+ if @options[:valid_file].nil? or @options[:invalid_file].nil?
204
+ files = create_output_files "values"
205
+ @options[:valid_file] = files[:valid_file]
206
+ @options[:invalid_file] = files[:invalid_file]
207
+ end
208
+ end
209
+ end
210
+ end
211
+ end
212
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Pattern that relizes emails. Matches whole lines only
4
+ EMAIL_PATTERN = /\A[\w!#\$%&'*+\/=?`{|}~^-]+(?:\.[\w!#\$%&'*+\/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}\Z/
5
+
6
+ # Pattern that relizes an email within a line.
7
+ ANY_EMAIL_PATTERN = /[\w!#\$%&'*+\/=?`{|}~^-]+(?:\.[\w!#\$%&'*+\/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}/
8
+
9
+ # Pattern that relizes strings between \A and \Z that is beginning of line and
10
+ # end of line patterns.
11
+ FULL_LINE = /(?<=\\A).*(?=\\Z)/
@@ -0,0 +1,31 @@
1
+ require_relative 'options'
2
+ require_relative 'separator'
3
+
4
+ # Module Inspector contains functions related to running the application
5
+ module Inspector
6
+ # Processes based on the provided command line arguments the scan of the
7
+ # file or shows the last processed files.
8
+ class Runner
9
+
10
+ # Initializes runner and invokes Options with the command line arguments
11
+ # provided
12
+ def initialize(argv)
13
+ @options = Options.new(argv)
14
+ end
15
+
16
+ # Runs the Separator or shows the requested valid or invalid file. To show
17
+ # the file 'less' is used.
18
+ def run
19
+ opts = @options.options
20
+ if opts[:infile]
21
+ separator = Separator.new
22
+ separator.process(opts)
23
+ separator.print_statistics(opts)
24
+ @options.save_result_files opts
25
+ end
26
+ if show = opts[:show]
27
+ system "less #{@options.get_file_from_history show}"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,182 @@
1
+ require_relative 'console'
2
+
3
+ # This module encapsulates functionality related to scanning values for
4
+ # patterns. If a line contains the pattern that line is added to valid files.
5
+ # If the pattern is not found in the line the line is added to invalid files.
6
+ # Lines can if requested to be fixed. The line is presented to the user and the
7
+ # user can eather fix the value by typing the corrected value. Other
8
+ # possibilities are to drop the line, scan the line or just considering the
9
+ # line as valid so it is added to valid values.
10
+ module Inspector
11
+
12
+ # The Separator scans the input file for a provided pattern and prints the
13
+ # results of the scan to the console.
14
+ class Separator
15
+ # The prompt string is presented to the user when values are requested to
16
+ # be fixed. (v)alid will add the value to the valid values without testing
17
+ # against the pattern. (i)nvalid adds the value to the invalid values.
18
+ # (d)rop discards the value, (s)can scans the line to look for the pattern.
19
+ # (f)ix allows to type the corrected value.
20
+ PROMPT_STRING = "-> (v)alid (i)nvalid (d)rop (s)can (f)ix: "
21
+
22
+ # Initializes the Separator and creating a Console object
23
+ def initialize
24
+ @console = Console.new
25
+ end
26
+
27
+ # Prints the results of the invokation of Separator.process
28
+ #
29
+ # :call-seq:
30
+ # print_statistics(opts)
31
+ def print_statistics(opts)
32
+ puts "-> statistics"
33
+ puts " ----------"
34
+ printf("%7s: %4d\n%7s: %4d\n%7s: %4d\n%7s: %4d\n%7s: %4d\n",
35
+ " total", opts[:valid_counter] +
36
+ opts[:invalid_counter] +
37
+ opts[:skip_counter] +
38
+ opts[:double_counter],
39
+ " valid", opts[:valid_counter],
40
+ " invalid", opts[:invalid_counter],
41
+ " drop", opts[:skip_counter],
42
+ " double", opts[:double_counter])
43
+ puts
44
+ puts "-> pattern: #{opts[:pattern].inspect}"
45
+ puts "-> scan pattern: #{opts[:scan_pattern].inspect}"
46
+ puts
47
+ puts "-> files operated on"
48
+ puts " -----------------"
49
+ puts " values read from: #{opts[:infile]}"
50
+ puts " valid values written to: #{opts[:valid_file]}"
51
+ puts " invalid values written to: #{opts[:invalid_file]}"
52
+ if opts[:note]
53
+ puts
54
+ puts "-> Note"
55
+ puts " ----"
56
+ puts opts[:note]
57
+ end
58
+ end
59
+
60
+ # Prompts the PROMPT_STRING and tests the value against the pattern
61
+ #
62
+ # :call-seq:
63
+ # fix(value, pattern) -> hash
64
+ #
65
+ # Return a hash with :value and :answer where :value contains the fixed
66
+ # value and the answer. To test whether the value is valid or invalid the
67
+ # :answer has to checked first.
68
+ def fix(value, pattern)
69
+ choice = value
70
+ result = {}
71
+
72
+ while not pattern.match(choice)
73
+ puts "-> #{choice}?"
74
+ result[:answer] = @console.prompt PROMPT_STRING
75
+ case result[:answer]
76
+ when 'v'
77
+ result[:value] = choice
78
+ break
79
+ when 'i'
80
+ result[:value] = choice
81
+ break
82
+ when 'f'
83
+ print "-> fix: "
84
+ choice = gets.chomp
85
+ print "-> confirm "
86
+ redo
87
+ when 'd'
88
+ result[:value] = value
89
+ break
90
+ when 's'
91
+ result[:value] = value
92
+ break
93
+ end
94
+ end
95
+
96
+ return result
97
+ end
98
+
99
+ # Processes the scan of the lines of the file and add the values eather to
100
+ # the valid or invalid values. The result of the scan will be added to the
101
+ # opts.
102
+ #
103
+ # :call-seq:
104
+ # process(opts)
105
+ def process(opts)
106
+ valid_file = File.open(opts[:valid_file], opts[:mode])
107
+ valid_values = []
108
+
109
+ invalid_file = File.open(opts[:invalid_file], 'w')
110
+ invalid_values = []
111
+
112
+ skip_counter = 0
113
+
114
+ File.open(opts[:infile], 'r') do |file|
115
+ while line = file.gets
116
+ line.chomp.split(opts[:delimiter]).each do |value|
117
+
118
+ match = value.match(opts[:pattern])
119
+
120
+ if match.nil?
121
+ if opts[:fix]
122
+ result = fix value, opts[:pattern]
123
+ case result[:answer]
124
+ when 'v'
125
+ valid_values << result[:value]
126
+ when 'i'
127
+ invalid_values << result[:value]
128
+ when 'd'
129
+ skip_counter += 1
130
+ when 's'
131
+ value.scan(opts[:scan_pattern]).each do |value|
132
+ valid_values << value
133
+ end
134
+ end
135
+ else
136
+ invalid_values << value
137
+ end
138
+ else
139
+ valid_values << match
140
+ end
141
+ end
142
+ end
143
+ end
144
+
145
+ valid_counter = valid_values.size
146
+
147
+ valid_values.uniq! {|value| value.downcase } if opts[:individualize]
148
+ valid_values.sort! if opts[:sort]
149
+
150
+ valid_values.each do |value|
151
+ valid_file.puts value
152
+ end
153
+
154
+ invalid_counter = invalid_values.size
155
+
156
+ invalid_values.uniq! {|value| value.downcase} if opts[:individualize]
157
+ invalid_values.sort! if opts[:sort]
158
+
159
+ invalid_values.each do |value|
160
+ invalid_file.puts value
161
+ end
162
+
163
+ valid_file.close
164
+ invalid_file.close
165
+
166
+ double_counter = valid_counter - valid_values.size +
167
+ invalid_counter - invalid_values.size
168
+
169
+ opts[:valid_counter] = valid_values.size
170
+ opts[:invalid_counter] = invalid_values.size
171
+ opts[:skip_counter] = skip_counter
172
+ opts[:double_counter] = double_counter
173
+ if (invalid_values.size > 0 and not opts[:fix])
174
+ opts[:note] = " You can fix invalid values and append " +
175
+ "to valid with: $ sycspector -fa"
176
+ end
177
+
178
+ end
179
+
180
+ end
181
+
182
+ end
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "syc-spector"
3
+ s.summary =
4
+ "Analyze a file and extract values matching a provided pattern.\n \
5
+ Allow to sort, remove double and manually fix values."
6
+ s.description = File.read(File.join(File.dirname(__FILE__), 'README'))
7
+ s.requirements = ['No requirements']
8
+ s.version = "0.0.1"
9
+ s.author = "Pierre Sugar"
10
+ s.email = "pierre@sugaryourcoffee.de"
11
+ s.homepage = "http://syc.dyndns.org/drupal"
12
+ s.platform = Gem::Platform::RUBY
13
+ s.required_ruby_version = '>=1.9'
14
+ s.files = Dir['**/**']
15
+ s.executables = ['sycspector']
16
+ s.test_files = Dir['test/test*.rb']
17
+ s.has_rdoc = true
18
+ end
@@ -0,0 +1,26 @@
1
+ require 'test/unit'
2
+ require 'shoulda'
3
+ require_relative '../lib/inspector/console'
4
+
5
+ # Tests the Console class
6
+ class TestConsole < Test::Unit::TestCase
7
+
8
+ context "console" do
9
+ should "return value from prompt string" do
10
+ console = Inspector::Console.new
11
+ result = console.prompt "(v)alid, (i)nvalid, (d)rop, (s)can, (f)ix: "
12
+ choices = %w(v i d s f)
13
+ assert choices.index(result) >= 0
14
+ end
15
+
16
+ should "exit with code 0" do
17
+ console = Inspector::Console.new
18
+ begin
19
+ result = console.prompt "No choices are available. To end press Ctrl-c:"
20
+ rescue SystemExit => e
21
+ assert e.status == 0
22
+ end
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,115 @@
1
+ require 'test/unit'
2
+ require 'shoulda'
3
+ require_relative '../lib/inspector/options'
4
+ require_relative '../lib/inspector/pattern'
5
+
6
+ # Test of the Options class
7
+ class TestOptions < Test::Unit::TestCase
8
+
9
+ context "specifying an inputfile that does not exist" do
10
+ should "exit with -1" do
11
+ begin
12
+ opts = Inspector::Options.new(["inputfile"])
13
+ rescue SystemExit => e
14
+ assert e.status == -1
15
+ end
16
+ end
17
+ end
18
+
19
+ context "specifying no input file" do
20
+ should "exit with -1" do
21
+ begin
22
+ opts = Inspector::Options.new([])
23
+ rescue SystemExit => e
24
+ assert e.status == 0
25
+ end
26
+ end
27
+ end
28
+
29
+ context "specifying an inputfile that exists" do
30
+
31
+ # Intializes the input, valid, invalid and history file
32
+ def setup
33
+ puts "in startup"
34
+ File.open('existing', 'w') do |file|
35
+ file.puts "pierre@thesugars.de"
36
+ file.puts "amanda@thesugars.de und pierre@thesugars.de"
37
+ end
38
+ File.open('.sycspector.data', 'w') do |file|
39
+ file.puts "20130113-121212_valid_values"
40
+ file.puts "20130113-121212_invalid_values"
41
+ file.puts "(?-mix:\A[\w!#\$%&'*+\/=?`{|}~^-]+" +
42
+ "(?:\.[\w!#\$%&'*+\/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\.)+" +
43
+ "[a-zA-Z]{2,6}\Z)"
44
+ file.puts "(?-mix:[\w!#\$%&'*+\/=?`{|}~^-]+" +
45
+ "(?:\.[\w!#\$%&'*+\/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\.)+" +
46
+ "[a-zA-Z]{2,6})"
47
+ end
48
+ File.open('20130113-121212_valid_values', 'w') do |file|
49
+ file.puts "pierre@thesugars.de"
50
+ file.puts "amanda@thesugars.de"
51
+ file.puts "pierre@thesugars.de"
52
+ end
53
+ File.open('20130113-121212_invalid_values', 'w') do |file|
54
+ file.puts "amanda@thesugars und pierre@thesugars"
55
+ end
56
+ end
57
+
58
+ # Cleans up the test directory by deleting the files created in setup
59
+ def teardown
60
+ puts "in shutdown"
61
+ `rm existing`
62
+ `rm 20130113-*`
63
+ `rm .sycspector.data`
64
+ end
65
+
66
+ should "return inputfile" do
67
+ opts = Inspector::Options.new(["existing"])
68
+ assert_equal "existing", opts.options[:infile]
69
+ end
70
+
71
+ should "return email pattern" do
72
+ opts = Inspector::Options.new(["-p", "email", "existing"])
73
+ assert_equal EMAIL_PATTERN, opts.options[:pattern]
74
+ assert_equal ANY_EMAIL_PATTERN, opts.options[:scan_pattern]
75
+ end
76
+
77
+ should "return pattern and scan pattern" do
78
+ opts = Inspector::Options.new(["-p", "\\A\\w+.*\\d\\Z", "existing"])
79
+ assert_equal /\A\w+.*\d\Z/, opts.options[:pattern]
80
+ assert_equal /\w+.*\d/, opts.options[:scan_pattern]
81
+ end
82
+
83
+ should "return sort switch" do
84
+ opts = Inspector::Options.new(["-s", "existing"])
85
+ assert_equal true, opts.options[:sort]
86
+ end
87
+
88
+ should "return individualize switch" do
89
+ opts = Inspector::Options.new(["-i", "existing"])
90
+ assert_equal true, opts.options[:individualize]
91
+ end
92
+
93
+ should "return show :valid and infile nil" do
94
+ opts = Inspector::Options.new(["--show"])
95
+ assert_equal :valid, opts.options[:show]
96
+ assert_equal nil, opts.options[:infile]
97
+ opts = Inspector::Options.new(["--show", "valid"])
98
+ assert_equal nil, opts.options[:infile]
99
+ end
100
+
101
+ should "return show :invalid and infile nil" do
102
+ opts = Inspector::Options.new(["--show", "invalid"])
103
+ assert_equal :invalid, opts.options[:show]
104
+ assert_equal nil, opts.options[:infile]
105
+ end
106
+
107
+ should "return fix and invalid file as input file from last invokation" do
108
+ opts = Inspector::Options.new(["-f"])
109
+ assert_equal true, opts.options[:fix]
110
+ assert_equal "20130113-121212_invalid_values", opts.options[:infile]
111
+ end
112
+
113
+ end
114
+
115
+ end