curly 0.1.0

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.
Files changed (6) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +2 -0
  3. data/README.md +77 -0
  4. data/bin/curly +28 -0
  5. data/curly.gemspec +15 -0
  6. metadata +68 -0
@@ -0,0 +1 @@
1
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
@@ -0,0 +1,77 @@
1
+ curly
2
+ =====
3
+
4
+ curly: A replacement for `curl` which pretty-prints JSON output
5
+
6
+
7
+ Usage
8
+ -----
9
+
10
+ Use this like you would normally use `curl`. By default this script adds the `-i` flag which includes the HTTP headers in the output, which is useful when debugging REST services that return different HTTP codes depending on the response.
11
+
12
+ Any command line arguments you pass to this script will be handed off to cURL.
13
+
14
+
15
+ Example
16
+ -------
17
+
18
+ `curly -d "foo=bar" http://example.com/`
19
+
20
+ `curly https://graph.facebook.com/19292868552`
21
+
22
+ ```
23
+ % Total % Received % Xferd Average Speed Time Time Time Current
24
+ Dload Upload Total Spent Left Speed
25
+ 100 786 100 786 0 0 2259 0 --:--:-- --:--:-- --:--:-- 3144
26
+ HTTP/1.1 200 OK
27
+ Access-Control-Allow-Origin: *
28
+ Cache-Control: private, no-cache, no-store, must-revalidate
29
+ Content-Type: text/javascript; charset=UTF-8
30
+ ETag: "04806e95d2cf191a0e231f2559757767da774bf7"
31
+ Expires: Sat, 01 Jan 2000 00:00:00 GMT
32
+ Pragma: no-cache
33
+ X-FB-Rev: 579367
34
+ X-FB-Debug: 8mgUjMq1LsuQS8tjNekLjIOR9uzgIrtkNadqxJGqyFQ=
35
+ Date: Sat, 23 Jun 2012 19:44:38 GMT
36
+ Connection: keep-alive
37
+ Content-Length: 786
38
+
39
+ {
40
+ "id": "19292868552",
41
+ "name": "Facebook Platform",
42
+ "picture": "http://profile.ak.fbcdn.net/hprofile-ak-ash2/276791_19292868552_1958181823_s.jpg",
43
+ "link": "http://www.facebook.com/platform",
44
+ "likes": 4781431,
45
+ "cover": {
46
+ "cover_id": "10150835335278553",
47
+ "source": "http://sphotos.xx.fbcdn.net/hphotos-ash3/s720x720/547890_10150835335278553_344659408_n.jpg",
48
+ "offset_y": 32
49
+ },
50
+ "category": "Product/service",
51
+ "is_published": true,
52
+ "website": "http://developers.facebook.com",
53
+ "username": "platform",
54
+ "founded": "2007",
55
+ "company_overview": "Facebook Platform enables anyone to build social apps on Facebook and the web.",
56
+ "mission": "To make the web more open and social.",
57
+ "about": "We're building the social web. Get the latest here: developers.facebook.com ",
58
+ "were_here_count": 1,
59
+ "talking_about_count": 20095
60
+ }
61
+ ```
62
+
63
+ Install
64
+ -------
65
+
66
+ The easiest way to use curly is to create a bash alias from `curly` to this script. After cloning this repository, add a line like the following to your bash profile.
67
+
68
+ `alias curly="/Users/aaronpk/Code/curly/curly.rb"`
69
+
70
+ Then you'll need to reload your bash profile:
71
+
72
+ `. ~/.bash_profile`
73
+
74
+ This script also requires the 'json' gem, which you can easily install by running
75
+
76
+ `gem install json`
77
+
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'json'
4
+
5
+ argString = ''
6
+
7
+ ARGV.each do |a|
8
+ if a == '--json'
9
+ argString += ' -H "Content-Type: application/json"'
10
+ elsif a.match /^-/
11
+ argString += " #{a}"
12
+ else
13
+ argString += " \"#{a}\""
14
+ end
15
+ end
16
+
17
+ cmd = "curl -i #{argString}"
18
+
19
+ result = `#{cmd}`
20
+
21
+ result.split(/\n/).each do |line|
22
+ if line.match /^[{\[].*[}\]]$/
23
+ jj JSON.parse line
24
+ else
25
+ puts line
26
+ end
27
+ end
28
+
@@ -0,0 +1,15 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["Aaron Parecki"]
5
+ gem.email = ["aaron@parecki.com"]
6
+ gem.description = gem.summary = "A wrapper for curl which pretty-prints JSON output"
7
+ gem.homepage = "https://github.com/aaronpk/curly"
8
+
9
+ gem.executables = ['curly']
10
+ gem.files = `git ls-files | grep -v myapp`.split("\n")
11
+ gem.name = "curly"
12
+ gem.require_paths = ["lib"]
13
+ gem.version = '0.1.0'
14
+ gem.add_dependency 'json'
15
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: curly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aaron Parecki
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: A wrapper for curl which pretty-prints JSON output
31
+ email:
32
+ - aaron@parecki.com
33
+ executables:
34
+ - curly
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - Gemfile
40
+ - README.md
41
+ - bin/curly
42
+ - curly.gemspec
43
+ homepage: https://github.com/aaronpk/curly
44
+ licenses: []
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 1.8.23
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: A wrapper for curl which pretty-prints JSON output
67
+ test_files: []
68
+ has_rdoc: