Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/namusyaka/ogg
Ogg is an Open Graph Generator.
https://github.com/namusyaka/ogg
Last synced: about 1 month ago
JSON representation
Ogg is an Open Graph Generator.
- Host: GitHub
- URL: https://github.com/namusyaka/ogg
- Owner: namusyaka
- Created: 2013-09-24T13:17:11.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-10-02T13:54:41.000Z (about 11 years ago)
- Last Synced: 2024-04-25T00:28:18.571Z (7 months ago)
- Language: Ruby
- Size: 121 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ogg
[![Build Status](https://travis-ci.org/namusyaka/ogg.png)](https://travis-ci.org/namusyaka/ogg)
Ogg is an Open Graph Generator, support *Basic Metadata*, *Optional Metadata*, *Structured Properties* at present.
[Whats is Open Graph?](http://ogp.me/)
## Installation
add this line to your Gemfile. `gem 'ogg'`
or
`$ gem install ogg`
## Usage
### Basic
Basic style.
```ruby
require 'ogg'ogg = Ogg.new
ogg.title = 'Site Title'
ogg.type = 'Article'
ogg.description = 'Description'
ogg.url = 'http://example.com/'
ogg.image = 'http://example.com/example.png'
ogg.html
```Ogg support new method with block.
```ruby
ogg = Ogg.new do |o|
o.title = 'Site Title'
o.type = 'Article'
o.description = 'Description'
o.url = 'http://example.com/'
o.image = 'http://example.com/example.png'
end
ogg.html
```### `:raise`
If you set :raise option and basic properties are inadequacy, occurs `InvalidBasicProperty`.
```ruby
ogg = Ogg.new(:raise => true)
begin
ogg.html
rescue InvalidBasicProperty
puts "called"
end
```### Structured Properties
#### like accessor
```ruby
ogg = Ogg.new do |o|
o.image.url = "http://example.com/example.png"
o.image.secure_url = "https://example.com/example.png"
o.image.type = "image/png"
o.image.width = "400"
o.image.height = "300"o.video.secure_url = "https://example.com/example.swf"
o.video.type = "application/x-shockwave-flash"
o.video.width = "400"
o.video.height = "300"o.audio.secure_url = "https://example.com/example.mp3"
o.audio.type = "audio/mpeg"
end
ogg.html
```#### like hash
```ruby
ogg = Ogg.new do |o|
o.image[:url] = "http://example.com/example.png"
o.image[:secure_url] = "https://example.com/example.png"
o.image[:type] = "image/png"
o.image[:width] = "400"
o.image[:height] = "300"o.video[:secure_url] = "https://example.com/example.swf"
o.video[:type] = "application/x-shockwave-flash"
o.video[:width] = "400"
o.video[:height] = "300"o.audio[:secure_url] = "https://example.com/example.mp3"
o.audio[:type] = "audio/mpeg"
end
ogg.html
```### Generate html
```ruby
ogg = Ogg.new
ogg.title = 'Site Title'
ogg.type = 'Article'
ogg.description = 'Description'
ogg.url = 'http://example.com/'
ogg.image = 'http://example.com/example.png'
```#### `html`
```ruby
ogg.html #=>
=begin=end
```#### `basic_properties`
```ruby
ogg.basic_properties #=>
=begin=end
```#### `optional_properties`
```ruby
ogg.optional_properties #=>
```## Contributing
1. fork the project.
2. create your feature branch. (`git checkout -b my-feature`)
3. commit your changes. (`git commit -am 'commit message'`)
4. push to the branch. (`git push origin my-feature`
5. send pull request.## License
the MIT License