errata 1.0.1 → 1.0.2

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.rdoc CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Correct strings based on remote errata files.
4
4
 
5
+ ==UTF-8
6
+
7
+ Assumes all input strings are UTF-8. Otherwise there can be problems with Ruby 1.9 and Regexp::FIXEDENCODING. Specifically, ASCII-8BIT regexps might be applied to UTF-8 strings (or vice-versa), resulting in Encoding::CompatibilityError.
8
+
5
9
  ==Real-life usage
6
10
 
7
11
  Used by data_miner (http://github.com/seamusabshere/data_miner)
data/Rakefile CHANGED
@@ -21,3 +21,5 @@ begin
21
21
  rescue LoadError
22
22
  puts "Rdoc is not available"
23
23
  end
24
+
25
+ task :default => :test
data/errata.gemspec CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
 
22
22
  s.add_dependency 'activesupport', '>=2.3.4'
23
- s.add_dependency 'remote_table', '~>1'
23
+ s.add_dependency 'remote_table', '>=1.1.7'
24
+ s.add_dependency 'to_regexp', '>= 0.0.2'
24
25
  s.add_development_dependency 'test-unit'
25
26
  s.add_development_dependency 'shoulda'
26
- s.add_development_dependency 'ruby-debug'
27
27
  end
data/lib/errata.rb CHANGED
@@ -38,10 +38,12 @@ class Errata
38
38
  end
39
39
 
40
40
  def errata
41
- @errata ||= (options['table'] ? options['table'] : ::RemoteTable.new(options.except('responder'))).map do |erratum_description|
42
- next unless ERRATUM_TYPES.include? erratum_description['action']
43
- "::Errata::Erratum::#{erratum_description['action'].camelcase}".constantize.new self, erratum_description
44
- end.compact
41
+ @errata ||= (options['table'] ? options['table'] : ::RemoteTable.new(options.except('responder'))).inject([]) do |memo, erratum_description|
42
+ if ERRATUM_TYPES.include? erratum_description['action']
43
+ memo.push "::Errata::Erratum::#{erratum_description['action'].camelcase}".constantize.new self, erratum_description
44
+ end
45
+ memo
46
+ end
45
47
  end
46
48
 
47
49
  def rejections
@@ -1,3 +1,5 @@
1
+ require 'to_regexp'
2
+
1
3
  class Errata
2
4
  class Erratum
3
5
  autoload :Delete, 'errata/erratum/delete'
@@ -33,12 +35,6 @@ class Errata
33
35
  !!(conditions_match?(row) and expression_matches?(row))
34
36
  end
35
37
 
36
- def correct!(row, &blk)
37
- return :skipped unless targets? row
38
- yield if block_given?
39
- :corrected
40
- end
41
-
42
38
  def expression_matches?(row)
43
39
  return true if matching_expression.blank? or section.blank?
44
40
  if matching_expression.is_a? ::Regexp
@@ -53,20 +49,14 @@ class Errata
53
49
  end
54
50
 
55
51
  def matching_expression
56
- return @_matching_expression[0] if @_matching_expression.is_a? ::Array
57
- @_matching_expression = []
58
- @_matching_expression[0] = if options['x'].blank?
52
+ return @matching_expression[0] if @matching_expression.is_a? ::Array
53
+ @matching_expression = []
54
+ @matching_expression[0] = if options['x'].blank?
59
55
  nil
60
- elsif options['x'].start_with? '/'
61
- if options['x'].end_with? 'i'
62
- ci = true
63
- expr = options['x'].chop
64
- else
65
- ci = false
66
- expr = options['x'].dup
56
+ elsif (options['x'].start_with?('/') and options['x'].end_with?('/')) or options['x'].start_with?('%r{')
57
+ if as_regexp = options['x'].as_regexp
58
+ ::Regexp.new(*as_regexp)
67
59
  end
68
- expr.gsub! /\A\/|\/\z/, ''
69
- ::Regexp.new expr, ci
70
60
  elsif /\Aabbr\((.*)\)\z/.match options['x']
71
61
  abbr = $1.split(/(\w\??)/).reject { |a| a == '' }.join('\.?\s?') + '\.?([^\w\.]|\z)'
72
62
  expr = '(\A|\s)' + abbr
@@ -77,7 +67,7 @@ class Errata
77
67
  else
78
68
  options['x']
79
69
  end
80
- @_matching_expression[0]
70
+ @matching_expression[0]
81
71
  end
82
72
  end
83
73
  end
@@ -7,7 +7,7 @@ class Errata
7
7
  end
8
8
 
9
9
  def correct!(row)
10
- super(row) do
10
+ if targets? row
11
11
  row[section].gsub! matching_expression, backfill
12
12
  end
13
13
  end
@@ -1,9 +1,6 @@
1
1
  class Errata
2
2
  class Erratum
3
3
  class Reject < Erratum
4
- def correct!
5
- raise "rejections don't correct"
6
- end
7
4
  end
8
5
  end
9
6
  end
@@ -6,7 +6,7 @@ class Errata
6
6
  end
7
7
 
8
8
  def correct!(row)
9
- super(row) do
9
+ if targets? row
10
10
  if matching_expression.blank?
11
11
  row[section] = correction.dup
12
12
  else
@@ -10,7 +10,7 @@ class Errata
10
10
  end
11
11
 
12
12
  def correct!(row)
13
- super(row) do
13
+ if targets? row
14
14
  row[section].gsub! special_matcher(row), ''
15
15
  end
16
16
  end
@@ -9,7 +9,7 @@ class Errata
9
9
  end
10
10
 
11
11
  def correct!(row)
12
- super(row) do
12
+ if targets? row
13
13
  row[section].gsub!(matching_expression) { |match| match.send string_method }
14
14
  end
15
15
  end
@@ -6,7 +6,7 @@ class Errata
6
6
  end
7
7
 
8
8
  def correct!(row)
9
- super(row) do
9
+ if targets? row
10
10
  row[section] = necessary_and_sufficient_prefix.dup
11
11
  end
12
12
  end
@@ -1,3 +1,3 @@
1
1
  class Errata
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
data/test/helper.rb CHANGED
@@ -7,9 +7,6 @@ end
7
7
  Bundler.setup
8
8
  require 'test/unit'
9
9
  require 'shoulda'
10
- unless RUBY_VERSION >= '1.9'
11
- require 'ruby-debug'
12
- end
13
10
  $LOAD_PATH.unshift(File.dirname(__FILE__))
14
11
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
15
12
  require 'errata'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: errata
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
4
+ hash: 19
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Seamus Abshere
@@ -16,8 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-01-25 00:00:00 -06:00
20
- default_executable:
19
+ date: 2011-04-26 00:00:00 Z
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
22
  name: activesupport
@@ -41,30 +40,34 @@ dependencies:
41
40
  requirement: &id002 !ruby/object:Gem::Requirement
42
41
  none: false
43
42
  requirements:
44
- - - ~>
43
+ - - ">="
45
44
  - !ruby/object:Gem::Version
46
- hash: 1
45
+ hash: 29
47
46
  segments:
48
47
  - 1
49
- version: "1"
48
+ - 1
49
+ - 7
50
+ version: 1.1.7
50
51
  type: :runtime
51
52
  version_requirements: *id002
52
53
  - !ruby/object:Gem::Dependency
53
- name: test-unit
54
+ name: to_regexp
54
55
  prerelease: false
55
56
  requirement: &id003 !ruby/object:Gem::Requirement
56
57
  none: false
57
58
  requirements:
58
59
  - - ">="
59
60
  - !ruby/object:Gem::Version
60
- hash: 3
61
+ hash: 27
61
62
  segments:
62
63
  - 0
63
- version: "0"
64
- type: :development
64
+ - 0
65
+ - 2
66
+ version: 0.0.2
67
+ type: :runtime
65
68
  version_requirements: *id003
66
69
  - !ruby/object:Gem::Dependency
67
- name: shoulda
70
+ name: test-unit
68
71
  prerelease: false
69
72
  requirement: &id004 !ruby/object:Gem::Requirement
70
73
  none: false
@@ -78,7 +81,7 @@ dependencies:
78
81
  type: :development
79
82
  version_requirements: *id004
80
83
  - !ruby/object:Gem::Dependency
81
- name: ruby-debug
84
+ name: shoulda
82
85
  prerelease: false
83
86
  requirement: &id005 !ruby/object:Gem::Requirement
84
87
  none: false
@@ -119,7 +122,6 @@ files:
119
122
  - lib/errata/version.rb
120
123
  - test/helper.rb
121
124
  - test/test_old_syntax.rb
122
- has_rdoc: true
123
125
  homepage: https://github.com/seamusabshere/errata
124
126
  licenses: []
125
127
 
@@ -149,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
151
  requirements: []
150
152
 
151
153
  rubyforge_project: errata
152
- rubygems_version: 1.3.7
154
+ rubygems_version: 1.7.2
153
155
  signing_key:
154
156
  specification_version: 3
155
157
  summary: Correct strings based on remote errata files