englishest 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efd066ca7b2c8c2116db5c43fbdaed3dd5956bc070a13c386966137a4e9cf8ad
4
- data.tar.gz: 8798a76c67d031cd0752dec1a69ddf793aa598f7f983681b63c1e3dbd8ebe616
3
+ metadata.gz: 8cb8a05f6ac1a1025318971a8a2f675f254d79bc1f091ae6a99260033d1a466d
4
+ data.tar.gz: e074cf3227bdbf671a56259987a42537e3d81e2ff46bc3b7938805a368899c97
5
5
  SHA512:
6
- metadata.gz: 7fd035b052c0a79ace0fbbb4a0e3a2702bdccd6d55d382e010915b0510f8f0ae21d503cd4b9ee8bc9e9b628159947cebe32718329b9fa419b429447de16473a8
7
- data.tar.gz: 42a16846944d701a3e73d718d65a82a510dcb03654f51b37d9c1594c81ec330dcd5bcde72f5435fb8629e7014f3cdd48216befb6d3b88375506e0c160fee328e
6
+ metadata.gz: e293b83300d6683c9475ae4c178df7402a56a364c78e6b7f0164e860e6a7f0d252342e7611f46db2c4136bb6f52ccc6321c94bab4b05dc393f67f8da7a32446d
7
+ data.tar.gz: 6eea047202cde2f2ee184db2270b9f69877faa79f39d0ea43f563d83e47c2adb28f615ca48d72f3d819384c013d75a9e13a34cf1cf5cd40360b4da8dfcdffa03
data/.rubocop.yml CHANGED
@@ -14,6 +14,9 @@ Style/StringLiteralsInInterpolation:
14
14
  Layout/LineLength:
15
15
  Max: 120
16
16
 
17
+ Lint/EmptyClass:
18
+ AllowComments: true
19
+
17
20
  Style/GlobalVars:
18
21
  AllowedVariables:
19
22
  - $LAST_PUT_LINE
data/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2021-11-17
3
+ ## [0.2.0] - 2022-03-05
4
+
5
+ - Move alises previously defined in Object to Kernel, as all aimed methods belong
6
+ to it.
7
+ - Add methods
8
+ - `String#subshell`: allow to execute a command without using backticks
9
+ - Add aliases for
10
+ - `Array::[]`: create engender generate gig
11
+ - `BasicObject#!`: bad? con? negative? ko?
12
+ - `BasicObject#__id__`: badge bib emblem identifier insigne insignia
13
+ - `BasicObject#!=`: inæqual? inequal? unequal? unlike? wry?
14
+ - `BasicObject#instance_eval`: contextually so tho wis
15
+ - `BasicObject#instance_exec`: aptly pat plumb suitably
16
+ - `BasicObject#method_missing`: gap lake vacant on_vacancy way_off
17
+ - `BasicObject#__send__`: address fax hop pst transmit
18
+ - `BasicObject#singleton_method_added`: hail hey hi on_attachment
19
+ - `BasicObject#singleton_method_removed`: ban ciao leave_taking on_detachment
20
+ - `BasicObject#singleton_method_undefined`: farewell nix on_unattachment]
21
+ - `Dir::[]`: conform native_global_match orb suit
22
+ - ``Kernel#```: subshell run
23
+ - `String#subshell`: run
24
+ - `SystemCallError::===`: encompass? fit? gird?
25
+
26
+
27
+ ## [0.1.0] - 2021-12-01
4
28
 
5
29
  - Initial release
