slugize 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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/lib/slugize/version.rb +3 -0
- data/lib/slugize.rb +27 -0
- data/slugize.gemspec +24 -0
- metadata +64 -0
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            require "bundler/gem_tasks"
         | 
    
        data/lib/slugize.rb
    ADDED
    
    | @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            # encoding: UTF-8
         | 
| 2 | 
            +
            require "slugize/version"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Slugize
         | 
| 5 | 
            +
              class String
         | 
| 6 | 
            +
                def slugize
         | 
| 7 | 
            +
                  str = self
         | 
| 8 | 
            +
                  separator = '-'
         | 
| 9 | 
            +
                  re_separator = Regexp.escape(separator)
         | 
| 10 | 
            +
                  str = pl2us(str)
         | 
| 11 | 
            +
                  str.gsub!(/ /, separator)
         | 
| 12 | 
            +
                  str.gsub!(/[^\x00-\x7F]+/, '')
         | 
| 13 | 
            +
                  str.gsub!(/[^a-z0-9\-_\+]+/i, separator)
         | 
| 14 | 
            +
                  str.gsub!(/#{re_separator}{2,}/, separator)
         | 
| 15 | 
            +
                  str.gsub!(/^#{re_separator}|#{re_separator}$/, '')
         | 
| 16 | 
            +
                  str
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
                def pl2us(str)
         | 
| 19 | 
            +
                  str = self.downcase.strip
         | 
| 20 | 
            +
                  chars = {'ą' => 'a', 'ć' => 'c', 'ę' => 'e', 'ł' => 'l', 'ń' => 'n', 'ó' => 'o', 'ś' => 's', 'ź' => 'z', 'ż' => 'z'}
         | 
| 21 | 
            +
                  chars.each do |k,v|
         | 
| 22 | 
            +
                    str.gsub! /#{k}/, "#{v}"
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                  str
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
    
        data/slugize.gemspec
    ADDED
    
    | @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            $:.push File.expand_path("../lib", __FILE__)
         | 
| 3 | 
            +
            require "slugize/version"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |s|
         | 
| 6 | 
            +
              s.name        = "slugize"
         | 
| 7 | 
            +
              s.version     = Slugize::VERSION
         | 
| 8 | 
            +
              s.authors     = ["Kamil Wdowicz"]
         | 
| 9 | 
            +
              s.email       = ["lolmamut@gmail.com"]
         | 
| 10 | 
            +
              s.homepage    = ""
         | 
| 11 | 
            +
              s.summary     = %q{Adds slugize method to Ruby String}
         | 
| 12 | 
            +
              s.description = %q{Adds slugize method to Ruby String}
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              s.rubyforge_project = "slugize"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              s.files         = `git ls-files`.split("\n")
         | 
| 17 | 
            +
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         | 
| 18 | 
            +
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 19 | 
            +
              s.require_paths = ["lib"]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              # specify any dependencies here; for example:
         | 
| 22 | 
            +
              s.add_development_dependency "rspec"
         | 
| 23 | 
            +
              # s.add_runtime_dependency "rest-client"
         | 
| 24 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,64 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: slugize
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
              prerelease: !!null 
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - Kamil Wdowicz
         | 
| 9 | 
            +
            autorequire: !!null 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2012-01-08 00:00:00.000000000 +01:00
         | 
| 13 | 
            +
            default_executable: !!null 
         | 
| 14 | 
            +
            dependencies:
         | 
| 15 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 16 | 
            +
              name: rspec
         | 
| 17 | 
            +
              requirement: &4047790 !ruby/object:Gem::Requirement
         | 
| 18 | 
            +
                none: false
         | 
| 19 | 
            +
                requirements:
         | 
| 20 | 
            +
                - - ! '>='
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: '0'
         | 
| 23 | 
            +
              type: :development
         | 
| 24 | 
            +
              prerelease: false
         | 
| 25 | 
            +
              version_requirements: *4047790
         | 
| 26 | 
            +
            description: Adds slugize method to Ruby String
         | 
| 27 | 
            +
            email:
         | 
| 28 | 
            +
            - lolmamut@gmail.com
         | 
| 29 | 
            +
            executables: []
         | 
| 30 | 
            +
            extensions: []
         | 
| 31 | 
            +
            extra_rdoc_files: []
         | 
| 32 | 
            +
            files:
         | 
| 33 | 
            +
            - .gitignore
         | 
| 34 | 
            +
            - Gemfile
         | 
| 35 | 
            +
            - Rakefile
         | 
| 36 | 
            +
            - lib/slugize.rb
         | 
| 37 | 
            +
            - lib/slugize/version.rb
         | 
| 38 | 
            +
            - slugize.gemspec
         | 
| 39 | 
            +
            has_rdoc: true
         | 
| 40 | 
            +
            homepage: ''
         | 
| 41 | 
            +
            licenses: []
         | 
| 42 | 
            +
            post_install_message: !!null 
         | 
| 43 | 
            +
            rdoc_options: []
         | 
| 44 | 
            +
            require_paths:
         | 
| 45 | 
            +
            - lib
         | 
| 46 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 47 | 
            +
              none: false
         | 
| 48 | 
            +
              requirements:
         | 
| 49 | 
            +
              - - ! '>='
         | 
| 50 | 
            +
                - !ruby/object:Gem::Version
         | 
| 51 | 
            +
                  version: '0'
         | 
| 52 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 53 | 
            +
              none: false
         | 
| 54 | 
            +
              requirements:
         | 
| 55 | 
            +
              - - ! '>='
         | 
| 56 | 
            +
                - !ruby/object:Gem::Version
         | 
| 57 | 
            +
                  version: '0'
         | 
| 58 | 
            +
            requirements: []
         | 
| 59 | 
            +
            rubyforge_project: slugize
         | 
| 60 | 
            +
            rubygems_version: 1.5.0
         | 
| 61 | 
            +
            signing_key: !!null 
         | 
| 62 | 
            +
            specification_version: 3
         | 
| 63 | 
            +
            summary: Adds slugize method to Ruby String
         | 
| 64 | 
            +
            test_files: []
         |