Permalink
Browse files

Add meta-bumf

  • Loading branch information...
1 parent 5247a54 commit a1edc3f64aa13cfe1a38cc4cbf439a098710cefd @ConradIrwin committed Jan 15, 2012
Showing with 118 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +19 −0 LICENSE.MIT
  3. +81 −0 README.markdown
  4. +17 −0 pry-highlight.gemspec
View
@@ -0,0 +1 @@
+*.gem
View
@@ -0,0 +1,19 @@
+Copyright (c) 2011 Conrad Irwin <conrad.irwin@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
@@ -0,0 +1,81 @@
+The Pry-higlight gem (`gem install pry-highlight`) adds a `higlight` command (aka. `>>`) to Pry.
+
+This intelligently formats and colourizes the result, so you don't have to.
+
+Features
+========
+
+By default this pretty-prints the previous output value:
+
+
+ [1] pry(main)> '{"hi":"world"}'
+ => "{\"hi\":\"world\"}"
+ [2] pry(main)> >>
+```javascript
+{
+ "hi": "world"
+}
+```
+
+It can auto-detect JSON, XML and Ruby code by default:
+
+
+ [3] pry(main)> JSON.method(:pretty_print).source
+ => " def pretty_print(q)\n q.text inspect\n end\n"
+ [4] pry(main)> >>
+```ruby
+ def pretty_print(q)
+ q.text inspect
+ end
+```
+
+You can also tell it which highlighter to use, see [CodeRay's homepage](http://coderay.rubychan.de/) for the full list.
+
+ [5] pry(main)> "function () {\n return 'meh';\n}"
+ => "function () {\n return 'meh';\n}"
+ [6] pry(main)> >> -t javascript
+```javascript
+function () {
+ return 'meh';
+}
+```
+
+You can give it the value to higlight explicitly:
+
+ [7] pry(main)> >> "<meta><foo/></meta>"
+```xml
+<?xml version="1.0"?>
+<meta>
+ <foo/>
+</meta>
+```
+
+In fact, any combination of ruby and a -t flag works :)
+
+ [8] pry(main)> >> -t html File.read("/var/www/foo.html")
+```html
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <body>
+ <h1>It works!</h1>
+ </body>
+</html>
+```
+
+Even if you try to `>>` a String that isn't understood, you'll still get nice results because newlines will be interpreted correctly:
+
+ [9] pry(main)> "1 2 3\n4 5 6\n7 8 9\n"
+ => "1 2 3\n4 5 6\n7 8 9\n"
+ [10] pry(main)> >>
+ 1 2 3
+ 4 5 6
+ 7 8 9
+
+Issues
+=====
+
+The guessing of type based on the string could do with improvement.
+
+Meta-foo
+========
+
+Licensed under the MIT license, contributions and bug-reports welcome :).
View
@@ -0,0 +1,17 @@
+Gem::Specification.new do |s|
+ s.name = "pry-highlight"
+ s.version = "0.0.1"
+ s.platform = Gem::Platform::RUBY
+ s.author = "Conrad Irwin"
+ s.email = "conrad.irwin@gmail.com"
+ s.license = "MIT"
+ s.homepage = "http://github.com/ConradIrwin/pry-highlight"
+ s.summary = "Adds a >> command to pretty-print Strings"
+ s.description = "Uses JSON, Nokogiri and CodeRay to highlight and prettify JSON, XML, HTML, Ruby and anything else CodeRay supports!"
+ s.files = ["lib/pry-highlight.rb", "README.markdown", "LICENSE.MIT"]
+ s.require_path = "lib"
+ s.add_dependency 'pry'
+ s.add_dependency 'json'
+ s.add_dependency 'nokogiri'
+ s.add_dependency 'coderay'
+end

0 comments on commit a1edc3f

Please sign in to comment.