30
+ - All provided identifiers have at least one three letter synonymous,
31
+ except `negative?` and `positive?`
32
+ - Incorporate a first set of mere aliases plus a few methods
33
+ - Covered types include BasicObject, Comparable, Object, Regexp, String
34
+ - introduced fully qualified methods are:
35
+ - `BasicObject#consent?(topic = true)`
36
+ - `BasicObject#dissent?(topic = true)`
37
+ - `BasicObject#positive?`
38
+ - `BasicObject#spot(pattern)`
39
+ - Target/synonymous aliases are:
40
+ - `BasicObject#==`: apt? congruent? equipotent? equiquantal? equivalue? worth?
41
+ - `BasicObject#consent?`: nod?
42
+ - `BasicObject#dissent?`: axe? deny?
43
+ - `BasicObject#!=`: dissent? inæqual inequal unequal? unlike? wry?
44
+ - `BasicObject#equal?`: equireferent? peg? univocal?
45
+ - `BasicObject#!`: negative?
46
+ - `BasicObject#spot`: reach win
47
+ - `Comparable#>=`: above? accede? at_least? comprise? on? onward? prosupercede? upward? upon?
48
+ - `Comparable#<`: afore? ahead? antecede? before? ere? inferior_to? less_than?
49
+ - `Comparable#>`: after? beyond? excede? exceed? greater_than? higher_than? over? outdo? outstrip? postcede? supercede?
50
+ - `Comparable#==`: apt? concede? # also has other aliases through BasicObject
51
+ - `Comparable#<=`: at_most? behind? ben? below? beneath? comprised? proconcede?
52
+ - `Object#!~`: absent? devoid? off? miss?
53
+ - `Object#===`: encompass? fit? gird?
54
+ - `Object#eql?`: akin? equisummable? isoepitomizable? like? tie?
55
+ - `Object#=~`: hit
56
+ - `Object#<=>`: trichotomise trichotomize spy wye
57
+ - `Regexp#=~`: hit index_of_first_matching
58
+ - `Regexp#~`: hit_tacitely index_of_first_hot_matching hot
59
+ - `String#=~`: hit index_of_first_matching
data/Gemfile CHANGED
@@ -4,11 +4,3 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in englishest.gemspec
6
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 CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- englishest (0.1.0)
4
+ englishest (0.2.0)
5
+ rake (~> 13.0)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
@@ -49,8 +50,7 @@ PLATFORMS
49
50
  DEPENDENCIES
50
51
  byebug (~> 11.1)
51
52
  englishest!
52
- rake (~> 13.0)
53
- rspec (~> 3.0)
53
+ rspec (~> 3.2)
54
54
  rubocop (~> 1.7)
55
55
 
56
56
  BUNDLED WITH
data/README.md CHANGED
@@ -8,7 +8,7 @@ synonyms for miscellaneous terms, especially offering full word counterpart
8
8
  to ideograms/logograms such as the so called *spaceship operator*.
9
9
 
10
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
11
+ to utter code which is closer to a voiceable English obviously ought to do it
12
12
  so through an obvious transgression of this language usual rules on superlatives.
13
13
 
14
14
  ## Installation
