Skip to content

JupriGH/apify-ruby-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

Apify Ruby SDK Unofficial

dont be sad readme is here

About Ruby (programming language)

Ruby is an interpreted, high-level, general-purpose programming language which supports multiple programming paradigms. It was designed with an emphasis on programming productivity and simplicity. In Ruby, everything is an object, including primitive data types. It was developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan.

About This Actor

Apify Ruby SDK Unofficial Unstable Unsupported Under Maintenance. Inspired by Apify Python SDK

Disclaimer : This library is community library and not supported by Apify

Included :

  • Apify SDK (unofficial)
  • Apify Client (unofficial)

Source Code :

Github

Important Notes (for Ruby beginner like me) :

  • On ruby all evaluated to true except for: false and nil.
  • Function will return value from last expression.

Developer Notes

  • Some method is conflicting with Ruby internal method such as: .initialize, .exit, .fail, etc. Renamed to: .initialize_, .exit_, .fail_ etc.

Installation

git clone https://github.com/JupriGH/apify-ruby-sdk.git
# import inside script
require_relative './apify-ruby-sdk/lib/apify_sdk'

Enable Logging

logger = Apify::Log

# level: INFO | WARN | ERROR | FATAL | UNKNOWN
logger.level = Logger::DEBUG 

# Formatter
logger.formatter = Apify::ActorLogFormatter.new

Basic Usage

# SYNC Mode
# won't be able to receive platform events (aborting, migration, etc.)
# for testing on local development (eg: IRB)
Apify::Actor.main(<callable>)

# ASYNC Mode
# use on apify platform to receive platform events
Async do
	Apify::Actor.main(<callable>)
end

Example #1

Apify::Actor.main( lambda { |actor|
	input = actor.get_input
	0 # optional exit code
})

or

actor = Apify::Actor
actor.main( lambda {
	input = actor.get_input
	0 # optional exit code
})

Example #2

def main(actor)
	input = actor.get_input
end

Apify::Actor.main( method(:main) )

Using "with" emulator

Use with function to emulate Python context manager

# SYNC Mode
with Apify::Actor do |actor|
	input = actor.get_input
end

# ASYNC Mode
Async do
	with Apify::Actor do |actor|
		input = actor.get_input
	end
end

do ... end can be replaced with { ... }

Async {
	with Apify::Actor { |actor|
		input = actor.get_input
	}
}

About

Apify Ruby SDK Unofficial

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages