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 | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/spec_helper.rb | Ruby | mit | 211 | main | 1,807 | # frozen_string_literal: true
# Generate coverage when run locally with rake coverage
require_relative './spec_helper_simplecov.rb' if ENV['COVERAGE']
# Load coverage when run through Travis
if ENV['TRAVIS']
require 'coveralls'
Coveralls.wear!
end
require 'jekyll'
require 'jekyll-algolia'
require 'ostruct'
RSpec... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/jekyll-algolia_spec.rb | Ruby | mit | 211 | main | 15,565 | # frozen_string_literal: true
# rubocop:disable Metrics/BlockLength
require 'spec_helper'
describe(Jekyll::Algolia) do
let(:configurator) { Jekyll::Algolia::Configurator }
let(:current) { Jekyll::Algolia }
let(:extractor) { Jekyll::Algolia::Extractor }
let(:file_browser) { Jekyll::Algolia::FileBrowser }
let... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/integration/settings_spec.rb | Ruby | mit | 211 | main | 5,640 | # frozen_string_literal: true
require_relative './spec_helper'
# Note: Those tests will delete and recreate the index several times, deleting
# any records in it, in order to test the settings.
# Be careful if you're actually testing the record content in the same test
# suite. It is recommended to run thoses tests a... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/integration/object_ids_spec.rb | Ruby | mit | 211 | main | 3,158 | # frozen_string_literal: true
require_relative './spec_helper'
# Note: Those tests will create and delete records and indexes several time.
# rubocop:disable Metrics/BlockLength
describe('storing object ids') do
let(:logger) { Jekyll::Algolia::Logger }
let(:configurator) { Jekyll::Algolia::Configurator }
let(:... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/integration/spec_helper.rb | Ruby | mit | 211 | main | 518 | # frozen_string_literal: true
require 'algoliasearch'
require 'jekyll'
require 'jekyll-algolia'
Algolia.init(
application_id: ENV['ALGOLIA_APPLICATION_ID'],
api_key: ENV['ALGOLIA_API_KEY']
)
RSpec.configure do |config|
config.filter_run(focus: true)
config.fail_fast = true
config.run_all_when_everything_fi... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/integration/main_spec.rb | Ruby | mit | 211 | main | 2,122 | # frozen_string_literal: true
require_relative './spec_helper'
# rubocop:disable Metrics/BlockLength
describe('pushed index') do
before(:all) do
@index = Algolia::Index.new(ENV['ALGOLIA_INDEX_NAME'])
end
describe('built website') do
# Files excluded from indexing should still be written on disk
it ... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/integration/site/Gemfile | Ruby | mit | 211 | main | 885 | # frozen_string_literal: true
source 'https://rubygems.org'
gem 'jekyll', '~> 3.7.3'
# Note: jekyll-remote-theme download themes on each run, which makes tests
# really slow. To workaround the issue, I submitted a PR to add a cache duration
# to the download. It hasn't been merged yet, so we're using the PR fork for... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/integration/site/_plugins/hooks.rb | Ruby | mit | 211 | main | 528 | # frozen_string_literal: true
module Jekyll
module Algolia
# Custom user hooks
module Hooks
def self.should_be_excluded?(filepath)
filepath == 'excluded-from-hook.html'
end
def self.before_indexing_each(record, _node, _context)
record[:added_through_each] = true
rec... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/site/Gemfile | Ruby | mit | 211 | main | 444 | # frozen_string_literal: true
source 'https://rubygems.org'
gem 'jekyll', '~> 3.7.3'
gem 'minima', '~> 2.0'
group :jekyll_plugins do
gem 'github-pages', '~> 183'
gem 'jekyll-algolia', path: '../../'
gem 'jekyll-feed', '~> 0.6'
gem 'jekyll-paginate', '~> 1.1'
gem 'jekyll-tagging', '~> 1.1'
end
# Windows d... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/site/_plugins/algolia.rb | Ruby | mit | 211 | main | 491 | # frozen_string_literal: true
module Jekyll
module Algolia
# Custom user hooks
module Hooks
def self.should_be_excluded?(filepath)
filepath == 'excluded-from-hook.html'
end
def self.before_indexing_each(record, _node, _context)
record[:added_through_each] = true
rec... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/jekyll/algolia/shrinker_spec.rb | Ruby | mit | 211 | main | 8,170 | # frozen_string_literal: true
require 'spec_helper'
# rubocop:disable Metrics/BlockLength
describe(Jekyll::Algolia::Shrinker) do
let(:current) { Jekyll::Algolia::Shrinker }
let(:logger) { Jekyll::Algolia::Logger }
let(:configurator) { Jekyll::Algolia::Configurator }
let(:json) { ::JSON }
describe '.size' do... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/jekyll/algolia/file_browser_spec.rb | Ruby | mit | 211 | main | 28,136 | # frozen_string_literal: true
# rubocop:disable Metrics/BlockLength
require 'spec_helper'
describe(Jekyll::Algolia::FileBrowser) do
let(:current) { Jekyll::Algolia::FileBrowser }
let(:configurator) { Jekyll::Algolia::Configurator }
let(:site) { init_new_jekyll_site }
# Suppress Jekyll logging
before do
... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/jekyll/algolia/overwrites_spec.rb | Ruby | mit | 211 | main | 1,559 | # frozen_string_literal: true
require 'spec_helper'
describe 'overwrites' do
let(:site) { init_new_jekyll_site }
before do
allow(Jekyll.logger).to receive(:info)
allow(Jekyll.logger).to receive(:warn)
end
describe('Jekyll::Document') do
let(:current) { site.__find_file('collection-item.md') }
... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/jekyll/algolia/error_handler_spec.rb | Ruby | mit | 211 | main | 10,727 | # frozen_string_literal: true
# rubocop:disable Metrics/BlockLength
require 'spec_helper'
describe(Jekyll::Algolia::ErrorHandler) do
let(:current) { Jekyll::Algolia::ErrorHandler }
let(:configurator) { Jekyll::Algolia::Configurator }
let(:logger) { Jekyll::Algolia::Logger }
let(:utils) { Jekyll::Algolia::Util... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/jekyll/algolia/progress_bar_spec.rb | Ruby | mit | 211 | main | 1,563 | # frozen_string_literal: true
require 'spec_helper'
describe(Jekyll::Algolia::ProgressBar) do
let(:current) { Jekyll::Algolia::ProgressBar }
let(:configurator) { Jekyll::Algolia::Configurator }
describe '.should_be_silenced?' do
before do
allow(configurator).to receive(:verbose?).and_return(verbose)
... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/jekyll/algolia/logger_spec.rb | Ruby | mit | 211 | main | 3,659 | # frozen_string_literal: true
# rubocop:disable Metrics/BlockLength
require 'spec_helper'
describe(Jekyll::Algolia::Logger) do
let(:current) { Jekyll::Algolia::Logger }
let(:configurator) { Jekyll::Algolia::Configurator }
describe '.known_message' do
let(:io) { double('IO', read: content) }
let(:content... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/jekyll/algolia/extractor_spec.rb | Ruby | mit | 211 | main | 5,748 | # frozen_string_literal: true
require 'spec_helper'
# rubocop:disable Metrics/BlockLength
describe(Jekyll::Algolia::Extractor) do
let(:configurator) { Jekyll::Algolia::Configurator }
let(:filebrowser) { Jekyll::Algolia::FileBrowser }
let(:hooks) { Jekyll::Algolia::Hooks }
let(:current) { Jekyll::Algolia::Extr... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/jekyll/algolia/hooks_spec.rb | Ruby | mit | 211 | main | 2,700 | # frozen_string_literal: true
require 'spec_helper'
# rubocop:disable Metrics/BlockLength
describe(Jekyll::Algolia::Hooks) do
let(:current) { Jekyll::Algolia::Hooks }
describe '.apply_each' do
let(:record) { { name: 'foo' } }
let(:node) { double('Node') }
let(:context) { double('Context') }
let(:... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/jekyll/algolia/utils_spec.rb | Ruby | mit | 211 | main | 7,859 | # frozen_string_literal: true
require 'spec_helper'
# rubocop:disable Metrics/BlockLength
describe(Jekyll::Algolia::Utils) do
let(:current) { Jekyll::Algolia::Utils }
describe '.html_to_text' do
subject { current.html_to_text(html) }
context 'with simple html' do
let(:html) { '<p>This is content</p... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/jekyll/algolia/indexer_spec.rb | Ruby | mit | 211 | main | 25,962 | # frozen_string_literal: true
require 'spec_helper'
# rubocop:disable Metrics/BlockLength
describe(Jekyll::Algolia::Indexer) do
let(:current) { Jekyll::Algolia::Indexer }
let(:configurator) { Jekyll::Algolia::Configurator }
let(:logger) { Jekyll::Algolia::Logger }
let(:error_handler) { Jekyll::Algolia::ErrorH... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | spec/jekyll/algolia/configurator_spec.rb | Ruby | mit | 211 | main | 13,263 | # frozen_string_literal: true
require 'spec_helper'
# rubocop:disable Metrics/BlockLength
describe(Jekyll::Algolia::Configurator) do
let(:current) { Jekyll::Algolia::Configurator }
let(:logger) { Jekyll::Algolia::Logger }
let(:config) { {} }
before do
allow(current).to receive(:config).and_return(config)
... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll-algolia.rb | Ruby | mit | 211 | main | 2,990 | # frozen_string_literal: true
require 'jekyll/commands/algolia'
require 'date'
module Jekyll
# Requirable file, loading all dependencies.
# Methods here are called by the main `jekyll algolia` command
module Algolia
require 'jekyll/algolia/configurator'
require 'jekyll/algolia/error_handler'
require... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/extractor.rb | Ruby | mit | 211 | main | 2,215 | # frozen_string_literal: true
require 'algolia_html_extractor'
module Jekyll
module Algolia
# Module to extract records from Jekyll files
module Extractor
include Jekyll::Algolia
# Public: Extract records from the file
#
# file - The Jekyll file to process
def self.run(file)
... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/shrinker.rb | Ruby | mit | 211 | main | 3,852 | # frozen_string_literal: true
require 'json'
module Jekyll
module Algolia
# Module to shrink a record so it fits in the plan quotas
module Shrinker
include Jekyll::Algolia
# Public: Get the byte size of the object once converted to JSON
# - record: The record to estimate
def self.siz... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/logger.rb | Ruby | mit | 211 | main | 2,927 | # frozen_string_literal: true
module Jekyll
module Algolia
# Display helpful error messages
module Logger
# Public: Silence all Jekyll log output in this block
# Usage:
# Logger.silence do
# # whatever Jekyll code here
# end
#
# This is especially useful when... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/file_browser.rb | Ruby | mit | 211 | main | 12,043 | # frozen_string_literal: true
require 'algolia_html_extractor'
require 'pathname'
require 'time'
module Jekyll
module Algolia
# Module to get information about Jekyll file. Jekyll handles posts, pages,
# collection, etc. They each need specific processing, so knowing which kind
# of file we're working o... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/progress_bar.rb | Ruby | mit | 211 | main | 535 | # frozen_string_literal: true
require 'progressbar'
require 'ostruct'
module Jekyll
module Algolia
# Module to push records to Algolia and configure the index
module ProgressBar
include Jekyll::Algolia
def self.should_be_silenced?
Configurator.verbose?
end
def self.create(o... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/configurator.rb | Ruby | mit | 211 | main | 9,393 | # frozen_string_literal: true
module Jekyll
module Algolia
# Single source of truth for access to configuration variables
module Configurator
include Jekyll::Algolia
@config = {}
# Algolia default values
ALGOLIA_DEFAULTS = {
'extensions_to_index' => nil,
'files_to_ex... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/indexer.rb | Ruby | mit | 211 | main | 13,386 | # frozen_string_literal: true
require 'algoliasearch'
require 'yaml'
require 'algolia_html_extractor'
# rubocop:disable Metrics/ModuleLength
module Jekyll
module Algolia
# Module to push records to Algolia and configure the index
module Indexer
include Jekyll::Algolia
# Public: Init the module
... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/error_handler.rb | Ruby | mit | 211 | main | 8,182 | # frozen_string_literal: true
require 'verbal_expressions'
require 'filesize'
require 'cgi'
module Jekyll
module Algolia
# Catch API errors and display messages
module ErrorHandler
include Jekyll::Algolia
# Public: Stop the execution of the plugin and display if possible
# a human-readabl... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/hooks.rb | Ruby | mit | 211 | main | 2,837 | # frozen_string_literal: true
module Jekyll
module Algolia
# Applying user-defined hooks on the processing pipeline
module Hooks
# Public: Apply the before_indexing_each hook to the record.
# This method is a simple wrapper around methods that can be overwritten
# by users. Using a wrapper ... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/utils.rb | Ruby | mit | 211 | main | 5,836 | # frozen_string_literal: true
require 'nokogiri'
module Jekyll
module Algolia
# Generic language-wide utils
module Utils
# Public: Allow redefining an instance method on the fly with a new one
#
# instance - The instance to overwrite
# method - The method symbol to overwrite
# ... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/overwrites/jekyll-document.rb | Ruby | mit | 211 | main | 441 | # frozen_string_literal: true
module Jekyll
# Overwriting the Jekyll::Document class
class Document
# By default, Jekyll will set the current date (time of build) to any
# collection item. This will break our diff algorithm, so we monkey patch
# this call to return nil if no date is defined and the fil... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/overwrites/jekyll-paginate-pager.rb | Ruby | mit | 211 | main | 631 | # frozen_string_literal: true
module Jekyll
module Paginate
# Disable pagination from jekyll-paginate
#
# This plugin will create pages that contain a list of all items to
# paginate. Those pages won't contain any interesting data to be indexed
# (as it will be duplicated content of the real page... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/overwrites/jekyll-algolia-site.rb | Ruby | mit | 211 | main | 4,696 | # frozen_string_literal: true
module Jekyll
module Algolia
# A Jekyll::Site subclass that overrides process from the parent class to
# create JSON records out of rendered documents and push those records to
# Algolia instead of writing files to disk.
class Site < Jekyll::Site
# We expose a way ... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/overwrites/githubpages-configuration.rb | Ruby | mit | 211 | main | 1,128 | # frozen_string_literal: true
module GitHubPages
# The github-pages gem will automatically disable every plugin that is not in
# the whitelist of plugins allowed by GitHub. This includes any plugin defined
# in the `_plugins` folder as well.
#
# Users of the jekyll-algolia plugin will use custom plugins in _... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/algolia/overwrites/jekyll-tags-link.rb | Ruby | mit | 211 | main | 1,118 | # frozen_string_literal: true
# The default `link` tag allow to link to a specific page, using its relative
# path. Because we might not be indexing the destination of the link, we might
# not have the representation of the page in our data. If that happens, the
# `link` tag fails.
#
# To fix that we'll overwrite the ... |
github | algolia/jekyll-algolia | https://github.com/algolia/jekyll-algolia | lib/jekyll/commands/algolia.rb | Ruby | mit | 211 | main | 1,653 | # frozen_string_literal: true
module Jekyll
module Commands
# Registering the `jekyll algolia` command
class Algolia < Command
class << self
def init_with_program(prog)
prog.command(:algolia) do |command|
command.syntax 'algolia [options]'
command.description '... |
github | jtescher/carrierwave-imageoptimizer | https://github.com/jtescher/carrierwave-imageoptimizer | carrierwave-imageoptimizer.gemspec | Ruby | mit | 211 | master | 1,352 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'carrierwave-imageoptimizer/version'
Gem::Specification.new do |gem|
gem.name = "carrierwave-imageoptimizer"
gem.version = CarrierWave::ImageOptimizer::VERSION
gem.a... |
github | jtescher/carrierwave-imageoptimizer | https://github.com/jtescher/carrierwave-imageoptimizer | spec/carrierwave_imageoptimizer_spec.rb | Ruby | mit | 211 | master | 1,303 | require 'spec_helper'
describe CarrierWave::ImageOptimizer do
describe '#optimize' do
before do
@uploader = Class.new do
include CarrierWave::ImageOptimizer
def current_path; '/tmp/path/to/image.jpg' end
end
end
it 'delegates to a new instance of ImageOptimizer with the curre... |
github | jtescher/carrierwave-imageoptimizer | https://github.com/jtescher/carrierwave-imageoptimizer | spec/spec_helper.rb | Ruby | mit | 211 | master | 201 | require 'simplecov'
require 'coveralls'
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
SimpleCov.start
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
require 'carrierwave-imageoptimizer' |
github | jtescher/carrierwave-imageoptimizer | https://github.com/jtescher/carrierwave-imageoptimizer | lib/carrierwave-imageoptimizer.rb | Ruby | mit | 211 | master | 223 | require "image_optimizer"
require "carrierwave-imageoptimizer/version"
module CarrierWave
module ImageOptimizer
def optimize(options = {})
::ImageOptimizer.new(current_path, options).optimize
end
end
end |
github | serpapi/turbo_tests | https://github.com/serpapi/turbo_tests | turbo_tests.gemspec | Ruby | mit | 210 | master | 1,389 | require_relative "lib/turbo_tests/version"
Gem::Specification.new do |spec|
spec.name = "turbo_tests"
spec.version = TurboTests::VERSION
spec.platform = Gem::Platform::RUBY
spec.date = Time.now.strftime('%Y-%m-%d')
spec.summary = "`turbo_tests` is a drop-in replacement for `grosser/parallel_tests` with incr... |
github | serpapi/turbo_tests | https://github.com/serpapi/turbo_tests | spec/doc_formatter_spec.rb | Ruby | mit | 210 | master | 389 | # This delay visualizes the effect of load time calculation.
# https://github.com/serpapi/turbo_tests/pull/8#issue-583037321
sleep 3
RSpec.describe "Top-level context" do
describe "#instance_method" do
it "does what it's supposed to" do
expect(true).to be_truthy
end
it "doesn't do what it isn't su... |
github | serpapi/turbo_tests | https://github.com/serpapi/turbo_tests | spec/spec_helper.rb | Ruby | mit | 210 | master | 408 | require "bundler/setup"
require "turbo_tests"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
config.expect_with ... |
github | serpapi/turbo_tests | https://github.com/serpapi/turbo_tests | spec/cli_spec.rb | Ruby | mit | 210 | master | 4,565 | RSpec.describe TurboTests::CLI do
before { output }
subject(:output) { `bundle exec turbo_tests -f d #{fixture}`.strip }
context "when the 'seed' parameter was used" do
let(:seed) { 1234 }
subject(:output) { `bundle exec turbo_tests -f d #{fixture} --seed #{seed}`.strip }
context "errors outside o... |
github | serpapi/turbo_tests | https://github.com/serpapi/turbo_tests | lib/turbo_tests.rb | Ruby | mit | 210 | master | 2,141 | # frozen_string_literal: true
require "securerandom"
require "open3"
require "fileutils"
require "json"
require "rspec"
require "parallel_tests"
require "parallel_tests/rspec/runner"
require "turbo_tests/reporter"
require "turbo_tests/runner"
require "turbo_tests/json_rows_formatter"
module TurboTests
autoload :... |
github | serpapi/turbo_tests | https://github.com/serpapi/turbo_tests | lib/turbo_tests/cli.rb | Ruby | mit | 210 | master | 3,032 | # frozen_string_literal: true
require "optparse"
module TurboTests
class CLI
def initialize(argv)
@argv = argv
end
def run
requires = []
formatters = []
tags = []
count = nil
runtime_log = nil
verbose = false
fail_fast = nil
seed = nil
Option... |
github | serpapi/turbo_tests | https://github.com/serpapi/turbo_tests | lib/turbo_tests/runner.rb | Ruby | mit | 210 | master | 7,471 | # frozen_string_literal: true
require "json"
require "parallel_tests/rspec/runner"
require_relative "../utils/hash_extension"
module TurboTests
class Runner
using CoreExtensions
def self.run(opts = {})
files = opts[:files]
formatters = opts[:formatters]
tags = opts[:tags]
start_ti... |
github | serpapi/turbo_tests | https://github.com/serpapi/turbo_tests | lib/turbo_tests/json_rows_formatter.rb | Ruby | mit | 210 | master | 3,858 | # frozen_string_literal: true
require "json"
require "rspec/core"
require "rspec/core/formatters"
require "rspec/core/notifications"
module RSpecExt
def handle_interrupt
if RSpec.world.wants_to_quit
exit!(1)
else
RSpec.world.wants_to_quit = true
end
end
end
RSpec::Core::Runner.singleton_c... |
github | serpapi/turbo_tests | https://github.com/serpapi/turbo_tests | lib/turbo_tests/reporter.rb | Ruby | mit | 210 | master | 4,744 | # frozen_string_literal: true
module TurboTests
class Reporter
attr_writer :load_time
def self.from_config(formatter_config, start_time, seed, seed_used)
reporter = new(start_time, seed, seed_used)
formatter_config.each do |config|
name, outputs = config.values_at(:name, :outputs)
... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | Guardfile | Ruby | bsd-3-clause | 210 | master | 723 | guard 'rspec', cmd: 'bundle exec rspec' do
watch('spec/spec_helper.rb') { 'spec' }
watch('config/routes.rb') { 'spec/controllers' }
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.+)_decorator\.rb$}) ... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | Appraisals | Ruby | bsd-3-clause | 210 | master | 574 | appraise 'spree-4-0' do
gem 'spree', '~> 4.0.0'
gem 'spree_auth_devise', '~> 4.0'
gem 'rails-controller-testing'
end
appraise 'spree-4-1' do
gem 'spree', '~> 4.1.0'
gem 'spree_auth_devise', '~> 4.1.0'
gem 'rails-controller-testing'
end
appraise 'spree-4-2' do
gem 'spree', '~> 4.2.0'
gem 'spree_auth_de... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | Gemfile | Ruby | bsd-3-clause | 210 | master | 236 | source 'https://rubygems.org'
spree_version = 'master'
gem 'spree', github: 'spree/spree', branch: spree_version
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: spree_version
gem 'rails-controller-testing'
gemspec |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | Rakefile | Ruby | bsd-3-clause | 210 | master | 328 | require 'bundler'
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
require 'spree/testing_support/common_rake'
RSpec::Core::RakeTask.new
task default: :spec
desc 'Generates a dummy app for testing'
task :test_app do
ENV['LIB_NAME'] = 'spree_social'
Rake::Task['common:test_app'].invoke('Spree::Use... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | spree_social.gemspec | Ruby | bsd-3-clause | 210 | master | 1,313 | lib = File.expand_path('../lib/', __FILE__)
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
require 'spree_social/version'
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_social'
s.version = SpreeSocial.version
s.summary = 'Adds social network login serv... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | db/migrate/20171028223910_add_db_index_to_user_authentications.rb | Ruby | bsd-3-clause | 210 | master | 221 | class AddDbIndexToUserAuthentications < SpreeExtension::Migration[4.2]
def change
add_index :spree_user_authentications, [:uid, :provider], unique: true
add_index :spree_user_authentications, :user_id
end
end |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | db/migrate/20120120163432_create_user_authentications.rb | Ruby | bsd-3-clause | 210 | master | 249 | class CreateUserAuthentications < SpreeExtension::Migration[4.2]
def change
create_table :spree_user_authentications do |t|
t.integer :user_id
t.string :provider
t.string :uid
t.timestamps null: false
end
end
end |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | db/migrate/20120123163222_create_authentication_methods.rb | Ruby | bsd-3-clause | 210 | master | 311 | class CreateAuthenticationMethods < SpreeExtension::Migration[4.2]
def change
create_table :spree_authentication_methods do |t|
t.string :environment
t.string :provider
t.string :api_key
t.string :api_secret
t.boolean :active
t.timestamps null: false
end
end
end |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | config/routes.rb | Ruby | bsd-3-clause | 210 | master | 426 | Spree::Core::Engine.add_routes do
devise_for :spree_user,
class_name: Spree::User,
only: [:omniauth_callbacks],
controllers: { omniauth_callbacks: 'spree/omniauth_callbacks' },
path: Spree::SocialConfig[:path_prefix]
resources :user_authentications
get 'account... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | config/initializers/devise.rb | Ruby | bsd-3-clause | 210 | master | 621 | SpreeSocial::OAUTH_PROVIDERS.each do |provider|
SpreeSocial.init_provider(provider[1])
end
OmniAuth.config.logger = Logger.new(STDOUT)
OmniAuth.logger.progname = 'omniauth'
OmniAuth.config.on_failure = proc do |env|
env['devise.mapping'] = Devise.mappings[Spree.user_class.table_name.singularize.to_sym]
controll... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | lib/spree_social.rb | Ruby | bsd-3-clause | 210 | master | 293 | require 'spree_core'
require 'spree_auth_devise'
require 'omniauth-twitter'
require 'omniauth-facebook'
require 'omniauth-github'
require 'omniauth-google-oauth2'
require 'omniauth-amazon'
require 'spree_social/engine'
require 'spree_social/version'
require 'deface'
require 'spree_extension' |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | lib/generators/spree_social/install/install_generator.rb | Ruby | bsd-3-clause | 210 | master | 820 | module SpreeSocial
module Generators
class InstallGenerator < Rails::Generators::Base
class_option :auto_run_migrations, type: :boolean, default: false
def add_stylesheets
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/spree_social\n", before:... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | lib/spree_social/engine.rb | Ruby | bsd-3-clause | 210 | master | 2,844 | module SpreeSocial
OAUTH_PROVIDERS = [
%w(Facebook facebook true),
%w(Twitter twitter false),
%w(Github github false),
%w(Google google_oauth2 true),
%w(Amazon amazon false)
]
class Engine < Rails::Engine
engine_name 'spree_social'
config.autoload_paths += %W(#{config.root}/lib)
... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | lib/spree_social/version.rb | Ruby | bsd-3-clause | 210 | master | 310 | module SpreeSocial
module_function
# Returns the version of the currently loaded SpreeSocial as a
# <tt>Gem::Version</tt>.
def version
Gem::Version.new VERSION::STRING
end
module VERSION
MAJOR = 3
MINOR = 3
TINY = 2
STRING = [MAJOR, MINOR, TINY].compact.join('.')
end
end |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | spec/models/spree/authentication_method_spec.rb | Ruby | bsd-3-clause | 210 | master | 460 | RSpec.describe Spree::AuthenticationMethod, type: :model do
let(:user) { create(:user) }
describe '#available_for' do
before do
Spree::AuthenticationMethod.create!(provider: 'facebook', environment: Rails.env, api_key: 'test', api_secret: 'test')
end
context 'without users' do
it 'returns ... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | spec/models/spree/user_decorator_spec.rb | Ruby | bsd-3-clause | 210 | master | 1,585 | RSpec.describe Spree::User, type: :model do
let(:user) { create(:user) }
let(:omni_params) { { 'provider' => 'twitter', 'uid' => 12_345 } }
let(:auths) { double 'auths' }
context '.apply_omniauth' do
before { allow(user).to receive(:user_authentications).and_return(auths) }
it 'builds an associated au... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | spec/support/capybara.rb | Ruby | bsd-3-clause | 210 | master | 579 | require 'capybara/rspec'
require 'capybara/rails'
require 'capybara-screenshot/rspec'
require "selenium-webdriver"
RSpec.configure do |config|
config.include Rack::Test::Methods, type: :requests
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new app,
browser: :chrome,
options... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | spec/support/database_cleaner.rb | Ruby | bsd-3-clause | 210 | master | 390 | require 'database_cleaner'
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with :truncation
end
config.before do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, :js) do
DatabaseCleaner.strategy = :truncation
end
config.before do
DatabaseClean... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | spec/support/spree.rb | Ruby | bsd-3-clause | 210 | master | 399 | require 'spree/testing_support/factories'
require 'spree/testing_support/controller_requests'
require 'spree/testing_support/authorization_helpers'
require 'spree/testing_support/url_helpers'
require 'spree/testing_support/capybara_ext'
RSpec.configure do |config|
config.include Spree::TestingSupport::ControllerRequ... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | spec/controllers/spree/omniauth_callbacks_controller_spec.rb | Ruby | bsd-3-clause | 210 | master | 5,239 | RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
let(:user) { create(:user) }
let(:omni_params) { double('omni', :[] => nil).as_null_object }
let(:order) { double('Spree::Order', associate_user: nil) }
before do
Rails.application.routes.default_url_options[:host] = 'test.host'
re... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | spec/lib/spree_social/engine_spec.rb | Ruby | bsd-3-clause | 210 | master | 456 | RSpec.describe SpreeSocial do
context 'constants' do
it { is_expected.to be_const_defined(:OAUTH_PROVIDERS) }
it 'contain all providers' do
oauth_providers = [
%w(Amazon amazon false),
%w(Facebook facebook true),
%w(Twitter twitter false),
%w(Github github false),
... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | spec/features/spree/sign_in_spec.rb | Ruby | bsd-3-clause | 210 | master | 2,722 | RSpec.feature 'signing in using Omniauth', :js do
context 'facebook' do
background do
Spree::AuthenticationMethod.create!(
provider: 'facebook',
api_key: 'fake',
api_secret: 'fake',
environment: Rails.env,
active: true)
OmniAuth.config.test_mode = true
Omn... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | spec/features/spree/admin/authentication_methods_configuration_spec.rb | Ruby | bsd-3-clause | 210 | master | 2,036 | RSpec.feature 'Admin Authentication Methods', :js do
stub_authorization!
context 'elements' do
scenario 'has configuration tab' do
visit spree.admin_path
click_link 'Configuration'
expect(page).to have_text 'Social Authentication Methods'
end
end
context 'when no auth methods exists'... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | app/models/spree/authentication_method.rb | Ruby | bsd-3-clause | 210 | master | 485 | require 'stringex'
class Spree::AuthenticationMethod < ActiveRecord::Base
validates :provider, :api_key, :api_secret, presence: true
def self.active_authentication_methods?
where(environment: ::Rails.env, active: true).exists?
end
scope :available_for, lambda { |user|
return none unless user
sc ... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | app/models/spree/user_decorator.rb | Ruby | bsd-3-clause | 210 | master | 726 | # frozen_string_literal: true
module Spree
module UserDecorator
def self.prepended(base)
base.has_many :user_authentications, dependent: :destroy
base.devise :omniauthable
end
def apply_omniauth(omniauth)
skip_signup_providers = SpreeSocial::OAUTH_PROVIDERS.map { |p| p[1] if p[2] == '... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | app/overrides/add_socials_to_login.rb | Ruby | bsd-3-clause | 210 | master | 619 | Deface::Override.new(
virtual_path: 'spree/user_registrations/new',
name: 'add_socials_to_login_extras',
insert_after: '[data-hook="login_extras"]',
text: '<%= render partial: "spree/shared/social" unless session[:omniauth] %>'
)
Deface::Override.new(
virtual_path: 'spree/user_sessions/new',
name: 'add_soc... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | app/overrides/add_socials_to_admin_configuration.rb | Ruby | bsd-3-clause | 210 | master | 341 | Deface::Override.new(
virtual_path: 'spree/admin/shared/sub_menu/_configuration',
name: 'add_social_providers_link_configuration_menu',
insert_bottom: '[data-hook="admin_configurations_sidebar_menu"]',
text: '<%= configurations_sidebar_menu_item Spree.t(:social_authentication_methods), spree.admin_authenticatio... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | app/helpers/spree/omniauth_helper.rb | Ruby | bsd-3-clause | 210 | master | 300 | module Spree
module OmniauthHelper
def path_for_omniauth(user, provider)
if Gem.loaded_specs['spree_auth_devise'].version >= Gem::Version.create('3.2.0')
omniauth_authorize_url(user, provider)
else
omniauth_authorize_path(user, provider)
end
end
end
end |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | app/controllers/spree/omniauth_callbacks_controller.rb | Ruby | bsd-3-clause | 210 | master | 2,712 | class Spree::OmniauthCallbacksController < Devise::OmniauthCallbacksController
include Spree::Core::ControllerHelpers::Common
include Spree::Core::ControllerHelpers::Order
include Spree::Core::ControllerHelpers::Auth
include Spree::Core::ControllerHelpers::Store
if defined?(Spree::Core::ControllerHelpers::Cur... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | app/controllers/spree/user_authentications_controller.rb | Ruby | bsd-3-clause | 210 | master | 402 | class Spree::UserAuthenticationsController < Spree::BaseController
def index
@authentications = spree_current_user.user_authentications if spree_current_user
end
def destroy
@authentication = spree_current_user.user_authentications.find(params[:id])
@authentication.destroy
flash[:notice] = Spree.... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | app/controllers/spree/user_registrations_controller_decorator.rb | Ruby | bsd-3-clause | 210 | master | 501 | module Spree
module UserRegistrationsControllerDecorator
def self.prepend(base)
base.after_action :clear_omniauth, only: :create
end
private
def build_resource(*args)
super
@spree_user.apply_omniauth(session[:omniauth]) if session[:omniauth]
@spree_user
end
def clear... |
github | spree-contrib/spree_social | https://github.com/spree-contrib/spree_social | app/controllers/spree/admin/authentication_methods_controller.rb | Ruby | bsd-3-clause | 210 | master | 538 | module Spree
module Admin
class AuthenticationMethodsController < ResourceController
create.after :update_oauth_method
update.after :update_oauth_method
private
def update_oauth_method
auth_method = params[:authentication_method]
return unless auth_method[:active] == 'tru... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | Rakefile | Ruby | mit | 210 | master | 564 | require 'rubygems'
begin
require 'bundler'
rescue LoadError => e
warn e.message
warn 'Run `gem install bundler` to install Bundler.'
exit -1
end
begin
Bundler.setup(:development)
rescue Bundler::BundlerError => e
warn e.message
warn 'Run `bundle install` to install missing gems.'
exit e.status_code
en... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | usage_with_inlined_dsl.rb | Ruby | mit | 210 | master | 1,473 | require_relative './lib/gqli'
class ContentfulClient
extend GQLi::DSL # Makes DSL available at a class level
include GQLi::DSL # Makes DSL available at an object level
SPACE_ID = 'cfexampleapi'
ACCESS_TOKEN = 'b4c0n73n7fu1'
CONTENTFUL_GQL = GQLi::Client.new(
"https://graphql.contentful.com/content/v1/sp... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | usage.rb | Ruby | mit | 210 | master | 1,694 | require_relative './lib/gqli'
puts GQLi::DSL.query {
__on('Foo') {
bar
}
}.to_gql
puts GQLi::DSL.query {
viewer {
login
repositories(first: 10) {
edges {
node {
nameWithOwner
watchers(first: 10) {
edges {
node {
login
... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | Guardfile | Ruby | mit | 210 | master | 569 | group :green_red_refactor, halt_on_fail: true do
guard :rspec, cmd: "bundle exec rspec" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)
# Feel free to open issues for suggestions and improvements
# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) { rspec.spec_dir }
w... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | usage_introspection.rb | Ruby | mit | 210 | master | 1,235 | require_relative './lib/gqli'
SPACE_ID = 'cfexampleapi'
ACCESS_TOKEN = 'b4c0n73n7fu1'
CONTENTFUL_GQL = GQLi::Client.new(
"https://graphql.contentful.com/content/v1/spaces/#{SPACE_ID}",
headers: { "Authorization" => "Bearer #{ACCESS_TOKEN}" }
)
CatBase = GQLi::DSL.fragment('CatBase', 'Cat') {
name
likes
live... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | gqli.gemspec | Ruby | mit | 210 | master | 1,527 | require File.expand_path('../lib/gqli/version', __FILE__)
Gem::Specification.new do |gem|
gem.name = 'gqli'
gem.version = GQLi::VERSION
gem.summary = 'GraphQL client for humans'
gem.description = 'GraphQL client with simple interface, designed for developer happiness'
gem.license ... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | lib/gqli.rb | Ruby | mit | 210 | master | 202 | # frozen_string_literal: true
require_relative './gqli/dsl'
require_relative './gqli/client'
require_relative './gqli/introspection'
require_relative './gqli/version'
require_relative './gqli/clients' |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | lib/gqli/subscription.rb | Ruby | mit | 210 | master | 508 | # frozen_string_literal: true
module GQLi
# Subscription node
class Subscription < Base
# Serializes to a GraphQL string
def to_gql
result = <<~GQL
subscription #{__name ? __name + ' ' : ''}{
#{__nodes.map(&:to_gql).join("\n")}
}
GQL
result.lstrip
end
# D... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | lib/gqli/query.rb | Ruby | mit | 210 | master | 514 | # frozen_string_literal: true
require_relative './base'
module GQLi
# Query node
class Query < Base
# Serializes to a GraphQL string
def to_gql
result = <<~GQL
query #{__name ? __name + ' ' : ''}{
#{__nodes.map(&:to_gql).join("\n")}
}
GQL
result.lstrip
end
... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | lib/gqli/fragment.rb | Ruby | mit | 210 | master | 458 | # frozen_string_literal: true
require_relative './base'
require_relative './node'
module GQLi
# Fragment wrapper
class Fragment < Base
attr_reader :__on_type
def initialize(name, on, &block)
super(name, 0, &block)
@__on_type = on
end
# Serializes to a GraphQL string
def to_gql
... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | lib/gqli/enum_value.rb | Ruby | mit | 210 | master | 259 | # frozen_string_literal: true
module GQLi
# Wrapper for Enum values
class EnumValue
attr_reader :value
def initialize(value)
@value = value
end
# Serializes the enum value to string
def to_s
value.to_s
end
end
end |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | lib/gqli/node.rb | Ruby | mit | 210 | master | 1,377 | # frozen_string_literal: true
require_relative './base'
module GQLi
# Node wrapper
class Node < Base
attr_reader :__params
def initialize(name, params = {}, depth = 1, &block)
super(name, depth, &block)
@__params = params
end
# Serializes to a GraphQL string
def to_gql
resu... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | lib/gqli/mutation.rb | Ruby | mit | 210 | master | 496 | # frozen_string_literal: true
module GQLi
# Mutation node
class Mutation < Base
# Serializes to a GraphQL string
def to_gql
result = <<~GQL
mutation #{__name ? __name + ' ' : ''}{
#{__nodes.map(&:to_gql).join("\n")}
}
GQL
result.lstrip
end
# Delegates its... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | lib/gqli/client.rb | Ruby | mit | 210 | master | 2,296 | # frozen_string_literal: true
require 'http'
require 'json'
require_relative './response'
require_relative './introspection'
require_relative './version'
module GQLi
# GraphQL HTTP Client
class Client
attr_reader :url, :params, :headers, :validate_query, :schema, :options
def initialize(url, params: {}, ... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | lib/gqli/dsl.rb | Ruby | mit | 210 | master | 1,777 | # frozen_string_literal: true
require_relative './query'
require_relative './mutation'
require_relative './subscription'
require_relative './fragment'
require_relative './enum_value'
module GQLi
# GraphQL-like DSL methods
module DSL
# Creates a Query object
#
# Can be used at a class level
def sel... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | lib/gqli/base.rb | Ruby | mit | 210 | master | 1,452 | # frozen_string_literal: true
require_relative './enum_value'
module GQLi
# Base class for GraphQL type wrappers
class Base
attr_reader :__name, :__depth, :__nodes
def initialize(name = nil, depth = 0, &block)
@__name = name
@__depth = depth
@__nodes = []
instance_eval(&block) unl... |
github | contentful-labs/gqli.rb | https://github.com/contentful-labs/gqli.rb | lib/gqli/response.rb | Ruby | mit | 210 | master | 663 | # frozen_string_literal: true
require 'hashie/mash'
module GQLi
# Response object wrapper
class Response
attr_reader :data, :errors, :query
def initialize(data, errors, query)
@data = Hashie::Mash.new(data)
@errors = parse_errors(errors)
@query = query
end
private
# Accept... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.