@@ -48,14 +48,21 @@ The gem is available as open source under the terms of the [MIT License](https:/
48
48
  # References
49
49
 
50
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
51
  - https://bundler.io/guides/creating_gem.html
52
+ - https://en.wikipedia.org/wiki/Three-way_comparison#Spaceship_operator
53
+ - https://en.wikipedia.org/wiki/Trichotomy_(mathematics)
54
+ - https://github.com/banister/binding_of_caller
56
55
  - https://guides.rubygems.org/patterns/
57
- - http://www.rubyinside.com/rubys-unary-operators-and-how-to-redefine-their-functionality-5610.html
56
+ - https://guides.rubygems.org/patterns/
57
+ - https://ruby-doc.org/core-2.5.0/Comparable.html
58
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
59
  - https://www.geeksforgeeks.org/ruby-pre-define-variables-constants/
60
+ - https://www.includehelp.com/ruby/alias-vs-alias_method-in-ruby.aspx
61
61
  - https://www.toptal.com/ruby/ruby-metaprogramming-cooler-than-it-sounds
62
+ - http://www.rubyinside.com/rubys-unary-operators-and-how-to-redefine-their-functionality-5610.html
63
+ - https://www.saturnflyer.com/blog/the-difference-between-instanceeval-and-instanceexec/
64
+ - https://dejimata.com/2017/5/20/the-ruby-module-builder-pattern
65
+ - https://stackoverflow.com/questions/51138274/list-all-ruby-classes-and-methods
66
+ - https://stackoverflow.com/questions/12274652/what-is-argf-class-in-ruby-1-9
67
+ - https://c-for-dummies.com/blog/?p=4813
68
+ - https://en.wikipedia.org/wiki/Glob_(programming)
data/englishest.gemspec CHANGED
@@ -37,7 +37,10 @@ Gem::Specification.new do |spec|
37
37
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
38
38
  spec.require_paths = ["lib"]
39
39
 
40
+ spec.add_runtime_dependency "rake", "~> 13.0"
41
+ spec.add_development_dependency "byebug", "~> 11.1"
40
42
  spec.add_development_dependency "rspec", "~> 3.2"
43
+ spec.add_development_dependency "rubocop", "~> 1.7"
41
44
  spec.metadata = {
42
45
  "rubygems_mfa_required" => "true"
43
46
  }
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Dir
4
+ ##
5
+ # :singleton-method: []
6
+ # Dir has a singleton method <tt>[](*args, base: nil, sort: true)</tt>
7
+ # which is equivalent to call <tt>Dir.glob([string, ...], 0)</tt>
8
+ #
9
+ # The +0+ passed as last argument is a flag that indicates case sensitivity.
10
+ # Given that +File::FNM_SYSCASE+ is defined as system default case
11
+ # insensitiveness, equals to +FNM_CASEFOLD+ or 0, it means that the expansion
12
+ # will match file name depending on how system consider case sensitivity.
13
+ #
14
+ # For information, FNM stands for "filename match". Indeed, from an historical
15
+ # perspective, the +glob+ UNIX command is usually based on the +fnmatch+
16
+ # function, which tests for whether a string matches a given pattern.
17
+ #
18
+ # In other word this method allows to access files matching the expansion of a
19
+ # string including wildcard characters while using system case conformity.
20
+
21
+ ##
22
+ # :singleton-method: conform
23
+ # Alias for +[]+ with alignment on semantic: a thing conforms to a set of
24
+ # rules, with a norm or standard, that is a system.
25
+
26
+ ##
27
+ # :singleton-method: native_global_match
28
+ # Alias for +[]+ with alignment on the original lexic
29
+
30
+ ##
31
+ # :singleton-method: orb
32
+ # Alias for +[]+ with alignment on the notion of *global*, moreover as a
33
+ # poetic singleton-metaphor, the verb means to encircle; to surround; to enclose.
34
+
35
+ ##
36
+ # :singleton-method: suit
37
+ # Alias for +[]+ shorter synonym of conform, with the same justifying semantic.
38
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Englishest
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/englishest.rb CHANGED
@@ -8,32 +8,45 @@ require "English"
8
8
  module Englishest
9
9
  class Error < StandardError; end
10
10
 
11
+ module Array
12
+ # List of aliases provided for each class method indexed by its identifier
13
+ SINGLETON_METHOD_ALIASES = {
14
+ # create a new instance encompassing parameters
15
+ "[]": %i[create engender generate gig]
16
+ }.freeze
17
+ end
18
+
11
19
  module BasicObject
12
20
  ALIASES = {
13
21
  "==": %i[apt? congruent? equipotent? equiquantal? equivalue? worth?],
14
22
  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
- # !
23
+ "!=": %i[inæqual? inequal? unequal? unlike? wry?],
24
+ "!": %i[bad? con? negative? ko?],
25
+ __id__: %i[badge bib emblem identifier insigne insignia],
26
+ __send__: %i[address fax hop pst transmit],
27
+ instance_eval: %i[contextually so tho wis],
28
+ instance_exec: %i[aptly pat plumb suitably],
29
+ method_missing: %i[gap lake vacant on_vacancy way_off],
30
+ singleton_method_added: %i[hail hey hi on_attachment],
31
+ singleton_method_removed: %i[ban ciao leave_taking on_detachment],
32
+ singleton_method_undefined: %i[farewell nix on_unattachment]
19
33
  }.freeze
20
34
  end
21
35
 
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]
36
+ module Dir
37
+ SINGLETON_METHOD_ALIASES = {
38
+ "[]": %i[conform native_global_match orb suit]
29
39
  }.freeze
30
40
  end
31
41
 
32
42
  module Regexp
43
+ # List of aliases provided for each instance method indexed by its identifier
33
44
  ALIASES = {
34
45
  "=~": %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
46
+ # As a reminder the tilde implicitely match against +$LAST_READ_LINE+
47
+ # (aka +$_+).
48
+ #
49
+ # Ruby allows to call it both in suffixed and prefixed form, that is
37
50
  # +some_regexp.~+ and +~some_regexp+.
38
51
  #
39
52
  # Note that these aliases cover only the case of a method call suffixing a
@@ -50,6 +63,13 @@ module Englishest
50
63
  }.freeze
51
64
  end
52
65
 
66
+ module SystemCallError
67
+ # List of aliases provided for each class method indexed by its identifier
68
+ SINGLETON_METHOD_ALIASES = {
69
+ "===": %i[encompass? fit? gird?]
70
+ }.freeze
71
+ end
72
+
53
73
  module Comparable
