repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
mitixx/abilitysheet
lib/tasks/ts_routes.rake
<reponame>mitixx/abilitysheet namespace :ts do TS_ROUTES_FILENAME = "#{Rails.root}/app/javascript/lib/routes.ts".freeze desc "Generate #{TS_ROUTES_FILENAME}" task routes: :environment do Rails.logger.info("Generating #{TS_ROUTES_FILENAME}") source = TsRoutes.generate(exclude: [/admin/, /active_storage/])...
mitixx/abilitysheet
lib/rails_log_silencer.rb
<gh_stars>10-100 # frozen_string_literal: true class RailsLogSilencer def initialize(app, paths) @app = app @paths = paths end def call(env) if @paths.include?(env['PATH_INFO']) ::Rails.logger.silence { @app.call(env) } else @app.call(env) end end end
mitixx/abilitysheet
app/services/application_service.rb
<filename>app/services/application_service.rb # frozen_string_literal: true class ApplicationService end
mitixx/abilitysheet
app/controllers/api/v1/sheets_controller.rb
# frozen_string_literal: true class Api::V1::SheetsController < Api::V1::BaseController def index render json: { sheets: Sheet.active.map(&:schema) } end def list render json: { sheets: Sheet.order(:id) } end end
mitixx/abilitysheet
app/models/concerns/score/api.rb
# frozen_string_literal: true module Score::Api extend ActiveSupport::Concern included do def schema { sheet_id: sheet_id, title: title, state: state, score: score, bp: bp, version: version, updated_at: updated_at } end def self.pie ...
mitixx/abilitysheet
app/models/concerns/user/devise_methods.rb
# frozen_string_literal: true module User::DeviseMethods extend ActiveSupport::Concern included do def self.find_first_by_auth_conditions(warden_conditions) conditions = warden_conditions.dup login = conditions.delete(:login) if login find_by('username = :value OR iidxid = :value OR ...
mitixx/abilitysheet
app/models/concerns/user/ist.rb
<reponame>mitixx/abilitysheet<gh_stars>10-100 # frozen_string_literal: true require 'ist_client' module User::Ist extend ActiveSupport::Concern FROM_IST_TO_AB = { '旋律のドグマ~Miserables~' => '旋律のドグマ ~Misérables~', '火影' => '焱影' }.freeze SEARCH_PARAMS = { q: { chart_level_eq: 12, chart_play_...
mitixx/abilitysheet
spec/rails_helper.rb
<reponame>mitixx/abilitysheet # frozen_string_literal: true ENV['RAILS_ENV'] ||= 'test' require 'spec_helper' require File.expand_path('../config/environment', __dir__) require 'rspec/rails' Dir[Rails.root.join('spec/support/**/*.rb')].sort.each { |f| require f } ActiveRecord::Migration.maintain_test_schema! RSpec.c...
mitixx/abilitysheet
spec/systems/admin/rails_admin_spec.rb
# frozen_string_literal: true feature RailsAdmin, type: :system do given(:user) { create(:user, id: 1) } background { login(user) } context '管理者の場合' do background do user.update!(role: 100) visit rails_admin_path end scenario '管理者ページが閲覧できる' do expect(page).to have_content('サイト管理')...
JonRowe/wrapup
lib/wrapup.rb
require "wrapup/version" require "wrapup/wrap" module WrapUp end
JonRowe/wrapup
spec/wrapup/wrap_spec.rb
<gh_stars>0 require 'wrapup/wrap' module WrapUp describe Wrap do class WrapperClass < Struct.new(:original) end let(:item_1) { double "item" } let(:item_2) { double "item" } let(:wrap) { described_class.new [item_1, item_2], WrapperClass } describe "#initialize" do it "takes a collec...
JonRowe/wrapup
lib/wrapup/wrap.rb
<reponame>JonRowe/wrapup module WrapUp class Wrap include Enumerable def initialize collection, wrapper_constant @collection = collection @wrapper = wrapper_constant end def each &block @collection.each do |item| block.call @wrapper.new item end end def si...
yoshoku/gem_rbs_collection
gems/sidekiq/6.2/_test/test_2.rb
<filename>gems/sidekiq/6.2/_test/test_2.rb class HardWorker include Sidekiq::Worker end class Hook end class Middleware end HardWorker.perform_async(1, 2, 3) # Test Sidekiq::Client client = Sidekiq::Client.new client.middleware do |chain| chain.add Middleware end Sidekiq::Client.push('class' => HardWorker, 'arg...
yoshoku/gem_rbs_collection
gems/wavedash/0.1/_test/test.rb
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "wavedash" str = "こんにちは\u{301C}" Wavedash.destination_encoding = 'eucjp-ms' Wavedash.normalize(str) # => "こんにちは~" Wavedash.invalid?(str) # => true
yoshoku/gem_rbs_collection
gems/aws-sdk-s3/1/_test/test.rb
<filename>gems/aws-sdk-s3/1/_test/test.rb require "aws-sdk-s3" client = Aws::S3::Client.new resp = client.list_buckets resp.buckets.each do |bucket| bucket.name.upcase end begin resp = Aws::S3::Client.new.get_object(bucket: 'test', key: 'test') resp.body.read rescue Aws::S3::Errors::InvalidObjectState => e e....
yoshoku/gem_rbs_collection
gems/httparty/0.18/_test/test_2.rb
<reponame>yoshoku/gem_rbs_collection HTTParty.get('http://api.stackexchange.com/2.2/questions', query: {site: 'stackoverflow'}) HTTParty.get('http://api.stackexchange.com/2.2/questions', query: {site: 'stackoverflow'}) { |res| res } HTTParty.post('https://reqres.in/api/users', query: { "name": "random", "job": "random"...
yoshoku/gem_rbs_collection
gems/httparty/0.18/_test/test_1.rb
class Foo include HTTParty base_uri "reqres.in" basic_auth "username", "password" digest_auth "username", "password" default_timeout 10 open_timeout 10 read_timeout 10 write_timeout 10 debug_output $stderr headers 'Accept' => 'application/json' format :json pem File.read('/home/user/my.pem'), "...
yoshoku/gem_rbs_collection
gems/woothee/1.11/_test/test.rb
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "woothee" result = Woothee.parse("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)") result[:name] # => "Internet Explorer" result[:category] # => :pc result[:os] # => "Windows 7" result[:os_version] # => "NT 6.1...
yoshoku/gem_rbs_collection
gems/chronic/0.10/_test/test.rb
require "chronic" Chronic.parse('monday') Chronic.parse('monday', context: :future) Chronic.parse('monday', context: :past) Chronic.parse('monday', now: Time.local(2000, 1, 1)) Chronic.parse('20:00:00', hours24: false) # => nil Chronic.parse('monday', week_start: :sunday) Chronic.parse('monday', week_start: :monda...
yoshoku/gem_rbs_collection
aws_client_types_generator.rb
#! /usr/bin/env ruby require 'aws-sdk-code-generator' require 'json' require 'rbs' using Module.new { refine String do def underscore AwsSdkCodeGenerator::Underscore.underscore(self) end end } class AwsClientTypesGenerator def initialize(path) @api = File.open(path) do |file| JSON.parse...
yoshoku/gem_rbs_collection
gems/nokogiri/1.11/_test/test.rb
# https://nokogiri.org/#how-to-use-nokogiri require 'nokogiri' # Fetch and parse HTML document doc = Nokogiri::HTML(<<~HTML) <body> <nav> <ul class="menu"> <li><a href="#">hello</a></li> </ul> </nav> <article> <h2>hello</h2> </article> </body> HTML # Search for nodes by css doc.css('nav ul...
yoshoku/gem_rbs_collection
gems/zengin_code/1.0/_test/test.rb
<reponame>yoshoku/gem_rbs_collection # Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "zengin_code" ZenginCode::Bank.all # => { '0001' => <#ZenginCode::Bank code, name, kana, hira, roma ... >, .... } bank = ZenginCode::Bank["0001"] or raise puts bank.code puts bank.name puts...
yoshoku/gem_rbs_collection
gems/delayed_job/4.1/_test/test.rb
Delayed::Worker.queue_attributes = { high_priority: { priority: -10 }, low_priority: { priority: 10 } } Delayed::Worker.delay_jobs = ->(job) { job.queue != 'inline' } Delayed::Worker.destroy_failed_jobs = false Delayed::Worker.sleep_delay = 60 Delayed::Worker.max_attempts = 3 Delayed::Worker.max_run_time = 5.mi...
kyounger/homebrew-jx
Formula/jx.rb
class Jx < Formula desc "A tool to install and interact with Jenkins X on your Kubernetes cluster." homepage "https://jenkins-x.github.io/jenkins-x-website/" version "1.3.887" url "https://github.com/jenkins-x/jx/releases/download/v#{version}/jx-darwin-amd64.tar.gz" sha256 "456182d8026c670c8c1c9c29ea395cf...
fgrehm/dev-droplet
site-cookbooks/dev_droplet/recipes/default.rb
# apt-get update awesomeness include_recipe 'apt' # Install some random packages defined by the user node.packages.each do |pkg| package pkg end # Stolen from https://github.com/bflad/chef-docker/blob/91cae5b866e096cbaa962ef1e3db3aafca7782ef/recipes/aufs.rb#L30 image_extra = Mixlib::ShellOut.new("apt-cache search l...
fgrehm/dev-droplet
site-cookbooks/dev_droplet/metadata.rb
name "dev_droplet" maintainer "<NAME>" maintainer_email "<EMAIL>" license "MIT" depends 'apt' depends 'user' depends 'openssh' depends 'fail2ban' depends 'sudo' depends 'rvm' depends 'golang'
fgrehm/dev-droplet
site-cookbooks/dev_droplet/recipes/vagrant.rb
vagrant_version = node[:vagrant][:version] vagrant_source = node[:vagrant][:source] vagrant_plugins = node[:vagrant][:plugins] vagrant_path = "#{Chef::Config[:file_cache_path]}/vagrant_#{vagrant_version}_x86_64.deb" package 'lxc' do options "-o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confol...
fgrehm/dev-droplet
site-cookbooks/dev_droplet/recipes/dotfiles.rb
<gh_stars>0 %w( dotfiles vimfiles ).each do |project| bash "setup-#{project}" do code "./setup.sh" cwd "#{node.developer.projects_root}/#{project}" user node.developer.user environment 'HOME' => "/home/#{node.developer.user}" end end
fgrehm/dev-droplet
site-cookbooks/dev_droplet/recipes/git_projects.rb
Chef::Provider::Git.class_eval do alias :run_options_old :run_options def run_options(run_opts={}) ret = run_options_old(run_opts) ret[:environment] = {} unless ret[:environment] ret[:environment]['HOME'] = "/home/#{node[:developer][:user]}" ret end end directory node[:developer][:projects_root] ...
fgrehm/dev-droplet
site-cookbooks/dev_droplet/attributes/default.rb
<reponame>fgrehm/dev-droplet default[:developer][:user] = 'developer' default[:developer][:projects_root] = "/home/#{node[:developer][:user]}/projects" default[:developer][:projects] = { } default[:developer][:vagrant_lxc_boxes] = { } default.packages = %w( htop vim git curl wget psmisc tmux redir apparmor-utils ) de...
Stromweld/chef
spec/unit/provider/user/linux_spec.rb
# # Author:: <NAME> (<<EMAIL>>) # Author:: <NAME> (<<EMAIL>>) # Copyright:: Copyright (c) Chef Software Inc. # # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the Lic...
shirot7335/spf_lookup
lib/spf_lookup/txt_record_fetcher.rb
require 'resolv' module SpfLookup class TXTRecordFetcher SUPPORTED_TYPE_CLASS = %w[TXT].freeze def initialize(dns_conf = nil) @resolver = Resolv::DNS.new(dns_conf) end def txt_record_values(domain) return txt_record_resources(domain).collect { |resource| resource.data } end d...
shirot7335/spf_lookup
lib/spf_lookup/version.rb
<reponame>shirot7335/spf_lookup<filename>lib/spf_lookup/version.rb module SpfLookup VERSION = "0.1.2c" end
shirot7335/spf_lookup
lib/spf_lookup/spf_record.rb
require "json" module SpfLookup class SpfRecord attr_accessor :domain, :record_value, :includes attr_accessor :lookup_term_count def initialize(domain, record_value, includes, lookup_term_count) @domain = domain || "" @record_value = record_value || "" @includes ...
shirot7335/spf_lookup
lib/spf_lookup/lookup.rb
<reponame>shirot7335/spf_lookup require 'coppertone' require_relative './txt_record_fetcher' require_relative './spf_record' require_relative './error' module SpfLookup class Lookup class << self def run(domain) return dns_lookup(domain) end private def dns_lookup(domain) ...
shirot7335/spf_lookup
lib/spf_lookup.rb
require "spf_lookup/version" require_relative './spf_lookup/lookup' module SpfLookup # 'options' could set nil or Resolv::DNS.new argument. # ex. # {nameserver: '8.8.8.8'} DNS_CONFIG = {option: nil} LOOKUP_LIMIT_SPECIFIED_BY_RFC7208 = 10 class << self def retrieve_record_set(domain) return S...
shirot7335/spf_lookup
lib/spf_lookup/error.rb
module SpfLookup class Error < StandardError end class SpfRecordNotFound < Error end class MultipleSpfRecordError < Error end end
dentarg/rubocop-eighty-four-codes
rubocop-eightyfourcodes.gemspec
<filename>rubocop-eightyfourcodes.gemspec $LOAD_PATH.unshift File.expand_path('lib', __dir__) require 'rubocop/eightyfourcodes/version' Gem::Specification.new do |spec| spec.name = 'rubocop-eightyfourcodes' spec.summary = 'Basic security checks for projects' spec.description = <<~DESCRIPTION Basic security c...
lzap/logging-journald
lib/logging/layouts/noop.rb
module Logging::Layouts def self.noop(*args) return ::Logging::Layouts::Noop if args.empty? ::Logging::Layouts::Noop.new(*args) end class Noop < ::Logging::Layout def format(event) event.data.to_s end end end
lzap/logging-journald
test/test_appenders.rb
require 'logging' require 'test/unit' require 'mocha/test_unit' Logging.initialize_plugins module TestLogging module TestAppenders DEBUG = ::Journald::LOG_DEBUG INFO = ::Journald::LOG_INFO WARN = ::Journald::LOG_WARNING ERR = ::Journald::LOG_ERR CRIT = ::Journald::LOG_CRIT class TestJournal...
lzap/logging-journald
lib/logging/plugins/journald.rb
<filename>lib/logging/plugins/journald.rb module Logging module Plugins module Journald extend self def initialize_journald require File.expand_path('../../layouts/noop', __FILE__) require File.expand_path('../../appenders/journald', __FILE__) end end end end
lzap/logging-journald
logging-journald.gemspec
<filename>logging-journald.gemspec<gh_stars>1-10 Gem::Specification.new do |spec| spec.name = 'logging-journald' spec.version = '2.1.0' spec.authors = ['<NAME>'] spec.email = ['<EMAIL>'] spec.summary = "Journald appender for logging gem" spec.description = "Plugin for lo...
lzap/logging-journald
examples/simple.rb
<gh_stars>1-10 require 'logging' log = Logging.logger['example'] log.add_appenders(Logging.appenders.journald('simple', ident: 'simple', # optional log ident (appender name by default) layout: Logging.layouts.pattern(pattern: "%m\n"), # optional layout mdc: true, # log mdc into custom journal fields (true by def...
lzap/logging-journald
lib/logging/appenders/journald.rb
<gh_stars>1-10 require 'journald/logger' module Logging module Appenders def self.journald(name, *args) if args.empty? return self['journald'] || ::Logging::Appenders::Journald.new(name) end ::Logging::Appenders::Journald.new(name, *args) end class Journald < ::Logging::Append...
bbc/linkr
test/test_resolve.rb
require 'helper' class TestLinkr < Test::Unit::TestCase def test_basics FakeWeb.register_uri(:get, "http://bbc.in/pdTHqe", :location => "http://www.bbc.co.uk", :status => ["301", "Moved permanently"]) FakeWeb.register_uri(:get, "http://www.bbc.co.uk", :status => ["200", "OK"], :body => "Hello World") ...
bbc/linkr
lib/linkr.rb
require 'ostruct' require 'net/http' require 'addressable/uri' class Linkr class TooManyRedirects < StandardError; end class InValidUrl < StandardError; end attr_accessor :original_url, :redirect_limit, :timeout attr_writer :url, :response def initialize(original_url, opts={}) opts = { :redire...
bbc/linkr
test/helper.rb
<filename>test/helper.rb require 'test/unit' require 'fakeweb' require_relative '../lib/linkr.rb'
4ormat/rubycas-client
spec/casclient/validation_response_spec.rb
<filename>spec/casclient/validation_response_spec.rb<gh_stars>0 require 'spec_helper' require 'casclient/responses.rb' describe CASClient::ValidationResponse do context "when parsing extra attributes as raw" do let(:response_text) do <<RESPONSE_TEXT <cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas"> ...
mengxianbin/sonic-notes
instrument/guitar/electronic_guitar.rb
define :play_guitar do |&do_play| use_synth :pluck use_synth_defaults attack: 0.01, sustain: 0.5, decay: 0.1, release: 0.2, amp: 1, note_slide: 0.25 with_fx :reverb do with_fx :lpf, cutoff: 115 do do_play.() end end end
mengxianbin/sonic-notes
util/note/check_note.rb
<filename>util/note/check_note.rb define :check_note do |n| n > 88 ? 88 : n < 0 ? 0 : n end
mengxianbin/sonic-notes
idea/2020/0227/blues_2020_0227_001.rb
<gh_stars>1-10 use_bpm 100 rhythm = [0.5, 0.25] template = [:C, :C, :E, :E, :G, :G, :A, :A, :Bb, :Bb, :A, :A, :G, :G, :E, :E] roots = [:C, :C, :F, :C, :G, :F, :C, :C] live_loop :blues do # play_phrase: reference from /util/play play_blues = ->() { roots.each { |root| play_phrase root, template, rhythm } } play_...
mengxianbin/sonic-notes
util/play/play_phrase.rb
define :play_phrase do |root, template, rhythm| offset = root - note(template[0]) with_fx :reverb do # check_note: reference from /util/note play_pattern_timed template.map { |n| check_note(n + offset) }, rhythm end end
mengxianbin/sonic-notes
idea/2020/0227/blues_2020_0227_002.rb
<filename>idea/2020/0227/blues_2020_0227_002.rb use_bpm 60 live_loop :ticks do play 0, release: 0 sleep 1 end live_loop :melody, sync: :ticks do rhythm = [0.33, 0.17, 0.34, 0.16] template = [:C, :C, :E, :E, :G, :G, :A, :A, :Bb, :Bb, :A, :A, :G, :G, :E, :E] roots = [:C, :C, :F, :C, :G, :F, :C, :C] play_pia...
mengxianbin/sonic-notes
api/v3.1/lang/synth_names.rb
<reponame>mengxianbin/sonic-notes # available synth names (ring :beep, :blade, :bnoise, :chipbass, :chiplead, :chipnoise, :cnoise, :dark_ambience, :dpulse, :dsaw, :dtri, :dull_bell, :fm, :gnoise, :growl, :hollow, :hoover, :mod_beep, :mod_dsaw, :mod_fm, :mod_pulse, :mod_saw, :mod_sine, :mod_tri, :noise, :piano, :pluck...
mengxianbin/sonic-notes
idea/2020/0228/tracks_2020_0228_001.rb
use_bpm 100 live_loop :ticks do play_pattern_timed [0], 4 end # Drum Track live_loop :beats, sync: :ticks do sample_rate = (sample_duration :loop_amen) / 4.0 sample :loop_amen, rate: sample_rate sleep 4 end define :play_ch do |ch| play_pattern_timed ch, 0.0625, attack: 0.4, sustain: 1, release: 4, amp: 2 ...
mengxianbin/sonic-notes
api/v3.1/lang/scale.rb
<reponame>mengxianbin/sonic-notes<filename>api/v3.1/lang/scale.rb # available scale types (scale :C, :diatonic) (scale :C, :ionian) (scale :C, :major) (scale :C, :dorian) (scale :C, :phrygian) (scale :C, :lydian) (scale :C, :mixolydian) (scale :C, :aeolian) (scale :C, :minor) (scale :C, :locrian) (scale :C, :hex_major...
mengxianbin/sonic-notes
api/v3.1/lang/chord.rb
<reponame>mengxianbin/sonic-notes # available chord types (chord :C, '1') (chord :C, '5') (chord :C, '+5') (chord :C, 'm+5') (chord :C, :sus2) (chord :C, :sus4) (chord :C, '6') (chord :C, :m6) (chord :C, '7sus2') (chord :C, '7sus4') (chord :C, '7-5') (chord :C, 'm7-5') (chord :C, '7+5') (chord :C, 'm7+5') (chord :C, '...
mengxianbin/sonic-notes
instrument/piano/piano.rb
define :play_piano do |&do_play| use_synth :piano with_fx :reverb do do_play.() end end
mengxianbin/sonic-notes
idea/2020/0227/lofi_2020_0227_001.rb
use_bpm 100 live_loop :ticks do play 0 sleep 4 end define :play_ch do |ch| play_pattern_timed ch, 0.125 sleep 3.5 end live_loop :chord, sync: :ticks do use_synth :piano with_fx :reverb do play_ch chord(:D3, :m7) play_ch chord(:G2, "7", invert: 2) play_ch chord(:C3, :M7) play_ch chord(:C3,...
mengxianbin/sonic-notes
idea/2020/0228/loop_2020_0228_001.rb
<filename>idea/2020/0228/loop_2020_0228_001.rb use_bpm 100 live_loop :ticks do play 0 sleep 4 end # Drum Track live_loop :beats, sync: :ticks do sample_rate = (sample_duration :loop_amen) / 4.0 sample :loop_amen, rate: sample_rate sleep 4 end define :play_ch do |ch| play_pattern_timed ch, 0.0625, attack:...
mengxianbin/sonic-notes
instrument/guitar/acoustic_guitar.rb
<reponame>mengxianbin/sonic-notes define :play_guitar do |&do_play| use_synth :pluck with_fx :reverb do with_fx :lpf, cutoff: 115 do with_synth :pluck do do_play.() end end end end
igrigorik/shopify-core-web-vitals
config/initializers/shopify_app.rb
<filename>config/initializers/shopify_app.rb ShopifyApp.configure do |config| config.application_name = "Core Web Vitals Dashboard" config.api_key = ENV["SHOPIFY_API_KEY"] config.secret = ENV["SHOPIFY_API_SECRET"] config.old_secret = "" # In theory, we don't need any scopes at all for this app, but Shopify co...
igrigorik/shopify-core-web-vitals
app/models/competitor.rb
class Competitor < ApplicationRecord belongs_to :shop validates :origin, presence: true end
igrigorik/shopify-core-web-vitals
app/controllers/competitors_controller.rb
# frozen_string_literal: true class CompetitorsController < AuthenticatedController before_action do @shop = Shop.find_by(shopify_domain: helpers.get_primary_shop_domain) end def show render json: @shop.competitors end def create @shop.competitors << Competitor.new(origin: params[:origin]) ...
igrigorik/shopify-core-web-vitals
app/controllers/home_controller.rb
<reponame>igrigorik/shopify-core-web-vitals<filename>app/controllers/home_controller.rb # frozen_string_literal: true class HomeController < AuthenticatedController DEFAULT_COMPETITORS = ["https://www.amazon.com"] def index # Effectively a noop API call but a necessary one as well to validate # that the g...
igrigorik/shopify-core-web-vitals
config/initializers/user_agent.rb
module ShopifyAPI class Base < ActiveResource::Base self.headers['User-Agent'] << " | ShopifyApp/#{ShopifyApp::VERSION} | Shopify App CLI" end end
igrigorik/shopify-core-web-vitals
app/helpers/application_helper.rb
<filename>app/helpers/application_helper.rb<gh_stars>10-100 module ApplicationHelper SHOP_QUERY = <<-'GRAPHQL' { shop { name, primaryDomain { id, url } } } GRAPHQL def get_primary_shop_domain client = ShopifyAPI::GraphQL.client result = clie...
igrigorik/shopify-core-web-vitals
config/routes.rb
Rails.application.routes.draw do root to: "home#index" mount ShopifyApp::Engine, at: "/" get "/privacy", to: "application#privacy" get "/competitors", to: "competitors#show" post "/competitors", to: "competitors#create" delete "/competitors", to: "competitors#destroy" end
igrigorik/shopify-core-web-vitals
app/jobs/app_uninstalled_job.rb
class AppUninstalledJob < ActiveJob::Base def perform(shop_domain:, webhook:) shop = Shop.find_by(shopify_domain: shop_domain) if shop.nil? logger.error("#{self.class} failed: cannot find shop with domain '#{shop_domain}'") return end shop.with_shopify_session do shop.destroy e...
royratcliffe/sqlanywhere
sqlanywhere.gemspec
pkg_version = "" # The package version of determined by parsing the c source file. This ensures the version is # only ever specified ins a single place. File.open(File.join("ext", "sqlanywhere.c") ) do |f| f.grep( /const char\* VERSION/ ) do |line| pkg_version = /\s*const char\* VERSION\s*=\s*["|']([^"']*)["|...
royratcliffe/sqlanywhere
test/sqlanywhere_test.rb
#==================================================== # # Copyright 2008-2010 iAnywhere Solutions, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # ...
centrevillage/letter_opener
lib/letter_opener/message.rb
<gh_stars>0 require "cgi" require "erb" require "fileutils" require "uri" module LetterOpener class Message attr_reader :mail def self.rendered_messages(mail, options = {}) messages = [] messages << new(mail, options.merge(part: mail.html_part)) if mail.html_part messages << new(mail, opti...
flowli/homebrew-yt2nas
Formula/yt2nas.rb
class Yt2nas < Formula desc "Downloads at YT video and uploads it to the NAS" homepage "https://arweb.de" version "0.1" url "https://github.com/flowli/homebrew-yt2nas/raw/master/yt2nas/yt2nas.zip", :using => :curl def install bin.install "yt2nas" end end
masakazutakewaka/exif_csv
spec/spec_helper.rb
# frozen_string_literal: true $LOAD_PATH << File.expand_path(__dir__) require 'tempfile' require 'open3' require 'cli_helper' RSpec.configure do |config| #... end
masakazutakewaka/exif_csv
spec/cli/exif_csv_spec.rb
# frozen_string_literal: true TEST_IMG_PATH = File.expand_path('../img', __dir__) describe 'exif_csv' do context 'when no image was found' do specify do img = TEST_IMG_PATH + '/wrong_path' output, status = cli_run([img]) expect(status.success?).to be false expect(output).to match /No ima...
masakazutakewaka/exif_csv
spec/cli_helper.rb
<filename>spec/cli_helper.rb module CLIHelper def cli_run(args) path = File.expand_path('../exe/exif_csv', __dir__) Tempfile.open(['exif_csv', '.rb']) do |f| f.puts(File.read(path)) f.flush cmd = ([:ruby, f.path] + args).join(' ') Open3.capture2e(cmd) end end end include CLIHelpe...
juanluis-garrote/octokit.rb
spec/octokit/client/search_spec.rb
<filename>spec/octokit/client/search_spec.rb require 'helper' describe Octokit::Client::Search do before do Octokit.reset! @client = oauth_client end describe ".search_code" do it "searches code", :vcr do results = @client.search_code 'code user:github in:file extension:gemspec -repo:octokit/...
DevMakerMobileApps/devmaker-contracts
config/routes.rb
DevmakerContracts::Engine.routes.draw do root to: "private_contracts#index", as: :private_contracts resources :contracts, controller: "private_contracts", except: [:show] get ":slug" => "public_contracts#show", as: :show_contract end
DevMakerMobileApps/devmaker-contracts
test/dummy/config/initializers/devmaker_contracts.rb
<reponame>DevMakerMobileApps/devmaker-contracts # the private controller used to edit the contracts DevmakerContracts.private_controller = "PrivateController" # the public controller used to display the contracts (defaults to ApplicationController) # DevmakerContracts.private_controller = "PublicController"
DevMakerMobileApps/devmaker-contracts
test/dummy/config/routes.rb
Rails.application.routes.draw do mount DevmakerContracts::Engine => "/devmaker_contracts" get "/public" => "public#index" get "/private" => "private#index" end
DevMakerMobileApps/devmaker-contracts
devmaker_contracts.gemspec
$:.push File.expand_path("lib", __dir__) # Maintain your gem's version: require "devmaker_contracts/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |spec| spec.name = "devmaker_contracts" spec.version = DevmakerContracts::VERSION spec.authors = ["<NAME>"] spec.email = ["<E...
DevMakerMobileApps/devmaker-contracts
test/dummy/app/controllers/private_controller.rb
class PrivateController < ApplicationController http_basic_authenticate_with name: "admin", password: "<PASSWORD>" def index end end
DevMakerMobileApps/devmaker-contracts
app/models/devmaker_contracts/contract.rb
module DevmakerContracts class Contract < ApplicationRecord validates :name, presence: true scope :search_for, -> (string) do s = "%#{string}%" where("name ilike ? or slug ilike ?", s, s) if string.present? end validates :slug, uniqueness: true end end
DevMakerMobileApps/devmaker-contracts
lib/devmaker_contracts.rb
require "devmaker_contracts/engine" module DevmakerContracts mattr_accessor :public_controller def self.public_controller (@@public_controller || "ApplicationController").constantize end mattr_accessor :private_controller def self.private_controller (@@private_controller || "ApplicationController")....
DevMakerMobileApps/devmaker-contracts
app/controllers/devmaker_contracts/public_contracts_controller.rb
module DevmakerContracts class PublicContractsController < DevmakerContracts.public_controller def show @contract = DevmakerContracts::Contract.find_by slug: params[:slug] head(:not_found) unless @contract render :show, layout: false end end end
DevMakerMobileApps/devmaker-contracts
lib/devmaker_contracts/engine.rb
<reponame>DevMakerMobileApps/devmaker-contracts<gh_stars>0 module DevmakerContracts class Engine < ::Rails::Engine isolate_namespace DevmakerContracts end end
DevMakerMobileApps/devmaker-contracts
app/helpers/devmaker_contracts/private_contracts_helper.rb
<reponame>DevMakerMobileApps/devmaker-contracts<filename>app/helpers/devmaker_contracts/private_contracts_helper.rb module DevmakerContracts module PrivateContractsHelper end end
DevMakerMobileApps/devmaker-contracts
app/controllers/devmaker_contracts/private_contracts_controller.rb
module DevmakerContracts class PrivateContractsController < DevmakerContracts.private_controller before_action :set_contract, only: [:show, :edit, :update, :destroy] def index @contracts = DevmakerContracts::Contract.search_for(params[:q]).order(:id) end def new @contract = DevmakerContr...
DevMakerMobileApps/devmaker-contracts
db/migrate/20190111164004_create_devmaker_contracts_contracts.rb
<reponame>DevMakerMobileApps/devmaker-contracts class CreateDevmakerContractsContracts < ActiveRecord::Migration[5.2] def change create_table :devmaker_contracts_contracts do |t| t.text :name t.text :content_html t.text :slug t.index :slug, unique: true t.timestamps end end en...
DevMakerMobileApps/devmaker-contracts
app/helpers/devmaker_contracts/application_helper.rb
module DevmakerContracts module ApplicationHelper end end
datacite/cheetoh
app/controllers/index_controller.rb
class IndexController < ApplicationController def login fail NotImplementedError, "one-time login and session cookies not supported by this service" end end
datacite/cheetoh
spec/apis/show_spec.rb
require "rails_helper" describe "show", :type => :api, vcr: true do it "show doi and metadata" do doi = "10.24354/n296wz12m" get "/id/doi:#{doi}" expect(last_response.status).to eq(200) response = last_response.body hsh = response.from_anvl expect(hsh["success"]).to eq("doi:10.24354/n296wz12...
datacite/cheetoh
spec/apis/reserved_spec.rb
<filename>spec/apis/reserved_spec.rb require "rails_helper" describe "reserved", :type => :api, vcr: true, :order => :defined do let(:doi) { "10.5072/bc11-cqw9" } let(:username) { ENV['MDS_USERNAME'] } let(:password) { ENV['MDS_PASSWORD'] } let(:headers) do { "HTTP_CONTENT_TYPE" => "text/plain", "HTT...
datacite/cheetoh
spec/apis/status_spec.rb
<reponame>datacite/cheetoh<gh_stars>0 require "rails_helper" describe "status", :type => :api, vcr: true, :order => :defined do let(:datacite) { File.read(file_fixture('10.5072_bc11-cqw8.xml')) } let(:url) { "https://blog.datacite.org/differences-between-orcid-and-datacite-metadata/" } let(:username) { ENV['MDS_...
datacite/cheetoh
spec/apis/compatibility_spec.rb
require "rails_helper" describe "ezid compatibility", :type => :api, vcr: true do let(:username) { ENV['MDS_USERNAME'] } let(:password) { ENV['<PASSWORD>'] } let(:headers) do { "HTTP_CONTENT_TYPE" => "text/plain", "HTTP_AUTHORIZATION" => ActionController::HttpAuthentication::Basic.encode_credentials(us...
datacite/cheetoh
config/initializers/anvl.rb
require "anvl"
datacite/cheetoh
spec/apis/index_spec.rb
require 'rails_helper' describe '/login', type: :api do it "login path not supported" do get '/login' expect(last_response.status).to eq(501) expect(last_response.body).to eq("error: one-time login and session cookies not supported by this service") end end
datacite/cheetoh
app/controllers/dois_controller.rb
class DoisController < ApplicationController include Doiable prepend_before_action :authenticate_user_with_basic_auth!, except: [:show] before_action :set_profile before_action :set_doi, only: [:show, :update, :destroy] before_action :set_raven_context, only: [:mint, :create, :update] def show respons...
datacite/cheetoh
config/routes.rb
<filename>config/routes.rb Rails.application.routes.draw do resources :heartbeat, only: [:index] # support login path get 'login', :to => 'index#login' resources :index, path: '/', only: [:index] resources :dois, path: '/id', only: [:show], constraints: { :id => /.+/ } # custom routes, as EZID's routes d...
datacite/cheetoh
spec/apis/delete_spec.rb
require "rails_helper" describe "delete", :type => :api, vcr: true, :order => :defined do let(:doi) { "10.5072/bc11-cqw7" } let(:username) { ENV['MDS_USERNAME'] } let(:password) { ENV['MDS_PASSWORD'] } let(:headers) do { "HTTP_CONTENT_TYPE" => "text/plain", "HTTP_AUTHORIZATION" => ActionController::H...