blankity 0.9.3 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a2474babea0e68bddb79670ae6b5680fd0b2be07677b502071d2d9a1abf4eea
4
- data.tar.gz: 6898a094071b9dfa0bd62863ee9b64cf5823c664d84a77913597c999826e92e8
3
+ metadata.gz: 77c386d3e2995f2bd9b923e9454b6ea7eee52ab56b0bee93365c38cf3c0c7116
4
+ data.tar.gz: b590b899c896efe9d843ee456517a30822e85220a89e8ae890fba831975159fd
5
5
  SHA512:
6
- metadata.gz: b0ff3504d136935da61af9c623b4e09a6765c5cb865ce97ee0ef31d82f44b9355109c221ec68432e7c0a0d26db1ed56ca54066e9a2f40ee8fead43a3e1aec222
7
- data.tar.gz: 98067d34173efe13142af36e399ee04ed95905924e4727995c1b0f09ded1cf679979fdca7b3718fbf03dffb574b6b6ff1e7f440b95cc2ce19b2fbc1ce0f6915f
6
+ metadata.gz: 614a8f62d477bac3d9809ac2e37201242fe34bca08693af20dd5089f6be99e5b1ef336971e31a0e3c02f355aa572420353288d747767a8f9ae2aa431e62ee6a0
7
+ data.tar.gz: 3044675608037373cb1d7ff3ff9ee40729289e0d68b3c170cdb8c5302013b70844d556fc359be50281598f598d5afa8b02c713d011b224c1cbcaeefae9b2b773
data/README.md CHANGED
@@ -24,7 +24,7 @@ p defined?(blank.==) #=> nil
24
24
  p defined?(blank.inspect) #=> nil
25
25
 
26
26
  # Include specific `Object` methods:
27
- blank = Blankity::Blank.new(methods: [:==])
27
+ blank = Blankity::Blank.new(with: [:==])
28
28
  p blank == blank #=> true
29
29
 
30
30
  # Also supports blocks, which are `instance_exec`ed
@@ -12,7 +12,7 @@ module Blankity
12
12
  # - Private methods are not undefined, as each one of them is expected to be present (most of them
13
13
  # are hooks, eg +singleton_method_added+), and aren't easily accessible from external classes.
14
14
  #
15
- # To make using +Blank+ easier, its constructor allows you to pass a +methods:+ keyword argument,
15
+ # To make using +Blank+ easier, its constructor allows you to pass a +with:+ keyword argument,
16
16
  # which will define singleton methods based on {Object}.
17
17
  class Blank < BasicObject
18
18
  # Define top-level methods that are annoying to not have present.
@@ -29,10 +29,15 @@ module Blankity
29
29
  undef_method(name) unless name.match?(/\A__.*__\z/)
30
30
  end
31
31
 
32
+ class << self
33
+ # Alias for `new`
34
+ alias blank new
35
+ end
36
+
32
37
  # Creates a new {BlankValue}, and defining singleton methods depending on the parameters
33
38
  #
34
- # @param methods [Array[interned]] a list of {Object} methods to define on +self+.
35
- # @param hash [bool] convenience argument, adds +hash+ and +eql?+ to +methods+ so the resulting
39
+ # @param with [Array[interned]] a list of {Object} methods to define on +self+.
40
+ # @param hash [bool] convenience argument, adds +hash+ and +eql?+ to +with+ so the resulting
36
41
  # type can be used as a key in +Hash+es
37
42
  # @yield [] if a block is given, runs it via +__instance_exec__+.
38
43
  #
@@ -41,18 +46,18 @@ module Blankity
41
46
  # Blankity::Blank.new
42
47
  #
43
48
  # # Include `Object#inspect`, so we can print with `p`
44
- # p Blankity::Blank.new(methods: %i[inspect])
49
+ # p Blankity::Blank.new(with: %i[inspect])
45
50
  #
46
51
  # # Define a singleton method
47
52
  # p Blankity::Blank.new{ def cool?(other) = other == 3 }.cool?(3) #=> true
48
53
  #
49
- # @rbs (?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
50
- def initialize(methods: [], hash: false, &block)
54
+ # @rbs (?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
55
+ def initialize(with: [], hash: false, &block)
51
56
  # If `hash` is supplied, then add `hash` and `eql?` to the list of methods to define
52
- methods |= %i[hash eql?] if hash
57
+ with |= %i[hash eql?] if hash
53
58
 
54
59
  # Define any object methods requested by the end-user
55
- methods.each do |method|
60
+ with.each do |method|
56
61
  __define_singleton_method__(method, ::Object.instance_method(method).bind(self))
57
62
  end
58
63
 
@@ -60,9 +65,4 @@ module Blankity
60
65
  __instance_exec__(&__any__ = block) if block
61
66
  end
62
67
  end
63
-
64
- # Shorthand constructor {Blankity::Blank}.
65
- #
66
- # @rbs (?methods: Array[interned], ?hash: bool) ?{ () [self: Blank] -> void } -> Blank
67
- def self.blank(...) = Blank.new(...)
68
68
  end
@@ -8,7 +8,7 @@ module Blankity
8
8
 
9
9
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
10
10
  #
11
- # @rbs (Integer, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
11
+ # @rbs (Integer, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
12
12
  def initialize(value, ...)
13
13
  @__value__ = value
14
14
  super(...)
@@ -24,7 +24,7 @@ module Blankity
24
24
 
25
25
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
26
26
  #
27
- # @rbs (Integer, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
27
+ # @rbs (Integer, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
28
28
  def initialize(value, ...)