54
74
  ALIASES = {
55
75
  "<": %i[afore? ahead? antecede? before? ere? inferior_to? less_than?
@@ -63,8 +83,16 @@ module Englishest
63
83
  }.freeze
64
84
  end
65
85
 
66
- # TODO
67
- # Kernel#` which allow shell execution
86
+ module Kernel
87
+ ALIASES = {
88
+ eql?: %i[akin? equisummable? isoepitomizable? like? tie?],
89
+ "!~": %i[absent? devoid? off? miss?],
90
+ "===": %i[encompass? fit? gird?],
91
+ "=~": %i[hit],
92
+ "<=>": %i[trichotomise trichotomize spy wye],
93
+ "`": %i[subshell run]
94
+ }.freeze
95
+ end
68
96
 
69
97
  # TODO
70
98
  # '=': %i[assign fix peg set],
@@ -75,23 +103,43 @@ module Englishest
75
103
  Englishest.constants.grep_v(/VERSION|Error/)
76
104
  end
77
105
 
106
+ # This make the bulk of the work of actually setting aliases, using ALIASES
107
+ # constant in submodules of Englishest
78
108
  covered_types.each do |type|
79
109
  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 }
110
+ # Define aliases of instance methods if such a list is provided
111
+ begin
112
+ Object.const_get("::Englishest::#{self}::ALIASES").each do |operator, monikers|
113
+ monikers.each { alias_method _1, operator }
114
+ end
115
+ rescue NameError
116
+ # No instance method defined for this class, it's fine.
117
+ end
118
+
119
+ # Define aliases of singleton methods if such a list is provided
120
+ begin
121
+ class << self
122
+ aim = "::Englishest::#{to_s.split(":").last.chomp(">")}::SINGLETON_METHOD_ALIASES"
123
+ Object.const_get(aim).each do |operator, monikers|
124
+ monikers.each { alias_method _1, operator }
125
+ end
126
+ end
127
+ rescue NameError
128
+ # No singleton/instance method defined for this class, it's fine.
82
129
  end
83
130
  end
84
131
  end
85
132
 
86
133
  # Treating some corner cases specifically
87
134
  class ::BasicObject
88
- alias_method :negative?, "!"
89
-
90
135
  # Alternative to the double bang prefix notation returning the result of
91
136
  # transtyping anything to either +true+ or +false+.
92
137
  def positive?
93
138
  !!self
94
139
  end
140
+ alias good? positive?
141
+ alias ok? positive?
142
+ alias pro? positive?
95
143
 
96
144
  # Consent tacitely mean "compared to truth" when no topic is given
97
145
  def consent?(topic = true)
@@ -108,13 +156,13 @@ module Englishest
108
156
  # Note that :ban?, :nay?, :nix?, :ort? might also have do the trick as alias
109
157
  alias axe? dissent?
110
158
 
111
- # $LAST_READ_LINE is locally binded, to define an synonymous method of the
159
+ ##
160
+ #
161
+ # $LAST_READ_LINE is locally binded, to define a synonymous method of the
112
162
  # unary prefixal matching operator which implicitely use it, the value it
113
163
  # holds in the calling context must be retrieved by some means. Here the
114
164
  # retained implementation is to stash the value in a global variable each
115
165
  # 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
166
  trace_var(:$LAST_READ_LINE, proc { |nub|
119
167
  $LAST_PUT_LINE = nub
120
168
  })
@@ -125,4 +173,20 @@ module Englishest
125
173
  alias win spot
126
174
  alias reach spot
127
175
  end
176
+
177
+ # A String object has an arbitrary sequence of bytes, typically representing
178
+ # text or binary data. Extensions provided by this library focus on making
179
+ # more specific features around String usable with more classic lexical calls.
180
+ class ::String
181
+ # Allow to method-pipeline strings toward a subshell execution, in more
182
+ # subject-verb oriented manner than the default backtilt +``. Subjectively
183
+ # that can also be considered more aligned with the "everything is object"
184
+ # spirit
185
+ def subshell
186
+ `#{self}`
187
+ end
188
+ # Trigraph which, albeit a bit less precise on what it undercover than its
189
+ # aliased version, is fully alligned with regular use of the word.
190
+ alias run subshell
191
+ end
128
192
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: englishest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathieu Lovato Stumpf Guntz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-01 00:00:00.000000000 Z
11
+ date: 2022-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '11.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '11.1'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: rspec
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +52,20 @@ dependencies:
24
52
  - - "~>"
25
53
  - !ruby/object:Gem::Version
26
54
  version: '3.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
27
69
  description: |
28
70
  This gem aims to provides alternative ways to utter Ruby code, simply defining
29
71
  synonyms for miscellaneous terms, especially offering full word counterpart
@@ -52,6 +94,7 @@ files:
52
94
  - bin/console
53
95
  - bin/setup
54
96
  - englishest.gemspec
97
+ - lib/documentation.rb
55
98
  - lib/englishest.rb
56
99
  - lib/englishest/version.rb
57
100
  homepage: https://github.com/psychoslave/englishest