englishest 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: efd066ca7b2c8c2116db5c43fbdaed3dd5956bc070a13c386966137a4e9cf8ad
4
+ data.tar.gz: 8798a76c67d031cd0752dec1a69ddf793aa598f7f983681b63c1e3dbd8ebe616
5
+ SHA512:
6
+ metadata.gz: 7fd035b052c0a79ace0fbbb4a0e3a2702bdccd6d55d382e010915b0510f8f0ae21d503cd4b9ee8bc9e9b628159947cebe32718329b9fa419b429447de16473a8
7
+ data.tar.gz: 42a16846944d701a3e73d718d65a82a510dcb03654f51b37d9c1594c81ec330dcd5bcde72f5435fb8629e7014f3cdd48216befb6d3b88375506e0c160fee328e
@@ -0,0 +1,16 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.2
14
+ bundler-cache: true
15
+ - name: Run the default task
16
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,29 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ DisplayCopNames: true
4
+ NewCops: enable
5
+
6
+ Style/StringLiterals:
7
+ Enabled: true
8
+ EnforcedStyle: double_quotes
9
+
10
+ Style/StringLiteralsInInterpolation:
11
+ Enabled: true
12
+ EnforcedStyle: double_quotes
13
+
14
+ Layout/LineLength:
15
+ Max: 120
16
+
17
+ Style/GlobalVars:
18
+ AllowedVariables:
19
+ - $LAST_PUT_LINE
20
+
21
+ Style/OptionalBooleanParameter:
22
+ AllowedMethods:
23
+ - consent?
24
+ - dissent?
25
+
26
+ Metrics/BlockLength:
27
+ Exclude:
28
+ - '*.gemspec'
29
+ - 'spec/*.rb'
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-11-17
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in englishest.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
13
+
14
+ gem "byebug", "~> 11.1", groups: %i[development test]
data/Gemfile.lock ADDED
@@ -0,0 +1,57 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ englishest (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ byebug (11.1.3)
11
+ diff-lcs (1.4.4)
12
+ parallel (1.21.0)
13
+ parser (3.0.2.0)
14
+ ast (~> 2.4.1)
15
+ rainbow (3.0.0)
16
+ rake (13.0.6)
17
+ regexp_parser (2.1.1)
18
+ rexml (3.2.5)
19
+ rspec (3.10.0)
20
+ rspec-core (~> 3.10.0)
21
+ rspec-expectations (~> 3.10.0)
22
+ rspec-mocks (~> 3.10.0)
23
+ rspec-core (3.10.1)
24
+ rspec-support (~> 3.10.0)
25
+ rspec-expectations (3.10.1)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.10.0)
28
+ rspec-mocks (3.10.2)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.10.0)
31
+ rspec-support (3.10.3)
32
+ rubocop (1.23.0)
33
+ parallel (~> 1.10)
34
+ parser (>= 3.0.0.0)
35
+ rainbow (>= 2.2.2, < 4.0)
36
+ regexp_parser (>= 1.8, < 3.0)
37
+ rexml
38
+ rubocop-ast (>= 1.12.0, < 2.0)
39
+ ruby-progressbar (~> 1.7)
40
+ unicode-display_width (>= 1.4.0, < 3.0)
41
+ rubocop-ast (1.13.0)
42
+ parser (>= 3.0.1.1)
43
+ ruby-progressbar (1.11.0)
44
+ unicode-display_width (2.1.0)
45
+
46
+ PLATFORMS
47
+ x86_64-linux
48
+
49
+ DEPENDENCIES
50
+ byebug (~> 11.1)
51
+ englishest!
52
+ rake (~> 13.0)
53
+ rspec (~> 3.0)
54
+ rubocop (~> 1.7)
55
+
56
+ BUNDLED WITH
57
+ 2.2.22
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Mathieu Lovato Stumpf Guntz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Englishest
2
+
3
+ In a nutshell, with this gem enabled you can now spell `<=>` as `trichotomize`,
4
+ and so on.
5
+
6
+ This gem aims to provides alternative ways to utter Ruby code, simply defining
7
+ synonyms for miscellaneous terms, especially offering full word counterpart
8
+ to ideograms/logograms such as the so called *spaceship operator*.
9
+
10
+ The name of the gem is of course a pun: a library which provides ability
11
+ to utter coder which is closer to a voiceable English obviously ought to do it
12
+ so through an obvious transgression of this language usual rules on superlatives.
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'englishest'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle install
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install englishest
29
+
30
+ ## Usage
31
+
32
+ TODO: Write usage instructions here
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/psychoslave/englishest].
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
47
+
48
+ # References
49
+
50
+ Resources consulted while hacking this gem:
51
+ - https://www.includehelp.com/ruby/alias-vs-alias_method-in-ruby.aspx
52
+ - https://ruby-doc.org/core-2.5.0/Comparable.html
53
+ - https://en.wikipedia.org/wiki/Trichotomy_(mathematics)
54
+ - https://en.wikipedia.org/wiki/Three-way_comparison#Spaceship_operator
55
+ - https://bundler.io/guides/creating_gem.html
56
+ - https://guides.rubygems.org/patterns/
57
+ - http://www.rubyinside.com/rubys-unary-operators-and-how-to-redefine-their-functionality-5610.html
58
+ - https://stackoverflow.com/questions/1356749/can-you-eval-code-in-the-context-of-a-caller-in-ruby
59
+ - https://github.com/banister/binding_of_caller
60
+ - https://www.geeksforgeeks.org/ruby-pre-define-variables-constants/
61
+ - https://www.toptal.com/ruby/ruby-metaprogramming-cooler-than-it-sounds
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/Roadmap.md ADDED
@@ -0,0 +1,35 @@
1
+ - define English equivalent for each non-letter methods/operators
2
+ - `=` aliased as `assign`, `fix`, `set`
3
+ - `==` aliased as `equivalent?`, `equipotent?`, `equiquantal?`, `equivalue?`
4
+ - `eql?` aliased as `akin?`, `assimilated?`, `equidense?`, `equiepitomize?`, `equisummable?`, `equivalate?`, `equivocate?`, `like?`, `tie?`
5
+ true if both operands refer to the same hash key
6
+ - `equal?` aliased as `equireferent?`, `univocal?`, `nod?`
7
+ refer to the same object.
8
+ - `===` aliased as `apt?`, `fit?`, `encompass?`, `gird?`,
9
+ case-equality,
10
+ - `!` unary bivalent negation prefix aliasable has `non-`
11
+ - `!=` aliased as `dissent?`, `inæqual`, `inequal`, `unequal?`, `unlike?`, `wry?`
12
+ - `<=>` aliased as `trichotomize`, `spy`, `wye`
13
+ - `=~` aliased as `hit`
14
+ - `!~` aliased as `absent?`, `devoid?`, `off?`, `miss?`
15
+ - enable to use dash rather than dot as method call operator :
16
+ that is `object-method` rather than `object.method`
17
+ - ensure that numeric value still bind dash to minus, that is substraction
18
+ - allow to select a locale rather than defining all alternatives forms
19
+
20
+ # Notes
21
+ Terms above are to be taken as
22
+ `ben`: (Scotland, Northern England) Inside.
23
+ `spy`: To distinguish something as being different from something else; to differentiate.
24
+ `wye`: a triangular joining arrangement of three rail lines with a railroad switch (set of points) at each corner connecting to each incoming line.
25
+ `ere`: Before; sooner than.
26
+
27
+ ## Terms with `equi-` prefix
28
+
29
+ # References
30
+
31
+ - https://www.planetmath.org/equibounded
32
+ - https://en.wiktionary.org/wiki/ searching for terms starting with `equi`
33
+ - https://medium.com/@khalidh64/difference-between-eql-equal-in-ruby-2ffa7f073532
34
+ - https://fr.wiktionary.org/wiki/Utilisateur:Psychoslave/Vocabulaire_utile_pour_l%E2%80%99informatique
35
+ - https://en.wikipedia.org/wiki/Wye_(rail)
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "englishest"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/englishest/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "englishest"
7
+ spec.version = Englishest::VERSION
8
+ spec.authors = ["Mathieu Lovato Stumpf Guntz"]
9
+ spec.email = ["psychoslave@culture-libre.org"]
10
+
11
+ spec.summary = "A Ruby gem which allows a more literate coding style"
12
+ spec.description = <<~ABOUT
13
+ This gem aims to provides alternative ways to utter Ruby code, simply defining
14
+ synonyms for miscellaneous terms, especially offering full word counterpart
15
+ to ideograms/logograms such as the so called *spaceship operator*.
16
+
17
+ The name of the gem is of course a pun: a library which provides ability
18
+ to utter coder which is closer to a voiceable English obviously ought to do it
19
+ so through an obvious transgression of this language usual rules on superlatives.
20
+ ABOUT
21
+ spec.homepage = "https://github.com/psychoslave/englishest"
22
+ spec.license = "MIT"
23
+ spec.required_ruby_version = ">= 2.5.0"
24
+
25
+ spec.metadata["allowed_push_host"] = "https://mygemserver.com"
26
+
27
+ spec.metadata["homepage_uri"] = spec.homepage
28
+ spec.metadata["source_code_uri"] = "https://github.com/psychoslave/englishest.git"
29
+ spec.metadata["changelog_uri"] = "https://github.com/psychoslave/englishest/blob/main/CHANGELOG.md"
30
+
31
+ # Specify which files should be added to the gem when it is released.
32
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
33
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
34
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
35
+ end
36
+ spec.bindir = "exe"
37
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
38
+ spec.require_paths = ["lib"]
39
+
40
+ spec.add_development_dependency "rspec", "~> 3.2"
41
+ spec.metadata = {
42
+ "rubygems_mfa_required" => "true"
43
+ }
44
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Englishest
4
+ VERSION = "0.1.0"
5
+ end
data/lib/englishest.rb ADDED
@@ -0,0 +1,128 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "englishest/version"
4
+ require "English"
5
+
6
+ # Encapsulate all the contrivances to allow a coding style using more English
7
+ # vocabulary, especially enabling to express ideas without ideographi operators.
8
+ module Englishest
9
+ class Error < StandardError; end
10
+
11
+ module BasicObject
12
+ ALIASES = {
13
+ "==": %i[apt? congruent? equipotent? equiquantal? equivalue? worth?],
14
+ equal?: %i[equireferent? peg? univocal?],
15
+ "!=": %i[dissent? inæqual inequal unequal? unlike? wry?]
16
+ # TODO
17
+ # '!': unary bivalent negation prefix aliasable has non-],
18
+ # !
19
+ }.freeze
20
+ end
21
+
22
+ module Object
23
+ ALIASES = {
24
+ eql?: %i[akin? equisummable? isoepitomizable? like? tie?],
25
+ "!~": %i[absent? devoid? off? miss?],
26
+ "<=>": %i[trichotomise trichotomize spy wye],
27
+ "===": %i[encompass? fit? gird?],
28
+ "=~": %i[hit]
29
+ }.freeze
30
+ end
31
+
32
+ module Regexp
33
+ ALIASES = {
34
+ "=~": %i[hit index_of_first_matching],
35
+ # As a reminder the tilde implicitely match against $LAST_READ_LINE/$_
36
+ # Ruby allow to call it both in suffixed and prefixed form, that is
37
+ # +some_regexp.~+ and +~some_regexp+.
38
+ #
39
+ # Note that these aliases cover only the case of a method call suffixing a
40
+ # Regexp object, like +some_regexp.index_of_first_hot_matching+. For a
41
+ # prefixed method expression form, see +Englishest#spot+ bellow.
42
+ "~": %i[hit_tacitely index_of_first_hot_matching hot
43
+ index_of_first_matching_on_last_read_line]
44
+ }.freeze
45
+ end
46
+
47
+ module String
48
+ ALIASES = {
49
+ "=~": %i[hit index_of_first_matching]
50
+ }.freeze
51
+ end
52
+
53
+ module Comparable
54
+ ALIASES = {
55
+ "<": %i[afore? ahead? antecede? before? ere? inferior_to? less_than?
56
+ lower_than? prior? subcede? subceed? smaller_than? precede?],
57
+ "<=": %i[at_most? behind? ben? below? beneath? comprised? proconcede?
58
+ under? underneath? within?],
59
+ "==": %i[apt? concede?], # also has other aliases through BasicObject
60
+ ">=": %i[above? accede? at_least? comprise? on? onward? prosupercede? upward? upon?],
61
+ ">": %i[after? beyond? excede? exceed? greater_than? higher_than? over? outdo? outstrip? postcede? supercede?
62
+ supersede? superior_to? top? upper_than?]
63
+ }.freeze
64
+ end
65
+
66
+ # TODO
67
+ # Kernel#` which allow shell execution
68
+
69
+ # TODO
70
+ # '=': %i[assign fix peg set],
71
+
72
+ # Return list of submodules whose name matches a class or module that is
73
+ # affected by the gem
74
+ def self.covered_types
75
+ Englishest.constants.grep_v(/VERSION|Error/)
76
+ end
77
+
78
+ covered_types.each do |type|
79
+ Object.const_get("::#{type}").class_eval do
80
+ Object.const_get("::Englishest::#{self}::ALIASES").each do |operator, monikers|
81
+ monikers.each { alias_method _1, operator }
82
+ end
83
+ end
84
+ end
85
+
86
+ # Treating some corner cases specifically
87
+ class ::BasicObject
88
+ alias_method :negative?, "!"
89
+
90
+ # Alternative to the double bang prefix notation returning the result of
91
+ # transtyping anything to either +true+ or +false+.
92
+ def positive?
93
+ !!self
94
+ end
95
+
96
+ # Consent tacitely mean "compared to truth" when no topic is given
97
+ def consent?(topic = true)
98
+ equal? topic
99
+ end
100
+ alias nod? consent?
101
+
102
+ # Opposite of consent, although this is implemented as a fully automous
103
+ # determination, which inter alia avoid some technical convonlutions
104
+ def dissent?(topic = true)
105
+ !equal?(topic)
106
+ end
107
+ alias deny? dissent?
108
+ # Note that :ban?, :nay?, :nix?, :ort? might also have do the trick as alias
109
+ alias axe? dissent?
110
+
111
+ # $LAST_READ_LINE is locally binded, to define an synonymous method of the
112
+ # unary prefixal matching operator which implicitely use it, the value it
113
+ # holds in the calling context must be retrieved by some means. Here the
114
+ # retained implementation is to stash the value in a global variable each
115
+ # time its value change.
116
+ # TODO: see if this could be implemented withou global variable nor class
117
+ # variable, as both raising Rubocop offenses
118
+ trace_var(:$LAST_READ_LINE, proc { |nub|
119
+ $LAST_PUT_LINE = nub
120
+ })
121
+
122
+ def spot(pattern)
123
+ $LAST_PUT_LINE =~ pattern
124
+ end
125
+ alias win spot
126
+ alias reach spot
127
+ end
128
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: englishest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mathieu Lovato Stumpf Guntz
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ description: |
28
+ This gem aims to provides alternative ways to utter Ruby code, simply defining
29
+ synonyms for miscellaneous terms, especially offering full word counterpart
30
+ to ideograms/logograms such as the so called *spaceship operator*.
31
+
32
+ The name of the gem is of course a pun: a library which provides ability
33
+ to utter coder which is closer to a voiceable English obviously ought to do it
34
+ so through an obvious transgression of this language usual rules on superlatives.
35
+ email:
36
+ - psychoslave@culture-libre.org
37
+ executables: []
38
+ extensions: []
39
+ extra_rdoc_files: []
40
+ files:
41
+ - ".github/workflows/main.yml"
42
+ - ".gitignore"
43
+ - ".rspec"
44
+ - ".rubocop.yml"
45
+ - CHANGELOG.md
46
+ - Gemfile
47
+ - Gemfile.lock
48
+ - LICENSE.txt
49
+ - README.md
50
+ - Rakefile
51
+ - Roadmap.md
52
+ - bin/console
53
+ - bin/setup
54
+ - englishest.gemspec
55
+ - lib/englishest.rb
56
+ - lib/englishest/version.rb
57
+ homepage: https://github.com/psychoslave/englishest
58
+ licenses:
59
+ - MIT
60
+ metadata:
61
+ rubygems_mfa_required: 'true'
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 2.5.0
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubygems_version: 3.2.22
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: A Ruby gem which allows a more literate coding style
81
+ test_files: []