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 | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/key_mapper/abstract_key_mapper.rb | Ruby | mit | 242 | master | 1,438 | require 'curses'
require 'twterm/key_mapper/no_such_command'
require 'twterm/key_mapper/no_such_key'
module Twterm
class KeyMapper
class AbstractKeyMapper
def initialize(dict)
commands = self.class.commands
dict ||= {}
dict.keys.each do |k|
raise NoSuchCommand.new(self.c... |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/key_mapper/tab_key_mapper.rb | Ruby | mit | 242 | master | 648 | require 'twterm/key_mapper/abstract_key_mapper'
module Twterm
class KeyMapper
class TabKeyMapper < Twterm::KeyMapper::AbstractKeyMapper
DEFAULT_MAPPINGS = {
:'1st' => '1',
:'2nd' => '2',
:'3rd' => '3',
:'4th' => '4',
:'5th' => '5',
:'6th' => '6',
:'7t... |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/key_mapper/no_such_key.rb | Ruby | mit | 242 | master | 247 | module Twterm
class KeyMapper
class NoSuchKey < StandardError
attr_reader :key
def initialize(key)
@key = key
super(message)
end
def message
"No such key: #{key}"
end
end
end
end |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/key_mapper/general_key_mapper.rb | Ruby | mit | 242 | master | 344 | require 'twterm/key_mapper/abstract_key_mapper'
class Twterm::KeyMapper::GeneralKeyMapper < Twterm::KeyMapper::AbstractKeyMapper
DEFAULT_MAPPINGS = {
bottom: 'G',
down: 'j',
left: 'h',
page_down: 'd',
page_up: 'u',
right: 'l',
top: 'g',
up: 'k',
}.freeze
def self.category
'ge... |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/key_mapper/cursor_key_mapper.rb | Ruby | mit | 242 | master | 292 | require 'twterm/key_mapper/abstract_key_mapper'
class Twterm::KeyMapper::CursorKeyMapper < Twterm::KeyMapper::AbstractKeyMapper
DEFAULT_MAPPINGS = {
bottom_of_window: 'L',
middle_of_window: 'M',
top_of_window: 'H',
}.freeze
def self.category
'cursor'.freeze
end
end |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/key_mapper/no_such_command.rb | Ruby | mit | 242 | master | 389 | module Twterm
class KeyMapper
class NoSuchCommand < StandardError
attr_reader :category, :command
def initialize(category, command)
@category, @command = category, command
super(message)
end
def full_command
"#{category}.#{command}"
end
def message
... |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/key_mapper/app_key_mapper.rb | Ruby | mit | 242 | master | 260 | require 'twterm/key_mapper/abstract_key_mapper'
class Twterm::KeyMapper::AppKeyMapper < Twterm::KeyMapper::AbstractKeyMapper
DEFAULT_MAPPINGS = {
cheatsheet: 'F1',
me: 'm',
quit: 'F10',
}.freeze
def self.category
'app'.freeze
end
end |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/key_mapper/status_key_mapper.rb | Ruby | mit | 242 | master | 374 | require 'twterm/key_mapper/abstract_key_mapper'
class Twterm::KeyMapper::StatusKeyMapper < Twterm::KeyMapper::AbstractKeyMapper
DEFAULT_MAPPINGS = {
compose: '^N',
conversation: 'c',
destroy: 'D',
like: 'F',
open_link: 'o',
quote: 'Q',
reply: 'r',
retweet: 'R',
user: 'U',
}.free... |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/image_builder/user_name_image_builder.rb | Ruby | mit | 242 | master | 640 | require 'twterm/image'
module Twterm
# @todo Rename to `Presenter`
module ImageBuilder
class UserNameImageBuilder
COLORS = [:red, :blue, :green, :cyan, :yellow, :magenta].freeze
# @param user [Twterm::User] user
def initialize(user)
@user = user
end
# @return [Twterm::Im... |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/notification_backend/tmux_backend.rb | Ruby | mit | 242 | master | 592 | require 'shellwords'
require 'twterm/notification_backend/abstract_notification_backend'
module Twterm
module NotificationBackend
class TmuxBackend < AbstractNotificationBackend
# @param [Twterm::Event::Notification::AbstractNotification] notification notification to display in tmux status line
# @r... |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/notification_backend/inline_backend.rb | Ruby | mit | 242 | master | 525 | require 'curses'
require 'twterm/event/message/info'
require 'twterm/notification_backend/abstract_notification_backend'
require 'twterm/publisher'
module Twterm
module NotificationBackend
class InlineBackend < AbstractNotificationBackend
include Publisher
# @param [Twterm::Event::Notification::Abs... |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/notification_backend/terminal_notifier_backend.rb | Ruby | mit | 242 | master | 666 | require 'terminal-notifier'
require 'twterm/notification_backend/abstract_notification_backend'
module Twterm
module NotificationBackend
class TerminalNotifierBackend < AbstractNotificationBackend
# @param [Twterm::Event::Notification::AbstractNotification] notification notification to display via termina... |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/notification_backend/abstract_notification_backend.rb | Ruby | mit | 242 | master | 391 | module Twterm
module NotificationBackend
# @abstract
class AbstractNotificationBackend
# @abstract
# @param [Twterm::Event::Notification::AbstractNotification] _notification a notification to show
def notify(_notification)
raise NotImplementedError, '`notify` method must be implement... |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/photo_viewer_backend/imgcat_backend.rb | Ruby | mit | 242 | master | 748 | require 'curses'
require 'twterm/event/screen/refresh'
require 'twterm/photo_viewer_backend/abstract_photo_viewer_backend'
require 'twterm/publisher'
module Twterm
module PhotoViewerBackend
class ImgcatBackend < AbstractPhotoViewerBackend
include Publisher
def view(url)
Curses.close_screen ... |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/photo_viewer_backend/browser_backend.rb | Ruby | mit | 242 | master | 360 | require 'twterm/photo_viewer_backend/abstract_photo_viewer_backend'
require 'twterm/publisher'
require 'twterm/event/open_uri'
module Twterm
module PhotoViewerBackend
class BrowserBackend < AbstractPhotoViewerBackend
include Publisher
def view(url)
event = Event::OpenURI.new(url)
pub... |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/photo_viewer_backend/abstract_photo_viewer_backend.rb | Ruby | mit | 242 | master | 1,026 | require 'concurrent'
module Twterm
module PhotoViewerBackend
# @abstract
class AbstractPhotoViewerBackend
# @abstract
def view(_url)
raise NotImplementedError, '`view` method must be implemented'
end
private
def getc
system('stty raw -echo')
STDIN.getc
... |
github | ryota-ka/twterm | https://github.com/ryota-ka/twterm | lib/twterm/photo_viewer_backend/quick_look_backend.rb | Ruby | mit | 242 | master | 320 | require 'twterm/photo_viewer_backend/abstract_photo_viewer_backend'
module Twterm
module PhotoViewerBackend
class QuickLookBackend < AbstractPhotoViewerBackend
def view(url)
with_downloaded_file(url) do |file|
`qlmanage -p #{file.path} 2>/dev/null`
end
end
end
end
end |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | Gemfile | Ruby | mit | 242 | master | 318 | source "https://rubygems.org"
group :development do
# gem "bundler", "~> 1.1.5"
gem "jeweler", "~> 1.6.4"
# gem "rcov", ">= 0"
gem "reek", "~> 1.2.8"
gem "vcr"
gem "webmock"
gem "turn" # Better output for Test::Unit
end
gem "rest-client"
gem "activesupport"
gem "activemodel"
gem "json"
gem "test-unit" |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | parse_resource.gemspec | Ruby | mit | 242 | master | 5,592 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: parse_resource 1.8.0 ruby lib
Gem::Specification.new do |s|
s.name = "parse_resource"
s.version = "1.8.0"
s.required_rubygems_version = Gem::Requirement.ne... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | Rakefile | Ruby | mit | 242 | master | 1,569 | # encoding: utf-8
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | test/active_model_lint_test.rb | Ruby | mit | 242 | master | 366 | require 'helper'
require 'parse_resource'
ParseResource::Base.load!(ENV["PARSE_RESOURCE_APPLICATION_ID"], ENV["PARSE_RESOURCE_MASTER_KEY"])
class Bowl < ParseResource
fields :title, :body, :author
validates_presence_of :title
end
class ActiveModelLintTest < ActiveModel::TestCase
include ActiveModel::Lint::Tests... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | test/test_types.rb | Ruby | mit | 242 | master | 7,601 | require 'helper'
require 'parse_resource'
ParseResource::Base.load!(ENV["PARSE_RESOURCE_APPLICATION_ID"], ENV["PARSE_RESOURCE_MASTER_KEY"])
class Place < ParseResource::Base
fields :name, :location
end
class TestParseResource < Test::Unit::TestCase
def test_saving_geopoint_with_coords
VCR.use_cassette('test_... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | test/test_parse_user.rb | Ruby | mit | 242 | master | 1,489 | require 'helper'
require 'parse_resource'
ParseResource::Base.load!(ENV["PARSE_RESOURCE_APPLICATION_ID"], ENV["PARSE_RESOURCE_MASTER_KEY"])
class User < ParseUser
end
class TestParseUser < Test::Unit::TestCase
#def setup
# User.destroy_all
#end
#def teardown
# User.destroy_all
#end
# deprecate... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | test/test_relations_via_array.rb | Ruby | mit | 242 | master | 9,235 | require 'helper'
require 'parse_resource'
ParseResource::Base.load!(ENV["PARSE_RESOURCE_APPLICATION_ID"], ENV["PARSE_RESOURCE_MASTER_KEY"])
class Tip < ParseResource::Base
field :title
has_many :categories
end
class Category < ParseResource::Base
field :name
belongs_to :tip
end
class TestParseResource < Te... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | test/helper.rb | Ruby | mit | 242 | master | 1,743 | require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
begin
require 'turn/autorun';
# Turn.config.trace = 8
Turn.config.format = :outline
... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | test/test_query.rb | Ruby | mit | 242 | master | 520 | require 'helper'
require 'parse_resource'
class TestQuery < Test::Unit::TestCase
def test_respond_to
q = Query.new(self).where(:foo => "bar")
assert_equal q.respond_to?(:length), true
assert_equal q.respond_to?(:[]), true
assert_equal q.respond_to?(:map), true
end
def test_order_criteria
q ... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | test/test_parse_installation.rb | Ruby | mit | 242 | master | 1,283 | require 'helper'
require 'parse_resource'
ParseResource::Base.load!(ENV["PARSE_RESOURCE_APPLICATION_ID"], ENV["PARSE_RESOURCE_MASTER_KEY"])
class Installation < ParseResource::Base
end
class TestParseUser < Test::Unit::TestCase
#def setup
# User.destroy_all
#end
#def teardown
# User.destroy_all
#end
... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | test/test_parse_role.rb | Ruby | mit | 242 | master | 1,881 | require 'helper'
require 'parse_resource'
ParseResource::Base.load!(ENV["PARSE_RESOURCE_APPLICATION_ID"], ENV["PARSE_RESOURCE_MASTER_KEY"])
class Role < ParseRole
end
class TestParseRole < Test::Unit::TestCase
def test_role_creation
VCR.use_cassette('test_role_creation', :record => :new_episodes) do
R... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | test/test_relations.rb | Ruby | mit | 242 | master | 8,669 | require 'helper'
require 'parse_resource'
ParseResource::Base.load!(ENV["PARSE_RESOURCE_APPLICATION_ID"], ENV["PARSE_RESOURCE_MASTER_KEY"])
class Tip < ParseResource::Base
field :title
has_many :categories
end
class Category < ParseResource::Base
field :name
belongs_to :tip
end
class TestParseResource < Te... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | test/test_parse_resource.rb | Ruby | mit | 242 | master | 10,965 | require 'helper'
require 'parse_resource'
ParseResource::Base.load!(ENV["PARSE_RESOURCE_APPLICATION_ID"], ENV["PARSE_RESOURCE_MASTER_KEY"])
class Post < ParseResource::Base
fields :title, :body, :author
validates_presence_of :title
end
class Author < ParseResource::Base
field :name
end
class Spoon < ParseReso... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | test/test_query_options.rb | Ruby | mit | 242 | master | 343 | require 'helper'
require 'parse_resource'
ParseResource::Base.load!(ENV["PARSE_RESOURCE_APPLICATION_ID"], ENV["PARSE_RESOURCE_MASTER_KEY"])
class Event < ParseResource::Base
field :name
end
class TestQueryOptions < Test::Unit::TestCase
#def setup
# Event.destroy_all
#end
#def teardown
# Event.de... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | lib/parse_resource.rb | Ruby | mit | 242 | master | 342 | require 'parse_resource/base'
require 'parse_resource/query_methods'
require 'parse_resource/client'
require 'parse_resource/query'
require 'parse_resource/parse_role'
require 'parse_resource/parse_user'
require 'parse_resource/parse_user_validator'
require 'parse_resource/parse_error'
require 'kaminari_extension'
mod... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | lib/kaminari_extension.rb | Ruby | mit | 242 | master | 1,394 | if defined?(Kaminari)
module KaminariExtension
module ParseBaseExt
extend ActiveSupport::Concern
include Kaminari::ConfigurationMethods
module ClassMethods
def page(num)
Query.new(self).page(num)
end
end
end
module QueryExt
extend ActiveSupport::Co... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | lib/parse_resource/query.rb | Ruby | mit | 242 | master | 7,244 | class Query
def initialize(klass)
@klass = klass
end
def criteria
@criteria ||= { :conditions => {} }
end
def where(args)
criteria[:conditions].merge!(convert_arg(args))
self
end
def convert_arg(arg)
return arg.to_pointer if arg.is_a?(ParseResource::Base)
return ParseResource::... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | lib/parse_resource/parse_user_validator.rb | Ruby | mit | 242 | master | 221 | class ParseUserValidator < ActiveModel::Validator
def validate(record)
@user = User.where(:username => record.username)
if @user.length > 0
record.errors[:username] << "is already taken."
end
end
end |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | lib/parse_resource/parse_user.rb | Ruby | mit | 242 | master | 1,927 | require 'parse_resource/parse_user_validator'
class ParseUser < ParseResource::Base
fields :username, :password
def self.authenticate(username, password)
base_uri = "https://api.parse.com/1/login"
app_id = settings['app_id']
master_key = settings['master_key']
resource = RestClient::Resource... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | lib/parse_resource/query_methods.rb | Ruby | mit | 242 | master | 1,594 | #require 'parse_resource'
require 'parse_resource/query'
module ParseResource
module QueryMethods
module ClassMethods
# Include the attributes of a parent ojbect in the results
# Similar to ActiveRecord eager loading
#
def include_object(parent)
Query.new(self).include_object(parent)
... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | lib/parse_resource/base.rb | Ruby | mit | 242 | master | 21,905 | require "rubygems"
require "bundler/setup"
require "active_model"
require "erb"
require "rest-client"
require "json"
require "active_support/hash_with_indifferent_access"
require "parse_resource/query"
require "parse_resource/query_methods"
require "parse_resource/parse_error"
require "parse_resource/parse_exceptions"
... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | lib/parse_resource/parse_role.rb | Ruby | mit | 242 | master | 2,304 | class ParseRole < ParseResource::Base
fields :name, :users, :roles
def users
User.related_to(self, :users)
end
def access_control
get_attribute("ACL")
end
def self.create(attributes)
base_uri = "https://api.parse.com/1/roles"
app_id = settings['app_id']
master_key = settings['ma... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | lib/parse_resource/relation_array.rb | Ruby | mit | 242 | master | 1,532 | class RelationArray < Array
attr_accessor :delegate, :key, :class_name
def initialize(delegate, items, key, class_name)
super(items)
self.delegate = delegate
self.key = key
self.class_name = class_name
class_eval do
define_method("#{key}_ids") do
each.map { |item| item.id }
... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | lib/parse_resource/parse_error.rb | Ruby | mit | 242 | master | 1,501 | class ParseError
# ParseError actually represents both HTTP & parse.com error codes. If the
# HTTP response is 400, one can inspect the first element of the error
# converted to_array for the HTTP error code and the 2nd element for the
# parse error response.
attr_accessor :msg, :code, :error
# @param [S... |
github | adelevie/parse_resource | https://github.com/adelevie/parse_resource | lib/parse_resource/types/parse_geopoint.rb | Ruby | mit | 242 | master | 407 | class ParseGeoPoint
attr_accessor :latitude, :longitude
def initialize(hash=nil)
if hash.nil?
self.latitude=0.0
self.longitude=0.0
else
self.latitude = hash["latitude"] || hash[:latitude]
self.longitude = hash["longitude"] || hash[:longitude]
end
end
def to_pointer
{"_... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | Rakefile | Ruby | mit | 242 | master | 299 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"
require 'rubocop/rake_task'
RuboCop::RakeTask.new
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.warning = true
t.test_files = FileList['test/**/*_test.rb']
end
task :default => :test |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | argon2.gemspec | Ruby | mit | 242 | master | 1,442 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'argon2/version'
Gem::Specification.new do |spec|
spec.name = "argon2"
spec.version = Argon2::VERSION
spec.authors = ["Technion"]
spec.email = ["te... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | test/error_test.rb | Ruby | mit | 242 | master | 854 | # frozen_string_literal: true
require 'test_helper'
class Argon2ErrorTest < Minitest::Test
def test_ffi_fail
assert_raises Argon2::ArgonHashFail do
Argon2::Engine.hash_argon2i("password", "somesalt\0\0\0\0\0\0\0\0", 2, 1, 1)
end
end
def test_memory_too_small
assert_raises Argon2::ArgonHashFai... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | test/saltlen_test.rb | Ruby | mit | 242 | master | 700 | # frozen_string_literal: true
require 'test_helper'
class SaltlenTest < Minitest::Test
# Tests relevant to issue #14
def test_longsalt
# A test for verifying existing hashes with diffferent salt lengths
assert Argon2::Password.verify_password("password",
"$argon... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | test/key_test.rb | Ruby | mit | 242 | master | 629 | # frozen_string_literal: true
require 'test_helper'
class LowLevelArgon2Test < Minitest::Test
KEY = "a magic key"
PASS = "random password"
def test_key_hash
# Default hash
argon = Argon2::Password.new(t_cost: 2, m_cost: 16)
assert basehash = argon.create(PASS)
# Keyed hash
argon = Argon2::Pa... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | test/test_helper.rb | Ruby | mit | 242 | master | 459 | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'simplecov'
require 'simplecov-lcov'
SimpleCov::Formatter::LcovFormatter.config do |c|
c.report_with_single_file = true
c.output_directory = 'coverage/lvoc'
c.lcov_file_name = 'lcov.info'
c.single_report_path = 'cover... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | test/unicode_test.rb | Ruby | mit | 242 | master | 923 | # frozen_string_literal: true
require 'test_helper'
class UnicodeTest < Minitest::Test
def test_utf16
# A string found on Google which encodes with a NULL byte
unstr = "Σὲ γνωρίζω ἀπὸ τὴν κό".encode("utf-16le")
assert hash = Argon2::Password.create(unstr)
assert Argon2::Password.verify_password(unst... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | test/low_level_test.rb | Ruby | mit | 242 | master | 4,904 | # frozen_string_literal: true
require 'test_helper'
# Vectors in this suite taken from test.c in reference
class LowLevelArgon2Test < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::Argon2::VERSION
end
def test_ffi_vector
assert_equal Argon2::Engine.hash_argon2i(
"password", "s... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | test/legacy_test.rb | Ruby | mit | 242 | master | 725 | # frozen_string_literal: true
require 'test_helper'
PASS = "password"
class Legacy < Minitest::Test
HASH_1_1 = "$argon2i$v=19$m=65536,t=1,p=1$c29tZXNhbHQAAAAAAAAAAA$+r0d29hqEB0yasKr55ZgICsQGSkl0v0kgwhd+U3wyRo"
HASH_0 = "$argon2i$v=16$m=256,t=2,p=1$c29tZXNhbHQ$/U3YPXYsSb3q9XxHvc0MLxur+GP960kN9j7emXX8zwY"
def tes... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | test/rubycheck_test.rb | Ruby | mit | 242 | master | 996 | # frozen_string_literal: true
require 'test_helper'
TIMES = (ENV['TEST_CHECKS'] || 100).to_i
# This was supposed to use Rubycheck, however the current version doesn't run
# These property tests identified the NULL hash bug
class Argon2PropertyTest < Minitest::Test
def test_success
hashlist = {}
TIMES.times... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | test/hash_format_test.rb | Ruby | mit | 242 | master | 958 | # frozen_string_literal: true
require 'test_helper'
class Argon2HashFormatTest < Minitest::Test
PASSWORD = 'My secret password'
OPTIONS = {
t_cost: 4,
m_cost: 12,
p_cost: 3
}.freeze
TEMP = Argon2::Password.new(OPTIONS)
DIGEST = TEMP.create(PASSWORD)
def test_hash_format_variant
assert ar... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | test/api_test.rb | Ruby | mit | 242 | master | 1,396 | # frozen_string_literal: true
require 'test_helper'
module Argon2
# Simple stub to facilitate testing these variables
class Password
attr_accessor :t_cost, :m_cost, :p_cost, :secret
end
end
class Argon2APITest < Minitest::Test
def test_create_default
assert pass = Argon2::Password.new
assert_inst... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | test/engine_test.rb | Ruby | mit | 242 | master | 430 | # frozen_string_literal: true
require 'test_helper'
class EngineTest < Minitest::Test
def test_saltgen
generate = []
assert(10.times { generate << Argon2::Engine.saltgen })
duplicates = generate.select { |e| generate.count(e) > 1 }
assert_equal duplicates.length, 0
wrong_length = generate.reject... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | test/salt_reuse_test.rb | Ruby | mit | 242 | master | 447 | # frozen_string_literal: true
require 'test_helper'
class Argon2SaltReuseTest < Minitest::Test
def test_salt_reuse
assert temp = Argon2::Password.new
assert pass1 = temp.create('any password here 1')
assert pass2 = temp.create('any password here 2')
refute_equal pass1, pass2
assert salt1 = Arg... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | test/profiles_test.rb | Ruby | mit | 242 | master | 824 | # frozen_string_literal: true
require 'test_helper'
class ProfilesTest < Minitest::Test
def test_hash_access
assert_equal Argon2::Profiles::RFC_9106_LOW_MEMORY, Argon2::Profiles[:RFC_9106_LOW_MEMORY]
end
def test_to_a
# rubocop:disable Naming/VariableNumber
assert_equal %i[
pre_rfc_9106
... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | lib/argon2.rb | Ruby | mit | 242 | master | 2,231 | # frozen_string_literal: true
require 'argon2/constants'
require 'argon2/ffi_engine'
require 'argon2/version'
require 'argon2/errors'
require 'argon2/engine'
require 'argon2/hash_format'
require 'argon2/profiles'
module Argon2
# Front-end API for the Argon2 module.
class Password
# Expose constants for the op... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | lib/argon2/errors.rb | Ruby | mit | 242 | master | 1,179 | # frozen_string_literal: true
# Defines an array of errors that matches the enum list of errors from
# argon2.h. This allows return values to propagate errors through the FFI.
module Argon2
class ArgonHashFail < StandardError; end
ERRORS = %w[
ARGON2_OK
ARGON2_OUTPUT_PTR_NULL
ARGON2_OUTPUT_TOO_SHORT
... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | lib/argon2/hash_format.rb | Ruby | mit | 242 | master | 1,609 | # frozen_string_literal: true
module Argon2
##
# Get the values from an Argon2 compatible string.
#
class HashFormat
attr_reader :variant, :version, :t_cost, :m_cost, :p_cost, :salt, :checksum
# FIXME: Reduce complexity/AbcSize
# rubocop:disable Metrics/AbcSize
def initialize(digest)
dig... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | lib/argon2/profiles.rb | Ruby | mit | 242 | master | 1,128 | # frozen_string_literal: true
module Argon2
# Contains named profiles of different common cost parameter sets
class Profiles
def self.[](name)
name = name.upcase.to_sym
raise NotImplementedError unless const_defined?(name)
const_get(name)
end
def self.to_a
constants.map(&:down... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | lib/argon2/engine.rb | Ruby | mit | 242 | master | 241 | # frozen_string_literal: true
require 'securerandom'
module Argon2
# Generates a random, binary string for use as a salt.
class Engine
def self.saltgen
SecureRandom.random_bytes(Argon2::Constants::SALT_LEN)
end
end
end |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | lib/argon2/ffi_engine.rb | Ruby | mit | 242 | master | 4,156 | # frozen_string_literal: true
require 'ffi'
require 'ffi-compiler/loader'
module Argon2
# Direct external bindings. Call these methods via the Engine class to ensure points are dealt with
module Ext
extend FFI::Library
ffi_lib FFI::Compiler::Loader.find(FFI::Platform.windows? ? 'libargon2_wrap' : 'argon2_... |
github | technion/ruby-argon2 | https://github.com/technion/ruby-argon2 | lib/argon2/constants.rb | Ruby | mit | 242 | master | 300 | # frozen_string_literal: true
module Argon2
# Constants utilised in several parts of the Argon2 module
# SALT_LEN is a standard recommendation from the Argon2 spec.
module Constants
SALT_LEN = 16
OUT_LEN = 32 # Binary, unencoded output
ENCODE_LEN = 108 # Encoded output
end
end |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | papercraft.gemspec | Ruby | mit | 242 | master | 1,409 | require_relative './lib/papercraft/version'
Gem::Specification.new do |s|
s.name = 'papercraft'
s.version = Papercraft::VERSION
s.licenses = ['MIT']
s.summary = 'Papercraft: functional HTML templating for Ruby'
s.author = 'Sharon Rosner'
s.email = 'sharon@noteflakes.com'
s.fi... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | Rakefile | Ruby | mit | 242 | master | 384 | # frozen_string_literal: true
task :default => :test
task :test do
exec 'ruby test/run.rb'
end
task :release do
require_relative './lib/papercraft/version'
version = Papercraft::VERSION
puts 'Building papercraft...'
`gem build papercraft.gemspec`
puts "Pushing papercraft #{version}..."
`gem push paper... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | lib/papercraft.rb | Ruby | mit | 242 | master | 8,708 | # frozen_string_literal: true
require_relative 'papercraft/template'
require_relative 'papercraft/compiler'
require_relative 'papercraft/proc_ext'
# Papercraft is a functional templating library. In Papercraft, templates are expressed as plain
# Ruby procs.
module Papercraft
# Exception class used to signal templat... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | lib/tilt/papercraft.rb | Ruby | mit | 242 | master | 1,265 | # frozen_string_literal: true
require 'papercraft'
require 'tilt'
require 'digest/sha1'
# Tilt.
module Tilt
# Papercraft templating engine for Tilt
class PapercraftTemplate < Template
module SiropExtension
# We override the Sirop get source in order to have access to the template
# source code whe... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | lib/papercraft/proc_ext.rb | Ruby | mit | 242 | master | 1,121 | # frozen_string_literal: true
require_relative './compiler'
module Papercraft
# Extensions to the Proc class.
module ProcExtensions
# Returns true if proc is marked as compiled.
#
# @return [bool] is the proc marked as compiled
def __papercraft_compiled?
@__papercraft_compiled
end
#... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | lib/papercraft/compiler.rb | Ruby | mit | 242 | master | 24,114 | # frozen_string_literal: true
require 'sirop'
require 'erb/escape'
require_relative './compiler/nodes'
require_relative './compiler/tag_translator'
module Papercraft
# A Compiler converts a template into an optimized form that generates HTML
# efficiently.
class Compiler < Sirop::Sourcifier
@@html_debug_at... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | lib/papercraft/template.rb | Ruby | mit | 242 | master | 1,160 | # frozen_string_literal: true
module Papercraft
# Template wrapper class. This class can be used to distinguish between Papercraft
# templates and other kinds of procs.
class Template
attr_reader :proc, :mode
# @param proc [Proc] template proc
# @param mode [Symbol] mode (:html, :xml)
def initia... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | lib/papercraft/proc.rb | Ruby | mit | 242 | master | 478 | # frozen_string_literal: true
require_relative '../papercraft'
module Papercraft
module ProcAPI
def ast
Papercraft.ast(self)
end
def compiled_code
Papercraft.compiled_code(self)
end
def to_html(*, **, &)
Papercraft.html(self, *, **, &)
end
def to_xml(*, **, &)
... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | lib/papercraft/compiler/tag_translator.rb | Ruby | mit | 242 | master | 2,337 | # frozen_string_literal: true
require 'prism'
require_relative './nodes'
module Papercraft
# Translates a normal proc AST into an AST containing custom nodes used for
# generating HTML. This translation is the first step in compiling templates
# into procs that generate HTML.
class TagTranslator < Prism::Muta... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | lib/papercraft/compiler/nodes.rb | Ruby | mit | 242 | master | 5,686 | # frozen_string_literal: true
class Prism::InspectVisitor
def visit_tag_node(node)
commands << [inspect_node("TagNode", node), indent]
# flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
# commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", ind... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | examples/app.rb | Ruby | mit | 242 | master | 536 | require 'bundler/setup'
require 'papercraft'
App = ->(**props) {
html5 {
body {
emit(Header, title: props[:title]) {
button "1"
button "2"
}
emit Content, **props
}
}
}
Header = ->(title:) {
header {
h2(title, id: 'title')
render_yield
}
}
Content = ->(title:... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | examples/gen2.rb | Ruby | mit | 242 | master | 1,316 | # frozen_string_literal: true
require 'erb'
require 'benchmark/ips'
def erubi(title:)
_buf = +'';;
_buf <<
'<article><h3>' <<
( ERB::Escape.html_escape(title) ).to_s <<
'</h3><p>Hello, world!</p><div><a href="' <<
( 'http://google.com/?a=1&b=2&c=3%204' ).to_s <<
'"><h3>foo bar</h3></a><p>lorem... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | examples/perf_code_gen.rb | Ruby | mit | 242 | master | 12,175 | # frozen_string_literal: true
require 'bundler/inline'
gemfile do
gem 'papercraft', path: '.'
gem 'benchmark-ips', '>= 2.14.0'
end
require 'papercraft'
require 'erb'
require 'benchmark/ips'
class PapercraftBaseline
App = ->(title:) {
html5 {
body {
render(Header, title: title) {
bu... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | examples/composition.rb | Ruby | mit | 242 | master | 540 | require 'bundler/setup'
require 'papercraft'
Title = ->(title) { h1 title }
Item = ->(id:, text:, checked:) {
li {
input name: id, type: 'checkbox', checked: checked
label text, for: id
}
}
ItemList = ->(items) {
ul {
items.each { |i|
Item(**i)
}
}
}
page = ->(title, items) {
html5 {... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | examples/dashboard.rb | Ruby | mit | 242 | master | 10,978 | # frozen_string_literal: true
require 'bundler/setup'
require 'papercraft'
require 'benchmark/ips'
require 'json'
# The following is an example of a dashboard-type SPA app, extracted from an
# actual working app. This example demonstrates the usage of template
# composition, which allows putting separate parts of th... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | examples/simple.rb | Ruby | mit | 242 | master | 254 | require 'bundler/setup'
require 'papercraft'
t = ->(title:) {
html {
body {
h1 title
}
}
}
p Papercraft.ast(t)
puts
puts Papercraft.compiled_code(t)
puts
p Papercraft.source_map(t)
puts
puts Papercraft.html(t, title: 'Hello, world!') |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | examples/perf.rb | Ruby | mit | 242 | master | 3,340 | # frozen_string_literal: true
require 'bundler/inline'
gemfile do
gem 'papercraft', path: '.'
gem 'benchmark'
gem 'benchmark-ips'
gem 'phlex'
end
require 'papercraft'
require 'erb'
require 'benchmark/ips'
require 'cgi'
require 'phlex'
App = ->(title:) {
html5 {
body {
render(Header, title: title... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | test/test_tilt.rb | Ruby | mit | 242 | master | 1,515 | # frozen_string_literal: true
require_relative './helper'
require 'tilt/papercraft'
class TiltIntegrationTest < Minitest::Test
def test_extension
assert_equal Tilt::PapercraftTemplate, Tilt['papercraft']
end
def test_tilt_inline_template
t = Tilt['papercraft'].new {
"
h1 'foo'
p '... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | test/test_papercraft.rb | Ruby | mit | 242 | master | 4,613 | # frozen_string_literal: true
require_relative './helper'
class PapercraftRenderTest < Minitest::Test
def test_papercraft_html_with_block
html = Papercraft.html {
h1 "foo"
}
assert_equal '<h1>foo</h1>', html
end
def test_papercraft_html_with_template
t = -> {
h1 "foo"
}
html... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | test/test_xml.rb | Ruby | mit | 242 | master | 2,765 | # frozen_string_literal: true
require_relative './helper'
require 'time'
class HtmlTest < Minitest::Test
def test_xml_for_html_void_elements
t = -> {
link 'foo'
}
assert_equal "<link>foo</link>", Papercraft.xml(t)
end
def test_xml_self_closing_tag
t = -> {
foo
}
assert_equal... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | test/test_html.rb | Ruby | mit | 242 | master | 10,000 | # frozen_string_literal: true
require_relative './helper'
class HtmlTest < Minitest::Test
def test_void_elements
h = -> {
hr
input value: 'foo'
br
text 'hi'
hr
}
assert_equal '<hr><input value="foo"><br>hi<hr>', Papercraft.html(h)
end
def test_error_on_void_elements_wi... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | test/test_proc.rb | Ruby | mit | 242 | master | 745 | # frozen_string_literal: true
require_relative './helper'
require 'papercraft/proc'
class ProcAPITest < Minitest::Test
def test_proc_ast
t = -> { h1 'foo' }
assert_kind_of Prism::Node, t.ast
assert_equal Papercraft.ast(t).inspect, t.ast.inspect
end
def test_proc_compiled_code
t = -> { h1 'foo' ... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | test/test_template.rb | Ruby | mit | 242 | master | 21,388 | # frozen_string_literal: true
require_relative './helper'
class ParametersTest < Minitest::Test
def test_empty_template
t = -> { }
assert_equal '', Papercraft.html(t)
t = ->(foo) { }
assert_raises(ArgumentError) { Papercraft.html(t) }
assert_equal '', Papercraft.html(t, 1)
end
def test_sim... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | test/test_markdown.rb | Ruby | mit | 242 | master | 1,770 | # frozen_string_literal: true
require_relative './helper'
class MarkdownTest < Minitest::Test
def test_basic_markdown
templ = ->(md) { body { markdown(md) } }
assert_equal "<body><h1 id=\"hi\">hi</h1>\n</body>",
Papercraft.html(templ, '# hi')
assert_equal "<body><p>Hello, <em>emphasis</em>.</p>\n... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | test/test_compiler.rb | Ruby | mit | 242 | master | 855 | # frozen_string_literal: true
require_relative './helper'
require_relative '../lib/papercraft/compiler'
class CompilerTest < Minitest::Test
Dir["#{FIXTURES_PATH}/compiler/*_source.rb"].each do |fn|
basename = File.basename(fn)
test_name = basename.match(/^(.+)_source\.rb$/)[1]
html_fn = File.join(FIXTUR... |
github | digital-fabric/papercraft | https://github.com/digital-fabric/papercraft | test/helper.rb | Ruby | mit | 242 | master | 281 | # frozen_string_literal: true
require 'bundler/setup'
require 'minitest/autorun'
require 'papercraft'
FIXTURES_PATH = File.join(__dir__, 'fixtures')
module Kernel
def load_code(name)
fn = File.join(EXAMPLES_PATH, "#{name}.rb")
eval(IO.read(fn), binding, fn)
end
end |
github | YusukeIwaki/capybara-playwright-driver | https://github.com/YusukeIwaki/capybara-playwright-driver | Gemfile | Ruby | mit | 243 | main | 438 | # frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
# Specify your gem's dependencies in capybara-playwright.gemspec
gemspec
gem 'allure-rspec'
gem 'bundler'
gem 'launchy', '>= 2.0.4'
gem 'pry-byebug'
gem 'rack-test_server'
gem 'rake', '~... |
github | YusukeIwaki/capybara-playwright-driver | https://github.com/YusukeIwaki/capybara-playwright-driver | capybara-playwright.gemspec | Ruby | mit | 243 | main | 962 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'capybara/playwright/version'
Gem::Specification.new do |spec|
spec.name = 'capybara-playwright-driver'
spec.version = Capybara::Playwright::VERSION
spec.authors ... |
github | YusukeIwaki/capybara-playwright-driver | https://github.com/YusukeIwaki/capybara-playwright-driver | spec/spec_helper.rb | Ruby | mit | 243 | main | 2,389 | # frozen_string_literal: true
require 'bundler/setup'
require 'allure-rspec'
require 'capybara/playwright'
require 'capybara/rspec'
require 'rack/test_server'
require 'sinatra/base'
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = '.r... |
github | YusukeIwaki/capybara-playwright-driver | https://github.com/YusukeIwaki/capybara-playwright-driver | spec/feature/stale_element_spec.rb | Ruby | mit | 243 | main | 1,626 | require 'spec_helper'
RSpec.describe 'stale element handling' do
before do
visit 'about:blank'
page.driver.with_playwright_page do |page|
page.content = <<~HTML
<div id="myid"></div>
HTML
end
end
def rerender_element
page.evaluate_script(<<~JAVASCRIPT)
(() => {
... |
github | YusukeIwaki/capybara-playwright-driver | https://github.com/YusukeIwaki/capybara-playwright-driver | spec/feature/tracing_spec.rb | Ruby | mit | 243 | main | 1,306 | require 'spec_helper'
RSpec.describe 'tracing', sinatra: true do
TRACES_DIR = 'tmp/capybara/playwright'.freeze
before do
FileUtils.rm_rf(TRACES_DIR)
sinatra.get '/' do
<<~HTML
<!DOCTYPE html>
<button>Go</button>
HTML
end
end
it 'can start and stop tracing' do
page... |
github | YusukeIwaki/capybara-playwright-driver | https://github.com/YusukeIwaki/capybara-playwright-driver | spec/feature/attach_file_spec.rb | Ruby | mit | 243 | main | 468 | require 'spec_helper'
RSpec.describe 'attach file' do
before do
visit 'about:blank'
page.driver.with_playwright_page do |page|
page.content = '<input type="file" />'
end
end
it 'should accept String' do
find('input').set(File.join('./', 'Gemfile'))
end
it 'should accept File' do
f... |
github | YusukeIwaki/capybara-playwright-driver | https://github.com/YusukeIwaki/capybara-playwright-driver | spec/feature/assertion_spec.rb | Ruby | mit | 243 | main | 1,437 | require 'spec_helper'
RSpec.describe 'assertion', sinatra: true do
before do
sinatra.get '/' do
<<~HTML
<!DOCTYPE html>
<h1>click the go button</h1>
<script>
function go (btn) {
btn.disabled = true
btn.innerText = 'please wait...'
setTimeout(() => {
... |
github | YusukeIwaki/capybara-playwright-driver | https://github.com/YusukeIwaki/capybara-playwright-driver | spec/feature/window_close_spec.rb | Ruby | mit | 243 | main | 722 | require 'spec_helper'
RSpec.describe 'closing a non-current window', sinatra: true do
before do
sinatra.get '/' do
'<h1>Main Page</h1>'
end
sinatra.get '/other' do
'<h1>Other Page</h1>'
end
end
it 'keeps the current page accessible after closing a different window' do
visit '/'
... |
github | YusukeIwaki/capybara-playwright-driver | https://github.com/YusukeIwaki/capybara-playwright-driver | spec/feature/status_code_race_spec.rb | Ruby | mit | 243 | main | 1,046 | require 'spec_helper'
module ResponseCallbackDelayPatch
class << self
attr_accessor :enabled
end
self.enabled = false
def perform_event_emitter_callback(event, callback, args)
if ResponseCallbackDelayPatch.enabled && event == Playwright::Events::Page::Response
# Delay only response callback asyn... |
github | YusukeIwaki/capybara-playwright-driver | https://github.com/YusukeIwaki/capybara-playwright-driver | spec/feature/example_spec.rb | Ruby | mit | 243 | main | 3,750 | require 'spec_helper'
require 'tmpdir'
RSpec.describe 'Example' do
around do |example|
previous_wait_time = Capybara.default_max_wait_time
Capybara.default_max_wait_time = 15
example.run
Capybara.default_max_wait_time = previous_wait_time
end
if ENV['CI']
before do |example|
Capybara.c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.