29
29
  @__value__ = value
30
30
  super(...)
@@ -40,7 +40,7 @@ module Blankity
40
40
 
41
41
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
42
42
  #
43
- # @rbs (String, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
43
+ # @rbs (String, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
44
44
  def initialize(value, ...)
45
45
  @__value__ = value
46
46
  super(...)
@@ -56,7 +56,7 @@ module Blankity
56
56
 
57
57
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
58
58
  #
59
- # @rbs (String, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
59
+ # @rbs (String, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
60
60
  def initialize(value, ...)
61
61
  @__value__ = value
62
62
  super(...)
@@ -74,7 +74,7 @@ module Blankity
74
74
 
75
75
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
76
76
  #
77
- # @rbs (Array[T], ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
77
+ # @rbs (Array[T], ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
78
78
  def initialize(value, ...)
79
79
  @__value__ = value
80
80
  super(...)
@@ -92,7 +92,7 @@ module Blankity
92
92
 
93
93
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
94
94
  #
95
- # @rbs (Array[T], ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
95
+ # @rbs (Array[T], ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
96
96
  def initialize(value, ...)
97
97
  @__value__ = value
98
98
  super(...)
@@ -111,7 +111,7 @@ module Blankity
111
111
 
112
112
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
113
113
  #
114
- # @rbs (Hash[K, V], ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
114
+ # @rbs (Hash[K, V], ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
115
115
  def initialize(value, ...)
116
116
  @__value__ = value
117
117
  super(...)
@@ -130,7 +130,7 @@ module Blankity
130
130
 
131
131
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
132
132
  #
133
- # @rbs (Hash[K, V], ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
133
+ # @rbs (Hash[K, V], ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
134
134
  def initialize(value, ...)
135
135
  @__value__ = value
136
136
  super(...)
@@ -146,7 +146,7 @@ module Blankity
146
146
 
147
147
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
148
148
  #
149
- # @rbs (Symbol, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
149
+ # @rbs (Symbol, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
150
150
  def initialize(value, ...)
151
151
  @__value__ = value
152
152
  super(...)
@@ -162,7 +162,7 @@ module Blankity
162
162
 
163
163
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
164
164
  #
165
- # @rbs (Rational, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
165
+ # @rbs (Rational, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
166
166
  def initialize(value, ...)
167
167
  @__value__ = value
168
168
  super(...)
@@ -178,7 +178,7 @@ module Blankity
178
178
 
179
179
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
180
180
  #
181
- # @rbs (Complex, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
181
+ # @rbs (Complex, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
182
182
  def initialize(value, ...)
183
183
  @__value__ = value
184
184
  super(...)
@@ -194,7 +194,7 @@ module Blankity
194
194
 
195
195
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
196
196
  #
197
- # @rbs (Float, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
197
+ # @rbs (Float, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
198
198
  def initialize(value, ...)
199
199
  @__value__ = value
200
200
  super(...)
@@ -210,7 +210,7 @@ module Blankity
210
210
 
211
211
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
212
212
  #
213
- # @rbs (Regexp, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
213
+ # @rbs (Regexp, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
214
214
  def initialize(value, ...)
215
215
  @__value__ = value
216
216
  super(...)
@@ -226,7 +226,7 @@ module Blankity
226
226
 
227
227
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
228
228
  #
229
- # @rbs (String, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
229
+ # @rbs (String, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
230
230
  def initialize(value, ...)
231
231
  @__value__ = value
232
232
  super(...)
@@ -242,7 +242,7 @@ module Blankity
242
242
 
243
243
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
244
244
  #
245
- # @rbs (IO, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
245
+ # @rbs (IO, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
246
246
  def initialize(value, ...)
247
247
  @__value__ = value
248
248
  super(...)
@@ -258,7 +258,7 @@ module Blankity
258
258
 
259
259
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
260
260
  #
261
- # @rbs (Proc, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
261
+ # @rbs (Proc, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
262
262
  def initialize(value, ...)
263
263
  @__value__ = value
264
264
  super(...)
@@ -279,7 +279,7 @@ module Blankity
279
279
 
280
280
  # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
281
281
  #
282
- # @rbs (T?, T?, ?bool, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
282
+ # @rbs (T?, T?, ?bool, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
283
283
  def initialize(begin_, end_, exclude_end = false, ...)
284
284
  @__begin__ = begin_
285
285
  @__end__ = end_
@@ -2,5 +2,5 @@
2
2
  # rbs_inline: enabled
3
3
 
4
4
  module Blankity
5
- VERSION = '0.9.3'
5
+ VERSION = '0.10.0'
6
6
  end
data/lib/blankity.rb CHANGED
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
  # rbs_inline: enabled
3
3
 
4
- module Blankity; end
4
+ module Blankity
5
+ # Shorthand constructor {Blankity::Blank}.
6
+ #
7
+ # @rbs (?with: Array[interned], ?hash: bool) ?{ () [self: Blank] -> void } -> Blank
8
+ def self.blank(...) = Blank.new(...)
9
+ end
5
10
 
6
11
  require_relative 'blankity/version'
7
12
  require_relative 'blankity/top'
@@ -19,6 +19,8 @@ module Blankity
19
19
 
20
20
  def __instance_exec__: [T] (*untyped, **untyped) { (?) [self: self] -> T } -> T
21
21
 
22
+ alias self.blank self.new
23
+
22
24
  # Creates a new {BlankValue}, and defining singleton methods depending on the parameters
23
25
  #
24
26
  # @param methods [Array[interned]] a list of {Object} methods to define on +self+.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blankity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Westerman