blankity 0.11.0 → 1.0.1
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 +4 -4
- data/README.md +9 -9
- data/lib/blankity/blank.rb +11 -2
- data/lib/blankity/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4ba15f42be4bf2749e4a4c953ff17b05027f28a25e531b3d18bd7034d2308b74
|
|
4
|
+
data.tar.gz: 44badfc698070779df25a32cbfcd11e3394beb46a9c94eccfde3445a59ab4293
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cab33e13ace93b648ed7b436123914d0b7a2fe4f424cfb8f0af0a38989f294ab2c27e7fba376b6a2048ecb012e656613ebdf9208670011bfa4baebbd63272869
|
|
7
|
+
data.tar.gz: e39737a87c120ddd67e1232f678d205780bc6586001a653c398796cbbe713748e38939a1631f517d38dbbcfa0e03fd0af4f38e0ad242ab3297cea94610838d6c
|
data/README.md
CHANGED
|
@@ -53,22 +53,22 @@ puts 'hello'.gsub(/[eo]/, Blankity::To.hash('e' => 'E', 'o' => 'O'))
|
|
|
53
53
|
#=> hEllO
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
You can include the `Blankity::To` module to get theeh `theo` method!
|
|
57
57
|
```ruby
|
|
58
58
|
extend Blankity::To
|
|
59
59
|
|
|
60
|
-
puts 'hello' + str(' world')
|
|
61
|
-
exit int(0)
|
|
60
|
+
puts 'hello' + to.str(' world')
|
|
61
|
+
exit to.int(0)
|
|
62
62
|
|
|
63
63
|
# Let's get crazy!
|
|
64
64
|
system(
|
|
65
|
-
hash(
|
|
66
|
-
str('HELLO', hash: true) => str('WORLD')
|
|
65
|
+
to.hash(
|
|
66
|
+
to.str('HELLO', hash: true) => to.str('WORLD')
|
|
67
67
|
),
|
|
68
|
-
ary(str('sh'), str('-sh')),
|
|
69
|
-
str('-c'),
|
|
70
|
-
str('echo $0 $HELLO $PWD'),
|
|
71
|
-
chdir: path('/'),
|
|
68
|
+
to.ary(to.str('sh'), to.str('-sh')),
|
|
69
|
+
to.str('-c'),
|
|
70
|
+
to.str('echo $0 $HELLO $PWD'),
|
|
71
|
+
chdir: to.path('/'),
|
|
72
72
|
)
|
|
73
73
|
```
|
|
74
74
|
|
data/lib/blankity/blank.rb
CHANGED
|
@@ -38,6 +38,7 @@ module Blankity
|
|
|
38
38
|
|
|
39
39
|
# Creates a new {BlankValue}, and defining singleton methods depending on the parameters
|
|
40
40
|
#
|
|
41
|
+
# @param vars [Hash[interned, untyped]] an array of instance variables to define on +self+.
|
|
41
42
|
# @param with [Array[interned]] a list of {Object} methods to define on +self+.
|
|
42
43
|
# @param hash [bool] convenience argument, adds +hash+ and +eql?+ to +with+ so the resulting
|
|
43
44
|
# type can be used as a key in +Hash+es
|
|
@@ -53,8 +54,8 @@ module Blankity
|
|
|
53
54
|
# # Define a singleton method
|
|
54
55
|
# p Blankity::Blank.new{ def cool?(other) = other == 3 }.cool?(3) #=> true
|
|
55
56
|
#
|
|
56
|
-
# @rbs (?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
|
|
57
|
-
def initialize(with: [], hash: false, &block)
|
|
57
|
+
# @rbs (?vars: Hash[interned, untyped], ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
|
|
58
|
+
def initialize(vars: {}, with: [], hash: false, &block)
|
|
58
59
|
# If `hash` is supplied, then add `hash` and `eql?` to the list of methods to define
|
|
59
60
|
with |= %i[hash eql?] if hash
|
|
60
61
|
|
|
@@ -63,6 +64,14 @@ module Blankity
|
|
|
63
64
|
__define_singleton_method__(method, ::Object.instance_method(method).bind(self))
|
|
64
65
|
end
|
|
65
66
|
|
|
67
|
+
# Assign all instance variables
|
|
68
|
+
vars.each do |key, value|
|
|
69
|
+
key = defined?(key.to_sym) ? key.to_sym : key.to_str
|
|
70
|
+
key = "@#{key}" unless key.start_with? '@'
|
|
71
|
+
|
|
72
|
+
::Kernel.instance_method(:instance_variable_set).bind_call(self, key, value)
|
|
73
|
+
end
|
|
74
|
+
|
|
66
75
|
# If a block's provided, then `instance_exec`
|
|
67
76
|
__instance_exec__(&__any__ = block) if block
|
|
68
77
|
end
|
data/lib/blankity/version.rb
CHANGED
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.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sam Westerman
|
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
56
56
|
- !ruby/object:Gem::Version
|
|
57
57
|
version: '0'
|
|
58
58
|
requirements: []
|
|
59
|
-
rubygems_version:
|
|
59
|
+
rubygems_version: 4.0.3
|
|
60
60
|
specification_version: 4
|
|
61
61
|
summary: Provides "blank" objects which only supply conversion methods
|
|
62
62
|
test_files: []
|