jazor 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.gitignore +1 -0
- data/.rvmrc +5 -0
- data/Gemfile +2 -10
- data/Gemfile.lock +15 -13
- data/README.md +4 -0
- data/Rakefile +2 -7
- data/jazor.gemspec +10 -9
- data/lib/jazor.rb +2 -7
- data/lib/jazor/app_info.rb +8 -0
- data/{spec → test}/test.json +0 -0
- data/{spec/jazor_cli_spec.rb → test/test_jazor_cli.rb} +21 -16
- data/{spec/jazor_lib_spec.rb → test/test_jazor_lib.rb} +16 -12
- metadata +57 -31
data/.gemtest
ADDED
File without changes
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/.rvmrc
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,24 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jazor (0.1.7)
|
5
|
+
json
|
6
|
+
term-ansicolor
|
7
|
+
|
1
8
|
GEM
|
2
9
|
remote: http://rubygems.org/
|
3
10
|
specs:
|
4
|
-
|
5
|
-
|
11
|
+
ZenTest (4.8.1)
|
12
|
+
autotest (4.4.6)
|
13
|
+
ZenTest (>= 4.4.1)
|
14
|
+
json (1.7.4)
|
15
|
+
minitest (3.2.0)
|
6
16
|
rake (0.9.2.2)
|
7
|
-
rspec (2.8.0)
|
8
|
-
rspec-core (~> 2.8.0)
|
9
|
-
rspec-expectations (~> 2.8.0)
|
10
|
-
rspec-mocks (~> 2.8.0)
|
11
|
-
rspec-core (2.8.0)
|
12
|
-
rspec-expectations (2.8.0)
|
13
|
-
diff-lcs (~> 1.1.2)
|
14
|
-
rspec-mocks (2.8.0)
|
15
17
|
term-ansicolor (1.0.7)
|
16
18
|
|
17
19
|
PLATFORMS
|
18
20
|
ruby
|
19
21
|
|
20
22
|
DEPENDENCIES
|
21
|
-
|
23
|
+
autotest
|
24
|
+
jazor!
|
25
|
+
minitest
|
22
26
|
rake
|
23
|
-
rspec
|
24
|
-
term-ansicolor
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require
|
2
|
+
require 'rake/testtask'
|
3
3
|
|
4
|
-
|
5
|
-
t.rspec_opts = [
|
6
|
-
"-f doc",
|
7
|
-
"-r #{File.expand_path(File.join(File.dirname(__FILE__), "lib", "jazor.rb"))}"
|
8
|
-
]
|
9
|
-
end
|
4
|
+
Rake::TestTask.new
|
10
5
|
|
11
6
|
task :default => :test
|
data/jazor.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
$:.push File.expand_path(File.join(File.dirname(__FILE__), "lib"))
|
2
|
-
require "jazor"
|
2
|
+
require "jazor/app_info"
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = Jazor::NAME
|
@@ -11,14 +11,15 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.summary = Jazor::DESCRIPTION
|
12
12
|
s.description = Jazor::DESCRIPTION
|
13
13
|
|
14
|
-
s.add_dependency
|
15
|
-
s.add_dependency
|
16
|
-
s.add_dependency("term-ansicolor")
|
14
|
+
s.add_dependency "json"
|
15
|
+
s.add_dependency "term-ansicolor"
|
17
16
|
|
18
|
-
s.add_development_dependency
|
19
|
-
s.add_development_dependency
|
17
|
+
s.add_development_dependency "rake"
|
18
|
+
s.add_development_dependency "minitest"
|
19
|
+
s.add_development_dependency "autotest"
|
20
20
|
|
21
|
-
s.files
|
22
|
-
s.
|
23
|
-
s.
|
21
|
+
s.files = `git ls-files`.split($\)
|
22
|
+
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
23
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
24
|
+
s.require_paths = ["lib"]
|
24
25
|
end
|
data/lib/jazor.rb
CHANGED
@@ -9,14 +9,9 @@ require "pp"
|
|
9
9
|
require "term/ansicolor"
|
10
10
|
require "uri"
|
11
11
|
|
12
|
-
|
12
|
+
require "jazor/app_info"
|
13
13
|
|
14
|
-
|
15
|
-
VERSION = "0.1.6"
|
16
|
-
AUTHOR = "Michael Paul Thomas Conigliaro"
|
17
|
-
AUTHOR_EMAIL = "mike [at] conigliaro [dot] org"
|
18
|
-
DESCRIPTION = "Jazor (JSON razor) is a simple command line JSON parsing tool."
|
19
|
-
URL = "http://github.com/mconigliaro/jazor"
|
14
|
+
module Jazor
|
20
15
|
|
21
16
|
LOG = Logger.new(STDOUT)
|
22
17
|
LOG.level = Logger::INFO
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module Jazor
|
2
|
+
NAME = "jazor"
|
3
|
+
VERSION = "0.1.7"
|
4
|
+
AUTHOR = "Michael Paul Thomas Conigliaro"
|
5
|
+
AUTHOR_EMAIL = "mike [at] conigliaro [dot] org"
|
6
|
+
DESCRIPTION = "Jazor (JSON razor) is a simple command line JSON parsing tool."
|
7
|
+
URL = "http://github.com/mconigliaro/jazor"
|
8
|
+
end
|
data/{spec → test}/test.json
RENAMED
File without changes
|
@@ -1,55 +1,60 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'minitest/pride'
|
3
|
+
|
4
|
+
require "jazor"
|
5
|
+
|
1
6
|
describe "Jazor command" do
|
2
7
|
|
3
|
-
before
|
4
|
-
@test_url = "
|
8
|
+
before do
|
9
|
+
@test_url = "https://api.github.com/repos/mconigliaro/jazor/commits"
|
5
10
|
@test_file = File.expand_path(File.join(File.dirname(__FILE__), "test.json"))
|
6
11
|
@test_hash = JSON.parse(IO.read(@test_file))
|
7
12
|
@jazor_bin = File.expand_path(File.join(File.dirname(__FILE__), "..", "bin", "jazor"))
|
8
13
|
end
|
9
14
|
|
10
15
|
it "prints a help summary on absence of input" do
|
11
|
-
`#{@jazor_bin}
|
16
|
+
assert_match /Usage:/, `#{@jazor_bin}`
|
12
17
|
end
|
13
18
|
|
14
19
|
it "parses JSON from STDIN" do
|
15
|
-
JSON.parse(`cat #{@test_file} | #{@jazor_bin} -q`)
|
20
|
+
assert_equal JSON.parse(`cat #{@test_file} | #{@jazor_bin} -q`), @test_hash
|
16
21
|
end
|
17
22
|
|
18
23
|
it "parses JSON from a URL" do
|
19
|
-
JSON.parse(`#{@jazor_bin} "#{@test_url}"`)
|
24
|
+
assert_kind_of Array, JSON.parse(`#{@jazor_bin} "#{@test_url}"`)
|
20
25
|
end
|
21
26
|
|
22
27
|
it "parses JSON from a file" do
|
23
|
-
JSON.parse(`#{@jazor_bin} #{@test_file}`)
|
28
|
+
assert_equal JSON.parse(`#{@jazor_bin} #{@test_file}`), @test_hash
|
24
29
|
end
|
25
30
|
|
26
31
|
it "parses JSON from ARGV" do
|
27
|
-
JSON.parse(`#{@jazor_bin} '#{IO.read(@test_file)}'`)
|
32
|
+
assert_equal JSON.parse(`#{@jazor_bin} '#{IO.read(@test_file)}'`), @test_hash
|
28
33
|
end
|
29
34
|
|
30
35
|
it "parses true/false values in quirks mode" do
|
31
36
|
[true, false].each do |obj|
|
32
|
-
eval(`#{@jazor_bin} -q "#{obj}"`)
|
37
|
+
assert_equal eval(`#{@jazor_bin} -q "#{obj}"`), obj
|
33
38
|
end
|
34
39
|
end
|
35
40
|
|
36
41
|
it "exits with non-zero status on invalid JSON" do
|
37
42
|
`#{@jazor_bin} invalid`
|
38
|
-
|
43
|
+
refute_equal $?, 0
|
39
44
|
end
|
40
45
|
|
41
46
|
it "parses JSON from a file with an expression" do
|
42
|
-
JSON.parse(`#{@jazor_bin} #{@test_file} test_Array`)
|
43
|
-
eval(`#{@jazor_bin} #{@test_file} test_String`).to_s
|
47
|
+
assert_equal JSON.parse(`#{@jazor_bin} #{@test_file} test_Array`), @test_hash["test_Array"]
|
48
|
+
assert_equal eval(`#{@jazor_bin} #{@test_file} test_String`).to_s, @test_hash["test_String"]
|
44
49
|
%w{Integer Float TrueClass FalseClass}.each do |t|
|
45
|
-
eval(`#{@jazor_bin} #{@test_file} test_#{t}`)
|
50
|
+
assert_equal eval(`#{@jazor_bin} #{@test_file} test_#{t}`), @test_hash["test_#{t}"]
|
46
51
|
end
|
47
|
-
eval(`#{@jazor_bin} #{@test_file} dontexist`)
|
52
|
+
assert_nil eval(`#{@jazor_bin} #{@test_file} dontexist`)
|
48
53
|
end
|
49
54
|
|
50
55
|
it "parses JSON from a file with tests" do
|
51
|
-
`#{@jazor_bin} -t #{@test_file} "test_Integer==123"
|
52
|
-
`#{@jazor_bin} -t #{@test_file} "test_Integer==1234"
|
56
|
+
assert_match /passed/, `#{@jazor_bin} -t #{@test_file} "test_Integer==123"`
|
57
|
+
assert_match /failed/, `#{@jazor_bin} -t #{@test_file} "test_Integer==1234"`
|
53
58
|
end
|
54
59
|
|
55
60
|
it "sorts output" do
|
@@ -60,7 +65,7 @@ describe "Jazor command" do
|
|
60
65
|
'{"foo":1, "bar":2}' => {"bar" => 2, "foo" => 1},
|
61
66
|
'{"1":1, "bar":2}' => {"1" => 1, "bar" => 2}
|
62
67
|
}.each do |k,v|
|
63
|
-
JSON.parse(`#{@jazor_bin} -s '#{k}'`)
|
68
|
+
assert_equal JSON.parse(`#{@jazor_bin} -s '#{k}'`), v
|
64
69
|
end
|
65
70
|
end
|
66
71
|
end
|
@@ -1,6 +1,11 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'minitest/pride'
|
3
|
+
|
4
|
+
require "jazor"
|
5
|
+
|
1
6
|
describe "Jazor lib" do
|
2
7
|
|
3
|
-
before
|
8
|
+
before do
|
4
9
|
@test_file = IO.read(File.expand_path(File.join(File.dirname(__FILE__), "test.json")))
|
5
10
|
@test_hash = JSON.parse(@test_file)
|
6
11
|
end
|
@@ -8,14 +13,14 @@ describe "Jazor lib" do
|
|
8
13
|
%w{String Integer Float TrueClass FalseClass NilClass Array}.each do |t|
|
9
14
|
it "parses #{t} values in the root object" do
|
10
15
|
obj = Jazor::parse(@test_file)["test_#{t}"]
|
11
|
-
|
12
|
-
obj
|
16
|
+
assert_kind_of Kernel.const_get(t), obj
|
17
|
+
assert_equal obj, @test_hash["test_#{t}"]
|
13
18
|
end
|
14
19
|
|
15
20
|
it "evaluates the expression \"test_#{t}\" and returns the correct result" do
|
16
21
|
obj = Jazor::evaluate(Jazor::parse(@test_file), "test_#{t}")
|
17
|
-
|
18
|
-
obj
|
22
|
+
assert_kind_of Kernel.const_get(t), obj
|
23
|
+
assert_equal obj, @test_hash["test_#{t}"]
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
@@ -23,22 +28,21 @@ describe "Jazor lib" do
|
|
23
28
|
|
24
29
|
it "can issue GET requests over HTTP" do
|
25
30
|
response = Jazor::RestClient.get("http://ajax.googleapis.com/ajax/services/search/web")
|
26
|
-
response.code
|
27
|
-
|
31
|
+
assert_equal response.code, "200"
|
32
|
+
assert_match /"responseStatus": 400/, response.body
|
28
33
|
end
|
29
34
|
|
30
35
|
it "can issue GET requests over HTTPS" do
|
31
|
-
response = Jazor::RestClient.get("https://github.com/
|
32
|
-
response.code
|
36
|
+
response = Jazor::RestClient.get("https://api.github.com/repos/mconigliaro/jazor/commits")
|
37
|
+
assert_equal response.code, "200"
|
33
38
|
end
|
34
39
|
|
35
40
|
it "can issue GET requests over HTTP with a query string" do
|
36
41
|
response = Jazor::RestClient.get("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=jazor")
|
37
|
-
response.code
|
38
|
-
|
42
|
+
assert_equal response.code, "200"
|
43
|
+
assert_match /"responseStatus": 200/, response.body
|
39
44
|
end
|
40
45
|
|
41
46
|
end
|
42
47
|
|
43
48
|
end
|
44
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jazor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement:
|
15
|
+
name: json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,21 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: json
|
27
|
-
requirement: &2165108820 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
none: false
|
29
26
|
requirements:
|
30
27
|
- - ! '>='
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: '0'
|
33
|
-
type: :runtime
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *2165108820
|
36
30
|
- !ruby/object:Gem::Dependency
|
37
31
|
name: term-ansicolor
|
38
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
34
|
requirements:
|
41
35
|
- - ! '>='
|
@@ -43,10 +37,31 @@ dependencies:
|
|
43
37
|
version: '0'
|
44
38
|
type: :runtime
|
45
39
|
prerelease: false
|
46
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
47
46
|
- !ruby/object:Gem::Dependency
|
48
47
|
name: rake
|
49
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: minitest
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
60
|
-
requirement:
|
79
|
+
name: autotest
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,7 +85,12 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
description: Jazor (JSON razor) is a simple command line JSON parsing tool.
|
70
95
|
email: mike [at] conigliaro [dot] org
|
71
96
|
executables:
|
@@ -73,16 +98,20 @@ executables:
|
|
73
98
|
extensions: []
|
74
99
|
extra_rdoc_files: []
|
75
100
|
files:
|
76
|
-
-
|
101
|
+
- .gemtest
|
102
|
+
- .gitignore
|
103
|
+
- .rvmrc
|
77
104
|
- Gemfile
|
78
105
|
- Gemfile.lock
|
79
106
|
- README.md
|
107
|
+
- Rakefile
|
80
108
|
- bin/jazor
|
109
|
+
- jazor.gemspec
|
81
110
|
- lib/jazor.rb
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
-
|
111
|
+
- lib/jazor/app_info.rb
|
112
|
+
- test/test.json
|
113
|
+
- test/test_jazor_cli.rb
|
114
|
+
- test/test_jazor_lib.rb
|
86
115
|
homepage: http://github.com/mconigliaro/jazor
|
87
116
|
licenses: []
|
88
117
|
post_install_message:
|
@@ -95,9 +124,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
124
|
- - ! '>='
|
96
125
|
- !ruby/object:Gem::Version
|
97
126
|
version: '0'
|
98
|
-
segments:
|
99
|
-
- 0
|
100
|
-
hash: 2150454013039615028
|
101
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
128
|
none: false
|
103
129
|
requirements:
|
@@ -106,12 +132,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
132
|
version: '0'
|
107
133
|
requirements: []
|
108
134
|
rubyforge_project: jazor
|
109
|
-
rubygems_version: 1.8.
|
135
|
+
rubygems_version: 1.8.23
|
110
136
|
signing_key:
|
111
137
|
specification_version: 3
|
112
138
|
summary: Jazor (JSON razor) is a simple command line JSON parsing tool.
|
113
139
|
test_files:
|
114
|
-
-
|
115
|
-
-
|
116
|
-
-
|
117
|
-
|
140
|
+
- test/test.json
|
141
|
+
- test/test_jazor_cli.rb
|
142
|
+
- test/test_jazor_lib.rb
|
143
|
+
has_rdoc:
|