shelike-pipe 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/README.md +12 -3
- data/lib/shelike/pipe.rb +14 -3
- data/lib/shelike/pipe/error.rb +11 -0
- data/lib/shelike/pipe/version.rb +1 -1
- data/shelike-pipe.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4e8c45e3d99dd5b8cd128146152d02d720f433d
|
4
|
+
data.tar.gz: f099c4bddc1ed5de560264b56a321f77ca73293f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c7fb17a1a93dfc6816a6acc4c6ae6b4b523010f7adebc6fceaa5c769aedc4034c54907c23aa4d4766d5ab533ef7e5f7eefdabed577cd1f6f8b4fbad1fc56980
|
7
|
+
data.tar.gz: ac73626068a893068c8cce48ae15d3b3e6356b4c89482ba3e17d3808dc47003e93b5f3d4153d1f042b7c8ff129fb7d550214277ea3eeb6b853fd4ef6b36878f0
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Shelike::Pipe
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/k-motoyan/shelike-pipe.svg?branch=master)](https://travis-ci.org/k-motoyan/shelike-pipe)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/k-motoyan/shelike-pipe/badges/gpa.svg)](https://codeclimate.com/github/k-motoyan/shelike-pipe)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/k-motoyan/shelike-pipe/badges/coverage.svg)](https://codeclimate.com/github/k-motoyan/shelike-pipe/coverage)
|
4
6
|
|
5
7
|
Shelike::Pipe offer an operator to behave like the pipe operator of the shell.
|
6
8
|
|
@@ -39,9 +41,16 @@ require 'json'
|
|
39
41
|
# When an argument is necessary, define it with sequence.
|
40
42
|
(%w(a b c) | :size | [:*, 3]).call # => 9
|
41
43
|
|
42
|
-
#
|
43
|
-
|
44
|
-
|
44
|
+
# Carry out the function that was connected to there by using `^` and catchable an exception.
|
45
|
+
'{ a: 1 }' | JSON.method(:parse) ^ ->(e) { exception! }
|
46
|
+
|
47
|
+
# When an exception occurs, the `^` returns `nil`, and the case except it returns the practice result of the function to there.
|
48
|
+
'{ a: 1 }' | JSON.method(:parse) ^ ->(e) { exception! } # => nil
|
49
|
+
'{ "a": 1 }' | JSON.method(:parse) ^ ->(e) { exception! } # => { "a" => 1 }
|
50
|
+
|
51
|
+
# When they use `|` and `^` for `nil`, results always become `nil`.
|
52
|
+
(nil | to_i).call # => nil
|
53
|
+
-> { nil } ^ :upcase # => nil
|
45
54
|
```
|
46
55
|
|
47
56
|
## Development
|
data/lib/shelike/pipe.rb
CHANGED
@@ -51,9 +51,20 @@ module Shelike
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
55
|
-
call
|
56
|
-
rescue =>
|
54
|
+
def ^(proc)
|
55
|
+
call.tap { |r| raise Shelike::Pipe::Error::ResultNilError if r.nil? }
|
56
|
+
rescue => e
|
57
|
+
proc.call(e)
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
refine NilClass do
|
63
|
+
def |(_)
|
64
|
+
nil
|
65
|
+
end
|
66
|
+
|
67
|
+
def ^(_)
|
57
68
|
nil
|
58
69
|
end
|
59
70
|
end
|
data/lib/shelike/pipe/version.rb
CHANGED
data/shelike-pipe.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelike-pipe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k-motoyan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: codeclimate-test-reporter
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description:
|
42
56
|
email:
|
43
57
|
- k.motoyan888@gmail.com
|
@@ -53,6 +67,7 @@ files:
|
|
53
67
|
- Rakefile
|
54
68
|
- bin/setup
|
55
69
|
- lib/shelike/pipe.rb
|
70
|
+
- lib/shelike/pipe/error.rb
|
56
71
|
- lib/shelike/pipe/version.rb
|
57
72
|
- shelike-pipe.gemspec
|
58
73
|
homepage: https://github.com/k-motoyan/shelike-pipe
|