string-scrub 0.0.2 → 0.0.3
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.
- checksums.yaml +13 -5
 - data/.gitignore +1 -0
 - data/.travis.yml +1 -0
 - data/README.md +1 -1
 - data/ext/string/scrub.c +10 -0
 - data/lib/string-scrub.rb +1 -0
 - data/string-scrub.gemspec +4 -4
 - data/test/test_scrub.rb +3 -0
 - metadata +15 -15
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 2 
     | 
    
         
            +
            !binary "U0hBMQ==":
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 4 
     | 
    
         
            +
                ZjUwNzExM2JmYzkzYWUyY2ZkYjhhOWE1ZDYyOTUwMDNlNTZjZGQyNw==
         
     | 
| 
      
 5 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 6 
     | 
    
         
            +
                NzQzODk4Y2IyZGRiZjNjMzdhZWU3MjI1MWRiMDJkOGE1MTcwMTRjZA==
         
     | 
| 
       5 
7 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 9 
     | 
    
         
            +
                MDkyMGE2OGYxZDA2Y2FkNTc3NDc3ZDMyNTZhNjQ5MjlmZWI1MzUyMDg2ODE0
         
     | 
| 
      
 10 
     | 
    
         
            +
                M2E1MWE2YmM4NTBkZTczYTg1ZDg4N2UwNDI5YTJmNWUzNjdiMGEyMjNhMjQ5
         
     | 
| 
      
 11 
     | 
    
         
            +
                YTNmNWU3OTI5ZmM5ZmM2NWRiYmUzMjk4YjZlMjljMDQ1MTMxYmE=
         
     | 
| 
      
 12 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 13 
     | 
    
         
            +
                NGU1MjEyMDQxNmMzMGQwNDg2M2IzN2JiOWI4MzVmNjNmOWNiODEyMGY5OWE5
         
     | 
| 
      
 14 
     | 
    
         
            +
                M2I3ZDJhNjgyNjFkYTBjODlmNDRhM2U3NTQzNTZlNTU3MTE0YTc1MTk2YTZj
         
     | 
| 
      
 15 
     | 
    
         
            +
                MTdjOGFhNWMyYWE5ZDYxZjkyN2NmMWFmZmM2YTVjZDhhYzliN2U=
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/.travis.yml
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    
    
        data/ext/string/scrub.c
    CHANGED
    
    | 
         @@ -11,6 +11,9 @@ 
     | 
|
| 
       11 
11 
     | 
    
         
             
            #endif
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
            #define STR_ENC_GET(str) rb_enc_from_index(ENCODING_GET(str))
         
     | 
| 
      
 14 
     | 
    
         
            +
            #ifndef UNREACHABLE
         
     | 
| 
      
 15 
     | 
    
         
            +
            # define UNREACHABLE
         
     | 
| 
      
 16 
     | 
    
         
            +
            #endif
         
     | 
| 
       14 
17 
     | 
    
         | 
| 
       15 
18 
     | 
    
         
             
            static inline const char *
         
     | 
| 
       16 
19 
     | 
    
         
             
            search_nonascii(const char *p, const char *e)
         
     | 
| 
         @@ -56,7 +59,13 @@ str_compat_and_valid(VALUE str, rb_encoding *enc) 
     | 
|
| 
       56 
59 
     | 
    
         
             
                str = StringValue(str);
         
     | 
| 
       57 
60 
     | 
    
         
             
                cr = rb_enc_str_coderange(str);
         
     | 
| 
       58 
61 
     | 
    
         
             
                if (cr == ENC_CODERANGE_BROKEN) {
         
     | 
| 
      
 62 
     | 
    
         
            +
            #ifdef PRIsVALUE
         
     | 
| 
       59 
63 
     | 
    
         
             
            	rb_raise(rb_eArgError, "replacement must be valid byte sequence '%+"PRIsVALUE"'", str);
         
     | 
| 
      
 64 
     | 
    
         
            +
            #else
         
     | 
| 
      
 65 
     | 
    
         
            +
            	str = rb_inspect(str);
         
     | 
| 
      
 66 
     | 
    
         
            +
            	rb_raise(rb_eArgError, "replacement must be valid byte sequence '%s'", RSTRING_PTR(str));
         
     | 
| 
      
 67 
     | 
    
         
            +
            	RB_GC_GUARD(str);
         
     | 
| 
      
 68 
     | 
    
         
            +
            #endif
         
     | 
| 
       60 
69 
     | 
    
         
             
                }
         
     | 
