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
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
Rakefile
Ruby
mit
177
master
702
require 'bundler' require 'rspec/core/rake_task' desc "Run Rspec unit tests" RSpec::Core::RakeTask.new(:spec) do |t| t.pattern = "spec/keen/**/*_spec.rb" end desc "Run Rspec integration tests" RSpec::Core::RakeTask.new(:integration) do |t| t.pattern = "spec/integration/**/*_spec.rb" end desc "Run Rspec synchrony...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
Guardfile
Ruby
mit
177
master
744
group :unit do guard 'rspec', :spec_paths => ["spec/keen"] do watch('spec/spec_helper.rb') { "spec" } watch('spec/keen/spec_helper.rb') { "spec" } watch(%r{^spec/keen/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/keen/#{m[1]}_spec.rb" } end end group :integration do guard 'rspec', :s...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
keen.gemspec
Ruby
mit
177
master
1,400
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "keen/version" Gem::Specification.new do |s| s.name = "keen" s.version = Keen::VERSION s.authors = ["Alex Kleissner", "Joe Wegner"] s.email = "opensource@keen.io" s.homepage = "https://github.com/keenlabs/k...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
lib/keen.rb
Ruby
mit
177
master
2,460
require 'logger' require 'forwardable' require 'keen/access_keys' require 'keen/client' require 'keen/saved_queries' require 'keen/cached_datasets' require 'keen/scoped_key' module Keen class Error < RuntimeError attr_accessor :original_error def initialize(message, _original_error=nil) self.original_...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
lib/keen/aes_helper.rb
Ruby
mit
177
master
1,008
require 'openssl' require 'digest' require 'base64' module Keen class AESHelper class << self def aes256_decrypt(key, iv_plus_encrypted) aes = OpenSSL::Cipher::AES.new(256, :CBC) iv = iv_plus_encrypted[0, aes.key_len] encrypted = iv_plus_encrypted[aes.key_len, iv_plus_encrypted.len...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
lib/keen/access_keys.rb
Ruby
mit
177
master
2,604
require 'multi_json' module Keen class AccessKeys def initialize(client) @client = client end def get(key) client.ensure_master_key! path = "/#{key}" response = access_keys_get(client.master_key, path) client.process_response(response.code.to_i, response.body) end ...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
lib/keen/client.rb
Ruby
mit
177
master
5,358
require 'keen/http' require 'keen/version' require 'keen/client/publishing_methods' require 'keen/client/querying_methods' require 'keen/client/maintenance_methods' require 'keen/version' require 'openssl' require 'multi_json' require 'base64' require 'cgi' require 'addressable/uri' module Keen class Client incl...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
lib/keen/cached_datasets.rb
Ruby
mit
177
master
3,419
require 'keen/version' require "json" require 'uri' module Keen class CachedDatasets def initialize(client) @client = client end def list(limit: nil, after_name: nil) client.ensure_master_key! query_params = clear_nil_attributes(limit: limit, after_name: after_name) response = _...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
lib/keen/aes_helper_old.rb
Ruby
mit
177
master
1,423
require 'openssl' require 'digest' require 'base64' module Keen class AESHelperOld BLOCK_SIZE = 32 class << self def aes256_decrypt(key, iv_plus_encrypted) padded_key = pad(key) unhexed_iv_plus_encrypted = unhexlify(iv_plus_encrypted) iv = unhexed_iv_plus_encrypted[0, 16] ...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
lib/keen/http.rb
Ruby
mit
177
master
2,734
module Keen module HTTP class Sync def initialize(base_url, proxy_url=nil, read_timeout=nil, open_timeout=nil) require 'uri' require 'net/http' uri = URI.parse(base_url) arguments = [uri.host, uri.port] arguments+= proxy_arguments_for(proxy_url) if proxy_url ...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
lib/keen/scoped_key.rb
Ruby
mit
177
master
1,049
require 'multi_json' require 'keen/aes_helper' require 'keen/aes_helper_old' module Keen # <b>DEPRECATED:</b> Please use <tt>access keys</tt> instead. class ScopedKey attr_accessor :api_key attr_accessor :data class << self def decrypt!(api_key, scoped_key) if api_key.length == 64 ...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
lib/keen/saved_queries.rb
Ruby
mit
177
master
3,517
require 'keen/version' require "json" module Keen class SavedQueries def initialize(client) @client = client end def all client.ensure_master_key! response = saved_query_response(client.master_key) client.process_response(response.code.to_i, response.body) end def get(s...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
lib/keen/client/querying_methods.rb
Ruby
mit
177
master
10,020
require 'uri' module Keen class Client module QueryingMethods # Runs a count query. # See detailed documentation here: # https://keen.io/docs/api/reference/#count-resource # # @param event_collection # @param params [Hash] (optional) # group_by (optional) # ti...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
lib/keen/client/maintenance_methods.rb
Ruby
mit
177
master
3,375
module Keen class Client module MaintenanceMethods # Runs a delete query. # See detailed documentation here: # https://keen.io/docs/maintenance/#deleting-event-collections # # @param event_collection # @param params [Hash] (optional) # filters (optional) [Array] ...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
lib/keen/client/publishing_methods.rb
Ruby
mit
177
master
6,316
module Keen class Client module PublishingMethods # @deprecated # # Publishes a synchronous event # @param event_collection # @param [Hash] event properties # # @return the JSON response from the API def add_event(event_collection, properties, options={}) s...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/spec_helper.rb
Ruby
mit
177
master
2,560
begin require 'bundler/setup' rescue LoadError puts 'Use of Bundler is recommended' end require 'rspec' require 'net/https' require 'em-http' require File.expand_path("../../lib/keen", __FILE__) module Keen::SpecHelpers def stub_keen_request(method, url, status, response_body) stub_request(method, url).to_...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/synchrony/synchrony_spec.rb
Ruby
mit
177
master
3,276
require File.expand_path("../spec_helper", __FILE__) describe Keen::HTTP::Async do let(:project_id) { "12345" } let(:write_key) { "abcdewrite" } let(:collection) { "users" } let(:api_url) { "https://fake.keen.io" } let(:event_properties) { { "name" => "Bob" } } let(:api_success) { { "created" => true } } ...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/integration/access_keys_spec.rb
Ruby
mit
177
master
1,795
require File.expand_path("../spec_helper", __FILE__) describe "Access Keys" do let(:project_id) { ENV["KEEN_PROJECT_ID"] } let(:master_key) { ENV["KEEN_MASTER_KEY"] } let(:client) { Keen::Client.new(project_id: project_id, master_key: master_key) } describe "#all" do it "gets all access keys" do exp...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/integration/spec_helper.rb
Ruby
mit
177
master
236
require File.expand_path("../../spec_helper", __FILE__) RSpec.configure do |config| unless ENV['KEEN_PROJECT_ID'] raise "Please set a KEEN_PROJECT_ID on the environment before running the integration specs." end end
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/integration/api_spec.rb
Ruby
mit
177
master
10,724
require File.expand_path("../spec_helper", __FILE__) describe "Keen IO API" do let(:project_id) { ENV['KEEN_PROJECT_ID'] } let(:write_key) { ENV['KEEN_WRITE_KEY'] } def wait_for_count(event_collection, count) attempts = 0 while attempts < 30 break if Keen.count(event_collection, {:timeframe => "th...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/integration/saved_query_spec.rb
Ruby
mit
177
master
1,080
require File.expand_path("../spec_helper", __FILE__) describe "Saved Queries" do let(:project_id) { ENV["KEEN_PROJECT_ID"] } let(:master_key) { ENV["KEEN_MASTER_KEY"] } let(:read_key) { ENV["KEEN_READ_KEY"] } let(:client) { Keen::Client.new(project_id: project_id, master_key: master_key, read_key: read_key) } ...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/keen/access_keys_spec.rb
Ruby
mit
177
master
2,625
require File.expand_path("../spec_helper", __FILE__) describe Keen do let(:client) do Keen::Client.new( project_id: "12341234", master_key: "abcdef", api_url: "https://notreal.keen.io" ) end describe "#access_keys" do describe "#all" do it "returns all access keys" do ...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/keen/keen_spec.rb
Ruby
mit
177
master
3,472
require File.expand_path("../spec_helper", __FILE__) describe Keen do describe "default client" do describe "configuring from the environment" do before do Keen.instance_variable_set(:@default_client, nil) ENV["KEEN_PROJECT_ID"] = "12345" ENV["KEEN_WRITE_KEY"] = "abcdewrite" ...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/keen/scoped_key_old_spec.rb
Ruby
mit
177
master
1,999
require 'spec_helper' describe Keen::ScopedKey do let(:api_key) { "ab428324dbdbcfe744" } let(:bad_api_key) { "badbadbadbad" } let(:data) { { "filters" => [{ "property_name" => "accountId", "operator" => "eq", "property_value" => "123456" }] }} let(:new_scoped_key) { Keen::ScopedKey.n...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/keen/scoped_key_spec.rb
Ruby
mit
177
master
1,833
require 'spec_helper' describe Keen::ScopedKey do let(:api_key) { "24077ACBCB198BAAA2110EDDB673282F8E34909FD823A15C55A6253A664BE368" } let(:bad_api_key) { "24077ACBCB198BAAA2110EDDB673282F8E34909FD823A15C55A6253A664BE369" } let(:data) { { "filters" => [{ "property_name" => "accountId", "operat...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/keen/cached_dataset_spec.rb
Ruby
mit
177
master
10,307
require File.expand_path("../spec_helper", __FILE__) describe Keen do let(:client) do Keen::Client.new( project_id: "12341234", master_key: "abcdef", read_key: "ghijkl", api_url: "https://notreal.keen.io" ) end describe "#cached_datasets" do describe "#list" do it "ret...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/keen/saved_query_spec.rb
Ruby
mit
177
master
5,002
require File.expand_path("../spec_helper", __FILE__) describe Keen do let(:client) do Keen::Client.new( project_id: "12341234", master_key: "abcdef", api_url: "https://notreal.keen.io" ) end describe "#saved_queries" do describe "#all" do it "returns all saved queries" do ...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/keen/client_spec.rb
Ruby
mit
177
master
4,463
require File.expand_path("../spec_helper", __FILE__) describe Keen::Client do let(:project_id) { "12345" } let(:write_key) { "abcdewrite" } let(:read_key) { "abcderead" } let(:api_url) { "http://fake.keen.io:fakeport" } let(:client) { Keen::Client.new(:project_id => project_id) } let(:read_timeout) { 40 } ...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/keen/client/querying_methods_spec.rb
Ruby
mit
177
master
9,157
require File.expand_path("../../spec_helper", __FILE__) describe Keen::Client do let(:project_id) { "12345" } let(:read_key) { "abcde" } let(:api_url) { "https://notreal.keen.io" } let(:api_version) { "3.0" } let(:event_collection) { "users" } let(:client) { Keen::Client.new( :project_id => project_id,...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/keen/client/maintenance_methods_spec.rb
Ruby
mit
177
master
2,487
require File.expand_path("../../spec_helper", __FILE__) describe Keen::Client do let(:project_id) { "12345" } let(:master_key) { 'pastor_of_muppets' } let(:api_url) { "https://notreal.keen.io" } let(:api_version) { "3.0" } let(:client) { Keen::Client.new( :project_id => project_id, :master_key => master...
github
keenlabs/keen-gem
https://github.com/keenlabs/keen-gem
spec/keen/client/publishing_methods_spec.rb
Ruby
mit
177
master
11,394
require File.expand_path("../../spec_helper", __FILE__) describe Keen::Client::PublishingMethods do let(:project_id) { "12345" } let(:write_key) { "abcde" } let(:api_url) { "https://unreal.keen.io" } let(:collection) { "some :actions_to.record" } let(:event_properties) { { "name" => "Bob" } } let(:api_succ...
github
isonic1/flick
https://github.com/isonic1/flick
flick.gemspec
Ruby
mit
99
master
1,744
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'flick/version' Gem::Specification.new do |spec| spec.name = "flick" spec.version = Flick::VERSION spec.authors = ["Justin"] spec.email = ["justin.ison@gmail.c...
github
isonic1/flick
https://github.com/isonic1/flick
spec/ios_spec.rb
Ruby
mit
99
master
1,314
require 'spec_helper' describe "Flick iOS Validations" do before :all do @options = {platform: "ios", flick_dir: "#{Dir.home}/.flick", outdir: Dir.pwd} Flick::Ios.new(@options).check_for_devices `rm *.png *.mp4 >> /dev/null 2>&1` end after :each do `rm *.png *.mp4 >> /dev/null 2>&1` end ...
github
isonic1/flick
https://github.com/isonic1/flick
spec/android_spec.rb
Ruby
mit
99
master
3,070
require 'spec_helper' describe "Flick Android Validations" do before :all do androids = ["TA64300B9C", "emulator-5554"] #set one real device and one emulator @options = {platform: "android", flick_dir: "#{Dir.home}/.flick", dir_name: "sdcard/flick", outdir: Dir.pwd, specs: true} Flick::Android.new(@op...
github
isonic1/flick
https://github.com/isonic1/flick
lib/flick.rb
Ruby
mit
99
master
818
require 'colorize' require 'json' require 'parallel' require 'wannabe_bool' require 'awesome_print' require 'os' require 'tempfile' require 'sys/proctable' require 'apktools/apkxml' require 'open3' require 'eyes_images' require 'pry' require 'openssl' original_verbose = $VERBOSE $VERBOSE = nil OpenSSL::SSL::VERIFY_PEER...
github
isonic1/flick
https://github.com/isonic1/flick
lib/flick/log.rb
Ruby
mit
99
master
1,043
class Log attr_accessor :action, :platform, :driver, :udid def initialize options Flick::Checker.action options[:action] Flick::Checker.platform options[:platform] self.action = options[:action] self.platform = options[:platform] case @platform when "ios" options[:todir] = options[:o...
github
isonic1/flick
https://github.com/isonic1/flick
lib/flick/android.rb
Ruby
mit
99
master
6,196
module Flick class Android attr_accessor :udid, :flick_dir, :dir_name, :name, :outdir, :unique, :limit, :specs, :size, :use_screenshots def initialize options Flick::Checker.system_dependency "adb" if options[:udid].nil? self.udid = get_device_udid else self.udid = options[:...
github
isonic1/flick
https://github.com/isonic1/flick
lib/flick/vitals.rb
Ruby
mit
99
master
720
class Vitals attr_accessor :platform, :driver, :name def initialize options Flick::Checker.platform options[:platform] self.platform = options[:platform] case @platform when "ios" options[:todir] = options[:outdir] self.driver = Flick::Ios.new options when "android" self.driv...
github
isonic1/flick
https://github.com/isonic1/flick
lib/flick/simple_daemon.rb
Ruby
mit
99
master
4,380
#!/usr/bin/env ruby # # https://gist.githubusercontent.com/mynameisrufus/1372491/raw/b76b60fb1842bf0507f47869ab19ad50a045b214/simple_daemon.rb # # == Double-forking Unix daemon # # Author:: Rufus Post (mailto:rufuspost@gmail.com) # # === How does it work? # # According to Stevens's Advanced Programming in the UNIX Env...
github
isonic1/flick
https://github.com/isonic1/flick
lib/flick/ios.rb
Ruby
mit
99
master
3,633
module Flick class Ios attr_accessor :flick_dir, :udid, :name, :outdir, :todir, :specs def initialize options self.udid = options.fetch(:udid, get_device_udid(options)) self.flick_dir = "#{Dir.home}/.flick/#{udid}" self.name = remove_bad_characters(options.fetch(:name, self.udid)) sel...
github
isonic1/flick
https://github.com/isonic1/flick
lib/flick/info.rb
Ruby
mit
99
master
810
class Info attr_accessor :platform, :driver, :save def initialize options Flick::Checker.platform options[:platform] self.platform = options[:platform] case @platform when "ios" options[:todir] = options[:outdir] self.driver = Flick::Ios.new options when "android" self.driver...
github
isonic1/flick
https://github.com/isonic1/flick
lib/flick/checker.rb
Ruby
mit
99
master
1,791
module Flick module Checker def self.which(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each { |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable?(exe) && !File.directory?(ex...
github
isonic1/flick
https://github.com/isonic1/flick
lib/flick/manager.rb
Ruby
mit
99
master
934
class Manager attr_accessor :action, :platform, :driver, :udid, :file, :name def initialize options Flick::Checker.manager options[:action] Flick::Checker.platform options[:platform] self.action = options[:action] self.platform = options[:platform] case platform when "ios" self.drive...
github
isonic1/flick
https://github.com/isonic1/flick
lib/flick/system.rb
Ruby
mit
99
master
1,142
module Flick module System include Sys #load sys-proctable methods def self.setup_system_dir dir_name Dir.mkdir dir_name unless File.exists? dir_name end def self.clean_system_dir dir_name, udid Dir.glob("#{dir_name}/*#{udid}*").each do |file| File.delete file end end ...
github
isonic1/flick
https://github.com/isonic1/flick
lib/flick/applitools.rb
Ruby
mit
99
master
1,292
require 'date' class Applitoolz attr_accessor :platform, :driver, :eyes, :app_name, :test_name, :keep def initialize options self.platform = options[:platform] self.driver = Screenshot.new options self.eyes = Applitools::Images::Eyes.new eyes.api_key = options[:apiKey] eyes.server_url = optio...
github
isonic1/flick
https://github.com/isonic1/flick
lib/flick/screenshot.rb
Ruby
mit
99
master
977
class Screenshot attr_accessor :platform, :driver def initialize options Flick::Checker.platform options[:platform] self.platform = options[:platform] case platform when "ios" options[:todir] = options[:outdir] self.driver = Flick::Ios.new options when "android" self.driver =...
github
isonic1/flick
https://github.com/isonic1/flick
lib/flick/video.rb
Ruby
mit
99
master
4,091
class Video attr_accessor :action, :platform, :driver, :image_count, :seconds, :rate, :extended, :udid, :format def initialize options Flick::Checker.action options[:action] Flick::Checker.platform options[:platform] Flick::Checker.format options[:format] self.action = options[:action] self.pl...
github
voxpupuli/vagrant-librarian-puppet
https://github.com/voxpupuli/vagrant-librarian-puppet
Gemfile
Ruby
mit
99
master
208
source 'https://rubygems.org' gemspec group :development do gem 'vagrant', github: 'mitchellh/vagrant', ref: 'v1.8.1' gem 'byebug' end group :plugins do gem 'vagrant-librarian-puppet', path: '.' end
github
voxpupuli/vagrant-librarian-puppet
https://github.com/voxpupuli/vagrant-librarian-puppet
vagrant-librarian-puppet.gemspec
Ruby
mit
99
master
1,223
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'vagrant-librarian-puppet/version' Gem::Specification.new do |spec| spec.name = "vagrant-librarian-puppet" spec.version = VagrantPlugins::LibrarianPuppet::VERSION spec.authors...
github
voxpupuli/vagrant-librarian-puppet
https://github.com/voxpupuli/vagrant-librarian-puppet
Vagrantfile
Ruby
mit
99
master
1,174
#!/usr/bin/env ruby # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure('2') do |config| # box needs to provide puppet >= 4 config.vm.box = 'puppetlabs/ubuntu-12.04-64-puppet' config.vm.define "default" do |default| default.librarian_puppet.puppetfile_dir = 'puppet' default.librarian_puppet.place...
github
voxpupuli/vagrant-librarian-puppet
https://github.com/voxpupuli/vagrant-librarian-puppet
lib/vagrant-librarian-puppet/plugin.rb
Ruby
mit
99
master
729
begin require "vagrant" rescue LoadError abort "vagrant-librarian-puppet must be loaded in a Vagrant environment." end require "vagrant-librarian-puppet/action/librarian_puppet" module VagrantPlugins module LibrarianPuppet class Plugin < Vagrant.plugin("2") name "vagrant-librarian-puppet" descr...
github
voxpupuli/vagrant-librarian-puppet
https://github.com/voxpupuli/vagrant-librarian-puppet
lib/vagrant-librarian-puppet/config.rb
Ruby
mit
99
master
1,377
module VagrantPlugins module LibrarianPuppet class Config < Vagrant.plugin(2, :config) attr_accessor :puppetfile_dir attr_accessor :use_v1_api attr_accessor :destructive attr_accessor :placeholder_filename attr_accessor :resolve_options def initialize @puppetfile_dir =...
github
voxpupuli/vagrant-librarian-puppet
https://github.com/voxpupuli/vagrant-librarian-puppet
lib/vagrant-librarian-puppet/action/librarian_puppet.rb
Ruby
mit
99
master
2,807
require 'librarian/puppet' require 'librarian/action' require "librarian/puppet/action/install" module VagrantPlugins module LibrarianPuppet module Action class Install def initialize(app, env) @app = app @env = env # Config#finalize! SHOULD be called automatically ...
github
discourse/mini_mime
https://github.com/discourse/mini_mime
mini_mime.gemspec
Ruby
mit
99
main
1,097
# coding: utf-8 # frozen_string_literal: true lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) if !$LOAD_PATH.include?(lib) require 'mini_mime/version' Gem::Specification.new do |spec| spec.name = "mini_mime" spec.version = MiniMime::VERSION spec.authors = ["Sam Saffron"] ...
github
discourse/mini_mime
https://github.com/discourse/mini_mime
Rakefile
Ruby
mit
99
main
2,122
# 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 task default: :test # rubocop:disable Discourse/Plugins/NamespaceMethods def pad(array) max = [] array.each do...
github
discourse/mini_mime
https://github.com/discourse/mini_mime
Gemfile
Ruby
mit
99
main
214
# frozen_string_literal: true source 'https://rubygems.org' # Specify your gem's dependencies in mini_mime.gemspec gemspec gem "mime-types", "~> 3" if RUBY_VERSION > '2' gem "memory_profiler" gem "benchmark-ips"
github
discourse/mini_mime
https://github.com/discourse/mini_mime
test/mini_mime_test.rb
Ruby
mit
99
main
5,122
# frozen_string_literal: true require 'test_helper' begin require 'mime/types/columnar' rescue LoadError end class MiniMimeTest < Minitest::Test def test_that_it_has_a_version_number refute_nil ::MiniMime::VERSION end def test_extension assert_equal "application/zip", MiniMime.lookup_by_extension("zi...
github
discourse/mini_mime
https://github.com/discourse/mini_mime
test/mini_mime/configuration_test.rb
Ruby
mit
99
main
1,335
# frozen_string_literal: true require 'test_helper' class MiniMime::ConfigurationTest < Minitest::Test CUSTOM_EXT_MIME_DB_PATH = File.expand_path("../../fixtures/custom_ext_mime.db", __FILE__) CUSTOM_CONTENT_TYPE_MIME_DB_PATH = File.expand_path("../../fixtures/custom_content_type_mime.db", __FILE__) def setup ...
github
discourse/mini_mime
https://github.com/discourse/mini_mime
lib/mini_mime.rb
Ruby
mit
99
main
4,453
# frozen_string_literal: true require "mini_mime/version" module MiniMime def self.lookup_by_filename(filename) Db.lookup_by_filename(filename) end def self.lookup_by_extension(extension) Db.lookup_by_extension(extension) end def self.lookup_by_content_type(mime) Db.lookup_by_content_type(mime)...
github
discourse/mini_mime
https://github.com/discourse/mini_mime
bench/bench.rb
Ruby
mit
99
main
1,375
# frozen_string_literal: true require 'memory_profiler' require 'benchmark/ips' $: << File.expand_path('../../lib', __FILE__) puts puts "Memory stats for requiring mime/types/columnar" result = MemoryProfiler.report do require 'mime/types/columnar' end puts "Total allocated: #{result.total_allocated_memsize} bytes...
github
totheralistair/SmallerWebHexagon
https://github.com/totheralistair/SmallerWebHexagon
config.ru
Ruby
mit
99
master
240
# run the Smaller Web Hexagon from a browser require './src/smaller_web_hexagon' require './src/rack_http_adapter' require './src/raters' hex = SmallerWebHexagon.new(InCodeRater.new) app = RackHttpAdapter.new(hex,"./src/views/") run app
github
totheralistair/SmallerWebHexagon
https://github.com/totheralistair/SmallerWebHexagon
src/raters.rb
Ruby
mit
99
master
855
# a Rater produces a multiplier ("rate") given a value # here are two kinds of raters: # - a variable in-code one that can be used when the db is down # - one w the table stored in a file (or db, but I only know files so far) # note: I'm making them give different rates, so that mistakes show up easier class InCod...
github
totheralistair/SmallerWebHexagon
https://github.com/totheralistair/SmallerWebHexagon
src/rack_http_adapter.rb
Ruby
mit
99
master
1,155
require 'rack' require 'pathname' require_relative '../src/html_from_template_file' # Primary adapter to SmallerWebHexagon, using Rack for web-type I/O class RackHttpAdapter def initialize(hex_app, views_folder) @app = hex_app @views_folder = views_folder end def call(env) # hooks into the Rack Reques...
github
totheralistair/SmallerWebHexagon
https://github.com/totheralistair/SmallerWebHexagon
src/smaller_web_hexagon.rb
Ruby
mit
99
master
576
# Welcome to Smallerwebhexagon, the simple web hexagon implementation # Alistair Cockburn and a couple of really nice friends # this hexagon has one primary port and one secondary # the user/test/web side is the primary # the rates "database" mechanism is the secondary # the app itself just returns value * rate(as a f...
github
totheralistair/SmallerWebHexagon
https://github.com/totheralistair/SmallerWebHexagon
test/test_smaller_web_hexagon.rb
Ruby
mit
99
master
1,772
require_relative '../src/smaller_web_hexagon' require_relative '../src/rack_http_adapter' require_relative '../src/raters' require 'rack/test' require 'rspec/expectations' require 'test/unit' # The first 2 tests check the primary adapter swaps, using direct API access for the left # The last test checks the secondary ...
github
jondot/padrino-warden
https://github.com/jondot/padrino-warden
padrino-warden.gemspec
Ruby
mit
99
master
1,115
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'padrino/warden/version' Gem::Specification.new do |spec| spec.name = "padrino-warden" spec.version = Padrino::Warden::VERSION spec.authors = ["Dotan Nahum", "Michał Zaj...
github
jondot/padrino-warden
https://github.com/jondot/padrino-warden
lib/padrino/warden.rb
Ruby
mit
99
master
1,917
require 'warden' $:.unshift File.join( File.dirname(__FILE__), '..', '..' ) require 'padrino/warden/version' require 'padrino/warden/controller' require 'padrino/warden/helpers' module Padrino module Warden def self.registered(app, register_controller = true) { # Enable sessions but allow the use...
github
jondot/padrino-warden
https://github.com/jondot/padrino-warden
lib/padrino/warden/helpers.rb
Ruby
mit
99
master
1,971
module Padrino module Warden module Helpers # The main accessor to the warden middleware def warden request.env['warden'] end # Return session info # # @param [Symbol] the scope to retrieve session info for def session_info(scope=nil) scope ? warden.sessi...
github
jondot/padrino-warden
https://github.com/jondot/padrino-warden
lib/padrino/warden/controller.rb
Ruby
mit
99
master
2,347
module Padrino module Warden module Controller def self.registered(app) app.controller :sessions do %w(get put post delete head options patch link unlink).each do |method| __send__ method, :unauthenticated, map: app.auth_unauthenticated_path do status 401 ...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
eldr.gemspec
Ruby
mit
99
master
1,399
# -*- encoding: utf-8 -*- require File.expand_path('../lib/eldr/version', __FILE__) Gem::Specification.new do |s| s.name = 'eldr' s.version = Eldr::VERSION s.platform = Gem::Platform::RUBY s.authors = ['K-2052'] s.email = ['k@2052.me'] s.homepage = 'https://github.com/eldr-rb/eld...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/route_spec.rb
Ruby
mit
99
master
2,806
class CatsHandler def index(env) 'cats' end end class ActionHandler def call(env) 'action handled!' end end describe Eldr::Route do describe '.new' do it 'returns a new instance' do expect(Eldr::Route.new).to be_instance_of Eldr::Route end it 'takes options and sets them' do ...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/configuration_spec.rb
Ruby
mit
99
master
697
describe Eldr::Configuration do describe '#initialize' do it 'sets defaults' do expect(Eldr::Configuration.new().lock).to eq(false) end end describe '#set' do let(:config) { Eldr::Configuration.new } it 'sets a configuration value in #table' do config.set(:bob, 'what about him?') ...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/readme_spec.rb
Ruby
mit
99
master
3,131
require 'yaml' describe 'README' do let(:readme) do readme = YAML.load_file(File.expand_path('./readme_definitions.yml', File.dirname(__FILE__))) end it 'has a hook' do expect(readme['has_hook']).to eq true end it 'links to badges' do expect(readme['links_to_badges']).to eq true end it 'ha...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/recognizer_spec.rb
Ruby
mit
99
master
800
describe Eldr::Recognizer do describe '#call' do let(:resp_proc) { proc { [200, {}, ['Hello Bob!']] } } subject(:app) do bob = Class.new(Eldr::App) bob.get '/cats', resp_proc bob end let(:recognizer) { Eldr::Recognizer.new(app.routes) } context 'when there are matching routes' ...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/matcher_spec.rb
Ruby
mit
99
master
520
describe Eldr::Matcher do describe '#match' do let(:matcher) { Eldr::Matcher.new('/cats/:id') } context 'when pattern matches' do it 'returns MatchData' do expect(matcher.match('/cats/bob')).to be_instance_of MatchData end it 'returns the splats' do expect(matcher.match('/c...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/app_spec.rb
Ruby
mit
99
master
4,683
describe Eldr::App do it 'has methods for all the http verbs' do %w(DELETE GET HEAD OPTIONS PATCH POST PUT).each do |verb| expect(Eldr::App.respond_to? verb.downcase.to_sym).to eq(true) end end describe '.inherited' do it 'inherits middleware' do bob = Class.new(Eldr::App) middlewar...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/builder_spec.rb
Ruby
mit
99
master
315
describe Eldr::Builder do describe '#use' do it 'supports passing an array of middleware' do builder = Eldr::Builder.new builder.use Class.new builder_2 = Eldr::Builder.new builder_2.use builder.middleware expect(builder_2.middleware).to eq(builder.middleware) end end end
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/spec_helper.rb
Ruby
mit
99
master
333
if ENV['COVERALLS_REPO_TOKEN'] require 'coveralls' Coveralls.wear! end require 'rack/test' require 'rack' require_relative '../lib/eldr' # Hardcode an instance into a global because rack-test likes to get too clever RSpec.configure do |config| config.include Rack::Test::Methods config.pattern = '**{,/*/**}/*_...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/examples/example_app_spec.rb
Ruby
mit
99
master
2,189
describe "ExampleApp" do it 'does not pollute the base class with routes' do expect(Eldr::App.routes[:get].length).to eq(0) end let(:app) do path = File.expand_path("../../examples/app.ru", File.dirname(__FILE__)) Rack::Builder.parse_file(path).first end let(:rt) do Rack::Test::Session.new(a...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/examples/action_objects_spec.rb
Ruby
mit
99
master
407
describe "ActionObjectsExample" do let(:app) do path = File.expand_path("../../examples/action_objects.ru", File.dirname(__FILE__)) Rack::Builder.parse_file(path).first end let(:rt) do Rack::Test::Session.new(app) end describe 'GET /cats/bob' do it 'returns bob' do response = rt.get '/...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/examples/multiple_apps_spec.rb
Ruby
mit
99
master
690
describe 'MultipleAppsExample' do let(:app) do path = File.expand_path("../../examples/multiple_apps.ru", File.dirname(__FILE__)) Rack::Builder.parse_file(path).first end let(:rt) do Rack::Test::Session.new(app) end describe 'GET /' do it 'returns hello world' do response = rt.get '/' ...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/examples/rendering_templates_spec.rb
Ruby
mit
99
master
727
describe 'RenderingTemplatesExample' do let(:app) do path = File.expand_path("../../examples/rendering_templates.ru", File.dirname(__FILE__)) Rack::Builder.parse_file(path).first end let(:rt) do Rack::Test::Session.new(app) end describe 'GET /cats' do it "should return a template" do r...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/examples/hello_world_spec.rb
Ruby
mit
99
master
384
describe 'HelloWorldExample' do let(:app) do path = File.expand_path("../../examples/hello_world.ru", File.dirname(__FILE__)) Rack::Builder.parse_file(path).first end let(:rt) do Rack::Test::Session.new(app) end describe 'GET /' do it 'returns hello world' do response = rt.get '/' ...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/examples/errors_spec.rb
Ruby
mit
99
master
409
describe 'ErrorsExample' do let(:app) do path = File.expand_path("../../examples/errors.ru", File.dirname(__FILE__)) Rack::Builder.parse_file(path).first end let(:rt) do Rack::Test::Session.new(app) end describe 'GET /' do it 'returns an error' do response = rt.get '/' expect(res...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/examples/rails_style_routing_spec.rb
Ruby
mit
99
master
428
describe 'RailsStyleRoutingExample' do let(:app) do path = File.expand_path("../../examples/rails_style_routing.ru", File.dirname(__FILE__)) Rack::Builder.parse_file(path).first end let(:rt) do Rack::Test::Session.new(app) end describe 'GET /cats' do it 'returns a greeting from cats' do ...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/examples/custom_response_spec.rb
Ruby
mit
99
master
399
describe 'CustomResponseExample' do let(:app) do path = File.expand_path("../../examples/custom_response.ru", File.dirname(__FILE__)) Rack::Builder.parse_file(path).first end let(:rt) do Rack::Test::Session.new(app) end describe 'GET /' do it 'returns hello world' do response = rt.get ...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/examples/builder_spec.rb
Ruby
mit
99
master
357
describe 'BuilderExample' do let(:app) do path = File.expand_path("../../examples/builder.ru", File.dirname(__FILE__)) Rack::Builder.parse_file(path).first end let(:rt) do Rack::Test::Session.new(app) end describe 'GET /' do it 'does some counting using middleware' do expect(rt.get('/'...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
spec/examples/inheritance_spec.rb
Ruby
mit
99
master
529
describe 'InheritedApp' do let(:app) do path = File.expand_path("../../examples/inheritance.ru", File.dirname(__FILE__)) Rack::Builder.parse_file(path).first end let(:rt) do Rack::Test::Session.new(app) end describe 'GET /' do it 'counts using counter middleware' do response = rt.get '...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
lib/eldr/builder.rb
Ruby
mit
99
master
1,451
require 'rack/builder' module Eldr class Builder < Rack::Builder attr_accessor :middleware def initialize(default_app = nil, &block) @middleware, @map, @run, @warmup = [], nil, default_app, nil instance_eval(&block) if block_given? end def self.app(default_app = nil, &block) new(de...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
lib/eldr/cascade.rb
Ruby
mit
99
master
930
# A version of Rack::Cascade that works with Rack::Response. # Seriously? WTF Rack::Cascade # TODO: Get fixes into rack and remove this entirely module Eldr class Cascade NOTFOUND = [404, { 'CONTENT-TYPE' => 'text/plain' }, []] attr_reader :apps def initialize(apps, catch = [404, 405]) @apps = ...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
lib/eldr/configuration.rb
Ruby
mit
99
master
878
module Eldr ### # This a OpenStruct like class. # It wraps a hash and when you hit a method that doesn't exist it tries to pull it from the hash # Probably can break in 100 ways an is dumb, but it works. # And it performs astromnomically better than stuff like Hashie::Mash ### class Configuration attr...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
lib/eldr/recognizer.rb
Ruby
mit
99
master
685
require 'fast_blank' module Eldr class Recognizer class NotFound < StandardError def call(_env) [404, {}, ['']] end end attr_accessor :app, :env, :routes, :pattern def initialize(routes) @routes = routes end def call(env) @env = env ret_routes = route...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
lib/eldr/route.rb
Ruby
mit
99
master
1,885
module Eldr class Route attr_accessor :app, :verb, :path, :name, :order, :handler, :before_filters, :after_filters def initialize(verb: :get, path: '/', name: nil, order: 0, handler: nil, to: nil) @verb, @path, @name, @order = verb.to_s.upcase, path, name, order @before_filters, @after_filters = ...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
lib/eldr/app.rb
Ruby
mit
99
master
3,512
require 'forwardable' require 'rack/request' require_relative 'route' require_relative 'matcher' require_relative 'recognizer' require_relative 'configuration' require_relative 'builder' ### # Eldr is a minimal Ruby framework ### module Eldr ### # The main class all Eldr apps extend ### class App # rubocop:di...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
lib/eldr/matcher.rb
Ruby
mit
99
master
413
require 'mustermann' module Eldr class Matcher def initialize(path, options = {}) @path = path @capture = options.delete(:capture) end def match(pattern) handler.match(pattern) end def handler @handler ||= case @path when String Mustermann.new(@pat...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
examples/rails_style_routing.ru
Ruby
mit
99
master
244
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'eldr' class Cats def index env Rack::Response.new "Hello from all the Cats!" end end class RailsStyle < Eldr::App get '/cats', to: 'Cats#index' end run RailsStyle
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
examples/errors.ru
Ruby
mit
99
master
284
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'eldr' class ErrorResponse < StandardError def call(env) Rack::Response.new message, 500 end end class ErrorsExample < Eldr::App get '/' do raise ErrorResponse, "Bad Data" end end run ErrorsExample
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
examples/builder.ru
Ruby
mit
99
master
436
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'eldr' class SimpleCounterMiddleware def initialize(app) @app = app end def call(env) env['eldr.simple_counter'] ||= 0 env['eldr.simple_counter'] += 1 @app.call(env) end end class BuilderExample < Eldr::App use SimpleCounter...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
examples/app.ru
Ruby
mit
99
master
1,102
class ExampleApp < Eldr::App class NotFound < StandardError def call(env) [404, {}, ['']] end end attr_accessor :cats before :before do @thing1 = "Thing1" end before do @thing2 = "Thing2" end after :cats do @cats == 'Cats!' end get '/posts' do Rack::Response.new "po...
github
eldr-rb/eldr
https://github.com/eldr-rb/eldr
examples/action_objects.ru
Ruby
mit
99
master
456
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'eldr' class Show attr_accessor :env def helper_logic # do things here end def params env['eldr.params'] end def call(env) @env = env helper_logic # @cat = Cat.find params[:id] Rack::Response.new "Found cat nam...