jazor 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,10 @@
1
1
  require 'test/unit'
2
2
 
3
- $:.push File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'jazor'
5
-
6
-
7
3
  class TestExecute < Test::Unit::TestCase
8
4
 
9
5
  def test_get
6
+ require 'jazor'
7
+
10
8
  response = Jazor::RestClient.get('http://ajax.googleapis.com/ajax/services/search/web')
11
9
  assert response.code == '200'
12
10
  assert response.body =~ /"responseStatus": 400/
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jazor
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
4
+ hash: 27
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 4
10
- version: 0.0.4
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael T. Conigliaro
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-25 00:00:00 -07:00
19
- default_executable:
18
+ date: 2011-08-23 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: json
@@ -32,7 +31,76 @@ dependencies:
32
31
  version: "0"
33
32
  type: :runtime
34
33
  version_requirements: *id001
35
- description: Jazor is a simple command line JSON parsing tool
34
+ description: |
35
+ = Jazor
36
+
37
+ Jazor (rhymes with "razor") is a simple command line JSON parsing tool.
38
+
39
+ == Installation
40
+
41
+ gem install jazor
42
+
43
+ == Usage
44
+
45
+ jazor [options] [source] [expression ...]
46
+
47
+ === Options
48
+
49
+ See the *--help* command line option.
50
+
51
+ === Sources
52
+
53
+ The *source* argument refers to a file, URL or string containing a JSON object.
54
+ Since attempts to implement a full-featured HTTP client within Jazor would have
55
+ been futile, Jazor also accepts input from STDIN. This means if you ever need
56
+ to use an advanced HTTP option that Jazor doesn't implement, you can always use
57
+ a *real* HTTP client (e.g. {cURL}[http://curl.haxx.se/]) and simply pipe the
58
+ output to Jazor.
59
+
60
+ === Expressions
61
+
62
+ Jazor accepts one or more Ruby *expressions* which are simply eval'ed within
63
+ the context of your JSON object. After Jazor parses your JSON input into native
64
+ Ruby data types (Hash, Array, etc.), these expressions are used to slice and
65
+ dice the data any way you want. The results will be "pretty printed" to STDOUT.
66
+
67
+ Note that hash keys can be accessed via standard Ruby (e.g. foo['bar'],
68
+ foo.fetch('bar'), etc.) or Javascript (e.g. foo.bar) syntax.
69
+
70
+ === Expression Testing
71
+
72
+ Expression testing (*--test*) allows you to test the "truthiness" of your
73
+ expression results. If any expression returns a "falsy" value, Jazor will exit
74
+ with a non-zero return code. This is useful for calling Jazor from within shell
75
+ scripts.
76
+
77
+ == Examples
78
+
79
+ $ jazor http://github.com/api/v2/json/commits/list/mconigliaro/jazor/master commits.count
80
+ 16
81
+
82
+ $ curl --silent http://github.com/api/v2/json/commits/list/mconigliaro/jazor/master | jazor commits.last.message
83
+ initial commit
84
+
85
+ $ jazor '{ "foo": "abc", "bar": [1, 2, 3] }' 'foo.split(//)'
86
+ ["a", "b", "c"]
87
+
88
+ $ jazor '{ "foo": "abc", "bar": [1, 2, 3] }' 'bar.inject { |memo,obj| memo + obj }'
89
+ 6
90
+
91
+ $ jazor '[1, 2, 3, 4, 5]' 'select { |obj| obj.even? }'
92
+ [2, 4]
93
+
94
+ $ jazor '[1, 2, 3, 4, 5]' 'select { |obj| obj.odd? }'
95
+ [1, 3, 5]
96
+
97
+ $ jazor '["a", "b", "c"]' self.count
98
+ 3
99
+
100
+ == Author
101
+
102
+ Michael T. Conigliaro <mike [at] conigliaro [dot] org>
103
+
36
104
  email:
37
105
  - mike [at] conigliaro [dot] org
38
106
  executables:
@@ -47,11 +115,10 @@ files:
47
115
  - README.rdoc
48
116
  - bin/jazor
49
117
  - lib/jazor.rb
50
- - test/test_jazor_bin.rb
51
118
  - test/test.json
52
119
  - test/test_jazor.rb
120
+ - test/test_jazor_bin.rb
53
121
  - test/test_rest_client.rb
54
- has_rdoc: true
55
122
  homepage: http://github.com/mconigliaro/jazor
56
123
  licenses: []
57
124
 
@@ -81,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
148
  requirements: []
82
149
 
83
150
  rubyforge_project: jazor
84
- rubygems_version: 1.3.7
151
+ rubygems_version: 1.8.6
85
152
  signing_key:
86
153
  specification_version: 3
87
154
  summary: Jazor is a simple command line JSON parsing tool