| 
       61 
70 
     | 
    
         
             
                else if (cr == ENC_CODERANGE_7BIT) {
         
     | 
| 
       62 
71 
     | 
    
         
             
            	rb_encoding *e = STR_ENC_GET(str);
         
     | 
| 
         @@ -76,6 +85,7 @@ str_compat_and_valid(VALUE str, rb_encoding *enc) 
     | 
|
| 
       76 
85 
     | 
    
         
             
            }
         
     | 
| 
       77 
86 
     | 
    
         | 
| 
       78 
87 
     | 
    
         
             
            /**
         
     | 
| 
      
 88 
     | 
    
         
            +
             * @param str the string to be scrubbed
         
     | 
| 
       79 
89 
     | 
    
         
             
             * @param repl the replacement character
         
     | 
| 
       80 
90 
     | 
    
         
             
             * @return If given string is invalid, returns a new string. Otherwise, returns Qnil.
         
     | 
| 
       81 
91 
     | 
    
         
             
             */
         
     | 
    
        data/lib/string-scrub.rb
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'string/scrub'
         
     | 
    
        data/string-scrub.gemspec
    CHANGED
    
    | 
         @@ -3,11 +3,11 @@ lib = File.expand_path('../lib', __FILE__) 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       5 
5 
     | 
    
         
             
              spec.name          = "string-scrub"
         
     | 
| 
       6 
     | 
    
         
            -
              spec.version       = "0.0. 
     | 
| 
      
 6 
     | 
    
         
            +
              spec.version       = "0.0.3"
         
     | 
| 
       7 
7 
     | 
    
         
             
              spec.authors       = ["SHIBATA Hiroshi"]
         
     | 
| 
       8 
8 
     | 
    
         
             
              spec.email         = ["shibata.hiroshi@gmail.com"]
         
     | 
