syc-spector 0.0.1
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/README +17 -0
- data/bin/sycspector +7 -0
- data/doc/Inspector/Console.html +256 -0
- data/doc/Inspector/Options.html +301 -0
- data/doc/Inspector/Runner.html +239 -0
- data/doc/Inspector/Separator.html +456 -0
- data/doc/Inspector.html +157 -0
- data/doc/Object.html +165 -0
- data/doc/README.html +119 -0
- data/doc/TestConsole.html +143 -0
- data/doc/TestOptions.html +246 -0
- data/doc/TestSeparator.html +270 -0
- data/doc/created.rid +11 -0
- data/doc/images/add.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +94 -0
- data/doc/js/darkfish.js +153 -0
- data/doc/js/jquery.js +18 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search.js +94 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searcher.js +228 -0
- data/doc/rdoc.css +543 -0
- data/doc/table_of_contents.html +109 -0
- data/lib/inspector/console.rb +60 -0
- data/lib/inspector/options.rb +212 -0
- data/lib/inspector/pattern.rb +11 -0
- data/lib/inspector/runner.rb +31 -0
- data/lib/inspector/separator.rb +182 -0
- data/sycspector.gemspec +18 -0
- data/test/test_console.rb +26 -0
- data/test/test_options.rb +115 -0
- data/test/test_separator.rb +118 -0
- metadata +140 -0
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'shoulda'
|
3
|
+
require_relative '../lib/inspector/separator'
|
4
|
+
|
5
|
+
# Tests the Separator class
|
6
|
+
class TestSeparator < Test::Unit::TestCase
|
7
|
+
|
8
|
+
# Options used for invoking the Separator
|
9
|
+
@options = {}
|
10
|
+
|
11
|
+
context "Process" do
|
12
|
+
|
13
|
+
# Initialize the @options
|
14
|
+
def setup
|
15
|
+
@options = {individualize: false, sort: false, fix: false, mode: 'w',
|
16
|
+
pattern: /\A\w+@\w+\.de\Z/, scan_pattern: /\w+@\w+\.de/,
|
17
|
+
delimiter: ";", valid_file: "20130113_121212_valid_values",
|
18
|
+
infile: "inputfile",
|
19
|
+
invalid_file: "20130113_121212_invalid_values", show: :valid}
|
20
|
+
end
|
21
|
+
|
22
|
+
# Initilize the infile with provided values and separating the values with
|
23
|
+
# the provided separator
|
24
|
+
def initialize_infile(values = [], separator)
|
25
|
+
File.open(@options[:infile], 'w') do |file|
|
26
|
+
first = true
|
27
|
+
values.each do |value|
|
28
|
+
if first
|
29
|
+
first = false
|
30
|
+
else
|
31
|
+
file.puts separator
|
32
|
+
end
|
33
|
+
file.puts value
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Overrides some of the standard @optinons initialized in setup
|
39
|
+
def initialize_options(opts={})
|
40
|
+
opts.each do |key, value|
|
41
|
+
@options[key] = value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
should "default processing" do
|
46
|
+
initialize_infile ["pierre@thesugars.de",
|
47
|
+
"amanda@thesugars.de and pierre@thesugars.de"], ";"
|
48
|
+
sep = Inspector::Separator.new
|
49
|
+
|
50
|
+
sep.process(@options)
|
51
|
+
|
52
|
+
valid_result = ["pierre@thesugars.de"]
|
53
|
+
|
54
|
+
File.open(@options[:valid_file]).each_line.with_index do |line, index|
|
55
|
+
assert_equal valid_result[index], line.chomp
|
56
|
+
end
|
57
|
+
|
58
|
+
invalid_result = ["amanda@thesugars.de and pierre@thesugars.de"]
|
59
|
+
|
60
|
+
File.open(@options[:invalid_file]).each_line.with_index do |line, index|
|
61
|
+
assert_equal invalid_result[index], line.chomp
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
should "individualize" do
|
66
|
+
initialize_infile ["pierre@thesugars.de", "pierre@thesugars.de",
|
67
|
+
"amanda@thesugars.de"], ";"
|
68
|
+
initialize_options({individualize: true})
|
69
|
+
|
70
|
+
sep = Inspector::Separator.new
|
71
|
+
|
72
|
+
sep.process(@options)
|
73
|
+
|
74
|
+
valid_result = ["pierre@thesugars.de", "amanda@thesugars.de"]
|
75
|
+
|
76
|
+
File.open(@options[:valid_file]).each_line.with_index do |line, index|
|
77
|
+
assert_equal valid_result[index], line.chomp
|
78
|
+
end
|
79
|
+
|
80
|
+
File.open(@options[:invalid_file]).each_line.with_index do |line, index|
|
81
|
+
assert false
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
should "sort" do
|
86
|
+
content = ["pierre@thesugars.de", "david@thesugars.de",
|
87
|
+
"amanda@thesugars.de", "fabian@thesugars.de",
|
88
|
+
"rene@thesugars.de", "sarah@thesugars.de",
|
89
|
+
"jonah@thesugars.de"]
|
90
|
+
initialize_infile content
|
91
|
+
valid_result = content.sort
|
92
|
+
|
93
|
+
sep = Inspector::Separator.new
|
94
|
+
|
95
|
+
sep.process(@options)
|
96
|
+
|
97
|
+
File.open(@options[:invalid_file]).each_line.with_index do |line, index|
|
98
|
+
assert_equal valid_result[index], line.chomp
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
should "show" do
|
104
|
+
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
should "fix" do
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
should "fix and append" do
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: syc-spector
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Pierre Sugar
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-15 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! '# The sycspector scans a file for patterns provided on the command
|
15
|
+
line.
|
16
|
+
|
17
|
+
# Lines that match the pattern are saved to a valid file and those lines that
|
18
|
+
|
19
|
+
# don''t match the pattern are added to an invalid file.
|
20
|
+
|
21
|
+
# The valid and invalid files as well as the used pattern are stored in a
|
22
|
+
|
23
|
+
# history file. The saved values are used for a subsequent call to sycspector
|
24
|
+
|
25
|
+
# with --show and -f for fix.
|
26
|
+
|
27
|
+
#
|
28
|
+
|
29
|
+
# Invokation Examples
|
30
|
+
|
31
|
+
# sycspector mail_addresses -p email
|
32
|
+
|
33
|
+
# searches for email addresses in the provided file ''email_addresses''
|
34
|
+
|
35
|
+
#
|
36
|
+
|
37
|
+
# Lines that are not recognized can be prompted, fixed and appended to the
|
38
|
+
|
39
|
+
# valid file with
|
40
|
+
|
41
|
+
# sycspector -fa
|
42
|
+
|
43
|
+
#
|
44
|
+
|
45
|
+
# To show the result of the invokation use
|
46
|
+
|
47
|
+
# sycspector --show
|
48
|
+
|
49
|
+
'
|
50
|
+
email: pierre@sugaryourcoffee.de
|
51
|
+
executables:
|
52
|
+
- sycspector
|
53
|
+
extensions: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- test/test_options.rb
|
57
|
+
- test/test_separator.rb
|
58
|
+
- test/test_console.rb
|
59
|
+
- lib/inspector/separator.rb
|
60
|
+
- lib/inspector/pattern.rb
|
61
|
+
- lib/inspector/options.rb
|
62
|
+
- lib/inspector/console.rb
|
63
|
+
- lib/inspector/runner.rb
|
64
|
+
- doc/Inspector.html
|
65
|
+
- doc/Object.html
|
66
|
+
- doc/table_of_contents.html
|
67
|
+
- doc/created.rid
|
68
|
+
- doc/js/searcher.js
|
69
|
+
- doc/js/search.js
|
70
|
+
- doc/js/navigation.js
|
71
|
+
- doc/js/search_index.js
|
72
|
+
- doc/js/jquery.js
|
73
|
+
- doc/js/darkfish.js
|
74
|
+
- doc/index.html
|
75
|
+
- doc/README.html
|
76
|
+
- doc/images/bullet_black.png
|
77
|
+
- doc/images/bullet_toggle_plus.png
|
78
|
+
- doc/images/package.png
|
79
|
+
- doc/images/wrench.png
|
80
|
+
- doc/images/page_white_width.png
|
81
|
+
- doc/images/wrench_orange.png
|
82
|
+
- doc/images/delete.png
|
83
|
+
- doc/images/page_green.png
|
84
|
+
- doc/images/ruby.png
|
85
|
+
- doc/images/tag_green.png
|
86
|
+
- doc/images/bug.png
|
87
|
+
- doc/images/transparent.png
|
88
|
+
- doc/images/bullet_toggle_minus.png
|
89
|
+
- doc/images/zoom.png
|
90
|
+
- doc/images/brick.png
|
91
|
+
- doc/images/page_white_text.png
|
92
|
+
- doc/images/find.png
|
93
|
+
- doc/images/add.png
|
94
|
+
- doc/images/brick_link.png
|
95
|
+
- doc/images/date.png
|
96
|
+
- doc/images/loadingAnimation.gif
|
97
|
+
- doc/images/macFFBgHack.png
|
98
|
+
- doc/images/plugin.png
|
99
|
+
- doc/images/tag_blue.png
|
100
|
+
- doc/rdoc.css
|
101
|
+
- doc/TestSeparator.html
|
102
|
+
- doc/TestOptions.html
|
103
|
+
- doc/Inspector/Console.html
|
104
|
+
- doc/Inspector/Separator.html
|
105
|
+
- doc/Inspector/Options.html
|
106
|
+
- doc/Inspector/Runner.html
|
107
|
+
- doc/TestConsole.html
|
108
|
+
- sycspector.gemspec
|
109
|
+
- bin/sycspector
|
110
|
+
- README
|
111
|
+
homepage: http://syc.dyndns.org/drupal
|
112
|
+
licenses: []
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '1.9'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements:
|
130
|
+
- No requirements
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 1.8.24
|
133
|
+
signing_key:
|
134
|
+
specification_version: 3
|
135
|
+
summary: Analyze a file and extract values matching a provided pattern. Allow to sort,
|
136
|
+
remove double and manually fix values.
|
137
|
+
test_files:
|
138
|
+
- test/test_options.rb
|
139
|
+
- test/test_separator.rb
|
140
|
+
- test/test_console.rb
|