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
charlotte-ruby/social_engine
https://github.com/charlotte-ruby/social_engine
app/models/friending.rb
Ruby
mit
45
master
494
class Friending < ActiveRecord::Base belongs_to :friendee, :class_name=>'User' belongs_to :friendor, :class_name=>'User' validates_uniqueness_of :friendee_id, :scope=> :friendor_id validate :not_friending_self def confirm self.update_attributes(:confirmed=>true) end def reject self.update_attrib...
github
charlotte-ruby/social_engine
https://github.com/charlotte-ruby/social_engine
app/models/social_engine/sociable.rb
Ruby
mit
45
master
267
module SocialEngine module Sociable def is_sociable is_rateable is_voteable is_commentable is_favoriteable include InstanceMethods end module InstanceMethods def sociable? true end end end end
github
charlotte-ruby/social_engine
https://github.com/charlotte-ruby/social_engine
app/models/social_engine/social_user.rb
Ruby
mit
45
master
281
module SocialEngine module SocialUser def is_social has_many :comments has_many :votes has_many :ratings has_many :favorites include InstanceMethods end module InstanceMethods def is_social? true end end end end
github
charlotte-ruby/social_engine
https://github.com/charlotte-ruby/social_engine
app/models/social_engine/commentable.rb
Ruby
mit
45
master
265
module SocialEngine module Commentable def is_commentable has_many :comments, :as=>:commentable, :dependent => :destroy include InstanceMethods end module InstanceMethods def commentable? true end end end end
github
charlotte-ruby/social_engine
https://github.com/charlotte-ruby/social_engine
app/models/social_engine/reputatable.rb
Ruby
mit
45
master
228
module SocialEngine module Reputatable def has_reputation has_many :reputations include InstanceMethods end module InstanceMethods def has_reputation? true end end end end
github
charlotte-ruby/social_engine
https://github.com/charlotte-ruby/social_engine
app/models/social_engine/rateable.rb
Ruby
mit
45
master
739
module SocialEngine module Rateable def is_rateable has_many :ratings, :as=>:rateable, :dependent=>:destroy include InstanceMethods end module InstanceMethods def rateable? true end def avg_rating avg = self.ratings.sum(:value).to_f/self.rating_cou...
github
charlotte-ruby/social_engine
https://github.com/charlotte-ruby/social_engine
app/models/social_engine/voteable.rb
Ruby
mit
45
master
603
module SocialEngine module Voteable def is_voteable has_many :votes, :as=>:voteable, :dependent=>:destroy include InstanceMethods end module InstanceMethods def voteable? true end def upvote(options={}) options.reverse_merge!(:value=>1) sel...
github
charlotte-ruby/social_engine
https://github.com/charlotte-ruby/social_engine
app/models/social_engine/favoriteable.rb
Ruby
mit
45
master
270
module SocialEngine module Favoriteable def is_favoriteable has_many :favorites, :as=>:favoriteable, :dependent => :destroy include InstanceMethods end module InstanceMethods def favoriteable? true end end end end
github
charlotte-ruby/social_engine
https://github.com/charlotte-ruby/social_engine
app/models/social_engine/helpers.rb
Ruby
mit
45
master
897
module SocialEngine module Helpers module User def name self.user ? self.user.name : self.unauthenticated_name end def email self.user ? self.user.email : self.unauthenticated_email end def website self.user ? self.user.website : self.unauthenticated_websi...
github
charlotte-ruby/social_engine
https://github.com/charlotte-ruby/social_engine
app/models/social_engine/friendable.rb
Ruby
mit
45
master
2,167
module SocialEngine module Friendable def is_friendable # Setup conditions active = ["confirmed = ? AND rejected = ?", true, false] pending = ["confirmed = ?", false] requested = ["confirmed = ? AND rejected = ?", false, false] rejected = ["rejected = ?", true] # Active frien...
github
charlotte-ruby/social_engine
https://github.com/charlotte-ruby/social_engine
app/helpers/social_engine_helper.rb
Ruby
mit
45
master
2,908
module SocialEngineHelper def tweetme(options={}) defaults = {count: SocialEngineYetting.tweetme["count"], url: request.url, div_class: SocialEngineYetting.tweetme["div_class"]} options.reverse_merge!(defaults) render "third_party/tweetme", options: options end def fb_like(options={}) defaults ...
github
mordaroso/guard-motion
https://github.com/mordaroso/guard-motion
guard-motion.gemspec
Ruby
mit
45
master
981
# -*- encoding: utf-8 -*- require File.expand_path('../lib/guard/motion/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["mordaroso"] gem.email = ["mordaroso@gmail.com"] gem.homepage = 'http://rubygems.org/gems/guard-motion' gem.summary = 'Guard gem for RubyMotion' ...
github
mordaroso/guard-motion
https://github.com/mordaroso/guard-motion
Guardfile
Ruby
mit
45
master
254
# A sample Guardfile # More info at https://github.com/guard/guard#readme guard 'rspec', :version => 2 do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } end
github
mordaroso/guard-motion
https://github.com/mordaroso/guard-motion
lib/guard/motion.rb
Ruby
mit
45
master
2,553
require 'guard' require 'guard/guard' require 'guard/motion/tasks' module Guard class Motion < Guard autoload :ResultsParser, 'guard/motion/results_parser' autoload :Runner, 'guard/motion/runner' autoload :Inspector, 'guard/motion/inspector' # Initialize a Guard. # @param [Array<G...
github
mordaroso/guard-motion
https://github.com/mordaroso/guard-motion
lib/guard/motion/tasks.rb
Ruby
mit
45
master
737
# include rake task spec:specific only if included in a rake file if Kernel.const_defined?(:Rake) desc "Run a specific list of motion specs" namespace :spec do task :specific, :files do |task, args| files = args[:files] if files.nil? || files.empty? puts "No spec file passed to the task." ...
github
mordaroso/guard-motion
https://github.com/mordaroso/guard-motion
lib/guard/motion/inspector.rb
Ruby
mit
45
master
1,664
module Guard class Motion class Inspector def initialize(options = {}) self.excluded = options[:exclude] self.spec_paths = options[:spec_paths] end def excluded @excluded || [] end def excluded=(pattern) @excluded = Dir[pattern.to_s] end ...
github
mordaroso/guard-motion
https://github.com/mordaroso/guard-motion
lib/guard/motion/results_parser.rb
Ruby
mit
45
master
590
module Guard class Motion class ResultsParser attr_reader :errors attr_reader :failures attr_reader :specs def parse(output) matched = false stats_regex = /(\d+) (tests|specifications),? \(?\d+ (assertions|requirements)\)?, (\d+) failures, (\d+) errors/ stat...
github
mordaroso/guard-motion
https://github.com/mordaroso/guard-motion
lib/guard/motion/runner.rb
Ruby
mit
45
master
2,881
require 'pty' module Guard class Motion class Runner def initialize(options = {}) @options = { :bundler => true, :binstubs => false, :env => {}, :notification => true, }.merge(options) end def run(paths = nil, options = ...
github
mordaroso/guard-motion
https://github.com/mordaroso/guard-motion
lib/guard/motion/templates/Guardfile
Ruby
mit
45
master
241
guard 'motion' do watch(%r{^spec/.+_spec\.rb$}) # RubyMotion App example watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } # RubyMotion gem example watch(%r{^lib/[^/]+/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } end
github
mordaroso/guard-motion
https://github.com/mordaroso/guard-motion
spec/spec_helper.rb
Ruby
mit
45
master
481
require 'guard/motion' require 'rspec' ENV["GUARD_ENV"] = 'test' Dir["#{File.expand_path('..', __FILE__)}/support/**/*.rb"].each { |f| require f } RSpec.configure do |config| config.color_enabled = true config.filter_run :focus => true config.run_all_when_everything_filtered = true config.before(:each) do ...
github
mordaroso/guard-motion
https://github.com/mordaroso/guard-motion
spec/guard/motion_spec.rb
Ruby
mit
45
master
4,295
require 'spec_helper' module Guard describe Motion do let(:default_options) do { :all_after_pass => true, :all_on_start => true, :keep_failed => true, :spec_paths => ['spec'] } end subject { described_class.new } let(:runner) { mock(described_class::Runner) } befo...
github
mordaroso/guard-motion
https://github.com/mordaroso/guard-motion
spec/guard/motion/inspector_spec.rb
Ruby
mit
45
master
4,086
require 'spec_helper' describe Guard::Motion::Inspector do describe '.initialize' do it 'accepts an :exclude option that sets @excluded' do inspector1 = described_class.new(:exclude => 'spec/slow/*') inspector2 = described_class.new inspector2.excluded = 'spec/slow/*' inspector1.exclud...
github
mordaroso/guard-motion
https://github.com/mordaroso/guard-motion
spec/guard/motion/results_parser_spec.rb
Ruby
mit
45
master
2,285
require 'spec_helper' module Guard class Motion describe ResultsParser do describe "#parse" do before do @result = subject.parse(output) end context "when the output contains spec output" do context "and specs failed" do let(:output) { "................
github
mordaroso/guard-motion
https://github.com/mordaroso/guard-motion
spec/guard/motion/runner_spec.rb
Ruby
mit
45
master
5,694
require 'spec_helper' module Guard class Motion describe Runner do subject { described_class.new } let(:output) { "..............................\n\n31 tests, 35 assertions, 2 failures, 0 errors\n" } before do PTY.stub(:spawn).and_yield(StringIO.new(output), StringIO.new, 123) ...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
dot_example.gemspec
Ruby
mit
45
master
1,259
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'dot_example/version' Gem::Specification.new do |spec| spec.name = "dot_example" spec.version = DotExample::VERSION spec.authors = ["Stephen Mariano Cabrera"] spec.ema...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
spec/dot_example_spec.rb
Ruby
mit
45
master
350
require 'spec_helper' describe DotExample do it 'has a version number' do expect(DotExample::VERSION).not_to be nil end describe '.add_pre_commit_hook' do #TODO: For when I figure out how to effectively test these end describe 'add_post_checkout_hook' do #TODO: For when I figure out how to effe...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
spec/lib/dot_example/pre_commit_hook_spec.rb
Ruby
mit
45
master
2,201
require "spec_helper" describe PreCommitHook do describe '#write!' do after do %x[ rm #{PreCommitHook.new.filepath} ] end context 'pre commit hook already exists and contains the steps from dot_example' do before do dot_env_dot_example = DotEnvDotExample.new pre_commit_hook ...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
spec/lib/dot_example/dot_env_dot_example_spec.rb
Ruby
mit
45
master
4,255
require 'spec_helper' describe DotEnvDotExample do before { `touch .env.example` } after { `rm .env.example` } describe '.new' do context 'it is initialized without a filename or a dot_env' do it 'uses the defaults of ".env.example" and instantiating a DotEnv with its defaults' do dot_env...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
spec/lib/dot_example/dot_env_spec.rb
Ruby
mit
45
master
1,796
require 'spec_helper' describe DotEnv do describe '#key_lines' do it 'returns a string with each key on its own line' do dot_env_file = DotEnv.new("spec/support/.env") expect(dot_env_file.key_lines).to eq "SOME_API_KEY=\nSOME_API_SECRET=" end end # TODO: This logic has been moved to a lint! fu...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
spec/lib/dot_example/post_checkout_hook_spec.rb
Ruby
mit
45
master
2,095
require "spec_helper" describe PostCheckoutHook do describe '#write!' do after do %x[ rm #{PostCheckoutHook.new.filepath} ] end context 'post-checkout hook already exists and contains the steps from dot_example' do before do post_checkout_hook = PostCheckoutHook.new File.ope...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
spec/lib/tasks/dot_example_rake_spec.rb
Ruby
mit
45
master
1,803
# An example rake spec borrowed from thoughtbot blog here: https://robots.thoughtbot.com/test-rake-tasks-like-a-boss # spec/lib/tasks/reports_rake_spec.rb # #describe "reports:users" do #include_context "rake" #let(:csv) { stub("csv data") } #let(:report) { stub("generated report", :to_csv => csv)...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
lib/dot_example.rb
Ruby
mit
45
master
522
require 'paint' require_relative "dot_example/version" require_relative "dot_example/dot_env" require_relative "dot_example/dot_env_dot_example" require_relative "dot_example/hook" require_relative "dot_example/pre_commit_hook" require_relative "dot_example/post_checkout_hook" module DotExample def self.add_pre_comm...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
lib/tasks/dot_example.rake
Ruby
mit
45
master
550
# TODO: Figure out whether it makes more sense to use rake tasks or just custom commands using commander. namespace :dot_example do desc "Setup the githooks to automate the dot_example tasks" task :setup => :environment do # Call other classes and do stuff end desc "Creates a new .env.example file with the...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
lib/dot_example/hook.rb
Ruby
mit
45
master
774
class Hook def print_new_hook_message puts Paint["New #{type} hook created", :green] end def print_new_steps_message puts Paint[ "New steps added to #{type} hook\n#{steps}", :green] end def contents File.read(filepath) end def filepath File.join(".git", "hooks", type) end def creat...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
lib/dot_example/dot_env_dot_example.rb
Ruby
mit
45
master
1,367
class DotEnvDotExample def initialize( options = {} ) @filename = options[:filename] || ".env.example" @dot_env = options[:dot_env] || DotEnv.new end attr_reader :filename, :dot_env def write! if keys_new_to_example.any? print_new_keys_message File.open(filename, "a") do |file| ...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
lib/dot_example/dot_env.rb
Ruby
mit
45
master
790
class DotEnv def initialize(filename = nil) @filename = filename || ".env" create_file_if_does_not_exist end attr_reader :filename def key_lines keys.map { |key| key + "=" }.join("\n") end def lint! unless line.match(/^[^=\s]*=[^=\s]*$/) # TODO: Don't know if this is the best erro...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
lib/dot_example/pre_commit_hook.rb
Ruby
mit
45
master
482
class PreCommitHook < Hook def initialize(dot_env_dot_example = nil) @dot_env_dot_example = dot_env_dot_example || DotEnvDotExample.new @type = "pre-commit" create_file_if_does_not_exist end attr_reader :dot_env_dot_example, :type # TODO: Make it possible to put .env and .env.example files somewhe...
github
smcabrera/dot_example
https://github.com/smcabrera/dot_example
lib/dot_example/post_checkout_hook.rb
Ruby
mit
45
master
303
class PostCheckoutHook < Hook def initialize(dot_env_dot_example = nil) @dot_env_dot_example = dot_env_dot_example || DotEnvDotExample.new @type = "post-checkout" create_file_if_does_not_exist end attr_reader :dot_env_dot_example, :type def steps "dot_example check" end end
github
unasuke/omniauth-twitter2
https://github.com/unasuke/omniauth-twitter2
Gemfile
Ruby
apache-2.0
45
main
262
# frozen_string_literal: true source "https://rubygems.org" # Specify your gem's dependencies in omniauth-twitter2.gemspec gemspec gem "minitest" gem "rake" gem "rubocop" gem "minitest-mock" if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create("3.1")
github
unasuke/omniauth-twitter2
https://github.com/unasuke/omniauth-twitter2
omniauth-twitter2.gemspec
Ruby
apache-2.0
45
main
1,401
# frozen_string_literal: true require_relative "lib/omniauth/twitter2/version" Gem::Specification.new do |spec| spec.name = "omniauth-twitter2" spec.version = OmniAuth::Twitter2::VERSION spec.authors = ["Yusuke Nakamura"] spec.email = ["yusuke1994525@gmail.com"] spec.summary = "Twitter OAuth2 strategy for ...
github
unasuke/omniauth-twitter2
https://github.com/unasuke/omniauth-twitter2
test/test_helper.rb
Ruby
apache-2.0
45
main
1,895
# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "omniauth/twitter2" require "minitest/mock" require "minitest/autorun" def mock_auth_sample # rubocop:disable Metrics/MethodLength # 2022-01-13 02:40:00 +0900 { "provider" => "twitter2", "uid" => "108252390", "in...
github
unasuke/omniauth-twitter2
https://github.com/unasuke/omniauth-twitter2
test/omniauth/test_twitter2.rb
Ruby
apache-2.0
45
main
1,847
# frozen_string_literal: true require "test_helper" require "omniauth" class TestOmniAuthTwitter2 < Minitest::Test def setup OmniAuth.config.test_mode = true # OmniAuth.config.mock_auth[:twitter2] = OmniAuth::AuthHash.new(mock_auth_sample) end def teardown OmniAuth.config.test_mode = false end ...
github
unasuke/omniauth-twitter2
https://github.com/unasuke/omniauth-twitter2
lib/omniauth/strategies/twitter2.rb
Ruby
apache-2.0
45
main
2,172
# frozen_string_literal: true require "base64" require "omniauth-oauth2" module OmniAuth module Strategies class Twitter2 < OmniAuth::Strategies::OAuth2 # :nodoc: option :name, "twitter2" # https://docs.x.com/fundamentals/authentication/oauth-2-0/overview option :client_options, { site...
github
veracross/pickadate-rails
https://github.com/veracross/pickadate-rails
pickadate-rails.gemspec
Ruby
mit
45
master
1,060
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'pickadate-rails/version' Gem::Specification.new do |spec| spec.name = "pickadate-rails" spec.version = PickadateRails::VERSION spec.authors = ["Jeff Fraser"] spec.ema...
github
veracross/pickadate-rails
https://github.com/veracross/pickadate-rails
Rakefile
Ruby
mit
45
master
896
require "bundler/gem_tasks" namespace :pickadate do desc "Download latest assets" task :download do require 'fileutils' system "curl https://github.com/amsul/pickadate.js/archive/master.zip -f -L --create-dirs -o tmp/pickadate.zip" system "unzip -o tmp/pickadate.zip -d tmp/" system "rm tmp/pickada...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
saml2.gemspec
Ruby
mit
45
main
1,264
# frozen_string_literal: true $LOAD_PATH.push File.expand_path("lib", __dir__) require "saml2/version" Gem::Specification.new do |s| s.name = "saml2" s.version = SAML2::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Cody Cutrer"] s.email = "cody@instructure.com'" s.homepage = "https://github.com/i...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
Gemfile
Ruby
mit
45
main
224
# frozen_string_literal: true source "https://rubygems.org" gemspec gem "debug", "~> 1.10" gem "rake", "~> 13.2" gem "rspec", "~> 3.5" gem "rubocop-inst", "~> 1" gem "rubocop-rake", "~> 0.6" gem "rubocop-rspec", "~> 3.5"
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2.rb
Ruby
mit
45
main
383
# frozen_string_literal: true require "saml2/authn_request" require "saml2/entity" require "saml2/logout_request" require "saml2/logout_response" require "saml2/response" require "saml2/version" require "saml2/engine" if defined?(Rails) && Rails::VERSION::MAJOR > 2 module SAML2 class << self def config @...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/schemas.rb
Ruby
mit
45
main
469
# frozen_string_literal: true module SAML2 module Schemas class << self def metadata @metadata ||= schema("metadata_combined.xsd") end def protocol @protocol ||= schema("saml-schema-protocol-2.0.xsd") end private def schema(filename) Dir.chdir(File.e...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/endpoint.rb
Ruby
mit
45
main
4,314
# frozen_string_literal: true require "saml2/bindings/http_post" module SAML2 class Endpoint < Base module ChoiceHelpers # Choose a binding supported by this list of endpoints # # @return [String] def choose_binding(*bindings) (bindings & map(&:binding)).first end # ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/role.rb
Ruby
mit
45
main
1,784
# frozen_string_literal: true require "saml2/base" require "saml2/key" require "saml2/organization_and_contacts" require "saml2/signable" module SAML2 # @abstract class Role < Base module Protocols SAML2 = "urn:oasis:names:tc:SAML:2.0:protocol" end include OrganizationAndContacts include Si...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/conditions.rb
Ruby
mit
45
main
4,117
# frozen_string_literal: true require "active_support/core_ext/array/wrap" module SAML2 class Conditions < Array # @return [Time, nil] attr_accessor :not_before, :not_on_or_after # (see Base#xml) attr_reader :xml # (see Base.from_xml) def self.from_xml(node) return nil unless node ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/assertion.rb
Ruby
mit
45
main
1,571
# frozen_string_literal: true require "saml2/conditions" module SAML2 class Assertion < Message attr_writer :statements, :subject def initialize super @statements = [] @conditions = Conditions.new end def from_xml(node) super @statements = nil remove_instance_va...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/key.rb
Ruby
mit
45
main
5,163
# frozen_string_literal: true require "openssl" require "saml2/base" require "saml2/namespaces" module SAML2 # This represents the XML Signatures <KeyInfo> element, and actually contains a # reference to an X.509 certificate, not solely a public key. class KeyInfo < Base # @return [String] The PEM encoded ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/attribute_consuming_service.rb
Ruby
mit
45
main
6,275
# frozen_string_literal: true require "active_support/core_ext/array/wrap" require "saml2/attribute" require "saml2/indexed_object" require "saml2/localized_name" require "saml2/namespaces" module SAML2 class RequestedAttribute < Attribute class << self # The XML namespace that this attribute class seria...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/message.rb
Ruby
mit
45
main
4,559
# frozen_string_literal: true require "securerandom" require "time" require "saml2/base" require "saml2/signable" module SAML2 class InvalidMessage < RuntimeError end class MissingMessage < InvalidMessage end class CorruptMessage < InvalidMessage end class MessageTooLarge < InvalidMessage end c...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/signable.rb
Ruby
mit
45
main
4,968
# frozen_string_literal: true require "saml2/key" module SAML2 module Signable # @return [Nokogiri::XML::Element, nil] def signature unless instance_variable_defined?(:@signature) @signature = xml.xpath("//dsig:Signature", Namespaces::ALL).find do |signature| signed_node = signature....
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/organization_and_contacts.rb
Ruby
mit
45
main
927
# frozen_string_literal: true require "saml2/contact" require "saml2/organization" module SAML2 module OrganizationAndContacts attr_writer :organization, :contacts def initialize @organization = nil @contacts = [] end # (see Base#from_xml) def from_xml(node) remove_instance_v...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/identity_provider.rb
Ruby
mit
45
main
2,081
# frozen_string_literal: true require "saml2/attribute" require "saml2/sso" module SAML2 class IdentityProvider < SSO # @return [Boolean, nil] attr_writer :want_authn_requests_signed attr_writer :single_sign_on_services, :attribute_profiles, :attributes def initialize super @want_authn_...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/service_provider.rb
Ruby
mit
45
main
2,555
# frozen_string_literal: true require "nokogiri" require "saml2/endpoint" require "saml2/sso" module SAML2 class ServiceProvider < SSO attr_writer :authn_requests_signed, :want_assertions_signed def initialize super @authn_requests_signed = nil @want_assertions_signed = nil @assert...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/contact.rb
Ruby
mit
45
main
1,891
# frozen_string_literal: true require "saml2/base" module SAML2 class Contact < Base module Type ADMINISTRATIVE = "administrative" BILLING = "billing" OTHER = "other" SUPPORT = "support" TECHNICAL = "technical" end # @see Type # @return [Str...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/authn_statement.rb
Ruby
mit
45
main
4,325
# frozen_string_literal: true require "saml2/base" module SAML2 class AuthnStatement < Base # @see https://docs.oasis-open.org/security/saml/v2.0/saml-authn-context-2.0-os.pdf module Classes INTERNET_PROTOCOL = "urn:oasis:names:tc:SAML:2.0:ac:classes:InternetProtocol" INTERNET_PROTOCOL_PASSWORD ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/response.rb
Ruby
mit
45
main
11,235
# frozen_string_literal: true require "nokogiri-xmlsec" require "time" require "saml2/assertion" require "saml2/authn_statement" require "saml2/status_response" require "saml2/subject" module SAML2 class Response < StatusResponse # Respond to an {AuthnRequest} # # {AuthnRequest#resolve} needs to have b...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/status_response.rb
Ruby
mit
45
main
772
# frozen_string_literal: true require "saml2/message" require "saml2/status" module SAML2 class StatusResponse < Message # @return [String] attr_accessor :in_response_to attr_writer :status def initialize super @status = Status.new end # (see Base#from_xml) def from_xml(nod...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/base.rb
Ruby
mit
45
main
6,940
# frozen_string_literal: true require "saml2/namespaces" module SAML2 # @abstract class Base class << self def lookup_qname(qname, namespaces) prefix, local_name = split_qname(qname) [lookup_namespace(prefix, namespaces), local_name] end # Create an appropriate object to rep...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/requested_authn_context.rb
Ruby
mit
45
main
845
# frozen_string_literal: true require "saml2/base" module SAML2 class RequestedAuthnContext < Base # @return [String, nil] attr_accessor :comparison # @return [String, Array<String>] attr_accessor :class_ref def initialize(class_ref = nil) super() @class_ref = class_ref end ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/namespaces.rb
Ruby
mit
45
main
765
# frozen_string_literal: true module SAML2 module Namespaces DSIG = "http://www.w3.org/2000/09/xmldsig#" METADATA = "urn:oasis:names:tc:SAML:2.0:metadata" SAML = "urn:oasis:names:tc:SAML:2.0:assertion" SAMLP = "urn:oasis:names:tc:SAML:2.0:protocol" XENC = "http://www.w3.org/2001/04...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/entity.rb
Ruby
mit
45
main
5,024
# frozen_string_literal: true require "nokogiri" require "saml2/base" require "saml2/identity_provider" require "saml2/organization_and_contacts" require "saml2/service_provider" require "saml2/signable" module SAML2 class Entity < Base include OrganizationAndContacts include Signable # @return [Strin...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/attribute.rb
Ruby
mit
45
main
6,580
# frozen_string_literal: true require "date" require "active_support/core_ext/array/wrap" require "saml2/base" require "saml2/namespaces" module SAML2 class Attribute < Base module NameFormats BASIC = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" UNSPECIFIED = "urn:oasis:names:tc:SAML:...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/sso.rb
Ruby
mit
45
main
961
# frozen_string_literal: true require "saml2/role" module SAML2 # @abstract class SSO < Role def initialize super @single_logout_services = Endpoint::Array.new @name_id_formats = [] end # (see Base#from_xml) def from_xml(node) super @single_logout_services = nil ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/logout_response.rb
Ruby
mit
45
main
1,244
# frozen_string_literal: true require "saml2/status_response" module SAML2 class LogoutResponse < StatusResponse # @param logout_request [LogoutRequest] # @param sso [SSO, nil] # @param issuer [NameID] # @param status_code [String] # @param binding [String] the binding to use for the response ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/authn_request.rb
Ruby
mit
45
main
7,557
# frozen_string_literal: true require "base64" require "zlib" require "saml2/attribute_consuming_service" require "saml2/bindings/http_redirect" require "saml2/endpoint" require "saml2/name_id" require "saml2/namespaces" require "saml2/request" require "saml2/requested_authn_context" require "saml2/schemas" require "...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/indexed_object.rb
Ruby
mit
45
main
2,153
# frozen_string_literal: true require "saml2/base" module SAML2 module IndexedObject def self.included(klass) klass.const_set(:Array, Array.dup) end # @return [Integer] attr_accessor :index def initialize(*) @is_default = nil super end def eql?(other) index == ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/logout_request.rb
Ruby
mit
45
main
1,516
# frozen_string_literal: true require "saml2/name_id" require "saml2/request" module SAML2 class LogoutRequest < Request attr_writer :name_id, :session_index # @param sso [SSO, nil] # @param issuer [NameID] # @param name_id [NameID] # @param session_index optional [String, Array<String>] # ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/status.rb
Ruby
mit
45
main
3,618
# frozen_string_literal: true require "saml2/base" module SAML2 class Status < Base SUCCESS = "urn:oasis:names:tc:SAML:2.0:status:Success" REQUESTER = "urn:oasis:names:tc:SAML:2.0:status:Requester" RESPONDER = "urn:oasis:names:tc:SAML:2.0:status:Responder" VERSION_MISMATCH = "urn:oasis:names:tc:SA...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/organization.rb
Ruby
mit
45
main
1,026
# frozen_string_literal: true require "saml2/base" require "saml2/localized_name" require "saml2/namespaces" module SAML2 class Organization < Base # @return [LocalizedName] attr_reader :name, :display_name, :url # (see Base#from_xml) def from_xml(node) name.from_xml(node.xpath("md:Organizati...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/localized_name.rb
Ruby
mit
45
main
1,204
# frozen_string_literal: true require "saml2/base" require "saml2/namespaces" module SAML2 class LocalizedName < Hash attr_reader :element def initialize(element, name = nil) super() @element = element return if name.nil? if name.is_a?(Hash) replace(name) else ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/name_id.rb
Ruby
mit
45
main
4,545
# frozen_string_literal: true require "saml2/base" require "saml2/namespaces" module SAML2 class NameID < Base module Format EMAIL_ADDRESS = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" ENTITY = "urn:oasis:names:tc:SAML:2.0:nameid-format:entity" KERBEROS = "urn:oasi...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/subject.rb
Ruby
mit
45
main
3,080
# frozen_string_literal: true require "saml2/name_id" require "saml2/namespaces" module SAML2 class Subject < Base attr_writer :name_id, :confirmations def initialize super @confirmations = [] end # (see Base#from_xml) def from_xml(node) super @confirmations = nil e...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/bindings/http_redirect.rb
Ruby
mit
45
main
7,764
# frozen_string_literal: true require "base64" require "uri" require "zlib" require "saml2/bindings" require "saml2/message" module SAML2 module Bindings module HTTPRedirect URN = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" module SigAlgs DSA_SHA1 = "http://www.w3.org/2000/09/xmld...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/bindings/http_post.rb
Ruby
mit
45
main
1,676
# frozen_string_literal: true require "base64" module SAML2 module Bindings module HTTP_POST # rubocop:disable Naming/ClassAndModuleCamelCase URN = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" class << self # Decode and parse a Base64 encoded SAML message. # # @param pos...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
lib/saml2/attribute/x500.rb
Ruby
mit
45
main
4,145
# frozen_string_literal: true module SAML2 class Attribute class X500 < Attribute GIVEN_NAME = "urn:oid:2.5.4.42" SN = SURNAME = "urn:oid:2.5.4.4" # https://www.ietf.org/rfc/rfc2798.txt module InetOrgPerson DISPLAY_NAME = "urn:oid:2.16.840.1.113730.3.1.241" EMPLOYE...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/signable_spec.rb
Ruby
mit
45
main
405
# frozen_string_literal: true module SAML2 describe Signable do describe "#valid_signature?" do it "can work with an explicit key from metadata" do response = Response.parse(fixture("response_with_rsa_key_value.xml")) key = response.assertions.first.signing_key.key expect(response.a...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/authn_request_spec.rb
Ruby
mit
45
main
2,537
# frozen_string_literal: true module SAML2 describe AuthnRequest do let(:sp) { Entity.parse(fixture("service_provider.xml")).roles.first } let(:request) { AuthnRequest.parse(fixture("authnrequest.xml")) } it "should be valid" do expect(request.valid_schema?).to be true expect(request.resolve...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/logout_response_spec.rb
Ruby
mit
45
main
2,218
# frozen_string_literal: true module SAML2 describe LogoutResponse do let(:idp) { Entity.parse(fixture("identity_provider.xml")).roles.first } let(:logout_request) do LogoutRequest.initiate(idp, NameID.new("issuer"), NameID.new("jacob", ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/entity_spec.rb
Ruby
mit
45
main
1,974
# frozen_string_literal: true module SAML2 describe Entity do it "should parse and validate" do entity = Entity.parse(fixture("service_provider.xml")) expect(entity.valid_schema?).to be true end it "should return nil when not valid schema" do entity = Entity.parse("<xml></xml>") ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/identity_provider_spec.rb
Ruby
mit
45
main
1,569
# frozen_string_literal: true module SAML2 describe IdentityProvider do it "should serialize valid xml" do entity = Entity.new entity.entity_id = "http://sso.canvaslms.com/SAML2" entity.organization = Organization.new("Canvas", "Canvas by Instructure", "https://www.canvaslms.com/") contac...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/name_id_spec.rb
Ruby
mit
45
main
634
# frozen_string_literal: true module SAML2 describe NameID do describe "#inspect" do it "returns just the id if that's the only present field" do expect(NameID.new("id").inspect).to eql '"id"' end it "returns the id and format if both are present" do expect(NameID.new("id", "fo...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/attribute_statement_spec.rb
Ruby
mit
45
main
2,574
# frozen_string_literal: true module SAML2 describe AttributeStatement do describe "#to_h" do it "works" do attr_statement = Response.parse(fixture("response_with_attribute_signed.xml")) .assertions.first.attribute_statements.first expect(attr_statement.to_h...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/indexed_object_spec.rb
Ruby
mit
45
main
1,133
# frozen_string_literal: true module SAML2 describe IndexedObject do describe "#default?" do it "always returns a boolean" do acs = Endpoint::Indexed.new("a", 0) expect(acs.default?).to be false expect(acs.default_defined?).to be false end it "#default_defined? works" d...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/endpoint_spec.rb
Ruby
mit
45
main
608
# frozen_string_literal: true module SAML2 describe Endpoint do describe "#effective_response_location" do it "returns the location if response_location is not present" do expect(Endpoint.new("http://example.com", Bindings::HTTPRedirect::URN).effective_response_location).to eql "http://example.com"...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/key_info_spec.rb
Ruby
mit
45
main
718
# frozen_string_literal: true module SAML2 describe KeyInfo do describe ".format_fingerprint" do it "strips non-hexadecimal characters" do expect(KeyInfo.format_fingerprint("\u200F abcdefghijklmnop 1234567890-\n a1")) .to eq("ab:cd:ef:12:34:56:78:90:a1") end end describe "#...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/service_provider_spec.rb
Ruby
mit
45
main
4,591
# frozen_string_literal: true module SAML2 describe ServiceProvider do it "should serialize valid xml" do entity = Entity.new entity.entity_id = "http://sso.canvaslms.com/SAML2" entity.organization = Organization.new("Canvas", "Canvas by Instructure", "https://www.canvaslms.com/") contact...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/logout_request_spec.rb
Ruby
mit
45
main
1,028
# frozen_string_literal: true module SAML2 describe LogoutRequest do let(:idp) { Entity.parse(fixture("identity_provider.xml")).roles.first } let(:logout_request) do LogoutRequest.initiate(idp, NameID.new("issuer"), NameID.new("jacob", ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/message_spec.rb
Ruby
mit
45
main
752
# frozen_string_literal: true module SAML2 describe Message do describe ".parse" do it "complains about invalid XML" do expect { Message.parse("garbage") }.to raise_error(CorruptMessage) end it "complains about getting the wrong type if calling on a subclass, and you get a different ty...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/attribute_spec.rb
Ruby
mit
45
main
4,779
# frozen_string_literal: true module SAML2 describe Attribute do def serialize(attribute) doc = Nokogiri::XML::Builder.new do |builder| builder["saml"].Root("xmlns:saml" => Namespaces::SAML) do |root| attribute.build(root) root.parent.child["xmlns:saml"] = Namespaces::SAML ...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/response_spec.rb
Ruby
mit
45
main
17,743
# frozen_string_literal: true module SAML2 describe Response do let(:sp_entity) { Entity.parse(fixture("service_provider.xml")) } let(:sp) { sp_entity.roles.first } let(:request) do request = AuthnRequest.parse(fixture("authnrequest.xml")) request.resolve(sp) request end let(:...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/attribute_consuming_service_spec.rb
Ruby
mit
45
main
5,507
# frozen_string_literal: true module SAML2 describe AttributeConsumingService do describe "#create_statement" do let(:acs) do requested_attributes = [ RequestedAttribute.new("name", true), RequestedAttribute.new("age") ] AttributeConsumingService.new("my service"...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/conditions_spec.rb
Ruby
mit
45
main
1,608
# frozen_string_literal: true module SAML2 describe Conditions do it "empty should be valid" do expect(Conditions.new.valid?).to be true end it "should be invalid with unknown condition" do conditions = Conditions.new conditions << Conditions::Condition.new expect(conditions.vali...
github
instructure/ruby-saml2
https://github.com/instructure/ruby-saml2
spec/lib/saml2/indexed_object/array_spec.rb
Ruby
mit
45
main
1,307
# frozen_string_literal: true module SAML2 module IndexedObject describe Array do it "should sort by index" do acses = Endpoint::Indexed::Array.new( [Endpoint::Indexed.new("b", 1), Endpoint::Indexed.new("a", 0)] ) expect(acses.map(&:location)).to eq %w[a b] ...