regexp-match-polyfill 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eb3a1f8807ca2c7c61a18d1092c5d6e2ba79aae4
4
+ data.tar.gz: 77243be2b75232def788d8b19559f96edbc7ade8
5
+ SHA512:
6
+ metadata.gz: e506741f1fe9f128c79510815e6c77d7d6e11a63465a8144a813eb693d20f8a4f1c07f608208bc93c9025334b95c9bf357fb63c64c48b73389f0e6a469075531
7
+ data.tar.gz: fed920f6ae019cf3d45d668bfa3dc6511879ff7a73c987774ab14b75833723bac3bbd65b20036c74ab9d2bd2b7af3e0c46e9347930b6c74d56b490a51f5322de
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ .ruby-version
4
+ pkg/
5
+ tmp/
6
+ /.idea/
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.3.3
5
+
6
+ cache: bundler
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ source 'https://rubygems.org'
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,24 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ regexp-match-polyfill (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ power_assert (1.0.1)
10
+ rake (12.0.0)
11
+ test-unit (3.2.3)
12
+ power_assert
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ bundler (~> 1.7)
19
+ rake (~> 12.0)
20
+ regexp-match-polyfill!
21
+ test-unit (~> 3.2)
22
+
23
+ BUNDLED WITH
24
+ 1.14.3
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ ## Implements Regexp#match? and String#match? in Ruby < 2.4.
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/regexp-match-polyfill.svg)](https://badge.fury.io/rb/regexp-match-polyfill)
4
+ [![Build Status](https://travis-ci.org/yivo/regexp-match-polyfill.svg?branch=master)](https://travis-ci.org/yivo/regexp-match-polyfill)
5
+
6
+ ## Installing gem
7
+ Add to your Gemfile:
8
+ ```ruby
9
+ gem 'regexp-match-polyfill', '~> 1.0'
10
+ ```
11
+
12
+ ## Running tests
13
+ Install bundler:
14
+ ```bash
15
+ gem install bundler
16
+ ```
17
+
18
+ Install dependencies:
19
+ ```bash
20
+ cd regexp-match-polyfill && bundle
21
+ ```
22
+
23
+ Run tests:
24
+ ```bash
25
+ cd regexp-match-polyfill && bundle exec rake test
26
+ ```
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new { |t| t.libs << 'test' }
7
+
8
+ task default: :test
@@ -0,0 +1,21 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ unless Regexp.instance_methods.include?(:match?) && String.instance_methods.include?(:match?)
5
+ module RegexpMatchPolyfill
6
+ module RegexpExtension
7
+ def match?(string, position = 0)
8
+ !!(string[position..-1] =~ self)
9
+ end
10
+ end
11
+
12
+ module StringExtension
13
+ def match?(regexp, position = 0)
14
+ !!(self[position..-1] =~ regexp)
15
+ end
16
+ end
17
+ end
18
+
19
+ Regexp.include RegexpMatchPolyfill::RegexpExtension
20
+ String.include RegexpMatchPolyfill::StringExtension
21
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ module RegexpMatchPolyfill
5
+ VERSION = '1.0.0'
6
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ require File.expand_path('../lib/regexp-match-polyfill/version', __FILE__)
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'regexp-match-polyfill'
8
+ s.version = RegexpMatchPolyfill::VERSION
9
+ s.author = 'Yaroslav Konoplov'
10
+ s.email = 'eahome00@gmail.com'
11
+ s.summary = 'Implements Regexp#match? and String#match? in Ruby < 2.4.'
12
+ s.description = 'Implements Regexp#match? and String#match? in Ruby < 2.4.'
13
+ s.homepage = 'https://github.com/yivo/regexp-match-polyfill'
14
+ s.license = 'MIT'
15
+
16
+ s.files = `git ls-files -z`.split("\x0")
17
+ s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
18
+ s.require_paths = ['lib']
19
+
20
+ s.add_development_dependency 'bundler', '~> 1.7'
21
+ s.add_development_dependency 'rake', '~> 12.0'
22
+ s.add_development_dependency 'test-unit', '~> 3.2'
23
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler'
5
+ Bundler.require :default, :development, :test
6
+
7
+ class RegexpMatchPolyfillTest < Test::Unit::TestCase
8
+ def test_regexp_match
9
+ assert_true(/foo/.match?('foo'))
10
+ assert_false(/bar/.match?('foo'))
11
+ end
12
+
13
+ def test_string_match
14
+ assert_true 'foo'.match?(/foo/)
15
+ assert_false 'foo'.match?(/bar/)
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: regexp-match-polyfill
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Yaroslav Konoplov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
55
+ description: Implements Regexp#match? and String#match? in Ruby < 2.4.
56
+ email: eahome00@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - ".gitignore"
62
+ - ".travis.yml"
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - README.md
66
+ - Rakefile
67
+ - lib/regexp-match-polyfill.rb
68
+ - lib/regexp-match-polyfill/version.rb
69
+ - regexp-match-polyfill.gemspec
70
+ - test/test-regexp-match-polyfill.rb
71
+ homepage: https://github.com/yivo/regexp-match-polyfill
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.6.8
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Implements Regexp#match? and String#match? in Ruby < 2.4.
95
+ test_files:
96
+ - test/test-regexp-match-polyfill.rb