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
delano/rye
https://github.com/delano/rye
lib/rye.rb
Ruby
mit
235
master
9,451
# vim: set sw=2 ts=2 : module Rye unless defined?(Rye::HOME) HOME = File.expand_path( File.join(File.dirname(__FILE__), '..') ) end end require 'logger' require 'thread' require 'base64' require 'net/ssh' require 'net/scp' require 'openssl' require 'tempfile' require 'highline' require 'timeout' require 'sto...
github
delano/rye
https://github.com/delano/rye
lib/rye/dsl.rb
Ruby
mit
235
master
2,361
require 'docile' module Rye class Set def run cmd instance_eval &@@command[cmd] end end end @hosts, @hostsets, @contexts = {}, {}, {} @parallel = nil @@colors = false || ENV['COLORS'] || ENV['TERM'].match(/.*color.*/) @@command = {} def parallel state; @parallel = state; end def colors state; @@...
github
delano/rye
https://github.com/delano/rye
lib/rye/rap.rb
Ruby
mit
235
master
4,157
# vim: set sw=2 ts=2 : module Rye; # Rye::Rap # # This class is a modified Array which is returned by # all command methods. The command output is split # by line into an instance of this class. If there is # only a single element it will act like a String. # # This class also contains a reference ...
github
delano/rye
https://github.com/delano/rye
lib/rye/key.rb
Ruby
mit
235
master
4,796
# vim: set sw=2 ts=2 : module Rye class Key class BadFile < RuntimeError def initialize(m); @m = m; end def message; "That ain't a no key. #{$/}#{@m}"; end end class BadPerm < RuntimeError def initialize(m); @m = m; end def message; "Bad file permissions. Set to 0600. #{$/}#{@m}";...
github
delano/rye
https://github.com/delano/rye
lib/rye/set.rb
Ruby
mit
235
master
5,687
# vim: set sw=2 ts=2 : module Rye # = Rye::Set # # class Set attr_reader :name attr_reader :boxes attr_reader :opts # Run commands in parallel? A Boolean value. Default: false. attr_accessor :parallel # * +name+ The name of the set of machines # * +opts+ a hash of optional arg...
github
delano/rye
https://github.com/delano/rye
lib/rye/hop.rb
Ruby
mit
235
master
14,188
# vim : set sw=2 ts=2 : require 'socket' module Rye DEBUG = false unless defined?(Rye::DEBUG) # = Rye::Hop # # The Rye::Hop class represents a machine. # This class allows boxes to by accessed via it. # # rhop = Rye::Hop.new('firewall.lan') # rbox = Rye::Box.new('filibuster', :via => rhop) ...
github
delano/rye
https://github.com/delano/rye
lib/rye/box.rb
Ruby
mit
235
master
42,623
# vim: set sw=2 ts=2 : require 'annoy' require 'readline' module Rye DEBUG = false unless defined?(Rye::DEBUG) # = Rye::Box # # The Rye::Box class represents a machine. All system # commands are made through this class. # # rbox = Rye::Box.new('filibuster') # rbox.hostname # => filibuster...
github
delano/rye
https://github.com/delano/rye
lib/rye/cmd.rb
Ruby
mit
235
master
14,001
# vim: set sw=2 ts=2 : module Rye; # = Rye::Cmd # # This class contains all of the shell command methods # available to an instance of Rye::Box. For security and # general safety, Rye only permits this whitelist of # commands by default. However, you're free to add methods # with mixins. # # ...
github
delano/rye
https://github.com/delano/rye
try/35_basics_with_hop.rb
Ruby
mit
235
master
915
require 'rye' ## a Rye::Hop instance defaults to localhost lhop = Rye::Hop.new "localhost" lhop.host #=> 'localhost' ## can set up arbitray port forwards from the hop, a give you the localport lhop = Rye::Hop.new "localhost" lhop.host lport = lhop.fetch_port("localhost", 22) lport.is_a?(Fixnum) #=> true ## Rye::Box...
github
delano/rye
https://github.com/delano/rye
try/13_set_tryouts.rb
Ruby
mit
235
master
919
require "rye" @dev_null = File.open("/dev/null", "w") @opt_test_set = Rye::Set.new( "option passing test", :safe => false, :debug => @dev_null, :error => @dev_null ) @opt_test_set.add_boxes("11.22.33.44") @opt_test_box = @opt_test_set.boxes.first @para_set_test = Rye::Set.new( "parallel test set", :para...
github
delano/rye
https://github.com/delano/rye
try/12_batch_tryouts.rb
Ruby
mit
235
master
358
require 'rye' ## can execute commands in a batch r = Rye::Box.new file = "/tmp/rye-#{rand.to_s}" r.batch do touch file end r.file_exists? file #=> true ## a batch can take arguments r = Rye::Box.new file = r.batch("/tmp/rye-#{rand.to_s}") do |f| touch f f end r.file_exists? file #=> true r = Rye::Box.new ...
github
delano/rye
https://github.com/delano/rye
try/30_safemode_tryouts.rb
Ruby
mit
235
master
1,355
require 'rye' ## enabled by default Rye::Box.new.safe? #=> true ## can be diabled when created r = Rye::Box.new 'localhost', :safe => false r.safe? #=> false ## can be disabled on the fly r = Rye::Box.new r.disable_safe_mode r.safe? #=> false ## cannot execute arbitrary commands begin r = Rye::Box.new 'localhost'...
github
delano/rye
https://github.com/delano/rye
try/keys.rb
Ruby
mit
235
master
4,227
#!/usr/bin/ruby # THIS IS A SCRAP FILE. __END__ require 'openssl' key = OpenSSL::PKey::RSA.generate(1024) pub = key.public_key ca = OpenSSL::X509::Name.parse("/C=US/ST=Florida/L=Miami/O=Waitingf/OU=Poopstat/CN=waitingf.org/emailAddress=bkerley@brycekerley.net") cert = OpenSSL::X509::Certificate.new cert.version = 2...
github
delano/rye
https://github.com/delano/rye
try/20_file_transfer_tryouts.rb
Ruby
mit
235
master
1,114
require 'rye' @local_sandbox = File.join(Rye.sysinfo.tmpdir, 'rye-tryouts') @lbox = Rye::Box.new 'localhost' Rye::Cmd.add_command :rm ## sandbox should not exist @lbox.file_exists? @local_sandbox #=> false ## create sandbox @lbox.mkdir :p, @local_sandbox @lbox.file_exists? @local_sandbox #=> true ## upload file @l...
github
delano/rye
https://github.com/delano/rye
try/copying.rb
Ruby
mit
235
master
410
#!/usr/bin/ruby # THIS IS A SCRAP FILE. $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') require 'rye' boxA = Rye::Box.new('localhost', :user => "delano") boxB = Rye::Box.new('127.0.0.1', :user => 'delano', :safe => false, :debug => STDOUT) set = Rye::Set.new set.add_boxes(boxA, boxB) #p boxA['/tmp/ssh-tes...
github
delano/rye
https://github.com/delano/rye
try/14_auth_methods_tryouts.rb
Ruby
mit
235
master
540
require "rye" @hostname = "onetimesecret.com" ## Don't prompt for password if "publickey" is the only :auth_method box = Rye::Box.new( @hostname, :auth_methods => ["publickey"] ) begin box.connect rescue Net::SSH::AuthenticationFailed => ex ex.class end #=> Net::SSH::AuthenticationFailed ## Never prompt for...
github
delano/rye
https://github.com/delano/rye
try/10_basic_tryouts.rb
Ruby
mit
235
master
839
require 'rye' ## a Rye::Box instance defaults to localhost lbox = Rye::Box.new lbox.host #=> 'localhost' ## can add commands lbox = Rye::Box.new initially = lbox.can? :rm Rye::Cmd.add_command :rm ret = [initially, lbox.can?(:rm)] #=> [false, true] ## can remove commands lbox = Rye::Box.new Rye::Cmd.remove_command :...
github
delano/rye
https://github.com/delano/rye
try/25_template_upload.rb
Ruby
mit
235
master
758
require 'rye' @local_sandbox = File.join(Rye.sysinfo.tmpdir, 'rye-tryouts') @rendered = "#{@local_sandbox}/rendered.txt" @lbox = Rye::Box.new 'localhost', :info => STDOUT Rye::Cmd.add_command :rm @lbox.rm :r, :f, @local_sandbox ## sandbox should not exist File.exists? @local_sandbox #=> false ## create sandbox @lbox...
github
delano/rye
https://github.com/delano/rye
tst/dsl_example.rb
Ruby
mit
235
master
1,721
# vim: filetype=ruby host '192.168.56.101', :user => 'root' do disable_safe_mode cd '/' info ls '-lah' end host '192.168.56.102', :user => 'root' parallel false hostset 'virtualbox machines', '192.168.56.101', '192.168.56.102' do disable_safe_mode disable_quiet_mode cd '/root' info ls '-lah' end host...
github
delano/rye
https://github.com/delano/rye
tst/10_keys_test.rb
Ruby
mit
235
master
4,255
#!/usr/bin/ruby TEST_HOME = File.dirname(__FILE__) $:.unshift File.join(TEST_HOME, '..', 'lib') require 'rye' private_key_path = File.join(TEST_HOME, '10-key1') rpk = Rye::Key.from_file(private_key_path) puts "RYE::KEY PUBLIC KEY GOOD TIMES: #{private_key_path}", $/ puts "1-2 should be the same. I don't understan...
github
delano/rye
https://github.com/delano/rye
tst/60_rbox_transfer_test.rb
Ruby
mit
235
master
1,704
#!/usr/bin/ruby # # Usage: test/60_rbox_upload_test.rb # $:.unshift File.join(File.dirname(__FILE__), "..", "lib") require "rubygems" require "stringio" require "yaml" require "rye" tmpdir = Rye.sysinfo.tmpdir rbox = Rye::Box.new("localhost", :info => true) def rbox.rm(*args); __allow('rm', args); end rbox.rm(:r,...
github
delano/rye
https://github.com/delano/rye
tst/test_hop.rb
Ruby
mit
235
master
664
$: << File.expand_path(Dir.pwd + "/lib") $:.reverse! require 'rubygems' require 'rye' begin require 'perftools' rescue LoadError => ex puts ex.message puts "$> gem install perftools.rb" exit 1 end data_file = Dir.pwd + "/profile.data" pdf_file = Dir.pwd + "/profile.pdf" text_file = Dir....
github
delano/rye
https://github.com/delano/rye
tst/shell2.rb
Ruby
mit
235
master
7,870
require 'net/ssh' # # For channel requests, see SSH_MSG_CHANNEL_REQUEST messages # in http://www.snailbook.com/docs/connection.txt DEBUG = true module Rye class Box def debug(state, msg='') return unless DEBUG puts " ------ %s: %s" % [state, msg] end def start_session_state(channel) ...
github
delano/rye
https://github.com/delano/rye
tst/shell3.rb
Ruby
mit
235
master
7,804
require 'net/ssh' # # For channel requests, see SSH_MSG_CHANNEL_REQUEST messages # in http://www.snailbook.com/docs/connection.txt DEBUG = true module Rye class Box def debug(state, msg='') return unless DEBUG puts " ------ %s: %s" % [state, msg] end def start_session_state(channel) ...
github
delano/rye
https://github.com/delano/rye
tst/50_rset_test.rb
Ruby
mit
235
master
1,628
#!/usr/bin/ruby # # Usage: test/50_rye_test.rb # $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') require 'benchmark' require 'rubygems' require 'stringio' require 'yaml' require 'rye' machine_key = { :host => 'localhost', :user => "delano", :key => '/proj/git/rudy/.rudy/key-test-app.private' } ma...
github
delano/rye
https://github.com/delano/rye
tst/70_rbox_env_test.rb
Ruby
mit
235
master
375
#!/usr/bin/ruby # # Usage: test/70_rbox_env_test.rb # $:.unshift File.join(File.dirname(__FILE__), "..", "lib") require "rubygems" require "stringio" require "yaml" require "rye" tmpdir = Rye.sysinfo.tmpdir rbox = Rye::Box.new("localhost", :info => true) puts rbox.getenv['HOME'] # slight delay while vars are fe...
github
delano/rye
https://github.com/delano/rye
tst/65_rbox_file_append_test.rb
Ruby
mit
235
master
1,505
#!/usr/bin/ruby # # Usage: test/65_rbox_file_append_test.rb # $:.unshift File.join(File.dirname(__FILE__), "..", "lib") require "rubygems" require "stringio" require "yaml" require "rye" tmpdir = Rye.sysinfo.tmpdir rbox = Rye::Box.new("localhost", :info => false) def rbox.rm(*args); __allow('rm', args); end rbox....
github
delano/rye
https://github.com/delano/rye
tst/shell.rb
Ruby
mit
235
master
7,930
require 'net/ssh' require 'annoy' # # For channel requests, see SSH_MSG_CHANNEL_REQUEST messages # in http://www.snailbook.com/docs/connection.txt DEBUG = false module Rye class Box def debug(state, msg='') return unless DEBUG puts " ------ %s: %s" % [state, msg] end def start_session_sta...
github
csdn-dev/limiter
https://github.com/csdn-dev/limiter
limiter.gemspec
Ruby
mit
235
master
767
# -*- encoding: utf-8 -*- lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'limiter/version' Gem::Specification.new do |gem| gem.name = "limiter" gem.version = Limiter::VERSION gem.authors = ["wangxz"] gem.email = ["wangxz@c...
github
csdn-dev/limiter
https://github.com/csdn-dev/limiter
lib/limiter/base.rb
Ruby
mit
235
master
4,611
# -*- encoding : utf-8 -*- # This is the base class for rate limiter implementations. # # @example Defining a rate limiter subclass # class MyLimiter < Limiter::Base # def allowed?(request) # # TODO: custom logic goes here # end # end # module Limiter class Base attr_reader :app attr_reader ...
github
csdn-dev/limiter
https://github.com/csdn-dev/limiter
lib/limiter/black_list.rb
Ruby
mit
235
master
432
# -*- encoding : utf-8 -*- module Limiter class BlackList def initialize(cache_store) @cache_store = cache_store end def list @cache_store.smembers(key) end def add(ip) @cache_store.sadd(key, ip) end def remove(ip) @cache_store.srem(key, ip) end def memb...
github
csdn-dev/limiter
https://github.com/csdn-dev/limiter
lib/limiter/white_list.rb
Ruby
mit
235
master
436
# -*- encoding : utf-8 -*- module Limiter class WhiteList def initialize(cache_store) @cache_store = cache_store end def list @cache_store.smembers(key) end def add(ip) @cache_store.sadd(key, ip) end def remove(ip) @cache_store.srem(key, ip) end def ...
github
csdn-dev/limiter
https://github.com/csdn-dev/limiter
lib/limiter/visit_counter.rb
Ruby
mit
235
master
769
# -*- encoding : utf-8 -*- module Limiter class VisitCounter def initialize(cache_store) @cache_store = cache_store end def remove(ip, method) @cache_store.del cache_key(ip, method) end def incr(ip, method, ttl) @cache_store.multi do @cache_store.incr cache_key(ip, meth...
github
csdn-dev/limiter
https://github.com/csdn-dev/limiter
lib/limiter/rate_limiter.rb
Ruby
mit
235
master
1,784
# -*- encoding : utf-8 -*- module Limiter class RateLimiter < Base GET_TTL = 20.minutes MAX_GET_NUM = 1000 POST_TTL = 5.seconds MAX_POST_NUM = 20 attr_reader :max_get_num attr_reader :max_post_num attr_reader :get_ttl attr_reader :post_ttl def initialize(app, options = {}) ...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
Rakefile
Ruby
mit
235
master
282
require "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) desc "Run specs without Rails" RSpec::Core::RakeTask.new("spec:norails") do |task| task.exclude_pattern = "**/rails/**" task.verbose = false end task default: [:spec, "spec:norails"]
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
graphql-ruby-fragment_cache.gemspec
Ruby
mit
235
master
1,458
# frozen_string_literal: true require_relative "lib/graphql/fragment_cache/version" Gem::Specification.new do |spec| spec.name = "graphql-fragment_cache" spec.version = GraphQL::FragmentCache::VERSION spec.authors = ["DmitryTsepelev"] spec.email = ["dmitry.a.tsepelev@gmail.com"] spec.summary = "Fragment ca...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/spec_helper.rb
Ruby
mit
235
master
825
# frozen_string_literal: true begin require "pry-byebug" rescue LoadError end require "graphql/batch" require "graphql-fragment_cache" require "timecop" Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f } RSpec.configure do |config| config.example_status_persistence_file_path = "tmp/.rs...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/support/test_schema.rb
Ruby
mit
235
master
3,330
# frozen_string_literal: true class AuthorLoader < GraphQL::Batch::Loader def perform(posts) posts.each { |post| fulfill(post, post.author) } posts.each { |post| fulfill(post, nil) unless fulfilled?(id) } end end class AuthorDataloaderSource < GraphQL::Dataloader::Source def fetch(post_ids) User.fin...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/support/graphql_context.rb
Ruby
mit
235
master
1,200
# frozen_string_literal: true using(Module.new { refine Hash do def camelize_keys transform_keys { |key| GraphQL::Schema::Member::BuildType.camelize(key.to_s) }.tap do |h| h.keys.each do |k| next unless h[k].is_a?(Hash) h[k] = h[k].camelize_keys end end end ...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/support/models/post.rb
Ruby
mit
235
master
667
# frozen_string_literal: true class Post class << self def find(id) store.fetch(id.to_i) do author = User.new(id: id, name: "User ##{id}") new(id: id, title: "Post ##{id}", author: author) end end def all @store.values end def create(id:, **) store[id] = ...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/support/models/user.rb
Ruby
mit
235
master
341
# frozen_string_literal: true class User attr_reader :id attr_accessor :name class << self def find_by_post_ids(post_ids) post_ids.map { |id| Post.find(id).author } end end def initialize(id:, name:) @id = id @name = name end end class CacheableUser < User def cache_key "#{id...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/graphql/schema_spec.rb
Ruby
mit
235
master
3,098
# frozen_string_literal: true require "spec_helper" describe GraphQL::Schema do describe "#multiplex" do let(:schema) { TestSchema } let(:id1) { 1 } let(:id2) { 2 } let(:author1) { User.new(id: 1, name: "John") } let(:author2) { User.new(id: 2, name: "Max") } let!(:post1) { Post.create(id...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/graphql/fragment_cache_spec.rb
Ruby
mit
235
master
1,261
# frozen_string_literal: true require "spec_helper" describe GraphQL::FragmentCache do describe ".cache_store=" do around do |ex| old_store = described_class.cache_store ex.run described_class.cache_store = old_store end it "raises if store doesn't implement #read method" do exp...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/graphql/fragment_cache/object_helpers_spec.rb
Ruby
mit
235
master
25,326
# frozen_string_literal: true require "spec_helper" describe "#cache_fragment" do describe "scalar caching" do let(:schema) do field_resolver = resolver build_schema do query( Class.new(Types::Query) { field :post, Types::Post, null: true do argument :id,...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/graphql/fragment_cache/fragment_spec.rb
Ruby
mit
235
master
2,870
# frozen_string_literal: true require "spec_helper" describe GraphQL::FragmentCache::Fragment do describe "#read_multi" do context "when all fragments don't have renew_cache in their context" do it "calls read_multi and returns the cached values for all of them" do fragment_doubles = fragment_doub...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/graphql/fragment_cache/field_extensions_spec.rb
Ruby
mit
235
master
9,808
# frozen_string_literal: true require "spec_helper" describe "cache_fragment: option" do let(:cache_fragment) { true } let(:schema) do cache_fragment_options = cache_fragment build_schema do query( Class.new(Types::Query) { field :post, Types::Post, null: true, cache_fragment: ca...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/graphql/fragment_cache/cache_key_builder_spec.rb
Ruby
mit
235
master
9,460
# frozen_string_literal: true require "spec_helper" describe GraphQL::FragmentCache::CacheKeyBuilder do let(:schema) do build_schema do query(Types::Query) end end let(:query) do <<~GQL query GetPost($id: ID!) { cachedPost(id: $id) { id title } ...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/graphql/fragment_cache/cacher_spec.rb
Ruby
mit
235
master
6,088
# frozen_string_literal: true require "spec_helper" describe GraphQL::FragmentCache::Cacher do let(:schema) { TestSchema } let(:id) { 1 } let(:variables) { {id: id} } let!(:post) { Post.create(id: id, title: "object test") } let(:query) do <<~GQL query getPost($id: ID!) { cachedPost(id: ...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/graphql/fragment_cache/memory_store_spec.rb
Ruby
mit
235
master
1,668
# frozen_string_literal: true require "spec_helper" describe GraphQL::FragmentCache::MemoryStore do subject { described_class.new } it "caches writes" do subject.write(:test, "42") expect(subject.read(:test)).to eq "42" end it "is symbol/string insensitive" do subject.write(:test, "42") expe...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/graphql/fragment_cache/rails/cache_key_builder_spec.rb
Ruby
mit
235
master
2,076
# frozen_string_literal: true require "rails_helper" describe GraphQL::FragmentCache::CacheKeyBuilder do let(:schema) { TestSchema } let(:query) do <<~GQL query GetPost($id: ID!) { cachedPost(id: $id) { id title author { id name } ...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/graphql/fragment_cache/rails/object_helpers_spec.rb
Ruby
mit
235
master
3,293
# frozen_string_literal: true require "rails_helper" describe GraphQL::FragmentCache::ObjectHelpers do let(:tweet_type_class) do Class.new(GraphQL::Schema::Object) do include GraphQL::FragmentCache::Object graphql_name "TweetType" field :id, GraphQL::Types::ID, null: false field :conte...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/graphql/fragment_cache/rails/railtie_spec.rb
Ruby
mit
235
master
630
# frozen_string_literal: true require "rails_helper" describe GraphQL::FragmentCache::Railtie do describe "config.graphql_fragment_cache.store=" do around do |ex| old_store = GraphQL::FragmentCache.cache_store ex.run GraphQL::FragmentCache.cache_store = old_store end it "supports Rail...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/graphql/fragment_cache/schema/instrumentation_spec.rb
Ruby
mit
235
master
2,192
# frozen_string_literal: true require "spec_helper" describe GraphQL::FragmentCache::Schema::Instrumentation do let(:schema) { TestSchema } let(:id) { 1 } let(:variables) { {id: id} } let!(:post) { Post.create(id: id, title: "object test") } let(:query) do <<~GQL query getPost($id: ID!) { ...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
spec/graphql/fragment_cache/schema/lazy_cache_resolver_spec.rb
Ruby
mit
235
master
1,836
# frozen_string_literal: true require "spec_helper" describe GraphQL::FragmentCache::Schema::LazyCacheResolver do describe "#initialize" do context "lazy cache resolver state management" do let(:state_key) { :lazy_cache_resolver_statez } let(:gql_context) { instance_double "Context" } let(:fra...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache.rb
Ruby
mit
235
master
2,318
# frozen_string_literal: true require "graphql" require "graphql/fragment_cache/graphql_ruby_version" require "graphql/fragment_cache/ext/context_fragments" require "graphql/fragment_cache/ext/graphql_cache_key" require "graphql/fragment_cache/object" require "graphql/fragment_cache/connections/patch" require "gra...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/object_helpers.rb
Ruby
mit
235
master
1,741
# frozen_string_literal: true require "graphql/fragment_cache/fragment" require "graphql/fragment_cache/schema/lazy_cache_resolver" module GraphQL module FragmentCache using Ext # Adds #cache_fragment method module ObjectHelpers extend Forwardable def self.included(base) return if ...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/cacher.rb
Ruby
mit
235
master
1,825
# frozen_string_literal: true module GraphQL module FragmentCache using Ext class WriteError < StandardError attr_reader :key, :value, :original_error def initialize(original_error, key, value) @original_error = original_error @key = key @value = value super(ori...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/object.rb
Ruby
mit
235
master
434
# frozen_string_literal: true require "graphql/fragment_cache/object_helpers" require "graphql/fragment_cache/field_extension" module GraphQL module FragmentCache # Adds #cache_fragment method and kwarg option module Object def self.included(base) base.include(GraphQL::FragmentCache::ObjectHel...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/fragment.rb
Ruby
mit
235
master
3,294
# frozen_string_literal: true require "graphql/fragment_cache/cache_key_builder" module GraphQL module FragmentCache using Ext # Represents a single fragment to cache class Fragment NIL_IN_CACHE = Object.new class << self def read_multi(fragments) unless FragmentCache.cac...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/field_extension.rb
Ruby
mit
235
master
2,417
# frozen_string_literal: true require "graphql/fragment_cache/schema/lazy_cache_resolver" module GraphQL module FragmentCache # Wraps resolver with cache method class FieldExtension < GraphQL::Schema::FieldExtension module Patch def initialize(*args, **kwargs, &block) cache_fragment ...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/graphql_ruby_version.rb
Ruby
mit
235
master
428
# frozen_string_literal: true module GraphQL module FragmentCache module GraphRubyVersion module_function def after_2_2_5? check_graphql_version "> 2.2.5" end def before_2_3_11? check_graphql_version "< 2.3.11" end def check_graphql_version(predicate) ...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/memory_store.rb
Ruby
mit
235
master
1,310
# frozen_string_literal: true module GraphQL module FragmentCache # Memory adapter for storing cached fragments class MemoryStore class Entry < Struct.new(:value, :expires_at, keyword_init: true) def expired? expires_at && expires_at < Time.now end end attr_reader...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/railtie.rb
Ruby
mit
235
master
1,148
# frozen_string_literal: true require "graphql/fragment_cache/rails/cache_key_builder" module GraphQL module FragmentCache class Railtie < ::Rails::Railtie # :nodoc: # Provides Rails-specific configuration, # accessible through `Rails.application.config.graphql_fragment_cache` module Config ...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/cache_key_builder.rb
Ruby
mit
235
master
4,526
# frozen_string_literal: true require "json" require "digest" module GraphQL module FragmentCache using Ext using(Module.new { refine Array do def traverse_argument(argument) return argument unless argument.is_a?(GraphQL::Schema::InputObject) "{#{argument.map { "#{_1}:#{t...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/ext/graphql_cache_key.rb
Ruby
mit
235
master
1,829
# frozen_string_literal: true module GraphQL module FragmentCache module Ext # Adds #_graphql_cache_key method to Object, # which just call #graphql_cache_key or #cache_key. # # For other core classes returns string representation. # # Raises ArgumentError otherwise. # ...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/ext/context_fragments.rb
Ruby
mit
235
master
553
# frozen_string_literal: true module GraphQL module FragmentCache module Ext # Add ability to access fragments via `context.fragments` # without dupclicating the storage logic and monkey-patching refine GraphQL::Query::Context do def fragments? namespace(:fragment_cache)[:frag...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/connections/patch.rb
Ruby
mit
235
master
784
# frozen_string_literal: true module GraphQL module FragmentCache module Connections # Patches GraphQL::Pagination::Connections to support raw values module Patch if Gem::Dependency.new("graphql", "< 1.11.0").match?("graphql", GraphQL::VERSION) def wrap(field, object, arguments, con...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/schema/tracer.rb
Ruby
mit
235
master
835
# frozen_string_literal: true module GraphQL # Plugin definition module FragmentCache module Schema class Tracer using Ext class << self def trace(key, data) yield.tap do |resolved_value| next unless connection_field?(key, data) verify_c...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/schema/instrumentation.rb
Ruby
mit
235
master
1,181
# frozen_string_literal: true require "graphql/fragment_cache/cacher" module GraphQL module FragmentCache module Schema # Adds hook for saving cached values after query is resolved module Instrumentation module_function def before_query(query) end def after_query(qu...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/schema/lazy_cache_resolver.rb
Ruby
mit
235
master
1,591
require "graphql/fragment_cache/fragment" module GraphQL module FragmentCache module Schema using Ext class LazyCacheResolver def initialize(fragment, query_ctx, object_to_cache, &block) @fragment = fragment @query_ctx = query_ctx @object_to_cache = object_to_cac...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/schema/patch.rb
Ruby
mit
235
master
326
# frozen_string_literal: true require "digest/sha1" module GraphQL module FragmentCache module Schema # Patches GraphQL::Schema to support fragment cache module Patch def schema_cache_key @schema_cache_key ||= Digest::SHA1.hexdigest(to_definition) end end end en...
github
DmitryTsepelev/graphql-ruby-fragment_cache
https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache
lib/graphql/fragment_cache/rails/cache_key_builder.rb
Ruby
mit
235
master
657
# frozen_string_literal: true module GraphQL module FragmentCache # Extends key builder to use .expand_cache_key in Rails class CacheKeyBuilder def object_key(obj) return nil if obj.nil? return obj.graphql_cache_key if obj.respond_to?(:graphql_cache_key) return obj.cache_key_wit...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
Gemfile
Ruby
mit
235
main
285
source "https://rubygems.org" # Include gem dependencies from anthropic.gemspec gemspec gem "byebug", "~> 11.1.3" gem "dotenv", "~> 2.8.1" gem "racc", "~> 1.7.3" gem "rake", "~> 13.0" gem "rspec", "~> 3.12" gem "rubocop", "~> 1.50.2" gem "vcr", "~> 6.1.0" gem "webmock", "~> 3.18.1"
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
anthropic.gemspec
Ruby
mit
235
main
1,365
require_relative "lib/anthropic/version" Gem::Specification.new do |spec| spec.name = "ruby-anthropic" spec.version = Anthropic::VERSION spec.authors = ["Alex"] spec.email = ["alexrudall@users.noreply.github.com"] spec.summary = "Anthropic API + Ruby! 🤖🌌" spec.homepage...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
spec/anthropic_spec.rb
Ruby
mit
235
main
1,866
RSpec.describe Anthropic do it "has a version number" do expect(Anthropic::VERSION).not_to be nil end describe "#configure" do let(:access_token) { "abc123" } let(:api_version) { "v2" } let(:custom_uri_base) { "ghi789" } let(:custom_request_timeout) { 25 } let(:extra_headers) { { "User-Ag...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
spec/spec_helper.rb
Ruby
mit
235
main
1,574
require "bundler/setup" require "dotenv/load" require "anthropic" require "anthropic/compatibility" require "vcr" require "byebug" Dir[File.expand_path("spec/support/**/*.rb")].sort.each { |f| require f } VCR.configure do |c| c.hook_into :webmock c.cassette_library_dir = "spec/fixtures/cassettes" c.default_cass...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
spec/compatibility_spec.rb
Ruby
mit
235
main
1,352
RSpec.describe "compatibility" do context "for moved constants" do describe "::Ruby::Anthropic::VERSION" do it "is mapped to ::Anthropic::VERSION" do expect(Ruby::Anthropic::VERSION).to eq(Anthropic::VERSION) end end describe "::Ruby::Anthropic::Error" do it "is mapped to ::Anth...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
spec/anthropic/client/complete_spec.rb
Ruby
mit
235
main
788
RSpec.describe Anthropic::Client do describe "#complete" do context "with a prompt and max_tokens", :vcr do let(:prompt) { "How high is the sky?" } let(:max_tokens) { 5 } let(:response) do Anthropic::Client.new.complete( parameters: { model: model, max_...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
spec/anthropic/client/http_spec.rb
Ruby
mit
235
main
2,953
RSpec.describe Anthropic::HTTP do describe "logging errors" do let(:cassette) { "http post with error response".downcase } before do @original_stdout = $stdout $stdout = StringIO.new end after do $stdout = @original_stdout end context "when log_errors is not set" do ...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
spec/anthropic/client/client_spec.rb
Ruby
mit
235
main
842
RSpec.describe Anthropic::Client do context "when using beta APIs" do let(:client) { Anthropic::Client.new.beta("message-batches-2024-09-24") } it "sends the appropriate header value" do expect(client.send(:headers)["anthropic-beta"]).to eq "message-batches-2024-09-24" end context "when chaini...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
spec/anthropic/client/messages/streaming_spec.rb
Ruby
mit
235
main
7,326
RSpec.describe Anthropic::Client do let(:json_prompt) { "Answer in the provided JSON format. Only include JSON." } describe "#messages" do context "with all required parameters (:model, :messages, :max_tokens)" do let(:model) { "claude-3-haiku-20240307" } let(:messages) { [{ role: "user", content: ...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
spec/anthropic/client/messages/tools_spec.rb
Ruby
mit
235
main
3,636
RSpec.describe Anthropic::Client do describe "#messages with streaming tool use" do let(:model) { "claude-3-haiku-20240307" } let(:max_tokens) { 1024 } let(:tools) do [ { name: "get_weather", description: "Get the current weather in a given location", input_sche...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
spec/anthropic/client/messages/batches_spec.rb
Ruby
mit
235
main
3,671
RSpec.describe Anthropic::Client do let(:client) { Anthropic::Client.new(access_token: ENV.fetch("ANTHROPIC_API_KEY", nil)) } describe "#messages.batches" do let(:batch_requests) do [ { custom_id: "test-prompt-1", params: { model: "claude-3-haiku-20240307", ...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
lib/anthropic.rb
Ruby
mit
235
main
1,875
require "faraday" require "faraday/multipart" require_relative "anthropic/http" require_relative "anthropic/client" require_relative "anthropic/version" module Anthropic class Error < StandardError; end class ConfigurationError < Error; end class MiddlewareErrors < Faraday::Middleware def call(env) @...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
lib/anthropic/client.rb
Ruby
mit
235
main
4,777
require_relative "messages/batches" require_relative "messages/client" module Anthropic class Client include Anthropic::HTTP CONFIG_KEYS = %i[ access_token anthropic_version api_version log_errors uri_base request_timeout extra_headers ].freeze attr_reader(*...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
lib/anthropic/http_headers.rb
Ruby
mit
235
main
790
module Anthropic module HTTPHeaders def add_headers(headers) @extra_headers = extra_headers.merge(headers.transform_keys(&:to_s)) end private def headers # TODO: Implement Amazon Bedrock headers # if azure? # azure_headers # else # anthropic_headers # en...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
lib/anthropic/http.rb
Ruby
mit
235
main
6,890
require "event_stream_parser" require_relative "http_headers" # rubocop:disable Metrics/ModuleLength module Anthropic module HTTP include HTTPHeaders def get(path:, parameters: nil) response = conn.get(uri(path: path), parameters) do |req| req.headers = headers end response&.body ...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
lib/anthropic/compatibility.rb
Ruby
mit
235
main
265
module Ruby module Anthropic VERSION = ::Anthropic::VERSION Error = ::Anthropic::Error ConfigurationError = ::Anthropic::ConfigurationError Configuration = ::Anthropic::Configuration MiddlewareErrors = ::Anthropic::MiddlewareErrors end end
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
lib/anthropic/messages/batches.rb
Ruby
mit
235
main
4,624
module Anthropic module Messages class Batches BETA_VERSION = "message-batches-2024-09-24".freeze def initialize(client) @client = client.beta(BETA_VERSION) end # Anthropic API Parameters as of 2024-10-09: # @see https://docs.anthropic.com/en/api/creating-message-batches ...
github
alexrudall/ruby-anthropic
https://github.com/alexrudall/ruby-anthropic
lib/anthropic/messages/client.rb
Ruby
mit
235
main
205
module Anthropic module Messages class Client def initialize(client) @client = client end def batches @batches ||= Batches.new(@client) end end end end
github
kpshek/mm2pwd
https://github.com/kpshek/mm2pwd
mm2pwd_spec.rb
Ruby
apache-2.0
235
master
3,449
# coding: UTF-8 # Copyright 2013 Kevin Shekleton # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agre...
github
kpshek/mm2pwd
https://github.com/kpshek/mm2pwd
mm2pwd.rb
Ruby
apache-2.0
235
master
4,674
#!/usr/bin/env ruby # coding: UTF-8 # Copyright 2013 Kevin Shekleton # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
github
voloko/twitter-stream
https://github.com/voloko/twitter-stream
twitter-stream.gemspec
Ruby
mit
234
master
1,358
# -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = %q{twitter-stream} s.version = "0.1.15" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Vladimir Kolesnikov"] s.date = %q{2012-04-10} s.description = %q{Simple Ruby client...
github
voloko/twitter-stream
https://github.com/voloko/twitter-stream
Rakefile
Ruby
mit
234
master
225
require 'rubygems' require 'bundler' Bundler::GemHelper.install_tasks gem 'rspec', '>= 2.5.0' require 'rspec/core/rake_task' desc "Run all specs" RSpec::Core::RakeTask.new(:spec) task :default => :spec task :test => :spec
github
voloko/twitter-stream
https://github.com/voloko/twitter-stream
lib/twitter/json_stream.rb
Ruby
mit
234
master
10,113
require 'eventmachine' require 'em/buftok' require 'uri' require 'simple_oauth' require 'http/parser' module Twitter class JSONStream < EventMachine::Connection MAX_LINE_LENGTH = 1024*1024 # network failure reconnections NF_RECONNECT_START = 0.25 NF_RECONNECT_ADD = 0.25 NF_RECONNECT_MAX = 16...
github
voloko/twitter-stream
https://github.com/voloko/twitter-stream
spec/spec_helper.rb
Ruby
mit
234
master
1,212
require 'rubygems' gem 'rspec', '>= 2.5.0' require 'rspec' require 'rspec/mocks' require 'twitter/json_stream' def fixture_path(path) File.join(File.dirname(__FILE__), '..', 'fixtures', path) end def read_fixture(path) File.read(fixture_path(path)) end def connect_stream(opts={}, &blk) EM.run { opts.merg...
github
voloko/twitter-stream
https://github.com/voloko/twitter-stream
spec/twitter/json_stream_spec.rb
Ruby
mit
234
master
9,585
require 'spec_helper.rb' require 'twitter/json_stream' include Twitter Host = "127.0.0.1" Port = 9550 class JSONServer < EM::Connection attr_accessor :data def receive_data data $recieved_data = data send_data $data_to_send EventMachine.next_tick { close_connection if $close_connection } ...
github
voloko/twitter-stream
https://github.com/voloko/twitter-stream
examples/reader.rb
Ruby
mit
234
master
1,015
require 'rubygems' lib_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path) require 'twitter/json_stream' EventMachine::run { stream = Twitter::JSONStream.connect( :path => '/1/statuses/filter.json', :auth => 'LOGIN:PA...
github
trailblazer/roar-rails
https://github.com/trailblazer/roar-rails
Rakefile
Ruby
mit
234
master
211
require "bundler/gem_tasks" require 'rake/testtask' task :default => [:test] Rake::TestTask.new(:test) do |test| test.libs << 'test' test.test_files = FileList['test/*_test.rb'] test.verbose = true end
github
trailblazer/roar-rails
https://github.com/trailblazer/roar-rails
Appraisals
Ruby
mit
234
master
1,300
appraise 'rails-3.0' do gem 'railties', '~> 3.0.11' gem 'activerecord', '~> 3.0.11' gem 'minitest-rails', '~> 1.0' end appraise 'rails-3.2' do gem 'railties', '~> 3.2.13' gem 'activerecord', '~> 3.2.13' gem 'minitest', '~> 4.7.5' gem 'minitest-rails', '~> 1.0' end appraise 'rails-4.0' do g...