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
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/password_validator.rb
Ruby
mit
301
master
648
module ActiveModel module Validations class PasswordValidator < EachValidator REGEXES = { :weak => /(?=.{6,}).*/, # 6 characters :medium => /^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$/, #len=7 chars and numbers :strong => /^.*(?=.{8,})...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/sin_validator.rb
Ruby
mit
301
master
2,874
require 'active_validators/active_model/validations/shared/luhn_checker' module ActiveModel module Validations class SinValidator < EachValidator def validate_each(record, attribute, value) country = options.fetch(:country, :canada) # :canada is defa...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/postal_code_validator.rb
Ruby
mit
301
master
3,038
module ActiveModel module Validations class PostalCodeValidator < EachValidator def validate_each(record, attribute, value) @value = value.to_s unless country = options[:country] if country_method = options[:country_method] country = record.send(country_method) ...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/email_validator.rb
Ruby
mit
301
master
1,659
require 'mail' old_w, $-w = $-w, false require 'mail/elements/address' $-w = old_w module ActiveModel module Validations class EmailValidator < EachValidator def check_validity! raise ArgumentError, "Not a callable object #{options[:with].inspect}" unless options[:with] == nil || options[:with].re...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/twitter_validator.rb
Ruby
mit
301
master
1,160
module ActiveModel module Validations class TwitterValidator < EachValidator # Basic username regexp TWITTER_USERNAME_REGEXP = /([A-Za-z0-9_]{1,15})/i # Regexp used to detect twitter username within the URL. TWITTER_URL_REGEXP = %r{\Ahttps?://(?:www\.)?twitter.com/#{TWITTER_USERNAME_REG...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/phone_validator.rb
Ruby
mit
301
master
899
require 'phony' require 'countries' module ActiveModel module Validations class PhoneValidator < EachValidator def validate_each(record, attribute, value) plausible = case (country = options[:country]) when ->(s) { s.blank? } # Without a country, try to figu...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/nino_validator.rb
Ruby
mit
301
master
2,342
module ActiveModel module Validations class NinoValidator < EachValidator def validate_each(record, attribute, value) record.errors.add(attribute) if value.blank? || !NinoValidatorUK.new(value).valid? end end # The National Insurance number is a number used in the United Kingdom. ...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/siren_validator.rb
Ruby
mit
301
master
874
module ActiveModel module Validations class SirenValidator < EachValidator # Validates siren format according to # http://fr.wikipedia.org/wiki/SIREN def valid_siren?(input) str = input.to_s reversed_array = str.split('').reverse digits = reversed_array.each_with_index.m...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/respond_to_validator.rb
Ruby
mit
301
master
438
module ActiveModel module Validations class RespondToValidator < EachValidator RESERVED_OPTIONS = [:if, :unless] def validate_each(record,attribute,value) responders = options.dup RESERVED_OPTIONS.each do |opt,should_apply| responders.delete(opt) end responders.each do |method,...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/url_validator.rb
Ruby
mit
301
master
3,227
require 'active_support/core_ext/array/wrap' require 'uri' module ActiveModel module Validations # Public: Uses `URI.regexp` to validate URLs, by default only allows # the http and https protocols. # # Examples # # validates :url, :url => true # # => only allow http, https # ...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/regexp_validator.rb
Ruby
mit
301
master
393
module ActiveModel module Validations class RegexpValidator < EachValidator def validate_each(record, attribute, value) unless valid_regexp?(value) record.errors.add(attribute) end end private def valid_regexp?(value) Regexp.compile(value.to_s) ...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/slug_validator.rb
Ruby
mit
301
master
320
module ActiveModel module Validations class SlugValidator < EachValidator def validate_each(record, attribute, value) if value.nil? record.errors.add(attribute, :blank) elsif value != value.parameterize record.errors.add(attribute) end end end end end
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/ssn_validator.rb
Ruby
mit
301
master
1,730
module ActiveModel module Validations class SsnValidator < EachValidator def validate_each(record, attribute, value) record.errors.add(attribute) if value.blank? || !SsnValidatorGeneral.valid?(options, value) end end # <b>DEPRECATED:</b> Please use <tt>:ssn => true</tt> instead. c...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
lib/active_validators/active_model/validations/shared/luhn_checker.rb
Ruby
mit
301
master
406
module LuhnChecker # This method implements Luhn algorythm. # Details about it's work may be founded here: http://en.wikipedia.org/wiki/Luhn_Algorithm def self.valid?(s) value = s.gsub(/\D/, '').reverse sum = i = 0 value.each_char do |ch| n = ch.to_i n *= 2 if i.odd? n = 1 + (n -...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/test_helper.rb
Ruby
mit
301
master
655
gem 'minitest' require 'minitest/autorun' require 'minitest/mock' old_w, $-w = $-w, false require 'active_support/test_case' $-w = old_w require 'activevalidators' class TestRecord include ActiveModel::Validations attr_accessor :ip, :url, :slug, :responder, :global_condition, :local_condition, :phone, :email, ...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/slug_test.rb
Ruby
mit
301
master
1,235
require 'test_helper' ActiveValidators.activate(:slug) describe "Slug Validation" do def build_slug_validation attrs = {} TestRecord.reset_callbacks(:validate) TestRecord.validates :slug, :slug => true TestRecord.new attrs end it "accepts valid slugs" do subject = build_slug_validation subje...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/hex_color_test.rb
Ruby
mit
301
master
1,293
require 'test_helper' ActiveValidators.activate(:hex_color) describe "Hex-Color Validation" do let(:invalid_message) { subject.errors.generate_message(:text_color, :invalid) } subject { TestRecord.new } before do TestRecord.reset_callbacks(:validate) TestRecord.validates :text_color, :hex_color => true...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/barcode_test.rb
Ruby
mit
301
master
2,112
require 'test_helper' ActiveValidators.activate(:barcode) describe "Barcode Validation" do describe "EAN13 Validation" do it "accepts valid EAN13s" do ["9782940199617", "9782940199600"].each do |barcode| subject = build_barcode_record :ean13, :barcode => barcode _(subject.valid?).must_equal...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/date_test.rb
Ruby
mit
301
master
739
require 'test_helper' require 'active_support/core_ext/hash/reverse_merge' ActiveValidators.activate(:date) # ActiveValidators relies on another gem called "date_validator" edited # by the fine folks at Codegram. # # If you wanna see tests for this gem, go take a look at the repository # [on Github](https://github.com...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/respond_to_test.rb
Ruby
mit
301
master
1,209
require 'test_helper' ActiveValidators.activate(:respond_to) describe "Respond To Validation" do def build_respond_to_record attrs = {} TestRecord.reset_callbacks(:validate) TestRecord.validates :responder, :respond_to => { :call => true, :if => :local_condition }, :if => :global_condition TestRecord.new...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/password_test.rb
Ruby
mit
301
master
1,540
require 'test_helper' ActiveValidators.activate(:password) describe "Password Validation" do STRENGTHS = { :weak => { :valid => 'sixchr', :invalid => 'foo' }, :medium => { :valid => 'chrs123', :invalid => 'sixchr' }, :strong => { :valid => 'HQSij2323#$%', :invalid => 'chrs123' } } STRENGTHS.eac...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/ssn_test.rb
Ruby
mit
301
master
2,356
require 'test_helper' ActiveValidators.activate(:ssn) describe "SSN validations" do describe "USA ssn" do describe "for invalid" do it "rejects empty ssn" do subject = build_ssn_record({:ssn => ''}, true) _(subject.valid?).must_equal(false) end it "rejects ssn when it doesn't c...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/regexp_test.rb
Ruby
mit
301
master
832
require 'test_helper' ActiveValidators.activate(:regexp) describe "Regexp Validation" do let(:invalid_message) { subject.errors.generate_message(:redirect_rule, :invalid) } subject { TestRecord.new } before do TestRecord.reset_callbacks(:validate) TestRecord.validates :redirect_rule, :regexp => true ...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/siren_test.rb
Ruby
mit
301
master
1,635
require 'test_helper' ActiveValidators.activate(:siren) describe "Siren Validation" do it "Rejects if not supplied" do subject = build_siren_record true _(subject.valid?).must_equal(false) _(subject.errors.size).must_equal(1) end describe 'supplied as a string' do it "Accepts if valid" do ...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/ip_test.rb
Ruby
mit
301
master
2,389
require 'test_helper' require 'ipaddr' ActiveValidators.activate(:ip) describe "IP Validation" do describe "IPv4 Validation" do it "accepts valid IPs" do subject = build_ip_record :v4, :ip => '192.168.1.1' _(subject.valid?).must_equal(true) _(subject.errors.size).must_equal(0) end it "...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/postal_code_test.rb
Ruby
mit
301
master
3,365
require 'test_helper' ActiveValidators.activate(:postal_code) describe "Postal Code Validation" do def build_postal_code_record postal_code, attrs = {} TestRecord.reset_callbacks(:validate) TestRecord.validates :postal_code, :postal_code => postal_code TestRecord.new attrs end describe "when no coun...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/url_test.rb
Ruby
mit
301
master
3,898
require 'test_helper' ActiveValidators.activate(:url) describe "Url Validation" do def build_url_record TestRecord.reset_callbacks(:validate) TestRecord.validates :url, :url => true TestRecord.new end def build_url_record_require_tld TestRecord.reset_callbacks(:validate) TestRecord.validates...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/twitter_test.rb
Ruby
mit
301
master
6,327
# coding: utf-8 require 'test_helper' ActiveValidators.activate(:twitter) describe "Twitter Validation" do def build_twitter_record format, attrs = {} TestRecord.reset_callbacks(:validate) TestRecord.validates :twitter_username, :twitter => format TestRecord.new attrs end it "rejects invalid urls" d...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/nino_test.rb
Ruby
mit
301
master
3,513
require 'test_helper' ActiveValidators.activate(:nino) describe "NINO validations" do describe "for UK" do describe "for invalid" do it "rejects empty nino" do subject = build_nino_record({:nino => ''}) _(subject.valid?).must_equal(false) end it "rejects nino, which has invalid...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/tracking_number_test.rb
Ruby
mit
301
master
6,053
require 'test_helper' ActiveValidators.activate(:tracking_number) describe "Tracking Number Validation" do def build_tracking_number_record carrier_opts, attrs = {} TestRecord.reset_callbacks(:validate) TestRecord.validates :tracking_number, :tracking_number => carrier_opts TestRecord.new(attrs).tap do |...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/phone_test.rb
Ruby
mit
301
master
2,485
require 'test_helper' ActiveValidators.activate(:phone) describe "Phone Validation" do def build_phone_validation phone, attrs = {} TestRecord.reset_callbacks(:validate) TestRecord.validates :phone, :phone => phone TestRecord.new attrs end describe "when a country is given" do it "allows numbers...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/email_test.rb
Ruby
mit
301
master
4,482
require 'test_helper' ActiveValidators.activate(:email) describe "Email Validation" do describe "strict: true" do it "accepts valid emails" do subject = build_email_record({:email => 'franck@verrot.fr'}, {:strict => true}) _(subject.valid?).must_equal(true) _(subject.errors.size).must_equal(0)...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/credit_card_test.rb
Ruby
mit
301
master
2,784
require 'test_helper' ActiveValidators.activate(:credit_card) describe "Credit Card Validation" do # Here are some valid credit cards VALID_CARDS = { #American Express :amex => '3400 0000 0000 009', #Discover :discover => '6011 0000 0000 0004', #Diners Club ...
github
franckverrot/activevalidators
https://github.com/franckverrot/activevalidators
test/validations/sin_test.rb
Ruby
mit
301
master
2,811
require 'test_helper' ActiveValidators.activate(:sin) describe "SIN validations" do describe "for Canada" do describe "for invalid" do it "rejects empty sin" do subject = build_sin_record({:sin => ''}) _(subject.valid?).must_equal(false) end it "rejects sin made out of zeroes" ...
github
TannerRogalsky/sprockets-es6
https://github.com/TannerRogalsky/sprockets-es6
sprockets-es6.gemspec
Ruby
mit
301
master
820
$:.unshift File.expand_path("../lib", __FILE__) require 'sprockets/es6/version' Gem::Specification.new do |s| s.name = 'sprockets-es6' s.version = Sprockets::ES6::VERSION s.homepage = "https://github.com/TannerRogalsky/sprockets-es6" s.summary = "Sprockets ES6 transformer" s.description = <<-EOS ...
github
TannerRogalsky/sprockets-es6
https://github.com/TannerRogalsky/sprockets-es6
test/test_es6.rb
Ruby
mit
301
master
4,986
require 'minitest/autorun' require 'sprockets' require 'sprockets/es6' class TestES6 < MiniTest::Test def setup @env = Sprockets::Environment.new @env.append_path File.expand_path("../fixtures", __FILE__) end def test_require_asset assert asset = @env["require_asset"] assert_equal 'application/j...
github
TannerRogalsky/sprockets-es6
https://github.com/TannerRogalsky/sprockets-es6
lib/sprockets/es6.rb
Ruby
mit
301
master
2,451
require 'babel/transpiler' require 'sprockets' require 'sprockets/es6/version' require 'ostruct' module Sprockets class ES6 class << self attr_accessor :configuration def configuration_hash configuration.to_h.reduce({}) do |hash, (key, val)| hash[key.to_s] = val hash ...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
Gemfile
Ruby
mit
301
master
799
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } # Declare your gem's dependencies in view_component_reflex.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec ...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
Rakefile
Ruby
mit
301
master
692
begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end require 'rdoc/task' RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'ViewComponentReflex' rdoc.options << '--line-numbers' rdoc.rdoc_files.include('README....
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
view_component_reflex.gemspec
Ruby
mit
301
master
1,310
$:.push File.expand_path("lib", __dir__) # Maintain your gem's version: require "view_component_reflex/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |spec| spec.name = "view_component_reflex" spec.version = ViewComponentReflex::VERSION spec.authors = ["Joshu...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
test/test_helper.rb
Ruby
mit
301
master
858
# Configure Rails Environment ENV["RAILS_ENV"] = "test" require_relative "../test/dummy/config/environment" ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] ActiveRecord::Migrator.migrations_paths << File.expand_path('../db/migrate', __dir__) require "rails/test_help" ...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
test/dummy/test/components/component_component_test.rb
Ruby
mit
301
master
955
require_relative "../../../test_helper" class ComponentComponentTest < ViewComponent::TestCase def test_memory_adapter ViewComponentReflex::Engine.configure do |config| config.state_adapter = ViewComponentReflex::StateAdapter::Memory end assert_component end def test_session_adapter ViewC...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
test/dummy/config/application.rb
Ruby
mit
301
master
575
require_relative 'boot' require 'rails/all' Bundler.require(*Rails.groups) require "view_component_reflex" module Dummy class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.2 # Settings in config/environments/* take p...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
lib/view_component_reflex.rb
Ruby
mit
301
master
643
require "stimulus_reflex" require "active_support/dependencies/autoload" require "view_component_reflex/state_adapter/base" require "view_component_reflex/state_adapter/session" require "view_component_reflex/state_adapter/memory" require "view_component_reflex/state_adapter/dom" require "view_component_reflex/state_ad...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
lib/view_component_reflex/engine.rb
Ruby
mit
301
master
1,314
module ViewComponentReflex class Engine < ::Rails::Engine mattr_accessor :state_adapter Engine.state_adapter = StateAdapter::Session config.to_prepare do StimulusReflex::Channel.class_eval do unless instance_methods.include?(:receive_original) alias_method :receive_original, :rec...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
lib/view_component_reflex/reflex_factory.rb
Ruby
mit
301
master
2,524
module ViewComponentReflex class ReflexFactory def initialize(component) @component = component @new = false reflex.component_class = component end def nested? @nested ||= @component.name.include?("::") end def reflex_name @reflex_name ||= if nested? @compon...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
lib/view_component_reflex/component.rb
Ruby
mit
301
master
8,249
module ViewComponentReflex class Component < ViewComponent::Base class_attribute :reflex_base_class, default: ViewComponentReflex::Reflex attr_reader :key class << self attr_reader :_state_adapter def init_stimulus_reflex factory = ViewComponentReflex::ReflexFactory.new(self) ...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
lib/view_component_reflex/reflex.rb
Ruby
mit
301
master
5,114
module ViewComponentReflex class Reflex < StimulusReflex::Reflex class << self attr_accessor :component_class end # pretty sure I can't memoize this because we need # to re-render every time def controller_document controller.process(params[:action]) Nokogiri::HTML(controller.re...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
lib/view_component_reflex/state_adapter/redis.rb
Ruby
mit
301
master
2,202
# A redis based adapter for component_reflex # # ViewComponentReflex::Engine.configure do |config| # config.state_adapter = ViewComponentReflex::StateAdapter::Redis.new( # redis_opts: { # url: "redis://localhost:6379/1", driver: :hiredis # }, # ttl: 3600) # end module ViewComponentReflex ...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
lib/view_component_reflex/state_adapter/base.rb
Ruby
mit
301
master
703
module ViewComponentReflex module StateAdapter class Base def self.state(request, key) # stub end def self.set_state(request, controller, key, new_state) # stub end def self.store_state(request, key, new_state = {}) # stub end def self.wrap_wri...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
lib/view_component_reflex/state_adapter/memory.rb
Ruby
mit
301
master
845
VIEW_COMPONENT_REFLEX_MEMORY_STATE = {} module ViewComponentReflex module StateAdapter class Memory < Base def self.state(request, key) id = extract_id(request) VIEW_COMPONENT_REFLEX_MEMORY_STATE[id] ||= {} VIEW_COMPONENT_REFLEX_MEMORY_STATE[id][key] ||= {} end def self...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
lib/view_component_reflex/state_adapter/dom.rb
Ruby
mit
301
master
1,564
## # This adapter exists solely to allow switching to dom-based state storage, even # though dom-based state storage doesn't abide by the same standards as the other adapters # # The dom-based state storage is handled by the Dom::Component and Dom::Reflex modules that are prepended # to Component and Reflex in Engine, ...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
lib/view_component_reflex/state_adapter/session.rb
Ruby
mit
301
master
689
module ViewComponentReflex module StateAdapter class Session < Base def self.state(request, key) request.session[key] ||= {} end def self.set_state(request, controller, key, new_state) new_state.each do |k, v| state(request, key)[k] = v end store = requ...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
lib/view_component_reflex/dom/verifier.rb
Ruby
mit
301
master
320
module ViewComponentReflex module Dom class Verifier class << self attr_reader :verifier delegate :generate, :verified, :verify, :valid_message?, to: :verifier def verifier Rails.application.message_verifier(:view_component_reflex) end end end end end
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
lib/view_component_reflex/dom/reflex.rb
Ruby
mit
301
master
1,102
## # State adapters assume that the data lives outside of the rendering pipeline # By moving the state to the DOM, we need to "hydrate" the state when the reflex comes in with the data # We're overriding `inject_key_into_component` for this purpose, since it's run once during a reflex, # and _just_ after the component ...
github
joshleblanc/view_component_reflex
https://github.com/joshleblanc/view_component_reflex
lib/view_component_reflex/dom/component.rb
Ruby
mit
301
master
952
module ViewComponentReflex module Dom module Component def component_controller(opts_or_tag = :div, opts = {}, &blk) initialize_component tag = :div options = if opts_or_tag.is_a? Hash opts_or_tag else tag = opts_or_tag opts end ...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
Rakefile
Ruby
mit
301
master
857
require 'rubygems' require 'bundler/setup' require 'rake' require 'rspec/core/rake_task' require File.expand_path('../lib/happymapper/version', __FILE__) RSpec::Core::RakeTask.new(:spec) task :default => :spec desc 'Builds the gem' task :build do sh "gem build happymapper.gemspec" end desc 'Builds and installs th...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
happymapper.gemspec
Ruby
mit
301
master
785
# encoding: UTF-8 require File.expand_path('../lib/happymapper/version', __FILE__) Gem::Specification.new do |s| s.name = 'happymapper' s.homepage = 'May you have many happy mappings!' s.summary = 'object to xml mapping library' s.homepage = 'http://happymapper.rubyforge.org' s.rubyforge...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
examples/twitter.rb
Ruby
mit
301
master
939
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) require File.join(dir, 'happymapper') file_contents = File.read(dir + '/../spec/fixtures/statuses.xml') class User include HappyMapper element :id, Integer element :name, String element :screen_name, String element :location, String ...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
examples/current_weather.rb
Ruby
mit
301
master
793
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) require File.join(dir, 'happymapper') file_contents = File.read(dir + '/../spec/fixtures/current_weather.xml') class CurrentWeather include HappyMapper tag 'ob' namespace 'http://www.aws.com/aws' element :temperature, Integer, :tag => '...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
examples/post.rb
Ruby
mit
301
master
519
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) require File.join(dir, 'happymapper') file_contents = File.read(dir + '/../spec/fixtures/posts.xml') class Post include HappyMapper attribute :href, String attribute :hash, String attribute :description, String attribute :tag, String ...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
examples/amazon.rb
Ruby
mit
301
master
1,152
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) require File.join(dir, 'happymapper') file_contents = File.read(dir + '/../spec/fixtures/pita.xml') # The document `pita.xml` contains both a default namespace and the 'georss' # namespace (for the 'point' element). module PITA class Item in...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
examples/dashed_elements.rb
Ruby
mit
301
master
491
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) require File.join(dir, 'happymapper') file_contents = File.read(dir + '/../spec/fixtures/commit.xml') module GitHub class Commit include HappyMapper tag "commit" element :url, String element :tree, String element :message, S...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
examples/multi_street_address.rb
Ruby
mit
301
master
768
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) require File.join(dir, 'happymapper') file_contents = File.read(dir + '/../spec/fixtures/multi_street_address.xml') class MultiStreetAddress include HappyMapper tag 'address' # allow primitive type to be collection has_many :street_a...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
lib/happymapper.rb
Ruby
mit
301
master
9,291
require 'rubygems' require 'date' require 'time' require 'xml' class Boolean; end module HappyMapper DEFAULT_NS = "happymapper" def self.included(base) base.instance_variable_set("@attributes", {}) base.instance_variable_set("@elements", {}) base.instance_variable_set("@registered_namespaces", {}) ...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
lib/happymapper/item.rb
Ruby
mit
301
master
5,287
module HappyMapper class Item attr_accessor :name, :type, :tag, :options, :namespace Types = [String, Float, Time, Date, DateTime, Integer, Boolean] # options: # :deep => Boolean False to only parse element's children, True to include # grandchildren and all others dow...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
spec/spec_helper.rb
Ruby
mit
301
master
277
require 'rubygems' require 'bundler/setup' require 'rspec' require File.expand_path('../../lib/happymapper', __FILE__) RSpec.configure do |c| c.raise_errors_for_deprecations! end def fixture_file(filename) File.read(File.dirname(__FILE__) + "/fixtures/#{filename}") end
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
spec/happymapper_attribute_spec.rb
Ruby
mit
301
master
356
require 'spec_helper' describe HappyMapper::Attribute do describe "initialization" do let(:attr) { HappyMapper::Attribute.new(:foo, String) } it 'should know that it is an attribute' do expect(attr.attribute?).to eq true end it 'should know that it is NOT an element' do expect(attr.elem...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
spec/happymapper_to_xml_namespaces_spec.rb
Ruby
mit
301
master
4,276
require 'spec_helper' module ToXMLWithNamespaces # # Similar example as the to_xml but this time with namespacing # class Address include HappyMapper register_namespace 'address', 'http://www.company.com/address' register_namespace 'country', 'http://www.company.com/country' tag 'Address' ...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
spec/happymapper_element_spec.rb
Ruby
mit
301
master
352
require 'spec_helper' describe HappyMapper::Element do describe "initialization" do let(:attr) { HappyMapper::Element.new(:foo, String) } it 'should know that it is an element' do expect(attr.element?).to eq true end it 'should know that it is NOT an attribute' do expect(attr.attribute?...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
spec/happymapper_to_xml_spec.rb
Ruby
mit
301
master
5,392
require 'spec_helper' module ToXML class Address include HappyMapper tag 'address' attribute :location, String attribute :precipitation, Float attribute :last_update, Time attribute :mayor_elected, Date attribute :last_earthquake, DateTime attribute :revision, Integer attribute...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
spec/happymapper_spec.rb
Ruby
mit
301
master
15,420
require 'spec_helper' require 'pp' require 'uri' require 'support/models' describe HappyMapper do describe "being included into another class" do let(:klass) do Class.new do include HappyMapper def self.to_s 'Foo' end end end it "should set attributes to an...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
spec/happymapper_item_spec.rb
Ruby
mit
301
master
3,106
require 'spec_helper' module Foo class Bar; end end describe HappyMapper::Item do describe "new instance" do let(:item) { HappyMapper::Item.new(:foo, String, :tag => 'foobar') } it "should accept a name" do expect(item.name).to eq 'foo' end it 'should accept a type' do expect(item.t...
github
jnunemaker/happymapper
https://github.com/jnunemaker/happymapper
spec/support/models.rb
Ruby
mit
301
master
8,345
module Analytics class Property include HappyMapper tag 'property' namespace 'http://schemas.google.com/analytics/2009' attribute :name, String attribute :value, String end class Entry include HappyMapper tag 'entry' element :id, String element :updated, DateTime element...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
bin/check-untyped-call.rb
Ruby
mit
301
main
968
#!/usr/bin/env ruby require 'open3' require 'csv' def red(str) "\e[31m#{str}\e[0m" end def green(str) "\e[32m#{str}\e[0m" end out, err, status = Open3.capture3('bundle', 'exec', 'steep', 'stats', '--format=csv') unless status.success? raise <<~END steep stats` fails. stdout: #{out} stderr: ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/parser/3.2/_test/test.rb
Ruby
mit
301
main
1,577
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "parser" require "parser/current" node = Parser::CurrentRuby.parse("2 + 2") or raise node.loc node.loc.node node.loc.expression node.loc.line node.loc.first_line node.loc.last_line node.loc.column node.loc.last_column buffer = ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/gimei/1.1/_test/test.rb
Ruby
mit
301
main
1,688
require "gimei" gimei = Gimei.name gimei.kanji gimei.hiragana gimei.katakana gimei.romaji gimei.gender gimei.male? gimei.female? gimei.last.kanji gimei.last.hiragana gimei.last.katakana gimei.last.romaji gimei.first.kanji gimei.first.hiragana gimei.first.katakana gimei.first.romaji gimei.family.kanji gimei.family.hir...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/railties/6.0/_test/test.rb
Ruby
mit
301
main
383
Rails.application.routes.draw do resources :test1_models end raise <<~HEREDOC unless Rails.application.routes.url_helpers.polymorphic_path(:new_test1_model) == '/test1_models/new' But it should work, since: >>> Rails.application.routes.method(:url_helpers).source_location ["/usr/local/bundle/gems/actionpack-6....
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/railties/6.0/_scripts/generate.rb
Ruby
mit
301
main
9,183
# Usage # # ruby generate.rb all # ruby generate.rb actionpack require 'pathname' require 'open3' RAILS_CODE_DIR = Pathname(__dir__) / '../_src/' def bin(c) Pathname(__dir__).join('../_rbs_rails/bin/', c).to_s end def sh!(*cmd, **kwargs) puts(cmd.join(' ')) Open3.capture2(*cmd, **kwargs).then do |out, sta...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/bcrypt/3.1/_test/test.rb
Ruby
mit
301
main
912
require "bcrypt" raw_password = 'password123' # BCrypt::Password hashed_password = BCrypt::Password.create(raw_password, { cost: 4 }) BCrypt::Password.valid_hash?(hashed_password) BCrypt::Password.valid_hash?(hashed_password.to_s) BCrypt::Password.new(hashed_password) BCrypt::Password.new(hashed_password.to_s) hash...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/activeadmin/3.3/_test/test.rb
Ruby
mit
301
main
346
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "activeadmin" class SessionsController < ActiveAdmin::Devise::SessionsController end class TestPanel < ActiveAdmin::Views::Panel builder_method :test_panel end class TestStatusTag < ActiveAdmin::Views::StatusTag builder_me...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/commonmarker/1.1/_test/test.rb
Ruby
mit
301
main
239
require "commonmarker" Commonmarker.to_html('"Hi *there*"', options: { parse: { smart: true } }) doc = Commonmarker.parse("*Hello* world", options: { parse: { smart: true } }) puts(doc.to_html) # => <p><em>Hello</em> world</p>\n
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/email_address/0.2/_test/test.rb
Ruby
mit
301
main
1,771
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "email_address" address = "Clark.Kent+scoops@gmail.com" EmailAddress.valid?(address) #=> true EmailAddress.normal(address) #=> "clark.kent+scoops@gmail.com" EmailAddress.canonical(address) #=> "clarkkent@gmail.com" EmailAd...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/async/2.12/_test/test.rb
Ruby
mit
301
main
2,159
require 'net' require 'async' require 'async/barrier' require 'async/semaphore' require 'async/waiter' Async do |task| task.async{ "str" }.wait.size task.with_timeout(10, Async::TimeoutError, 'timeout') {} end Async(transient: true) do end Async do a = Async { "str" } p a.wait.size end Sync{ "str" }.size A...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/octokit/8.0/_test/test.rb
Ruby
mit
301
main
1,382
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "octokit" # Provide authentication credentials client = Octokit::Client.new(:access_token => 'personal_access_token') # You can still use the username/password syntax by replacing the password value with your PAT. # client = Oc...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/circuitbox/2.0/_test/test.rb
Ruby
mit
301
main
933
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "circuitbox" Circuitbox::VERSION Circuitbox::FaradayMiddleware Circuitbox.circuit(:your_service, exceptions: [ArgumentError]) do :processing! end.id2name circuit = Circuitbox.circuit(:your_service, exceptions: [ArgumentError])...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/activemodel/7.1/_test/test.rb
Ruby
mit
301
main
630
require "active_model" class Person include ActiveModel::Attributes include ActiveModel::Validations # @dynamic name, name= attribute :name, :string end Person.attribute_types ActiveModel::Error::CALLBACKS_OPTIONS ActiveModel::Error::MESSAGE_OPTIONS error = ActiveModel::Error.new(Person.new, :name, :too_sh...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/rubocop-ast/1.46/_test/test.rb
Ruby
mit
301
main
25,487
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "rubocop-ast" class MyRule < Parser::AST::Processor include RuboCop::AST::Traversal def on_sym(node) node.value node.location.begin node.location.end node.loc.begin node.loc.end end def on_if(node) ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/rubocop-ast/1.30/_test/test.rb
Ruby
mit
301
main
24,391
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "rubocop-ast" class MyRule < Parser::AST::Processor include RuboCop::AST::Traversal def on_sym(node) node.value node.location.begin node.location.end node.loc.begin node.loc.end end def on_if(node) ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/actionview/6.0/_test/actionview.rb
Ruby
mit
301
main
1,967
class Test class ApplicationController < ActionController::Base end class UsersController < ApplicationController def create render :new, status: :unprocessable_entity end def update render "edit", status: :unprocessable_entity end end class View include ActionView::Helpers ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/devise/4.9/_test/test.rb
Ruby
mit
301
main
723
require "devise" require "active_record" class CustomConfirmationsController < Devise::ConfirmationsController end class CustomOmniauthCallbacksController < Devise::OmniauthCallbacksController end class CustomPasswordsController < Devise::PasswordsController end class CustomRegistrationsController < Devise::Registr...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/nokogiri/1.11/_test/test.rb
Ruby
mit
301
main
3,211
# https://nokogiri.org/#how-to-use-nokogiri require 'nokogiri' # Fetch and parse HTML document doc = Nokogiri::HTML(<<~HTML) <body> <nav> <ul class="menu"> <li><a href="#">hello</a></li> </ul> </nav> <article> <h2>hello</h2> </article> </body> HTML # Search for nodes by css doc.css('nav ul...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/google-apis-bigquery_v2/0.76/_test/test.rb
Ruby
mit
301
main
441
require "google-apis-bigquery_v2" require "googleauth" json_key = '' client = Google::Apis::BigqueryV2::BigqueryService.new client.authorization = Google::Auth::ServiceAccountCredentials.make_creds( json_key_io: StringIO.new(json_key), scope: [Google::Apis::BigqueryV2::AUTH_BIGQUERY] ) query = 'SELECT 1' request = G...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/addressable/2.8/_test/test.rb
Ruby
mit
301
main
2,213
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "addressable/uri" uri = Addressable::URI.parse("http://example.com/path/to/resource/") uri.scheme #=> "http" uri.host #=> "example.com" uri.path #=> "/path/to/resource/" uri = Addressable::URI.parse("http://www.詹姆斯.com/") uri.n...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/csv/3.3/_test/test.rb
Ruby
mit
301
main
680
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "csv" csv = CSV.new("header1,header2\nrow1_1,row1_2") csv.headers csv = CSV.new("header1,header2\nrow1_1,row1_2", headers: true) csv.headers csv.read csv.headers [1, 2, 3].to_csv [1, 2, 3].to_csv(col_sep: '\t') CSV.open("exam...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/ruby-odbc/0.999992/_test/test.rb
Ruby
mit
301
main
3,137
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "odbc" # Test module methods # Connection test conn = ODBC.connect("test_dsn", "user", "password") # Data sources and drivers dsns = ODBC.datasources drivers = ODBC.drivers # Error handling error = ODBC.error info = ODBC.info...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/climate_control/1.2/_test/test.rb
Ruby
mit
301
main
265
require "climate_control" a = ClimateControl.modify(ABC: "abc", MY_VAR1: "var1", EDITOR: nil) do "#{ENV['ABC']} #{ENV['MY_VAR1']}" end a.upcase xs = ClimateControl.unsafe_modify(XYZ: nil, MY_VAR2: "var2") do [ENV["MY_VAR2"]] end xs.detect { |x| x == "var1" }
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/http/5.1/_test/test.rb
Ruby
mit
301
main
2,823
require "http" # Test HTTP::Response initialization and methods response = HTTP::Response.new( status: 200, version: "1.1", body: "Hello world!", ) response.code == 200 response.reason response.flush response.to_s response.to_str # Test HTTP module singleton methods (verb methods) HTTP.get("https://example.com...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/signet/0.19/_test/test.rb
Ruby
mit
301
main
456
require "signet" begin raise Signet::AuthorizationError rescue Signet::AuthorizationError => e # nop end class MyClient < Signet::OAuth2::Client end client = Signet::OAuth2::Client.new({ :authorization_uri => 'https://example.com/authorization', :token_credential_uri => 'https://example.com/token', :client...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/simplecov/0.22/_test/test.rb
Ruby
mit
301
main
1,270
require "simplecov" SimpleCov.start SimpleCov.start 'rails' SimpleCov.start do add_filter 'test' end SimpleCov.start 'rails' do add_filter 'test' end SimpleCov.start do enable_coverage :line enable_coverage :branch enable_coverage_for_eval primary_coverage :line primary_coverage :branch end Simple...