scrub 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/VERSION +1 -1
  2. data/lib/scrub.rb +1 -30
  3. data/lib/scrubber.rb +29 -0
  4. data/scrub.gemspec +3 -2
  5. metadata +3 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.1.0
data/lib/scrub.rb CHANGED
@@ -1,34 +1,5 @@
1
+ require 'scrubber'
1
2
  module Scrub
2
- class Scrubber
3
- def initialize(&block)
4
- config(&block) if block_given?
5
- end
6
-
7
- def config
8
- @config = Scrub::Config.new
9
- yield @config
10
- end
11
-
12
- def crawl(data, splitter = /\n/)
13
- lines = data.split(splitter)
14
- while(line = lines.shift)
15
- line.strip!
16
- @config.matchers.each do |matcher, prok|
17
- prok.call(line) if line =~ matcher
18
- end
19
- @config.between_matchers.each do |matcher, options|
20
- if line =~ matcher
21
- end_matcher, prok, conditions = options
22
- next_line = nil
23
- while(next_line = lines.shift) && (next_line !~ end_matcher)
24
- prok.call(next_line) if next_line =~ conditions[:when]
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
31
-
32
3
  class Config
33
4
  attr_accessor :matchers, :between_matchers
34
5
  def initialize
data/lib/scrubber.rb ADDED
@@ -0,0 +1,29 @@
1
+ class Scrubber
2
+ def initialize(&block)
3
+ config(&block) if block_given?
4
+ end
5
+
6
+ def config
7
+ @config = Scrub::Config.new
8
+ yield @config
9
+ end
10
+
11
+ def scrub(data, splitter = /\n/)
12
+ lines = data.split(splitter)
13
+ while(line = lines.shift)
14
+ line.strip!
15
+ @config.matchers.each do |matcher, prok|
16
+ prok.call(line) if line =~ matcher
17
+ end
18
+ @config.between_matchers.each do |matcher, options|
19
+ if line =~ matcher
20
+ end_matcher, prok, conditions = options
21
+ next_line = nil
22
+ while(next_line = lines.shift) && (next_line !~ end_matcher)
23
+ prok.call(next_line) if next_line =~ conditions[:when]
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
data/scrub.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{scrub}
8
- s.version = "0.0.1"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matthew Mongeau"]
12
- s.date = %q{2009-12-29}
12
+ s.date = %q{2010-02-02}
13
13
  s.description = %q{Scrub files with ease and elbow grease}
14
14
  s.email = %q{matt@toastyapps.com}
15
15
  s.files = [
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  "Readme.textile",
19
19
  "VERSION",
20
20
  "lib/scrub.rb",
21
+ "lib/scrubber.rb",
21
22
  "scrub.gemspec"
22
23
  ]
23
24
  s.homepage = %q{http://github.com/toastyapps/scrub}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Mongeau
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-29 00:00:00 -05:00
12
+ date: 2010-02-02 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -27,6 +27,7 @@ files:
27
27
  - Readme.textile
28
28
  - VERSION
29
29
  - lib/scrub.rb
30
+ - lib/scrubber.rb
30
31
  - scrub.gemspec
31
32
  has_rdoc: true
32
33
  homepage: http://github.com/toastyapps/scrub