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
cxn03651/write_xlsx
https://github.com/cxn03651/write_xlsx
test/drawing/test_drawing_shape_04.rb
Ruby
mit
305
main
3,473
# -*- coding: utf-8 -*- require 'helper' require 'write_xlsx/workbook' require 'write_xlsx/worksheet' require 'write_xlsx/shape' require 'write_xlsx/drawing' require 'stringio' class DrawingShape04 < Minitest::Test def setup @workbook = WriteXLSX.new(StringIO.new) @worksheet = @workbook.add_worksheet('') ...
github
cxn03651/write_xlsx
https://github.com/cxn03651/write_xlsx
test/drawing/test_drawing_image_01.rb
Ruby
mit
305
main
2,074
# -*- coding: utf-8 -*- require 'helper' require 'write_xlsx/drawing' class DrawingImage011 < Minitest::Test def test_drawing_image_01 @obj = Writexlsx::Drawings.new dimensions = [ 2, 1, 0, 0, 3, 6, 533257, 190357, 1219200, 190500 ] drawing = Writexlsx::Drawing.new( 2, dimensions, 114285...
github
cxn03651/write_xlsx
https://github.com/cxn03651/write_xlsx
test/drawing/test_drawing_shape_02.rb
Ruby
mit
305
main
2,631
# -*- coding: utf-8 -*- require 'helper' require 'write_xlsx/shape' require 'write_xlsx/drawing' class DrawingShape02 < Minitest::Test def test_drawing_shape_02 shape = Writexlsx::Shape.new # Set shape properties via []= method shape.id = 1000 shape.name = 'Connector 1' # Set bulk shape propert...
github
cxn03651/write_xlsx
https://github.com/cxn03651/write_xlsx
test/drawing/test_drawing_shape_01.rb
Ruby
mit
305
main
2,265
# -*- coding: utf-8 -*- require 'helper' require 'write_xlsx/shape' require 'write_xlsx/drawing' class DrawingShape01 < Minitest::Test def test_drawing_shape_01 shape = Writexlsx::Shape.new shape.id = 1000 @obj = Writexlsx::Drawings.new @obj.embedded = 1 dimensions = [ 4, 8, 209550, 95250...
github
cxn03651/write_xlsx
https://github.com/cxn03651/write_xlsx
test/drawing/test_drawing_chart_01.rb
Ruby
mit
305
main
1,799
# -*- coding: utf-8 -*- require 'helper' require 'write_xlsx/drawing' class DrawingChart011 < Minitest::Test def test_drawing_chart_01 @obj = Writexlsx::Drawings.new dimensions = [4, 8, 457200, 104775, 12, 22, 152400, 180975] drawing = Writexlsx::Drawing.new( 1, dimensions, nil, nil, nil, nil, 1, ...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
foursquare2.gemspec
Ruby
mit
305
master
1,792
# Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = "foursquare2" s.version = "2.0.2" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_ruby...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
Rakefile
Ruby
mit
305
master
697
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 'rake/testtask' Rake::TestTask.new(:test) do |test| test.libs << ...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2.rb
Ruby
mit
305
master
1,059
require "faraday" require "faraday_middleware" require "hashie/mash" __dir__ module Foursquare2 class << self FIELDS = [:client_id, :client_secret, :api_version, :ssl, :connection_middleware, :locale].freeze attr_accessor(*FIELDS) def filter(tips, term) tip = [] tips&.items&.each do |check_...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/campaigns.rb
Ruby
mit
305
master
2,659
module Foursquare2 module Campaigns # Retrieve information about a campaign # # param [String] campaign_id The ID of the venue def campaign(campaign_id, options = {}) response = connection.get do |req| req.url "campaigns/#{campaign_id}", options end return_error_or_body(respo...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/lists.rb
Ruby
mit
305
master
4,688
module Foursquare2 module Lists # Retrieve information about a list. # # @param [String] list_id - The id of the list to retrieve. # @param [Hash] options # @option options Integer :limit - Number of results to return, up to 200. # @option options Integer :offset - The number of results to sk...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/venuegroups.rb
Ruby
mit
305
master
2,412
module Foursquare2 module Venuegroups # Retrieve information about a venuegroup # # param [String] group_id The ID of the venuegroup def venuegroup(group_id, options={}) response = connection.get do |req| req.url "venuegroups/#{group_id}", options end return_error_or_body(re...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/users.rb
Ruby
mit
305
master
9,369
module Foursquare2 module Users # Get user's leaderboard details # # @param [Hash] options # @option options Integer :neighbors Number of friends' scores adjacent to your score def leaderboard(options={}) response = connection.get do |req| req.url "users/leaderboard", options ...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/specials.rb
Ruby
mit
305
master
1,883
module Foursquare2 module Specials # Retrieve information about a special # # param [String] special_id The ID of the special def special(special_id, options={}) response = connection.get do |req| req.url "specials/#{special_id}", options end return_error_or_body(response, r...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/checkins.rb
Ruby
mit
305
master
4,681
module Foursquare2 module Checkins # Retrieve information about a single checkin. # # @param [String] checkin_id the ID of the checkin. # @param [Hash] options # @option options String :signature - Signature allowing users to bypass the friends-only access check on checkins def checkin(check...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/pages.rb
Ruby
mit
305
master
2,255
module Foursquare2 module Pages # Get information about a page. # # /!\ A page is considered by Foursquare as a user. # @param [Integer] user_id - Page to get information for. def page(user_id, options = {}) response = connection.get do |req| req.url "pages/#{user_id}", options ...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/events.rb
Ruby
mit
305
master
626
module Foursquare2 module Events # Retrieve information about an event # # param [String] event_id The ID of the event def event(event_id, options = {}) response = connection.get do |req| req.url "events/#{event_id}", options end return_error_or_body(response, response.body....
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/venues.rb
Ruby
mit
305
master
14,523
module Foursquare2 module Venues # Retrieve information about a venue # # param [String] venue_id The ID of the venue def venue(venue_id, options={}) response = connection.get do |req| req.url "venues/#{venue_id}", options end return_error_or_body(response, response.body.re...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/tips.rb
Ruby
mit
305
master
3,179
module Foursquare2 module Tips # Retrieve information about a tip. # # param [String] tip_id - The id of the tip to retrieve. def tip(tip_id, options={}) response = connection.get do |req| req.url "tips/#{tip_id}", options end return_error_or_body(response, response.body.res...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/client.rb
Ruby
mit
305
master
3,549
require 'forwardable' module Foursquare2 class Client DEFAULT_CONNECTION_MIDDLEWARE = [ Faraday::Request::Multipart, Faraday::Request::UrlEncoded, Foursquare2::MashifyWrapper, FaradayMiddleware::ParseJson ].freeze extend Forwardable include Venues include Venuegroups ...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/api_error.rb
Ruby
mit
305
master
411
module Foursquare2 class APIError < StandardError attr_reader :code attr_reader :detail attr_reader :type attr_reader :response def initialize(error, response) @code = error.code @detail = error.errorDetail @type = error.errorType @response = response end def ...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/settings.rb
Ruby
mit
305
master
1,155
module Foursquare2 module Settings # Retrive all settings for the authenticated user. def settings(options={}) response = connection.get do |req| req.url "settings/all", options end return_error_or_body(response, response.body.response.settings) end # Retrieve a single sett...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
lib/foursquare2/photos.rb
Ruby
mit
305
master
1,999
module Foursquare2 module Photos # Retrieve a photo # # @params [String] photo_id - The ID of the photo def photo(photo_id, options={}) response = connection.get do |req| req.url "photos/#{photo_id}", options end return_error_or_body(response, response.body.response.photo) ...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
test/test_venuegroups.rb
Ruby
mit
305
master
1,238
require "helper" class TestVenuegroups < Test::Unit::TestCase context "When using the foursquare API and working with venuegroups" do setup do @client = foursquare_test_client end should "get a venuegroup" do stub_get("https://api.foursquare.com/v2/venuegroups/4e15cd13b61c42e7c54e5bb6?oauth...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
test/test_campaigns.rb
Ruby
mit
305
master
1,530
require "helper" class TestCampaigns < Test::Unit::TestCase context "When using the foursquare API and working with campaigns" do setup do @client = foursquare_test_client end should "get a campaign" do stub_get("https://api.foursquare.com/v2/campaigns/4e0deba2922e6f94b1410b79?oauth_token=#...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
test/test_checkins.rb
Ruby
mit
305
master
1,649
require "helper" class TestCheckins < Test::Unit::TestCase context "When using the foursquare API and working with checkins" do setup do @client = foursquare_test_client end should "fetch info for a single checkin" do stub_get("https://api.foursquare.com/v2/checkins/4d572bcc9e508cfab975189b...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
test/test_specials.rb
Ruby
mit
305
master
1,399
require "helper" class TestSpecials < Test::Unit::TestCase context "When using the foursquare API and working with specials" do setup do @client = foursquare_test_client end should "fetch info for a single special" do stub_get("https://api.foursquare.com/v2/specials/4bd876f886ba62b58a6e88b3...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
test/test_client.rb
Ruby
mit
305
master
3,992
require "helper" class TestClient < Test::Unit::TestCase context "when configuring the client at a class level" do should "use the class-assigned attributes for new instances" do Foursquare2.configure do |config| config.client_id = "awesome" config.client_secret = "sauce" config.ap...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
test/test_photos.rb
Ruby
mit
305
master
629
require "helper" class TestPhotos < Test::Unit::TestCase context "When using the foursquare API and working with photos" do setup do @client = foursquare_test_client end should "fetch info for a single photo" do stub_get("https://api.foursquare.com/v2/photos/4d0fb8162d39a340637dc42b?oauth_t...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
test/test_tips.rb
Ruby
mit
305
master
1,149
require "helper" class TestTips < Test::Unit::TestCase context "When using the foursquare API and working with tips" do setup do @client = foursquare_test_client end should "fetch info for a single tip" do stub_get("https://api.foursquare.com/v2/tips/4b5e662a70c603bba7d790b4?oauth_token=#{@...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
test/test_users.rb
Ruby
mit
305
master
6,012
require "helper" class TestUsers < Test::Unit::TestCase context "When using the foursquare API and working with users" do setup do @client = foursquare_test_client end should "fetch user's leaderboard" do stub_get("https://api.foursquare.com/v2/users/leaderboard?oauth_token=#{@client.oauth_...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
test/test_pages.rb
Ruby
mit
305
master
1,507
require "helper" class TestPages < Test::Unit::TestCase context "When using the foursquare API and working with pages" do setup do @client = foursquare_test_client end should "fetch info for a single page" do stub_get("https://api.foursquare.com/v2/pages/14046309?oauth_token=#{@client.oauth...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
test/test_events.rb
Ruby
mit
305
master
791
require "helper" class TestEvents < Test::Unit::TestCase context "When using the foursquare API and working with events" do setup do @client = foursquare_test_client end should "fetch list of event categories" do stub_get("https://api.foursquare.com/v2/events/categories?oauth_token=#{@clien...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
test/helper.rb
Ruby
mit
305
master
1,969
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 "test/unit" require "shoulda" require "matchy" require "fakeweb" require "json" # r...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
test/test_venues.rb
Ruby
mit
305
master
10,500
require "helper" class TestVenues < Test::Unit::TestCase context "When using the foursquare API and working with venues" do setup do @client = foursquare_test_client end should "fetch info for a single venue" do stub_get("https://api.foursquare.com/v2/venues/4b8c3d87f964a520f7c532e3?oauth_t...
github
mattmueller/foursquare2
https://github.com/mattmueller/foursquare2
test/test_lists.rb
Ruby
mit
305
master
2,790
require "helper" class TestLists < Test::Unit::TestCase context "When using the foursquare API and working with lists" do setup do @client = foursquare_test_client @list_id = "4f230d90e4b0b653a21ffd0d" end should "fetch info for a single list" do stub_get("https://api.foursquare.com/v...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
jekyll-github-metadata.gemspec
Ruby
mit
306
main
1,064
# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "jekyll-github-metadata/version" Gem::Specification.new do |spec| spec.name = "jekyll-github-metadata" spec.version = Jekyll::GitHubMetadata::VERSION spec.authors ...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
Gemfile
Ruby
mit
306
main
299
# frozen_string_literal: true source "https://rubygems.org" gemspec gem "faraday", "~> #{ENV["FARADAY_VERSION"]}" if ENV["FARADAY_VERSION"] gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}" if ENV["JEKYLL_VERSION"] group :test do gem "webmock", "~> 3.14" end gem "webrick" if RUBY_VERSION.to_i >= 3
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/repository_compat_spec.rb
Ruby
mit
306
main
2,858
# frozen_string_literal: true require "spec_helper" RSpec.describe(Jekyll::GitHubMetadata::RepositoryCompat) do let(:repo) { Jekyll::GitHubMetadata::Repository.new(nwo) } let(:repo_compat) { repo.repo_compat } context "hubot.github.com" do let(:nwo) { "github/hubot.github.com" } before(:each) { allow(r...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/owner_spec.rb
Ruby
mit
306
main
3,103
# frozen_string_literal: true require "spec_helper" RSpec.describe(Jekyll::GitHubMetadata::Owner) do subject { described_class.new(login) } before(:each) do ENV["JEKYLL_GITHUB_TOKEN"] = "allthespecs" end context "is an ORG" do let(:login) { "jekyll" } let!(:stub) do stub_api("/orgs/#{login}...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/site_github_munger_spec.rb
Ruby
mit
306
main
9,074
require "spec_helper" require "jekyll" require "jekyll-github-metadata/site_github_munger" RSpec.describe(Jekyll::GitHubMetadata::SiteGitHubMunger) do let(:source) { File.expand_path("test-site", __dir__) } let(:dest) { File.expand_path("../tmp/test-site-build", __dir__) } let(:github_namespace) { nil } let(:u...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/repository_spec.rb
Ruby
mit
306
main
5,904
# frozen_string_literal: true require "spec_helper" RSpec.describe(Jekyll::GitHubMetadata::Repository) do let(:repo) { described_class.new(nwo) } before(:each) do ENV["JEKYLL_GITHUB_TOKEN"] = "allthespecs" end context "with the html_url preview API turned on" do let(:nwo) { "jekyll/jekyll" } let!...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/repository_finder_spec.rb
Ruby
mit
306
main
3,470
# frozen_string_literal: true require "spec_helper" RSpec.describe Jekyll::GitHubMetadata::RepositoryFinder do let(:overrides) { { "repository" => "jekyll/another-repo" } } let(:config) { Jekyll::Configuration.from(overrides) } let(:site) { Jekyll::Site.new config } subject { described_class.new(site) } co...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/github_metadata_spec.rb
Ruby
mit
306
main
417
# frozen_string_literal: true require "spec_helper" RSpec.describe(Jekyll::GitHubMetadata) do let(:key_value_pair) { %w(some_key some_value) } it "has a global GitHub API client" do expect(described_class.client).to be_a(Jekyll::GitHubMetadata::Client) end it "does auto_paginate" do expect( de...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/spec_helper.rb
Ruby
mit
306
main
2,985
# frozen_string_literal: true require "jekyll" require "jekyll-github-metadata" require "webmock/rspec" require "pathname" require_relative "spec_helpers/env_helper" require_relative "spec_helpers/integration_helper" require_relative "spec_helpers/web_mock_helper" require_relative "spec_helpers/stub_helper" require_r...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/client_spec.rb
Ruby
mit
306
main
1,972
# frozen_string_literal: true require "spec_helper" RSpec.describe(Jekyll::GitHubMetadata::Client) do let(:token) { "abc1234" } subject { described_class.new(:access_token => token) } it "whitelists certain api calls" do described_class::API_CALLS.each do |method_name| expect(subject).to respond_to(m...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/value_spec.rb
Ruby
mit
306
main
2,824
# frozen_string_literal: true RSpec.describe(Jekyll::GitHubMetadata::Value) do let(:simple_value) { described_class.new(proc { "a value" }) } let(:number_value) { described_class.new(4) } let(:string_value) { described_class.new("petunia my dear") } let(:array_value) { described_class.new(%(oy you there))...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/metadata_drop_spec.rb
Ruby
mit
306
main
2,911
# frozen_string_literal: true require "spec_helper" RSpec.describe(Jekyll::GitHubMetadata::MetadataDrop) do extend IntegrationHelper let(:overrides) { { "repository" => "jekyll/another-repo" } } let(:config) { Jekyll::Configuration.from(overrides) } let(:site) { Jekyll::Site.new config } subject { describe...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/edit_link_tag_spec.rb
Ruby
mit
306
main
5,605
RSpec.describe Jekyll::GitHubMetadata::EditLinkTag do let(:repository_url) { "https://github.com/jekyll/github-metadata" } let(:branch) { "gh-pages" } let(:path) { "/" } let(:source) { { "branch" => branch, "path" => path } } let(:github) { { "repository_url" => repository_url, "source" => source } } let(:c...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/integration_spec.rb
Ruby
mit
306
main
1,949
# frozen_string_literal: true require "spec_helper" require "jekyll" require "jekyll-github-metadata/site_github_munger" RSpec.describe("integration into a jekyll site") do extend IntegrationHelper let!(:stubs) { stub_all_api_requests } before(:each) do # Run Jekyll ENV.delete("JEKYLL_ENV") ENV["J...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/pages_spec.rb
Ruby
mit
306
main
4,859
# frozen_string_literal: true require "spec_helper" RSpec.describe(Jekyll::GitHubMetadata::Pages) do context "enterprise" do before(:each) { ENV["PAGES_ENV"] = "enterprise" } after(:each) { ENV["PAGES_ENV"] = "test" } let(:ghe_domain) { "ghe.io" } it "disables custom domains" do expect(desc...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/spec_helpers/stub_helper.rb
Ruby
mit
306
main
1,707
# frozen_string_literal: true module StubHelper include WebMockHelper # Returns all stubs created. def stub_all_api_requests reset_env_for_stubs stubs = { "/users/jekyll/repos?per_page=100&type=public" => "owner_repos", "/repos/jekyll/github-metadata" => ...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/spec_helpers/integration_helper.rb
Ruby
mit
306
main
2,436
# frozen_string_literal: true module IntegrationHelper def expected_values { "environment" => "dotcom", "hostname" => "github.com", "pages_env" => "dotcom", "pages_hostname" => "github.io", "help_url" => "https://docs.github.com", ...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/spec_helpers/fixture_helper.rb
Ruby
mit
306
main
996
# frozen_string_literal: true module FixtureHelper def in_dest_dir(*files) dest_dir.join(*files) end def dest_dir @dest_dir ||= Pathname.new(File.expand_path("../../tmp/test-site-build", __dir__)) end def source_dir @source_dir ||= Pathname.new(File.expand_path("../test-site", __dir__)) end ...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/spec_helpers/web_mock_helper.rb
Ruby
mit
306
main
1,876
# frozen_string_literal: true module WebMockHelper REQUEST_HEADERS = { "Accept" => %r!application/vnd\.github\.(v3|drax-preview|mercy-preview)\+json!, "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "Content-Type" => "application/json", "User-Agent" => "Octokit Ruby G...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
spec/spec_helpers/env_helper.rb
Ruby
mit
306
main
617
# frozen_string_literal: true module EnvHelper def with_env(*args) env_hash = env_args_to_hash(*args) old_env = {} env_hash.each do |name, value| old_env[name] = ENV[name] ENV[name] = value end yield ensure old_env.each do |name, value| ENV[name] = value end end p...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
script/console.rb
Ruby
mit
306
main
412
# frozen_string_literal: true require "octokit" require "pry" stack = Faraday::RackBuilder.new do |builder| builder.use Octokit::Middleware::FollowRedirects builder.use Octokit::Response::RaiseError builder.use Octokit::Response::FeedParser builder.response :logger builder.adapter Faraday.default_adapter en...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
lib/jekyll-github-metadata/repository_finder.rb
Ruby
mit
306
main
2,344
# frozen_string_literal: true module Jekyll module GitHubMetadata class RepositoryFinder NoRepositoryError = Class.new(Jekyll::Errors::FatalException) attr_reader :site def initialize(site) @site = site end # Public: fetches the repository name with owner to fetch metadata...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
lib/jekyll-github-metadata/client.rb
Ruby
mit
306
main
4,864
# frozen_string_literal: true require "digest" module Jekyll module GitHubMetadata class Client InvalidMethodError = Class.new(NoMethodError) BadCredentialsError = Class.new(StandardError) # Whitelisted API calls. API_CALLS = Set.new(%w( repository organization u...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
lib/jekyll-github-metadata/repository.rb
Ruby
mit
306
main
6,384
# frozen_string_literal: true module Jekyll module GitHubMetadata class Repository attr_reader :nwo, :owner, :name # Defines an instance method that delegates to a hash's key # # hash - a symbol representing the instance method to delegate to. The # instance method shoul...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
lib/jekyll-github-metadata/metadata_drop.rb
Ruby
mit
306
main
4,253
# frozen_string_literal: true require "jekyll" require "forwardable" module Jekyll module GitHubMetadata class MetadataDrop < Jekyll::Drops::Drop extend Forwardable mutable true # See https://github.com/jekyll/jekyll/pull/6338 alias_method :invoke_drop, :[] def key?(key) ...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
lib/jekyll-github-metadata/sanitizer.rb
Ruby
mit
306
main
1,872
# frozen_string_literal: true module Jekyll module GitHubMetadata module Sanitizer extend self # Sanitize an object. # When the resource is either `false`, `true`, `nil` or a number, # it returns the resource as-is. When the resource is an array, # it maps over the entire array,...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
lib/jekyll-github-metadata/pages.rb
Ruby
mit
306
main
2,977
# frozen_string_literal: true module Jekyll module GitHubMetadata class Pages class << self DEFAULTS = { "PAGES_ENV" => "development", "PAGES_API_URL" => "https://api.github.com", "PAGES_HELP_URL" => "https://docs.github.com", "P...
github
jekyll/github-metadata
https://github.com/jekyll/github-metadata
lib/jekyll-github-metadata/site_github_munger.rb
Ruby
mit
306
main
3,125
require "jekyll" require "uri" module Jekyll module GitHubMetadata class SiteGitHubMunger extend Forwardable class << self attr_accessor :global_munger end def_delegators Jekyll::GitHubMetadata, :site, :repository private :repository def initialize(site) Jek...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
stronger_parameters.gemspec
Ruby
apache-2.0
304
main
657
# frozen_string_literal: true require "./lib/stronger_parameters/version" Gem::Specification.new do |spec| spec.name = "stronger_parameters" spec.version = StrongerParameters::VERSION spec.authors = ["Mick Staugaard"] spec.email = ["mick@zendesk.com"] spec.summary = "Type checking and type casting of parame...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
Rakefile
Ruby
apache-2.0
304
main
497
# frozen_string_literal: true require "bundler/setup" require "bump/tasks" require "bundler/gem_tasks" task default: [:test, :fmt] task :test do sh "forking-test-runner test --merge-coverage --quiet" end desc "Format code" task :fmt do sh "rubocop --autocorrect" end desc "Bundle all gemfiles [CMD=]" task :bund...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters.rb
Ruby
apache-2.0
304
main
244
# frozen_string_literal: true require "stronger_parameters/version" require "action_pack" require "stronger_parameters/parameters" require "stronger_parameters/constraints" require "stronger_parameters/controller_support/permitted_parameters"
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/errors.rb
Ruby
apache-2.0
304
main
455
# frozen_string_literal: true module StrongerParameters class InvalidValue attr_reader :value, :message def initialize(value, message) @value = value @message = message end end class InvalidParameter < StandardError attr_reader :key, :value def initialize(invalid_value, key) ...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints.rb
Ruby
apache-2.0
304
main
1,357
# frozen_string_literal: true require "stronger_parameters/constraint" require "stronger_parameters/constraints/string_constraint" require "stronger_parameters/constraints/float_constraint" require "stronger_parameters/constraints/date_constraint" require "stronger_parameters/constraints/date_iso8601_constraint" requi...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/parameters.rb
Ruby
apache-2.0
304
main
5,340
# frozen_string_literal: true require "action_pack" require "action_controller/base" require "action_controller/api" require "action_controller/metal/strong_parameters" require "stronger_parameters/constraints" require "stronger_parameters/errors" module StrongerParameters module Parameters extend ActiveSuppo...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraint.rb
Ruby
apache-2.0
304
main
1,715
# frozen_string_literal: true require "stronger_parameters/errors" module StrongerParameters class Constraint def value(v) v end def |(other) OrConstraint.new(self, other) end def &(other) AndConstraint.new(self, other) end def ==(other) self.class == other.cla...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/boolean_constraint.rb
Ruby
apache-2.0
304
main
472
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class BooleanConstraint < Constraint TRUE_VALUES = [true, "true", "1", 1, "on"].freeze FALSE_VALUES = [false, "false", "0", 0].freeze def value(v) v = v.downcase if v.is_a?(String) return true ...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/hash_constraint.rb
Ruby
apache-2.0
304
main
838
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class HashConstraint < Constraint attr_reader :constraints def initialize(constraints) @constraints = constraints.with_indifferent_access unless constraints.nil? end def value(v) return Inv...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/time_iso8601_constraint.rb
Ruby
apache-2.0
304
main
307
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class TimeIso8601Constraint < Constraint def value(v) Time.iso8601 v rescue ArgumentError, TypeError StrongerParameters::InvalidValue.new(v, "must be an iso8601 time") end end end
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/ulid_constraint.rb
Ruby
apache-2.0
304
main
577
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class UlidConstraint < Constraint # https://www.crockford.com/base32.html INVALID_CHAR_REGEX = /[ilou]|[^a-z0-9]/i ULID_LENGTH = 26 def value(v) return invalid_value(v) unless v.is_a?(String) ...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/date_iso8601_constraint.rb
Ruby
apache-2.0
304
main
307
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class DateIso8601Constraint < Constraint def value(v) Date.iso8601 v rescue ArgumentError, TypeError StrongerParameters::InvalidValue.new(v, "must be an iso8601 date") end end end
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/date_time_iso8601_constraint.rb
Ruby
apache-2.0
304
main
319
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class DateTimeIso8601Constraint < Constraint def value(v) DateTime.iso8601 v rescue ArgumentError, TypeError StrongerParameters::InvalidValue.new(v, "must be an iso8601 datetime") end end end
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/date_time_constraint.rb
Ruby
apache-2.0
304
main
366
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class DateTimeConstraint < Constraint def value(v) return v if v.is_a?(DateTime) begin DateTime.parse v rescue ArgumentError, TypeError StrongerParameters::InvalidValue.new(v, "mus...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/nil_constraint.rb
Ruby
apache-2.0
304
main
239
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class NilConstraint < Constraint def value(v) return v if v.nil? InvalidValue.new(v, "must be an nil") end end end
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/nil_string_constraint.rb
Ruby
apache-2.0
304
main
362
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class NilStringConstraint < Constraint NULL_VALUES = [nil, "", "undefined"].freeze def value(v) if NULL_VALUES.include?(v) nil else StrongerParameters::InvalidValue.new(v, "must be a...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/integer_constraint.rb
Ruby
apache-2.0
304
main
356
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class IntegerConstraint < Constraint def value(v) if v.is_a?(Integer) return v elsif v.is_a?(String) && v.strip.match?(/\A-?\d+\Z/) return v.to_i end InvalidValue.new(v, "mus...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/regexp_constraint.rb
Ruby
apache-2.0
304
main
543
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class RegexpConstraint < Constraint attr_reader :regexp def initialize(regexp) @regexp = regexp @string = StringConstraint.new end def value(v) v = @string.value(v) return v if ...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/file_constraint.rb
Ruby
apache-2.0
304
main
468
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class FileConstraint < Constraint VALID_FILE_TYPES = [ File, StringIO, Rack::Test::UploadedFile, ActionDispatch::Http::UploadedFile ].freeze def value(v) if VALID_FILE_TYPES.an...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/time_constraint.rb
Ruby
apache-2.0
304
main
350
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class TimeConstraint < Constraint def value(v) return v if v.is_a?(Time) begin Time.parse v rescue ArgumentError, TypeError StrongerParameters::InvalidValue.new(v, "must be a time"...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/comparison_constraints.rb
Ruby
apache-2.0
304
main
1,076
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class ComparisonConstraints < Constraint attr_reader :limit def initialize(limit) @limit = limit end def value(*) raise NotImplementedError end def ==(other) super && limit =...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/hex_constraint.rb
Ruby
apache-2.0
304
main
292
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class HexConstraint < Constraint def value(v) return v if v.is_a?(String) && v.match?(/\A[a-f0-9]+\z/i) InvalidValue.new(v, "must be a hexadecimal string") end end end
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/date_constraint.rb
Ruby
apache-2.0
304
main
350
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class DateConstraint < Constraint def value(v) return v if v.is_a?(Date) begin Date.parse v rescue ArgumentError, TypeError StrongerParameters::InvalidValue.new(v, "must be a date"...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/decimal_constraint.rb
Ruby
apache-2.0
304
main
575
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class DecimalConstraint < Constraint def initialize(precision, scale) @precision = precision @scale = scale @regex = /\A-?\d{1,#{precision - scale}}#{"(\\.\\d{1,#{scale}})?" if scale > 0}\Z/ en...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/string_constraint.rb
Ruby
apache-2.0
304
main
1,035
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class StringConstraint < Constraint attr_reader :maximum_length, :minimum_length def initialize(options = {}) @maximum_length = options[:maximum_length] || options[:max_length] @minimum_length = opt...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/float_constraint.rb
Ruby
apache-2.0
304
main
368
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class FloatConstraint < Constraint def value(v) if v.is_a?(Float) return v elsif v.is_a?(String) && v.match?(/\A-?\d+\.\d+\Z/) return v.to_f end StrongerParameters::InvalidVa...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/enumeration_constraint.rb
Ruby
apache-2.0
304
main
446
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class EnumerationConstraint < Constraint attr_reader :allowed def initialize(*allowed) @allowed = allowed end def value(v) return v if allowed.include?(v) InvalidValue.new(v, "must b...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/constraints/array_constraint.rb
Ruby
apache-2.0
304
main
617
# frozen_string_literal: true require "stronger_parameters/constraint" module StrongerParameters class ArrayConstraint < Constraint attr_reader :item_constraint def initialize(item_constraint) @item_constraint = item_constraint end def value(v) if v.is_a?(Array) return v.map do...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
lib/stronger_parameters/controller_support/permitted_parameters.rb
Ruby
apache-2.0
304
main
4,828
# frozen_string_literal: true require "stronger_parameters/constraints" module StrongerParameters module ControllerSupport module PermittedParameters def self.included(klass) klass.extend ClassMethods klass.before_action :permit_parameters end def self.sugar(value) cas...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
test/benchmark.rb
Ruby
apache-2.0
304
main
463
# frozen_string_literal: true require_relative "test_helper" require "benchmark" def build_stack(count, &block) if count.zero? yield else build_stack(count - 1, &block) end end puts(Benchmark.realtime do build_stack(100) do 10000.times do ( StrongerParameters::IntegerConstraint.new ...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
test/controller_test.rb
Ruby
apache-2.0
304
main
1,949
# frozen_string_literal: true require_relative "test_helper" SingleCov.not_covered! class BooksController < ActionController::Base ROUTES = ActionDispatch::Routing::RouteSet.new ROUTES.draw { resources :books } include ROUTES.url_helpers rescue_from(ActionController::ParameterMissing) do |e| if request....
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
test/test_helper.rb
Ruby
apache-2.0
304
main
1,913
# frozen_string_literal: true ENV["RAILS_ENV"] = "test" require "bundler/setup" require "single_cov" SingleCov.setup :minitest require "minitest/mock" require "maxitest/global_must" require "maxitest/autorun" require "rails" require "action_controller" require "rails/generators" require "rails/test_unit/reporter" ...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
test/coverage_test.rb
Ruby
apache-2.0
304
main
315
# frozen_string_literal: true require_relative "test_helper" SingleCov.not_covered! # not testing any code in lib/ describe "Coverage" do it "does not let users add new untested code" do SingleCov.assert_used end it "does not let users add new untested files" do SingleCov.assert_tested end end
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
test/stronger_parameters/version_test.rb
Ruby
apache-2.0
304
main
260
# frozen_string_literal: true require_relative "../test_helper" SingleCov.not_covered! # loaded before SingleCov is loaded describe StrongerParameters::VERSION do it "is a version" do StrongerParameters::VERSION.must_match(/^\d+\.\d+\.\d+/) end end
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
test/stronger_parameters/constraint_test.rb
Ruby
apache-2.0
304
main
3,528
# frozen_string_literal: true require_relative "../test_helper" SingleCov.covered! describe StrongerParameters::Constraint do subject { StrongerParameters::Constraint.new } describe "#value" do permits "abc" end describe "#==" do it "equals itself" do subject.must_equal subject end i...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
test/stronger_parameters/errors_test.rb
Ruby
apache-2.0
304
main
613
# frozen_string_literal: true require_relative "../test_helper" SingleCov.covered! describe StrongerParameters::InvalidValue do it "has a nice message" do error = StrongerParameters::InvalidValue.new(1, "blob") error.message.must_equal "blob" error.value.must_equal 1 end end describe StrongerParamet...
github
zendesk/stronger_parameters
https://github.com/zendesk/stronger_parameters
test/stronger_parameters/parameters_test.rb
Ruby
apache-2.0
304
main
8,951
# frozen_string_literal: true require_relative "../test_helper" SingleCov.covered! uncovered: 3 # Covered in test/controller_test.rb describe StrongerParameters::Parameters do describe ".anything" do subject { ActionController::Parameters.anything } permits "1" permits 1 permits [] end descri...