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 | Zomato/vinifera | https://github.com/Zomato/vinifera | app/transformers/github_event_tracker_transformer.rb | Ruby | apache-2.0 | 93 | master | 395 | class GithubEventTrackerTransformer
def transform_all(events, target_id)
events.map do |event|
transform(event, target_id)
end
end
def transform(event, target_id)
{
target_id: target_id,
event_id: event.id,
meta_data: event.to_h,
event_type: event.type,
c... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | app/transformers/target_monitor_transformer.rb | Ruby | apache-2.0 | 93 | master | 420 | class TargetMonitorTransformer
def transform(target_id, type, opts = {})
{
target_id: target_id,
monitor_type: type,
repeat: opts[:repeat],
repeat_interval: opts[:repeat_interval].to_i,
created_at: Time.zone.now,
updated_at: Time.zone.now
}
end
def transform_all(target... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | app/transformers/target_transformer.rb | Ruby | apache-2.0 | 93 | master | 1,766 | class TargetTransformer
def transform(external_data, provider, type)
if provider == Target.providers[:github]
github_transformer(external_data, type)
end
end
def transform_all(external_data, provider, type)
external_data.map do |data|
transform(data, provider, type)
end
end
priv... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | db/schema.rb | Ruby | apache-2.0 | 93 | master | 4,164 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
#... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | db/migrate/20210111085126_create_stray_reports.rb | Ruby | apache-2.0 | 93 | master | 239 | class CreateStrayReports < ActiveRecord::Migration[6.0]
def change
create_table :stray_reports do |t|
t.string :url, null: false
t.jsonb :meta_data
t.timestamps
end
add_index :stray_reports, :url
end
end |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | db/migrate/20191231092728_create_target_monitors.rb | Ruby | apache-2.0 | 93 | master | 417 | class CreateTargetMonitors < ActiveRecord::Migration[6.0]
def change
create_table :target_monitors do |t|
t.bigint :target_id, null:false
t.integer :repeat_interval
t.boolean :repeat, default: false
t.string :monitor_type, null: false
t.jsonb :meta_data
t.timestamps
end
... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | db/migrate/20191231092431_create_targets.rb | Ruby | apache-2.0 | 93 | master | 325 | class CreateTargets < ActiveRecord::Migration[6.0]
def change
create_table :targets do |t|
t.string :url
t.string :target_type
t.string :provider
t.jsonb :meta_data
t.timestamps
end
add_index :targets, [:url,:target_type], unique: true
add_index :targets, :provider
end... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | db/migrate/20200103072607_add_slug_to_target.rb | Ruby | apache-2.0 | 93 | master | 393 | class AddSlugToTarget < ActiveRecord::Migration[6.0]
def change
add_column :targets, :slug, :string
add_column :targets, :status, :string
add_column :targets, :external_id, :string, null: false
add_index :targets, :slug
add_index :targets, :status
add_index :targets, :external_id
add_index... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | db/migrate/20191231093108_create_reports.rb | Ruby | apache-2.0 | 93 | master | 336 | class CreateReports < ActiveRecord::Migration[6.0]
def change
create_table :reports do |t|
t.bigint :target_id, null: false
t.bigint :target_monitor_id
t.binary :run_logs
t.jsonb :meta_data
t.timestamps
end
add_index :reports, :target_id
add_index :reports, :target_monit... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | db/migrate/20200803103732_create_github_event_trackers.rb | Ruby | apache-2.0 | 93 | master | 414 | class CreateGithubEventTrackers < ActiveRecord::Migration[6.0]
def change
create_table :github_event_trackers do |t|
t.bigint :target_id, null: false
t.bigint :event_id, null: false
t.string :event_type, null: false
t.jsonb :meta_data
t.timestamps
end
add_index :github_event... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | db/migrate/20200114121257_create_target_revisions.rb | Ruby | apache-2.0 | 93 | master | 576 | class CreateTargetRevisions < ActiveRecord::Migration[6.0]
def change
create_table :target_revisions do |t|
t.bigint :target_id, null: false
t.string :external_id
t.string :revision_id, null: false
t.boolean :ignore,default: false
t.jsonb :meta_data
t.timestamps
end
ad... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | db/migrate/20200106101559_target_monitor_unique_monitor_id.rb | Ruby | apache-2.0 | 93 | master | 210 | class TargetMonitorUniqueMonitorId < ActiveRecord::Migration[6.0]
def change
remove_index :target_monitors, [:target_id]
add_index :target_monitors, [:target_id,:monitor_type], unique: true
end
end |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | lib/slack_webhook_api.rb | Ruby | apache-2.0 | 93 | master | 302 | class SlackWebhookApi
def initialize(webhook = nil, opts = {})
webhook ||= ENV['SLACK_UPDATES_GROUP_URL']
@notifier = Slack::Notifier.new(webhook || ENV['SLACK_UPDATES_GROUP_URL'])
end
def notify(message)
@notifier.post(text: message)
end
alias_method :send_message, :notify
end |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | lib/slack_notifier.rb | Ruby | apache-2.0 | 93 | master | 979 | class SlackNotifier
CHANNELS = {UPDATES: 'vinifera-updates',
TARGET: 'vinifera-targets',
USER_TRACKING: 'vinifera-user-tracking',
VIOLATIONS: 'vinifera-violations',
ERROR: 'vinifera-error'
}.freeze
def notify(message, channel = CHANNELS[:UPDATES])
chann... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | lib/github.rb | Ruby | apache-2.0 | 93 | master | 5,683 | class Github
MAX_ITEMS_PER_PAGE = 100
BIG_REPO_SIZE_THRESHOLD = 13000 # raw size in kb of source only
MANUAL_PAGINATION_LIMIT = 50
INTERNAL_OPTS_KEYS = %i[page_limit item_limit manual_pagination last_id_processed filter_date].freeze
USER_INFO_CACHE_KEY = 'github_user_info_'.freeze
REPO_SOURCE_CACHE_KEY = ... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | lib/code_scanner.rb | Ruby | apache-2.0 | 93 | master | 4,319 | class CodeScanner
IMAGE_VERSION = 'v7.2.0'.freeze
BASE_IMAGE = "zricethezav/gitleaks:#{IMAGE_VERSION}".freeze
REPO_TAG = "zricethezav/gitleaks:#{IMAGE_VERSION}".freeze
CUSTOM_RULE_PATH = '/data/gitleaks.toml'.freeze
POLL_INTERVAL = 2.seconds
TTL = 10.minutes
CPU_SHARE = '0.3'.freeze # Dedicate at most 30%... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | lib/pager_duty_client.rb | Ruby | apache-2.0 | 93 | master | 558 | class PagerDutyClient
DEFAULT_API_VERSION = 2
INCIDENT_SEVERITIES = { critical: 'critical', error: 'error', warning: 'warning', info: 'info' }.freeze
def initialize(opts = {})
@client = Pagerduty.build(integration_key: opts[:integration_key] || ENV['DEFAULT_PD_INTEGRATION_KEY'], api_version: opts[:api_versi... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | lib/data_dog_helper.rb | Ruby | apache-2.0 | 93 | master | 331 | # Data Dog Metrics Helper
module DataDogHelper
PREFIX = 'vinifera_'.freeze
class << self
def gauge_key(key, value)
$statsd.gauge(PREFIX + key, value)
end
def increment_key(key)
$statsd.increment(PREFIX + key)
end
def decrement_key(key)
$statsd.decrement(PREFIX + key)
end... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | lib/utilities/target_monitor_installer.rb | Ruby | apache-2.0 | 93 | master | 1,334 | class TargetMonitorInstaller
def initialize
@transformer = TargetMonitorTransformer.new
@slack_notifier = SlackNotifier.new
end
def install(target)
monitor_type = monitor_type_resolver(target)
repeat_interval = repeat_interval(target)
transformed_request = @transformer.transform(target.id, mo... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | lib/utilities/provider/github_user_activity_syncer.rb | Ruby | apache-2.0 | 93 | master | 603 | class GithubUserActivitySyncer
def initialize
@github = Github.new
@commit_event_processor = GithubService::PublicCommitProcessor.new
end
def sync_activity(target, last_run = nil)
username = target.slug
last_run = Time.zone.parse(last_run) if last_run
event_opts = {last_id_processed: target.... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | lib/utilities/provider/github_user_syncer.rb | Ruby | apache-2.0 | 93 | master | 587 | class GithubUserSyncer
def initialize
@github = Github.new
@transformer = TargetTransformer.new
@service = TargetService.new
end
def sync_org_users(org_name)
users = @github.org_members(org_name)
transformed_users = @transformer.transform_all(users, Target.providers[:github], Target.target_ty... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | lib/utilities/provider/github_user_repo_syncer.rb | Ruby | apache-2.0 | 93 | master | 1,217 | class GithubUserRepoSyncer
def initialize
@github = Github.new
@transformer = TargetTransformer.new
@service = TargetService.new
@slack_notifier = SlackNotifier.new
end
def sync_repos(target)
gh_username = target.slug
repos = @github.user_repos(gh_username)
transformed_repos = @transf... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | lib/utilities/provider/github_user_gist_syncer.rb | Ruby | apache-2.0 | 93 | master | 1,222 | class GithubUserGistSyncer
def initialize
@github = Github.new
@transformer = TargetTransformer.new
@service = TargetService.new
@slack_notifier = SlackNotifier.new
end
def sync_gists(target)
gh_username = target.slug
gists = @github.user_gists(gh_username)
transformed_gists = @transf... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | lib/tasks/periodic_syncs.rake | Ruby | apache-2.0 | 93 | master | 467 | namespace :periodic_syncs do
task sync_github_users: :environment do |_, _args|
Rails.logger.info '[Period-Syncs-Sync-Github-Users] Syncing Github Users '
github_user_syncer = GithubUserSyncer.new
github_user_syncer.sync_org_users(ENV['VINIFERA_ORG_NAME'])
Rails.logger.info '[Period-Syncs-Sync-Github... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | config/schedule.rb | Ruby | apache-2.0 | 93 | master | 675 | # Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
# Example:
#
# set :output, "/path/to/my/cron_log.log"
#
# every 2.hours do
# command "/usr/bin/some_great_command"
# runner "MyModel.some_m... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | config/application.rb | Ruby | apache-2.0 | 93 | master | 1,582 | require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_mailbox/engine"
require "action_text/en... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | config/initializers/docker_init.rb | Ruby | apache-2.0 | 93 | master | 249 | cert_path = ENV['DOCKER_CLIENT_CERT_PATH']
return unless cert_path
Docker.options = {
client_cert: File.join(cert_path, 'cert.pem'),
client_key: File.join(cert_path, 'key.pem'),
ssl_ca_file: File.join(cert_path, 'ca.pem'),
scheme: 'https'
} |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | config/initializers/sidekiq.rb | Ruby | apache-2.0 | 93 | master | 423 | require 'sidekiq/throttled'
Sidekiq::Throttled.setup!
redis_url = ENV.fetch('SIDEKIQ_REDIS_URL') { 'redis://localhost:6379/2' }
Sidekiq.configure_server do |config|
config.redis = { url: redis_url, network_timeout: 5 }
end
Sidekiq.configure_client do |config|
config.redis = { url: redis_url, network_timeout: 5 }... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | config/environments/development.rb | Ruby | apache-2.0 | 93 | master | 1,845 | 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 on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | config/environments/production.rb | Ruby | apache-2.0 | 93 | master | 4,851 | 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 most of Rails and
# your application in memory, allowing both threaded web serve... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | throttlers/target_monitor_throttler.rb | Ruby | apache-2.0 | 93 | master | 713 | class TargetMonitorThrottler < BaseThrottler
PRESSURE_THRESHOLD = 10
CONCURRENCY_FACTOR = {throttled: 20, normal: 100}.freeze
THRESHOLD_FACTOR = {throttled: 2500, normal: 5000}.freeze # Change these values are per your load and expected capacity
THRESHOLD_PERIOD = 10.minutes
IDENTIFIER = 'target_monitor'.free... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | throttlers/base_throttler.rb | Ruby | apache-2.0 | 93 | master | 2,215 | class BaseThrottler
DEFAULT_THRESHOLD_PERIOD = 1.hour
THROTTLE_INDICATOR_KEY = '_throttle_indicator_key'.freeze
THROTTLE_REPORTED_KEY = '_throttled_reported_key'.freeze
LOCK_KEY = '_throttle_lock_key_'.freeze
THROTTLE_REPORT_LOCK_KEY = '_throttle_report_lock_key'.freeze
Factor = Struct.new(:throttled, :no... |
github | Zomato/vinifera | https://github.com/Zomato/vinifera | throttlers/code_scan_throttler.rb | Ruby | apache-2.0 | 93 | master | 636 | class CodeScanThrottler < BaseThrottler
PRESSURE_THRESHOLD = 5
CONCURRENCY_FACTOR = {throttled: 20, normal: 50}.freeze
THRESHOLD_FACTOR = {throttled: 20, normal: 50}.freeze
THRESHOLD_PERIOD = 30.minute
IDENTIFIER = 'code_scan'.freeze
def initialize
super(IDENTIFIER,prepare_opts)
end
private
de... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | Guardfile | Ruby | mit | 93 | master | 376 | # -*- ruby -*-
guard 'rspec', cmd: 'bundle exec rspec', all_after_pass: false do
watch(%r{^spec/.+_spec\.rb$})
watch('spec/spec_helper.rb') { 'spec' }
watch(/spec\/support\/(.+)\.rb/) { 'spec' }
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
watch(%r{^lib/sycamore/(.... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | Rakefile | Ruby | mit | 93 | master | 720 | require 'bundler/gem_tasks'
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
rescue LoadError
puts "Couldn't find RSpec core Rake task"
end
begin
require 'yard'
YARD::Rake::YardocTask.new do |t|
t.options = ['--verbose']
t.files = ['lib/**/*.rb', 'doc/**/*.md']
t.stats_opt... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | sycamore.gemspec | Ruby | mit | 93 | master | 1,127 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'sycamore/version'
Gem::Specification.new do |spec|
spec.name = 'sycamore'
spec.version = Sycamore::VERSION
spec.authors = ['Marcel Otto']
spec.email = ['marce... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/spec_helper.rb | Ruby | mit | 93 | master | 735 | require 'bundler/setup'
begin
require 'simplecov'
require 'coveralls'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
])
SimpleCov.start do
add_filter "/spec/"
end
rescue LoadError => e
STDERR.puts "Coverag... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/unit/sycamore/path_root_spec.rb | Ruby | mit | 93 | master | 1,828 | describe Sycamore::Path::ROOT do
subject(:root) { Sycamore::Path::ROOT }
it { is_expected.to be_a Sycamore::Path }
############################################################################
describe '#node' do
specify { expect( root.node ).to be_nil }
end
##########################################... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/unit/sycamore/path_spec.rb | Ruby | mit | 93 | master | 16,907 | describe Sycamore::Path do
let(:example_path) { Sycamore::Path[:foo, :bar] }
############################################################################
# Construction
############################################################################
describe '.new' do
it 'is not available' do
expect ... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/unit/sycamore/nothing_spec.rb | Ruby | mit | 93 | master | 3,071 | describe Sycamore::Nothing do
it { is_expected.to be_a Singleton }
it { is_expected.to be_a Sycamore::Tree }
it { is_expected.to be_falsey }
describe 'query methods' do
describe 'children' do
specify { expect( Sycamore::Nothing.child_of(1 ) ).to be Sycamore::Nothing }
specify { expect( S... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/unit/sycamore/tree_spec.rb | Ruby | mit | 93 | master | 24,684 | describe Sycamore::Tree do
it { is_expected.to be_a Enumerable }
let(:subclass) { Class.new(Sycamore::Tree) }
specify { expect { Sycamore::Tree[].data }.to raise_error NoMethodError }
describe 'CQS reflection class methods' do
specify 'all Tree methods are separated into command and query methods' do
... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/unit/sycamore/absence_spec.rb | Ruby | mit | 93 | master | 19,525 | describe Sycamore::Absence do
let(:parent_node) { :missing }
let(:parent_tree) { Sycamore::Tree.new }
let(:absent_tree) { Sycamore::Absence.new(parent_tree, parent_node) }
############################################################################
describe '#presence' do
context 'when the absent tree ... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/unit/sycamore/tree/comparison_spec.rb | Ruby | mit | 93 | master | 23,576 | describe Sycamore::Tree do
############################################################################
# Equality
############################################################################
MyTree = Class.new(Sycamore::Tree)
TREE_EQL = [
[ Sycamore::Tree.new , Sycamore::Tree.new ],
[ MyTree.new... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/unit/sycamore/tree/deletion_spec.rb | Ruby | mit | 93 | master | 11,295 | describe Sycamore::Tree do
describe '#delete' do
context 'when given a single node' do
it 'does delete the value from the set of nodes' do
expect( Sycamore::Tree[1] >> 1 ).to be_empty
expect( Sycamore::Tree[1,2,3].delete(2).nodes.to_set ).to eql Set[1,3]
expect( Sycamore::Tree[:foo... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/unit/sycamore/tree/addition_spec.rb | Ruby | mit | 93 | master | 16,677 | describe Sycamore::Tree do
subject(:tree) { Sycamore::Tree.new }
############################################################################
describe '#add_node_with_empty_child' do
it 'does add the given node' do
expect( tree.add_node_with_empty_child(:foo) ).to include_node :foo
end
it 'd... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/unit/sycamore/tree/access_spec.rb | Ruby | mit | 93 | master | 24,192 | describe Sycamore::Tree do
subject(:tree) { Sycamore::Tree.new }
describe '#nodes' do
context 'when empty' do
it 'does return an empty array' do
expect( Sycamore::Tree.new.nodes ).to eql []
end
end
context 'when containing a single node' do
context 'without children' do
... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/unit/sycamore/tree/enumeration_spec.rb | Ruby | mit | 93 | master | 4,817 | describe Sycamore::Tree do
let(:tree) { Sycamore::Tree.new }
############################################################################
describe '#each_node' do
context 'when a block given' do
it 'does return the tree' do
expect( tree.each_node { 'foo' } ).to be tree
end
it 'do... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/unit/sycamore/tree/conversion_spec.rb | Ruby | mit | 93 | master | 5,954 | describe Sycamore::Tree do
describe '#to_native_object' do
it 'does return an empty array, when empty' do
expect( Sycamore::Tree.new.to_native_object ).to eql []
end
it 'does return a hash, with leaves having an empty array as a child' do
expect( Sycamore::Tree[1=>[], 2=>{}].to_native_object... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/support/matchers/include_tree_part.rb | Ruby | mit | 93 | master | 829 | RSpec::Matchers.define :include_tree_part do |part|
match do |this_tree|
expect(this_tree).to be_a(Sycamore::Tree).or be_a(Sycamore::Absence)
expect(this_tree).to include part
end
end
RSpec::Matchers.define :include_node do |node|
match do |this_tree|
expect(this_tree).to include_tree_part node
end... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | spec/support/matchers/be_path_of.rb | Ruby | mit | 93 | master | 345 | RSpec::Matchers.define :be_path_of do |*nodes|
match do |this_path|
expect(this_path).to be_a Sycamore::Path
current = this_path
nodes.reverse_each do |node|
expect(current.node ).to eql node
expect(current.parent).to be_a Sycamore::Path
current = current.parent
end
expect(curre... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | lib/sycamore.rb | Ruby | mit | 93 | master | 230 | require 'sycamore/version'
require 'sycamore/exceptions'
require 'sycamore/path'
require 'sycamore/path_root'
require 'sycamore/tree'
require 'sycamore/nothing'
require 'sycamore/absence'
##
# see README.md
#
module Sycamore
end |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | lib/sycamore/exceptions.rb | Ruby | mit | 93 | master | 556 | module Sycamore
# raised when a value is not a valid node
class InvalidNode < ArgumentError ; end
# raised when trying to call a additive command method of the {Nothing} tree
class NothingMutation < StandardError ; end
# raised when calling {Tree#node} or {Tree#node!} on a Tree with multiple nodes
class N... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | lib/sycamore/path.rb | Ruby | mit | 93 | master | 7,159 | require 'forwardable'
module Sycamore
##
# A compact, immutable representation of Tree paths, i.e. node sequences.
#
# This class is optimized for its usage in {Tree#each_path}, where it
# can efficiently represent the whole tree as a set of paths by sharing the
# parent paths.
# It is not intended to b... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | lib/sycamore/tree.rb | Ruby | mit | 93 | master | 43,315 | module Sycamore
##
# A tree data structure as a recursively nested set of {#nodes nodes} of immutable values.
#
# See {file:README.md} for a general introduction.
#
class Tree
include Enumerable
# the internal hash representation of this tree
attr_reader :data
protected :data
#######... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | lib/sycamore/absence.rb | Ruby | mit | 93 | master | 4,828 | require 'delegate'
module Sycamore
##
# An Absence object represents the absence of a specific child {Sycamore::Tree}.
#
# +Absence+ instances get created when accessing non-existent children of a
# Tree with {Tree#child_of} or {Tree#child_at}.
# It is not intended to be instantiated by the user.
#
# ... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | lib/sycamore/path_root.rb | Ruby | mit | 93 | master | 592 | require 'singleton'
module Sycamore
class Path
##
# @api private
#
class Root < Path
include Singleton
def initialize
@parent, @node = nil, nil
end
def up(distance = 1)
super unless distance.is_a? Integer
self
end
def root?
true
... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | lib/sycamore/nothing.rb | Ruby | mit | 93 | master | 3,893 | require 'singleton'
module Sycamore
##
# The Nothing Tree singleton class.
#
# The Nothing Tree is an empty Sycamore Tree, and means "there are no nodes".
#
# It is immutable:
# - {Tree::QUERY_METHODS Query method} calls will behave like a normal, empty Tree.
# - {Tree::DESTRUCTIVE_COMMAND_METHODS Pur... |
github | marcelotto/sycamore | https://github.com/marcelotto/sycamore | lib/sycamore/version.rb | Ruby | mit | 93 | master | 664 | module Sycamore
# version representation
module VERSION
# the file containing the project version number
FILE = File.expand_path('../../../VERSION', __FILE__)
MAJOR, MINOR, TINY, EXTRA = File.read(FILE).chomp.split('.')
# the normalized version string
STRING = [MAJOR, MINOR, TINY, EXTRA].compact... |
github | palkan/pgrel | https://github.com/palkan/pgrel | Gemfile | Ruby | mit | 93 | master | 279 | source 'https://rubygems.org'
gemspec
gem "pry-byebug", platform: :mri
eval_gemfile "gemfiles/rubocop.gemfile"
local_gemfile = 'Gemfile.local'
if File.exist?(local_gemfile)
eval(File.read(local_gemfile)) # rubocop:disable Lint/Eval
else
gem 'activerecord', '~> 6.1'
end |
github | palkan/pgrel | https://github.com/palkan/pgrel | pgrel.gemspec | Ruby | mit | 93 | master | 810 | # frozen_string_literal: true
# Maintain your gem's version:
require_relative "lib/pgrel/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "pgrel"
s.version = Pgrel::VERSION
s.authors = ["palkan"]
s.email = ["dementiev.vm@gmail.com"]
s.homepage = "http://githu... |
github | palkan/pgrel | https://github.com/palkan/pgrel | Rakefile | Ruby | mit | 93 | master | 282 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
begin
require "rubocop/rake_task"
RuboCop::RakeTask.new
rescue LoadError
task(:rubocop) {}
task("rubocop:md") {}
end
task default: %w[rubocop spec] |
github | palkan/pgrel | https://github.com/palkan/pgrel | spec/spec_helper.rb | Ruby | mit | 93 | master | 1,066 | # frozen_string_literal: true
begin
require "pry-byebug"
rescue LoadError
end
require "rspec"
require "active_record"
require "pg"
require "pgrel"
connection_params =
if ENV.key?("DATABASE_URL")
{"url" => ENV["DATABASE_URL"]}
else
{
"host" => ENV["DB_HOST"] || "localhost",
"username" => ENV... |
github | palkan/pgrel | https://github.com/palkan/pgrel | spec/support/user.rb | Ruby | mit | 93 | master | 363 | # frozen_string_literal: true
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.string :name
t.string :tags
t.integer :jsonb_id
t.integer :array_store_id
t.integer :hstore_id
t.timestamps null: true
end
end
class User < ActiveRecord::Base
belongs_to :jsonb
belong... |
github | palkan/pgrel | https://github.com/palkan/pgrel | spec/pgrel/array_spec.rb | Ruby | mit | 93 | master | 2,469 | # frozen_string_literal: true
require "spec_helper"
describe ArrayStore do
before(:all) do
@connection = ActiveRecord::Base.connection
@connection.transaction do
@connection.create_table("array_stores") do |t|
t.string "tags", default: [], null: false, array: true
t.string "name"
... |
github | palkan/pgrel | https://github.com/palkan/pgrel | spec/pgrel/jsonb_spec.rb | Ruby | mit | 93 | master | 6,523 | # frozen_string_literal: true
require "spec_helper"
describe Jsonb do
before(:all) do
@connection = ActiveRecord::Base.connection
@connection.transaction do
@connection.create_table("jsonbs") do |t|
t.jsonb "tags", default: {}, null: false
t.string "name"
end
end
Jsonb.... |
github | palkan/pgrel | https://github.com/palkan/pgrel | spec/pgrel/hstore_spec.rb | Ruby | mit | 93 | master | 6,758 | # frozen_string_literal: true
require "spec_helper"
describe Hstore do
before(:all) do
@connection = ActiveRecord::Base.connection
@connection.transaction do
@connection.create_table("hstores") do |t|
t.hstore "tags", default: {}, null: false
t.string "name"
end
end
Hst... |
github | palkan/pgrel | https://github.com/palkan/pgrel | lib/pgrel/active_record.rb | Ruby | mit | 93 | master | 331 | # frozen_string_literal: true
require "active_record"
require "pgrel/active_record/relation"
require "pgrel/active_record/store/flexible_store"
require "pgrel/active_record/store/flexible_hstore"
require "pgrel/active_record/store/flexible_jsonb"
require "pgrel/active_record/querying"
require "pgrel/active_record/quer... |
github | palkan/pgrel | https://github.com/palkan/pgrel | lib/pgrel/active_record/query_methods.rb | Ruby | mit | 93 | master | 1,015 | # frozen_string_literal: true
require "active_record/relation"
require "pgrel/active_record/store_chain"
require "pgrel/active_record/store_chain/array_chain"
require "pgrel/active_record/store_chain/hstore_chain"
require "pgrel/active_record/store_chain/jsonb_chain"
module ActiveRecord
module QueryMethods
# Ex... |
github | palkan/pgrel | https://github.com/palkan/pgrel | lib/pgrel/active_record/store_chain.rb | Ruby | mit | 93 | master | 7,915 | # frozen_string_literal: true
module ActiveRecord
module QueryMethods
# Base class for different store chains (hstore, jsonb, array).
# Provides _containment_ queries methods.
# Provides basic methods.
class StoreChain
attr_reader :store_name, :quoted_store_name
def initialize(scope, sto... |
github | palkan/pgrel | https://github.com/palkan/pgrel | lib/pgrel/active_record/relation.rb | Ruby | mit | 93 | master | 560 | # frozen_string_literal: true
module ActiveRecord
class Relation
def update_store(store_name)
raise ArgumentError, "Empty store name to update" if store_name.blank?
type = type_for_attribute(store_name.to_s).type
raise TypeConflictError, store_type_error_msg(type) if %i[hstore jsonb].exclude?(t... |
github | palkan/pgrel | https://github.com/palkan/pgrel | lib/pgrel/active_record/store/flexible_jsonb.rb | Ruby | mit | 93 | master | 674 | # frozen_string_literal: true
module ActiveRecord
module Store
class FlexibleJsonb < ActiveRecord::Store::FlexibleStore
def delete_keys(*keys)
keys.flatten!
query = +"#{store_name} = #{store_name}"
keys.length.times { query.concat(" - ?") }
relation.update_all([query, *keys]... |
github | palkan/pgrel | https://github.com/palkan/pgrel | lib/pgrel/active_record/store/flexible_hstore.rb | Ruby | mit | 93 | master | 745 | # frozen_string_literal: true
module ActiveRecord
module Store
class FlexibleHstore < ActiveRecord::Store::FlexibleStore
def delete_keys(*keys)
keys = keys.flatten.map(&:to_s)
relation.update_all(["#{store_name} = delete(#{store_name}, ARRAY[:keys])", keys: keys])
end
def merge... |
github | palkan/pgrel | https://github.com/palkan/pgrel | lib/pgrel/active_record/store/flexible_store.rb | Ruby | mit | 93 | master | 257 | # frozen_string_literal: true
module ActiveRecord
module Store
class FlexibleStore
attr_reader :relation, :store_name
def initialize(relation, store_name)
@relation, @store_name = relation, store_name
end
end
end
end |
github | palkan/pgrel | https://github.com/palkan/pgrel | lib/pgrel/active_record/store_chain/jsonb_chain.rb | Ruby | mit | 93 | master | 2,423 | # frozen_string_literal: true
module ActiveRecord
module QueryMethods
# Store chain for jsonb columns.
class JsonbChain < KeyStoreChain
OPERATORS = {contains: "@>", overlap: "&&"}.freeze
# Query by value in path.
#
# Example:
# Model.create!(name: 'first', store: {b: 1, c: { ... |
github | palkan/pgrel | https://github.com/palkan/pgrel | lib/pgrel/active_record/store_chain/array_chain.rb | Ruby | mit | 93 | master | 606 | # frozen_string_literal: true
module ActiveRecord
module QueryMethods
# Store chain for array columns.
class ArrayChain < StoreChain
# Whether the array overlaps provided array.
#
# Example
# Model.create!(name: 'first', store: ['b', 'c'])
# Model.create!(name: 'second', sto... |
github | palkan/pgrel | https://github.com/palkan/pgrel | lib/pgrel/active_record/store_chain/hstore_chain.rb | Ruby | mit | 93 | master | 985 | # frozen_string_literal: true
module ActiveRecord
module QueryMethods
# Store chain for hstore columns.
class HstoreChain < KeyStoreChain
# Overlap values
#
# Example
# Model.create!(name: 'first', store: {a: 1, b: 2})
# Model.create!(name: 'second', store: {b: 1, c: 3})
... |
github | kirtithorat/carrierwave-crop | https://github.com/kirtithorat/carrierwave-crop | carrierwave-crop.gemspec | Ruby | mit | 93 | master | 1,149 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'carrierwave/crop/version'
Gem::Specification.new do |spec|
spec.name = "carrierwave-crop"
spec.version = CarrierWave::Crop::VERSION
spec.authors = ["Kirti Thorat"]
sp... |
github | kirtithorat/carrierwave-crop | https://github.com/kirtithorat/carrierwave-crop | spec/crop/model_additions_spec.rb | Ruby | mit | 93 | master | 235 | require 'spec_helper'
describe CarrierWave::Crop::ModelAdditions do
describe ".crop_uploaded" do
it "for column avatar, accessors avatar_crop_x, avatar_crop_y, avatar_crop_w and avatar_crop_h are added" do
end
end
end |
github | kirtithorat/carrierwave-crop | https://github.com/kirtithorat/carrierwave-crop | lib/carrierwave/crop/railtie.rb | Ruby | mit | 93 | master | 311 | # encoding: utf-8
module CarrierWave
module Crop
class Railtie < Rails::Railtie
initializer 'carrierwave.crop' do
ActiveSupport.on_load :active_record do
extend ModelAdditions::ClassMethods
include ModelAdditions::InstanceMethods
end
end
end
end
end |
github | kirtithorat/carrierwave-crop | https://github.com/kirtithorat/carrierwave-crop | lib/carrierwave/crop/model_additions.rb | Ruby | mit | 93 | master | 3,522 | # encoding: utf-8
module CarrierWave
module Crop
module ModelAdditions
module ClassMethods
# Adds cropping feature on a specific attribute of your model
#
# crop_uploaded :avatar
#
# @param attachment [Symbol] Name of the attachment attribute to be cropped
... |
github | kirtithorat/carrierwave-crop | https://github.com/kirtithorat/carrierwave-crop | lib/carrierwave/crop/all.rb | Ruby | mit | 93 | master | 265 | # encoding: utf-8
require "carrierwave/crop/version"
require "carrierwave/crop/error"
if defined? Rails
require "carrierwave/crop/engine"
require 'carrierwave/crop/helpers'
require "carrierwave/crop/model_additions"
require "carrierwave/crop/railtie"
end |
github | kirtithorat/carrierwave-crop | https://github.com/kirtithorat/carrierwave-crop | lib/carrierwave/crop/helpers.rb | Ruby | mit | 93 | master | 4,070 | # encoding: utf-8
module CarrierWave
module Crop
module Helpers
# Form helper to render the preview of a cropped attachment.
# Loads the actual image. Previewbox has no constraints on dimensions, image is renedred at full size.
# By default box size is 100x100. Size can be customized by settin... |
github | kirtithorat/carrierwave-crop | https://github.com/kirtithorat/carrierwave-crop | lib/generators/cropper_generator.rb | Ruby | mit | 93 | master | 506 | class CropperGenerator < Rails::Generators::NamedBase
source_root File.expand_path("../templates", __FILE__)
desc "This generator creates a cropper file at app/assets/javascripts"
argument :attachment_name, :required => true, :type => :string, :desc => "The names of the attachment to crop.",
:banner =... |
github | polleverywhere/moat | https://github.com/polleverywhere/moat | moat.gemspec | Ruby | mit | 93 | main | 902 | require File.expand_path("lib/moat/version", __dir__)
Gem::Specification.new do |gem|
gem.name = "moat"
gem.version = Moat::VERSION
gem.license = "MIT"
gem.authors = ["Poll Everywhere"]
gem.email = ["geeks@polleverywhere.com"]
gem.homepage ... |
github | polleverywhere/moat | https://github.com/polleverywhere/moat | lib/moat.rb | Ruby | mit | 93 | main | 3,508 | module Moat
POLICY_CLASS_SUFFIX = "Policy".freeze
class Error < StandardError; end
class PolicyNotAppliedError < Error; end
class NotFoundError < Error; end
class ActionNotFoundError < NotFoundError
attr_reader :action, :resource, :policy, :user
def initialize(options = {})
return super if opt... |
github | polleverywhere/moat | https://github.com/polleverywhere/moat | lib/moat/rspec.rb | Ruby | mit | 93 | main | 7,122 | module Moat
module RSpec
module PolicyMatchers
extend ::RSpec::Matchers::DSL
matcher :permit_all_authorizations do
match do |policy_class|
@incorrectly_denied = policy_authorizations - permitted_authorizations(policy_class)
@incorrectly_denied.empty?
end
fa... |
github | polleverywhere/moat | https://github.com/polleverywhere/moat | spec/moat_spec.rb | Ruby | mit | 93 | main | 8,498 | # require "spec_helper"
require_relative "../lib/moat"
# Will typically be a Rails controller
class MoatConsumerClass
include Moat
def current_user
@current_user ||= Object.new
end
def action_name
:read
end
end
class IntegerPolicy
class Filter
attr_reader :user, :scope
def initialize(us... |
github | ericboehs/nest_thermostat | https://github.com/ericboehs/nest_thermostat | nest_thermostat.gemspec | Ruby | mit | 93 | master | 950 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/nest_thermostat/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Eric Boehs"]
gem.email = ["ericboehs@gmail.com"]
gem.description = %q{Control your nest thermostat}
gem.summary = %q{View and set temperature and ... |
github | ericboehs/nest_thermostat | https://github.com/ericboehs/nest_thermostat | Rakefile | Ruby | mit | 93 | master | 236 | #!/usr/bin/env rake
require "bundler/gem_tasks"
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
rescue LoadError
warn "RSpec is not available. Have you ran `bundle install`?"
end |
github | ericboehs/nest_thermostat | https://github.com/ericboehs/nest_thermostat | lib/nest_thermostat/nest.rb | Ruby | mit | 93 | master | 6,483 | require 'rubygems'
require 'httparty'
require 'json'
require 'uri'
module NestThermostat
class Nest
attr_accessor :login_url, :user_agent, :auth, :login, :token, :user_id,
:transport_url, :transport_host, :structure_id, :device_id, :headers
attr_reader :temperature_scale
def initialize(config = {... |
github | ericboehs/nest_thermostat | https://github.com/ericboehs/nest_thermostat | spec/nest_thermostat_spec.rb | Ruby | mit | 93 | master | 3,495 | require 'spec_helper'
module NestThermostat
describe Nest do
before(:all) do
@nest = Nest.new(email: ENV['NEST_EMAIL'], password: ENV['NEST_PASS'], temperature_scale: :fahrenheit)
end
it "logs in to home.nest.com" do
expect(@nest.transport_url).to match(/transport\.(home\.)?nest\.com/)
e... |
github | procore-oss/handcuffs | https://github.com/procore-oss/handcuffs | handcuffs.gemspec | Ruby | mit | 92 | main | 1,762 | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'handcuffs/version'
Gem::Specification.new do |spec|
spec.name = "handcuffs"
spec.version = Handcuffs::VERSION
spec.authors = ["Procore Technologies, Inc."]
spec.email = ["ope... |
github | procore-oss/handcuffs | https://github.com/procore-oss/handcuffs | lib/handcuffs.rb | Ruby | mit | 92 | main | 207 | require 'rails'
require 'active_record'
module Handcuffs; end
Dir[File.join(File.dirname(__FILE__), 'handcuffs', '*.rb')].each {|file| require file }
ActiveRecord::Migration.extend Handcuffs::Extensions |
github | procore-oss/handcuffs | https://github.com/procore-oss/handcuffs | lib/tasks/handcuffs.rake | Ruby | mit | 92 | main | 1,605 | # frozen_string_literal: true
namespace :handcuffs do
task :migrate, [:phase] => :environment do |_t, args|
phase = setup(args, 'handcuffs:migrate')
patch_migrator!(phase)
run_task('db:migrate')
end
task :rollback, [:phase] => :environment do |_t, args|
phase = setup(args, 'handcuffs:rollback')
... |
github | procore-oss/handcuffs | https://github.com/procore-oss/handcuffs | lib/handcuffs/pending_filter_ext.rb | Ruby | mit | 92 | main | 644 | # frozen_string_literal: true
module Handcuffs
# PendingFilter is prepended to ActiveRecord::Migrator in the rake tasks
# in order to check the current phase before it is run
module PendingFilterExt
def runnable
attempted_phase = self.class.handcuffs_phase
if @direction == :up
Handcuffs::... |
github | procore-oss/handcuffs | https://github.com/procore-oss/handcuffs | lib/handcuffs/configuration.rb | Ruby | mit | 92 | main | 476 | require "handcuffs/errors/configuration_block_missing_error"
module Handcuffs
mattr_accessor :config
def self.configure
raise ConfigurationBlockMissingError unless block_given?
@@config = Configurator.new
yield @@config
end
class Configurator
attr_reader :phases
attr_accessor :default_pha... |
github | procore-oss/handcuffs | https://github.com/procore-oss/handcuffs | lib/handcuffs/phases.rb | Ruby | mit | 92 | main | 1,067 | # frozen_string_literal: true
require 'tsort'
module Handcuffs
# Phases encapsulates the list of phases and any interdependencies
class Phases
def initialize(phases)
@phases = case phases
when Hash
phases.each_with_object({}) do |phase, acc|
acc[phas... |
github | procore-oss/handcuffs | https://github.com/procore-oss/handcuffs | lib/handcuffs/phase_filter.rb | Ruby | mit | 92 | main | 3,033 | class Handcuffs::PhaseFilter
attr_reader :attempted_phase
attr_reader :direction
def initialize(attempted_phase, direction)
@attempted_phase = attempted_phase
@direction = direction
end
def filter(migration_proxies)
migration_hashes = proxies_with_migrations(migration_proxies)
check_for_unde... |
github | procore-oss/handcuffs | https://github.com/procore-oss/handcuffs | lib/handcuffs/errors.rb | Ruby | mit | 92 | main | 1,588 | class HandcuffsError < StandardError; end
class RequiresPhaseArgumentError < HandcuffsError
def initialize(task)
msg = <<-MESSAGE
rake #{task} requires a phase argument.
For example: #{task}[pre_restart]
MESSAGE
super(msg)
end
end
class HandcuffsNotConfiguredError < Han... |
github | procore-oss/handcuffs | https://github.com/procore-oss/handcuffs | lib/handcuffs/extensions.rb | Ruby | mit | 92 | main | 249 | # frozen_string_literal: true
module Handcuffs
# Extended by ActiveRecord::Migrator in order to track the current phase
module Extensions
attr_accessor :handcuffs_phase
def phase(phase)
@handcuffs_phase = phase
end
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.