rjp 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.travis.yml +1 -0
- data/Gemfile +1 -0
- data/bin/rjp +6 -2
- data/lib/rjp/version.rb +1 -1
- data/spec/lib/rjp/rjp_spec.rb +1 -1
- data/spec/rjp_spec.rb +28 -16
- data/spec/spec_helper.rb +9 -0
- metadata +18 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d900408cdf43c6fb54cb59b2a488aac4124a053c
|
4
|
+
data.tar.gz: c747eed69b0d673efdd6290b77fa0cddff139747
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78393f3976e231b2c6410c6e569ee48bdf5584d044a97318502194a6ebd60c3832945b1ae2207eb4817565a94409bf8872f93db594802194837028f7ca615851
|
7
|
+
data.tar.gz: 98568eee9ee12b8803ca3a8bf5faf07e60334e0932c9f9e67d49d238da3c5bd4bbd7fd6ed46ea581e305e370d093cd218c59ba8060904ba271a33f6b800d54c1
|
data/.rspec
ADDED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/bin/rjp
CHANGED
@@ -24,8 +24,12 @@ option_parser = OptionParser.new do |options|
|
|
24
24
|
opts.default_value = default
|
25
25
|
end
|
26
26
|
|
27
|
-
options.on(
|
28
|
-
|
27
|
+
options.on(
|
28
|
+
"-e",
|
29
|
+
"--eval expression",
|
30
|
+
"Block body for output argument. ->(output){ <provided expression> } "
|
31
|
+
) do |code|
|
32
|
+
opts.post_processor = eval "->(output){ #{code} }"
|
29
33
|
end
|
30
34
|
|
31
35
|
options.on_tail("-h", "--help", "You're looking at it!") do
|
data/lib/rjp/version.rb
CHANGED
data/spec/lib/rjp/rjp_spec.rb
CHANGED
data/spec/rjp_spec.rb
CHANGED
@@ -1,24 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'rjp'
|
3
3
|
|
4
4
|
describe 'rjp' do
|
5
5
|
let(:json_string) { %({"level1": #{level1}}) }
|
6
6
|
let(:level1) { %({ "level2" : #{level2} }) }
|
7
7
|
let(:level2) { %([ { "level3a": "level3a_value" }, { "level3b": "level3b_value" } ]) }
|
8
|
-
let(:
|
9
|
-
|
10
|
-
it "accepts stdin" do
|
11
|
-
expect(`echo '{ "key": "value" }' | #{rjp} -k key`).to eq(%("value"\n))
|
12
|
-
end
|
13
|
-
|
14
|
-
it "accepts file list" do
|
15
|
-
`echo '{ "key": "value" }' > /tmp/rjp_json_test`
|
16
|
-
expect(`#{rjp} -k key /tmp/rjp_json_test`).to eq(%("value"\n))
|
17
|
-
`rm /tmp/rjp_json_test`
|
18
|
-
end
|
19
|
-
|
20
|
-
it "outputs formated a hash to stdout" do
|
21
|
-
str=<<-hash
|
8
|
+
let(:output) {
|
9
|
+
<<-hash
|
22
10
|
{
|
23
11
|
"level1" => {
|
24
12
|
"level2" => [
|
@@ -32,7 +20,21 @@ describe 'rjp' do
|
|
32
20
|
}
|
33
21
|
}
|
34
22
|
hash
|
35
|
-
|
23
|
+
}
|
24
|
+
let(:rjp) { File.expand_path(File.join('..', '..', 'bin', 'rjp'), __FILE__) }
|
25
|
+
|
26
|
+
it "accepts stdin" do
|
27
|
+
expect(`echo '{ "key": "value" }' | #{rjp} -k key`).to eq(%("value"\n))
|
28
|
+
end
|
29
|
+
|
30
|
+
it "accepts file list" do
|
31
|
+
`echo '{ "key": "value" }' > /tmp/rjp_json_test`
|
32
|
+
expect(`#{rjp} -k key /tmp/rjp_json_test`).to eq(%("value"\n))
|
33
|
+
`rm /tmp/rjp_json_test`
|
34
|
+
end
|
35
|
+
|
36
|
+
it "outputs formated a hash to stdout" do
|
37
|
+
expect(`echo '#{json_string}' | #{rjp}`).to eq(output)
|
36
38
|
end
|
37
39
|
|
38
40
|
context "when --keys are provided" do
|
@@ -55,4 +57,14 @@ describe 'rjp' do
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
60
|
+
|
61
|
+
context 'when --eval is provided' do
|
62
|
+
it 'returns the result of the block' do
|
63
|
+
expect(`echo '#{json_string}' | #{rjp} -e "'yolo'"`).to eq(%("yolo"\n))
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'passed the output as an argument' do
|
67
|
+
expect(`echo '#{json_string}' | #{rjp} -e "output"`).to eq(output)
|
68
|
+
end
|
69
|
+
end
|
58
70
|
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
CodeClimate::TestReporter.start
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
6
|
+
config.run_all_when_everything_filtered = true
|
7
|
+
config.filter_run :focus
|
8
|
+
config.order = 'random'
|
9
|
+
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjp
|
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
|
- Tyler Dooling
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: awesome_print
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: A command line tool for formatting JSON and extracting values
|
@@ -74,8 +74,9 @@ executables:
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
- .gitignore
|
78
|
-
- .
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
79
80
|
- Gemfile
|
80
81
|
- LICENSE.txt
|
81
82
|
- README.md
|
@@ -87,6 +88,7 @@ files:
|
|
87
88
|
- rjp.gemspec
|
88
89
|
- spec/lib/rjp/rjp_spec.rb
|
89
90
|
- spec/rjp_spec.rb
|
91
|
+
- spec/spec_helper.rb
|
90
92
|
homepage: https://github.com/tylerdooling/rjp
|
91
93
|
licenses:
|
92
94
|
- MIT
|
@@ -97,20 +99,21 @@ require_paths:
|
|
97
99
|
- lib
|
98
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
99
101
|
requirements:
|
100
|
-
- -
|
102
|
+
- - ">="
|
101
103
|
- !ruby/object:Gem::Version
|
102
104
|
version: '0'
|
103
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
106
|
requirements:
|
105
|
-
- -
|
107
|
+
- - ">="
|
106
108
|
- !ruby/object:Gem::Version
|
107
109
|
version: '0'
|
108
110
|
requirements: []
|
109
111
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.2.2
|
111
113
|
signing_key:
|
112
114
|
specification_version: 4
|
113
115
|
summary: A command line tool for formatting JSON and extracting values
|
114
116
|
test_files:
|
115
117
|
- spec/lib/rjp/rjp_spec.rb
|
116
118
|
- spec/rjp_spec.rb
|
119
|
+
- spec/spec_helper.rb
|