Update layouts of some Ruby sheets
This commit is contained in:
parent
52852bf6d4
commit
f2cf246e4e
|
@ -1,29 +1,54 @@
|
||||||
---
|
---
|
||||||
title: Chunky PNG
|
title: Chunky PNG
|
||||||
category: Ruby libraries
|
category: Ruby libraries
|
||||||
|
layout: 2017/sheet
|
||||||
---
|
---
|
||||||
|
|
||||||
### Loading
|
### Loading
|
||||||
|
|
||||||
image = ChunkyPNG::Image.from_file('filename.png')
|
```ruby
|
||||||
image = ChunkyPNG::Image.from_blob(File.read('file.png'))
|
image = ChunkyPNG::Image.from_file('file.png')
|
||||||
image = ChunkyPNG::Image.from_io(io)
|
```
|
||||||
|
|
||||||
|
#### Alternate ways
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
image = ChunkyPNG::Image.from_blob(File.read('file.png'))
|
||||||
|
image = ChunkyPNG::Image.from_io(io)
|
||||||
|
```
|
||||||
|
|
||||||
|
Loads from `file.png`.
|
||||||
|
|
||||||
### Saving
|
### Saving
|
||||||
|
|
||||||
image.save('filename.png')
|
```ruby
|
||||||
File.open('newfile.png', 'wb') { |io| image.write(io) }
|
image.save('filename.png')
|
||||||
binary_string = image.to_blob
|
```
|
||||||
|
|
||||||
|
#### Alternate ways
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
File.open('newfile.png', 'wb') { |io| image.write(io) }
|
||||||
|
binary_string = image.to_blob
|
||||||
|
```
|
||||||
|
|
||||||
|
Writes an image to `newfile.png`.
|
||||||
|
|
||||||
### Drawing
|
### Drawing
|
||||||
|
|
||||||
image[0, 0] = ChunkyPNG::Color.rgba(255, 0,0, 128)
|
```ruby
|
||||||
image.line(1, 1, 10, 1, ChunkyPNG::Color.from_hex('#aa007f'))
|
image[0, 0] = ChunkyPNG::Color.rgba(255, 0,0, 128)
|
||||||
|
image.line(1, 1, 10, 1, ChunkyPNG::Color.from_hex('#aa007f'))
|
||||||
|
```
|
||||||
|
|
||||||
### Canvas
|
### Canvas
|
||||||
|
|
||||||
crop(x, y, w, h)
|
```ruby
|
||||||
|
crop(x, y, w, h)
|
||||||
|
```
|
||||||
|
|
||||||
### Transforms
|
### Transforms
|
||||||
|
|
||||||
new_image = image.flip_horizontally.rotate_right
|
```ruby
|
||||||
|
new_image = image.flip_horizontally.rotate_right
|
||||||
|
```
|
||||||
|
|
128
psdrb.md
128
psdrb.md
|
@ -1,80 +1,112 @@
|
||||||
---
|
---
|
||||||
title: PSD.rb
|
title: PSD.rb
|
||||||
category: Ruby libraries
|
category: Ruby libraries
|
||||||
|
layout: 2017/sheet
|
||||||
|
intro: |
|
||||||
|
[PSD.rb](https://github.com/layervault/psd.rb) parses Photoshop documents in Ruby.
|
||||||
---
|
---
|
||||||
|
|
||||||
### Opening
|
### Opening
|
||||||
|
|
||||||
psd = PSD.new(file, parse_layer_images: true)
|
```ruby
|
||||||
psd.parse!
|
psd = PSD.new(file, parse_layer_images: true)
|
||||||
|
psd.parse!
|
||||||
|
```
|
||||||
|
|
||||||
### Traversing
|
### Traversing
|
||||||
|
|
||||||
# Gets the root node.
|
```ruby
|
||||||
# A #<Node> can be a Group or a Layer.
|
# Gets the root node.
|
||||||
node = psd.tree
|
# A #<Node> can be a Group or a Layer.
|
||||||
|
node = psd.tree
|
||||||
|
```
|
||||||
|
|
||||||
node.root
|
```ruby
|
||||||
node.descendants
|
node.root
|
||||||
node.ancestors
|
node.descendants
|
||||||
node.siblings
|
node.ancestors
|
||||||
node.subtree
|
node.siblings
|
||||||
|
node.subtree
|
||||||
|
```
|
||||||
|
|
||||||
node.descendant_groups
|
```ruby
|
||||||
node.descendant_layers
|
node.descendant_groups
|
||||||
|
node.descendant_layers
|
||||||
|
```
|
||||||
|
|
||||||
### Layer info
|
### Layer info
|
||||||
|
|
||||||
node.name #=> "Layer 2"
|
```ruby
|
||||||
|
node.name #=> "Layer 2"
|
||||||
|
```
|
||||||
|
|
||||||
node.top #=> 3
|
```ruby
|
||||||
node.left #=> 3
|
node.top #=> 3
|
||||||
node.bottom
|
node.left #=> 3
|
||||||
node.right
|
node.bottom
|
||||||
|
node.right
|
||||||
|
```
|
||||||
|
|
||||||
# Note: these are interchanged (?)
|
```ruby
|
||||||
node.width
|
# Note: these are interchanged (?)
|
||||||
node.height
|
node.width
|
||||||
|
node.height
|
||||||
|
```
|
||||||
|
|
||||||
node.visible?
|
```ruby
|
||||||
node.hidden?
|
node.visible?
|
||||||
|
node.hidden?
|
||||||
|
```
|
||||||
|
|
||||||
node.layer?
|
```ruby
|
||||||
node.group?
|
node.layer?
|
||||||
|
node.group?
|
||||||
|
```
|
||||||
|
|
||||||
node.blending_mode #=> "normal"
|
```ruby
|
||||||
node.opacity #=> 0..255
|
node.blending_mode #=> "normal"
|
||||||
node.fill_opacity #=> 0..255
|
node.opacity #=> 0..255
|
||||||
|
node.fill_opacity #=> 0..255
|
||||||
|
```
|
||||||
|
|
||||||
### Layer text
|
### Layer text
|
||||||
|
|
||||||
node.text #=> (Hash)
|
```ruby
|
||||||
node.text[:value] #=> "Text here"
|
node.text #=> (Hash)
|
||||||
node.text[:font][:name] #=> "Arial"
|
node.text[:value] #=> "Text here"
|
||||||
node.text[:font][:sizes] #=> [6.9]
|
node.text[:font][:name] #=> "Arial"
|
||||||
node.text[:font][:colors] #=> [[255,255,255,255]]
|
node.text[:font][:sizes] #=> [6.9]
|
||||||
node.text[:font][:css] #=> "font-family: ...;"
|
node.text[:font][:colors] #=> [[255,255,255,255]]
|
||||||
node.text[:left] #=> 3
|
node.text[:font][:css] #=> "font-family: ...;"
|
||||||
node.text[:top]
|
node.text[:left] #=> 3
|
||||||
node.text[:right]
|
node.text[:top]
|
||||||
node.text[:bottom]
|
node.text[:right]
|
||||||
node.text[:transform] #=> (Hash)
|
node.text[:bottom]
|
||||||
|
node.text[:transform] #=> (Hash)
|
||||||
|
```
|
||||||
|
|
||||||
### Layer effects
|
### Layer effects
|
||||||
|
|
||||||
fx = node.info[:object_effects]
|
```ruby
|
||||||
fx.data['Scl '] # ?
|
fx = node.info[:object_effects]
|
||||||
fx.data['GrFl'] # Gradient fill
|
```
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
fx.data['Scl '] # ?
|
||||||
|
fx.data['GrFl'] # Gradient fill
|
||||||
|
```
|
||||||
|
|
||||||
### Layer mask
|
### Layer mask
|
||||||
|
|
||||||
node.mask["mask_size"] == 0 # No mask
|
```ruby
|
||||||
node.mask["mask_size"] == 20 # Has mask
|
node.mask["mask_size"] == 0 # No mask
|
||||||
node.mask["top"]
|
node.mask["mask_size"] == 20 # Has mask
|
||||||
node.mask["left"]
|
node.mask["top"]
|
||||||
node.mask["bottom"]
|
node.mask["left"]
|
||||||
node.mask["right"]
|
node.mask["bottom"]
|
||||||
|
node.mask["right"]
|
||||||
|
```
|
||||||
|
|
||||||
### Reference
|
### Reference
|
||||||
|
|
||||||
* https://github.com/layervault/psd.rb
|
* [layervault/psd.rb](https://github.com/layervault/psd.rb) _(github.com)_
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
---
|
---
|
||||||
title: rack-test
|
title: rack-test
|
||||||
category: Ruby libraries
|
category: Ruby libraries
|
||||||
|
layout: 2017/sheet
|
||||||
---
|
---
|
||||||
|
|
||||||
```rb
|
### Methods
|
||||||
|
|
||||||
|
```ruby
|
||||||
get 'url'
|
get 'url'
|
||||||
post 'url', 'name' => 'john'
|
post 'url', 'name' => 'john'
|
||||||
put
|
put
|
||||||
|
@ -11,7 +14,9 @@ patch
|
||||||
delete
|
delete
|
||||||
options
|
options
|
||||||
head
|
head
|
||||||
|
```
|
||||||
|
|
||||||
|
```ruby
|
||||||
authorize 'user', 'pass'
|
authorize 'user', 'pass'
|
||||||
env 'rack.session', csrf: 'token'
|
env 'rack.session', csrf: 'token'
|
||||||
header 'Content-Type', 'text/html'
|
header 'Content-Type', 'text/html'
|
||||||
|
|
69
ronn.md
69
ronn.md
|
@ -1,27 +1,36 @@
|
||||||
---
|
---
|
||||||
title: Ronn
|
title: Ronn
|
||||||
category: Ruby libraries
|
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).
|
## Getting started
|
||||||
{:.center.brief-intro}
|
{: .-left-reference}
|
||||||
|
|
||||||
```sh
|
### Installation
|
||||||
|
|
||||||
|
#### Installation
|
||||||
|
|
||||||
|
```
|
||||||
gem install ronn
|
gem install ronn
|
||||||
```
|
```
|
||||||
{:.light}
|
|
||||||
|
|
||||||
```sh
|
#### Usage
|
||||||
|
|
||||||
|
```
|
||||||
ronn foo.1.md # creates foo.1.html
|
ronn foo.1.md # creates foo.1.html
|
||||||
ronn -r foo.1.md # creates foo.1 (--roff)
|
ronn -r foo.1.md # creates foo.1 (--roff)
|
||||||
ronn -r -h foo.1.md # builds --roff and --html
|
ronn -r -h foo.1.md # builds --roff and --html
|
||||||
ronn -m foo.1.md # view as manpage
|
ronn -m foo.1.md # view as manpage
|
||||||
```
|
```
|
||||||
{:.light}
|
|
||||||
|
|
||||||
## Basic template
|
Ronn is a Ruby gem.
|
||||||
|
|
||||||
```markdown
|
### Basic template
|
||||||
|
|
||||||
|
```
|
||||||
name(1) -- short, single-sentence description
|
name(1) -- short, single-sentence description
|
||||||
=============================================
|
=============================================
|
||||||
|
|
||||||
|
@ -61,9 +70,21 @@ ronn-format(7), ronn(1)
|
||||||
|
|
||||||
## Formatting tags
|
## Formatting tags
|
||||||
|
|
||||||
|
### Inline
|
||||||
|
|
||||||
|
#### Bold
|
||||||
|
|
||||||
```
|
```
|
||||||
Bold: `code` **strong**
|
`code`
|
||||||
Underline: <variable> _emphasis_ *emphasis*
|
**strong**
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Underline
|
||||||
|
|
||||||
|
```
|
||||||
|
<variable>
|
||||||
|
_emphasis_
|
||||||
|
*emphasis*
|
||||||
```
|
```
|
||||||
|
|
||||||
### Linking
|
### Linking
|
||||||
|
@ -71,13 +92,18 @@ Underline: <variable> _emphasis_ *emphasis*
|
||||||
```
|
```
|
||||||
Manual references: sh(1) markdown(7)
|
Manual references: sh(1) markdown(7)
|
||||||
Sections: [STANDARDS][], [SEE ALSO][], [DIFFERENT TEXT][#SEE-ALSO]
|
Sections: [STANDARDS][], [SEE ALSO][], [DIFFERENT TEXT][#SEE-ALSO]
|
||||||
URL: [URL link](http://github.com/rstacruz)
|
```
|
||||||
URL: <http://github.com>
|
|
||||||
|
#### URL links
|
||||||
|
|
||||||
|
```
|
||||||
|
[URL link](http://github.com/rstacruz)
|
||||||
|
<http://github.com>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Frequently-used sections
|
## Frequently-used sections
|
||||||
|
|
||||||
```markdown
|
```
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
@ -95,7 +121,7 @@ URL: <http://github.com>
|
||||||
|
|
||||||
## Other CLI options
|
## Other CLI options
|
||||||
|
|
||||||
```sh
|
```
|
||||||
--pipe # write to stdout
|
--pipe # write to stdout
|
||||||
--server, -S # serve in http://localhost:1207
|
--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
|
## JavaScript version
|
||||||
See [marked-man](https://github.com/kapouer/marked-man).
|
|
||||||
|
|
||||||
```sh
|
### marked-man
|
||||||
|
|
||||||
|
```
|
||||||
npm install -g marked-man
|
npm install -g marked-man
|
||||||
marked-man foo.1.md > foo.1
|
marked-man foo.1.md > foo.1
|
||||||
```
|
```
|
||||||
{:.light}
|
|
||||||
|
|
||||||
### Differences
|
See [marked-man](https://github.com/kapouer/marked-man).
|
||||||
|
|
||||||
|
#### Differences
|
||||||
|
|
||||||
* No definition lists
|
* No definition lists
|
||||||
* Can't use `<br>`
|
* Can't use `<br>`
|
||||||
|
|
||||||
### Mantastic
|
### Mantastic
|
||||||
|
|
||||||
[mantastic](http://mantastic.herokuapp.com/) is a hosted service.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
curl -F page=@mymanpage.md http://mantastic.herokuapp.com
|
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.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue