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 | jordanful/Promptspot | https://github.com/jordanful/Promptspot | test/models/model_provider_test.rb | Ruby | apache-2.0 | 85 | master | 374 | require "test_helper"
class ModelProviderTest < ActiveSupport::TestCase
test "should create model_provider" do
FactoryBot.create(:model_provider)
assert ModelProvider.count == 1
end
test "should not create model_provider without name" do
assert_raises(ActiveRecord::RecordInvalid) do
FactoryBot... |
github | jordanful/Promptspot | https://github.com/jordanful/Promptspot | test/models/organization_test.rb | Ruby | apache-2.0 | 85 | master | 385 | require "test_helper"
class OrganizationTest < ActiveSupport::TestCase
test "should create organization" do
FactoryBot.create(:organization)
assert Organization.count == 1
end
test "should not create organization without billing_email" do
assert_raises ActiveRecord::RecordInvalid do
FactoryBo... |
github | jordanful/Promptspot | https://github.com/jordanful/Promptspot | test/models/test_suite_prompt_test.rb | Ruby | apache-2.0 | 85 | master | 1,372 | require "test_helper"
class TestSuitePromptTest < ActiveSupport::TestCase
setup do
WebMock.allow_net_connect!
VCR.insert_cassette name
@user = FactoryBot.create(:user)
@user.accounts.first.organization.update(openai_api_key: ENV["OPEN_AI_API_SECRET"])
model_provider = FactoryBot.create(:model_pro... |
github | jordanful/Promptspot | https://github.com/jordanful/Promptspot | test/models/test_run_test.rb | Ruby | apache-2.0 | 85 | master | 1,318 | require "test_helper"
class TestRunTest < ActiveSupport::TestCase
setup do
WebMock.allow_net_connect!
VCR.insert_cassette name
@user = FactoryBot.create(:user)
@user.accounts.first.organization.update(openai_api_key: ENV["OPEN_AI_API_SECRET"])
model_provider = FactoryBot.create(:model_provider)
... |
github | jordanful/Promptspot | https://github.com/jordanful/Promptspot | test/models/test_suite_input_test.rb | Ruby | apache-2.0 | 85 | master | 1,359 | require "test_helper"
class TestSuiteInputTest < ActiveSupport::TestCase
setup do
WebMock.allow_net_connect!
VCR.insert_cassette name
@user = FactoryBot.create(:user)
@user.accounts.first.organization.update(openai_api_key: ENV["OPEN_AI_API_SECRET"])
model_provider = FactoryBot.create(:model_prov... |
github | jordanful/Promptspot | https://github.com/jordanful/Promptspot | test/models/user_test.rb | Ruby | apache-2.0 | 85 | master | 481 | require "test_helper"
class UserTest < ActiveSupport::TestCase
test "should create user" do
FactoryBot.create(:user)
assert User.count == 1
end
test "should not create user without email" do
assert_raises ActiveRecord::RecordInvalid do
FactoryBot.create(:user, email: nil)
end
end
tes... |
github | jordanful/Promptspot | https://github.com/jordanful/Promptspot | test/factories/inputs.rb | Ruby | apache-2.0 | 85 | master | 297 | FactoryBot.define do
factory :input do
text { "User profile:
Name: Alice Lee
Age: 29
Favorite hotels: 1) Ace Hotel in New Orleans, 2) Hotel San Fernando in Mexico City, 3) Blackberry Farms in TN
Hobbies and interests: fitness, art museums, music festivals" }
account
user
end
end |
github | jordanful/Promptspot | https://github.com/jordanful/Promptspot | test/factories/models.rb | Ruby | apache-2.0 | 85 | master | 200 | FactoryBot.define do
factory :model do
model_provider
name { "davinci" }
enabled { false }
description { "This is an example description" }
model_type { "completion" }
end
end |
github | jordanful/Promptspot | https://github.com/jordanful/Promptspot | test/factories/users.rb | Ruby | apache-2.0 | 85 | master | 204 | FactoryBot.define do
factory :user do
email { "test@example.com" }
password { "123456" }
password_confirmation { "123456" }
first_name { "John" }
last_name { "Appleseed" }
end
end |
github | jordanful/Promptspot | https://github.com/jordanful/Promptspot | lib/tasks/fly.rake | Ruby | apache-2.0 | 85 | master | 1,239 | # commands used to deploy a Rails application
namespace :fly do
# BUILD step:
# - changes to the filesystem made here DO get deployed
# - NO access to secrets, volumes, databases
# - Failures here prevent deployment
task :build => 'assets:precompile'
# RELEASE step:
# - changes to the filesystem made... |
github | miyataka/fcmpush | https://github.com/miyataka/fcmpush | Gemfile | Ruby | mit | 85 | main | 236 | source 'https://rubygems.org'
# Specify your gem's dependencies in fcmpush.gemspec
gemspec
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4')
gem 'bigdecimal'
gem 'drb'
end
gem 'activesupport', '< 7.0'
gem 'pry-byebug' |
github | miyataka/fcmpush | https://github.com/miyataka/fcmpush | fcmpush.gemspec | Ruby | mit | 85 | main | 1,298 | lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'fcmpush/version'
Gem::Specification.new do |spec|
spec.name = 'fcmpush'
spec.version = Fcmpush::VERSION
spec.authors = ['miyataka']
spec.email = ['voyager.3taka28@gmail.com']
... |
github | miyataka/fcmpush | https://github.com/miyataka/fcmpush | spec/json_compatibility_spec.rb | Ruby | mit | 85 | main | 2,213 | RSpec.describe Fcmpush do
let(:device_token) { ENV.fetch('TEST_DEVICE_TOKEN') }
let(:project_id) { ENV.fetch('TEST_PROJECT_ID') }
let(:server_key) { ENV.fetch('FCM_SERVER_KEY') }
let(:json_key_path) { ENV.fetch('TEST_JSON_KEY_PATH') }
let(:another_json_key_path) { ENV.fetch('ANOTHER_TEST_JSON_KEY_PATH') }
... |
github | miyataka/fcmpush | https://github.com/miyataka/fcmpush | spec/spec_helper.rb | Ruby | mit | 85 | main | 475 | require 'bundler/setup'
require 'fcmpush'
require 'active_support/test_case'
# require 'pry-byebug'
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`
... |
github | miyataka/fcmpush | https://github.com/miyataka/fcmpush | spec/fcmpush_spec.rb | Ruby | mit | 85 | main | 2,854 | RSpec.describe Fcmpush do
let(:device_token) { ENV.fetch('TEST_DEVICE_TOKEN') }
let(:project_id) { ENV.fetch('TEST_PROJECT_ID') }
let(:server_key) { ENV.fetch('FCM_SERVER_KEY') }
let(:json_key_path) { ENV.fetch('TEST_JSON_KEY_PATH') }
let(:another_json_key_path) { ENV.fetch('ANOTHER_TEST_JSON_KEY_PATH') }
... |
github | miyataka/fcmpush | https://github.com/miyataka/fcmpush | lib/fcmpush.rb | Ruby | mit | 85 | main | 605 | require 'net/http/persistent'
require 'googleauth'
require 'fcmpush/configuration'
require 'fcmpush/version'
require 'fcmpush/client'
module Fcmpush
class Error < StandardError; end
DOMAIN = 'https://fcm.googleapis.com'.freeze
class << self
def build(project_id, domain: nil)
::Fcmpush::Client.new(dom... |
github | miyataka/fcmpush | https://github.com/miyataka/fcmpush | lib/fcmpush/batch.rb | Ruby | mit | 85 | main | 1,234 | module Fcmpush
module Batch
PART_BOUNDRY = '__END_OF_PART__'.freeze
def make_batch_payload(messages, headers)
uri = URI.join(domain, path)
subrequests = messages.map do |payload|
req = Net::HTTP::Post.new(uri, headers)
req.body = payload
req
end
subrequests.map... |
github | miyataka/fcmpush | https://github.com/miyataka/fcmpush | lib/fcmpush/client.rb | Ruby | mit | 85 | main | 7,663 | require 'fcmpush/exceptions'
require 'fcmpush/batch'
require 'fcmpush/json_response'
require 'fcmpush/batch_response'
module Fcmpush
V1_ENDPOINT_PREFIX = '/v1/projects/'.freeze
V1_ENDPOINT_SUFFIX = '/messages:send'.freeze
TOPIC_DOMAIN = 'https://iid.googleapis.com'.freeze
TOPIC_ENDPOINT_PREFIX = '/iid/v1'.free... |
github | miyataka/fcmpush | https://github.com/miyataka/fcmpush | lib/fcmpush/batch_response.rb | Ruby | mit | 85 | main | 922 | require 'delegate' if RUBY_VERSION >= '2.7'
module Fcmpush
class BatchResponse < DelegateClass(Net::HTTPResponse)
alias response __getobj__
alias headers to_hash
HAS_SYMBOL_GC = RUBY_VERSION > '2.2.0'
def json
parsable? ? @parsed ||= parse_body(body) : nil
end
def inspect
"#<Bat... |
github | miyataka/fcmpush | https://github.com/miyataka/fcmpush | lib/fcmpush/json_response.rb | Ruby | mit | 85 | main | 512 | require 'delegate' if RUBY_VERSION >= '2.7'
require 'json'
module Fcmpush
class JsonResponse < DelegateClass(Net::HTTPResponse)
alias response __getobj__
alias headers to_hash
HAS_SYMBOL_GC = RUBY_VERSION > '2.2.0'
def json
parsable? ? JSON.parse(body, symbolize_names: HAS_SYMBOL_GC) : nil
... |
github | miyataka/fcmpush | https://github.com/miyataka/fcmpush | lib/fcmpush/exceptions.rb | Ruby | mit | 85 | main | 4,330 | module Fcmpush
class APIError < StandardError; end
class DeprecatedApiError < StandardError; end
class NetworkError < APIError; end
class HttpError < APIError
attr_reader :response
def initialize(message, response)
super(message)
@response = response
end
end
class ClientError < Ht... |
github | miyataka/fcmpush | https://github.com/miyataka/fcmpush | lib/fcmpush/configuration.rb | Ruby | mit | 85 | main | 1,209 | module Fcmpush
class Configuration
attr_accessor :scope, :json_key_io, :server_key, :proxy, :open_timeout, :read_timeout
def initialize
@scope = ['https://www.googleapis.com/auth/firebase.messaging']
# set file path
@json_key_io = nil
# Or Environment Variable
# ENV['GOOGLE_AC... |
github | xdevplatform/SnowBotDev | https://github.com/xdevplatform/SnowBotDev | app/controllers/snow_bot_dev_app.rb | Ruby | mit | 85 | master | 1,643 | require 'sinatra'
require 'base64'
require 'json'
require_relative "../../app/helpers/event_manager"
class SnowBotDevApp < Sinatra::Base
def initialize
puts "Starting up web app."
super()
end
#Load authentication details
keys = {}
set :dm_api_consumer_secret, ENV['CONSUMER_SECRET'] #Account Activity API wi... |
github | xdevplatform/SnowBotDev | https://github.com/xdevplatform/SnowBotDev | app/config/environment.rb | Ruby | mit | 85 | master | 687 | require 'bundler'
Bundler.require
# get the path of the root of the app
APP_ROOT = File.expand_path("..", __dir__)
# require the controller(s)
Dir.glob(File.join(APP_ROOT, 'controllers', '*.rb')).each { |file| require file }
# require the helper(s)
Dir.glob(File.join(APP_ROOT, 'helpers', '*.rb')).each { |file| requi... |
github | xdevplatform/SnowBotDev | https://github.com/xdevplatform/SnowBotDev | app/helpers/get_resources.rb | Ruby | mit | 85 | master | 3,878 | #Attempting to abstract away all the 'resource' metadata and management into this class.
#This class knows where things are stored (on Heroku at least)
#Could have 'dev helper' features for working on different platforms (heroku, local linux, ?).
#Sets up all object variables needed by Bot. One Stop Shop.
#Key feature... |
github | xdevplatform/SnowBotDev | https://github.com/xdevplatform/SnowBotDev | app/helpers/send_direct_message.rb | Ruby | mit | 85 | master | 3,581 | require 'json'
require 'csv'
require 'pathname'
require_relative 'api_oauth_request'
require_relative 'generate_direct_message_content'
class SendDirectMessage
attr_accessor :dm, #Object that manages DM API requests.
:content,
:sender
def initialize
#puts "Creating SendD... |
github | xdevplatform/SnowBotDev | https://github.com/xdevplatform/SnowBotDev | app/helpers/generate_direct_message_content.rb | Ruby | mit | 85 | master | 14,587 | #Generates all content for bot Direct Messages.
#Many responses include configuration metadata/resources, such as photos, links, and location list.
#These metadata are loading from local files.
#Direct Messages with media require a side call to Twitter upload endpoint, so this class uses a Twitter API object.
require... |
github | xdevplatform/SnowBotDev | https://github.com/xdevplatform/SnowBotDev | app/helpers/twitter_api.rb | Ruby | mit | 85 | master | 1,230 | require 'twitter' #Opens doors to the rest of the standard Twitter APIs.
#https://github.com/sferik/twitter/blob/master/examples/Configuration.md
class TwitterAPI
attr_accessor :keys,
:upload_client,
:base_url, # 'https://api.twitter.com/' or 'upload.twitter.com' or ?
:ur... |
github | xdevplatform/SnowBotDev | https://github.com/xdevplatform/SnowBotDev | app/helpers/api_oauth_request.rb | Ruby | mit | 85 | master | 3,640 | #With many Twitter (Public) APIs, you can just use something like the 'twitter' gem.
#This example instead builds requests making the 'oauth' gem, and is not Twitter specific.
require 'json'
require 'oauth'
require 'yaml'
class ApiOauthRequest
HEADERS = {"content-type" => "application/json"} #Suggested set? Any?
... |
github | xdevplatform/SnowBotDev | https://github.com/xdevplatform/SnowBotDev | app/helpers/third_party_request.rb | Ruby | mit | 85 | master | 4,443 | require 'json'
require 'open-uri'
class ThirdPartyRequest
HEADERS = {"content-type" => "application/json"} #Suggested set? Any?
attr_accessor :keys,
:base_url, #Default: 'https://api.twitter.com/'
:uri_path #No default.
def initialize(config_file = nil)
#Get Twitter App keys and ... |
github | xdevplatform/SnowBotDev | https://github.com/xdevplatform/SnowBotDev | app/helpers/event_manager.rb | Ruby | mit | 85 | master | 5,563 | #POST requests to /webhooks/twitter arrive here.
#Twitter Account Activity API send events as POST requests with DM JSON payloads.
require 'json'
#Two helper classes...
require_relative 'send_direct_message'
class EventManager
#Design: Identifying explicit commands is easy and can restrict text length based on its ... |
github | xdevplatform/SnowBotDev | https://github.com/xdevplatform/SnowBotDev | scripts/setup_webhooks.rb | Ruby | mit | 85 | master | 8,018 | #Code for configuring webhook details for the Account Activity API.
#Note that this code currently does not have support for running on Heroku. To add that the configuration details
#(OAuth keys) should be loaded from the ENV[] structure.
require 'json'
require 'cgi'
require 'optparse'
require_relative '../app/helper... |
github | xdevplatform/SnowBotDev | https://github.com/xdevplatform/SnowBotDev | scripts/setup_welcome_messages.rb | Ruby | mit | 85 | master | 5,822 | #Code for managing Default Welcome Messages.
#Note that this code currently does not have support for running on Heroku. To add that the configuration details
#(OAuth keys) should be loaded from the ENV[] structure.
require 'json'
require 'optparse'
require_relative '../app/helpers/api_oauth_request'
require_relativ... |
github | ftp27/fastlane-plugin-translate_gpt | https://github.com/ftp27/fastlane-plugin-translate_gpt | fastlane-plugin-translate_gpt.gemspec | Ruby | mit | 85 | master | 1,699 | lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'fastlane/plugin/translate_gpt/version'
Gem::Specification.new do |spec|
spec.name = 'fastlane-plugin-translate_gpt'
spec.version = Fastlane::TranslateGpt::VERSION
spec.author = 'Aleksei C... |
github | ftp27/fastlane-plugin-translate_gpt | https://github.com/ftp27/fastlane-plugin-translate_gpt | lib/fastlane/plugin/translate_gpt.rb | Ruby | mit | 85 | master | 479 | require 'fastlane/plugin/translate_gpt/version'
module Fastlane
module TranslateGpt
# Return all .rb files inside the "actions" and "helper" directory
def self.all_classes
Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
end
end
end
# By default we want to import all ava... |
github | ftp27/fastlane-plugin-translate_gpt | https://github.com/ftp27/fastlane-plugin-translate_gpt | lib/fastlane/plugin/translate_gpt/helper/translate_gpt_helper.rb | Ruby | mit | 85 | master | 16,028 | require 'fastlane_core/ui/ui'
require 'loco_strings/parsers/xcstrings_file'
require 'json'
require 'openai'
# rubocop:disable all
module Fastlane
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
module Helper
class TranslateGptHelper
def initialize(params)
@params = params
@cli... |
github | ftp27/fastlane-plugin-translate_gpt | https://github.com/ftp27/fastlane-plugin-translate_gpt | lib/fastlane/plugin/translate_gpt/actions/translate_gpt_action.rb | Ruby | mit | 85 | master | 5,864 | require 'fastlane/action'
require_relative '../helper/translate_gpt_helper'
require 'loco_strings'
module Fastlane
module Actions
class TranslateGptAction < Action
def self.run(params)
helper = Helper::TranslateGptHelper.new(params)
helper.prepare_hashes
bunch_size = params[:bunch_s... |
github | ftp27/fastlane-plugin-translate_gpt | https://github.com/ftp27/fastlane-plugin-translate_gpt | spec/spec_helper.rb | Ruby | mit | 85 | master | 453 | $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
require 'simplecov'
# SimpleCov.minimum_coverage 95
SimpleCov.start
# This module is only used to check the environment is currently a testing env
module SpecHelper
end
require 'fastlane' # to import the Action super class
require 'fastlane/plugin/translate_gp... |
github | ftp27/fastlane-plugin-translate_gpt | https://github.com/ftp27/fastlane-plugin-translate_gpt | spec/translate_gpt_action_spec.rb | Ruby | mit | 85 | master | 265 | describe Fastlane::Actions::TranslateGptAction do
describe '#run' do
it 'prints a message' do
expect(Fastlane::UI).to receive(:message).with("The translate_gpt plugin is working!")
Fastlane::Actions::TranslateGptAction.run(nil)
end
end
end |
github | mcasimir/kaminari-bootstrap | https://github.com/mcasimir/kaminari-bootstrap | Rakefile | Ruby | mit | 85 | master | 816 | # encoding: utf-8
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 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is... |
github | mcasimir/kaminari-bootstrap | https://github.com/mcasimir/kaminari-bootstrap | kaminari-bootstrap.gemspec | Ruby | mit | 85 | master | 2,089 | # 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 = "kaminari-bootstrap"
s.version = "3.0.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :requir... |
github | roo-rb/roo-xls | https://github.com/roo-rb/roo-xls | roo-xls.gemspec | Ruby | mit | 85 | master | 1,454 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'roo/xls/version'
Gem::Specification.new do |spec|
spec.name = "roo-xls"
spec.version = Roo::Xls::VERSION
spec.authors = ["Thomas Preymesser", "Hugh McGowan", "Ben Woosl... |
github | roo-rb/roo-xls | https://github.com/roo-rb/roo-xls | Rakefile | Ruby | mit | 85 | master | 550 | require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rspec/core/rake_task'
require 'coveralls/rake/task'
# Test unit
Rake::TestTask.new do |t|
t.libs << 'test'
t.test_files = FileList['test/test*.rb']
t.verbose = true
end
# RSpec
RSpec::Core::RakeTask.new(:spec)
# Coveralls
Coveralls::RakeTask.new
de... |
github | roo-rb/roo-xls | https://github.com/roo-rb/roo-xls | Gemfile | Ruby | mit | 85 | master | 836 | source 'https://rubygems.org'
# Specify your gem's dependencies in roo-xls.gemspec
gemspec
if ENV['CI']
gem 'roo', '>= 2.0.0beta1', git: 'https://github.com/roo-rb/roo.git'
else
gem 'roo', '>= 2.0.0beta1', '< 3'
end
group :test do
# additional testing libs
gem 'webmock'
gem 'shoulda'
gem 'rspec', '>= 3.0... |
github | roo-rb/roo-xls | https://github.com/roo-rb/roo-xls | test/test_excel_2003_xml.rb | Ruby | mit | 85 | master | 1,250 | require 'test_helper'
class TestExcel2013XML < Minitest::Test
def with_xml_spreadsheet(name)
yield ::Roo::Excel2003XML.new(File.join(TESTDIR, "#{name}.xml"))
end
def test_xml_namespace_ss
with_xml_spreadsheet('excel2003') do |oo|
oo.default_sheet = oo.sheets.first
assert_equal 'BST Variables... |
github | roo-rb/roo-xls | https://github.com/roo-rb/roo-xls | test/test_roo_excel.rb | Ruby | mit | 85 | master | 39,322 | # -- encoding : utf-8 --
require 'test_helper'
require 'stringio'
class TestRooExcel < Minitest::Test
def with_spreadsheet(name)
yield ::Roo::Spreadsheet.open(File.join(TESTDIR, "#{name}.xls"))
end
# Excel can only read the cell's value
def test_formula_excel
with_spreadsheet('formula') do |oo|
... |
github | roo-rb/roo-xls | https://github.com/roo-rb/roo-xls | test/test_helper.rb | Ruby | mit | 85 | master | 1,232 | require 'simplecov'
# require deps
require 'tmpdir'
require 'fileutils'
require 'minitest/autorun'
require 'shoulda'
require 'fileutils'
require 'timeout'
require 'logger'
require 'date'
require 'webmock/minitest'
# require gem files
require File.dirname(__FILE__) + '/../lib/roo-xls'
TESTDIR = File.join(File.dirname... |
github | roo-rb/roo-xls | https://github.com/roo-rb/roo-xls | spec/lib/roo/xls/excel2003xml_spec.rb | Ruby | mit | 85 | master | 6,359 | require 'spec_helper'
RSpec.describe Roo::Excel2003XML do
subject { instance }
let(:instance) { described_class.new(path) }
let(:path) { File.join(test_files_dir, test_file) }
let(:test_files_dir) { 'test/files' }
describe '.new' do
context 'with an xml file' do
let(:test_file) { 'datetime.xml' }... |
github | roo-rb/roo-xls | https://github.com/roo-rb/roo-xls | spec/lib/roo/xls/excel_spec.rb | Ruby | mit | 85 | master | 369 | require 'spec_helper'
describe Roo::Excel do
let(:excel) { Roo::Excel.new('test/files/boolean.xls') }
describe '.new' do
it 'creates an instance' do
expect(excel).to be_a(Roo::Excel)
end
end
describe '#sheets' do
it 'returns the sheet names of the file' do
expect(excel.sheets).to eq([... |
github | roo-rb/roo-xls | https://github.com/roo-rb/roo-xls | lib/roo/xls/excel_2003_xml.rb | Ruby | mit | 85 | master | 9,231 | require 'date'
require 'base64'
require 'nokogiri'
require 'tmpdir'
class Roo::Excel2003XML < Roo::Base
# initialization and opening of a spreadsheet file
# values for packed: :zip
def initialize(filename, options = {})
packed = options[:packed]
file_warning = options[:file_warning] || :error
Dir.mk... |
github | roo-rb/roo-xls | https://github.com/roo-rb/roo-xls | lib/roo/xls/spreadsheet_extensions.rb | Ruby | mit | 85 | master | 607 | module Roo
module Xls
# patch for skipping blank rows in the case of
# having a spreadsheet with 30,000 nil rows appended
# to the actual data. (it happens and your RAM will love me)
module SpreadsheetEachSkipBlanks
def each(skip = dimensions[0])
blanks = 0
skip.upto(dimensions[... |
github | roo-rb/roo-xls | https://github.com/roo-rb/roo-xls | lib/roo/xls/excel.rb | Ruby | mit | 85 | master | 10,301 | require 'roo/xls/version'
require 'roo/base'
require 'spreadsheet'
require 'tmpdir'
module Roo
# Class for handling Excel-Spreadsheets
class Excel < Roo::Base
FORMULAS_MESSAGE = 'the spreadsheet gem does not support formulas, so roo can not.'
CHARGUESS =
begin
require 'charguess'
true... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | stream.gemspec | Ruby | bsd-3-clause | 85 | main | 1,260 | $LOAD_PATH.unshift File.expand_path('lib', __dir__)
require 'stream/version'
Gem::Specification.new do |gem|
gem.name = 'stream-ruby'
gem.description = 'Ruby client for getstream.io service'
gem.version = Stream::VERSION
gem.platform = Gem::Platform::RUBY
gem.summary = 'A gem that provides a client interface... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | Rakefile | Ruby | bsd-3-clause | 85 | main | 238 | require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop) do |t|
t.options = ['--display-cop-names']
end
task default: [:spec]
task test: [:spec] |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | lib/stream/errors.rb | Ruby | bsd-3-clause | 85 | main | 1,531 | module Stream
class Error < StandardError; end
class StreamApiResponseException < Error; end
class StreamApiResponseApiKeyException < StreamApiResponseException; end
class StreamApiResponseSignatureException < StreamApiResponseException; end
class StreamApiResponseInputException < StreamApiResponseExcepti... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | lib/stream/activities.rb | Ruby | bsd-3-clause | 85 | main | 5,464 | module Stream
module Activities
#
# Get activities directly, via ID or Foreign ID + timestamp
#
# @param [Hash<:ids, :foreign_id_times>] params the request params (ids or list of <:foreign_id, :time> objects)
#
# @return the found activities, if any.
#
# @example Retrieve by activity I... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | lib/stream/batch.rb | Ruby | bsd-3-clause | 85 | main | 1,861 | module Stream
module Batch
#
# Follows many feeds in one single request
#
# @param [Array<Hash<:source, :target>>] follows the list of follows
#
# @return [nil]
#
# @example
# follows = [
# {:source => 'flat:1', :target => 'user:1'},
# {:source => 'flat:1', :targe... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | lib/stream/client.rb | Ruby | bsd-3-clause | 85 | main | 8,703 | require 'faraday'
require 'faraday/net_http_persistent'
require 'stream/errors'
require 'stream/feed'
require 'stream/signer'
require 'stream/url'
module Stream
STREAM_URL_COM_RE = %r{https://(?<key>\w+):(?<secret>\w+)@((api\.)|((?<location>[-\w]+)\.))?(?<api_hostname>stream-io-api\.com)/[\w=-?%&]+app_id=(?<app_id>\... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | lib/stream/collections.rb | Ruby | bsd-3-clause | 85 | main | 1,836 | module Stream
class CollectionsClient < Client
def add(collection_name, collection_data, id: nil, user_id: nil)
data = {
id: id,
user_id: user_id,
data: collection_data
}
uri = "/collections/#{collection_name}/"
make_collection_request(:post, {}, data, endpoint: uri... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | lib/stream/users.rb | Ruby | bsd-3-clause | 85 | main | 1,064 | module Stream
class UsersClient < Client
def add(user_id, data: nil, get_or_create: false)
data = {
id: user_id,
data: data
}
params = {
get_or_create: get_or_create
}
make_user_request(:post, params, data)
end
def get(user_id)
uri = "/user/#{us... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | lib/stream/personalization.rb | Ruby | bsd-3-clause | 85 | main | 803 | require 'stream/url'
module Stream
class PersonalizationClient < Client
def url_generator
PersonalizationURLGenerator.new(@client_options)
end
def get(resource, params = {})
make_personalization_request(:get, resource, params, {})
end
def post(resource, params = {}, data = {})
... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | lib/stream/feed.rb | Ruby | bsd-3-clause | 85 | main | 6,012 | require 'stream/signer'
require 'jwt'
module Stream
class Feed
attr_reader :id
attr_reader :slug
attr_reader :user_id
def initialize(client, feed_slug, user_id)
raise StreamInputData, 'feed_slug can only contain alphanumeric characters plus underscores' unless valid_feed_slug feed_slug
... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | lib/stream/base.rb | Ruby | bsd-3-clause | 85 | main | 318 | require 'json'
require 'stream/client'
require 'stream/errors'
require 'stream/version'
require 'stream/signer'
module Stream
class << self
def connect(api_key, api_secret)
Stream::Client.new(api_key, api_secret)
end
def get_feed_slug_and_id(feed_id)
feed_id.sub(':', '')
end
end
end |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | lib/stream/signer.rb | Ruby | bsd-3-clause | 85 | main | 618 | require 'openssl'
require 'base64'
module Stream
class Signer
@key = nil
def initialize(key)
@key = key.to_s
end
def self.create_user_token(user_id, payload = {}, api_secret)
payload['user_id'] = user_id
JWT.encode(payload, api_secret, 'HS256')
end
def self.create_jwt_tok... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | lib/stream/reactions.rb | Ruby | bsd-3-clause | 85 | main | 2,665 | module Stream
class ReactionsClient < Client
def add(kind, activity_id, user_id, data: nil, target_feeds: nil, target_feeds_extra_data: nil)
data = {
kind: kind,
activity_id: activity_id,
user_id: user_id,
data: data,
target_feeds: target_feeds,
target_feeds_e... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | lib/stream/url.rb | Ruby | bsd-3-clause | 85 | main | 1,457 | module Stream
class URLGenerator
attr_reader :options
attr_reader :base_path
attr_reader :url
end
class APIURLGenerator < URLGenerator
def initialize(options)
super()
@options = options
location = make_location(options[:location])
location ||= 'api'
api_version = opt... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | spec/integration_spec.rb | Ruby | bsd-3-clause | 85 | main | 45,819 | require 'spec_helper'
require 'date'
require './spec/support/utils'
RSpec.configure do |c|
c.include Utils
end
describe 'Integration tests' do
before(:all) do
@client = Stream::Client.new(ENV.fetch('STREAM_API_KEY'), ENV.fetch('STREAM_API_SECRET'), nil, location: ENV.fetch('STREAM_REGION', nil), default_timeo... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | spec/client_spec.rb | Ruby | bsd-3-clause | 85 | main | 7,868 | require 'spec_helper'
require 'stream'
describe Stream::Client do
before do
@env_url = ENV.fetch('STREAM_URL', nil)
end
after do
ENV.delete 'STREAM_URL'
ENV['STREAM_URL'] = @env_url if @env_url
end
it 'feed returns a Feed instance with id' do
client = Stream::Client.new('key', 'secret')
... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | spec/personalization_spec.rb | Ruby | bsd-3-clause | 85 | main | 1,352 | require 'spec_helper'
require 'stream'
describe Stream::PersonalizationClient do
before do
client = Stream::Client.new('key', 'secret')
@personalization = client.personalization
end
def stub_and_expect(method, endpoint, params, data)
expected = {
method: method,
endpoint: endpoint,
... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | spec/feed_spec.rb | Ruby | bsd-3-clause | 85 | main | 1,081 | require 'spec_helper'
describe Stream::Feed do
it 'should validate feed_id' do
Stream::Feed.new(nil, 'slug', 'user_id')
end
it 'should validate user_id' do
Stream::Feed.new(nil, 'slug', 'user_id-1')
end
it 'should refuse user_id with semicolon' do
expect { Stream::Feed.new(nil, 'slug', 'user:id... |
github | GetStream/stream-ruby | https://github.com/GetStream/stream-ruby | spec/errors_spec.rb | Ruby | bsd-3-clause | 85 | main | 2,183 | require 'spec_helper'
require 'stream'
describe Stream::Error do
it { expect(Stream::Error).to be < StandardError }
it { expect(Stream::StreamApiResponseException).to be < Stream::Error }
it { expect(Stream::StreamApiResponseDoesNotExistException).to be < Stream::StreamApiResponseException }
it { expect(Stream... |
github | ElMassimo/request_store_rails | https://github.com/ElMassimo/request_store_rails | request_store_rails.gemspec | Ruby | mit | 85 | master | 911 | lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
require 'request_store_rails/version'
Gem::Specification.new do |s|
s.name = 'request_store_rails'
s.version = RequestStoreRails::VERSION
s.licenses = ['MIT']
s.summary = 'Per-request global storage for Rails'
s.description =... |
github | ElMassimo/request_store_rails | https://github.com/ElMassimo/request_store_rails | test/test_helper.rb | Ruby | mit | 85 | master | 350 | require 'pry'
require 'minitest/reporters'
Minitest::Reporters.use!
require 'simplecov'
SimpleCov.start do
add_filter '/test/'
end
class RackApp
attr_reader :last_value
def call(env)
RequestLocals.store[:foo] ||= 0
RequestLocals.store[:foo] += 1
@last_value = RequestLocals.store[:foo]
raise 'F... |
github | ElMassimo/request_store_rails | https://github.com/ElMassimo/request_store_rails | test/request_locals_test.rb | Ruby | mit | 85 | master | 3,155 | require 'minitest/autorun'
require 'request_store_rails'
require_relative 'test_helper'
class RequestLocalsTest < Minitest::Unit::TestCase
def test_initial_state
RequestLocals.set_current_store_id(:random_id)
assert_empty RequestLocals.store
assert RequestLocals.current_store_id
end
def test_exis... |
github | ElMassimo/request_store_rails | https://github.com/ElMassimo/request_store_rails | test/middleware_test.rb | Ruby | mit | 85 | master | 714 | require 'minitest/autorun'
require 'request_store_rails'
require_relative 'test_helper'
class MiddlewareTest < Minitest::Unit::TestCase
def setup
@app = RackApp.new
@middleware = RequestStoreRails::Middleware.new(@app)
RequestLocals.set_current_store_id(nil)
RequestLocals.clear_all!
end
def t... |
github | ElMassimo/request_store_rails | https://github.com/ElMassimo/request_store_rails | lib/request_locals.rb | Ruby | mit | 85 | master | 3,258 | require 'singleton'
require 'forwardable'
require 'concurrent'
# Public: Provides per-request global storage, by offering an interface that is
# very similar to Rails.cache, or Hash.
#
# The store may be shared between threads, as long as the current store id is
# set as a thread-local variable.
#
# Intended to work i... |
github | ElMassimo/request_store_rails | https://github.com/ElMassimo/request_store_rails | lib/request_store_rails/middleware.rb | Ruby | mit | 85 | master | 974 | require 'securerandom'
module RequestStoreRails
# Public: Middleware that takes care of setting a thread-local variable, which
# enables RequestLocals to associate threads with the store for a request.
class Middleware
def initialize(app)
@app = app
end
# Internal: Assigns a thread-local var... |
github | ElMassimo/request_store_rails | https://github.com/ElMassimo/request_store_rails | lib/request_store_rails/railtie.rb | Ruby | mit | 85 | master | 581 | module RequestStoreRails
# Internal: Inserts the middleware to manage request_ids and cleaning up after
# the request is complete.
class Railtie < ::Rails::Railtie
initializer 'request_store_rails.insert_middleware' do |app|
app.config.middleware.insert_after ActionDispatch::RequestId, RequestStoreRai... |
github | pch/based_uuid | https://github.com/pch/based_uuid | based_uuid.gemspec | Ruby | mit | 85 | main | 722 | require_relative "lib/based_uuid/version"
Gem::Specification.new do |spec|
spec.name = "based_uuid"
spec.version = BasedUUID::VERSION
spec.authors = ["Piotr Chmolowski"]
spec.email = ["piotr@chmolowski.pl"]
spec.summary = "URL-friendly, Base32-encoded UUIDs for Rails models"
spec.homepage = "https://githu... |
github | pch/based_uuid | https://github.com/pch/based_uuid | Gemfile | Ruby | mit | 85 | main | 201 | # frozen_string_literal: true
source "https://rubygems.org"
# Specify your gem's dependencies in based_uuid.gemspec
gemspec
gem "rake", "~> 13.0"
gem "minitest", "~> 5.0"
gem "rubocop", "~> 1.21" |
github | pch/based_uuid | https://github.com/pch/based_uuid | Rakefile | Ruby | mit | 85 | main | 289 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/test_*.rb"]
end
require "rubocop/rake_task"
RuboCop::RakeTask.new
task default: %i[test rubocop] |
github | pch/based_uuid | https://github.com/pch/based_uuid | lib/based_uuid.rb | Ruby | mit | 85 | main | 1,143 | require "active_support/core_ext/module/attribute_accessors"
require_relative "based_uuid/version"
require_relative "based_uuid/base32_uuid"
require_relative "based_uuid/has_based_uuid"
module BasedUUID
class Error < StandardError; end
mattr_accessor :delimiter, default: "_"
class << self
def find(token)
... |
github | pch/based_uuid | https://github.com/pch/based_uuid | lib/based_uuid/base32_uuid.rb | Ruby | mit | 85 | main | 1,317 | module BasedUUID
class Base32UUID
CROCKFORDS_ALPHABET = "0123456789abcdefghjkmnpqrstvwxyz".freeze
CHARACTER_MAP = CROCKFORDS_ALPHABET.bytes.freeze
ENCODED_LENGTH = 26
BITS_PER_CHAR = 5
ZERO = "0".ord
MASK = 0x1f
UUID_LENGTH = 32
UUID_VALIDATION_REGEXP = /\A[0-9a-fA-F]{8}-[0-9a-fA-F]{... |
github | pch/based_uuid | https://github.com/pch/based_uuid | lib/based_uuid/has_based_uuid.rb | Ruby | mit | 85 | main | 1,833 | require "active_support/lazy_load_hooks"
require "active_support/concern"
require "active_support/core_ext/object/blank"
require "active_support/core_ext/class/attribute"
module BasedUUID
module HasBasedUUID
extend ActiveSupport::Concern
included do
class_attribute :_based_uuid_prefix
class_attr... |
github | pch/based_uuid | https://github.com/pch/based_uuid | test/test_has_based_uuid.rb | Ruby | mit | 85 | main | 3,130 | require "test_helper"
require "ostruct"
require "securerandom"
class FakeActiveRecordBase < OpenStruct
include BasedUUID::HasBasedUUID
class RecordNotFound < StandardError; end
class_attribute :primary_key
self.primary_key = "id"
class_attribute :fake_datastore
self.fake_datastore = {}
def self.creat... |
github | pch/based_uuid | https://github.com/pch/based_uuid | test/test_base32_uuid.rb | Ruby | mit | 85 | main | 1,768 | require "test_helper"
require "securerandom"
class TestBase32UUID < Minitest::Test
UUIDS_V7 = {
"018c3b49-560c-719f-9daf-bae405f6ffca" => "01hgxmjngce6fsvbxtwg2zdzya",
"018c3b49-f34a-7e22-90af-13b6f0a69d47" => "01hgxmkwtafrh91brkpvrad7a7",
"018c3b4a-093a-7072-b1ae-0170b310000e" => "01hgxmm29te1sb3bg1e2sh... |
github | pch/based_uuid | https://github.com/pch/based_uuid | test/test_based_uuid.rb | Ruby | mit | 85 | main | 2,245 | require "test_helper"
class TestBasedUUID < Minitest::Test
class DummyModel1; end
class DummyModel2; end
def teardown
BasedUUID.delimiter = "_"
end
def test_that_it_has_a_version_number
refute_nil ::BasedUUID::VERSION
end
def test_encoding
uuid = "018c3b49-560c-719f-9daf-bae405f6ffca"
... |
github | sous-chefs/iis | https://github.com/sous-chefs/iis | metadata.rb | Ruby | apache-2.0 | 85 | main | 358 | name 'iis'
maintainer 'Sous Chefs'
maintainer_email 'help@sous-chefs.org'
license 'Apache-2.0'
description 'Installs/Configures Windows IIS'
source_url 'https://github.com/sous-chefs/iis'
issues_url 'https://github.com/sous-chefs/iis/issues'
chef_version '>= 15.3'
version... |
github | sous-chefs/iis | https://github.com/sous-chefs/iis | libraries/processors.rb | Ruby | apache-2.0 | 85 | main | 4,030 | #
# Cookbook:: iis
# Library:: processors
#
# Copyright:: 2017-2019, Chef Software, 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#... |
github | sous-chefs/iis | https://github.com/sous-chefs/iis | libraries/constants.rb | Ruby | apache-2.0 | 85 | main | 23,954 | #
# Cookbook:: iis
# Library:: constants
#
# Copyright:: 2013-2019, Chef Software, 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... |
github | sous-chefs/iis | https://github.com/sous-chefs/iis | libraries/helper.rb | Ruby | apache-2.0 | 85 | main | 2,744 | #
# Cookbook:: iis
# Library:: helper
#
# Copyright:: 2017-2019, Chef Software, 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unl... |
github | sous-chefs/iis | https://github.com/sous-chefs/iis | libraries/section_helper.rb | Ruby | apache-2.0 | 85 | main | 2,641 | #
# Cookbook:: iis
# Library:: section-helper
#
# Copyright:: 2017-2019, Chef Software, 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
#
# http://www.apache.org/licenses/LICENSE-2.0... |
github | sous-chefs/iis | https://github.com/sous-chefs/iis | test/integration/section/libraries/iis_section.rb | Ruby | apache-2.0 | 85 | main | 2,728 | # frozen_string_literal: true
# check for sections in IIS
# Usage:
# describe iis_section('//staticContent', 'Default Web Site') do
# it { should exist }
# it { should have_override_mode('Allow') }
# it { should have_override_mode_effective('Allow') }
# end
#
# Note: this is only supported in windows 2012 and lat... |
github | sous-chefs/iis | https://github.com/sous-chefs/iis | test/integration/section/controls/section_spec.rb | Ruby | apache-2.0 | 85 | main | 432 | # copyright: 2017, Chef Software, Inc.
# license: All rights reserved
title 'iis_section section'
describe service('W3SVC') do
it { should be_installed }
it { should be_running }
its('startmode') { should eq 'Auto' }
end
describe iis_section('system.webServer/staticContent', 'Default Web Site') do
it { shoul... |
github | sous-chefs/iis | https://github.com/sous-chefs/iis | test/integration/default/spec/default_spec.rb | Ruby | apache-2.0 | 85 | main | 1,058 | #
# Copyright:: 2015-2019, Chef Software, 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agre... |
github | sous-chefs/iis | https://github.com/sous-chefs/iis | test/integration/site/site_spec.rb | Ruby | apache-2.0 | 85 | main | 1,662 | #
# Copyright:: 2017-2019, Chef Software, 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agre... |
github | sous-chefs/iis | https://github.com/sous-chefs/iis | test/integration/pool/libraries/iis_pool.rb | Ruby | apache-2.0 | 85 | main | 11,701 | # frozen_string_literal: true
# check for application pools in IIS
# Usage:
# describe iis_pool('DefaultAppPool') do
# it { should exist }
# it { should have_name('DefaultAppPool') }
# it { should have_queue_length(1000) }
# it { should be_running }
# end
#
# Note: this is only supported in windows 2012 and later
... |
github | sous-chefs/iis | https://github.com/sous-chefs/iis | test/integration/pool/controls/pool_spec.rb | Ruby | apache-2.0 | 85 | main | 2,363 | # copyright: 2017, Chef Software, Inc.
# license: All rights reserved
title 'iis_app section'
describe service('W3SVC') do
it { should be_installed }
it { should be_running }
its('startmode') { should eq 'Auto' }
end
describe iis_pool('myAppPool_v1_1') do
it { should exist }
it { should_not be_running }
... |
github | sous-chefs/iis | https://github.com/sous-chefs/iis | test/integration/config_property/config_property_spec.rb | Ruby | apache-2.0 | 85 | main | 738 | # copyright: 2018, Chef Software, Inc.
# license: All rights reserved
control 'config_property' do
title 'Check IIS properties are set'
describe powershell("(Get-WebConfigurationProperty -PSPath \"MACHINE/WEBROOT/APPHOST\" \
-filter \"system.applicationHost/sites/siteDefaults/logfile\" \
... |
github | sous-chefs/iis | https://github.com/sous-chefs/iis | test/integration/vdir/controls/vdir_spec.rb | Ruby | apache-2.0 | 85 | main | 1,099 | # copyright: 2017, Chef Software, Inc.
# license: All rights reserved
title 'iis_vdir section'
describe service('W3SVC') do
it { should be_installed }
it { should be_running }
its('startmode') { should eq 'Auto' }
end
describe iis_vdir('/vdir_test', 'Default Web Site') do
it { should exist }
it { should ha... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.