qig 0.1.3 → 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/.rubocop.yml +7 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +23 -0
- data/Gemfile +5 -4
- data/Gemfile.lock +14 -1
- data/README.md +6 -3
- data/bin/console +1 -1
- data/lib/qig/version.rb +1 -1
- data/lib/qig.rb +34 -28
- data/qig.gemspec +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baaf3d2d15ea2c35ff975d3b1f373b307269ca866faed4363ffc5648320c415f
|
4
|
+
data.tar.gz: 195d83a355ddcf760fd66afb6e3e791b0571d48f01190c9e15fd5b890b83b937
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1124ac020d0e6ad9c8b6be999d8d25c1b1423e5482bcab1c24d832724d566e7783ad1c8780cf7dbf2e84b41e68bc92652896ec1d94f88ef903da267447d2d273
|
7
|
+
data.tar.gz: 946766e1e920e92226c5994efb64a435da1c42dbe132b26116bf3065f9f1f77c3d2612eaeb812fa8cda5d9318ea432cf4ed3ba61daeda00e19c322f951a7e4b0
|
data/.rubocop.yml
CHANGED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--markup markdown
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
# 0.2.0 (January 14, 2022)
|
2
|
+
|
3
|
+
## Features
|
4
|
+
|
5
|
+
- Value iteration(`[]` over hashes)
|
6
|
+
|
7
|
+
## Documentation
|
8
|
+
|
9
|
+
- Initial yard documentation on method and module
|
10
|
+
- Document and spec that we can qig into Structs and OpenStructs
|
11
|
+
|
12
|
+
# 0.1.3 (January 13, 2022)
|
13
|
+
|
14
|
+
## Documentation
|
15
|
+
|
16
|
+
- fix changelog uri (again)
|
17
|
+
|
18
|
+
# 0.1.2 (January 13, 2022)
|
19
|
+
|
20
|
+
## Documentation
|
21
|
+
|
22
|
+
- fix changelog uri
|
23
|
+
|
1
24
|
# 0.1.1 (January 13, 2022)
|
2
25
|
|
3
26
|
## Documentation
|
data/Gemfile
CHANGED
@@ -5,10 +5,11 @@ source 'https://rubygems.org'
|
|
5
5
|
# Specify your gem's dependencies in qig.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
+
gem 'pry', '~> 0.14.1'
|
8
9
|
gem 'rake', '~> 13.0'
|
9
|
-
|
10
10
|
gem 'rspec', '~> 3.0'
|
11
|
-
|
11
|
+
gem 'rspec_junit_formatter', '~> 0.5.1'
|
12
12
|
gem 'rubocop', '~> 1.21'
|
13
|
-
|
14
|
-
gem
|
13
|
+
gem 'rubocop-rake', '~> 0.6.0'
|
14
|
+
gem 'rubocop-rspec', '~> 2.7'
|
15
|
+
gem 'yard', '~> 0.9.27'
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
qig (0.
|
4
|
+
qig (0.2.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -33,6 +33,8 @@ GEM
|
|
33
33
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
34
|
rspec-support (~> 3.10.0)
|
35
35
|
rspec-support (3.10.3)
|
36
|
+
rspec_junit_formatter (0.5.1)
|
37
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
36
38
|
rubocop (1.24.1)
|
37
39
|
parallel (~> 1.10)
|
38
40
|
parser (>= 3.0.0.0)
|
@@ -44,8 +46,15 @@ GEM
|
|
44
46
|
unicode-display_width (>= 1.4.0, < 3.0)
|
45
47
|
rubocop-ast (1.15.1)
|
46
48
|
parser (>= 3.0.1.1)
|
49
|
+
rubocop-rake (0.6.0)
|
50
|
+
rubocop (~> 1.0)
|
51
|
+
rubocop-rspec (2.7.0)
|
52
|
+
rubocop (~> 1.19)
|
47
53
|
ruby-progressbar (1.11.0)
|
48
54
|
unicode-display_width (2.1.0)
|
55
|
+
webrick (1.7.0)
|
56
|
+
yard (0.9.27)
|
57
|
+
webrick (~> 1.7.0)
|
49
58
|
|
50
59
|
PLATFORMS
|
51
60
|
x86_64-linux
|
@@ -55,7 +64,11 @@ DEPENDENCIES
|
|
55
64
|
qig!
|
56
65
|
rake (~> 13.0)
|
57
66
|
rspec (~> 3.0)
|
67
|
+
rspec_junit_formatter (~> 0.5.1)
|
58
68
|
rubocop (~> 1.21)
|
69
|
+
rubocop-rake (~> 0.6.0)
|
70
|
+
rubocop-rspec (~> 2.7)
|
71
|
+
yard (~> 0.9.27)
|
59
72
|
|
60
73
|
BUNDLED WITH
|
61
74
|
2.3.4
|
data/README.md
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
# Qig
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/qig.svg)](https://badge.fury.io/rb/qig)
|
4
|
+
[![CircleCI](https://circleci.com/gh/NAR8789/qig-ruby/tree/main.svg?style=shield)](https://circleci.com/gh/NAR8789/qig-ruby/tree/main)
|
5
|
+
|
3
6
|
qig is dig extended with jq's "value iterator" `[]` operator.
|
4
7
|
|
5
8
|
## Features
|
6
9
|
|
7
10
|
- [x] qig into arrays and hashes
|
8
|
-
- [
|
9
|
-
- [
|
11
|
+
- [x] qig into structs
|
12
|
+
- [x] qig into OpenStructs
|
10
13
|
- [ ] qig into CSV::Tables
|
11
14
|
- [ ] qig into CSV::Rows
|
12
15
|
- [x] value iteration over arrays
|
13
|
-
- [
|
16
|
+
- [x] value iteration over hashes
|
14
17
|
- [ ] option to monkey patch this for more dig-like `subject.qig(*path)` syntax
|
15
18
|
|
16
19
|
## Installation
|
data/bin/console
CHANGED
data/lib/qig/version.rb
CHANGED
data/lib/qig.rb
CHANGED
@@ -2,39 +2,45 @@
|
|
2
2
|
|
3
3
|
require_relative 'qig/version'
|
4
4
|
|
5
|
+
# Combining the powers of `dig` and `jq`.
|
6
|
+
# Qig is dig extended with jq's value iteration `[]` operator.
|
5
7
|
module Qig
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
class << self
|
9
|
+
# @param subject [Array, Hash, #[]] `subject` to be qug into.
|
10
|
+
# @param path [Array<String, Symbol, Array, Object>] retrieval path to apply to `subject`
|
11
|
+
#
|
12
|
+
# @return [Object, Array<Object>] the value(s) of `subject` located at `path`
|
13
|
+
def qig(subject, *path)
|
14
|
+
unit_qig(subject, *path)
|
15
|
+
end
|
9
16
|
|
10
|
-
|
11
|
-
return subject if subject.nil?
|
17
|
+
private
|
12
18
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
def unit_qig(subject, *path)
|
20
|
+
head, *rest = path
|
21
|
+
case head
|
22
|
+
when nil
|
23
|
+
subject
|
24
|
+
when []
|
25
|
+
subject = subject&.values if subject.is_a? Hash
|
26
|
+
collection_qig(subject, *rest)
|
27
|
+
else
|
28
|
+
unit_qig(subject&.[](head), *rest)
|
29
|
+
end
|
22
30
|
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.collection_qig(subjects, *path)
|
26
|
-
return subjects if subjects.empty?
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
def collection_qig(subjects, *path)
|
33
|
+
head, *rest = path
|
34
|
+
case head
|
35
|
+
when nil
|
36
|
+
subjects
|
37
|
+
when []
|
38
|
+
collection_qig(subjects.map { |s| s.is_a?(Hash) ? s.values : s }.flatten(1), *rest)
|
39
|
+
# not sure this is quite jq-compliant... [] refuses to iterate over atoms, but flatten will just preserve them.
|
40
|
+
# maybe more in the spirit of `dig` though?
|
41
|
+
else
|
42
|
+
collection_qig(subjects.map { |e| e.nil? ? e : e[head] }, *rest)
|
43
|
+
end
|
38
44
|
end
|
39
45
|
end
|
40
46
|
end
|
data/qig.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xiao Fan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -19,6 +19,7 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- ".rspec"
|
21
21
|
- ".rubocop.yml"
|
22
|
+
- ".yardopts"
|
22
23
|
- CHANGELOG.md
|
23
24
|
- CODE_OF_CONDUCT.md
|
24
25
|
- Gemfile
|
@@ -39,6 +40,7 @@ metadata:
|
|
39
40
|
homepage_uri: https://github.com/NAR8789/qig-ruby
|
40
41
|
source_code_uri: https://github.com/NAR8789/qig-ruby
|
41
42
|
changelog_uri: https://github.com/NAR8789/qig-ruby/blob/main/CHANGELOG.md
|
43
|
+
rubygems_mfa_required: 'true'
|
42
44
|
post_install_message:
|
43
45
|
rdoc_options: []
|
44
46
|
require_paths:
|