source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/human_task_agent.rb
Ruby
mit
49,192
master
20,840
module Agents class HumanTaskAgent < Agent default_schedule "every_10m" gem_dependency_check { defined?(RTurk) } description <<~MD The Human Task Agent is used to create Human Intelligence Tasks (HITs) on Mechanical Turk. #{'## Include `rturk` in your Gemfile to use this Agent!' if dependen...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/commander_agent.rb
Ruby
mit
49,192
master
2,159
module Agents class CommanderAgent < Agent include AgentControllerConcern cannot_create_events! description <<~MD The Commander Agent is triggered by schedule or an incoming event, and commands other agents ("targets") to run, disable, configure, or enable themselves. # Action types ...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/phantom_js_cloud_agent.rb
Ruby
mit
49,192
master
5,529
require 'json' require 'uri' module Agents class PhantomJsCloudAgent < Agent include ERB::Util include FormConfigurable include WebRequestConcern can_dry_run! default_schedule 'every_12h' description <<~MD This Agent generates [PhantomJs Cloud](https://phantomjscloud.com/) URLs that ...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/rss_agent.rb
Ruby
mit
49,192
master
11,857
module Agents class RssAgent < Agent include WebRequestConcern cannot_receive_events! can_dry_run! default_schedule "every_1d" gem_dependency_check { defined?(Feedjira) } DEFAULT_EVENTS_ORDER = [['{{date_published}}', 'time'], ['{{last_updated}}', 'time']] description do <<~MD ...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/tumblr_likes_agent.rb
Ruby
mit
49,192
master
2,494
# frozen_string_literal: true module Agents class TumblrLikesAgent < Agent include TumblrConcern gem_dependency_check do Devise.omniauth_providers.include?(:tumblr) && ENV["TUMBLR_OAUTH_KEY"].present? && ENV["TUMBLR_OAUTH_SECRET"].present? end description <<~MD The Tumbl...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/email_agent.rb
Ruby
mit
49,192
master
2,874
require 'net/smtp' module Agents class EmailAgent < Agent include EmailConcern can_dry_run! default_schedule "never" cannot_create_events! no_bulk_receive! description <<~MD The Email Agent sends any events it receives via email immediately. You can specify the email's subject ...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/aftership_agent.rb
Ruby
mit
49,192
master
4,300
require 'uri' module Agents class AftershipAgent < Agent cannot_receive_events! default_schedule "every_10m" description <<~MD The Aftership agent allows you to track your shipment from aftership and emit them into events. To be able to use the Aftership API, you need to generate an `API K...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/attribute_difference_agent.rb
Ruby
mit
49,192
master
3,868
module Agents class AttributeDifferenceAgent < Agent cannot_be_scheduled! description <<~MD The Attribute Difference Agent receives events and emits a new event with the difference or change of a specific attribute in comparison to the previous event received. `path` specifies the JS...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/public_transport_agent.rb
Ruby
mit
49,192
master
5,699
require 'date' require 'cgi' module Agents class PublicTransportAgent < Agent cannot_receive_events! default_schedule "every_2m" description <<~MD The Public Transport Request Agent generates Events based on NextBus GPS transit predictions. Specify the following user settings: * agen...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/twitter_search_agent.rb
Ruby
mit
49,192
master
3,346
module Agents class TwitterSearchAgent < Agent include TwitterConcern can_dry_run! cannot_receive_events! description <<~MD The Twitter Search Agent performs and emits the results of a specified Twitter search. #{twitter_dependencies_missing if dependencies_missing?} If you want ...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/hipchat_agent.rb
Ruby
mit
49,192
master
3,199
module Agents class HipchatAgent < Agent include FormConfigurable cannot_be_scheduled! cannot_create_events! no_bulk_receive! gem_dependency_check { defined?(HipChat) } description <<~MD The Hipchat Agent sends messages to a Hipchat Room #{'## Include `hipchat` in your Gemfile ...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/trigger_agent.rb
Ruby
mit
49,192
master
6,331
module Agents class TriggerAgent < Agent cannot_be_scheduled! can_dry_run! VALID_COMPARISON_TYPES = %w[ regex !regex field<value field<=value field==value field!=value field>=value field>value not\ in ] description <<~MD The Trigger Age...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/evernote_agent.rb
Ruby
mit
49,192
master
12,726
module Agents class EvernoteAgent < Agent include EvernoteConcern description <<~MD The Evernote Agent connects with a user's Evernote note store. Visit [Evernote](https://dev.evernote.com/doc/) to set up an Evernote app and receive an api key and secret. Store these in the Evernote enviro...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/twilio_agent.rb
Ruby
mit
49,192
master
4,212
require 'securerandom' module Agents class TwilioAgent < Agent cannot_be_scheduled! cannot_create_events! no_bulk_receive! gem_dependency_check { defined?(Twilio) } description <<~MD The Twilio Agent receives and collects events and sends them via text message (up to 160 characters) or gi...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/website_agent.rb
Ruby
mit
49,192
master
30,867
require 'nokogiri' require 'date' module Agents class WebsiteAgent < Agent include WebRequestConcern can_dry_run! can_order_created_events! no_bulk_receive! default_schedule "every_12h" UNIQUENESS_LOOK_BACK = 200 UNIQUENESS_FACTOR = 3 description <<~MD The Website Agent scra...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/jq_agent.rb
Ruby
mit
49,192
master
6,055
require 'open3' module Agents class JqAgent < Agent cannot_be_scheduled! can_dry_run! def self.should_run? !!jq_version end def self.jq_command ENV['USE_JQ'].presence end def self.jq_version if command = jq_command Open3.capture2(command, '--version', 2 => IO:...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/weibo_user_agent.rb
Ruby
mit
49,192
master
3,485
module Agents class WeiboUserAgent < Agent include WeiboConcern cannot_receive_events! description <<~MD The Weibo User Agent follows the timeline of a specified Weibo user. It uses this endpoint: http://open.weibo.com/wiki/2/statuses/user_timeline/en You must first set up a Weibo app and g...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/adioso_agent.rb
Ruby
mit
49,192
master
2,546
module Agents class AdiosoAgent < Agent cannot_receive_events! default_schedule "every_1d" description <<~MD The Adioso Agent will tell you the minimum airline prices between a pair of cities, and within a certain period of time. The currency is USD. Please make sure that the difference bet...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/threads_publish_agent.rb
Ruby
mit
49,192
master
4,191
module Agents class ThreadsPublishAgent < Agent include ThreadsConcern cannot_be_scheduled! description <<~MD The Threads Publish Agent publishes Threads posts from the events it receives. #{threads_dependencies_missing if dependencies_missing?} To be able to use this Agent you need ...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/read_file_agent.rb
Ruby
mit
49,192
master
1,122
module Agents class ReadFileAgent < Agent include FormConfigurable include FileHandling cannot_be_scheduled! consumes_file_pointer! def default_options { 'data_key' => 'data' } end description do <<~MD The ReadFileAgent takes events from `FileHandling` ...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/local_file_agent.rb
Ruby
mit
49,192
master
6,493
module Agents class LocalFileAgent < Agent include LongRunnable include FormConfigurable include FileHandling emits_file_pointer! default_schedule 'every_1h' def self.should_run? ENV['ENABLE_INSECURE_AGENTS'] == "true" end description do <<~MD The LocalFileAgent...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/java_script_agent.rb
Ruby
mit
49,192
master
7,692
require 'date' require 'cgi' module Agents class JavaScriptAgent < Agent include FormConfigurable can_dry_run! default_schedule "never" gem_dependency_check { defined?(MiniRacer) } description <<~MD The JavaScript Agent allows you to write code in JavaScript that can create and receive ...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/user_location_agent.rb
Ruby
mit
49,192
master
3,980
require 'securerandom' module Agents class UserLocationAgent < Agent cannot_be_scheduled! gem_dependency_check { defined?(Haversine) } description do <<~MD The User Location Agent creates events based on WebHook POSTS that contain a `latitude` and `longitude`. You can use the [POSTLocati...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/manual_event_agent.rb
Ruby
mit
49,192
master
1,322
module Agents class ManualEventAgent < Agent cannot_be_scheduled! cannot_receive_events! description <<~MD The Manual Event Agent is used to manually create Events for testing or other purposes. Connect this Agent to other Agents and create Events using the UI provided on this Agent's Summar...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/jabber_agent.rb
Ruby
mit
49,192
master
4,464
module Agents class JabberAgent < Agent include LongRunnable include FormConfigurable cannot_be_scheduled! gem_dependency_check { defined?(Jabber) } description <<~MD The Jabber Agent will send any events it receives to your Jabber/XMPP IM account. #{'## Include `xmpp4r` in your Ge...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/http_status_agent.rb
Ruby
mit
49,192
master
3,811
require 'time_tracker' module Agents class HttpStatusAgent < Agent include WebRequestConcern include FormConfigurable can_dry_run! can_order_created_events! default_schedule "every_12h" form_configurable :url form_configurable :disable_redirect_follow, type: :boolean form_configura...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/tumblr_publish_agent.rb
Ruby
mit
49,192
master
6,067
# frozen_string_literal: true module Agents class TumblrPublishAgent < Agent include TumblrConcern cannot_be_scheduled! gem_dependency_check do Devise.omniauth_providers.include?(:tumblr) && ENV["TUMBLR_OAUTH_KEY"].present? && ENV["TUMBLR_OAUTH_SECRET"].present? end descr...
github
huginn/huginn
https://github.com/huginn/huginn
app/models/agents/pdf_info_agent.rb
Ruby
mit
49,192
master
3,259
module Agents class PdfInfoAgent < Agent include WebRequestConcern gem_dependency_check { defined?(PDF::Reader) } cannot_be_scheduled! no_bulk_receive! description <<~MD The PDF Info Agent returns the metadata contained within a given PDF file, using the pdf-reader gem. #{'## Inclu...
github
huginn/huginn
https://github.com/huginn/huginn
app/validators/owned_by_validator.rb
Ruby
mit
49,192
master
253
class OwnedByValidator < ActiveModel::EachValidator def validate_each(record, attribute, association) return if association.all? {|s| s[options[:with]] == record[options[:with]] } record.errors.add(attribute, "must be owned by you") end end
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/user_credentials_controller.rb
Ruby
mit
49,192
master
2,953
class UserCredentialsController < ApplicationController include SortableTable def index set_table_sort sorts: %w[credential_name credential_value], default: { credential_name: :asc } @user_credentials = current_user.user_credentials.reorder(table_sort).page(params[:page]) respond_to do |format| ...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/scenarios_controller.rb
Ruby
mit
49,192
master
3,966
require 'agents_exporter' class ScenariosController < ApplicationController include SortableTable skip_before_action :authenticate_user!, only: :export def index set_table_sort sorts: %w[name public], default: { name: :asc } @scenarios = current_user.scenarios.reorder(table_sort).page(params[:page]) ...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/scenario_imports_controller.rb
Ruby
mit
49,192
master
620
class ScenarioImportsController < ApplicationController def new @scenario_import = ScenarioImport.new(:url => params[:url]) end def create @scenario_import = ScenarioImport.new(scenario_import_params) @scenario_import.set_user(current_user) if @scenario_import.valid? && @scenario_import.import_c...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/events_controller.rb
Ruby
mit
49,192
master
1,163
class EventsController < ApplicationController before_action :load_event, except: [:index, :show] def index if params[:agent_id] @agent = current_user.agents.find(params[:agent_id]) @events = @agent.events.page(params[:page]) else @events = current_user.events.preload(:agent).page(params[...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/omniauth_callbacks_controller.rb
Ruby
mit
49,192
master
1,104
class OmniauthCallbacksController < Devise::OmniauthCallbacksController def action_missing(name) case name.to_sym when *Devise.omniauth_providers reauthorization_service = reauthorization_service_for(name) service = reauthorization_service || current_user.services.initialize_or_update_via_omniauth...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/application_controller.rb
Ruby
mit
49,192
master
3,061
class ApplicationController < ActionController::Base before_action :authenticate_user! before_action :configure_permitted_parameters, if: :devise_controller? helper :all rescue_from 'ActiveRecord::SubclassNotFound' do @undefined_agent_types = current_user.undefined_agent_types render template: 'appli...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/diagrams_controller.rb
Ruby
mit
49,192
master
423
class DiagramsController < ApplicationController def show if params[:scenario_id].present? @scenario = current_user.scenarios.find(params[:scenario_id]) agents = @scenario.agents else agents = current_user.agents end @disabled_agents = agents.inactive agents = agents.active if pa...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/logs_controller.rb
Ruby
mit
49,192
master
318
class LogsController < ApplicationController before_action :load_agent def index @logs = @agent.logs.all render :action => :index, :layout => false end def clear @agent.delete_logs! index end protected def load_agent @agent = current_user.agents.find(params[:agent_id]) end end
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/worker_status_controller.rb
Ruby
mit
49,192
master
993
class WorkerStatusController < ApplicationController def show start = Time.now events = current_user.events if params[:since_id].present? since_id = params[:since_id].to_i events = events.where('id > ?', since_id) end result = events.select('COUNT(id) AS count', 'MIN(id) AS min_id', ...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/agents_controller.rb
Ruby
mit
49,192
master
7,635
class AgentsController < ApplicationController include DotHelper include ActionView::Helpers::TextHelper include SortableTable def index set_table_sort sorts: %w[name created_at last_check_at last_event_at last_receive_at], default: { created_at: :desc } @agents = current_user.agents.preload(:scenario...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/services_controller.rb
Ruby
mit
49,192
master
1,000
class ServicesController < ApplicationController include SortableTable before_action :upgrade_warning, only: :index def index set_table_sort sorts: %w[provider name global], default: { provider: :asc } @services = current_user.services.reorder(table_sort).page(params[:page]) @service_agent_counts =...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/web_requests_controller.rb
Ruby
mit
49,192
master
2,771
# This controller is designed to allow your Agents to receive cross-site Webhooks (POSTs), or to output data streams. # When a POST or GET is received, your Agent will have #receive_web_request called on itself with the incoming params, # method, and requested content-type. # # Requests are routed as follows: # http:...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/jobs_controller.rb
Ruby
mit
49,192
master
2,092
class JobsController < ApplicationController before_action :authenticate_admin! def index @jobs = Delayed::Job.order(Arel.sql("coalesce(failed_at,'1000-01-01'), run_at asc")).page(params[:page]) respond_to do |format| format.html { render layout: !request.xhr? } format.json { render json: @job...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/agents/dry_runs_controller.rb
Ruby
mit
49,192
master
1,739
module Agents class DryRunsController < ApplicationController include ActionView::Helpers::TextHelper def index @events = if params[:agent_id] current_user.agents.find_by(id: params[:agent_id]).received_events.limit(5) elsif params[:source_ids] Event....
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/admin/users_controller.rb
Ruby
mit
49,192
master
3,182
class Admin::UsersController < ApplicationController before_action :authenticate_admin!, except: [:switch_back] before_action :find_user, only: [:edit, :destroy, :update, :deactivate, :activate, :switch_to_user] helper_method :resource def index @users = User.reorder('created_at DESC').page(params[:page]...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/concerns/sortable_table.rb
Ruby
mit
49,192
master
1,885
require 'active_support/concern' module SortableTable extend ActiveSupport::Concern included do helper SortableTableHelper end protected def table_sort raise("You must call set_table_sort in any action using table_sort.") unless @table_sort_info.present? @table_sort_info[:order] end def s...
github
huginn/huginn
https://github.com/huginn/huginn
app/controllers/users/registrations_controller.rb
Ruby
mit
49,192
master
264
module Users class RegistrationsController < Devise::RegistrationsController after_action :create_default_scenario, only: :create private def create_default_scenario DefaultScenarioImporter.import(@user) if @user.persisted? end end end
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/dropbox_concern.rb
Ruby
mit
49,192
master
348
module DropboxConcern extend ActiveSupport::Concern included do include Oauthable valid_oauth_providers :dropbox gem_dependency_check { Devise.omniauth_providers.include?(:dropbox) } end def dropbox DropboxApiClient.new(access_token: oauth_token) end private def oauth_token service...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/assignable_types.rb
Ruby
mit
49,192
master
1,353
module AssignableTypes extend ActiveSupport::Concern included do validate :validate_type end def short_type @short_type ||= type.split("::").pop end def validate_type errors.add(:type, "cannot be changed once an instance has been created") if type_changed? && !new_record? errors.add(:type...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/google_oauth2_concern.rb
Ruby
mit
49,192
master
587
module GoogleOauth2Concern extend ActiveSupport::Concern included do include Oauthable valid_oauth_providers :google end private def google_oauth2_client_id (config = Devise.omniauth_configs[:google]) && config.strategy.client_id end def google_oauth2_client_secret (config = Devise.om...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/threads_concern.rb
Ruby
mit
49,192
master
1,694
module ThreadsConcern extend ActiveSupport::Concern THREADS_DEFAULT_FIELDS = %w[ id media_product_type media_type media_url permalink owner username text timestamp shortcode thumbnail_url children is_quote_post quoted_post reposted_post alt_text l...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/markdown_class_attributes.rb
Ruby
mit
49,192
master
920
module MarkdownClassAttributes extend ActiveSupport::Concern module ClassMethods def markdown_class_attributes(*attributes) attributes.each do |attribute| class_eval <<-RUBY def html_#{attribute} Kramdown::Document.new(#{attribute}, auto_ids: false).to_html.html_safe ...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/file_handling.rb
Ruby
mit
49,192
master
2,346
module FileHandling extend ActiveSupport::Concern def get_file_pointer(file) { file_pointer: { file: file, agent_id: id } } end def has_file_pointer?(event) event.payload['file_pointer'] && event.payload['file_pointer']['file'] && event.payload['file_pointer']['agent_id'] end def get_...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/liquid_interpolatable.rb
Ruby
mit
49,192
master
14,897
# :markup: markdown module LiquidInterpolatable extend ActiveSupport::Concern included do validate :validate_interpolation end def valid?(context = nil) super rescue Liquid::Error errors.empty? end def validate_interpolation interpolated rescue Liquid::ZeroDivisionError => e # Ig...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/liquid_droppable.rb
Ruby
mit
49,192
master
2,022
# frozen_string_literal: true module LiquidDroppable class Drop < Liquid::Drop def initialize(object) @object = object end def to_s @object.to_s end def each (public_instance_methods - Drop.public_instance_methods).each { |name| yield [name, __send__(name)] } ...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/json_serialized_field.rb
Ruby
mit
49,192
master
3,374
require "json_with_indifferent_access" module JsonSerializedField extend ActiveSupport::Concern included do class_attribute :json_serialized_fields, instance_writer: false, default: [] class_attribute :json_serialized_field_methods_defined, instance_writer: false, default: [] end class NativeType < A...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/dry_runnable.rb
Ruby
mit
49,192
master
2,224
module DryRunnable extend ActiveSupport::Concern def dry_run!(event = nil) @dry_run = true log = StringIO.new @dry_run_started_at = Time.zone.now @dry_run_logger = Logger.new(log).tap { |logger| logger.formatter = proc { |severity, datetime, progname, message| elapsed_time = '%02d:%0...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/email_concern.rb
Ruby
mit
49,192
master
1,658
module EmailConcern extend ActiveSupport::Concern MAIN_KEYS = %w[title message text main value] included do self.validate :validate_email_options end def validate_email_options errors.add( :base, "subject and expected_receive_period_in_days are required" ) unless options['subject']....
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/inheritance_tracking.rb
Ruby
mit
49,192
master
452
module InheritanceTracking extend ActiveSupport::Concern module ClassMethods def inherited(subclass) @subclasses ||= [] @subclasses << subclass @subclasses.uniq! super end def subclasses @subclasses end def with_subclasses(*subclasses) original_subclasses =...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/web_request_concern.rb
Ruby
mit
49,192
master
5,621
require 'faraday' module WebRequestConcern module DoNotEncoder def self.encode(params) params.map do |key, value| value.nil? ? "#{key}" : "#{key}=#{value}" end.join('&') end def self.decode(val) [val] end end class CharacterEncoding < Faraday::Middleware def initia...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/event_headers_concern.rb
Ruby
mit
49,192
master
1,560
# frozen_string_literal: true module EventHeadersConcern private def validate_event_headers_options! event_headers_payload({}) rescue ArgumentError => e errors.add(:base, e.message) rescue Liquid::Error => e errors.add(:base, "has an error with Liquid templating: #{e.message}") end def event_...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/openai_concern.rb
Ruby
mit
49,192
master
7,217
module OpenaiConcern extend ActiveSupport::Concern included do include WebRequestConcern end OPENAI_BASE_URI = URI('https://api.openai.com/v1/').freeze DEFAULT_OPENAI_TIMEOUT = 60 # seconds def openai_base_uri url = interpolated['base_url'].presence || ENV['OPENAI_BASE_URL'].presence ...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/long_runnable.rb
Ruby
mit
49,192
master
3,265
=begin Usage Example: class Agents::ExampleAgent < Agent include LongRunnable # Optional # Override this method if you need to group multiple agents based on an API key, # or server they connect to. # Have a look at the TwitterStreamAgent for an example. def self.setup_worker; end class Worker < ...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/oauthable.rb
Ruby
mit
49,192
master
706
module Oauthable extend ActiveSupport::Concern included do |base| @valid_oauth_providers = :all validate :validate_service end def oauthable? true end def validate_service if !service errors.add(:service, :blank) end end def valid_services_for(user) if valid_oauth_provi...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/weibo_concern.rb
Ruby
mit
49,192
master
351
module WeiboConcern extend ActiveSupport::Concern included do self.validate :validate_weibo_options end def validate_weibo_options errors.add(:base, "access_token is required") unless options["access_token"].present? end def weibo_client @weibo_client ||= WeiboApiClient.new(access_token: opti...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/tumblr_concern.rb
Ruby
mit
49,192
master
1,168
# frozen_string_literal: true # Shared Tumblr OAuth helpers for Tumblr agents. module TumblrConcern extend ActiveSupport::Concern included do include Oauthable valid_oauth_providers :tumblr end def tumblr_consumer_key ENV["TUMBLR_OAUTH_KEY"] end def tumblr_consumer_secret ENV["TUMBLR_OA...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/twitter_concern.rb
Ruby
mit
49,192
master
4,657
module TwitterConcern extend ActiveSupport::Concern included do include Oauthable validate :validate_twitter_options valid_oauth_providers :twitter gem_dependency_check { defined?(Twitter) && Devise.omniauth_providers.include?(:twitter) && ENV['TWITTER_OAUTH_KEY'].present? &...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/sortable_events.rb
Ruby
mit
49,192
master
5,994
module SortableEvents extend ActiveSupport::Concern included do validate :validate_events_order end EVENTS_ORDER_KEY = 'events_order'.freeze EVENTS_DESCRIPTION = 'events created in each run'.freeze def description_events_order(*args) self.class.description_events_order(*args) end module Clas...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/evernote_concern.rb
Ruby
mit
49,192
master
1,155
module EvernoteConcern extend ActiveSupport::Concern included do include Oauthable validate :validate_evernote_options valid_oauth_providers :evernote gem_dependency_check { defined?(EvernoteOAuth) && Devise.omniauth_providers.include?(:evernote) } end def evernote_client EvernoteOAuth:...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/form_configurable.rb
Ruby
mit
49,192
master
2,180
module FormConfigurable extend ActiveSupport::Concern included do class_attribute :_form_configurable_fields self._form_configurable_fields = HashWithIndifferentAccess.new { |h, k| h[k] = [] } end delegate :form_configurable_attributes, to: :class delegate :form_configurable_fields, to: :class de...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/working_helpers.rb
Ruby
mit
49,192
master
664
module WorkingHelpers extend ActiveSupport::Concern def event_created_within?(days) last_event_at && last_event_at > days.to_i.days.ago end def recent_error_logs? last_event_at && last_error_log_at && last_error_log_at > (last_event_at - 2.minutes) end def received_event_without_error? (last_...
github
huginn/huginn
https://github.com/huginn/huginn
app/concerns/agent_controller_concern.rb
Ruby
mit
49,192
master
2,641
module AgentControllerConcern extend ActiveSupport::Concern included do can_control_other_agents! validate :validate_control_action end def default_options { 'action' => 'run' } end def control_action interpolated['action'] end def validate_control_action case options[...
github
huginn/huginn
https://github.com/huginn/huginn
app/presenters/form_configurable_agent_presenter.rb
Ruby
mit
49,192
master
3,352
require 'delegate' class Decorator < SimpleDelegator def class __getobj__.class end end class FormConfigurableAgentPresenter < Decorator def initialize(agent, view) @agent = agent @view = view super(agent) end def option_field_for(attribute) data = @agent.form_configurable_fields[attrib...
github
huginn/huginn
https://github.com/huginn/huginn
app/jobs/agent_receive_job.rb
Ruby
mit
49,192
master
578
class AgentReceiveJob < ActiveJob::Base # Given an Agent id and an array of Event ids, load the Agent, call #receive on it with the Event objects, and then # save it with an updated `last_receive_at` timestamp. def perform(agent_id, event_ids) agent = Agent.find(agent_id) begin return if agent.unava...
github
huginn/huginn
https://github.com/huginn/huginn
app/jobs/agent_reemit_job.rb
Ruby
mit
49,192
master
435
class AgentReemitJob < ActiveJob::Base # Given an Agent, re-emit all of agent's events up to (and including) `most_recent_event_id` def perform(agent, most_recent_event_id, delete_old_events = false) # `find_each` orders by PK, so events get re-created in the same order agent.events.where("id <= ?", most_re...
github
huginn/huginn
https://github.com/huginn/huginn
app/jobs/agent_check_job.rb
Ruby
mit
49,192
master
460
class AgentCheckJob < ActiveJob::Base # Given an Agent id, load the Agent, call #check on it, and then save it with an updated `last_check_at` timestamp. def perform(agent_id) agent = Agent.find(agent_id) begin return if agent.unavailable? agent.check agent.last_check_at = Time.now a...
github
huginn/huginn
https://github.com/huginn/huginn
app/jobs/agent_propagate_job.rb
Ruby
mit
49,192
master
955
class AgentPropagateJob < ActiveJob::Base queue_as :propagation def perform Agent.receive! end def self.can_enqueue? case queue_adapter.class.name # not using class since it would load adapter dependent gems when 'ActiveJob::QueueAdapters::DelayedJobAdapter' return Delayed::Job.where(failed_...
github
huginn/huginn
https://github.com/huginn/huginn
app/mailers/system_mailer.rb
Ruby
mit
49,192
master
635
class SystemMailer < ActionMailer::Base default :from => ENV['EMAIL_FROM_ADDRESS'].presence || 'you@example.com' def send_message(options) @groups = options[:groups] @headline = options[:headline] @body = options[:body] mail_options = { to: options[:to], subject: options[:subject] } mail_optio...
github
huginn/huginn
https://github.com/huginn/huginn
app/importers/scenario_import.rb
Ruby
mit
49,192
master
9,277
require 'ostruct' # This is a helper class for managing Scenario imports, used by the ScenarioImportsController. This class behaves much # like a normal ActiveRecord object, with validations and callbacks. However, it is never persisted to the database. class ScenarioImport include ActiveModel::Model include Act...
github
huginn/huginn
https://github.com/huginn/huginn
app/importers/default_scenario_importer.rb
Ruby
mit
49,192
master
605
require 'open-uri' class DefaultScenarioImporter def self.import(user) return unless ENV['IMPORT_DEFAULT_SCENARIO_FOR_ALL_USERS'] == 'true' seed(user) end def self.seed(user) scenario_import = ScenarioImport.new() scenario_import.set_user(user) scenario_file = ENV['DEFAULT_SCENARIO_FILE'].pre...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/shell_command.rb
Ruby
bsd-2-clause
47,751
main
493
# typed: strict # frozen_string_literal: true module Homebrew module ShellCommand extend T::Helpers requires_ancestor { AbstractCommand } sig { void } def run T.bind(self, AbstractCommand) sh_cmd_path = "#{self.class.dev_cmd? ? "dev-cmd" : "cmd"}/#{self.class.command_name}.sh" ra...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/standalone.rb
Ruby
bsd-2-clause
47,751
main
213
# typed: strict # frozen_string_literal: true # This file should be the first `require` in all entrypoints outside the `brew` environment. require_relative "standalone/init" require_relative "standalone/sorbet"
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/linkage_cache_store.rb
Ruby
bsd-2-clause
47,751
main
2,115
# typed: strict # frozen_string_literal: true require "cache_store" # # {LinkageCacheStore} provides methods to fetch and mutate linkage-specific data used # by the `brew linkage` command. # class LinkageCacheStore < CacheStore Key = type_member { { fixed: String } } Value = type_member { { fixed: T::Hash[T.any(S...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/formula_assertions.rb
Ruby
bsd-2-clause
47,751
main
2,055
# typed: strict # frozen_string_literal: true require "utils/output" module Homebrew # Helper functions available in formula `test` blocks. module Assertions include Context include ::Utils::Output::Mixin extend T::Helpers requires_ancestor { Kernel } require "minitest" require "minitest...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/abstract_command.rb
Ruby
bsd-2-clause
47,751
main
2,680
# typed: strong # frozen_string_literal: true require "cli/parser" require "shell_command" require "utils/output" module Homebrew # Subclass this to implement a `brew` command. This is preferred to declaring a named function in the `Homebrew` # module, because: # # - Each Command lives in an isolated namespac...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/lock_file.rb
Ruby
bsd-2-clause
47,751
main
3,105
# typed: strict # frozen_string_literal: true require "fcntl" require "utils/output" # A lock file to prevent multiple Homebrew processes from modifying the same path. class LockFile include Utils::Output::Mixin class OpenFileChangedOnDisk < RuntimeError; end private_constant :OpenFileChangedOnDisk sig { re...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/github_runner.rb
Ruby
bsd-2-clause
47,751
main
620
# typed: strict # frozen_string_literal: true require "linux_runner_spec" require "macos_runner_spec" class GitHubRunner < T::Struct const :platform, Symbol const :arch, Symbol const :spec, T.any(LinuxRunnerSpec, MacOSRunnerSpec) const :macos_version, T.nilable(MacOSVersion) prop :active, T::Boolean, defau...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/build_options.rb
Ruby
bsd-2-clause
47,751
main
2,845
# typed: strict # frozen_string_literal: true # Options for a formula build. class BuildOptions sig { params(args: Options, options: Options).void } def initialize(args, options) @args = args @options = options end # True if a {Formula} is being built with a specific option. # # ### Examples # ...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/linux_runner_spec.rb
Ruby
bsd-2-clause
47,751
main
767
# typed: strict # frozen_string_literal: true class LinuxRunnerSpec < T::Struct const :name, String const :runner, String const :container, T::Hash[Symbol, String] const :workdir, String const :timeout, Integer const :cleanup, T::Boolean prop :testing_formulae, T::Array[String], default: [] sig { ...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/url.rb
Ruby
bsd-2-clause
47,751
main
971
# typed: strict # frozen_string_literal: true require "version" class URL sig { returns(T::Hash[Symbol, T.untyped]) } attr_reader :specs sig { returns(T.nilable(T.any(Symbol, T::Class[AbstractDownloadStrategy]))) } attr_reader :using sig { params(url: String, specs: T::Hash[Symbol, T.untyped]).void } de...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/migrator.rb
Ruby
bsd-2-clause
47,751
main
16,229
# typed: strict # frozen_string_literal: true require "lock_file" require "keg" require "tab" require "utils" require "utils/output" # Helper class for migrating a formula from an old to a new name. class Migrator extend Utils::Output::Mixin include Context include Utils::Output::Mixin # Error for when a mig...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/livecheck.rb
Ruby
bsd-2-clause
47,751
main
8,326
# typed: strict # frozen_string_literal: true require "livecheck/constants" require "livecheck/options" require "cask/cask" # The {Livecheck} class implements the DSL methods used in a formula's, cask's # or resource's `livecheck` block and stores related instance variables. Most # of these methods also return the re...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/head_software_spec.rb
Ruby
bsd-2-clause
47,751
main
366
# typed: strict # frozen_string_literal: true require "software_spec" class HeadSoftwareSpec < SoftwareSpec sig { params(flags: T::Array[String]).void } def initialize(flags: []) super @resource.version(Version.new("HEAD")) end sig { params(_filename: Pathname).returns(NilClass) } def verify_downlo...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/keg_only_reason.rb
Ruby
bsd-2-clause
47,751
main
1,866
# typed: strict # frozen_string_literal: true # Used to annotate formulae that duplicate macOS-provided software # or cause conflicts when linked in. class KegOnlyReason sig { returns(T.any(Symbol, String)) } attr_reader :reason sig { params(reason: T.any(Symbol, String), explanation: String).void } def initi...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/bump.rb
Ruby
bsd-2-clause
47,751
main
5,954
# typed: strict # frozen_string_literal: true require "system_command" require "tap" require "utils/git" require "utils/github" require "utils/output" require "utils/popen" module Homebrew # @api internal module Bump extend SystemCommand::Mixin extend Utils::Output::Mixin class Commit < T::Struct ...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/dependencies.rb
Ruby
bsd-2-clause
47,751
main
1,866
# typed: strict # frozen_string_literal: true require "delegate" require "dependency" require "requirement" # A collection of dependencies. class Dependencies < SimpleDelegator extend T::Generic Elem = type_member(:out) { { fixed: Dependency } } sig { params(args: Dependency).void } def initialize(*args) ...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/context.rb
Ruby
bsd-2-clause
47,751
main
1,938
# typed: strict # frozen_string_literal: true require "monitor" # Module for querying the current execution context. module Context extend MonitorMixin # Struct describing the current execution context. class ContextStruct sig { params(debug: T.nilable(T::Boolean), quiet: T.nilable(T::Boolean), verbose: T....
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/autobump_constants.rb
Ruby
bsd-2-clause
47,751
main
870
# typed: strict # frozen_string_literal: true NO_AUTOBUMP_REASONS_INTERNAL = T.let({ extract_plist: "livecheck uses `:extract_plist` strategy", latest_version: "`version` is set to `:latest`", }.freeze, T::Hash[Symbol, String]) NO_AUTOBUMP_REASONS_DEPRECATED = T.let({ requires_manual_review: "a manual review o...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/dependents_message.rb
Ruby
bsd-2-clause
47,751
main
1,111
# typed: strict # frozen_string_literal: true require "utils/output" class DependentsMessage include ::Utils::Output::Mixin sig { returns(T::Array[T.any(String, Keg)]) } attr_reader :reqs sig { returns(T::Array[String]) } attr_reader :deps, :named_args sig { params(requireds: T::Array[T.any(String, Keg...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/search.rb
Ruby
bsd-2-clause
47,751
main
9,653
# typed: strict # frozen_string_literal: true require "description_cache_store" require "utils/output" module Homebrew # Helper module for searching formulae or casks. module Search extend Utils::Output::Mixin QUERY_REGEX = %r{^/(.*)/$} SearchBlockType = T.type_alias do T.nilable( T.pr...
github
Homebrew/brew
https://github.com/Homebrew/brew
Library/Homebrew/cachable.rb
Ruby
bsd-2-clause
47,751
main
382
# typed: strict # frozen_string_literal: true module Cachable extend T::Generic # Sorbet type members are mutable by design and cannot be frozen. Cache = type_member { { upper: T::Hash[T.anything, T.anything] } } sig { returns(Cache) } def cache @cache ||= T.let(T.cast({}, Cache), T.nilable(Cache)) en...