From f2cf246e4e5e2b5edf1531ec3a75866a1fd93a60 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Sun, 15 Oct 2017 14:27:15 +0800 Subject: [PATCH] Update layouts of some Ruby sheets --- chunky_png.md | 45 ++++++++++++++---- psdrb.md | 128 +++++++++++++++++++++++++++++++------------------- rack-test.md | 7 ++- ronn.md | 75 ++++++++++++++++++++--------- 4 files changed, 173 insertions(+), 82 deletions(-) diff --git a/chunky_png.md b/chunky_png.md index 144cec185..f06339677 100644 --- a/chunky_png.md +++ b/chunky_png.md @@ -1,29 +1,54 @@ --- title: Chunky PNG category: Ruby libraries +layout: 2017/sheet --- ### Loading - image = ChunkyPNG::Image.from_file('filename.png') - image = ChunkyPNG::Image.from_blob(File.read('file.png')) - image = ChunkyPNG::Image.from_io(io) +```ruby +image = ChunkyPNG::Image.from_file('file.png') +``` + +#### Alternate ways + +```ruby +image = ChunkyPNG::Image.from_blob(File.read('file.png')) +image = ChunkyPNG::Image.from_io(io) +``` + +Loads from `file.png`. ### Saving - image.save('filename.png') - File.open('newfile.png', 'wb') { |io| image.write(io) } - binary_string = image.to_blob +```ruby +image.save('filename.png') +``` + +#### Alternate ways + +```ruby +File.open('newfile.png', 'wb') { |io| image.write(io) } +binary_string = image.to_blob +``` + +Writes an image to `newfile.png`. ### Drawing - image[0, 0] = ChunkyPNG::Color.rgba(255, 0,0, 128) - image.line(1, 1, 10, 1, ChunkyPNG::Color.from_hex('#aa007f')) +```ruby +image[0, 0] = ChunkyPNG::Color.rgba(255, 0,0, 128) +image.line(1, 1, 10, 1, ChunkyPNG::Color.from_hex('#aa007f')) +``` ### Canvas - crop(x, y, w, h) +```ruby +crop(x, y, w, h) +``` ### Transforms - new_image = image.flip_horizontally.rotate_right +```ruby +new_image = image.flip_horizontally.rotate_right +``` diff --git a/psdrb.md b/psdrb.md index 5d0e8f90b..b4a44e43e 100644 --- a/psdrb.md +++ b/psdrb.md @@ -1,80 +1,112 @@ --- title: PSD.rb category: Ruby libraries +layout: 2017/sheet +intro: | + [PSD.rb](https://github.com/layervault/psd.rb) parses Photoshop documents in Ruby. --- ### Opening - psd = PSD.new(file, parse_layer_images: true) - psd.parse! +```ruby +psd = PSD.new(file, parse_layer_images: true) +psd.parse! +``` ### Traversing - # Gets the root node. - # A # can be a Group or a Layer. - node = psd.tree +```ruby +# Gets the root node. +# A # can be a Group or a Layer. +node = psd.tree +``` - node.root - node.descendants - node.ancestors - node.siblings - node.subtree +```ruby +node.root +node.descendants +node.ancestors +node.siblings +node.subtree +``` - node.descendant_groups - node.descendant_layers +```ruby +node.descendant_groups +node.descendant_layers +``` ### Layer info - node.name #=> "Layer 2" +```ruby +node.name #=> "Layer 2" +``` - node.top #=> 3 - node.left #=> 3 - node.bottom - node.right +```ruby +node.top #=> 3 +node.left #=> 3 +node.bottom +node.right +``` - # Note: these are interchanged (?) - node.width - node.height +```ruby +# Note: these are interchanged (?) +node.width +node.height +``` - node.visible? - node.hidden? +```ruby +node.visible? +node.hidden? +``` - node.layer? - node.group? +```ruby +node.layer? +node.group? +``` - node.blending_mode #=> "normal" - node.opacity #=> 0..255 - node.fill_opacity #=> 0..255 +```ruby +node.blending_mode #=> "normal" +node.opacity #=> 0..255 +node.fill_opacity #=> 0..255 +``` ### Layer text - node.text #=> (Hash) - node.text[:value] #=> "Text here" - node.text[:font][:name] #=> "Arial" - node.text[:font][:sizes] #=> [6.9] - node.text[:font][:colors] #=> [[255,255,255,255]] - node.text[:font][:css] #=> "font-family: ...;" - node.text[:left] #=> 3 - node.text[:top] - node.text[:right] - node.text[:bottom] - node.text[:transform] #=> (Hash) +```ruby +node.text #=> (Hash) +node.text[:value] #=> "Text here" +node.text[:font][:name] #=> "Arial" +node.text[:font][:sizes] #=> [6.9] +node.text[:font][:colors] #=> [[255,255,255,255]] +node.text[:font][:css] #=> "font-family: ...;" +node.text[:left] #=> 3 +node.text[:top] +node.text[:right] +node.text[:bottom] +node.text[:transform] #=> (Hash) +``` ### Layer effects - fx = node.info[:object_effects] - fx.data['Scl '] # ? - fx.data['GrFl'] # Gradient fill +```ruby +fx = node.info[:object_effects] +``` + +```ruby +fx.data['Scl '] # ? +fx.data['GrFl'] # Gradient fill +``` ### Layer mask - node.mask["mask_size"] == 0 # No mask - node.mask["mask_size"] == 20 # Has mask - node.mask["top"] - node.mask["left"] - node.mask["bottom"] - node.mask["right"] +```ruby +node.mask["mask_size"] == 0 # No mask +node.mask["mask_size"] == 20 # Has mask +node.mask["top"] +node.mask["left"] +node.mask["bottom"] +node.mask["right"] +``` ### Reference - * https://github.com/layervault/psd.rb + * [layervault/psd.rb](https://github.com/layervault/psd.rb) _(github.com)_ diff --git a/rack-test.md b/rack-test.md index 753ec6a1e..4676b77f4 100644 --- a/rack-test.md +++ b/rack-test.md @@ -1,9 +1,12 @@ --- title: rack-test category: Ruby libraries +layout: 2017/sheet --- -```rb +### Methods + +```ruby get 'url' post 'url', 'name' => 'john' put @@ -11,7 +14,9 @@ patch delete options head +``` +```ruby authorize 'user', 'pass' env 'rack.session', csrf: 'token' header 'Content-Type', 'text/html' diff --git a/ronn.md b/ronn.md index 8b06830a5..c0b2ad6bf 100644 --- a/ronn.md +++ b/ronn.md @@ -1,27 +1,36 @@ --- title: Ronn category: Ruby libraries +layout: 2017/sheet +intro: | + Ronn generates Man pages. See [ronn(1)](http://rtomayko.github.io/ronn/ronn.1.html), [ronn-format(7)](http://rtomayko.github.com/ronn/ronn-format.7.html). Also see it on GitHub: [rtomayko/ronn](https://github.com/rtomayko/ronn). --- -Ronn generates Man pages. See [ronn(1)](http://rtomayko.github.io/ronn/ronn.1.html), [ronn-format(7)](http://rtomayko.github.com/ronn/ronn-format.7.html). Also see it on GitHub: [rtomayko/ronn](https://github.com/rtomayko/ronn). -{:.center.brief-intro} +## Getting started +{: .-left-reference} -```sh +### Installation + +#### Installation + +``` gem install ronn ``` -{:.light} -```sh +#### Usage + +``` ronn foo.1.md # creates foo.1.html ronn -r foo.1.md # creates foo.1 (--roff) ronn -r -h foo.1.md # builds --roff and --html ronn -m foo.1.md # view as manpage ``` -{:.light} -## Basic template - -```markdown +Ronn is a Ruby gem. + +### Basic template + +``` name(1) -- short, single-sentence description ============================================= @@ -61,9 +70,21 @@ ronn-format(7), ronn(1) ## Formatting tags +### Inline + +#### Bold + ``` -Bold: `code` **strong** -Underline: _emphasis_ *emphasis* +`code` +**strong** +``` + +#### Underline + +``` + +_emphasis_ +*emphasis* ``` ### Linking @@ -71,13 +92,18 @@ Underline: _emphasis_ *emphasis* ``` Manual references: sh(1) markdown(7) Sections: [STANDARDS][], [SEE ALSO][], [DIFFERENT TEXT][#SEE-ALSO] -URL: [URL link](http://github.com/rstacruz) -URL: ``` - + +#### URL links + +``` +[URL link](http://github.com/rstacruz) + +``` + ## Frequently-used sections - -```markdown + +``` ## SYNOPSIS ## DESCRIPTION ## OPTIONS @@ -95,7 +121,7 @@ URL: ## Other CLI options -```sh +``` --pipe # write to stdout --server, -S # serve in http://localhost:1207 @@ -141,23 +167,26 @@ Place manual files in `man/xxx.1.md`, then in package.json: ``` ## JavaScript version -See [marked-man](https://github.com/kapouer/marked-man). -```sh +### marked-man + +``` npm install -g marked-man marked-man foo.1.md > foo.1 ``` -{:.light} -### Differences +See [marked-man](https://github.com/kapouer/marked-man). + +#### Differences * No definition lists * Can't use `
` ### Mantastic -[mantastic](http://mantastic.herokuapp.com/) is a hosted service. - ``` curl -F page=@mymanpage.md http://mantastic.herokuapp.com ``` + +[mantastic](http://mantastic.herokuapp.com/) is a hosted service. It's not available at the time of writing, I don't know if it'll be back. +