Sha256: 5c1cb8e1cca5c599c2c41cb189c750f88328f5af38c00563d61e5f35e1e4be5a
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require 'chronicle/etl' require 'faraday' module Chronicle module Pinboard class PinboardExtractor < Chronicle::ETL::Extractor register_connector do |r| r.provider = 'pinboard' r.description = 'bookmarks' end setting :access_token, required: true def prepare @bookmarks = load_bookmarks @username = @config.access_token.split(":").first end def extract @bookmarks.each do |bookmark| yield Chronicle::ETL::Extraction.new(data: bookmark, meta: { username: @username }) end end def results_count @bookmarks.count end private def load_bookmarks params = { auth_token: @config.access_token, format: 'json', meta: true, } params[:fromdt] = @config.since.utc.iso8601 if @config.since conn = Faraday.new( url: 'https://api.pinboard.in/', params: params ) response = conn.get('/v1/posts/all') bookmarks = JSON.parse(response.body, { symbolize_names: true }) bookmarks = bookmarks.keep_if { |bookmark| Time.parse(bookmark[:time]) < @config.until } if @config.until bookmarks end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chronicle-pinboard-0.1.0 | lib/chronicle/pinboard/pinboard_extractor.rb |