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 | gree/observed | https://github.com/gree/observed | spec/hash/fetcher_spec.rb | Ruby | mit | 88 | master | 529 | require 'spec_helper'
require 'observed/hash/fetcher'
describe Observed::Hash::Fetcher do
subject {
described_class.new(hash)
}
context 'when the source hash is nil' do
let(:hash) { nil }
it 'fails' do
expect { subject }.to raise_error
end
end
context 'when the source hash is nest... |
github | gree/observed | https://github.com/gree/observed | spec/observer_helpers/timer_spec.rb | Ruby | mit | 88 | master | 5,073 | require 'spec_helper'
require 'observed/observer'
require 'observed/observer_helpers/timer'
require 'observed/configurable'
describe describe Observed::ObserverHelpers::Timer do
before {
subject.configure system: sys, logger: logger
}
let(:sys) {
sys = stub('system')
sys.stubs(:now).returns(before... |
github | gree/observed | https://github.com/gree/observed | spec/builtin_plugins/file_spec.rb | Ruby | mit | 88 | master | 3,312 | require 'spec_helper'
require 'observed/builtin_plugins/file'
describe Observed::BuiltinPlugins::File do
include FakeFS::SpecHelpers
subject {
reporter = Observed::BuiltinPlugins::File.new
reporter.configure config
reporter
}
let(:config) {
{ tag_pattern: /foo\..+/, format: formatter, path:... |
github | gree/observed | https://github.com/gree/observed | spec/builtin_plugins/stdout_spec.rb | Ruby | mit | 88 | master | 1,445 | require 'spec_helper'
require 'observed/builtin_plugins/stdout'
describe Observed::BuiltinPlugins::Stdout do
subject {
reporter = Observed::BuiltinPlugins::Stdout.new
reporter.configure config
reporter
}
let(:config) {
{ tag_pattern: /foo\..+/, format: formatter, output: output }
}
let(:o... |
github | gree/observed | https://github.com/gree/observed | omnibus-observed/Vagrantfile | Ruby | mit | 88 | master | 2,904 | # -*- mode: ruby -*-
# vi: set ft=ruby :
require "vagrant"
if Vagrant::VERSION < "1.2.1"
raise "The Omnibus Build Lab is only compatible with Vagrant 1.2.1+"
end
host_project_path = File.expand_path("..", __FILE__)
guest_project_path = "/home/vagrant/#{File.basename(host_project_path)}"
project_name = "observed"
... |
github | gree/observed | https://github.com/gree/observed | omnibus-observed/config/software/observed.rb | Ruby | mit | 88 | master | 545 | name "observed"
#version "0.1.1"
version "master"
dependency "ruby"
dependency "rubygems"
#dependency "bundler"
dependency "rsync"
source :git => "https://github.com/gree/observed.git"
relative_path "observed"
build do
gem "install bundler --no-rdoc --no-ri -v 1.3.0"
bundle "install --path=#{install_dir}/embedd... |
github | gree/observed | https://github.com/gree/observed | omnibus-observed/config/projects/observed.rb | Ruby | mit | 88 | master | 396 | name "observed"
maintainer "KUOKA Yusuke"
homepage "https://github.com/gree/observed"
replaces "observed"
install_path "/opt/observed"
build_version Omnibus::BuildVersion.new.semver
build_iteration 1
# creates required build directories
dependency "preparation"
dependency "observed"
# version manifest f... |
github | gree/observed | https://github.com/gree/observed | integrations/observed-eventmachine/observed-eventmachine.gemspec | Ruby | mit | 88 | master | 1,166 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'observed/eventmachine/version'
Gem::Specification.new do |spec|
spec.name = "observed-eventmachine"
spec.version = Observed::EM::VERSION
spec.authors = ["KUOKA Yusuke"]... |
github | gree/observed | https://github.com/gree/observed | integrations/observed-eventmachine/lib/observed/eventmachine.rb | Ruby | mit | 88 | master | 1,969 | require "eventmachine"
require "observed/eventmachine/version"
module Observed
module EM
# Schedule the observation to run it periodically
# @param [Float|Fixnum] seconds
# @param [Hash] args
# @option args [String] :run The tag of the observation to schedule running. It is the one registered via th... |
github | gree/observed | https://github.com/gree/observed | integrations/observed-eventmachine/examples/observed.rb | Ruby | mit | 88 | master | 698 | require 'observed'
require 'observed/eventmachine'
include Observed
# This is a observed-eventmachine specific code to extend the DSL to use EventMachine
extend Observed::EM
class Test < Observed::Observer
plugin_name 'test'
def observe
puts "Sleeping 10 seconds"
sleep 10.0
puts "Slept 10 seconds"
... |
github | gree/observed | https://github.com/gree/observed | integrations/observed-clockwork/observed-clockwork.gemspec | Ruby | mit | 88 | master | 1,100 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'observed/clockwork/version'
Gem::Specification.new do |spec|
spec.name = "observed-clockwork"
spec.version = Observed::Clockwork::VERSION
spec.authors = ["KUOKA Yusuke"... |
github | gree/observed | https://github.com/gree/observed | integrations/observed-clockwork/lib/observed/clockwork.rb | Ruby | mit | 88 | master | 340 | require 'clockwork'
require 'observed'
require "observed/clockwork/version"
require "observed/application"
module Observed
module Clockwork
extend self
def register_observed_handler(args)
Observed.init!
Observed.configure args
::Clockwork.handler do |job|
Observed.run job
end... |
github | gree/observed | https://github.com/gree/observed | integrations/observed-clockwork/examples/clockwork/foo_plugin.rb | Ruby | mit | 88 | master | 363 | module OneshotSpec
class FooPlugin < Observed::Observer
plugin_name 'foo'
default timeout_in_milliseconds: 5000
default number_of_trials: 10
def observe
sleep_duration = rand / 20
sleep sleep_duration
system.report(tag, "Foo #{sleep_duration}")
end
def logger
@logge... |
github | gree/observed | https://github.com/gree/observed | integrations/observed-clockwork/examples/clockwork/clockwork.rb | Ruby | mit | 88 | master | 209 | require 'clockwork'
require 'observed/clockwork'
include Clockwork
include Observed::Clockwork
register_observed_handler :config_file => File.dirname(__FILE__) + '/observed.conf'
every(10.seconds, 'foo_1') |
github | justincinmd/devise_mailchimp | https://github.com/justincinmd/devise_mailchimp | devise_mailchimp.gemspec | Ruby | mit | 88 | master | 1,179 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "devise_mailchimp/version"
Gem::Specification.new do |s|
s.name = "devise_mailchimp"
s.version = DeviseMailchimp::VERSION
s.authors = ["Justin Cunningham"]
s.email = ["justin@compucatedsolutions.com"]
s.homepa... |
github | justincinmd/devise_mailchimp | https://github.com/justincinmd/devise_mailchimp | lib/devise_mailchimp.rb | Ruby | mit | 88 | master | 2,107 | require 'devise'
require "devise_mailchimp/version"
module DeviseMailchimp
class Engine < Rails::Engine
end
# Your code goes here...
end
module Devise
# Public: Default mailing list for user to join. This can be an array of strings, or just one string.
# By default, this is "Site List". If this will be c... |
github | justincinmd/devise_mailchimp | https://github.com/justincinmd/devise_mailchimp | lib/devise_mailchimp/mailchimp_list_api_mapper.rb | Ruby | mit | 88 | master | 2,674 | require 'hominid'
module Devise
module Models
module Mailchimp
class MailchimpListApiMapper
LIST_CACHE_KEY = "devise_mailchimp/lists"
# craete a new ApiMapper with the provided API key
def initialize(api_key, double_opt_in, send_welcome_email)
@api_key = api_key
... |
github | justincinmd/devise_mailchimp | https://github.com/justincinmd/devise_mailchimp | lib/devise_mailchimp/model.rb | Ruby | mit | 88 | master | 4,377 | module Devise
module Models
# Mailchimp is responsible for joining users to mailchimp lists when the create accounts with devise
# When a user is created, and join_mailing_list is set to true, they will automatically be added to one or more
# mailing lists returned by mailchimp_lists_to_join.
#
# ... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | Rakefile | Ruby | mit | 88 | main | 207 | # frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new
task default: %i[spec rubocop] |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | instructor-rb.gemspec | Ruby | mit | 88 | main | 1,978 | # frozen_string_literal: true
require_relative 'lib/instructor/version'
Gem::Specification.new do |spec|
spec.name = 'instructor-rb'
spec.version = Instructor::VERSION
spec.authors = ['Sergio Bayona', 'Jason Liu']
spec.email = ['bayona.sergio@gmail.com', 'jason@jxnl.co']
spec.summary = 'Structured extracti... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | spec/instructor_spec.rb | Ruby | mit | 88 | main | 465 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Instructor, '.class' do
it 'returns the default mode after patching' do
described_class.from_openai(OpenAI::Client)
expect(described_class.mode).to eq(Instructor::Mode::TOOLS.function)
end
it 'changes the the mode' do
described_clas... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | spec/spec_helper.rb | Ruby | mit | 88 | main | 767 | # frozen_string_literal: true
require 'instructor'
require 'pry-byebug'
require 'vcr'
require 'rspec/json_expectations'
VCR.configure do |config|
config.cassette_library_dir = 'spec/vcr_cassettes'
config.hook_into :webmock
config.configure_rspec_metadata!
config.filter_sensitive_data('<OPENAI_KEY_PLACEHOLDER>... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | spec/examples/autoticketer_spec.rb | Ruby | mit | 88 | main | 3,795 | # frozen_string_literal: true
require 'spec_helper'
require_relative '../helpers/autoticketer_models'
RSpec.describe 'Auto-ticketer' do
RSpec.configure do |c|
c.include AutoticketerModels
end
let(:client) { Instructor.from_openai(OpenAI::Client).new }
let(:data) do
<<~DATA
Alice: Hey team, we ... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | spec/anthropic/patch_spec.rb | Ruby | mit | 88 | main | 3,933 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Instructor::Anthropic::Patch do
subject(:patched_client) { Instructor.from_anthropic(Anthropic::Client) }
let(:user_model) do
Class.new do
include EasyTalk::Model
def self.name
'User'
end
define_schema do
... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | spec/openai/patch_spec.rb | Ruby | mit | 88 | main | 5,879 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Instructor::OpenAI::Patch do
subject(:patched_client) { Instructor.from_openai(OpenAI::Client) }
let(:user_model) do
Class.new do
include EasyTalk::Model
def self.name
'User'
end
def self.instructions
... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | spec/openai/response_spec.rb | Ruby | mit | 88 | main | 1,940 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Instructor::OpenAI::Response do
subject(:response_object) { described_class.new(response) }
let(:response) do
{ 'id' => 'chatcmpl-9DEGpBfHqcS17uJtx1vxpRMEb4DtK',
'object' => 'chat.completion',
'created' => 1_712_940_147,
'mo... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | spec/features/iterable_spec.rb | Ruby | mit | 88 | main | 1,436 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'running an OpenAI function with a multiple object response' do
let(:user_model) do
Class.new do
include EasyTalk::Model
def self.name
'Users'
end
define_schema do
property :name, String
property... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | spec/features/basic_use_spec.rb | Ruby | mit | 88 | main | 823 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'running an OpenAI function call' do
let(:user_model) do
Class.new do
include EasyTalk::Model
def self.name
'User'
end
define_schema do
property :name, String
property :age, Integer
end
... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | spec/helpers/autoticketer_models.rb | Ruby | mit | 88 | main | 1,187 | # frozen_string_literal: true
module AutoticketerModels
class Subtask
include EasyTalk::Model
define_schema do
property :id, Integer, description: 'Unique identifier for the subtask'
property :name, String, description: 'Informative title of the subtask'
end
end
class Ticket
include... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | lib/instructor.rb | Ruby | mit | 88 | main | 1,572 | # frozen_string_literal: true
require 'openai'
require 'anthropic'
require 'easy_talk'
require 'active_support/all'
require_relative 'instructor/version'
require_relative 'instructor/openai/patch'
require_relative 'instructor/openai/response'
require_relative 'instructor/anthropic/patch'
require_relative 'instructor/a... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | lib/instructor/mode.rb | Ruby | mit | 88 | main | 705 | # frozen_string_literal: true
require 'ostruct'
module Instructor
# This module defines constants related to different modes of operation.
# It provides options for tool behavior, function types, and JSON modes.
# Currently supported modes are:
# - tools: select between function, auto, required, and none.
#... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | lib/instructor/anthropic/patch.rb | Ruby | mit | 88 | main | 2,359 | # frozen_string_literal: true
require 'anthropic'
require 'instructor/base/patch'
# The Instructor module provides functionality for interacting with Anthropic's messages API.
module Instructor
module Anthropic
# The `Patch` module provides methods for patching and modifying the Anthropic client behavior.
m... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | lib/instructor/anthropic/response.rb | Ruby | mit | 88 | main | 1,445 | # frozen_string_literal: true
module Instructor
module Anthropic
# The Response class represents the response received from the OpenAI API.
# It takes the raw response and provides convenience methods to access the chat completions,
# tool calls, function responses, and parsed arguments.
class Respon... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | lib/instructor/openai/response.rb | Ruby | mit | 88 | main | 2,348 | # frozen_string_literal: true
module Instructor
module OpenAI
# The Response class represents the response received from the OpenAI API.
# It takes the raw response and provides convenience methods to access the chat completions,
# tool calls, function responses, and parsed arguments.
class Response
... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | lib/instructor/openai/patch.rb | Ruby | mit | 88 | main | 2,813 | # frozen_string_literal: true
require 'instructor/base/patch'
# The Instructor module provides functionality for interacting with OpenAI's chat API.
module Instructor
module OpenAI
# The `Patch` module provides methods for patching and modifying the OpenAI client behavior.
module Patch
include Instruc... |
github | jxnl/instructor-rb | https://github.com/jxnl/instructor-rb | lib/instructor/base/patch.rb | Ruby | mit | 88 | main | 5,096 | # frozen_string_literal: true
module Instructor
module Base
# The `Patch` module provides common methods for patching and modifying the client behavior.
module Patch
# Generates the function name for the API request.
# You can customize the function name for the LLM by adding a `title` key to the... |
github | vigetlabs/cachebar | https://github.com/vigetlabs/cachebar | cachebar.gemspec | Ruby | mit | 88 | master | 3,531 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: cachebar 1.1.1 ruby lib
Gem::Specification.new do |s|
s.name = "cachebar"
s.version = "1.1.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if... |
github | vigetlabs/cachebar | https://github.com/vigetlabs/cachebar | Gemfile | Ruby | mit | 88 | master | 365 | source "http://rubygems.org"
gem "redis"
gem "redis-namespace"
gem 'httparty', '~> 0.8.3'
gem 'activesupport'
group :development do
gem "shoulda"
gem "bundler", "~> 1.0"
gem "jeweler", "~> 1.6"
gem "rcov", :platforms => :ruby_18
gem "webmock"
gem 'vcr', '~> 1.11'
gem 'mocha'
gem 'rake', '~> 0.8.7'
g... |
github | vigetlabs/cachebar | https://github.com/vigetlabs/cachebar | Rakefile | Ruby | mit | 88 | master | 1,321 | # encoding: utf-8
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is... |
github | vigetlabs/cachebar | https://github.com/vigetlabs/cachebar | lib/cachebar.rb | Ruby | mit | 88 | master | 1,253 | require 'ostruct'
require 'httparty'
require 'digest/md5'
require 'active_support'
require 'active_support/core_ext/module/aliasing'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/object/blank'
if RUBY_VERSION < '1.9'
begin
require 'system_timer'
rescue LoadError
... |
github | vigetlabs/cachebar | https://github.com/vigetlabs/cachebar | lib/httparty/httpcache.rb | Ruby | mit | 88 | master | 4,499 | module HTTParty
module HTTPCache
class NoResponseError < StandardError; end
mattr_accessor :perform_caching,
:apis,
:logger,
:redis,
:timeout_length,
:cache_stale_backup_time,
:exceptio... |
github | vigetlabs/cachebar | https://github.com/vigetlabs/cachebar | test/twitter_api.rb | Ruby | mit | 88 | master | 740 | module TwitterAPI
include HTTParty
base_uri 'https://api.twitter.com/1'
format :json
caches_api_responses :key_name => "twitter", :expire_in => 3600
class << self
def user_timeline(username)
get '/statuses/user_timeline.json', :query => {:screen_name => username}
end
def bogus_timeline(us... |
github | vigetlabs/cachebar | https://github.com/vigetlabs/cachebar | test/helper.rb | Ruby | mit | 88 | master | 2,256 | require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'test/unit'
require 'mocha'
require 'shoulda'
require 'vcr'
require 'active_support... |
github | vigetlabs/cachebar | https://github.com/vigetlabs/cachebar | test/test_cachebar.rb | Ruby | mit | 88 | master | 8,213 | require 'helper'
class TestCacheBar < Test::Unit::TestCase
context 'CacheBar' do
context 'mocking redis' do
setup do
@redis = mock
HTTParty::HTTPCache.redis = @redis
end
context 'with caching on' do
context 'with a good response' do
setup do
@uri_... |
github | fnando/notifier | https://github.com/fnando/notifier | notifier.gemspec | Ruby | mit | 88 | main | 1,265 | # frozen_string_literal: true
require "./lib/notifier/version"
Gem::Specification.new do |s|
s.name = "notifier"
s.version = Notifier::Version::STRING
s.platform = Gem::Platform::RUBY
s.authors = ["Nando Vieira"]
s.email = ["me@fnando.com"]
s.homepage = "http://rubygems.org/gems... |
github | fnando/notifier | https://github.com/fnando/notifier | Rakefile | Ruby | mit | 88 | main | 290 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"
require "rubocop/rake_task"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.test_files = FileList["test/**/*_test.rb"]
t.warning = false
end
RuboCop::RakeTask.new
task default: %i[test rubocop] |
github | fnando/notifier | https://github.com/fnando/notifier | test/test_helper.rb | Ruby | mit | 88 | main | 238 | # frozen_string_literal: true
ENV.delete("NOTIFIER")
require "simplecov"
SimpleCov.start
require "bundler/setup"
require "notifier"
require "minitest/utils"
require "minitest/autorun"
module Snarl
def self.show_message(*)
end
end |
github | fnando/notifier | https://github.com/fnando/notifier | test/notifier_test.rb | Ruby | mit | 88 | main | 2,589 | # frozen_string_literal: true
require "test_helper"
class NotifierTest < Minitest::Test
setup do
Notifier.notifiers.each do |notifier|
unless notifier == Notifier::Noop
notifier.stubs(:supported?).returns(false)
end
end
Notifier.default_notifier = nil
ENV.delete("NOTIFIER")
en... |
github | fnando/notifier | https://github.com/fnando/notifier | test/notifier/snarl_test.rb | Ruby | mit | 88 | main | 275 | # frozen_string_literal: true
require "test_helper"
class SnarlTest < Minitest::Test
test "sends notification" do
Snarl.expects(:show_message).with("TITLE", "MESSAGE", "IMAGE")
Notifier::Snarl.notify(title: "TITLE", message: "MESSAGE", image: "IMAGE")
end
end |
github | fnando/notifier | https://github.com/fnando/notifier | lib/notifier.rb | Ruby | mit | 88 | main | 1,617 | # frozen_string_literal: true
require "open3"
require "socket"
require "digest/md5"
require "timeout"
require "rbconfig"
require "English"
require "net/http"
module Notifier
require "notifier/snarl"
require "notifier/hud"
require "notifier/osd_cat"
require "notifier/knotify"
require "notifier/kdialog"
req... |
github | fnando/notifier | https://github.com/fnando/notifier | lib/notifier/kdialog.rb | Ruby | mit | 88 | main | 450 | # frozen_string_literal: true
module Notifier
module Kdialog
extend self
def supported?
Notifier.os?(/(linux|freebsd)/) &&
`which kdialog > /dev/null` &&
$CHILD_STATUS == 0
end
def notify(options)
command = [
"kdialog",
"--title", options[:title].to_s,
... |
github | fnando/notifier | https://github.com/fnando/notifier | lib/notifier/knotify.rb | Ruby | mit | 88 | main | 526 | # frozen_string_literal: true
module Notifier
module Knotify
extend self
def supported?
Notifier.os?(/(linux|freebsd)/) &&
`ps -Al | grep dcop` &&
$CHILD_STATUS == 0
end
def notify(options)
command = [
"dcop",
"knotify",
"default",
"notify... |
github | fnando/notifier | https://github.com/fnando/notifier | lib/notifier/snarl.rb | Ruby | mit | 88 | main | 407 | # frozen_string_literal: true
module Notifier
module Snarl
extend self
def supported?
return false unless Notifier.os?(/(mswin|mingw)/)
begin
require "snarl" unless defined?(::Snarl)
true
rescue LoadError
false
end
end
def notify(options)
::Sna... |
github | fnando/notifier | https://github.com/fnando/notifier | lib/notifier/hud.rb | Ruby | mit | 88 | main | 658 | # frozen_string_literal: true
module Notifier
module Hud
extend self
def supported?
Notifier.os?(/darwin/) && hud_bin
end
def hud_bin
@hud_bin ||= [
"/Applications/hud.app/Contents/MacOS/cli",
File.expand_path("~/Applications/hud.app/Contents/MacOS/cli")
].find {|p... |
github | fnando/notifier | https://github.com/fnando/notifier | lib/notifier/terminal_notifier.rb | Ruby | mit | 88 | main | 933 | # frozen_string_literal: true
module Notifier
module TerminalNotifier
extend self
def supported?
Notifier.os?(/darwin/) && `which terminal-notifier` && $CHILD_STATUS == 0
end
def notify(options)
command = [
"terminal-notifier",
"-ignoreDnD",
"-group", "notifier-r... |
github | fnando/notifier | https://github.com/fnando/notifier | lib/notifier/notify_send.rb | Ruby | mit | 88 | main | 455 | # frozen_string_literal: true
module Notifier
module NotifySend
extend self
def supported?
Notifier.os?(/(linux|freebsd)/) &&
`which notify-send > /dev/null` &&
$CHILD_STATUS == 0
end
def notify(options)
command = [
"notify-send", "-i",
options[:image].to... |
github | fnando/notifier | https://github.com/fnando/notifier | lib/notifier/osd_cat.rb | Ruby | mit | 88 | main | 781 | # frozen_string_literal: true
module Notifier
module OsdCat
extend self
def supported?
Notifier.os?(/(linux|freebsd)/) &&
`which osd_cat > /dev/null` &&
$CHILD_STATUS == 0
end
def notify(options)
color = options.fetch(:color, "white").to_s
command = [
"osd... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | elastictastic.gemspec | Ruby | mit | 88 | master | 1,389 | require File.expand_path('../lib/elastictastic/version', __FILE__)
Gem::Specification.new do |s|
s.name = 'elastictastic'
s.version = Elastictastic::VERSION
s.authors = ['Mat Brown', 'Aubrey Holland', 'John Crepezzi']
s.email = 'mat.a.brown@gmail.com'
s.license = 'MIT'
s.summary = 'Object-document mapper f... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | Rakefile | Ruby | mit | 88 | master | 1,091 | require File.expand_path('../lib/elastictastic/version', __FILE__)
require 'rspec/core/rake_task'
task :default => :release
task :release => [:test, :build, :tag, :update_stable, :push, :cleanup]
desc 'Build gem'
task :build do
system 'gem build elastictastic.gemspec'
end
desc 'Create git release tag'
task :tag do... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic.rb | Ruby | mit | 88 | master | 6,808 | require 'active_support'
require 'active_support/core_ext'
require 'active_model'
require 'elastictastic/adapter'
require 'elastictastic/basic_document'
require 'elastictastic/errors'
require 'elastictastic/client'
require 'elastictastic/configuration'
require 'elastictastic/discrete_persistence_strategy'
require 'ela... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/index.rb | Ruby | mit | 88 | master | 308 | module Elastictastic
class Index
class <<self
def default
new(Elastictastic.config.default_index)
end
end
attr_reader :name
def initialize(name)
@name = name
end
def to_s
@name
end
def ==(other)
name == other.name
end
end
end |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/thrift_adapter.rb | Ruby | mit | 88 | master | 1,700 | begin
require 'thrift'
rescue LoadError
raise LoadError, 'Using the ThriftAdapter requires the "thrift" gem. Please install it.'
end
require 'cgi'
require 'faraday'
require 'elastictastic/thrift/rest'
module Elastictastic
class ThriftAdapter < Faraday::Adapter
def initialize(app, options = {})
super(ap... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/search.rb | Ruby | mit | 88 | master | 5,490 | module Elastictastic
class Search
KEYS = %w(query filter from size sort highlight fields script_fields
preference facets _source)
attr_reader :sort, :from, :size, :fields, :script_fields, :preference, :facets, :_source
delegate :[], :to => :params
def initialize(params = {})
para... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/multi_get.rb | Ruby | mit | 88 | master | 559 | module Elastictastic
class MultiGet
include Enumerable
def initialize
@docspecs = []
@scopes = []
end
def add(scope, *ids)
scope = scope.all
params = scope.multi_get_params
ids.flatten.each do |id|
@docspecs << params.merge('_id' => id.to_s)
@scopes <<... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/optimistic_locking.rb | Ruby | mit | 88 | master | 2,201 | module Elastictastic
module OptimisticLocking
extend ActiveSupport::Concern
module ClassMethods
def create_or_update(*ids, &block)
scope = current_scope
ids.each do |id|
begin
new.tap do |instance|
instance.id = id
yield instance
... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/client.rb | Ruby | mit | 88 | master | 3,440 | module Elastictastic
class Client
attr_reader :connection
def initialize(config)
adapter_options = {
:request_timeout => config.request_timeout,
:write_timeout => config.write_timeout,
:connect_timeout => config.connect_timeout
}
if config.hosts.length == 1
c... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/persistence.rb | Ruby | mit | 88 | master | 1,277 | module Elastictastic
module Persistence
def save(options = {}, &block)
persisted? ? update(options, &block) : create(options, &block)
end
def destroy(options = {}, &block)
if persisted?
Elastictastic.persister.destroy(self, &block)
else
raise OperationNotAllowed, "Cannot... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/scoped.rb | Ruby | mit | 88 | master | 336 | module Elastictastic
module Scoped
def with_scope(scope)
scope_stack.push(scope)
begin
yield
ensure
scope_stack.pop
end
end
def scope_stack
Thread.current["#{name}::scope_stack"] ||= []
end
def current_scope
scope_stack.last || default_scope
... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/observing.rb | Ruby | mit | 88 | master | 548 | module Elastictastic
module Observing
extend ActiveSupport::Concern
extend ActiveModel::Observing::ClassMethods
included do
include ActiveModel::Observing
end
Callbacks::HOOKS.each do |method|
module_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{method}(options = {})
i... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/new_relic_instrumentation.rb | Ruby | mit | 88 | master | 926 | begin
require 'new_relic/agent/method_tracer'
rescue LoadError => e
raise LoadError, "Can't use NewRelic instrumentation without NewRelic gem"
end
module Elastictastic
module NewRelicInstrumentation
extend ActiveSupport::Concern
included do
include NewRelic::Agent::MethodTracer
add_method_t... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/association.rb | Ruby | mit | 88 | master | 569 | module Elastictastic
#
# Container for information about generic Elastictastic associations --
# this might be an embed association or a parent/child association.
#
# @api private
#
class Association
attr_reader :name, :options
def initialize(name, options = {})
@name, @options = name.to_s,... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/transport_methods.rb | Ruby | mit | 88 | master | 359 | module Elastictastic
module TransportMethods
def head(path)
request(:head, path)
end
def get(path)
request(:get, path)
end
def post(path, body)
request(:post, path, body)
end
def put(path, body)
request(:put, path, body)
end
def delete(path)
requ... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/errors.rb | Ruby | mit | 88 | master | 454 | module Elastictastic
Error = Class.new(StandardError)
CancelSave = Class.new(Error)
IllegalModificationError = Class.new(Error)
OperationNotAllowed = Class.new(Error)
MissingParameter = Class.new(Error)
class ConnectionFailed < Error
attr_reader :source
def initialize(source)
super(source.me... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/child_collection_proxy.rb | Ruby | mit | 88 | master | 1,225 | module Elastictastic
class ChildCollectionProxy < Scope
attr_reader :parent
def initialize(association, parent)
super(
parent.index,
association.clazz,
Search.new(
'query' => {
'constant_score' => {
'filter' => { 'term' => { '_parent' => paren... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/scope.rb | Ruby | mit | 88 | master | 13,316 | require 'hashie'
require 'elastictastic/search'
module Elastictastic
class Scope < BasicObject
attr_reader :clazz, :index
def initialize(index, clazz, search = Search.new, parent = nil, routing = nil)
@index, @clazz, @search, @parent, @routing = index, clazz, search, parent, routing
end
def i... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/field.rb | Ruby | mit | 88 | master | 1,100 | module Elastictastic
class Field < BasicObject
private_class_method :new
def self.process(field_name, default_options, &block)
{}.tap do |properties|
new(field_name, default_options, properties, &block)
end
end
def self.with_defaults(options)
options = Util.deep_stringify(o... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/bulk_persistence_strategy.rb | Ruby | mit | 88 | master | 4,433 | require 'stringio'
module Elastictastic
class BulkPersistenceStrategy
DEFAULT_HANDLER = proc { |e| raise(e) if e }
Operation = Struct.new(:id, :commands, :handler, :skip)
def initialize(options)
@operations = []
@operations_by_id = {}
@auto_flush = options.delete(:auto_flush)
@au... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/mass_assignment_security.rb | Ruby | mit | 88 | master | 267 | module Elastictastic
module MassAssignmentSecurity
extend ActiveSupport::Concern
included do
include ActiveModel::MassAssignmentSecurity
end
def attributes=(attributes)
super(sanitize_for_mass_assignment(attributes))
end
end
end |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/parent_child.rb | Ruby | mit | 88 | master | 3,255 | module Elastictastic
module ParentChild
extend ActiveSupport::Concern
module ClassMethods
attr_reader :parent_association
def belongs_to(parent_name, options = {})
@parent_association = Association.new(parent_name, options)
module_eval(<<-RUBY, __FILE__, __LINE__+1)
de... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/callbacks.rb | Ruby | mit | 88 | master | 737 | module Elastictastic
module Callbacks
extend ActiveSupport::Concern
HOOKS = [:save, :create, :update, :destroy]
included do
extend ActiveModel::Callbacks
define_model_callbacks(*HOOKS)
end
def save(options = {})
with_callbacks(:save, options) { super }
end
def create(... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/dirty.rb | Ruby | mit | 88 | master | 4,174 | module Elastictastic
module Dirty
extend ActiveSupport::Concern
included do
include ActiveModel::Dirty
end
module ClassMethods
def define_field(field_name, options, &block)
super
define_dirty_accessors(field_name)
end
def define_embed(embed_name, options)
... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/test_helpers.rb | Ruby | mit | 88 | master | 6,050 | begin
require 'fakeweb'
rescue LoadError => e
raise LoadError, "Elastictastic::TestHelpers requires the 'fakeweb' gem."
end
module Elastictastic
module TestHelpers
ALPHANUM = ('0'..'9').to_a + ('A'..'Z').to_a + ('a'..'z').to_a
def stub_es_create(index, type, id = nil)
if id.nil?
id = gener... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/basic_document.rb | Ruby | mit | 88 | master | 6,182 | module Elastictastic
#
# The top-level module mixed in to classes which will be mapped as
# ElasticSearch documents. Note that most people will want to use the Document
# mixin, which extends BasicDocument with ActiveModel functionality such as
# validations, lifecycle hooks, observers, mass-assignment securi... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/rotor.rb | Ruby | mit | 88 | master | 2,474 | require 'elastictastic/transport_methods'
module Elastictastic
class Rotor
include TransportMethods
NodeUnavailable = Class.new(StandardError)
def initialize(hosts, options)
node_options = {}
[:backoff_threshold, :backoff_start, :backoff_max].each do |key|
node_options[key] = opti... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/adapter.rb | Ruby | mit | 88 | master | 2,538 | require 'elastictastic/transport_methods'
module Elastictastic
class Adapter
include TransportMethods
Response = Struct.new(:status, :headers, :body)
def self.[](str)
case str
when nil then NetHttpAdapter
when /^[a-z_]+$/ then Elastictastic.const_get("#{str.to_s.classify}Adapter")
... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/scope_builder.rb | Ruby | mit | 88 | master | 573 | module Elastictastic
class ScopeBuilder < BasicObject
class <<self
private :new
def build(&block)
new(&block).build
end
end
def initialize(&block)
@block = block
end
def build
@scope = {}
instance_eval(&@block)
@scope
end
def method_mis... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/middleware.rb | Ruby | mit | 88 | master | 2,370 | require 'elastictastic/transport_methods'
module Elastictastic
module Middleware
class Base
include TransportMethods
def initialize(connection)
@connection = connection
end
def request(method, path, body = nil)
@connection.request(method, path, body)
end
en... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/server_error.rb | Ruby | mit | 88 | master | 1,075 | module Elastictastic
module ServerError
ERROR_PATTERN = /^([A-Z][A-Za-z]*)(?::\s*)?(.*)$/
NESTED_PATTERN = /^.*nested:\s+(.*)$/
class ServerError < Elastictastic::Error
attr_accessor :status, :request_path, :request_body
end
class <<self
def const_missing(name)
Class.new(::El... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/configuration.rb | Ruby | mit | 88 | master | 2,023 | module Elastictastic
class Configuration
attr_writer :hosts, :default_index, :auto_refresh, :default_batch_size, :adapter
attr_accessor :logger, :connect_timeout, :request_timeout, :write_timeout, :backoff_threshold, :backoff_start, :backoff_max
attr_reader :extra_middlewares
def initialize
@e... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/document.rb | Ruby | mit | 88 | master | 267 | module Elastictastic
module Document
extend ActiveSupport::Concern
included do
include BasicDocument
include Callbacks
include Observing
include Dirty
include MassAssignmentSecurity
include Validations
end
end
end |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/util.rb | Ruby | mit | 88 | master | 1,463 | module Elastictastic
module Util
extend self
def deep_stringify(hash)
{}.tap do |stringified|
hash.each_pair do |key, value|
stringified[key.to_s] = Hash === value ? deep_stringify(value) : value
end
end
end
def deep_merge(l, r)
if l.nil? then r
elsi... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/discrete_persistence_strategy.rb | Ruby | mit | 88 | master | 2,134 | require 'singleton'
module Elastictastic
class DiscretePersistenceStrategy
include Singleton
DEFAULT_HANDLER = proc { |e| raise(e) if e }
attr_accessor :auto_refresh
def create(doc, &block)
block ||= DEFAULT_HANDLER
begin
response = Elastictastic.client.create(
doc.in... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/multi_search.rb | Ruby | mit | 88 | master | 1,835 | require 'stringio'
module Elastictastic
class MultiSearch
Component = Struct.new(:scope, :search_type)
def self.query(*scopes)
new.query(*scopes).run
end
def self.count(*scopes)
new.count(*scopes).run
end
def initialize
@components = []
end
def query(*scopes)
... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/properties.rb | Ruby | mit | 88 | master | 6,897 | module Elastictastic
module Properties
extend ActiveSupport::Concern
module ClassMethods
def each_field
properties.each_pair do |field, properties|
if properties['properties']
embeds[field].clazz.each_field do |embed_field, embed_properties|
yield("#{field}.#... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/embedded_document.rb | Ruby | mit | 88 | master | 741 | module Elastictastic
module EmbeddedDocument
extend ActiveSupport::Concern
included do
include Properties
include Dirty
include Dirty::EmbeddedDocumentMethods
include MassAssignmentSecurity
include Validations
include ActiveModel::Serializers::JSON
include ActiveMod... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/validations.rb | Ruby | mit | 88 | master | 914 | module Elastictastic
module Validations
extend ActiveSupport::Concern
included do
include ActiveModel::Validations
end
module ClassMethods
def embed(*embed_names)
super
embed_names.extract_options!
args = embed_names + [{ :nested => true }]
validates(*args... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/railtie.rb | Ruby | mit | 88 | master | 1,052 | module Elastictastic
class Railtie < Rails::Railtie
config.elastictastic = Elastictastic.config
initializer "elastictastic.configure_rails" do
config_path = Rails.root.join('config/elastictastic.yml').to_s
config = Elastictastic.config
app_name = Rails.application.class.name.split('::').fir... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/thrift/rest.rb | Ruby | mit | 88 | master | 2,111 | #
# Autogenerated by Thrift Compiler (0.8.0-dev)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
require 'thrift'
require 'elastictastic/thrift/types'
module Elastictastic
module Thrift
module Rest
class Client
include ::Thrift::Client
def execute(request)
... |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/thrift/constants.rb | Ruby | mit | 88 | master | 206 | #
# Autogenerated by Thrift Compiler (0.8.0-dev)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
require 'elastictastic/thrift/types'
module Elastictastic
module Thrift
end
end |
github | brewster/elastictastic | https://github.com/brewster/elastictastic | lib/elastictastic/thrift/types.rb | Ruby | mit | 88 | master | 6,084 | #
# Autogenerated by Thrift Compiler (0.8.0-dev)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
module Elastictastic
module Thrift
module Method
GET = 0
PUT = 1
POST = 2
DELETE = 3
HEAD = 4
OPTIONS = 5
VALUE_MAP = {0 => "GET", 1 => "PUT", 2 => "P... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.