| 
       9 
     | 
    
         
            -
              spec.summary       = %q{String#scrub for Ruby 2.0.0}
         
     | 
| 
       10 
     | 
    
         
            -
              spec.description   = %q{String#scrub for Ruby 2.0.0}
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.summary       = %q{String#scrub for Ruby 2.0.0 and 1.9.3}
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.description   = %q{String#scrub for Ruby 2.0.0 and 1.9.3}
         
     | 
| 
       11 
11 
     | 
    
         
             
              spec.homepage      = "https://github.com/hsbt/string-scrub"
         
     | 
| 
       12 
12 
     | 
    
         
             
              spec.license       = "MIT"
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
         @@ -17,7 +17,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       17 
17 
     | 
    
         
             
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
       18 
18 
     | 
    
         
             
              spec.require_paths = ["lib"]
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
              spec.required_ruby_version     = '>=  
     | 
| 
      
 20 
     | 
    
         
            +
              spec.required_ruby_version     = '>= 1.9.3'
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
              spec.add_development_dependency "bundler"
         
     | 
| 
       23 
23 
     | 
    
         
             
              spec.add_development_dependency "rake"
         
     | 
    
        data/test/test_scrub.rb
    CHANGED
    
    | 
         @@ -43,6 +43,9 @@ class TestScrub < Test::Unit::TestCase 
     | 
|
| 
       43 
43 
     | 
    
         
             
                assert_raise(ArgumentError){ u("\xE3\x81\x82\xE3\x81\x82\xE3\x81").scrub{u("\x81")} }
         
     | 
| 
       44 
44 
     | 
    
         
             
                assert_equal(e("\xA4\xA2\xA2\xAE"), e("\xA4\xA2\xA4").scrub{e("\xA2\xAE")})
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
      
 46 
     | 
    
         
            +
                assert_equal(u("\x81"), u("a\x81").scrub {|c| break c})
         
     | 
| 
      
 47 
     | 
    
         
            +
                assert_raise(ArgumentError) {u("a\x81").scrub {|c| c}}
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
       46 
49 
     | 
    
         
             
                assert_equal("\uFFFD\u3042".encode("UTF-16BE"),
         
     | 
| 
       47 
50 
     | 
    
         
             
                             "\xD8\x00\x30\x42".force_encoding(Encoding::UTF_16BE).
         
     | 
| 
       48 
51 
     | 
    
         
             
                             scrub)
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,44 +1,44 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: string-scrub
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - SHIBATA Hiroshi
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-02-26 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
       15 
15 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
     | 
    
         
            -
                - -  
     | 
| 
      
 17 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
19 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :development
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
     | 
    
         
            -
                - -  
     | 
| 
      
 24 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
26 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
28 
     | 
    
         
             
              name: rake
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
     | 
    
         
            -
                - -  
     | 
| 
      
 31 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
33 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       34 
34 
     | 
    
         
             
              type: :development
         
     | 
| 
       35 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
     | 
    
         
            -
                - -  
     | 
| 
      
 38 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
40 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       41 
     | 
    
         
            -
            description: String#scrub for Ruby 2.0.0
         
     | 
| 
      
 41 
     | 
    
         
            +
            description: String#scrub for Ruby 2.0.0 and 1.9.3
         
     | 
| 
       42 
42 
     | 
    
         
             
            email:
         
     | 
| 
       43 
43 
     | 
    
         
             
            - shibata.hiroshi@gmail.com
         
     | 
| 
       44 
44 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -46,14 +46,15 @@ extensions: 
     | 
|
| 
       46 
46 
     | 
    
         
             
            - ext/string/extconf.rb
         
     | 
| 
       47 
47 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       48 
48 
     | 
    
         
             
            files:
         
     | 
| 
       49 
     | 
    
         
            -
            -  
     | 
| 
       50 
     | 
    
         
            -
            -  
     | 
| 
      
 49 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 50 
     | 
    
         
            +
            - .travis.yml
         
     | 
| 
       51 
51 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       52 
52 
     | 
    
         
             
            - LICENSE.txt
         
     | 
| 
       53 
53 
     | 
    
         
             
            - README.md
         
     | 
| 
       54 
54 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       55 
55 
     | 
    
         
             
            - ext/string/extconf.rb
         
     | 
| 
       56 
56 
     | 
    
         
             
            - ext/string/scrub.c
         
     | 
| 
      
 57 
     | 
    
         
            +
            - lib/string-scrub.rb
         
     | 
| 
       57 
58 
     | 
    
         
             
            - string-scrub.gemspec
         
     | 
| 
       58 
59 
     | 
    
         
             
            - test/test_scrub.rb
         
     | 
| 
       59 
60 
     | 
    
         
             
            homepage: https://github.com/hsbt/string-scrub
         
     | 
| 
         @@ -66,20 +67,19 @@ require_paths: 
     | 
|
| 
       66 
67 
     | 
    
         
             
            - lib
         
     | 
| 
       67 
68 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
       68 
69 
     | 
    
         
             
              requirements:
         
     | 
| 
       69 
     | 
    
         
            -
              - -  
     | 
| 
      
 70 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
       70 
71 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       71 
     | 
    
         
            -
                  version:  
     | 
| 
      
 72 
     | 
    
         
            +
                  version: 1.9.3
         
     | 
| 
       72 
73 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       73 
74 
     | 
    
         
             
              requirements:
         
     | 
| 
       74 
     | 
    
         
            -
              - -  
     | 
| 
      
 75 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
       75 
76 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       76 
77 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       77 
78 
     | 
    
         
             
            requirements: []
         
     | 
| 
       78 
79 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       79 
     | 
    
         
            -
            rubygems_version: 2.2. 
     | 
| 
      
 80 
     | 
    
         
            +
            rubygems_version: 2.2.2
         
     | 
| 
       80 
81 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       81 
82 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       82 
     | 
    
         
            -
            summary: String#scrub for Ruby 2.0.0
         
     | 
| 
      
 83 
     | 
    
         
            +
            summary: String#scrub for Ruby 2.0.0 and 1.9.3
         
     | 
| 
       83 
84 
     | 
    
         
             
            test_files:
         
     | 
| 
       84 
85 
     | 
    
         
             
            - test/test_scrub.rb
         
     | 
| 
       85 
     | 
    
         
            -
            has_rdoc: 
         
     |