
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Extracted modules from the Posterous Blog Importer. A way to structure the code needed to connect to various APIs and conform the results to your liking. At it's core is a very simple module that tries to keep things sane when communicating with a multitude of platforms.
gem install io_tools
Include the Importer.
class PosterousImporter
include IoTools::Importer
end
The Importer gives you a way to structure your import code. Moving data from one API to another consists of two basic steps, Collecting and Conforming. The rest of the work usually ends up being specific to the API that you are dealing with. So look in the lib/server/importers
directory for how to deal with more complicated APIs that require helper methods.
The collect
method.
class PosterousImporter
include IoTools::Importer
collect :feed_items
def feed_items
[{:title => "Fancy Post", :body => "Is fancy."}]
end
end
The collect
method accepts a method name as a symbol
or a block that will provide an Array
of results from the API or feed. This method does not have to do all the work, all it needs to do is return an Array
.
Hey wait, what format do the results have to be in?
It doesn't matter. This is where our friend the conform
method comes in.
class PosterousImporter
include IoTools::Importer
collect :feed_items
conform do |incoming, conformed|
conformed.title = incoming[:title]
conformed.body = incoming[:body]
conformed
end
def feed_items
[{:title => "Fancy Post", :body => "Is fancy."}]
end
end
The conform method is called for every entry in the Array
that is created by the collect
method. This is where you turn crazy camelcase field names from weird APIs into nice clean attributes that suit your systems needs. conform
is passed the incoming item from the Array
produced by the collect
method. Along with an empty Openstruct
to hold whatever values your system needs. These in turn will populate the final conformed_collection
.
Copyright (c) 2010 Posterous Inc. See LICENSE for details.
FAQs
Unknown package
We found that io_tools demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.