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
securityroots/passdb
https://github.com/securityroots/passdb
lib/passdb.rb
Ruby
mit
19
master
936
require 'open-uri' require 'nokogiri' require 'passdb/entry' require 'passdb/version' module Passdb URL = 'http://cirt.net/passwords' def self.search(args={}) type, query = args.first if ![:vendor, :criteria].include?(type) || query.nil? raise ArgumentError, "Either :vendor or :criteria are requir...
github
securityroots/passdb
https://github.com/securityroots/passdb
lib/passdb/cli.rb
Ruby
mit
19
master
1,432
require 'thor' require 'thor/actions' require 'passdb' module Passdb class CLI < Thor include Thor::Actions map "-v" => :version def initialize(*) super Thor::Shell::Basic.new end method_option "vendor", :type => :string, :banner => "Name of the vendor as especified in http:...
github
securityroots/passdb
https://github.com/securityroots/passdb
spec/spec_helper.rb
Ruby
mit
19
master
356
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rspec' require 'passdb' # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} ...
github
securityroots/passdb
https://github.com/securityroots/passdb
spec/passdb_spec.rb
Ruby
mit
19
master
368
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Passdb: vendor search" do it "should fail if the vendor is empty" do lambda{ Passdb::search(:vendor => nil) }.should raise_error(ArgumentError) end it "should fail if criteria is empty" do lambda{ Passdb::search(:criteria => nil...
github
pedroandrade/pushwoosh
https://github.com/pedroandrade/pushwoosh
pushwoosh.gemspec
Ruby
mit
19
master
1,050
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'pushwoosh/version' Gem::Specification.new do |spec| spec.name = "pushwoosh" spec.version = Pushwoosh::VERSION spec.authors = ["Pedro Andrade"] spec.email = ["...
github
pedroandrade/pushwoosh
https://github.com/pedroandrade/pushwoosh
spec/spec_helper.rb
Ruby
mit
19
master
389
require 'rubygems' require 'bundler/setup' require 'pushwoosh' require 'vcr' require 'webmock' require 'json' VCR.configure do |c| #the directory where your cassettes will be saved c.cassette_library_dir = 'spec/vcr' # your HTTP request service. You can also use fakeweb, webmock, and more c.hook_into :webmock ...
github
pedroandrade/pushwoosh
https://github.com/pedroandrade/pushwoosh
spec/pushwoosh/pushwoosh_spec.rb
Ruby
mit
19
master
723
require 'spec_helper' describe Pushwoosh do before do Pushwoosh.configure do |config| config.application = '5555-5555' config.auth = 'abcefg' end end describe '.notify_all' do context 'when has message' do it 'sends push message' do VCR.use_cassette 'pushwoosh/push_notifica...
github
pedroandrade/pushwoosh
https://github.com/pedroandrade/pushwoosh
spec/pushwoosh/pushwoosh/request_spec.rb
Ruby
mit
19
master
1,931
require 'spec_helper' describe Pushwoosh::Request do describe '#make_post!' do let(:body) do { request: { application: "555555", auth: "5555-5555", notifications: [{ send_date: "now", ios_badges: "+1", content: "Te...
github
pedroandrade/pushwoosh
https://github.com/pedroandrade/pushwoosh
spec/pushwoosh/pushwoosh/push_notification_spec.rb
Ruby
mit
19
master
2,706
require 'spec_helper' describe Pushwoosh::PushNotification do let(:options) do { auth: '5555-5555', application: '555555' } end let(:response) do double(:response, status_code: 200, status_message: "OK", response: {"Messages" => ["555555534563456345"]} ) end subject ...
github
pedroandrade/pushwoosh
https://github.com/pedroandrade/pushwoosh
lib/pushwoosh.rb
Ruby
mit
19
master
540
require "pushwoosh/version" require 'pushwoosh/push_notification' require 'pushwoosh/configurable' require 'httparty' require 'pushwoosh/helpers' module Pushwoosh extend Pushwoosh::Configurable class << self def notify_all(message, notification_options = {}) PushNotification.new(options).notify_all(mes...
github
pedroandrade/pushwoosh
https://github.com/pedroandrade/pushwoosh
lib/pushwoosh/configurable.rb
Ruby
mit
19
master
996
require 'forwardable' module Pushwoosh module Configurable extend Forwardable attr_writer :application, :auth attr_accessor :application, :auth def_delegator :options, :hash class << self def keys @keys ||= [ :application, :auth, ] end end ...
github
pedroandrade/pushwoosh
https://github.com/pedroandrade/pushwoosh
lib/pushwoosh/push_notification.rb
Ruby
mit
19
master
1,204
require 'httparty' require 'json' require 'pushwoosh/exceptions' require 'pushwoosh/request' require 'pushwoosh/response' require 'pushwoosh/helpers' module Pushwoosh class PushNotification def initialize(auth_hash = {}) @auth_hash = auth_hash end def notify_all(message, other_options = {}) ...
github
pedroandrade/pushwoosh
https://github.com/pedroandrade/pushwoosh
lib/pushwoosh/request.rb
Ruby
mit
19
master
1,288
require 'httparty' module Pushwoosh class Request include HTTParty base_uri 'https://cp.pushwoosh.com/json/1.3/' format :json def self.make_post!(*args) new(*args).make_post! end def initialize(url, options = {}) validations!(url, options) @options = options @notif...
github
full360/sneaql
https://github.com/full360/sneaql
sneaql.gemspec
Ruby
mit
19
master
1,010
Gem::Specification.new do |s| s.name = 'sneaql' s.version = '0.0.27' s.date = '2018-09-30' s.summary = "sneaql language core" s.description = "provides the base classes required to run and extend sneaql" s.authors = ["jeremy winters"] s.email = 'jeremy.winters@full360.com' ...
github
full360/sneaql
https://github.com/full360/sneaql
Gemfile
Ruby
mit
19
master
217
source 'https://rubygems.org' do gem 'logger','>=1.2.8' gem 'minitest','>=5.9.0' gem "jdbc_helpers",'~> 0.0', '>= 0.0.2' gem "rubyzip",'>=1.2.0' gem "zip", '~> 2.0', '~> 2.0.2' gem "git", ">=1.3.0" end
github
full360/sneaql
https://github.com/full360/sneaql
lib/sneaql.rb
Ruby
mit
19
master
11,128
require 'jdbc_helpers' require 'logger' require_relative 'sneaql_lib/exceptions.rb' require_relative 'sneaql_lib/core.rb' require_relative 'sneaql_lib/repo_manager.rb' require_relative 'sneaql_lib/step_manager.rb' require_relative 'sneaql_lib/parser.rb' require_relative 'sneaql_lib/expressions.rb' require_relative 'sn...
github
full360/sneaql
https://github.com/full360/sneaql
lib/sneaql_lib/repo_manager.rb
Ruby
mit
19
master
2,989
require 'git' require 'open-uri' require_relative 'base.rb' module Sneaql # Classes to manage repositories full of SneaQL code. module RepoManagers # tells you the repo type based upon the url # either git or http # @param [String] repo_url def self.repo_type_from_url(repo_url) return 'git'...
github
full360/sneaql
https://github.com/full360/sneaql
lib/sneaql_lib/step_manager.rb
Ruby
mit
19
master
722
require 'json' module Sneaql # Managers for transform steps module StepManagers # source step metadata from a json file class JSONFileStepManager < Sneaql::Core::StepMetadataManager Sneaql::Core::RegisterMappedClass.new( :step_metadata_manager, 'local_file', Sneaql::StepManage...
github
full360/sneaql
https://github.com/full360/sneaql
lib/sneaql_lib/base.rb
Ruby
mit
19
master
9,989
require 'zip/zip' require 'fileutils' require 'logger' # top level namespace for sneaql objects module Sneaql # contains the base classes for the extendable parts of sneaql: # commands (the actual commands specified in sneaql tags) # repo_managers (used to pull the sql files from a remote or local source) ...
github
full360/sneaql
https://github.com/full360/sneaql
lib/sneaql_lib/expressions.rb
Ruby
mit
19
master
14,592
require 'logger' require 'time' module Sneaql module Core # Handles variables, expression evaluation, and comparisons. # A single ExpressionHandler is created per transform. This # object will get passed around to the various commands as well # as other manager objects attached to the transform clas...
github
full360/sneaql
https://github.com/full360/sneaql
lib/sneaql_lib/tokenizer.rb
Ruby
mit
19
master
6,284
module Sneaql module Core @@valid_tokenizer_states = [ :outside_word, :in_word, :in_string_literal, :in_string_literal_escape ] # these are the states that can be jumped between during tokenization. # @return [Array<Symbol>] def self.valid_tokenizer_states @@valid_to...
github
full360/sneaql
https://github.com/full360/sneaql
lib/sneaql_lib/exceptions.rb
Ruby
mit
19
master
3,150
module Sneaql # Exceptions for SneaQL module Exceptions class ExceptionManager attr_accessor :pending_error attr_accessor :last_iterated_record def initialize(logger = nil) @logger = logger ? logger : Logger.new(STDOUT) end def output_pending_error @lo...
github
full360/sneaql
https://github.com/full360/sneaql
lib/sneaql_lib/recordset.rb
Ruby
mit
19
master
3,602
require 'logger' module Sneaql module Core #manages stored recordsets in sneaql transforms class RecordsetManager attr_reader :recordset def initialize(expression_manager, logger = nil) @logger = logger ? logger : Logger.new(STDOUT) @expression_manager = expression_manager ...
github
full360/sneaql
https://github.com/full360/sneaql
lib/sneaql_lib/core.rb
Ruby
mit
19
master
18,445
require 'jdbc_helpers' require_relative 'base.rb' require_relative 'exceptions.rb' module Sneaql module Core # Core Sneaql language command tags. # You can create your own tags by extending # Sneaql::Core::SneaqlCommand and overriding the # action method. You should also override arg_definition ...
github
full360/sneaql
https://github.com/full360/sneaql
lib/sneaql_lib/docker.rb
Ruby
mit
19
master
1,418
require 'json' module Sneaql module Docker class LocalTransformDockerfile def initialize(repo_dir, repo_tag) @repo_dir = repo_dir @repo_tag = repo_tag @steps = JSON.parse( File.read("#{repo_dir}/sneaql.json") ) create_step_files create_dockerfile ...
github
full360/sneaql
https://github.com/full360/sneaql
lib/sneaql_lib/parser.rb
Ruby
mit
19
master
3,644
require_relative 'tokenizer.rb' module Sneaql module Core # Parses a step file into discrete statements. # Also performs validation of all Sneaql tags. class StepParser # array of raw statement text attr_reader :statements attr_reader :expression_handler # @param [String] file_pa...
github
full360/sneaql
https://github.com/full360/sneaql
test/core_test.rb
Ruby
mit
19
master
20,486
require_relative "helpers/helper" require_relative "#{$base_path}/lib/sneaql_lib/core.rb" require_relative "#{$base_path}/lib/sneaql_lib/expressions.rb" require_relative "#{$base_path}/lib/sneaql_lib/recordset.rb" require_relative "#{$base_path}/lib/sneaql_lib/exceptions.rb" require_relative "#{$base_path}/test/helper...
github
full360/sneaql
https://github.com/full360/sneaql
test/step_manager_test.rb
Ruby
mit
19
master
1,037
require_relative "helpers/helper" require 'jdbc_helpers' require 'json' require_relative "#{$base_path}/lib/sneaql_lib/base.rb" require_relative "#{$base_path}/lib/sneaql_lib/step_manager.rb" require_relative "#{$base_path}/test/helpers/sqlite_helper.rb" class TestSneaqlStepManager < Minitest::Test def test_that_...
github
full360/sneaql
https://github.com/full360/sneaql
test/parser_test.rb
Ruby
mit
19
master
3,216
require_relative "helpers/helper" require_relative "#{$base_path}/lib/sneaql_lib/base.rb" require_relative "#{$base_path}/lib/sneaql_lib/core.rb" require_relative "#{$base_path}/lib/sneaql_lib/parser.rb" require_relative "#{$base_path}/lib/sneaql_lib/expressions.rb" require_relative "#{$base_path}/lib/sneaql_lib/recor...
github
full360/sneaql
https://github.com/full360/sneaql
test/sneaql_test.rb
Ruby
mit
19
master
847
require_relative "helpers/helper" require_relative "#{$base_path}/test/helpers/sqlite_helper.rb" require_relative "#{$base_path}/lib/sneaql.rb" class TestSneaqlTransform < Minitest::Test def test_transform_end_to_end File.delete('memory') if File.exists? 'memory' t = Sneaql::Transform.new({ transform...
github
full360/sneaql
https://github.com/full360/sneaql
test/test_gem.rb
Ruby
mit
19
master
723
require 'sneaql' # not an official part of the test suite # this tests the actual gem installed locally $base_path = File.expand_path("#{File.dirname(__FILE__)}/../") #load up a sqlite database and delete the db if it's in the path require_relative 'helpers/sqlite_helper.rb' File.delete('memory') if File.exists? 'mem...
github
full360/sneaql
https://github.com/full360/sneaql
test/base_test.rb
Ruby
mit
19
master
4,738
require_relative "helpers/helper" require_relative "#{$base_path}/lib/sneaql_lib/base.rb" require_relative "#{$base_path}/lib/sneaql_lib/expressions.rb" require_relative "#{$base_path}/lib/sneaql_lib/recordset.rb" # this gives the sneaql command test something to change $test_sneaql_base_command_value = nil # test in...
github
full360/sneaql
https://github.com/full360/sneaql
test/repo_manager_test.rb
Ruby
mit
19
master
1,367
require_relative "helpers/helper" require_relative "#{$base_path}/lib/sneaql_lib/repo_manager.rb" class TestRepoManager < Minitest::Test def test_local_repo r = Sneaql::RepoManagers::LocalFileSystemRepoManager.new( { repo_base_dir: "#{$base_path}/test/fixtures/test-transform" } ) assert_equal( ...
github
full360/sneaql
https://github.com/full360/sneaql
test/tokenizer_test.rb
Ruby
mit
19
master
1,742
require_relative "helpers/helper" require_relative "#{$base_path}/lib/sneaql_lib/tokenizer.rb" class TestTokenizer < Minitest::Test def test_classify sq = 39.chr bs = 92.chr t = Sneaql::Core::Tokenizer.new [ [' ', :whitespace], [bs, :escape], ['f', :word], ['-', :word], ...
github
full360/sneaql
https://github.com/full360/sneaql
test/expressions_test.rb
Ruby
mit
19
master
13,414
require_relative "helpers/helper" require_relative "#{$base_path}/lib/sneaql_lib/expressions.rb" class TestSneaqlExpressionManager < Minitest::Test def test_set_env_vars_via_constructor x = Sneaql::Core::ExpressionHandler.new assert_equal( ENV['HOSTNAME'], x.get_environment_variable('HOSTNAME')...
github
full360/sneaql
https://github.com/full360/sneaql
test/recordset_test.rb
Ruby
mit
19
master
2,863
require_relative "helpers/helper" require_relative "#{$base_path}/lib/sneaql_lib/core.rb" require_relative "#{$base_path}/lib/sneaql_lib/expressions.rb" require_relative "#{$base_path}/lib/sneaql_lib/recordset.rb" require_relative "#{$base_path}/test/helpers/sqlite_helper.rb" class TestRecordsetManager < Minitest::Te...
github
full360/sneaql
https://github.com/full360/sneaql
test/helpers/sqlite_helper.rb
Ruby
mit
19
master
436
require 'jdbc_helpers' require_relative 'sqlite-jdbc-3.8.11.2.jar' java_import 'org.sqlite.JDBC' def give_me_an_empty_test_database File.delete('memory') if File.exists? 'memory' conn = JDBCHelpers::ConnectionFactory.new( 'jdbc:sqlite:memory', '', '' ).connection return conn end def give_me_the_c...
github
full360/sneaql
https://github.com/full360/sneaql
test/helpers/helper.rb
Ruby
mit
19
master
279
gem 'minitest' require 'minitest/autorun' # using a global variable because this is only a test $base_path = File.expand_path("#{File.dirname(__FILE__)}/../../") unless $base_path ENV['SNEAQL_DISABLE_SQL_INJECTION_CHECK']="TEST" unless ENV['SNEAQL_DISABLE_SQL_INJECTION_CHECK']
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
puma-plugin-telemetry.gemspec
Ruby
mit
19
main
1,961
# frozen_string_literal: true require_relative 'lib/puma/plugin/telemetry/version' Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength spec.name = 'puma-plugin-telemetry' spec.version = Puma::Plugin::Telemetry::VERSION spec.authors = ['Leszek Zalewski'] spec.email = ['tnt@babbel.com'] ...
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
Gemfile
Ruby
mit
19
main
280
# frozen_string_literal: true source 'https://rubygems.org' # Specify your gem's dependencies in puma-plugin-telemetry.gemspec gemspec gem 'dogstatsd-ruby' gem 'rack' gem 'rake', '~> 13.2' gem 'rspec', '~> 3.13' gem 'rubocop', '~> 1.75.5' gem 'rubocop-performance', '~> 1.25'
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
spec/spec_helper.rb
Ruby
mit
19
main
774
# frozen_string_literal: true require 'bundler/setup' require 'puma/plugin/telemetry' require_relative 'support/server' RSpec.configure do |config| # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = '.rspec_status' # Run specs in random order to surface order ...
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
spec/rack/request_queue_time_middleware_spec.rb
Ruby
mit
19
main
1,858
# frozen_string_literal: true require_relative '../../lib/rack/request_queue_time_middleware' require 'rack' require 'datadog/statsd' # Provide mock as Timecop doesn't support such case class MockedProcess def initialize @clock = Process.clock_gettime(Process::CLOCK_REALTIME) end def microseconds @cloc...
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
spec/integration/plugin_spec.rb
Ruby
mit
19
main
3,948
# frozen_string_literal: true require 'timeout' require 'net/http' TestTakesTooLongError = Class.new(StandardError) module Puma class Plugin RSpec.describe Telemetry do around do |example| @server = nil Timeout.timeout(10, TestTakesTooLongError) do example.run end ...
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
spec/puma/plugin/telemetry_spec.rb
Ruby
mit
19
main
2,034
# frozen_string_literal: true module Puma class Plugin RSpec.describe Telemetry do it 'has a version number' do expect(Telemetry::VERSION).not_to be_nil end describe '.config' do it 'has a default configuration' do expect(described_class.config).not_to be_nil ...
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
spec/puma/plugin/telemetry/config_spec.rb
Ruby
mit
19
main
2,235
# frozen_string_literal: true module Puma class Plugin module Telemetry RSpec.describe Config do subject(:config) { described_class.new } describe '#enabled?' do context 'when default' do it { expect(config.enabled?).to eq false } end context 'whe...
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
spec/support/server.rb
Ruby
mit
19
main
1,240
# frozen_string_literal: true class Server attr_reader :lines def initialize(config = 'config') @config = config @lines = [] end def start @server = IO.popen("BIND_PATH=#{bind_path} bundle exec puma -C spec/fixtures/#{@config}.rb -v --debug", 'r') @server_pid = @server.pid true until nex...
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
lib/puma/plugin/telemetry.rb
Ruby
mit
19
main
3,073
# frozen_string_literal: true require 'puma' require 'puma/plugin' require 'puma/plugin/telemetry/version' require 'puma/plugin/telemetry/data' require 'puma/plugin/telemetry/targets/datadog_statsd_target' require 'puma/plugin/telemetry/targets/io_target' require 'puma/plugin/telemetry/config' module Puma class Pl...
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
lib/puma/plugin/telemetry/config.rb
Ruby
mit
19
main
3,584
# frozen_string_literal: true module Puma class Plugin module Telemetry # Configuration object for plugin class Config DEFAULT_PUMA_TELEMETRY = [ # Total booted workers. 'workers.booted', # Total number of workers configured. 'workers.total', ...
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
lib/puma/plugin/telemetry/data.rb
Ruby
mit
19
main
9,751
# frozen_string_literal: true module Puma class Plugin module Telemetry # Helper for working with Puma stats module CommonData TELEMETRY_TO_METHODS = { 'workers.booted' => :workers_booted, 'workers.total' => :workers_total, 'workers.spawned_threads' => :workers_s...
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
lib/puma/plugin/telemetry/targets/datadog_statsd_target.rb
Ruby
mit
19
main
1,743
# frozen_string_literal: true module Puma class Plugin module Telemetry module Targets # Target wrapping Datadog Statsd client. You can configure # all details like _metrics prefix_ and _tags_ in the client # itself. # # ## Example # # require "da...
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
lib/puma/plugin/telemetry/targets/io_target.rb
Ruby
mit
19
main
1,164
# frozen_string_literal: true require 'json' module Puma class Plugin module Telemetry module Targets # Simple IO Target, publishing metrics to STDOUT or logs # class IOTarget # JSON formatter for IO, expects `call` method accepting telemetry hash # cl...
github
babbel/puma-plugin-telemetry
https://github.com/babbel/puma-plugin-telemetry
lib/rack/request_queue_time_middleware.rb
Ruby
mit
19
main
1,561
# frozen_string_literal: true # Measures the queue time (= time between receiving the request in downstream # load balancer and starting request in ruby process) class RequestQueueTimeMiddleware ENV_KEY = 'rack.request_queue_time' def initialize(app, statsd:, process: Process) @app = app @statsd = statsd ...
github
dvci/health_cards
https://github.com/dvci/health_cards
health_cards.gemspec
Ruby
apache-2.0
19
main
1,923
# frozen_string_literal: true require_relative 'lib/health_cards/version' Gem::Specification.new do |spec| spec.name = 'health_cards' spec.version = HealthCards::VERSION spec.authors = ['Reece Adamson', 'Samuel Sayer', 'Stephen MacVicar', ...
github
dvci/health_cards
https://github.com/dvci/health_cards
Gemfile
Ruby
apache-2.0
19
main
2,710
# frozen_string_literal: true source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.7.4' gemspec gem 'dotenv-rails' gem 'faker' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' gem 'rails', '~> 6.1.3.1' # Use sqlite3 as the database for...
github
dvci/health_cards
https://github.com/dvci/health_cards
config/routes.rb
Ruby
apache-2.0
19
main
1,569
# frozen_string_literal: true Rails.application.routes.draw do # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html root 'landing_page#index' resources :patients do resources :immunizations resources :lab_results resource :health_card, except: :upload ...
github
dvci/health_cards
https://github.com/dvci/health_cards
config/application.rb
Ruby
apache-2.0
19
main
924
# frozen_string_literal: true require_relative 'boot' require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module HealthCards class Application < Rails::Application # Initialize configuration defaul...
github
dvci/health_cards
https://github.com/dvci/health_cards
config/environments/development.rb
Ruby
apache-2.0
19
main
2,803
# frozen_string_literal: true require 'active_support/core_ext/integer/time' Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded any time # it changes. This slows down response ti...
github
dvci/health_cards
https://github.com/dvci/health_cards
config/environments/production.rb
Ruby
apache-2.0
19
main
5,366
# frozen_string_literal: true require 'active_support/core_ext/integer/time' Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads mos...
github
dvci/health_cards
https://github.com/dvci/health_cards
config/environments/test.rb
Ruby
apache-2.0
19
main
2,400
# frozen_string_literal: true require 'active_support/core_ext/integer/time' # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test r...
github
dvci/health_cards
https://github.com/dvci/health_cards
config/initializers/mime_types.rb
Ruby
apache-2.0
19
main
418
# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf Mime::Type.register 'application/smart-health-card', :healthcard, [], ['smart-health-card'] Mime::Type.register 'application/fhir+js...
github
dvci/health_cards
https://github.com/dvci/health_cards
config/initializers/wicked_pdf.rb
Ruby
apache-2.0
19
main
991
# frozen_string_literal: true # WickedPDF Global Configuration # # Use this to set up shared configuration options for your entire application. # Any of the configuration options shown here can also be applied to single # models by passing arguments to the `render :pdf` call. # # To learn more, check out the README: #...
github
dvci/health_cards
https://github.com/dvci/health_cards
config/initializers/smart_health_cards.rb
Ruby
apache-2.0
19
main
571
# frozen_string_literal: true require 'health_cards' Rails.application.configure do config.smart = config_for('well-known') config.metadata = config_for('metadata') config.operation = config_for('operation') config.hc_key_path = ENV['KEY_PATH'] FileUtils.mkdir_p(File.dirname(ENV['KEY_PATH'])) kp = Health...
github
dvci/health_cards
https://github.com/dvci/health_cards
config/initializers/inflections.rb
Ruby
apache-2.0
19
main
718
# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflec...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/models/patient.rb
Ruby
apache-2.0
19
main
3,666
# frozen_string_literal: true require 'serializers/fhir_serializer' # Patient model to map our input form to FHIR class Patient < FHIRRecord attribute :given, :string attribute :family, :string attribute :gender, :string attribute :birth_date, :date attribute :phone, :string attribute :email, :string at...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/models/immunization.rb
Ruby
apache-2.0
19
main
1,684
# frozen_string_literal: true # Maps FHIR Immunization to Web UI. Represents a dose of an immunization, actual # vaccine info is stored in Vaccine. These are composited when mapping to FHIR class Immunization < FHIRRecord # include FHIRJsonStorage attribute :occurrence, :date attribute :lot_number, :string b...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/models/value_set.rb
Ruby
apache-2.0
19
main
734
# frozen_string_literal: true class ValueSet attr_reader :codes def initialize(file) @codes = FHIR.from_contents(File.read(file)).compose.include.flat_map do |compose| compose.concept.map do |concept| FHIR::Coding.new(system: compose.system, code: concept.code, display: concept.display) en...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/models/lab_result.rb
Ruby
apache-2.0
19
main
2,007
# frozen_string_literal: true class LabResult < FHIRRecord attribute :effective, :date attribute :code, :string attribute :result, :string attribute :status, :string belongs_to :patient serialize :json, FHIR::Observation STATUS = %w[final amended corrected].freeze validates :effective, presence: tr...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/models/serializers/fhir_serializer.rb
Ruby
apache-2.0
19
main
509
# frozen_string_literal: true # Manages serializing from fhir_models object into FHIR JSON to be stored in the database module Serializers module FHIRSerializer def load(json) json ? FHIR.from_contents(json) : new end def dump(model) raise ActiveRecord::SerializationTypeMismatch unless model...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/controllers/patients_controller.rb
Ruby
apache-2.0
19
main
2,346
# frozen_string_literal: true # PatientsController manages patients via the Web UI class PatientsController < SecuredController before_action :find_patient, except: %i[index new create] # GET /patients or /patients.json def index @patients = Patient.all end # GET /patients/1 or /patients/1.json def s...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/controllers/well_known_controller.rb
Ruby
apache-2.0
19
main
453
# frozen_string_literal: true require 'health_cards' # WellKnownController exposes the .well-known configuration to identify relevant urls and server capabilities class WellKnownController < ApplicationController def smart render json: Rails.application.config.smart end def jwks render json: key_set.to...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/controllers/application_controller.rb
Ruby
apache-2.0
19
main
1,637
# frozen_string_literal: true class ApplicationController < ActionController::Base around_action :handle_fhir_errors private def find_patient @patient = Patient.find(params[:patient_id]) end def handle_fhir_errors if request.format.json? || request.format.fhir_json? begin yield ...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/controllers/metadata_controller.rb
Ruby
apache-2.0
19
main
342
# frozen_string_literal: true # MetadataController exposes the metadata configuration to identify server capabilities class MetadataController < ApplicationController def capability_statement render json: Rails.application.config.metadata end def operation_definition render json: Rails.application.confi...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/controllers/secured_controller.rb
Ruby
apache-2.0
19
main
835
# frozen_string_literal: true # SecuredController checks access token before authorizing requests class SecuredController < ApplicationController before_action :authorize_request private def get_access_token(headers) headers['Authorization'].split.last if headers['Authorization'].present? end def auth...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/controllers/health_cards_controller.rb
Ruby
apache-2.0
19
main
1,137
# frozen_string_literal: true # require 'app/lib/covid_health_card_reporter' # HealthCardsController is the endpoint for download and issue of health cards class HealthCardsController < SecuredController before_action :find_patient, only: [:show, :create] before_action :health_card, only: :show skip_before_acti...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/controllers/lab_results_controller.rb
Ruby
apache-2.0
19
main
1,969
# frozen_string_literal: true class LabResultsController < ApplicationController before_action :find_patient, except: :show before_action :set_lab_result, only: %i[index edit update destroy] def new @lab_result = LabResult.new end def edit; end def index; end def create @lab_result = LabResul...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/controllers/qr_codes_controller.rb
Ruby
apache-2.0
19
main
535
# frozen_string_literal: true class QRCodesController < ApplicationController before_action :find_patient, only: :show def new; end def create contents = JSON.parse(params[:qr_contents]) @scan_result = HealthCards::Importer.scan(contents) end def show respond_to do |format| format.png do...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/controllers/immunizations_controller.rb
Ruby
apache-2.0
19
main
2,433
# frozen_string_literal: true # Handles immunization of patients through web UI class ImmunizationsController < SecuredController before_action :find_patient, except: :show before_action :set_immunization, only: %i[edit update destroy] before_action :find_vaccines, only: %i[new edit create update] # GET /immu...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/controllers/auth_controller.rb
Ruby
apache-2.0
19
main
2,812
# frozen_string_literal: true # AuthController exposes authorization endpoints for users to get access tokens class AuthController < ApplicationController skip_before_action :verify_authenticity_token, only: :token before_action :set_params before_action :set_headers_no_cache def authorize if valid_reques...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/helpers/patients_helper.rb
Ruby
apache-2.0
19
main
1,155
# frozen_string_literal: true module PatientsHelper def show_address(patient) [patient.street_line1, patient.street_line2, patient.city, patient.state, patient.zip_code].compact.join(', ') end def fake_patient_params gender = Patient::GENDERS.sample phone = Faker::PhoneNumber.phone_number email ...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/helpers/lab_results_helper.rb
Ruby
apache-2.0
19
main
238
# frozen_string_literal: true module LabResultsHelper def lab_options(value_set) value_set.codes.group_by(&:system).to_a.map do |system| [system.first, system.last.map! { |code| [code.display, code.code] }] end end end
github
dvci/health_cards
https://github.com/dvci/health_cards
app/helpers/health_cards_helper.rb
Ruby
apache-2.0
19
main
1,742
# frozen_string_literal: true module HealthCardsHelper def create_patient_from_jws(jws_payload) bundle = FHIR.from_contents(jws_payload['vc']['credentialSubject']['fhirBundle'].to_json) patient_entry = bundle.entry.find { |e| e.resource.is_a?(FHIR::Patient) } return nil if patient_entry.nil? patient...
github
dvci/health_cards
https://github.com/dvci/health_cards
app/lib/fhir_record.rb
Ruby
apache-2.0
19
main
721
# frozen_string_literal: true # Provides validation and utility methods for AR models that store data as FHIR JSON class FHIRRecord < ApplicationRecord self.abstract_class = true validate :valid_fhir_json after_create :set_fhir_id def to_json(*_args) json.to_hash end protected def to_fhir_time(t...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards.rb
Ruby
apache-2.0
19
main
1,073
# frozen_string_literal: true require 'health_cards/version' require 'health_cards/encoding' require 'health_cards/issuer' require 'health_cards/key' require 'health_cards/jws' require 'health_cards/key_set' require 'health_cards/private_key' require 'health_cards/public_key' require 'health_cards/health_card' require...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/qr_codes.rb
Ruby
apache-2.0
19
main
1,109
# frozen_string_literal: true require 'rqrcode' module HealthCards # Implements QR Code chunking in ruby class QRCodes attr_reader :chunks # Creates a QRCodes from a JWS # @param jws [String] the JWS string # @return [HealthCards::QRCodes] def self.from_jws(jws) QRCodes.new(ChunkingUtil...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/importer.rb
Ruby
apache-2.0
19
main
1,439
# frozen_string_literal: true module HealthCards # Converts a JWS to formats needed by endpoints (e.g. $issue-health-card, download and qr code) module Importer # Import JWS from file upload # @param [String] JSON string containing file upload contents # @return [Array<Hash>] An array of Hashes contai...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/key.rb
Ruby
apache-2.0
19
main
2,201
# frozen_string_literal: true require 'openssl' require 'base64' module HealthCards # Methods to generate signing keys and jwk class Key BASE = { kty: 'EC', crv: 'P-256' }.freeze DIGEST = OpenSSL::Digest.new('SHA256') # Checks if obj is the the correct key type or nil # @param obj Object that sho...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/attribute_filters.rb
Ruby
apache-2.0
19
main
3,197
# frozen_string_literal: true module HealthCards # Handles behavior related to removing disallowed attributes from FHIR Resources module AttributeFilters ALL_FHIR_RESOURCES = :fhir_resource def self.included(base) base.extend ClassMethods end # Class level methods for Payload class specific...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/public_key.rb
Ruby
apache-2.0
19
main
916
# frozen_string_literal: true module HealthCards # A key used for verifying JWS class PublicKey < Key def self.from_json(json) # TODO end def verify(payload, signature) @key.verify(OpenSSL::Digest.new('SHA256'), raw_to_asn1(signature, self), payload) end private # Convert the...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/private_key.rb
Ruby
apache-2.0
19
main
1,384
# frozen_string_literal: true module HealthCards # A key used for signing JWS class PrivateKey < Key def self.from_file(path) pem = OpenSSL::PKey::EC.new(File.read(path)) PrivateKey.new(pem) end def self.load_from_or_create_from_file(path) if File.exist?(path) from_file(path)...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/issuer.rb
Ruby
apache-2.0
19
main
2,045
# frozen_string_literal: true require 'fhir_models' module HealthCards # Issue Health Cards based on a stored private key class Issuer attr_reader :url, :key # Create an Issuer # # @param key [HealthCards::PrivateKey] the private key used for signing issued health cards def initialize(key:, u...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/health_card.rb
Ruby
apache-2.0
19
main
2,213
# frozen_string_literal: true module HealthCards # Represents a signed SMART Health Card class HealthCard extend Forwardable attr_reader :jws def_delegator :@qr_codes, :code_by_ordinal def_delegators :@payload, :bundle, :issuer # Create a HealthCard from a JWS # @param jws [JWS, String] ...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/payload_types.rb
Ruby
apache-2.0
19
main
1,176
# frozen_string_literal: true module HealthCards # Handles behavior related to support types by Payload subclasses module PayloadTypes # Additional type claims this Payload class supports # @param types [String, Array] A string or array of string representing the additional type claims or nil # if used...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/key_set.rb
Ruby
apache-2.0
19
main
2,183
# frozen_string_literal: true require 'forwardable' module HealthCards # A set of keys used for signing or verifying HealthCards class KeySet extend Forwardable def_delegator :keys, :empty? # Create a KeySet from a JWKS # # @param jwks [String] the JWKS as a string # @return [HealthCards...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/verifier.rb
Ruby
apache-2.0
19
main
1,743
# frozen_string_literal: true require 'net/http' require_relative 'verification' module HealthCards # Verifiers can validate HealthCards using public keys class Verifier attr_reader :keys attr_accessor :resolve_keys include HealthCards::Verification extend HealthCards::Verification # Verify ...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/chunk.rb
Ruby
apache-2.0
19
main
847
# frozen_string_literal: true module HealthCards # Represents a single QRCode in a sequence. This class is a shim to the RQRCode library # to enable multimode encoding class Chunk attr_reader :ordinal, :data, :qrcode SINGLE_REGEX = %r{shc:/}.freeze MULTI_REGEX = %r{shc:/[0-9]*/[0-9]*/}.freeze d...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/payload.rb
Ruby
apache-2.0
19
main
8,691
# frozen_string_literal: true require 'zlib' require 'uri' require 'health_cards/attribute_filters' require 'health_cards/payload_types' module HealthCards # A Payload which implements the credential claims specified by https://smarthealth.cards/ class Payload include HealthCards::AttributeFilters extend...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/jws.rb
Ruby
apache-2.0
19
main
3,863
# frozen_string_literal: true module HealthCards # Create JWS from a payload class JWS class << self include Encoding # Creates a JWS from a String representation, or returns the HealthCards::JWS object # that was passed in # @param jws [String, HealthCards::JWS] the JWS string, or a J...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/verification.rb
Ruby
apache-2.0
19
main
1,514
# frozen_string_literal: true module HealthCards # Logic for verifying a Payload JWS module Verification # Verify Health Card with given KeySet # # @param verifiable [HealthCards::JWS, String] the health card to verify # @param key_set [HealthCards::KeySet, nil] the KeySet from which keys should be...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/exporter.rb
Ruby
apache-2.0
19
main
1,738
# frozen_string_literal: true module HealthCards # Converts a JWS to formats needed by endpoints (e.g. $issue-health-card, download and qr code) module Exporter class << self # Export JWS for file download # @param [Array<JWS, String>] An array of JWS objects to be exported # @return [String]...
github
dvci/health_cards
https://github.com/dvci/health_cards
lib/health_cards/errors.rb
Ruby
apache-2.0
19
main
1,841
# frozen_string_literal: true module HealthCards class HealthCardsError < StandardError; end class JWSError < HealthCardsError; end class HealthCardError < HealthCardsError; end # Errors related to JWS # Exception thrown when a private key is expected or required class MissingPrivateKeyError < JWSErro...