jr-cli 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -4
- data/bin/jr +2 -0
- data/lib/jr/cli/version.rb +1 -1
- 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: 571f0ebed46056b1357383e6ad9161fe330057e7
|
4
|
+
data.tar.gz: 17742313424d2d177a5a97058b8f54e10d693ae8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8386745b224fb617bbde00c45b96e2c1dbb57afdb1cc4f74b0ccd6bb425440dbf8aff9790d22e05a92cb35edd9fd814dfccf09461c00f73263b967e531739129
|
7
|
+
data.tar.gz: 8b38c081c77377d95a720bb3dd58c14a253a53c2fbc9b9ffe52cc87fcc73e7238f32cca9850c31a5ff966e424fc4877083f68cfb4d674753578884f8f72b8bf0
|
data/README.md
CHANGED
@@ -41,20 +41,22 @@ $ curl -s 'https://api.github.com/users/yuya-takeyama/repos' > repos.json
|
|
41
41
|
|
42
42
|
### show repositories
|
43
43
|
|
44
|
-
Because response from `GET /users/:username/repos` is wrapped with `Array`,
|
44
|
+
Because response from `GET /users/:username/repos` is wrapped with `Array`, flatten it by `#flat_map`.
|
45
45
|
You'll get stream of JSON reperesents repositories.
|
46
46
|
|
47
47
|
```
|
48
|
-
$ jr '
|
48
|
+
$ jr 'flat_map(&:itself)' repos.json
|
49
49
|
```
|
50
50
|
|
51
|
+
Pro Tip: `Kernel#itself` is an identity function implemented in Ruby 2.2.0, but `jr` provides it for Ruby 2.1.0 or earlier versions.
|
52
|
+
|
51
53
|
### map to reduce data
|
52
54
|
|
53
55
|
Default response has too much informations.
|
54
56
|
So reduce data using `#map` method.
|
55
57
|
|
56
58
|
```
|
57
|
-
$
|
59
|
+
$ jr 'flat_map(&:itself).map{|j| {name: j[:name], desc: j[:description], lang: j[:language]} }' repos.json
|
58
60
|
{
|
59
61
|
"name": "acne",
|
60
62
|
"desc": "Simple DI container for PHP < 5.3",
|
@@ -84,7 +86,7 @@ Repositories have its primary language which is detected automatically.
|
|
84
86
|
Let's aggregate it and count by languages.
|
85
87
|
|
86
88
|
```
|
87
|
-
$
|
89
|
+
$ jr 'flat_map(&:itself).map{|j| {name: j[:name], desc: j[:description], lang: j[:language]} }.group_by{|j| j[:lang] }.map{|l, v| [l, v.size ] }.to_h' repos.json
|
88
90
|
{
|
89
91
|
"PHP": 10,
|
90
92
|
"Ruby": 12,
|
data/bin/jr
CHANGED
data/lib/jr/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jr-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuya Takeyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yajl-ruby
|