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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba8996108e4f521e3c1ece8b4a56208c0f6c0aa7
4
- data.tar.gz: cc1f51d3f33e56107b4b8db31301313f4b29ac41
3
+ metadata.gz: f30450303060b252707cc95284fdc6b667aeddc9
4
+ data.tar.gz: f3f7c2a7213a94976f5cae3f4063560e99123512
5
5
  SHA512:
6
- metadata.gz: 00540d8a078ae88e35b403e65ce6a19c287af5f6ad29f5f42b9f295956ccf6d384f0c18acea3141d515ac1353ecff7719da3218dc56b37c6d810ccaf1676de23
7
- data.tar.gz: 546dc501ed9724a0b05f322723a3e330fcdc4cadf8abf7d954d7c8eea68732fa06aa16107861f6de55debbacc5e7e981df5538ace3c9f9efe60273a774acbae7
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
- In Linux to enter you need to type CTRl-SHIFT-U and then 1405 followed by the space or enter key.
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.
@@ -1,3 +1,3 @@
1
1
  module Elixirize
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.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-23 00:00:00.000000000 Z
11
+ date: 2017-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler