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 | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/workers/feed_retriever_worker.rb | Ruby | mit | 46 | main | 1,781 | require 'nyct-subway.pb'
require 'net/http'
require 'uri'
class FeedRetrieverWorker
include Sidekiq::Worker
sidekiq_options retry: 1, dead: false, queue: 'critical'
BASE_URI = "https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2Fgtfs"
def perform(feed_id, minutes, fraction_of_minute)
current_mi... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/workers/feed_retriever_spawning_b2_worker.rb | Ruby | mit | 46 | main | 394 | class FeedRetrieverSpawningB2Worker < FeedRetrieverSpawningWorkerBase
include Sidekiq::Worker
sidekiq_options retry: false, queue: 'critical'
FEEDS = ["-jz", "-nqrw", "-l", "-si"]
def perform
minutes = Time.current.min
fraction_of_minute = Time.current.sec / 15
FEEDS.each do |id|
FeedRetriev... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/workers/travel_times_refresh_worker.rb | Ruby | mit | 46 | main | 766 | class TravelTimesRefreshWorker
include Sidekiq::Worker
sidekiq_options retry: false, queue: 'default'
def perform
routes = Scheduled::Route.all
route_futures = {}
REDIS_CLIENT.pipelined do |pipeline|
route_futures = routes.to_h do |r|
[r.internal_id, RedisStore.route_status(r.internal_... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/workers/redis_cleanup_worker.rb | Ruby | mit | 46 | main | 209 | class RedisCleanupWorker
include Sidekiq::Worker
sidekiq_options retry: false, queue: 'low'
def perform
RedisStore.clear_outdated_trips
RedisStore.clear_outdated_trip_stops_and_delays
end
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/workers/feed_retriever_spawning_a_worker.rb | Ruby | mit | 46 | main | 367 | class FeedRetrieverSpawningAWorker < FeedRetrieverSpawningWorkerBase
include Sidekiq::Worker
sidekiq_options retry: false, queue: 'critical'
FEEDS = [""]
def perform
minutes = Time.current.min
fraction_of_minute = Time.current.sec / 5
FEEDS.each do |id|
FeedRetrieverWorker.perform_async(id, ... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/workers/accessibility_statuses_worker.rb | Ruby | mit | 46 | main | 1,153 | class AccessibilityStatusesWorker
include Sidekiq::Worker
sidekiq_options retry: 1, queue: 'low'
FEED_URI = "https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2Fnyct_ene.json"
def perform
feed_data = retrieve_feed
update_elevator_advisories(feed_data)
end
private
def retrieve_feed
... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/workers/feed_retriever_spawning_worker_base.rb | Ruby | mit | 46 | main | 461 | class FeedRetrieverSpawningWorkerBase
ALL_FEEDS = ["", "-ace", "-bdfm", "-g", "-jz", "-nqrw", "-l", "-si"]
MISC_FEED_MAPPING = {
"FS" => "-bdfm",
"GS" => "",
"H" => "-ace",
"SI" => "-si",
"SS" => "-si",
}
def self.feed_id_for(route_id)
if MISC_FEED_MAPPING[route_id]
MISC_FEED_MAPP... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/workers/route_processor_worker.rb | Ruby | mit | 46 | main | 443 | class RouteProcessorWorker
include Sidekiq::Worker
sidekiq_options retry: false, queue: 'critical'
def perform(route_id, timestamp)
marshaled_trips = RedisStore.route_trips(route_id, timestamp)
trips = Marshal.load(marshaled_trips) if marshaled_trips
if !trips
raise "Error: Trips for #{route_i... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/workers/twitter_service_changes_notifier_worker.rb | Ruby | mit | 46 | main | 6,053 | class TwitterServiceChangesNotifierWorker
include Sidekiq::Worker
include TwitterHelper
sidekiq_options retry: 1, queue: 'low'
SERVICE_CHANGE_NOTIFICATION_THRESHOLD = (ENV['SERVICE_CHANGE_NOTIFICATION_THRESHOLD'] || 30.minutes).to_i
ENABLE_ROUTE_CLIENTS = ENV['TWITTER_ENABLE_ROUTE_CLIENTS'] ? ActiveModel::Ty... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/workers/feed_retriever_spawning_worker.rb | Ruby | mit | 46 | main | 419 | class FeedRetrieverSpawningWorker < FeedRetrieverSpawningWorkerBase
include Sidekiq::Worker
sidekiq_options retry: false, queue: 'critical'
FEEDS = ["", "-bdfm", "-ace", "-jz", "-nqrw", "-l", "-si", "-g"]
def perform
minutes = Time.current.min
fraction_of_minute = Time.current.sec / 15
FEEDS.each ... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/workers/scheduled_times_refresh_worker.rb | Ruby | mit | 46 | main | 736 | class ScheduledTimesRefreshWorker
include Sidekiq::Worker
sidekiq_options retry: false, queue: 'default'
def perform
stop_pairs_map = {}
Scheduled::Route.all.each do |route|
Scheduled::Trip.soon_grouped(Time.current.to_i, route.id).each do |_, trips|
trips.each do |trip|
trip.stop... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/workers/accessibility_list_worker.rb | Ruby | mit | 46 | main | 1,117 | class AccessibilityListWorker
include Sidekiq::Worker
sidekiq_options retry: 1, queue: 'low'
FEED_URI = "https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2Fnyct_ene_equipments.json"
def perform
feed_data = retrieve_feed
update_accessible_stops_list(feed_data)
end
private
def retriev... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/controllers/oauth_controller.rb | Ruby | mit | 46 | main | 558 | require "uri"
require "net/http"
class OauthController < ApplicationController
SLACK_OAUTH_URI = "https://slack.com/api/oauth.access"
def index
code = params[:code]
post_params = {
client_id: ENV["SLACK_CLIENT_ID"],
client_secret: ENV["SLACK_CLIENT_SECRET"],
code: code
}
data =... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/controllers/api/stops_controller.rb | Ruby | mit | 46 | main | 11,118 | class Api::StopsController < ApplicationController
M_TRAIN_SHUFFLE_STOPS = ["M21", "M20", "M19", "M18", "M16", "M14", "M13", "M12", "M11"]
HOYT_SCHERMERHORN_STOP = "A42"
ADA_OVERRIDES = ENV['ADA_OVERRIDES']&.split(',') || []
ADA_ADDITIONAL_STOPS = ENV['ADA_ADDITIONAL_STOPS']&.split(',') || []
def index
d... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/controllers/api/slack_controller.rb | Ruby | mit | 46 | main | 14,403 | class Api::SlackController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :verify_slack_request
def index
query = params[:text]
if query == 'help'
result = help_response
elsif (route = Scheduled::Route.find_by(internal_id: query))
result = route_respo... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/controllers/api/virtual_assistant_controller.rb | Ruby | mit | 46 | main | 13,910 | class Api::VirtualAssistantController < ApplicationController
skip_before_action :verify_authenticity_token
PRONOUNCIATION_MAPPING = {
"houston" => "ˈhaʊstən",
"nostrand" => "ˈnoʊstrənd",
"dyckman" => "daɪkmɪn",
"schermerhorn" => "ʃɜrmərhərn",
"kosciuszko" => "ˌkɒʒiˈʊʃkoʊ",
"tremont" => "tɹ... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/controllers/api/alexa_controller.rb | Ruby | mit | 46 | main | 11,669 | class Api::AlexaController < Api::VirtualAssistantController
def index
verify_timestamp
verify_header
if params["alexa"]["request"]["type"] == "IntentRequest"
case params["alexa"]["request"]["intent"]["name"]
when "LookupTrainTimes"
data = stop_times_response
when "LookupDelays"
... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/controllers/api/routes_controller.rb | Ruby | mit | 46 | main | 5,344 | class Api::RoutesController < ApplicationController
def index
detailed = params[:detailed] == '1'
data = Rails.cache.fetch(detailed ? "status-detailed" : "status", expires_in: 10.seconds) do
data_hash = detailed ? RedisStore.route_status_detailed_summaries : RedisStore.route_status_summaries
sched... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/controllers/api/stats_controller.rb | Ruby | mit | 46 | main | 291 | class Api::StatsController < ApplicationController
def index
data = {
feeds: RedisStore.all_feed_latencies.transform_values(&:to_f),
routes: RedisStore.all_processed_route_latencies.transform_values(&:to_f),
}
render json: data
end
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/controllers/api/trips_controller.rb | Ruby | mit | 46 | main | 841 | class Api::TripsController < ApplicationController
def show
trip_id = params[:id].sub("-", "..")
marshaled_trip = RedisStore.active_trip(FeedRetrieverSpawningWorkerBase.feed_id_for(params[:route_id]), trip_id)
if !marshaled_trip && trip_id.include?("..")
trip_id = trip_id.sub("..", ".")
marsh... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/service_change_analyzer.rb | Ruby | mit | 46 | main | 26,816 | class ServiceChangeAnalyzer
NORTH = {
route_direction: 1,
scheduled_direction: 0,
suffix: 'N',
sym: :north,
}
SOUTH = {
route_direction: 3,
scheduled_direction: 1,
suffix: 'S',
sym: :south,
}
CITY_HALL_STOP = "R24" # Use to disguish re-routes via Manhattan Bridge/Lower Manhat... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/route_processor.rb | Ruby | mit | 46 | main | 12,165 | class RouteProcessor
TRAVEL_TIME_AVERAGE_TRIP_COUNT = 20
ACTUAL_TO_SCHEDULED_DIRECTION_MAPPING = {
1 => 0,
3 => 1,
}
class << self
def process_route(route_id, trips, timestamp)
puts "Processing route #{route_id}, latency #{Time.current - Time.zone.at(timestamp)}"
trips_by_direction = ... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/long_term_service_change_regular_routing.rb | Ruby | mit | 46 | main | 2,013 | class LongTermServiceChangeRegularRouting
attr_accessor :route_id, :direction, :first_departure, :last_run_times, :is_weekday, :is_saturday, :is_sunday
def initialize(route_id, direction, first_departure, last_run_times, is_weekday = true, is_saturday = true, is_sunday = true)
self.route_id = route_id
self... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/feed_processor.rb | Ruby | mit | 46 | main | 15,601 | require 'nyct-subway.pb'
class FeedProcessor
UPCOMING_TRIPS_TIME_ALLOWANCE = 30.minutes.to_i
UPCOMING_TRIPS_TIME_ALLOWANCE_FOR_SI = 60.minutes.to_i
SI_FEED = '-si'
INACTIVE_TRIP_TIMEOUT = 10.minutes.to_i
SCHEDULE_DISCREPANCY_THRESHOLD = -2.minutes.to_i
SUPPLEMENTED_TIME_LOOKUP = 20.minutes.to_i
TRIP_UPDA... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/delay_notification.rb | Ruby | mit | 46 | main | 2,547 | class DelayNotification
attr_accessor :routes, :direction, :stops, :affected_sections, :destinations, :last_tweet_ids, :last_tweet_times, :mins_since_observed, :tracks
def initialize(route, direction, stops, routing, destinations, tracks = {})
affected_section_indices = stops.map {|s| routing.index(s) }
af... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/long_term_service_change_routing_manager.rb | Ruby | mit | 46 | main | 99,566 | class LongTermServiceChangeRoutingManager
F_TRAIN_ROUTING_N = ["D43", "D42", "F39", "F38", "F36", "F35", "F34", "F33", "F32", "F31", "F30", "F29", "F27", "F26", "F25", "F24", "F23", "F22", "F21", "F20", "A41", "F18", "F16", "F15", "F14", "D21", "D20", "D19", "D18", "D17", "D16", "D15", "B10", "B08", "B06", "B04", "G1... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/route_analyzer.rb | Ruby | mit | 46 | main | 54,741 | class RouteAnalyzer
SLOW_SECTION_STATIONS_RANGE = 3..7
def self.analyze_route(route_id, processed_trips, actual_routings, common_routings, timestamp, scheduled_trips, scheduled_routings, recent_scheduled_routings, scheduled_headways_by_routes, routes_with_shared_tracks)
stop_name_formatter = StopNameFormatter.... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/redis_store.rb | Ruby | mit | 46 | main | 12,845 | class RedisStore
INACTIVE_TRIP_TIMEOUT = 30.minutes.to_i
DATA_RETENTION = 4.hours.to_i
DELAYS_RETENTION = 1.day.to_i
ROUTE_UPDATE_TIMEOUT = 5.minutes.to_i
class << self
# Feeds
def feed_timestamp(feed_id, client = REDIS_CLIENT)
client.hget("feed-timestamp", feed_id)
end
def update_feed... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/trip.rb | Ruby | mit | 46 | main | 5,342 | class Trip
attr_reader :route_id, :direction, :timestamp, :stops, :tracks
attr_accessor :id, :interval, :previous_trip, :schedule, :past_stops, :latest, :is_assigned
SOUTHBOUND_J_STOPS_TO_OMIT_TRACKING = ["J15", "J16", "J17", "J19", "J20", "J21", "J22"]
NORTHBOUND_J_STOPS_TO_OMIT_TRACKING = ["J16", "J15", "J14... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/scheduled/stop_time.rb | Ruby | mit | 46 | main | 1,134 | class Scheduled::StopTime < ActiveRecord::Base
belongs_to :trip, foreign_key: "trip_internal_id", primary_key: "internal_id"
belongs_to :stop, foreign_key: "stop_internal_id", primary_key: "internal_id"
DAY_IN_MINUTES = 86400
BUFFER = 10800
def self.rounded_time
Time.current.change(sec: 0)
end
def ... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/scheduled/schedule.rb | Ruby | mit | 46 | main | 646 | class Scheduled::Schedule < ActiveRecord::Base
has_many :calendar_exceptions, foreign_key: "schedule_service_id", primary_key: "service_id"
scope :day, ->(day_of_the_week) { where("#{day_of_the_week} = 1")}
def self.today(date: Date.current)
joins("LEFT OUTER JOIN calendar_exceptions ON schedules.service_id ... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/scheduled/trip.rb | Ruby | mit | 46 | main | 2,123 | class Scheduled::Trip < ActiveRecord::Base
belongs_to :route, foreign_key: "route_internal_id", primary_key: "internal_id"
belongs_to :schedule, foreign_key: "schedule_service_id", primary_key: "service_id"
has_many :stop_times, -> { order("departure_time") }, foreign_key: "trip_internal_id", primary_key: "intern... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/scheduled/stop.rb | Ruby | mit | 46 | main | 1,676 | class Scheduled::Stop < ActiveRecord::Base
has_many :stop_times, foreign_key: "stop_internal_id", primary_key: "internal_id"
PREFIX_ABBREVIATIONS = {
"st" => "saint",
"ft" => "fort",
}
ABBREVIATIONS = {
"&" => "and",
# "n" => "north",
"ne" => "northeast",
"nw" => "northwest",
"e" =... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/scheduled/transfer.rb | Ruby | mit | 46 | main | 266 | class Scheduled::Transfer < ActiveRecord::Base
belongs_to :from_stop, class_name: "Stop", foreign_key: "from_stop_internal_id", primary_key: "internal_id"
belongs_to :to_stop, class_name: "Stop", foreign_key: "to_stop_internal_id", primary_key: "internal_id"
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/scheduled/calendar_exception.rb | Ruby | mit | 46 | main | 426 | class Scheduled::CalendarException < ActiveRecord::Base
belongs_to :schedule, foreign_key: "schedule_service_id", primary_key: "service_id"
def self.next_weekday
date = Date.current
while [0, 6].include?(date.wday) ||
where(date: date).where("schedule_service_id like ?", "%Sunday%").or(where(date: da... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/scheduled/bus_transfer.rb | Ruby | mit | 46 | main | 214 | class Scheduled::BusTransfer < ActiveRecord::Base
belongs_to :from_stop, class_name: "Stop", foreign_key: "from_stop_internal_id", primary_key: "internal_id"
def is_sbs?
bus_route.include?("SBS")
end
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/service_changes/local_to_express_service_change.rb | Ruby | mit | 46 | main | 277 | class ServiceChanges::LocalToExpressServiceChange < ServiceChanges::ServiceChange
CLOSED_STOPS = ENV['CLOSED_STOPS']&.split(',')&.map {|s| s[0..2]} || []
def not_long_term?
!long_term?
end
def long_term?
(intermediate_stations - CLOSED_STOPS).empty?
end
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/service_changes/truncated_service_change.rb | Ruby | mit | 46 | main | 242 | class ServiceChanges::TruncatedServiceChange < ServiceChanges::ServiceChange
def applicable_to_routing?(routing)
if begin_of_route?
destinations.include?(routing.last)
else
routing.last == first_station
end
end
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/service_changes/rerouting_service_change.rb | Ruby | mit | 46 | main | 244 | class ServiceChanges::ReroutingServiceChange < ServiceChanges::ServiceChange
def applicable_to_routing?(routing)
if begin_of_route?
destinations.include?(routing.last)
else
routing.include?(first_station)
end
end
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/service_changes/split_routing_service_change.rb | Ruby | mit | 46 | main | 1,233 | class ServiceChanges::SplitRoutingServiceChange < ServiceChanges::ServiceChange
attr_accessor :routing_tuples, :related_routes_by_segments
def initialize(direction, routing_tuples, long_term_override = false)
self.direction = direction
self.affects_some_trains = false
self.routing_tuples = routing_tupl... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/service_changes/service_change.rb | Ruby | mit | 46 | main | 1,743 | class ServiceChanges::ServiceChange
attr_accessor :direction, :stations_affected, :related_routes, :affects_some_trains, :origin, :destinations, :routing, :long_term_override
def initialize(direction, stations_affected, origin, routing, long_term_override = false)
self.direction = direction
self.stations_a... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/service_changes/express_to_local_service_change.rb | Ruby | mit | 46 | main | 269 | class ServiceChanges::ExpressToLocalServiceChange < ServiceChanges::ServiceChange
def convert_to_rerouting
ServiceChanges::ReroutingServiceChange.new(
self.direction, self.stations_affected, self.origin, self.routing, self.long_term_override
)
end
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | app/models/processed/trip.rb | Ruby | mit | 46 | main | 5,725 | class Processed::Trip
DELAY_THRESHOLD = 5.minutes.to_i
delegate :id, :interval, :route_id, :stops_behind, :timestamp, :direction, :upcoming_stop, :time_until_upcoming_stop,
:is_assigned, :is_phantom?,
:upcoming_stop_arrival_time, :destination, :stops, :stop_ids, :tracks, :schedule_discrepancy, :past_stops, to: ... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/seeds.rb | Ruby | mit | 46 | main | 28,184 | require "csv"
Scheduled::Route.create(name: '1', internal_id: '1', color: 'ee352e')
Scheduled::Route.create(name: '2', internal_id: '2', color: 'ee352e')
Scheduled::Route.create(name: '3', internal_id: '3', color: 'ee352e')
Scheduled::Route.create(name: '4', internal_id: '4', color: '00933c')
Scheduled::Route.create(n... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/schema.rb | Ruby | mit | 46 | main | 6,263 | # 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 `bin/rai... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20240520022419_use_official_mta_colors.rb | Ruby | mit | 46 | main | 933 | class UseOfficialMtaColors < ActiveRecord::Migration[7.1]
def change
color_map = {
'1' => 'ee352e',
'2' => 'ee352e',
'3' => 'ee352e',
'4' => '00933c',
'5' => '00933c',
'6' => '00933c',
'6X' => '00933c',
'7' => 'b933ad',
'7X' => 'b933ad',
'GS' => '6d6e71'... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20240330050715_on_update_cascade_schedule_f_ks.rb | Ruby | mit | 46 | main | 533 | class OnUpdateCascadeScheduleFKs < ActiveRecord::Migration[6.1]
def change
remove_foreign_key :calendar_exceptions, :schedules, column: :schedule_service_id
remove_foreign_key :trips, :schedules, column: :schedule_service_id
add_foreign_key :calendar_exceptions, :schedules, column: :schedule_service_id, p... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20211015052833_seed_more_bus_transfers_and_connections.rb | Ruby | mit | 46 | main | 353 | class SeedMoreBusTransfersAndConnections < ActiveRecord::Migration[6.1]
def change
Scheduled::BusTransfer.create!(from_stop_internal_id: "J12", bus_route: "Q10 to JFK", min_transfer_time: 300, airport_connection: true)
Scheduled::Connection.create!(from_stop_internal_id: "418", name: "PATH", mode: "subway", m... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20211003182053_seed_connection_for_gwb_bus_station.rb | Ruby | mit | 46 | main | 217 | class SeedConnectionForGwbBusStation < ActiveRecord::Migration[6.1]
def change
Scheduled::Connection.create!(from_stop_internal_id: "A07", name: "GWB Bus Station", mode: "bus", min_transfer_time: 300)
end
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20211015051225_add_unique_indexes_and_foreign_keys_to_bus_transfers_and_connections.rb | Ruby | mit | 46 | main | 477 | class AddUniqueIndexesAndForeignKeysToBusTransfersAndConnections < ActiveRecord::Migration[6.1]
def change
add_index :bus_transfers, [:from_stop_internal_id, :bus_route], unique: true
add_index :connections, [:from_stop_internal_id, :name], unique: true
add_foreign_key :bus_transfers, :stops, column: :fr... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20210123052305_drop_directional_stops.rb | Ruby | mit | 46 | main | 213 | class DropDirectionalStops < ActiveRecord::Migration[6.1]
def change
Scheduled::Stop.where("internal_id like ?", "%N").destroy_all
Scheduled::Stop.where("internal_id like ?", "%S").destroy_all
end
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20240102074539_update_fs_alternate_name.rb | Ruby | mit | 46 | main | 204 | class UpdateFsAlternateName < ActiveRecord::Migration[6.1]
def change
route = Scheduled::Route.find_by!(internal_id: 'FS')
route.alternate_name = 'Franklin Av Shuttle'
route.save!
end
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20211003014720_add_connections.rb | Ruby | mit | 46 | main | 461 | class AddConnections < ActiveRecord::Migration[6.1]
def change
create_table :connections, force: :cascade do |t|
t.string :from_stop_internal_id, null: false
t.string :name, null: false
t.string :mode
t.integer :min_transfer_time, default: 0, null: false
t.integer :access_time_from
... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20211002202553_add_bus_transfers.rb | Ruby | mit | 46 | main | 515 | class AddBusTransfers < ActiveRecord::Migration[6.1]
def change
create_table :bus_transfers, force: :cascade do |t|
t.string :from_stop_internal_id, null: false
t.string :bus_route, null: false
t.integer :min_transfer_time, default: 0, null: false
t.integer :access_time_from
t.intege... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20210329005640_add_more_indexes.rb | Ruby | mit | 46 | main | 202 | class AddMoreIndexes < ActiveRecord::Migration[6.1]
def change
add_index :trips, :schedule_service_id
add_index :trips, :route_internal_id
add_index :stop_times, :departure_time
end
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20210102223417_initialize_scheduled_models.rb | Ruby | mit | 46 | main | 2,924 | class InitializeScheduledModels < ActiveRecord::Migration[6.1]
def change
create_table :routes do |t|
t.string :internal_id, null: false
t.string :name, null: false
t.string :alternate_name
t.string :color, null: false
t.string :text_color
t.boolean :visible, null: false, defau... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20210123050349_migrate_stop_times.rb | Ruby | mit | 46 | main | 485 | class MigrateStopTimes < ActiveRecord::Migration[6.1]
def change
Scheduled::Stop.where("internal_id like ?", "%N").each do |stop|
Scheduled::StopTime.where("stop_internal_id = ?", stop.internal_id).update_all(stop_internal_id: stop.internal_id[0..2])
end
Scheduled::Stop.where("internal_id like ?", "... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20230309061906_seed_gcm_connections.rb | Ruby | mit | 46 | main | 574 | class SeedGcmConnections < ActiveRecord::Migration[6.1]
def change
Scheduled::Connection.create!(from_stop_internal_id: "631", name: "LIRR", mode: "train", min_transfer_time: 300, access_time_from: 19800, access_time_to: 86399)
Scheduled::Connection.create!(from_stop_internal_id: "723", name: "LIRR", mode: "t... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20211003215534_seed_missing_si_ferry_connection.rb | Ruby | mit | 46 | main | 209 | class SeedMissingSiFerryConnection < ActiveRecord::Migration[6.1]
def change
Scheduled::Connection.create!(from_stop_internal_id: "S31", name: "SI Ferry", mode: "ship", min_transfer_time: 300)
end
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20211002064045_seed_times_sq_to_bryant_pk_transfer.rb | Ruby | mit | 46 | main | 1,062 | class SeedTimesSqToBryantPkTransfer < ActiveRecord::Migration[6.1]
def change
Scheduled::Transfer.create!(from_stop_internal_id: "D16", to_stop_internal_id: "902", min_transfer_time: 300, access_time_from: 21600, access_time_to: 86399)
Scheduled::Transfer.create!(from_stop_internal_id: "D16", to_stop_internal... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20210122182736_remove_h19_station.rb | Ruby | mit | 46 | main | 301 | class RemoveH19Station < ActiveRecord::Migration[6.1]
def change
# H19 is an internal station for Broad Channel
Scheduled::Stop.find_by(internal_id: 'H19')&.destroy
Scheduled::Stop.find_by(internal_id: 'H19N')&.destroy
Scheduled::Stop.find_by(internal_id: 'H19S')&.destroy
end
end |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20211003014943_seed_connections.rb | Ruby | mit | 46 | main | 6,152 | class SeedConnections < ActiveRecord::Migration[6.1]
def change
Scheduled::Connection.create!(from_stop_internal_id: "A28", name: "LIRR", min_transfer_time: 300, mode: "train")
Scheduled::Connection.create!(from_stop_internal_id: "128", name: "LIRR", min_transfer_time: 300, mode: "train")
Scheduled::Conn... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20211002203023_seed_bus_transfers.rb | Ruby | mit | 46 | main | 14,382 | class SeedBusTransfers < ActiveRecord::Migration[6.1]
def change
Scheduled::BusTransfer.create!(from_stop_internal_id: "113", bus_route: "Bx6 SBS", min_transfer_time: 180, access_time_from: 21600, access_time_to: 75599)
Scheduled::BusTransfer.create!(from_stop_internal_id: "A11", bus_route: "Bx6 SBS", min_tra... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20220102081654_seed_stops_geolocations.rb | Ruby | mit | 46 | main | 472 | class SeedStopsGeolocations < ActiveRecord::Migration[6.1]
def change
csv_text = File.read(Rails.root.join('import', 'Stations.csv'))
csv = CSV.parse(csv_text, headers: true)
csv.each do |row|
stop_id = row['GTFS Stop ID']
stop = Scheduled::Stop.find_by!(internal_id: stop_id)
stop.latitu... |
github | blahblahblah-/subwaynow-server | https://github.com/blahblahblah-/subwaynow-server | db/migrate/20210123172430_drop_n12_stop.rb | Ruby | mit | 46 | main | 300 | class DropN12Stop < ActiveRecord::Migration[6.1]
def change
# N12 is an internal station for S.B. Coney Island
Scheduled::Stop.find_by(internal_id: 'N12')&.destroy
Scheduled::Stop.find_by(internal_id: 'N12N')&.destroy
Scheduled::Stop.find_by(internal_id: 'N12S')&.destroy
end
end |
github | gosu/gosu-examples | https://github.com/gosu/gosu-examples | gosu-examples.gemspec | Ruby | mit | 45 | master | 704 | Gem::Specification.new do |s|
s.name = "gosu-examples"
s.version = "1.0.7"
s.author = "Julian Raschke"
s.email = "julian@raschke.de"
s.homepage = "http://www.libgosu.org/"
s.summary = "Ruby examples for the Gosu library"
s.description = "The `gosu-examples` tool provides an ea... |
github | gosu/gosu-examples | https://github.com/gosu/gosu-examples | examples/cptn_ruby.rb | Ruby | mit | 45 | master | 5,909 | # A simple jump-and-run/platformer game with a tile-based map.
# Shows how to
# * implement jumping/gravity
# * implement scrolling using Window#translate
# * implement a simple tile-based map
# * load levels from primitive text files
# Some exercises, starting at the real basics:
# 0) understand the existing co... |
github | gosu/gosu-examples | https://github.com/gosu/gosu-examples | examples/welcome.rb | Ruby | mit | 45 | master | 1,631 | require "gosu"
WIDTH, HEIGHT = 640, 480
class Welcome < (Example rescue Gosu::Window)
PADDING = 20
def initialize
super WIDTH, HEIGHT
self.caption = "Welcome!"
text =
"<b>Welcome to the Gosu Example Box!</b>
This little tool lets you launch any of Gosu’s example games from the list on ... |
github | gosu/gosu-examples | https://github.com/gosu/gosu-examples | examples/rmagick_integration.rb | Ruby | mit | 45 | master | 12,617 | # A simple Gorilla-style shooter for two players.
# Shows how Gosu and RMagick can be used together to generate a map, implement
# a dynamic landscape and generally look great.
# Also shows a very minimal, yet effective way of designing a game's object system.
# Doesn't make use of Gosu's Z-ordering. Not many differen... |
github | gosu/gosu-examples | https://github.com/gosu/gosu-examples | examples/chipmunk_integration.rb | Ruby | mit | 45 | master | 9,800 | ## File: ChipmunkIntegration.rb
## Author: Dirk Johnson
## Version: 1.0.0
## Date: 2007-10-05
## License: Same as for Gosu (MIT)
## Comments: Based on the Gosu Ruby Tutorial, but incorporating the Chipmunk Physics Engine
## See https://github.com/jlnr/gosu/wiki/Ruby-Chipmunk-Integration for the accompanying text.
requ... |
github | gosu/gosu-examples | https://github.com/gosu/gosu-examples | examples/opengl_integration.rb | Ruby | mit | 45 | master | 5,626 | # The tutorial game over a landscape rendered with OpenGL.
# Basically shows how arbitrary OpenGL calls can be put into
# the block given to Window#gl, and that Gosu Images can be
# used as textures using the gl_tex_info call.
require "gosu"
require "opengl"
OpenGL.load_lib
WIDTH, HEIGHT = 640, 480
module ZOrder
... |
github | gosu/gosu-examples | https://github.com/gosu/gosu-examples | examples/tutorial.rb | Ruby | mit | 45 | master | 2,631 | require "gosu"
module ZOrder
BACKGROUND, STARS, PLAYER, UI = *0..3
end
class Player
attr_reader :score
def initialize
@image = Gosu::Image.new("media/starfighter.bmp")
@beep = Gosu::Sample.new("media/beep.wav")
@x = @y = @vel_x = @vel_y = @angle = 0.0
@score = 0
end
def warp(x, y)
@x, ... |
github | gosu/gosu-examples | https://github.com/gosu/gosu-examples | examples/text_input.rb | Ruby | mit | 45 | master | 5,358 | # This example demonstrates use of the TextInput class with three text field widgets.
# One can cycle through them with tab, or click into the text fields and change their contents.
# The way TextInput works is that you create an instance of it, and then assign it to the text_input
# attribute of your window.
# Until ... |
github | gosu/gosu-examples | https://github.com/gosu/gosu-examples | examples/chipmunk_and_rmagick.rb | Ruby | mit | 45 | master | 4,248 | # Based on the C Demo3 demonstration distributed with Chipmunk.
# Also with some help from the chipmunk_integration.rb program.
#
# License: Same as for Gosu (MIT)
# Created on 21/10/2007, 00:05:19 by Robert Sheehan
require "gosu"
require "chipmunk"
require "rmagick"
# Layering of sprites
module ZOrder
BACKGROUND, ... |
github | gosu/gosu-examples | https://github.com/gosu/gosu-examples | lib/gosu-examples/sidebar.rb | Ruby | mit | 45 | master | 1,366 | class Sidebar
WIDTH = 300
HEIGHT = 600
FONT = Gosu::Font.new(20)
HEADER = Gosu::Image.new("media/header@2x.psd", tileable: true)
class Button
HEIGHT = 25
SPACING = 5
TOP_Y = HEADER.height / 2 + 15
attr_reader :filename
def initialize(top, filename, &handler)
@top, @filename, @hand... |
github | gosu/gosu-examples | https://github.com/gosu/gosu-examples | lib/gosu-examples/example.rb | Ruby | mit | 45 | master | 1,859 | class Example
attr_accessor :caption
attr_reader :width, :height
attr_writer :parent_window
def initialize(width, height, *options)
@width, @height = width, height
end
def draw
end
def update
end
def button_down(id)
end
def button_up(id)
end
def close
# no-op, examples cannot c... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | rschema.gemspec | Ruby | apache-2.0 | 45 | master | 1,429 | lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
require 'rschema/version'
Gem::Specification.new do |s|
s.name = 'rschema'
s.summary = 'Schema-based validation and coercion for Ruby data structures'
s.homepage = 'https://github.com/tomdalling/rschema'
s.license... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/error_spec.rb | Ruby | apache-2.0 | 45 | master | 879 | require 'set'
RSpec.describe RSchema::Error do
let(:error) {
RSchema::Error.new(
schema: schema,
value: 'dog',
symbolic_name: :not_a_duck,
vars: { fee: 'fi fo' },
)
}
let(:schema) { TestNamespace::TestSchema.new }
specify '#to_s provides a short, developer-friendly description'... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/result_spec.rb | Ruby | apache-2.0 | 45 | master | 237 | RSpec.describe RSchema::Result do
it 'raises an error if you attempt to get the value when its invalid' do
result = RSchema::Result.failure('wawawa')
expect {
result.value
}.to raise_error(RSchema::Invalid)
end
end |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/dsl_spec.rb | Ruby | apache-2.0 | 45 | master | 4,333 | RSpec.describe RSchema::DSL do
subject { TestDSL.new }
class TestDSL; include RSchema::DSL; end
describe '#type' do
specify 'explicit usage' do
schema = subject.type(Integer)
expect(schema).to be_a(RSchema::Schemas::Type)
expect(schema.type).to be(Integer)
end
describe 'underscore... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/rails_spec.rb | Ruby | apache-2.0 | 45 | master | 3,270 | require 'action_controller/railtie'
require 'rschema/rails'
RSpec.describe RSchema::Rails do
include Rack::Test::Methods
let(:app){ Rails5Host::Application }
let(:controller) { Rails5Host::TestController }
after do
if controller.instance_variable_defined?(:@__rschema_options)
controller.instance_va... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/rack_param_coercer_spec.rb | Ruby | apache-2.0 | 45 | master | 6,882 | require 'rschema/coercion_wrapper/rack_params'
RSpec.describe RSchema::CoercionWrapper::RACK_PARAMS do
subject { described_class.wrap(schema) }
let(:schema) do
RSchema.define do
fixed_hash(
optional(:int) => _Integer,
optional(:float) => _Float,
optional(:symbol) => _Symbol,
... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/spec_helper.rb | Ruby | apache-2.0 | 45 | master | 1,157 | require 'simplecov'
Bundler.require
SimpleCov.start
begin; require 'byebug'; rescue LoadError; end
module SpecHelperMethods
def validate(value, options=RSchema::Options.default)
subject.call(value, options)
end
end
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.inc... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/rschema_spec.rb | Ruby | apache-2.0 | 45 | master | 4,171 | require 'rschema/coercion_wrapper/rack_params'
RSpec.describe RSchema do
it 'provides schema-based validation of arbitrary data structures' do
int_schema = RSchema.define { _Integer }
valid_result = int_schema.validate(5)
expect(valid_result).to be_valid
invalid_result = int_schema.validate('hello'... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/schema_stub_spec.rb | Ruby | apache-2.0 | 45 | master | 208 | RSpec.describe SchemaStub do
it_behaves_like 'a schema'
it 'can be wrapped' do
stub = SchemaStub.new
wrapped = stub.with_wrapped_subschemas(WrapperStub)
expect(wrapped).to be(stub)
end
end |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/support/wrapper_stub.rb | Ruby | apache-2.0 | 45 | master | 349 | # frozen_string_literal: true
class WrapperStub
def self.wrap(schema, recursive = false)
new(recursive ? schema.with_wrapped_subschemas(self) : schema)
end
attr_reader :wrapped_subschema
def initialize(wrapped_subschema)
@wrapped_subschema = wrapped_subschema
end
def call(*args)
@wrapped_sub... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/support/coercer_stub.rb | Ruby | apache-2.0 | 45 | master | 288 | class CoercerStub
def initialize(&coerce_block)
@coerce_block = coerce_block || ->(x){x}
end
def call(value)
begin
RSchema::Result.success(@coerce_block.call(value))
rescue
RSchema::Result.failure
end
end
def will_affect?(value)
true
end
end |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/support/schema_stub.rb | Ruby | apache-2.0 | 45 | master | 650 | class SchemaStub
def initialize(&validity_checker)
@validity_checker = validity_checker
end
def call(value, options)
if valid?(value)
RSchema::Result.success(value)
else
RSchema::Result.failure(error)
end
end
def with_wrapped_subschemas(wrapper)
self
end
def error
@e... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/schemas/boolean_spec.rb | Ruby | apache-2.0 | 45 | master | 603 | RSpec.describe RSchema::Schemas::Boolean do
subject { described_class.instance }
it_behaves_like 'a schema'
specify 'successful validation' do
expect(validate(true)).to be_valid
expect(validate(false)).to be_valid
end
specify 'failed validation' do
result = validate(nil)
expect(result).to ... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/schemas/enum_spec.rb | Ruby | apache-2.0 | 45 | master | 1,127 | RSpec.describe RSchema::Schemas::Enum do
subject { described_class.new([:a, :b, :c], subschema) }
let(:subschema) do
SchemaStub.new { |value| value.is_a?(Symbol) }
end
it_behaves_like 'a schema'
specify 'successful validation' do
result = validate(:b)
expect(result).to be_valid
expect(resul... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/schemas/coercer_spec.rb | Ruby | apache-2.0 | 45 | master | 1,187 | RSpec.describe RSchema::Schemas::Coercer do
subject { described_class.new(coercer, subschema) }
let(:coercer) do
CoercerStub.new { |value| Integer(value) }
end
let(:subschema) do
SchemaStub.new { |value| value.odd? }
end
it_behaves_like 'a schema'
specify 'successful validation' do
result = ... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/schemas/anything_spec.rb | Ruby | apache-2.0 | 45 | master | 409 | RSpec.describe RSchema::Schemas::Anything do
subject{ described_class.instance }
it_behaves_like 'a schema'
it 'always succeeds' do
value = double
result = validate(value)
expect(result).to be_valid
expect(result.value).to be(value)
end
specify '#with_wrapped_subschemas' do
wrapped = s... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/schemas/type_spec.rb | Ruby | apache-2.0 | 45 | master | 643 | RSpec.describe RSchema::Schemas::Type do
subject { described_class.new(Enumerable) }
it_behaves_like 'a schema'
it 'gives a valid result with the value.is_a?(type)' do
result = validate([])
expect(result).to be_valid
expect(result.value).to eq([])
end
it 'gives an invalid result when not value... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/schemas/sum_spec.rb | Ruby | apache-2.0 | 45 | master | 985 | RSpec.describe RSchema::Schemas::Sum do
subject { described_class.new([even_schema, positive_schema]) }
let(:even_schema) { SchemaStub.new(&:even?) }
let(:positive_schema) { SchemaStub.new(&:positive?) }
it_behaves_like 'a schema'
it 'passes validation if _any_ subschema is valid' do
expect(validate(-6)... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/schemas/fixed_hash_spec.rb | Ruby | apache-2.0 | 45 | master | 3,494 | RSpec.describe RSchema::Schemas::FixedHash do
subject { described_class.new([name_attr, age_attr]) }
let(:name_attr) { described_class::Attribute.new(:name, name_schema, false) }
let(:name_schema) { SchemaStub.new{ |value| value.is_a?(String) } }
let(:age_attr) { described_class::Attribute.new(:age, age_schema,... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/schemas/variable_hash_spec.rb | Ruby | apache-2.0 | 45 | master | 2,221 | RSpec.describe RSchema::Schemas::VariableHash do
subject { described_class.new(key_schema, value_schema) }
let(:key_schema) { SchemaStub.new { |x| x.is_a?(Symbol) } }
let(:value_schema) { SchemaStub.new }
it_behaves_like 'a schema'
context 'valid result' do
it 'allows empty hashes' do
result = val... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/schemas/predicate_spec.rb | Ruby | apache-2.0 | 45 | master | 750 | RSpec.describe RSchema::Schemas::Predicate do
subject do
described_class.new('bongos', &:even?)
end
it_behaves_like 'a schema'
it 'gives a valid result if the predicate passes' do
expect(validate(4)).to be_valid
end
it 'gives an invalid result if the predicate fails' do
result = validate(5)
... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/schemas/set_spec.rb | Ruby | apache-2.0 | 45 | master | 1,570 | RSpec.describe RSchema::Schemas::Set do
subject { described_class.new(subschema) }
let(:subschema) { SchemaStub.new { |value| value.is_a?(Symbol) } }
it_behaves_like 'a schema'
context 'valid result' do
it 'allows empty sets' do
result = validate(Set.new)
expect(result).to be_valid
expec... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/schemas/fixed_length_array_spec.rb | Ruby | apache-2.0 | 45 | master | 1,729 | RSpec.describe RSchema::Schemas::FixedLengthArray do
subject { described_class.new([first_subschema, last_subschema]) }
let(:first_subschema) { SchemaStub.new }
let(:last_subschema) { SchemaStub.new }
it_behaves_like 'a schema'
specify 'successful validation' do
result = validate([:valid, :valid])
... |
github | tomdalling/rschema | https://github.com/tomdalling/rschema | spec/schemas/pipeline_spec.rb | Ruby | apache-2.0 | 45 | master | 1,694 | RSpec.describe RSchema::Schemas::Pipeline do
subject { described_class.new([first_subschema, last_subschema]) }
let(:first_subschema) { double }
let(:last_subschema) { double }
let(:options) { RSchema::Options.default }
it_behaves_like 'a schema'
it 'gives a valid result if _all_ subschemas give a valid r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.