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
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/locker/locker_base.rb
Ruby
mit
236
master
16,300
module ZK module Locker # Common code for the shared and exclusive lock implementations # # One thing to note about this implementation is that the API unfortunately # __does not__ follow the convention where bang ('!') methods raise # exceptions when they fail. This was an oversight on the part ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/locker/exclusive_locker.rb
Ruby
mit
236
master
1,726
module ZK module Locker # An exclusive lock implementation # # If the name 'dingus' is given, then in the case of an exclusive lock, the # algorithm works like: # # * lock_path = `zk.create("/_zklocking/dingus/ex", :sequential => true, :ephemeral => true)` # * extract the digit from the lo...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/locker/shared_locker.rb
Ruby
mit
236
master
1,041
module ZK module Locker class SharedLocker < LockerBase include Exceptions # (see LockerBase#lock) # obtain a shared lock. # def lock(opts={}) super end # (see LockerBase#assert!) # # checks that we: # # * we have obtained the lock (i.e. ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/locker/lock_options.rb
Ruby
mit
236
master
875
module ZK module Locker # @private class LockOptions attr_reader :wait, :now, :timeout def initialize(opts={}) @timeout = nil @now = Time.now raise "BLAH!" if opts.has_key?(:block) if opts.has_key?(:timeout) raise ArgumentError, ":timeout is an invalid ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/client/state_mixin.rb
Ruby
mit
236
master
2,177
module ZK module Client # Provides client-state related methods. Included in ZK::Client::Base. # (refactored out to this class to ease documentation overload) module StateMixin # Register a block to be called when *any* connection event occurs # # @yield [event] yields the connection eve...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/client/base.rb
Ruby
mit
236
master
42,883
module ZK module Client # This class forms the base API for interacting with ZooKeeper. Most people will # want to create instances of the class ZK::Client::Threaded, and the most # convenient way of doing that is through the top-level method `ZK.new` # # @note There is a lot of functionality mix...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/client/conveniences.rb
Ruby
mit
236
master
5,417
module ZK module Client # Convenience methods for creating instances of the cluster coordination # objects ZK provides, using the current connection. # # Mixed into {ZK::Client::Threaded} # module Conveniences # Queue an operation to be run on an internal threadpool. You may either ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/client/threaded.rb
Ruby
mit
236
master
25,318
module ZK module Client # This is the default client that ZK will use. In the zk-eventmachine gem, # there is an Evented client. # # If you want to register `on_*` callbacks (see {ZK::Client::StateMixin}) # then you should pass a block, which will be called before the # connection is set up (t...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/client/unixisms.rb
Ruby
mit
236
master
4,877
module ZK module Client module Unixisms include Zookeeper::Constants include Exceptions # Creates all parent paths and 'path' in zookeeper as persistent nodes with # zero data. # # @param [String] path An absolute znode path to create # # @option opts [String] :da...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
Rakefile
Ruby
mit
236
master
228
require 'bundler/gem_tasks' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec, :tag) do |t, task_args| unless task_args[:tag] == 'regression' t.rspec_opts = "--tag ~regression" end end task default: :spec
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
wgif.gemspec
Ruby
mit
236
master
1,375
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'wgif/version' Gem::Specification.new do |spec| spec.name = 'wgif' spec.version = WGif::VERSION spec.authors = ['Connor Mendenhall'] spec.email = ['ecmendenhal...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif.rb
Ruby
mit
236
master
324
require 'wgif/cli' require 'wgif/converter' require 'wgif/download_bar' require 'wgif/downloader' require 'wgif/exceptions' require 'wgif/gif_maker' require 'wgif/installer' require 'wgif/info_displayer' require 'wgif/uploader' require 'wgif/validator' require 'wgif/version' require 'wgif/video' require 'wgif/video_cac...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif/video.rb
Ruby
mit
236
master
1,495
require 'streamio-ffmpeg' require 'fileutils' module WGif class Video attr_accessor :name, :clip, :logger def initialize(name, filepath) @name = name @clip = FFMPEG::Movie.new(filepath) FileUtils.mkdir_p '/tmp/wgif/' @logger = Logger.new("/tmp/wgif/#{name}.log") FFMPEG.logger =...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif/download_bar.rb
Ruby
mit
236
master
452
require 'ruby-progressbar' module WGif class DownloadBar FORMAT = '==> %p%% |%B|' SMOOTHING = 0.8 attr_reader :progress_bar def initialize @progress_bar = ProgressBar.create( format: FORMAT, smoothing: SMOOTHING, total: @size ) end def update_total(size...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif/uploader.rb
Ruby
mit
236
master
882
require 'json' require 'typhoeus' require 'wgif/exceptions' module WGif class Uploader UPLOAD_ENDPOINT = 'https://api.imgur.com/3/image' def initialize(client_id) @client_id = client_id end def upload(filename) File.open(filename, 'r') do |file| response = Typhoeus.post(UPLOAD_...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif/downloader.rb
Ruby
mit
236
master
1,805
require 'viddl-rb' require 'typhoeus' require 'wgif/download_bar' require 'wgif/exceptions' require 'wgif/video' require 'wgif/video_cache' require 'uri' require 'cgi' module WGif class Downloader def initialize @cache = WGif::VideoCache.new end def video_url(youtube_url) urls = ViddlRb.get...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif/gif_maker.rb
Ruby
mit
236
master
487
require 'RMagick' module WGif class GifMaker def make_gif(frames_dir, filename, dimensions) image = Magick::ImageList.new(*frames_dir) resize(image, dimensions) image.coalesce image.optimize_layers Magick::OptimizeLayer image.write(filename) end def resize(image, dimensions...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif/exceptions.rb
Ruby
mit
236
master
432
module WGif InvalidUrlException = Class.new(Exception) InvalidTimestampException = Class.new(Exception) InvalidDurationException = Class.new(Exception) InvalidFramesException = Class.new(Exception) MissingOutputFileException = Class.new(Exception) VideoNotFoundException = Class.new(Excepti...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif/video_cache.rb
Ruby
mit
236
master
242
require 'pathname' module WGif class VideoCache def initialize @cache = {} end def get(video_id) path = "/tmp/wgif/#{video_id}" WGif::Video.new(video_id, path) if Pathname.new(path).exist? end end end
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif/validator.rb
Ruby
mit
236
master
499
require 'wgif/exceptions' module WGif class Validator TIMESTAMP = /\A\d{1,2}(?::\d{2})+(?:\.\d*)?\z/ def initialize(args) @args = args end def validate fail InvalidUrlException unless valid_url? fail InvalidTimestampException unless args[:trim_from] =~ TIMESTAMP fail Missing...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif/installer.rb
Ruby
mit
236
master
1,056
module WGif class Installer DEPENDENCIES = [['ffmpeg', 'ffmpeg'], ['imagemagick', 'convert']] def run if dependencies_installed? puts 'All dependencies are installed. Go make a gif.' Kernel.exit 0 end if homebrew_installed? DEPENDENCIES.each do |...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif/cli.rb
Ruby
mit
236
master
2,430
require 'wgif/argument_parser' require 'wgif/converter' require 'wgif/exceptions' require 'wgif/installer' require 'wgif/version' module WGif class CLI attr_accessor :argument_parser def initialize @argument_parser = WGif::ArgumentParser.new end def make_gif(cli_args) WGif::Installer.n...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif/converter.rb
Ruby
mit
236
master
672
require 'securerandom' require 'wgif/downloader' module WGif class Converter def initialize(args) @url = args[:url] @trim_from = args[:trim_from] @duration = args[:duration] @frames = args[:frames] end def video_to_frames clip = video.trim(trim_from, duration) clip.t...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif/argument_parser.rb
Ruby
mit
236
master
2,739
require 'optparse' require 'wgif/validator' module WGif class ArgumentParser DEFAULTS = { trim_from: '00:00:00', duration: 1.0, dimensions: '480' } def initialize @options = {} @parser = OptionParser.new do |opts| opts.on('-f N', '--frames N', ...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
lib/wgif/info_displayer.rb
Ruby
mit
236
master
601
module WGif class InfoDisplayer GIGA_SIZE = 1_073_741_824.0 MEGA_SIZE = 1_048_576.0 KILO_SIZE = 1024.0 def display(file_name) file_size = readable_file_size(File.size("#{file_name}").to_f) puts "#{file_name} is #{file_size}" end def readable_file_size(size) if size < KILO...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/regression/empty_image_list_spec.rb
Ruby
mit
236
master
441
require 'spec_helper' require 'wgif/cli' describe 'empty image list bug', regression: true do it 'throws an empty image list error' do args = ['https://www.youtube.com/watch?v=deFDlB8RiNg', 'fish_grease.gif', '--start', '00:00:13', '-d', '3', ...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/regression/frame_order_spec.rb
Ruby
mit
236
master
543
require 'spec_helper' require 'wgif/cli' describe 'frame order bug', regression: true do it 'does not create frames out of order' do args = ['https://www.youtube.com/watch?v=piWCBOsJr-w', 'banana-shoot.gif', '-s', '2:22', '-d', '17', ...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/unit/wgif/validator_spec.rb
Ruby
mit
236
master
937
require 'spec_helper' require 'wgif/validator' describe WGif::Validator do let(:valid_args) do { url: 'https://crazynonsense.info', output: 'output.gif', trim_from: '00:00:01' } end it 'checks for an invalid URL' do args = valid_args.merge(url: 'crazy nonsense') expect { descri...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/unit/wgif/converter_spec.rb
Ruby
mit
236
master
2,174
require "spec_helper" require "wgif/converter" describe WGif::Converter do describe "#video_to_frames" do it "downloads videos from youtube if the url is from www.youtube.com" do args = { url: "https://www.youtube.com/watvideo", trim_from: 0, duration: 10, frames: 200 ...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/unit/wgif/info_displayer_spec.rb
Ruby
mit
236
master
525
require 'spec_helper' require 'wgif/info_displayer' describe WGif::InfoDisplayer do let(:cache) { described_class.new } before do @mock_stdout = StringIO.new @real_stdout, $stdout = $stdout, @mock_stdout end after do $stdout = @real_stdout end it 'prints out a file size to the command line'...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/unit/wgif/downloader_spec.rb
Ruby
mit
236
master
2,614
require 'spec_helper' require 'wgif/downloader' require 'wgif/video' describe WGif::Downloader do let(:downloader) { described_class.new } let(:clip_url) { 'http://lol.wut/watch?v=roflcopter' } before do FileUtils.rm_rf('/tmp/wgif') download_bar = double(WGif::DownloadBar).as_null_object allow(WGif:...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/unit/wgif/download_bar_spec.rb
Ruby
mit
236
master
975
require 'spec_helper' require 'wgif/download_bar' describe WGif::DownloadBar do context 'setup' do let(:download_bar) { described_class.new } let(:mock_progress_bar) { double(ProgressBar) } before do allow(ProgressBar).to receive(:create).and_return(mock_progress_bar) end it 'creates a ...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/unit/wgif/cli_spec.rb
Ruby
mit
236
master
3,987
require 'spec_helper' require 'wgif/cli' describe WGif::CLI do let(:cli) { described_class.new } context 'error handling' do before do @mock_stdout = StringIO.new @real_stdout, $stdout = $stdout, @mock_stdout end after do $stdout = @real_stdout end def expect_help_with_mes...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/unit/wgif/gif_maker_spec.rb
Ruby
mit
236
master
703
require 'spec_helper' require 'wgif/gif_maker' require 'wgif/video' describe WGif::GifMaker do let(:gif_maker) { described_class.new } let(:image) { double(Magick::Image) } let(:images) { double(Magick::ImageList, each: nil) } before do allow(Magick::ImageList).to receive(:new).and_return(images) end ...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/unit/wgif/installer_spec.rb
Ruby
mit
236
master
3,875
require 'spec_helper' require 'wgif/installer' describe WGif::Installer do let(:installer) { described_class.new } before do @mock_stdout = StringIO.new @real_stdout, $stdout = $stdout, @mock_stdout end after do $stdout = @real_stdout end context 'checking for Homebrew' do it 'finds Hom...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/unit/wgif/video_cache_spec.rb
Ruby
mit
236
master
426
require 'spec_helper' require 'wgif/video_cache' describe WGif::VideoCache do let(:cache) { described_class.new } it 'checks for existing video files in /tmp' do pathname = double(Pathname) expect(Pathname).to receive(:new).and_return(pathname) expect(pathname).to receive(:exist?).and_return(true) ...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/unit/wgif/uploader_spec.rb
Ruby
mit
236
master
1,488
require 'json' require 'spec_helper' require 'typhoeus' require 'wgif/uploader' describe WGif::Uploader do let(:api_key) { 'api-key' } let(:uploader) { WGif::Uploader.new(api_key) } let(:success) do Typhoeus::Response.new( response_code: 200, return_code: :ok, body: { data: { link: 'foo' } ...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/unit/wgif/argument_parser_spec.rb
Ruby
mit
236
master
2,984
require 'spec_helper' require 'wgif/argument_parser' describe WGif::ArgumentParser do let(:parser) { described_class.new } it 'starts at 0s by default' do args = parser.parse_args ['http://example.com'] expect(args[:trim_from]).to eq('00:00:00') end it 'trims clips to 1s by default' do args = par...
github
ecmendenhall/wgif
https://github.com/ecmendenhall/wgif
spec/unit/wgif/video_spec.rb
Ruby
mit
236
master
3,450
require 'spec_helper' require 'wgif/video' describe WGif::Video do let(:clip) { double(FFMPEG::Movie) } before do allow(FFMPEG::Movie).to receive(:new).and_return(clip) end it 'has a name and filepath' do expect(clip).to receive(:path).and_return('/tmp/wgif/bjork.mp4') video = described_class.new...
github
peek/peek-rblineprof
https://github.com/peek/peek-rblineprof
peek-rblineprof.gemspec
Ruby
mit
235
master
1,069
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'peek-rblineprof/version' Gem::Specification.new do |spec| spec.name = 'peek-rblineprof' spec.version = Peek::Rblineprof::VERSION spec.authors = ['Garrett Bjerkhoel'] ...
github
peek/peek-rblineprof
https://github.com/peek/peek-rblineprof
lib/peek-rblineprof/railtie.rb
Ruby
mit
235
master
327
require 'peek/rblineprof/controller_helpers' module Peek module Rblineprof class Railtie < ::Rails::Engine initializer 'peek.rblineprof.include_controller_helpers' do ActiveSupport.on_load(:action_controller) do include Peek::Rblineprof::ControllerHelpers end end end e...
github
peek/peek-rblineprof
https://github.com/peek/peek-rblineprof
lib/peek/rblineprof/controller_helpers.rb
Ruby
mit
235
master
4,285
begin require 'pygments.rb' rescue LoadError # Doesn't have pygments.rb installed end require 'rack/utils' module Peek module Rblineprof module ControllerHelpers extend ActiveSupport::Concern included do around_action :inject_rblineprof, :if => [:peek_enabled?, :rblineprof_enabled?] ...
github
mbleigh/princely
https://github.com/mbleigh/princely
princely.gemspec
Ruby
mit
235
master
989
# -*- encoding: utf-8 -*- require File.expand_path('../lib/princely/version', __FILE__) Gem::Specification.new do |s| s.name = "princely" s.version = Princely::Version.to_s s.authors = ["Michael Bleigh", "Jared Fraser"] s.date = "2016-06-16" s.description = "A wrapper for the PrinceXML PDF generation library...
github
mbleigh/princely
https://github.com/mbleigh/princely
spec/spec_helper.rb
Ruby
mit
235
master
212
require 'princely' RSpec.configure do |config| config.run_all_when_everything_filtered = true config.filter_run :focus #config.expect_with(:rspec) { |c| c.syntax = :should } config.order = 'random' end
github
mbleigh/princely
https://github.com/mbleigh/princely
spec/princely/executable_spec.rb
Ruby
mit
235
master
1,485
require 'spec_helper' module Princely describe Executable do context 'without executable checks' do before do allow_any_instance_of(Princely::Executable).to receive(:check_for_executable) end describe '#join' do let(:path) { '/some/path' } let(:executable) { Princ...
github
mbleigh/princely
https://github.com/mbleigh/princely
spec/princely/version_spec.rb
Ruby
mit
235
master
284
require 'spec_helper' require 'princely/version' describe Princely::Version do let(:version) { '9.9.9' } before { allow(Princely::Version).to receive(:version).and_return(version) } it "prints the version" do expect(Princely::Version.to_s).to eql(version) end end
github
mbleigh/princely
https://github.com/mbleigh/princely
spec/princely/logging_spec.rb
Ruby
mit
235
master
567
require 'spec_helper' require 'princely/logging' module Princely describe Logging do describe "filename=" do it "sets the log file" do Princely::Logging.filename = "palakir" expect(Princely::Logging.filename).to eql("palakir") Princely::Logging.filename = nil # clean up end ...
github
mbleigh/princely
https://github.com/mbleigh/princely
spec/princely/pdf_spec.rb
Ruby
mit
235
master
2,929
require 'spec_helper' describe Princely::Pdf do let(:html_doc) { "<html><body>Hello World</body></html>"} before(:each) do Princely.executable = nil allow_any_instance_of(Princely::Executable).to receive(:check_for_executable) end it "generates a PDF from HTML" do pdf = Princely::Pdf.new.pdf_from_...
github
mbleigh/princely
https://github.com/mbleigh/princely
lib/princely.rb
Ruby
mit
235
master
1,161
# PrinceXML Ruby interface. # http://www.princexml.com # # Original code by Seth @ Subimage LLC # - http://subimage.com/blog/2007/05/29/html-css-to-pdf-using-ruby-on-rails/ # # # USAGE # ----------------------------------------------------------------------------- # princely = Princely.new # html_string = render_t...
github
mbleigh/princely
https://github.com/mbleigh/princely
lib/princely/railtie.rb
Ruby
mit
235
master
759
require 'princely/pdf_helper' module Princely class Railtie < Rails::Railtie initializer "princely.helper" do if Mime::Type.lookup_by_extension(:pdf) != 'application/pdf' Mime::Type.register 'application/pdf', :pdf end if ::Rails::VERSION::MAJOR >= 5 ActiveSupport.on_load(:acti...
github
mbleigh/princely
https://github.com/mbleigh/princely
lib/princely/pdf_helper.rb
Ruby
mit
235
master
2,277
require 'princely' require 'princely/asset_support' module Princely module PdfHelper def self.included(base) base.send :alias_method, :render_without_princely, :render base.send :alias_method, :render, :render_with_princely end def self.prepended(base) base.send :alias_method, :render_...
github
mbleigh/princely
https://github.com/mbleigh/princely
lib/princely/asset_support.rb
Ruby
mit
235
master
923
module Princely module AssetSupport def localize_html_string(html_string, asset_path = nil) html_string = html_string.to_str # Make all paths relative, on disk paths... html_string.gsub!(".com:/",".com/") # strip out bad attachment_fu URLs html_string.gsub!( /src=["']+([^:]+?)["']/i ) do |...
github
mbleigh/princely
https://github.com/mbleigh/princely
lib/princely/executable.rb
Ruby
mit
235
master
673
module Princely class Executable attr_reader :path def initialize(path=nil) @path = path || default_executable_path check_for_executable end def check_for_executable raise "Cannot find prince command-line app in $PATH" if !@path || @path.length == 0 raise "Cannot find prince...
github
mbleigh/princely
https://github.com/mbleigh/princely
lib/princely/pdf.rb
Ruby
mit
235
master
3,630
require 'timeout' module Princely class Pdf attr_accessor :executable, :style_sheets, :logger, :log_file, :server_flag, :media, :javascript_flag, :timeout, :pdf_forms_flag # Initialize method # def initialize(options={}) options = { :path => nil, :executable => Princely.executa...
github
mbleigh/princely
https://github.com/mbleigh/princely
lib/princely/logging.rb
Ruby
mit
235
master
354
module Princely module Logging class << self attr_accessor :logger, :filename def logger @logger ||= defined?(Rails) ? Rails.logger : StdoutLogger end def filename pathname = defined?(Rails) ? Rails.root : Princely.root @filename ||= pathname.join 'log', 'prince....
github
q9f/eth.rb
https://github.com/q9f/eth.rb
Gemfile
Ruby
apache-2.0
235
main
340
# frozen_string_literal: true source "https://rubygems.org" group :test, :development do gem "bundler", ">= 2.4" gem "pry", "~> 0.15" gem "rake", "~> 13.2" gem "rdoc", "~> 6.13" gem "rspec", "~> 3.13" gem "rufo", "~> 0.18" gem "simplecov", "~> 0.22" gem "simplecov-cobertura", "~> 3.0" gem "yard", "~...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
eth.gemspec
Ruby
apache-2.0
235
main
2,194
# frozen_string_literal: true # coding: utf-8 lib = File.expand_path("lib", __dir__).freeze $LOAD_PATH.unshift lib unless $LOAD_PATH.include? lib require "eth/version" Gem::Specification.new do |spec| spec.name = "eth" spec.version = Eth::VERSION spec.authors = ["Steve Ellis", "Afri Schoedon"] spec.email = [...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/spec_helper.rb
Ruby
apache-2.0
235
main
380
# use the local version of the code instead of a globally installed gem $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) if ENV["COVERAGE"] or ENV["CI"] require "simplecov" require "simplecov-cobertura" SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter SimpleCov.start end require "eth" ...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/rlp_spec.rb
Ruby
apache-2.0
235
main
3,303
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Rlp do describe ".encode .decode" do # load official ethereum/tests fixtures for RLPs let(:rlp_tests_file) { File.read "spec/fixtures/ethereum/tests/RLPTests/rlptest.json", :encoding => "ascii-8bit" } subject(:rlp_tests) { JSON.parse rlp_te...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/address_spec.rb
Ruby
apache-2.0
235
main
6,380
require "spec_helper" describe Address do describe ".initialize" do # alice is initialized with an unprefixed address subject(:alice) { Address.new "c1c0f155bd054597c60cb33e6da7edbc9c70275b" } # bob is initialized with a prefixed address subject(:bob) { Address.new "0x7291d3cd257053bac810ee2c55fd7c15...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/util_spec.rb
Ruby
apache-2.0
235
main
11,263
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Util do describe ".public_key_to_address" do it "can create ethereum address from random keys" do alice = Util.public_key_to_address Key.new.public_bytes expect(alice).to be expect(Util.prefixed? alice.to_s).to be_truthy expe...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/constant_spec.rb
Ruby
apache-2.0
235
main
1,301
# # -*- encoding : ascii-8bit -*- require "spec_helper" describe Eth::Constant do describe "#SYMBOLS" do it "has valid constants" do expect(Constant::BYTE_EMPTY).to eq "" expect(Constant::BYTE_ZERO).to eq "\x00" expect(Constant::BYTE_ONE).to eq "\x01" expect(Constant::TT32).to eq 4294967...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/chain_spec.rb
Ruby
apache-2.0
235
main
5,905
require "spec_helper" describe Chain do context "#CHAIN_ID" do it "has EIP155 chain ids for mainnets, testnets, and devnets" do # Chain IDs for selected mainnets expect(Chain::ETHEREUM).to eq 1 expect(Chain::EXPANSE).to eq 2 expect(Chain::OPTIMISM).to eq 10 expect(Chain::CLASSIC).to...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/bls_spec.rb
Ruby
apache-2.0
235
main
1,187
# frozen_string_literal: true require "spec_helper" RSpec.describe Eth::Bls do let(:priv_key) { "0x01" } let(:message) { "#{"ab" * 32}" } it "wraps signing and public key derivation" do pub_hex = Eth::Bls.get_public_key(priv_key) sig_hex = Eth::Bls.sign(message, priv_key) expect(pub_hex).to eq(Uti...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/solidity_spec.rb
Ruby
apache-2.0
235
main
3,322
require "spec_helper" describe Solidity do it "finds a solc compiler" do # This fails if no `solc` is in the $PATH. expect(Solidity.new).to be expect(Solidity.new(system("which", "solc", :out => File::NULL))).to be end subject(:solc) { Solidity.new } it "compiles the dummy contract" do contra...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/eip712_spec.rb
Ruby
apache-2.0
235
main
12,327
require "spec_helper" describe Eip712 do # The EIP-712 domain specification descriptor. subject(:eip712_domain) { [ { :name => "name", :type => "string" }, { :name => "version", :type => "string" }, { :name => "chainId", :type => "uint256" }, { :name => "verifyingContract", :type => "a...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/client_spec.rb
Ruby
apache-2.0
235
main
43,005
require "spec_helper" describe Client do # run `geth --dev --http --wc --ipcpath /tmp/geth.ipc` # to provide http, ws and ipc to pass these tests. let(:geth_ipc_path) { "/tmp/geth.ipc" } let(:geth_http_path) { "http://127.0.0.1:8545" } let(:geth_ws_path) { "ws://127.0.0.1:8546" } let(:geth_http_authed_pat...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/tx_spec.rb
Ruby
apache-2.0
235
main
14,482
require "spec_helper" describe Tx do context "#GAS" do it "defines gas limits" do expect(Tx::DEFAULT_GAS_LIMIT).to eq 21_000 expect(Tx::DEFAULT_PRIORITY_FEE).to eq 1_010_000_000 expect(Tx::DEFAULT_GAS_PRICE).to eq 42_690_000_000 expect(Tx::BLOCK_GAS_LIMIT).to eq 30_000_000 end it...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/ens_spec.rb
Ruby
apache-2.0
235
main
243
require "spec_helper" describe Ens do it "has EIP155 chain ids for mainnets, testnets, and devnets" do # Chain IDs for selected mainnets expect(Ens::DEFAULT_ADDRESS.to_s).to eq "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" end end
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/abi_spec.rb
Ruby
apache-2.0
235
main
31,400
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Abi do describe ".encode .decode" do # load official ethereum/tests fixtures for ABIs let(:basic_abi_tests_file) { File.read "spec/fixtures/ethereum/tests/ABITests/basic_abi_tests.json" } subject(:basic_abi_tests) { JSON.parse basic_abi_tes...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/signature_spec.rb
Ruby
apache-2.0
235
main
16,186
require "spec_helper" describe Signature do describe ".prefix_message" do it "can properly prefix messages" do hello = "Hello World!" expect(Signature.prefix_message hello).to eq "\x19Ethereum Signed Message:\n12Hello World!" proof = "This is proof that I, user A, have access to this address." ...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/key_spec.rb
Ruby
apache-2.0
235
main
8,951
require "spec_helper" describe Key do describe ".initialize" do subject(:alice) { Key.new } subject(:bob) { Key.new } it "generates functional keypairs" do # generates a functional key for alice of type Key expect(alice).to be_an_instance_of Key # generates a functional key for bob o...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/contract_spec.rb
Ruby
apache-2.0
235
main
6,897
require "spec_helper" describe Contract do subject(:solc) { Eth::Solidity.new } subject(:contract) { solc.compile(file) } subject(:dummy_contract) { Contract.new(name, bin, abi) } let(:file) { "spec/fixtures/contracts/dummy.sol" } let(:name) { contract.keys[0] } let(:bin) { contract[name]["bin"] } let(:...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/unit_spec.rb
Ruby
apache-2.0
235
main
506
require "spec_helper" describe Unit do context "#ETHER" do it "has constants for all common Ether units" do expect(Unit::WEI).to eq 1 expect(Unit::BABBAGE).to eq 1_000 expect(Unit::LOVELACE).to eq 1_000_000 expect(Unit::SHANNON).to eq 1_000_000_000 expect(Unit::SZABO).to eq 1_000_00...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/rlp/sedes_spec.rb
Ruby
apache-2.0
235
main
885
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Rlp::Sedes do describe "inference" do subject(:pairs) { [ [5, Rlp::Sedes.big_endian_int], [0, Rlp::Sedes.big_endian_int], [-1, nil], ["", Rlp::Sedes.binary], ["asdf", Rlp::Sedes.binary], ['\xe4\x...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/rlp/sedes/list_spec.rb
Ruby
apache-2.0
235
main
1,101
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Rlp::Sedes::List do subject(:l1) { Rlp::Sedes::List.new } subject(:l2) { Rlp::Sedes::List.new elements: [Rlp::Sedes.big_endian_int, Rlp::Sedes.big_endian_int] } subject(:l3) { Rlp::Sedes::List.new elements: [l1, l2, [[[]]]] } it "it does not seri...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/rlp/sedes/big_endian_int_spec.rb
Ruby
apache-2.0
235
main
2,132
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Rlp::Sedes::BigEndianInt do subject(:integers) { [ 256, 257, 4839, 849302, 483290432, 483290483290482039482039, 48930248348219540325894323584235894327865439258743754893066, ] } subject(:negatives) { ...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/rlp/sedes/binary_spec.rb
Ruby
apache-2.0
235
main
482
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Rlp::Sedes::Binary do it "does serialize fixed length binary" do b = Rlp::Sedes::Binary.fixed_length 3 expect(b.serialize "foo").to eq "foo" expect(b.deserialize "bar").to eq "bar" expect { b.serialize "foobar" }.to raise_error Rlp::Seri...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/contract/function_input_spec.rb
Ruby
apache-2.0
235
main
770
require "spec_helper" describe Contract::FunctionInput do subject(:function_input) { Contract::FunctionInput.new({ "name" => "amount", "type" => "uint256" }) } it "creates FunctionInput objects" do expect(function_input.name).to eq("amount") expect(function_input.type).to eq("uint256") expect(function_...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/contract/event_spec.rb
Ruby
apache-2.0
235
main
5,382
require "spec_helper" describe Contract::Event do let(:path) { "spec/fixtures/contracts/test_contract.sol" } subject(:contract) { Eth::Contract.from_file(file: path) } context ".initialize" do it "succeed" do expect(contract.events[0].name).to eq("changed") expect(contract.events[0].signature).t...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/contract/function_output_spec.rb
Ruby
apache-2.0
235
main
780
require "spec_helper" describe Contract::FunctionOutput do subject(:function_output) { Contract::FunctionOutput.new({ "name" => "amount", "type" => "uint256" }) } it "creates FunctionOutput objects" do expect(function_output.name).to eq("amount") expect(function_output.type).to eq("uint256") expect(fun...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/contract/error_spec.rb
Ruby
apache-2.0
235
main
1,272
require "spec_helper" describe Contract do let(:abi) do [ { "type" => "function", "name" => "foo", "inputs" => [], "outputs" => [] }, { "type" => "error", "name" => "Unauthorized", "inputs" => [{ "name" => "addr", "type" => "address" }], }, ] end let(:contract) ...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/contract/initializer_spec.rb
Ruby
apache-2.0
235
main
703
require "spec_helper" describe Contract::Initializer do subject(:file) { "spec/fixtures/contracts/greeter.sol" } subject(:contract_initializer) { Contract::Initializer.new(file) } describe ".initialize" do it "contracts initialized" do expect(contract_initializer.contracts.size).to eq 2 expect(c...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/contract/function_spec.rb
Ruby
apache-2.0
235
main
3,215
require "spec_helper" describe Contract::Function do let(:erc20_abi_file) { File.read "spec/fixtures/abi/ERC20.json" } let(:abi) { JSON.parse erc20_abi_file } subject(:functions) { abi.select { |x| x["type"] == "function" }.map { |fun| Eth::Contract::Function.new(fun) } } it "creates Function objects" do ...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/client/ws_spec.rb
Ruby
apache-2.0
235
main
10,734
# Copyright (c) 2016-2025 The Ruby-Eth Contributors # # 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...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/key/encrypter_spec.rb
Ruby
apache-2.0
235
main
4,585
require "spec_helper" # These test vectors are specified in the ethereum wiki: # https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition describe Key::Encrypter do describe ".perform" do let(:password) { "testpassword" } let(:key) { Key.new priv: "7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/key/decrypter_spec.rb
Ruby
apache-2.0
235
main
2,216
require "spec_helper" describe Key::Decrypter do def read_key_fixture(path) File.read "./spec/fixtures/keys/#{path}.json" end describe ".perform pbkdf2 key" do let(:password) { "testpassword" } let(:key_data) { read_key_fixture password } it "recovers the example pbkdf2 key" do result = K...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/ens/resolver_spec.rb
Ruby
apache-2.0
235
main
2,570
require "spec_helper" describe Ens::Resolver do # public rpc let(:drpc_api) { "https://eth.drpc.org" } subject(:drpc_mainnet) { Client.create drpc_api } let(:resolver) { Ens::Resolver.new(drpc_mainnet) } describe "normalize" do it "can normalize ascii" do expect(resolver.normalize("foo.eth")).to ...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/ens/coin_type_spec.rb
Ruby
apache-2.0
235
main
470
require "spec_helper" describe Ens::CoinType do it "knows some coin slip-44 types" do expect(Ens::CoinType::BITCOIN).to eq 0 expect(Ens::CoinType::LITECOIN).to eq 2 expect(Ens::CoinType::DOGECOIN).to eq 3 expect(Ens::CoinType::ETHEREUM).to eq 60 expect(Ens::CoinType::ETHEREUM_CLASSIC).to eq 61 ...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/abi/function_spec.rb
Ruby
apache-2.0
235
main
1,383
require "spec_helper" describe Abi::Function do let(:erc20_abi_file) { File.read "spec/fixtures/abi/ERC20.json" } subject(:interfaces) { JSON.parse(erc20_abi_file).select { |i| i["type"] == "function" } } let(:functions) { interfaces.map { |fun| Eth::Contract::Function.new(fun) } } describe ".type" do it...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/abi/encoder_spec.rb
Ruby
apache-2.0
235
main
10,056
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Abi::Encoder do subject(:t_bool) { Abi::Type.parse "bool" } subject(:t_uint_8) { Abi::Type.parse "uint8" } subject(:t_int_8) { Abi::Type.parse "int8" } subject(:t_ureal_128_128) { Abi::Type.parse "ureal128x128" } subject(:t_real_128_128) { Abi::...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/abi/event_spec.rb
Ruby
apache-2.0
235
main
15,931
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Abi::Event do let(:erc20_abi_file) { File.read "spec/fixtures/abi/ERC20.json" } subject(:erc20_abi) { JSON.parse erc20_abi_file } let(:erc721_abi_file) { File.read "spec/fixtures/abi/ERC721.json" } subject(:erc721_abi) { JSON.parse erc721_abi_fil...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/abi/type_spec.rb
Ruby
apache-2.0
235
main
8,115
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Abi::Type do describe ".initialize" do it "can instantiate new types" do # https://github.com/cryptape/ruby-ethereum-abi/blob/90d4fa3fc6b568581165eaacdc506b9b9b49e520/test/abi/type_test.rb#L8 expect(Abi::Type.new "uint", 8, []).to eq Ab...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/abi/decoder_spec.rb
Ruby
apache-2.0
235
main
8,908
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Abi::Decoder do subject(:t_bool) { Abi::Type.parse "bool" } subject(:t_uint_8) { Abi::Type.parse "uint8" } subject(:t_int_8) { Abi::Type.parse "int8" } subject(:t_ureal_128_128) { Abi::Type.parse "ureal128x128" } subject(:t_real_128_128) { Abi::...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/abi/packed/encoder_spec.rb
Ruby
apache-2.0
235
main
12,152
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Abi::Packed::Encoder do it "encodes packed types" do expect(Util.bin_to_hex Abi.solidity_packed(["uint8[]"], [[1, 2, 3]])).to eq "010203" expect(Util.bin_to_hex Abi.solidity_packed(["uint16[]"], [[1, 2, 3]])).to eq "000100020003" expect(Util...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/tx/eip2930_spec.rb
Ruby
apache-2.0
235
main
19,636
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Tx::Eip2930 do # ref https://goerli.etherscan.io/tx/0xaed08e43736c8c99d6fa3a10b7a66f59a08f0b0999bbf6d050b2f65a5608d988#accesslist subject(:list) { [ [ "de0b295669a9fd93d5f28d9ec85e40f4cb697bae", [ "00000000000000000...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/tx/eip7702_spec.rb
Ruby
apache-2.0
235
main
22,066
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Tx::Eip7702 do subject(:anvil) { 31337.freeze } subject(:authorization_list) { [ Tx::Eip7702::Authorization.new( chain_id: anvil, address: "700b6a60ce7eaaea56f065753d8dcb9653dbad35", nonce: 2, recovery_...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/tx/eip1559_spec.rb
Ruby
apache-2.0
235
main
12,787
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Tx::Eip1559 do # ref https://goerli.etherscan.io/tx/0x737b57a273ea1e63e6b8f770313fc2fbc4a668706d2921292dd28307b9f9644f#accesslist subject(:list) { [ [ "de0b295669a9fd93d5f28d9ec85e40f4cb697bae", [ "0000000000000000...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/tx/legacy_spec.rb
Ruby
apache-2.0
235
main
18,406
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Tx::Legacy do subject(:tx) { Tx.new({ nonce: 0, gas_price: Unit::WEI, gas_limit: Tx::DEFAULT_GAS_LIMIT, }) } subject(:cow) { Key.new(priv: Util.keccak256("cow")) } # ref https://sepolia.etherscan.io/tx/0x7613b4de482fcff6...
github
q9f/eth.rb
https://github.com/q9f/eth.rb
spec/eth/tx/eip4844_spec.rb
Ruby
apache-2.0
235
main
9,924
# -*- encoding : ascii-8bit -*- require "spec_helper" describe Tx::Eip4844 do subject(:blob_hashes) { ["0x" + "11" * 32] } subject(:tx) do Tx.new({ nonce: 0, priority_fee: 0, max_gas_fee: Unit::WEI, gas_limit: Tx::DEFAULT_GAS_LIMIT, to: "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD82...