scrub_rb 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,4 +3,7 @@ rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
5
  - jruby-19mode
6
- - jruby-20mode
6
+ matrix:
7
+ include:
8
+ - rvm: jruby
9
+ env: JRUBY_OPTS="--2.0"
@@ -22,8 +22,8 @@ module ScrubRb
22
22
  :replace => '?' )
23
23
  end
24
24
 
25
- result = ""
26
- bad_chars = ""
25
+ result = "".force_encoding("BINARY")
26
+ bad_chars = "".force_encoding("BINARY")
27
27
  bad_char_flag = false # weirdly, optimization to use flag
28
28
 
29
29
  str.chars.each do |c|
@@ -42,6 +42,8 @@ module ScrubRb
42
42
  scrub_replace(result, bad_chars, replacement, block)
43
43
  end
44
44
 
45
+ result.force_encoding(str.encoding)
46
+
45
47
  return result
46
48
  end
47
49
 
@@ -1,3 +1,3 @@
1
1
  module ScrubRb
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -58,6 +58,15 @@ describe "ScrubRb" do
58
58
  ScrubRb.scrub(@bad_bytes_utf8, "*").must_equal("M*xico")
59
59
  end
60
60
 
61
+ it "preserves encoding with replacement string" do
62
+ input = "good".force_encoding("UTF-8")
63
+ assert_equal input.encoding.name, ScrubRb.scrub(input, "*").encoding.name
64
+ assert_equal input.encoding.name, ScrubRb.scrub(input).encoding.name
65
+
66
+ assert_equal "UTF-8", ScrubRb.scrub(@bad_bytes_utf8, "*").encoding.name
67
+ assert_equal "UTF-8", ScrubRb.scrub(@bad_bytes_utf8).encoding.name
68
+ end
69
+
61
70
  it "replaces with empty string" do
62
71
  ScrubRb.scrub(@bad_bytes_utf8, '').must_equal("Mxico")
63
72
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrub_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Jonathan Rochkind
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-07-16 00:00:00.000000000 Z
12
+ date: 2014-09-16 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,15 +30,17 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  description:
@@ -62,28 +67,30 @@ files:
62
67
  homepage: https://github.com/jrochkind/scrub_rb
63
68
  licenses:
64
69
  - MIT
65
- metadata: {}
66
70
  post_install_message:
67
71
  rdoc_options: []
68
72
  require_paths:
69
73
  - lib
70
74
  required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
71
76
  requirements:
72
- - - '>='
77
+ - - ! '>='
73
78
  - !ruby/object:Gem::Version
74
79
  version: '0'
75
80
  required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
76
82
  requirements:
77
- - - '>='
83
+ - - ! '>='
78
84
  - !ruby/object:Gem::Version
79
85
  version: '0'
80
86
  requirements: []
81
87
  rubyforge_project:
82
- rubygems_version: 2.0.3
88
+ rubygems_version: 1.8.23
83
89
  signing_key:
84
- specification_version: 4
90
+ specification_version: 3
85
91
  summary: Pure-ruby polyfill of MRI 2.1 String#scrub, for ruby 1.9 and 2.0 any interpreter
86
92
  test_files:
87
93
  - test/borrowed_string_scrub_test.rb
88
94
  - test/monkey_patch_test.rb
89
95
  - test/scrub_test.rb
96
+ has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 644acb6ff368a1469fabcce3a3a41b8c3389fbb1
4
- data.tar.gz: 4b80ec9d61708227bb65a43bb799d66b48b2e14f
5
- SHA512:
6
- metadata.gz: 9ad061344fd9587e8ed1eb39404e828a05f357a769c9838043870cb7034efaa763f2a827322043e5fa943e17ff6318df42f89050c4de7fc4aeba7d876a823c7c
7
- data.tar.gz: 69b9a20817599ed7647ad6007f7c8b123f247cd32484719b88d7f14ab3e29879fc5d7b1d6d1225c209477fa5eb6e8df2f19444debd75578089b02b8acc1c8685