elixirize 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -1
- data/lib/elixirize/version.rb +1 -1
- data/lib/elixirize.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f30450303060b252707cc95284fdc6b667aeddc9
|
4
|
+
data.tar.gz: f3f7c2a7213a94976f5cae3f4063560e99123512
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: add253f3de8585ee05618a9ece79c0ff5dc66b36e25b1013f6d91853e7354f49e86afc1b8db849ab126219379669f3914a6cca59307b200d21c51db4e505ea58
|
7
|
+
data.tar.gz: '02942923f295a2157cedfed5d76295a9d93d75e9353e5259c4b8c92c3cfe8ce9cf2c7ba1943fb50fe2057071f4c39f1e8dd581c9bd07b6a13becd96ac3785e9b'
|
data/README.md
CHANGED
@@ -10,7 +10,14 @@
|
|
10
10
|
This adds the `ᐅ` method to Ruby. It pipes in the returned value of the left as the first parameter of the
|
11
11
|
Proc on the right.
|
12
12
|
|
13
|
-
|
13
|
+
### Unicode ᐅ
|
14
|
+
|
15
|
+
To enter ᐅ you need to:
|
16
|
+
|
17
|
+
* **Linux:** type **CTRl-SHIFT-U** and then **1405** followed by the **Space** or **Enter** key.
|
18
|
+
* **Mac:** hold the **Option** key while you type **1405** and then release the **Option** key.
|
19
|
+
* **VIM:** press **CTRL-v** then **SHIFT-U** then **1405** and hit **Enter**.
|
20
|
+
* **Emacs:** press **CTRL-x** then **8** then **Enter** and type **1405** and hit **Enter**.
|
14
21
|
|
15
22
|
## Installation
|
16
23
|
|
@@ -48,6 +55,33 @@ add(40, 60).ᐅ method(:divide), 20
|
|
48
55
|
# => 5
|
49
56
|
```
|
50
57
|
|
58
|
+
For fun I've also aliased λ to lambda; unicode 03bb.
|
59
|
+
|
60
|
+
Since Ruby is designed largely to call methods on the object that was returned
|
61
|
+
I've written the `~` method on `Symbol` to allow method calls on the returned
|
62
|
+
object rather than only being the first parameter passed in.
|
63
|
+
|
64
|
+
**Example:**
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
s = "a b c d"
|
68
|
+
val = s.
|
69
|
+
ᐅ(~:split, " ").
|
70
|
+
ᐅ(~:join, "-").
|
71
|
+
ᐅ ~:capitalize
|
72
|
+
|
73
|
+
val
|
74
|
+
# => "A-b-c-d"
|
75
|
+
```
|
76
|
+
|
77
|
+
You can mix both behaviors without any issue.
|
78
|
+
|
79
|
+
This may seem counter intuitive as it's the same thing as just calling the method
|
80
|
+
on the object, but consider this a noticable refactoring step. If you're designing
|
81
|
+
a project in a manner where you want results piped in as the first parameter then
|
82
|
+
the tilde-Symbol will be your TODO reminder to convert/refactor how your code base is
|
83
|
+
implemented.
|
84
|
+
|
51
85
|
## Development
|
52
86
|
|
53
87
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/elixirize/version.rb
CHANGED
data/lib/elixirize.rb
CHANGED
@@ -2,8 +2,17 @@ require "elixirize/version"
|
|
2
2
|
|
3
3
|
module Elixirize
|
4
4
|
::Object.class_eval do
|
5
|
+
|
5
6
|
def ᐅ other, *args
|
6
7
|
other.call(self, *args)
|
7
8
|
end
|
9
|
+
|
10
|
+
alias_method :λ, :lambda
|
11
|
+
end
|
12
|
+
|
13
|
+
::Symbol.class_eval do
|
14
|
+
def ~
|
15
|
+
λ {|obj, *args| obj.send self, *args }
|
16
|
+
end
|
8
17
|
end
|
9
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elixirize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|