No description
Find a file
Shane Becker 408145f52a Merge pull request #33 from jeena/master
Resolve relative URLs (bugfix)
2015-12-22 17:19:41 -08:00
lib Resolve relative URLs (bugfix) 2015-08-21 21:17:54 +02:00
spec Merge pull request #23 from indieweb/add-spec-for-p-h-foo 2015-12-22 17:11:54 -08:00
.gitignore gitignore coverage 2013-04-18 22:13:34 -07:00
.rspec makes specs way more readable 2013-04-18 22:13:37 -07:00
.travis.yml Remove campfire notifications 2015-12-22 16:12:42 -08:00
Gemfile removes straggling pry 2013-04-18 22:13:38 -07:00
Guardfile adds dependencies 2013-04-18 22:13:34 -07:00
LICENSE.md Change license file to CC0. 2015-12-22 15:33:22 -08:00
microformats2.gemspec Remove reference to G5 2015-12-22 16:52:52 -08:00
Rakefile reorganizes spec cases and fixes a couple few 2013-04-18 22:13:36 -07:00
README.md Change license to CC0. 2015-12-22 15:14:18 -08:00

Microformats2

NO LONGER MAINTAINED

Build Status Code Climate

A Ruby gem to parse HTML containing one or more microformats2 and return a collection of dynamically defined Ruby objects.

A work in progress.

Implemented:

Not Implemented:

Current Version

2.0.1

Requirements

  • "nokogiri"
  • "json"
  • "activesupport"

Installation

Add this line to your application's Gemfile:

gem 'microformats2'

And then execute:

$ bundle

Or install it yourself as:

$ gem install microformats2

Usage

require "microformats2"

source = '<div class="h-card"><p class="p-name">Jessica Lynn Suttles</p></div>'
collection = Microformats2.parse(source)
# using singular accessors
collection.card.name.to_s #=> "Jessica Lynn Suttles"
# using plural accessors
collection.cards.first.names.first.to_s #=> "Jessica Lynn Suttles"

source = '<article class="h-entry">
  <h1 class="p-name">Microformats 2</h1>
  <div class="h-card p-author"><p class="p-name">Jessica Lynn Suttles</p></div>
</article>'
collection = Microformats2.parse(source)
collection.entry.name.to_s #=> "Microformats 2"
# accessing nested microformats
collection.entry.author.format.name.to_s #=> "Jessica Lynn Suttles"

# getting a copy of the canonical microformats2 hash structure
collection.to_hash

# the above, as JSON in a string
collection.to_json
  • source can be a URL, filepath, or HTML

Authors

Contributions

  1. Fork it
  2. Get it running (see Installation above)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Write your code and specs
  5. Commit your changes (git commit -am 'Add some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new Pull Request

If you find bugs, have feature requests or questions, please file an issue.

Specs

To update spec cases that are scraped from other sites. Warning: This could break specs.

rake specs:update

To run specs

rake spec

To keep specs running

guard

License

Microformats2 is dedicated to the public domain using Creative Commons -- CC0 1.0 Universal.

http://creativecommons.org/publicdomain/zero/1.0