vertere 0.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of vertere might be problematic. Click here for more details.

checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4a641f9117b0d3b6ab07a8595792e79f6bc71ae20fe0be591ae65bee3ed0d27a
4
+ data.tar.gz: d33e205e5cfbb5798f5702ae88e56f43ff1f143a3ee006bfc883fcbe80eae842
5
+ SHA512:
6
+ metadata.gz: 42f537af8351c21642c115383fbfdb93990ac7393d1df8fd0ac1549e61fd8d89bf26cd7824e1bb3374f0320ca00adf3b5c43497230c73d0d3130c24afad22cde
7
+ data.tar.gz: a5e4eef9cc68ae5f51f6d06602ddad7a3b52498d6b885e719e1416f3dcac3d00587f518805fd653b140b67a055a87cd5d451ad98677180ed8339cbf24db352c3
data/.gitignore ADDED
@@ -0,0 +1,32 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ coverage.data
7
+ InstalledFiles
8
+ lib/bundler/man
9
+ pkg
10
+ rdoc
11
+ spec/reports
12
+ test/tmp
13
+ test/version_tmp
14
+ tmp
15
+
16
+ # bundler
17
+ vendor/
18
+
19
+ # YARD artifacts
20
+ .yardoc
21
+ _yardoc
22
+ doc/
23
+
24
+ # tmp-old
25
+ .old
26
+
27
+ # editor
28
+ *~
29
+ .redcar
30
+
31
+ # other
32
+ *.lock
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - ruby-head
5
+ - 2.6
6
+ - 2.5
7
+ - rbx-3
8
+ - jruby-head
9
+
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: ruby-head
13
+ - rvm: rbx-3
14
+ - rvm: jruby-head
15
+
16
+ before_install:
17
+ - gem install bundler
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --readme README.md lib/**/*.rb
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rake'
7
+ end
8
+
9
+ group :test do
10
+ gem 'rake'
11
+ end
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT X License)
2
+
3
+ Copyright (c) 2012 Kenichi Kamiya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ vertere
2
+ =============
3
+
4
+ [![Build Status](https://secure.travis-ci.org/kachick/vertere.png)](http://travis-ci.org/kachick/vertere)
5
+ [![Gem Version](https://badge.fury.io/rb/vertere.png)](http://badge.fury.io/rb/vertere)
6
+
7
+ Description
8
+ -----------
9
+
10
+ Get wrapper for inverted comparisons.
11
+
12
+ Features
13
+ --------
14
+
15
+ ### Wraps
16
+
17
+ * #==
18
+ * #===
19
+ * #=~
20
+ * #<=>
21
+
22
+ Usage
23
+ -----
24
+
25
+ ```ruby
26
+ require 'vertere'
27
+
28
+ # An approaching to invert comparisons
29
+ num_chars = %w[0 1 9 10 11]
30
+ num_chars.grep(/0/) #=> ["0", "10"]
31
+ num_chars.grep(Veretere.invert(/0/)) #=> ["1", "9", "11"]
32
+
33
+ # Extend core classies
34
+ require 'vertere/core_ext'
35
+ num_chars.grep(/0/.for_!) #=> ["1", "9", "11"]
36
+
37
+ # And more
38
+ num_chars.sort_by{|s|s.to_i.for_!} #=> ["11", "10", "9", "1", "0"]
39
+ ```
40
+
41
+ But I suggest [Enumerable#grep_v from Ruby 2.3](https://bugs.ruby-lang.org/issues/11049) :).
42
+
43
+ Requirements
44
+ -------------
45
+
46
+ * [Ruby 2.5 or later](http://travis-ci.org/#!/kachick/vertere)
47
+
48
+ Install
49
+ -------
50
+
51
+ ```bash
52
+ $ gem install vertere
53
+ ```
54
+
55
+ Link
56
+ ----
57
+
58
+ * [Home](http://kachick.github.com/vertere/)
59
+ * [code](https://github.com/kachick/vertere)
60
+ * [API](http://www.rubydoc.info/github/kachick/vertere)
61
+ * [issues](https://github.com/kachick/vertere/issues)
62
+ * [CI](http://travis-ci.org/#!/kachick/vertere)
63
+ * [gem](https://rubygems.org/gems/vertere)
64
+
65
+ License
66
+ --------
67
+
68
+ The MIT X11 License
69
+ Copyright (c) 2012 Kenichi Kamiya
70
+ See MIT-LICENSE for further details.
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+
4
+ require 'rake/testtask'
5
+
6
+ task default: [:test]
7
+
8
+ Rake::TestTask.new do |tt|
9
+ tt.verbose = true
10
+ tt.warning = true
11
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $VERBOSE = true
4
+
5
+ require_relative '../lib/vertere'
6
+
7
+ num_chars = %w[0 1 9 10 11].freeze
8
+ p num_chars.grep(/0/) #=> ["0", "10"]
9
+ p(/0/ =~ '0') #=> 0
10
+
11
+ require_relative '../lib/vertere/core_ext'
12
+
13
+ p num_chars.grep(/0/.for_!) #=> ["1", "9", "11"]
14
+ p(/0/.for_! =~ '0') #=> false
15
+ p num_chars.grep(/0/) #=> ["0", "10"]
16
+ p num_chars.sort_by(&:to_i) #=> ["0", "1", "9", "10", "11"]
17
+ p num_chars.sort_by{|s|s.to_i.for_!} #=> ["11", "10", "9", "1", "0"]
data/lib/vertere.rb ADDED
@@ -0,0 +1,41 @@
1
+ # Copyright (C) 2012 Kenichi Kamiya
2
+
3
+ require 'delegate'
4
+ require_relative 'vertere/version'
5
+ require_relative 'vertere/objectextension'
6
+
7
+ module Vertere
8
+
9
+ class << self
10
+
11
+ # @return [SimpleDelegator]
12
+ def for_object(original)
13
+ SimpleDelegator.new(original).tap {|wrapper|
14
+ wrapper.singleton_class.class_eval do
15
+ [:==, :===, :=~].each do |operator|
16
+ if original.respond_to? operator
17
+ define_method operator do |other|
18
+ ! (super other)
19
+ end
20
+ end
21
+ end
22
+
23
+ if original.respond_to? :<=>
24
+ def <=>(other)
25
+ r = super other
26
+ r && (- r)
27
+ end
28
+ end
29
+
30
+ def comparison_inverted?
31
+ true
32
+ end
33
+ end
34
+ }
35
+ end
36
+
37
+ alias_method :invert, :for_object
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,7 @@
1
+ require_relative 'objectextension'
2
+
3
+ class Object
4
+
5
+ include Vertere::ObjectExtension
6
+
7
+ end
@@ -0,0 +1,18 @@
1
+ module Vertere
2
+
3
+ module ObjectExtension
4
+
5
+ # @return [SimpleDelegator]
6
+ def for_vertere
7
+ ::Vertere.for_object self
8
+ end
9
+
10
+ alias_method :for_!, :for_vertere
11
+
12
+ def comparison_inverted?
13
+ false
14
+ end
15
+
16
+ end
17
+
18
+ end
@@ -0,0 +1,5 @@
1
+ module Vertere
2
+
3
+ VERSION = '0.1.0'.freeze
4
+
5
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'test/unit'
2
+ require_relative '../lib/vertere'
3
+ require_relative '../lib/vertere/core_ext'
@@ -0,0 +1,32 @@
1
+ require_relative 'helper'
2
+
3
+ class TestVertere < Test::Unit::TestCase
4
+
5
+ def test_compare
6
+ num_chars = ('0'..'11').map(&:freeze).freeze
7
+
8
+ assert_equal(["0", "10"], num_chars.grep(/0/))
9
+ assert_equal((num_chars - ["0", "10"]), num_chars.grep(Vertere.invert(/0/)))
10
+ assert_equal((num_chars - ["0", "10"]), num_chars.grep(/0/.for_!))
11
+ assert_equal(false, (/0/.for_! =~ '0'))
12
+ assert_equal(["0", "10"], num_chars.grep(/0/)) # check not bloken
13
+ assert_equal(num_chars, num_chars.sort_by(&:to_i))
14
+ assert_equal(num_chars.reverse, num_chars.sort_by{|s|s.to_i.for_!})
15
+ end
16
+
17
+ def test_methods_minimum_defined
18
+ obj = Object.new
19
+ assert_equal(true, obj.respond_to?(:=~))
20
+ obj.singleton_class.class_eval do
21
+ undef_method :=~
22
+ end
23
+ assert_equal(false, obj.respond_to?(:=~))
24
+ assert_equal(false, obj.for_!.respond_to?(:=~))
25
+ end
26
+
27
+ def test_check_methods
28
+ obj = Object.new
29
+ assert_equal(false, obj.comparison_inverted?)
30
+ assert_equal(true, obj.for_!.comparison_inverted?)
31
+ end
32
+ end
data/vertere.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # coding: us-ascii
2
+
3
+ lib_name = 'vertere'.freeze
4
+ require "./lib/#{lib_name}/version"
5
+
6
+ Gem::Specification.new do |gem|
7
+ # specific
8
+
9
+ gem.description = %q{Get wrapper for inverted comparisons}
10
+ gem.summary = gem.description.dup
11
+ gem.homepage = "https://github.com/kachick/#{lib_name}"
12
+ gem.license = 'MIT'
13
+ gem.name = lib_name.dup
14
+
15
+ # dup for https://github.com/rubygems/rubygems/commit/48f1d869510dcd325d6566df7d0147a086905380#-P0
16
+ gem.version = Vertere::VERSION.dup
17
+
18
+ gem.add_development_dependency 'test-unit', '>= 3.3.3', '< 4'
19
+ gem.add_development_dependency 'yard', '>= 0.9.20', '< 2'
20
+ gem.add_development_dependency 'rake', '>= 10', '< 20'
21
+ gem.add_development_dependency 'bundler', '>= 2', '< 3'
22
+
23
+ # common
24
+
25
+ gem.authors = ['Kenichi Kamiya']
26
+ gem.email = ['kachick1+ruby@gmail.com']
27
+ gem.files = `git ls-files`.split($\)
28
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
29
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
30
+ gem.require_paths = ['lib']
31
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vertere
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kenichi Kamiya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-07-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: test-unit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.3.3
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 3.3.3
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4'
33
+ - !ruby/object:Gem::Dependency
34
+ name: yard
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 0.9.20
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '2'
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.9.20
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '2'
53
+ - !ruby/object:Gem::Dependency
54
+ name: rake
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '10'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '20'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '10'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '20'
73
+ - !ruby/object:Gem::Dependency
74
+ name: bundler
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '2'
80
+ - - "<"
81
+ - !ruby/object:Gem::Version
82
+ version: '3'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '2'
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: '3'
93
+ description: Get wrapper for inverted comparisons
94
+ email:
95
+ - kachick1+ruby@gmail.com
96
+ executables: []
97
+ extensions: []
98
+ extra_rdoc_files: []
99
+ files:
100
+ - ".gitignore"
101
+ - ".travis.yml"
102
+ - ".yardopts"
103
+ - Gemfile
104
+ - MIT-LICENSE
105
+ - README.md
106
+ - Rakefile
107
+ - examples/README.rb
108
+ - lib/vertere.rb
109
+ - lib/vertere/core_ext.rb
110
+ - lib/vertere/objectextension.rb
111
+ - lib/vertere/version.rb
112
+ - test/helper.rb
113
+ - test/test_vertere.rb
114
+ - vertere.gemspec
115
+ homepage: https://github.com/kachick/vertere
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.7.6
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: Get wrapper for inverted comparisons
139
+ test_files:
140
+ - test/helper.rb
141
+ - test/test_vertere.rb