repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
martinos/http_fp | test/http_fn/httpie_test.rb | <filename>test/http_fn/httpie_test.rb
require "minitest_helper"
require "http_fn"
require "http_fn/rack"
require "http_fn/httpie"
class HttpFn::CurlTest < Minitest::Test
include HttpFn
def setup
@curl = (verb.("GET") >>
with_path.("/coucou") >>
with_headers.(json_headers) >>
... |
martinos/http_fp | lib/http_fn/curl.rb | <reponame>martinos/http_fp
require "net/http"
require "http_fn"
module HttpFn::Curl
include HttpFn
fn_reader :print_curl, :req
@@req = -> req {
first_part = %{curl -X '#{req[:method]}' '#{HttpFn::to_uri.(req).to_s}' #{req[:header].map(&@@header_to_curl).join(" ")}}
if req[:body] && !req[:body].empty?
... |
martinos/http_fp | lib/http_fn/utils.rb | <reponame>martinos/http_fp<gh_stars>0
require "json"
require "pp"
require "yaml"
module Utils
fn_reader :parse_json, :debug, :at, :retry_fn,
:record, :player, :count_by, :cache, :red, :time,
:expired, :apply, :and_then, :default, :map, :get, :try
@@parse_json = JSON.method(:parse)
@@debug = -> print, a,... |
seouri/rails-template | template.rb | git :init
git add: "."
git commit: "-a -m 'Initial commit'"
gem_group :development, :test do
gem "bundler-audit", require: false
gem "dotenv-rails"
gem "pronto-brakeman", require: false
gem "pronto-fasterer", require: false
gem "pronto-flay", require: false
gem "pronto-rails_best_practices", require: false... |
glasner/tweethook | lib/tweethook/result.rb | class Tweethook::Result
attr_accessor :user, :tweet, :usrimg, :tid, :tstamp, :unix_tstamp, :is_reply, :is_retweet, :mentions, :source, :sourcelink, :search_query
def initialize(args)
args.each { |key,value| instance_variable_set("@#{key}",value) }
change_boolean_values
end
def change_boole... |
glasner/tweethook | test/test_search.rb | require 'helper'
class TestSearch < Test::Unit::TestCase
context "instantiating Search with parsed JSON from API" do
subject { @search }
setup do
@json = '{
"id": 12560300,
"search": "\"hello world\"",
"webhook": "http:\/\/example.com\/webhook.ph... |
glasner/tweethook | lib/tweethook/search.rb | class Tweethook::Search
# create a new search at Tweethook
# Tweethook::Search.create('monkey', :webhook => 'http://where.com/callback' )
def self.create(search,args)
args.merge!({:search => search})
search = new(args)
search.save
end
def self.find(id)
response = Tweethook.get('/info.jso... |
glasner/tweethook | test/test_post.rb | <gh_stars>0
require 'helper'
require 'time'
class TestPost < Test::Unit::TestCase
context "instantiating TestPost with valid JSON" do
subject { @post }
setup do
@json = '{
"status_count": 2,
"signature": "XXXXXXXXXXXXXXXXXXXXXXXX",
"time": 1253055217,
"r... |
glasner/tweethook | lib/tweethook.rb | $:.unshift File.expand_path(File.dirname(__FILE__))
require 'typhoeus'
require 'json'
class Tweethook
autoload :Search, 'tweethook/search'
autoload :Post, 'tweethook/post'
autoload :Result, 'tweethook/result'
def self.user
ENV['TWEETHOOK_API_USER']
end
def self.password
ENV['<PASSWORD>']
... |
glasner/tweethook | lib/tweethook/post.rb | <filename>lib/tweethook/post.rb<gh_stars>0
class Tweethook::Post < Array
attr_accessor :signature, :time
def initialize(json)
hash = json.is_a?(Hash) ? json : JSON.parse(json)
@signature = hash['signature']
@time = Time.at(hash['time'])
super(hash['results'].map { |result| Tweethook::Result.ne... |
alextaylor000/emoji-formatter | spec/test_output_spec.rb | <reponame>alextaylor000/emoji-formatter
require "spec_helper"
describe EmojiFormatter do
describe "demo tests" do
100.times do |i|
it "runs test #{i}" do
expect(true).to eq([true, true, false].sample)
sleep(rand(0.75))
end
end
xit "is pending" do
raise "pending"
end... |
alextaylor000/emoji-formatter | lib/emoji_formatter.rb | <reponame>alextaylor000/emoji-formatter
require "emoji_formatter/formatter"
|
alextaylor000/emoji-formatter | lib/emoji_formatter/formatter.rb | <reponame>alextaylor000/emoji-formatter
require "rspec/core/formatters/console_codes"
class EmojiFormatter
PROGRESS_ICONS = {
:example_passed => "\u{1f600}",
:example_failed => "\u{1f621}",
:example_pending => "\u{1f537}"
}
RSpec::Core::Formatters.register self, :start, :example_passed, :example_... |
seattlerb/omnifocus-rubyforge | lib/omnifocus/rubyforge.rb | <reponame>seattlerb/omnifocus-rubyforge
require 'rubyforge'
module OmniFocus::Rubyforge
VERSION = '1.1.1'
RF_URL = "http://rubyforge.org"
PREFIX = "RF"
def rubyforge
unless defined? @rubyforge then
@rubyforge = RubyForge.new
@rubyforge.configure
end
@rubyforge
end
def login_to_r... |
Shopify/annex-29 | spec/spec_helper.rb | RSpec.configure do |config|
config.expect_with(:rspec) do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with(:rspec) do |mocks|
mocks.verify_partial_doubles = true
end
config.disable_monkey_patching!
config.example_status_persistence_file_p... |
Shopify/annex-29 | lib/annex_29/word_segmentation.rb |
# line 1 "lib/annex_29/word_segmentation.rl"
module Annex29
module WordSegmentation
# line 170 "lib/annex_29/word_segmentation.rl"
# line 13 "lib/annex_29/word_segmentation.rb"
class << self
attr_accessor :_segmenter_key_offsets
private :_segmenter_key_offsets, :_segmenter_key_offsets=
end
self._segm... |
Shopify/annex-29 | spec/word_segmentation_spec.rb | <gh_stars>1-10
RSpec.describe(Annex29.method(:segment_words)) do
class << self
def parse_sample(sample)
sample = sample.sub(/^\s*÷/, "").sub(/÷\s*$/, "")
source = sample.split(/[÷×]/).map do |code_point|
code_point.strip.hex
end.pack("U*")
expected = sample.split("÷").map do |fragm... |
Shopify/annex-29 | annex_29.gemspec | <gh_stars>1-10
Gem::Specification.new do |spec|
spec.name = "annex_29"
spec.version = "0.1.1"
spec.date = "2016-10-18"
spec.summary = "Unicode annex 29 compliant word segmentation"
spec.authors = ["<NAME>"]
spec.email = "<EMAIL>"
spec.files = %w(
lib/annex_29.rb
lib/annex_29/word_segmentation.rb
... |
Shopify/annex-29 | lib/annex_29.rb | module Annex29
require("annex_29/word_segmentation")
class << self
def segment_words(input)
Annex29::WordSegmentation.call(String(input))
end
end
end
|
MainShayne233/command_mine | lib/command_mine.rb | <reponame>MainShayne233/command_mine
require "command_mine/version"
module CommandMine
def self.say_hi
begin
`say hi`
rescue e => Exception
`espeak hi`
end
end
end
|
shepeliev/webrtc-kmp | webrtc-kmp.podspec | <reponame>shepeliev/webrtc-kmp<gh_stars>10-100
version = '0.89.6'
Pod::Spec.new do |s|
s.name = 'webrtc-kmp'
s.version = version
s.summary = 'WebRTC Kotlin Multiplatform'
s.homepage = 'https://github.com/shepeliev/webrtc-kmp'
s.license = 'Apache 2... |
POPPIN-FUMI/gem_rbs_collection | gems/redis/4.2/_test/pipeline.rb | redis = Redis.new
# @type ivar @set: Redis::Future[String]
# @type ivar @incr: Redis::Future[Integer]
redis.pipelined do |redis|
@set = redis.set "foo", "bar"
@incr = redis.incr "baz"
end
# => ["OK", 1]
@set.value
# => "OK"
@incr.value
# => 1
|
POPPIN-FUMI/gem_rbs_collection | gems/redis/4.2/_test/ssl.rb | <reponame>POPPIN-FUMI/gem_rbs_collection<filename>gems/redis/4.2/_test/ssl.rb<gh_stars>10-100
# @type const OpenSSL: untyped
# @type const OpenSSL::X509: untyped
# @type const OpenSSL::X509::Certificate: untyped
# @type const OpenSSL::PKey::RSA: untyped
# @type const OpenSSL::PKey: untyped
redis = Redis.new(
:url ... |
POPPIN-FUMI/gem_rbs_collection | gems/redis/4.2/_test/sentinels.rb | redis = Redis.new(
url: "redis://mymaster",
sentinels: [{ host: "127.0.0.1", port: 26380 }, { host: "127.0.0.1", port: 26381, password: "<PASSWORD>" }],
role: :master
)
|
POPPIN-FUMI/gem_rbs_collection | gems/activestorage/6.0/_test/test.rb | class User < ActiveRecord::Base
has_one_attached :one_image
has_many_attached :many_image
end
user = User.new
one = ActiveStorage::Attached::One.new("one_image", user)
one.url
|
POPPIN-FUMI/gem_rbs_collection | gems/redis/4.2/_test/initialize.rb | <gh_stars>10-100
redis = Redis.new
redis = Redis.new(host: "10.0.1.1", port: 6380, db: 15)
redis = Redis.new(url: "redis://:p4ssw0rd@10.0.1.1:6380/15")
redis = Redis.new(path: "/tmp/redis.sock")
redis = Redis.new(password: "<PASSWORD>")
|
POPPIN-FUMI/gem_rbs_collection | gems/listen/3.2/_test/test.rb | <gh_stars>10-100
listener = Listen.to('dir/to/listen', 'dir/to/listen2') do |modified, added, removed|
puts "modified absolute path: #{modified}"
puts "added absolute path: #{added}"
puts "removed absolute path: #{removed}"
end
listener.start # not blocking
sleep
|
POPPIN-FUMI/gem_rbs_collection | gems/redis/4.2/_test/multi.rb | <filename>gems/redis/4.2/_test/multi.rb
redis = Redis.new
redis.multi do
redis.set "foo", "bar"
redis.incr "baz"
end
# => ["OK", 1]
|
POPPIN-FUMI/gem_rbs_collection | gems/parallel/1.20/_test/number.rb | Parallel.each(1..5) { |i| puts "#{i}: #{Parallel.worker_number / 2.0}" }
puts Parallel.physical_processor_count.even?
puts Parallel.processor_count.odd?
|
POPPIN-FUMI/gem_rbs_collection | gems/redis/4.2/_test/reconnect.rb | Redis.new(
:reconnect_attempts => 10,
:reconnect_delay => 1.5,
:reconnect_delay_max => 10.0,
)
|
POPPIN-FUMI/gem_rbs_collection | gems/rack/2.2.2/_test/test.rb | require "rack"
require 'rack/lobster'
Rack::Server.start(app: Rack::ShowExceptions.new(Rack::Lint.new(Rack::Lobster.new)), Port: 9292)
|
POPPIN-FUMI/gem_rbs_collection | gems/protobuf/3.10.3/_test/enum.rb | module Enum
class States < ::Protobuf::Enum
define :ALABAMA, 1
define :CALIFORNIA, 2
define :HOGE, 1
end
States::ALABAMA
States::ALABAMA.to_i
States::ALABAMA.tag
States::ALABAMA.name
States.fetch(1).___error___
States.fetch(0)
States.enums.___error___
States.all_tags.___error___
end
|
POPPIN-FUMI/gem_rbs_collection | gems/sidekiq/6.2/_test/test_3.rb | # Test error handling
# Taken from: https://github.com/mperham/sidekiq/wiki/Error-Handling
Sidekiq.configure_server do |config|
config.error_handlers << proc { |ex,ctx_hash| puts "#{ex} exception: #{ctx_hash} context" }
end
class LessRetryableWorker
include Sidekiq::Worker
sidekiq_options retry: 5 # Only five ... |
POPPIN-FUMI/gem_rbs_collection | gems/rainbow/3.0/_scripts/gen_x11_colors.rb | <filename>gems/rainbow/3.0/_scripts/gen_x11_colors.rb
require "rainbow"
existing_names = Rainbow::Presenter.public_instance_methods(false)
x11_color_names = Rainbow::X11ColorNames::NAMES.keys - existing_names
case ARGV[0]
when "sig"
puts x11_color_names.sort.map { |method| " def #{method}: () -> instance\n" }.jo... |
POPPIN-FUMI/gem_rbs_collection | gems/ulid/1.3/_test/ulid_test.rb | require 'ulid'
p ULID.generate.bytes
p ULID.generate(Time.now).bytes
p ULID.generate_bytes.bytes
p ULID.generate_bytes(Time.now).bytes
|
POPPIN-FUMI/gem_rbs_collection | gems/redis/4.2/_test/error_handling.rb | redis = Redis.new
begin
redis.ping
rescue StandardError => e
e.inspect
# => #<Redis::CannotConnectError: Timed out connecting to Redis on 10.0.1.1:6380>
e.message
# => Timed out connecting to Redis on 10.0.1.1:6380
end
|
POPPIN-FUMI/gem_rbs_collection | gems/regexp_trie/1.0/_test/test.rb | <filename>gems/regexp_trie/1.0/_test/test.rb
require "regexp_trie"
p RegexpTrie.union('foo', 'bar', 'baz')
# From https://github.com/gfx/ruby-regexp_trie#readme
# like Regexp.union()
p RegexpTrie.union(%w(foobar fooxar foozap fooza)) # /foo(?:bar|xar|zap?)/
p RegexpTrie.union(%w(foobar fooxar foozap fooza), option: ... |
POPPIN-FUMI/gem_rbs_collection | gems/chunky_png/1.4.0/_test/test_5.rb | png = ChunkyPNG::Image.new(128, 128, ChunkyPNG::Color::TRANSPARENT)
datastream = png.to_datastream
datastream.chunks.map { |x| x.type }
datastream.each_chunk { |chunk| chunk }
# Snippet taken from Gem's GitHub Wiki
image = ChunkyPNG::Image.from_file('clock.png')
image.change_theme_color!(ChunkyPNG::Color.from_hex('#bb... |
POPPIN-FUMI/gem_rbs_collection | gems/redis/4.2/_test/mset_mget.rb | <filename>gems/redis/4.2/_test/mset_mget.rb
redis = Redis.new(cluster: %w[redis://127.0.0.1:7000])
redis.mget('key1', 'key2')
#=> Redis::CommandError (CROSSSLOT Keys in request don't hash to the same slot)
redis.mget('{key}1', '{key}2')
#=> [nil, nil]
|
POPPIN-FUMI/gem_rbs_collection | gems/chunky_png/1.4.0/_test/test_2.rb | <reponame>POPPIN-FUMI/gem_rbs_collection<gh_stars>10-100
# Loading Data - Datastream/StreamImport
image = ChunkyPNG::Image.from_rgba_stream(128, 128, File.read('pixeldata.rgba'))
image = ChunkyPNG::Image.from_rgb_stream(128, 128, File.read('pixeldata.rgb'))
image = ChunkyPNG::Image.from_file('file.png')
File.open('file... |
POPPIN-FUMI/gem_rbs_collection | gems/sidekiq/6.2/_test/test_4.rb | # Test advanced configurations
# Taken from: https://github.com/mperham/sidekiq/wiki/Advanced-Options
class ImportantWorker
include Sidekiq::Worker
sidekiq_options queue: 'critical', retry: true, dead: true, backtrace: false, tags: ['important', 'test']
def perform
puts "Doing critical work"
end
end
Sidek... |
POPPIN-FUMI/gem_rbs_collection | gems/chunky_png/1.4.0/_test/test_1.rb | # Basic API usage - Color, Dimension
png = ChunkyPNG::Image.new(128, 128, ChunkyPNG::Color::TRANSPARENT)
png[1, 1] = ChunkyPNG::Color.rgba(10, 20, 30, 128)
png[2, 1] = ChunkyPNG::Color('black @ 0.5')
png[3, 1] = ChunkyPNG::Color.rgb(255, 0, 128)
png.metadata['title'] = 'Test image'
puts png.metadata['title']
puts png.d... |
POPPIN-FUMI/gem_rbs_collection | gems/parallel/1.20/_test/control.rb | <reponame>POPPIN-FUMI/gem_rbs_collection
puts Parallel.map([1, 2, 3]) { |x| raise Parallel::Break, x if x == 2 } == 2
puts Parallel.map([1, 2, 3]) { |x| raise Parallel::Break.new(x) if x == 2 } == 2
Parallel.map([1, 2, 3]) do |x|
if x == 1
sleep 0.1
puts 'DEAD'
raise Parallel::Kill
elsif x == 3
sl... |
POPPIN-FUMI/gem_rbs_collection | gems/parallel/1.20/_test/all.rb | <filename>gems/parallel/1.20/_test/all.rb
Parallel.all?(['a','b','c']) { |item| item.size == 1 }
Parallel.all?(['a','b','c'], in_processes: 2) { |item| item.size == 1 }
Parallel.all?(['a','b','c'], in_threads: 2) { |item| item.size == 1 }
Parallel.all?(['a','b','c'], progress: 'Running...') { |item| item.size == 1 }... |
POPPIN-FUMI/gem_rbs_collection | gems/activerecord/6.0/_test/activerecord-generated.rb | <reponame>POPPIN-FUMI/gem_rbs_collection<gh_stars>10-100
class User < ActiveRecord::Base
end
user = User.new
|
POPPIN-FUMI/gem_rbs_collection | gems/sidekiq/6.2/_test/test_5.rb | <gh_stars>10-100
# Test logging configuration
# Taken from: https://github.com/mperham/sidekiq/wiki/Logging
class YourWorker
include Sidekiq::Worker
def perform
logger.info "Things are happening."
logger.debug "Here's some info: #{hash.inspect}"
end
end
Sidekiq.logger.level = Logger::ERROR
Sidekiq.confi... |
POPPIN-FUMI/gem_rbs_collection | gems/retryable/3.0/_test/test.rb | <filename>gems/retryable/3.0/_test/test.rb<gh_stars>10-100
require "retryable"
Retryable.retryable(tries: 0)
str = Retryable.retryable do
"foo"
end
str&.ascii_only?
Retryable.retryable do |retries, exception|
retries.bit_length
exception&.backtrace
end
Retryable.retryable(
ensure: ->(retries) { retries.bit_... |
POPPIN-FUMI/gem_rbs_collection | gems/chunky_png/1.4.0/_test/test_3.rb | <reponame>POPPIN-FUMI/gem_rbs_collection
# Operations - Manipulating images
image = ChunkyPNG::Image.from_file('filename.png')
new_image = ChunkyPNG::Canvas.from_canvas(image)
image[0, 0] = ChunkyPNG::Color.rgba(255, 0,0, 128)
image.line(1, 1, 10, 1, ChunkyPNG::Color.from_hex('#aa007f'))
image.flip_horizontally!.rotate... |
POPPIN-FUMI/gem_rbs_collection | gems/listen/3.2/_test/test3.rb | listener = Listen.to('dir/path/to/listen', ignore: /\.txt/) { |modified, added, removed| }
listener.start
listener.ignore! /\.pkg/ # overwrite all patterns and only ignore pkg extension.
listener.ignore /\.rb/ # ignore rb extension in addition of pkg.
sleep
|
POPPIN-FUMI/gem_rbs_collection | gems/listen/3.2/_test/test2.rb | <reponame>POPPIN-FUMI/gem_rbs_collection
listener = Listen.to('dir/path/to/listen') { |modified, added, removed| puts 'handle changes here...' }
listener.start
listener.paused? # => false
listener.processing? # => true
listener.pause # stops processing changes (but keeps on collecting them)
listener.paused? # => tr... |
POPPIN-FUMI/gem_rbs_collection | gems/parallel/1.20/_test/each.rb | <gh_stars>0
Parallel.each(['a','b','c']) { |item| puts item }
Parallel.each(['a','b','c'], in_processes: 2) { |item| puts item * 2 }
Parallel.each(['a','b','c'], in_threads: 2) { |item| puts item * 3 }
Parallel.each(['a','b','c'], progress: 'Running...') { |item| puts item * 4 }
Parallel.each(['a','b','c'], start: ... |
POPPIN-FUMI/gem_rbs_collection | gems/redis/4.2/_test/expert-mode-options.rb | Redis.new(inherit_socket: true)
|
POPPIN-FUMI/gem_rbs_collection | gems/scanf/1.0/_test/test.rb | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require 'scanf'
# String#scanf and IO#scanf take a single argument, the format string
"123ac".scanf("%d%s")
File.open('test.rb', "rb").scanf("%d%s")
# Kernel#scanf reads from STDIN
scanf("%d%s")
|
POPPIN-FUMI/gem_rbs_collection | gems/redis/4.2/_test/get_set.rb | redis = Redis.new
redis.set("mykey", "hello world")
# => "OK"
redis.get("mykey")
# => "hello world"
|
POPPIN-FUMI/gem_rbs_collection | gems/parallel/1.20/_test/map.rb | puts Parallel.map(['a','b','c']) { |item| item * 1 }.at(0)
puts Parallel.map(['a','b','c'], in_processes: 2) { |item| item * 2 }.at(0)
puts Parallel.map(['a','b','c'], in_threads: 2) { |item| item * 3 }.at(0)
puts Parallel.map(['a','b','c'], progress: 'Running...') { |item| item * 4 }.at(0)
puts Parallel.map(['a','... |
POPPIN-FUMI/gem_rbs_collection | gems/graphql/1.12/_test/test.rb | <gh_stars>10-100
require "graphql"
# generated codes
module Types
class BaseObject < GraphQL::Schema::Object
end
class BaseEdge < Types::BaseObject
end
class BaseConnection < Types::BaseObject
include GraphQL::Types::Relay::ConnectionBehaviors
end
class BaseArgument < GraphQL::Schema::Argument
end
... |
POPPIN-FUMI/gem_rbs_collection | gems/parallel/1.20/_test/queue.rb | <filename>gems/parallel/1.20/_test/queue.rb
queue = Queue.new
queue.push 1
queue.push 2
queue.push 3
queue.push Parallel::Stop
puts Parallel.map(queue, in_threads: 2) { |i| "ITEM-#{i}" }
|
POPPIN-FUMI/gem_rbs_collection | gems/rainbow/3.0/_test/rainbow_test.rb | rainbow = Rainbow("hello")
rainbow.color(:pink)
rainbow.reset
.italic
.bold
.underline
.blink
.inverse
.hide
.black
.red
.green
.yellow
.blue
.magenta
.cyan
.white
Rainbow.enabled
Rainbow.enabled = false
Rainbow.uncolor("a string")
# X11 color names
Rainbow('Hi').aliceblue
Rainbow('Hi').a... |
POPPIN-FUMI/gem_rbs_collection | gems/redis/4.2/_test/timeout.rb | Redis.new(:timeout => 1)
Redis.new(
:connect_timeout => 0.2,
:read_timeout => 1.0,
:write_timeout => 0.5
)
|
POPPIN-FUMI/gem_rbs_collection | gems/sidekiq/6.2/_test/test_1.rb | <reponame>POPPIN-FUMI/gem_rbs_collection<gh_stars>0
# Test fundamental APIs
# Taken from: https://github.com/mperham/sidekiq/wiki/Getting-Started
class HardWorker
include Sidekiq::Worker
def perform(name, count)
puts "Performing #{name} #{count} times"
end
end
HardWorker.perform_async('bob', 5)
HardWorker.... |
POPPIN-FUMI/gem_rbs_collection | gems/redis/4.2/_test/cluster.rb | # @type var nodes: Array[Redis::node]
nodes = (7000..7005).map { |port| "redis://127.0.0.1:#{port}" }
redis = Redis.new(cluster: nodes)
nodes = (7000..7005).map do |port|
# @type block: Redis::node
{ host: '127.0.0.1', port: port }
end
redis = Redis.new(cluster: nodes)
|
POPPIN-FUMI/gem_rbs_collection | gems/ast/2.4/_test/test.rb | require 'ast'
def String!(_) end
def Symbol!(_) end
def Array!(_) end
def Node!(_) end
def Bool!(_) end
# AST::Node
node1 = AST::Node.new(:x)
node2 = AST::Node.new(:x, [:foo, 42])
AST::Node.new(:x, [:foo, 42], { y: 1 })
Array! node1.children
String! node1.hash
Symbol! node1.type
Bool! node1 == node2
Node! node... |
POPPIN-FUMI/gem_rbs_collection | gems/httpclient/2.8/_test/test.rb | require "httpclient"
client = HTTPClient.new
res = client.get("http://example.com", query: {"q" => "v"})
if res.status == 200
puts res.body
end
resnil = client.get("http://example.com") { |chunk| chunk.gsub(//) }
unless resnil.body
puts 'ok'
end
conn = client.post_async("http://example.com", body: { "name" => "kss... |
POPPIN-FUMI/gem_rbs_collection | gems/protobuf/3.10.3/_test/services.rb | module Services
class UserService
rpc :find, UserRequest, UserList
end
end
|
POPPIN-FUMI/gem_rbs_collection | gems/protobuf/3.10.3/_test/messages.rb | module Messages
::Protobuf::Optionable.inject(self) { ::Google::Protobuf::FileOptions }
class User < Protobuf::Message; end
class Address < Protobuf::Message; end
class User
optional :string, :first_name, 1
optional :string, :last_name, 2
optional ::Messages::Address, :address, 3
optional :boo... |
POPPIN-FUMI/gem_rbs_collection | gems/chunky_png/1.4.0/_test/test_4.rb | <gh_stars>10-100
image = ChunkyPNG::Image.from_rgba_stream(128, 128, File.read('pixeldata.rgba')) # or
image.save('filename.png', :best_compression)
File.open('newfile.png', 'wb' ) { |io| image.write(io) }
png_data = image.to_blob(:fast_rgba)
image.save('filename.png', :color_mode => ChunkyPNG::COLOR_INDEXED, :compress... |
readeldj/cheers_take3 | cheers.rb | #!/usr/bin/env ruby
require_relative 'lib/cheer'
# This file is for I/O, and delegates logic to our tested classes (in lib).
puts "Hello, what's your name?"
name = gets
puts Cheer.for_person(name)
puts "Hey #{name}, what's your birthday? (mm/dd)"
birthday_string = gets
puts Cheer.for_birthday(birthday_string) |
readeldj/cheers_take3 | lib/birthday_parser.rb | class BirthdayParser
def self.parse(birthday)
next_birthday = Date.parse(birthday)
today = Date.today
if next_birthday < today
next_birthday = next_birthday >> 12
end
next_birthday
end
end |
readeldj/cheers_take3 | lib/cheer.rb | require_relative 'birthday_parser'
class Cheer
AN_LETTERS = "HALFNORSEMIX"
def self.for_birthday(birthday)
today = Date.today
# puts today
next_birthday = BirthdayParser.parse(birthday)
difference = (next_birthday - today).to_i
case difference
when 0
# Today is their birthday
"... |
ninjudd/deep_clonable | test/test_helper.rb | <gh_stars>1-10
require 'rubygems'
require 'test/unit'
require 'shoulda'
require 'mocha/setup'
require 'deep_clonable'
class Test::Unit::TestCase
end
|
ninjudd/deep_clonable | test/deep_clonable_test.rb | require File.dirname(__FILE__) + '/test_helper'
class TestClass
deep_clonable
attr_reader :num, :hash, :array
def initialize(num, hash, array)
@num = num
@hash = hash
@array = array
end
clone_method :+, :add!
def add!(other)
@num += other.num
@hash.merge!(other.hash)
@array.co... |
ninjudd/deep_clonable | lib/deep_clonable.rb | class Class
def deep_clonable
include DeepClonable::InstanceMethods
extend DeepClonable::ClassMethods
end
end
module DeepClonable
module InstanceMethods
def clone
cloned_object = dup
yield(cloned_object) if block_given?
frozen? ? cloned_object.freeze : cloned_object
end
de... |
localytics/stager-client | lib/stager.rb | <filename>lib/stager.rb
require File.expand_path "stager/version", File.dirname(__FILE__)
require "thor"
require "httparty"
require "configliere"
require "launchy"
require File.expand_path "auth_strategy", File.dirname(__FILE__)
module Stager
class Command < Thor
Dir[File.expand_path("auth_strategies/*.r... |
localytics/stager-client | lib/auth_strategies/github.rb | require "launchy"
module Stager
class Github < Stager::AuthStrategy
def token
return Settings['github_token'] if Settings['github_token'] and !Settings['github_token'].empty?
gh_state = Digest::MD5.hexdigest("#{(36**8).to_s(36)}#{Time.now.to_i}")
oauth_url = HTTParty.post("#{@cli.endpoint}... |
localytics/stager-client | lib/auth_strategies/basic.rb | require 'io/console'
module Stager
class Basic < Stager::AuthStrategy
def saved_user
Settings[:username]
end
def user_saved?
saved_user && !saved_user.empty?
end
def save_user
puts "No user configured for basic auth"
print "Please enter username: "
username = STDIN... |
localytics/stager-client | lib/auth_strategy.rb | <reponame>localytics/stager-client
module Stager
class AuthStrategy
def for_cli(cli)
@cli = cli
self
end
def sign_request_options(options)
raise NotImplementedError
end
end
end
|
oklas/gem-json-rpc | lib/JsonRpcHttpServer.rb | require 'eventmachine'
require 'evma_httpserver'
require 'json'
class JsonRpcHttpServer < EM::Connection
include EM::HttpServer
def post_init
super
no_environment_strings
end
def id
1
end
def process_http_request
err = nil
response = EM::DelegatedHttpResponse.new(self)
response.s... |
oklas/gem-json-rpc | gem-json-rpc.gemspec | <reponame>oklas/gem-json-rpc
Gem::Specification.new do |s|
s.name = 'gem-json-rpc'
s.license = 'MIT'
s.version = '0.1.0'
s.date = '2017-02-21'
s.summary = "em json rpc"
s.description = "eventmachine based simplificators of json-rpc in ruby"
s.authors = ["<NAME>"]
s.email ... |
oklas/gem-json-rpc | lib/gem-json-rpc.rb | require 'JsonRpcHttpServer'
require 'JsonRpcHttpClient'
|
oklas/gem-json-rpc | lib/JsonRpcHttpClient.rb | <reponame>oklas/gem-json-rpc
require 'eventmachine'
require 'json-rpc-client'
require 'fiber'
class JsonRpcHttpClient
def initialize(url)
@url = url
end
def _rpc_call(method, *args)
err = nil
res = nil
EventMachine.run do
# To use the syncing behaviour, use it in a fiber.
fiber = Fib... |
rapid7/rex-core | lib/rex/core/version.rb | module Rex
module Core
VERSION = "0.1.19"
end
end
|
johngrimes/bigcharger | lib/bigcharger/utils.rb | <filename>lib/bigcharger/utils.rb
require 'logger'
class BigCharger
private
def set_request_defaults
@client.verbose = false
@client.url = @endpoint
@client.headers['Content-Type'] = 'text/xml'
end
def wrap_in_envelope(&block)
envelope = Nokogiri::XML::Builder.new do |xml|
xml.Envelope(... |
johngrimes/bigcharger | lib/bigcharger/config.rb | <filename>lib/bigcharger/config.rb
class BigCharger
SOAP_NAMESPACE = 'http://schemas.xmlsoap.org/soap/envelope/'
SERVICE_NAMESPACE = 'https://www.eway.com.au/gateway/managedpayment'
ENDPOINT = 'https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx'
TEST_ENDPOINT = 'https://www.eway... |
johngrimes/bigcharger | lib/bigcharger.rb | <filename>lib/bigcharger.rb
require File.dirname(__FILE__) + '/bigcharger/config'
require File.dirname(__FILE__) + '/bigcharger/utils'
require File.dirname(__FILE__) + '/bigcharger/ops'
class BigCharger
attr_accessor :logger
def initialize(customer_id, username, password, test_mode = false, logger = Logger.new('/... |
johngrimes/bigcharger | spec/spec_helper.rb | require 'rubygems'
require 'bundler'
Bundler.setup(:default, :development)
require 'webmock/rspec'
require 'simplecov'
WebMock.disable_net_connect!
SimpleCov.start
module BigChargerSpecHelpers
def message(name)
file = File.open(File.join(File.dirname(__FILE__), "./messages/#{name.to_s}.xml"), 'rb')
return ... |
johngrimes/bigcharger | bigcharger.gemspec | Gem::Specification.new do |s|
s.name = 'bigcharger'
s.version = '0.1.0'
s.description = 'A lightweight Ruby library for interfacing with the eWAY Token Payments API.'
s.summary = s.description
s.authors = ['<NAME>']
s.email = '<EMAIL>'
s.homepage = 'http://github.com/johngrimes/bigcharger'
s.require_pat... |
johngrimes/bigcharger | spec/bigcharger_spec.rb | <gh_stars>1-10
require File.dirname(__FILE__) + '/spec_helper'
require File.dirname(__FILE__) + '/../lib/bigcharger'
describe BigCharger do
include BigChargerSpecHelpers
before(:all) do
@customer_id = '87654321'
@username = '<EMAIL>'
@password = '<PASSWORD>'
@test_customer_id = '9876543211000'
... |
johngrimes/bigcharger | lib/bigcharger/ops.rb | <gh_stars>1-10
require 'nokogiri'
require 'curb'
class BigCharger
# Creates a new managed customer on the eWAY server.
# @param customer_fields Title, FirstName, LastName, Address, Suburb,
# State, Company, PostCode, Country, Email, Fax, Phone, Mobile,
# CustomerRef, JobDesc, Comments, URL, CCNumber, CCN... |
bdewey/Zipper | Zipper.podspec | <reponame>bdewey/Zipper<gh_stars>10-100
Pod::Spec.new do |s|
s.name = 'Zipper'
s.version = '1.2.0'
s.license = 'MIT'
s.summary = 'Effortless ZIP Handling in Swift'
s.homepage = 'https://github.com/Meniny/Zipper'
s.social_media_url = 'https://meniny.cn/'
s.authors = { '<NAME>' => '<EMAIL>' }
s.source = {... |
jeremyevans/roda-message_bus | spec/roda-message_bus_spec.rb | require 'roda'
require 'message_bus'
require 'json'
ENV['MT_NO_PLUGINS'] = '1' # Work around stupid autoloading of plugins
require 'minitest/global_expectations/autorun'
MessageBus.configure(:backend => :memory)
describe 'roda message_bus plugin' do
def req(path, input={}, env={})
env = {"PATH_INFO"=>path, "REQ... |
jeremyevans/roda-message_bus | lib/roda/plugins/message_bus.rb | # frozen-string-literal: true
require 'message_bus/rack/middleware'
class Roda
module RodaPlugins
# The message_bus plugin allows for integrating the message_bus library into
# Roda's routing tree. By default, MessageBus provides a Rack middlware to
# work with any rack framework. However, that doesn'... |
dorianmariefr/activejob-limiter | lib/active_job/limiter/railtie.rb | # frozen_string_literal: true
require 'global_id/railtie'
require 'active_job'
module ActiveJob
module Limiter
class Railtie < Rails::Railtie
ActiveSupport.on_load(:active_job) do
include ActiveJob::Limiter::Mixin
end
end
end
end
|
dorianmariefr/activejob-limiter | lib/active_job/limiter/queue_adapters/test_adapter.rb | # frozen_string_literal: true
module ActiveJob
module Limiter
module QueueAdapters
module TestAdapter
def self.check_lock_before_enqueue(_job, _expiration)
true
end
def self.clear_lock_before_perform(_job)
true
end
def self.acquire_lock_for_job_... |
dorianmariefr/activejob-limiter | lib/active_job/limiter/mixin.rb | # frozen_string_literal: true
require 'active_support/concern'
module ActiveJob
module Limiter
# ActiveJob Limiter
#
# This extends ActiveJob::Base
module Mixin
extend ActiveSupport::Concern
module ClassMethods
def limit_queue(expiration:)
# around_enqueue is preferred... |
dorianmariefr/activejob-limiter | spec/active_job/limiter_throttle_spec.rb | <reponame>dorianmariefr/activejob-limiter
# frozen_string_literal: true
RSpec.describe ActiveJob::Limiter do
let(:throttle_duration) { 2.minutes }
let(:resource_id) { '123' }
let(:queue_name) { :some_queue_name }
class MetricsProxy
def self.call(result, job); end
end
class ThrottledJob < ActiveJob::B... |
dorianmariefr/activejob-limiter | lib/active_job/limiter.rb | # frozen_string_literal: true
require 'active_job/limiter/version'
require 'active_support/dependencies/autoload'
module ActiveJob
module Limiter
extend ActiveSupport::Autoload
class UnsupportedActiveJobLimiterQueueAdapter; end
autoload :Mixin
autoload :QueueAdapters
class << self
def ch... |
dorianmariefr/activejob-limiter | activejob-limiter.gemspec | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'active_job/limiter/version'
Gem::Specification.new do |spec|
spec.name = 'activejob-limiter'
spec.version = ActiveJob::Limiter::VERSION
spec.authors = ['<NAM... |
dorianmariefr/activejob-limiter | lib/active_job/limiter/version.rb | # frozen_string_literal: true
module ActiveJob
module Limiter
VERSION = '0.1.1'
end
end
|
dorianmariefr/activejob-limiter | spec/active_job/limiter_spec.rb | # frozen_string_literal: true
RSpec.describe ActiveJob::Limiter do
let(:expiration_time) { 2.minutes }
class LimitedJob < ActiveJob::Base
include ActiveJob::Limiter::Mixin # Needed without Rails autoloading
# Same as :expiration_time above, unable to access let()
limit_queue expiration: 2.minutes
... |
dorianmariefr/activejob-limiter | lib/active_job/limiter/queue_adapters.rb | # frozen_string_literal: true
require 'active_support/dependencies/autoload'
module ActiveJob
module Limiter
module QueueAdapters
extend ActiveSupport::Autoload
autoload :SidekiqAdapter
autoload :TestAdapter
end
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.