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
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
spec/flash_session_spec.rb
Ruby
mit
304
master
396
require 'spec_helper' describe "A FlashSession" do before do @flash = CloudKit::FlashSession.new end it "should accept a value for a key" do @flash['greeting'] = 'hello' @flash['greeting'].should == 'hello' end it "should erase a key/value pair after access" do @flash['greeting'] = 'hello'...
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
spec/openid_filter_spec.rb
Ruby
mit
304
master
2,428
require 'spec_helper' describe "An OpenIDFilter" do before(:each) do openid_app = Rack::Builder.new { use Rack::Lint use Rack::Session::Pool use CloudKit::OpenIDFilter, :allow => ['/foo'] run echo_env(CLOUDKIT_AUTH_KEY) } @request = Rack::MockRequest.new(openid_app) end it "...
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
spec/spec_helper.rb
Ruby
mit
304
master
8,045
$:.unshift File.expand_path(File.dirname(__FILE__)) + '/../lib' require 'cloudkit' require 'rexml/document' require 'rack/test' require 'support/fixtures' TEST_REMOTE_USER = '/cloudkit_users/abcdef'.freeze VALID_TEST_AUTH = {CLOUDKIT_AUTH_KEY => TEST_REMOTE_USER}.freeze def echo_text(text) lambda {|env| [200, app_...
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
spec/api_spec.rb
Ruby
mit
304
master
4,670
require 'spec_helper' describe "CloudKit REST API" do context "GET" do context "/cloudkit-meta" do subject { get "/cloudkit-meta" } it_should_behave_like "it was successful" it_should_behave_like "it's response is json encoded" it_should_behave_like "it has uris" it "should ret...
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
spec/memory_table_spec.rb
Ruby
mit
304
master
216
require 'spec_helper' describe "A MemoryTable" do before(:each) do @table = CloudKit::MemoryTable.new end after(:each) do @table.clear end it_should_behave_like "a CloudKit storage adapter" end
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
spec/mongo_store_spec.rb
Ruby
mit
304
master
2,036
require 'spec_helper' describe "A MongoStore" do before(:each) do @table = CloudKit::MongoStore.new end after(:each) do @table.clear end it_should_behave_like "a CloudKit storage adapter" it "should create the default indexes for a collection" do @table['a'] = {'foo' => 'bar' } @table.db...
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
spec/uri_spec.rb
Ruby
mit
304
master
3,897
require 'spec_helper' describe "A URI" do it "should know its string form" do CloudKit::URI.new('/items/123').string.should == '/items/123' end it "should encode urls with spaces in them" do CloudKit::URI.new('/items/1 2 3').string.should == '/items/1%202%203' end it "should know its parent resour...
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
spec/openid_store_spec.rb
Ruby
mit
304
master
3,070
require 'spec_helper' describe "An OpenIDStore" do before(:each) do CloudKit.setup_storage_adapter unless CloudKit.storage_adapter @store = CloudKit::OpenIDStore.new @server = 'http://openid.claimid.com/server' @handle = "{HMAC-SHA1}{736kwv3j}{wbhwEK==}" @secret = "\350\068\753\436\567\8327\232\...
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
spec/rack_builder_spec.rb
Ruby
mit
304
master
1,203
require 'spec_helper' describe "Rack::Builder" do it "should expose services" do app = Rack::Builder.new do expose :items, :things run lambda {|app| [200, {}, ['hello']]} end response = Rack::MockRequest.new(app).get('/items') response.status.should == 200 documents = JSON.parse(resp...
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
spec/resource_spec.rb
Ruby
mit
304
master
8,682
require 'spec_helper' describe "A Resource" do before(:all) do CloudKit.setup_storage_adapter unless CloudKit.storage_adapter end after(:each) do CloudKit.storage_adapter.clear end describe "on initialization" do before(:each) do @resource = CloudKit::Resource.new( CloudKit::URI...
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
spec/request_spec.rb
Ruby
mit
304
master
8,017
require 'spec_helper' describe "A Request" do it "should match requests with routes" do CloudKit::Request.new(Rack::MockRequest.env_for( 'http://example.com')).match?('GET', '/').should be_true CloudKit::Request.new(Rack::MockRequest.env_for( 'http://example.com/')).match?('GET', '/').should be_...
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
spec/support/fixtures.rb
Ruby
mit
304
master
289
module CloudKit module Fixtures class << self def collections [:foo] end def collection_uris collections.map { |collection| "/#{collection}" }.sort end def first_collection_uri collection_uris.first end end end end
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
examples/3.ru
Ruby
mit
304
master
275
$:.unshift File.expand_path(File.dirname(__FILE__)) + '/../lib' require 'cloudkit' use Rack::Session::Pool use CloudKit::OpenIDFilter use CloudKit::Service, :collections => [:notes] run lambda{|env| [200, {'Content-Type' => 'text/html', 'Content-Length' => '5'}, ['HELLO']]}
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
examples/6.ru
Ruby
mit
304
master
500
$:.unshift File.expand_path(File.dirname(__FILE__)) + '/../lib' require 'cloudkit' require 'rufus/tokyo/tyrant' # gem install rufus-tokyo # start Tokyo Tyrant with a table store... # ttserver data.tct CloudKit.setup_storage_adapter(Rufus::Tokyo::TyrantTable.new('127.0.0.1', 1978)) use Rack::Session::Pool use CloudKit::...
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
examples/5.ru
Ruby
mit
304
master
421
$:.unshift File.expand_path(File.dirname(__FILE__)) + '/../lib' require 'cloudkit' require 'rufus/tokyo' # gem install rufus-tokyo CloudKit.setup_storage_adapter(Rufus::Tokyo::Table.new('cloudkit.tdb')) use Rack::Session::Pool use CloudKit::OAuthFilter use CloudKit::OpenIDFilter use CloudKit::Service, :collections => [...
github
jcrosby/cloudkit
https://github.com/jcrosby/cloudkit
examples/4.ru
Ruby
mit
304
master
250
$:.unshift File.expand_path(File.dirname(__FILE__)) + '/../lib' require 'cloudkit' use CloudKit::OAuthFilter use CloudKit::Service, :collections => [:notes] run lambda{|env| [200, {'Content-Type' => 'text/html', 'Content-Length' => '5'}, ['HELLO']]}
github
palkan/litecable
https://github.com/palkan/litecable
litecable.gemspec
Ruby
mit
303
master
1,505
# frozen_string_literal: true require_relative "lib/lite_cable/version" Gem::Specification.new do |spec| spec.name = "litecable" spec.version = LiteCable::VERSION spec.authors = ["palkan"] spec.email = ["dementiev.vm@gmail.com"] spec.summary = "Fat-free ActionCable implementation" spec.description = "Fat...
github
palkan/litecable
https://github.com/palkan/litecable
Rakefile
Ruby
mit
303
master
419
# frozen_string_literal: true require "bundler/gem_tasks" require "rspec/core/rake_task" require "rubocop/rake_task" RSpec::Core::RakeTask.new(:spec) begin require "rubocop/rake_task" RuboCop::RakeTask.new RuboCop::RakeTask.new("rubocop:md") do |task| task.options << %w[-c .rubocop-md.yml] end rescue Lo...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable.rb
Ruby
mit
303
master
1,547
# frozen_string_literal: true require "lite_cable/version" require "lite_cable/internal" require "lite_cable/logging" # Lightwieght ActionCable implementation. # # Contains application logic (channels, streams, broadcasting) and # also (optional) Rack hijack based server (suitable only for development and test). # # ...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/config.rb
Ruby
mit
303
master
459
# frozen_string_literal: true require "anyway_config" require "logger" module LiteCable # AnyCable configuration class Config < Anyway::Config require "lite_cable/coders/json" require "lite_cable/coders/raw" config_name :litecable attr_config :logger, coder: Coders::JSON, broadcast_a...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/channel.rb
Ruby
mit
303
master
206
# frozen_string_literal: true module LiteCable module Channel # :nodoc: require "lite_cable/channel/registry" require "lite_cable/channel/streams" require "lite_cable/channel/base" end end
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/anycable.rb
Ruby
mit
303
master
2,078
# frozen_string_literal: true module LiteCable # :nodoc: # AnyCable extensions module AnyCable module Connection # :nodoc: def self.extended(base) base.prepend InstanceMethods end def call(socket, **options) new(socket, **options) end module InstanceMethods # :no...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/broadcast_adapters.rb
Ruby
mit
303
master
1,043
# frozen_string_literal: true require "lite_cable/broadcast_adapters/base" module LiteCable module BroadcastAdapters # :nodoc: module_function def lookup_adapter(args) adapter, options = Array(args) path_to_adapter = "lite_cable/broadcast_adapters/#{adapter}" adapter_class_name = adapter....
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/logging.rb
Ruby
mit
303
master
622
# frozen_string_literal: true require "logger" module LiteCable module Logging # :nodoc: PREFIX = "LiteCable" class << self def logger return @logger if instance_variable_defined?(:@logger) @logger = LiteCable.config.logger return if @logger == false @logger ||= ::Lo...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/connection.rb
Ruby
mit
303
master
324
# frozen_string_literal: true module LiteCable module Connection # :nodoc: require "lite_cable/connection/authorization" require "lite_cable/connection/identification" require "lite_cable/connection/base" require "lite_cable/connection/streams" require "lite_cable/connection/subscriptions" end ...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/internal.rb
Ruby
mit
303
master
352
# frozen_string_literal: true module LiteCable INTERNAL = { message_types: { welcome: "welcome", ping: "ping", confirmation: "confirm_subscription", rejection: "reject_subscription", cancel: "cancel_subscription" }.freeze, protocols: ["actioncable-v1-json", "actioncable-unsu...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/server.rb
Ruby
mit
303
master
611
# frozen_string_literal: true module LiteCable # Rack middleware to hijack sockets. # # Uses thread-per-connection model (thus recommended only for development and test usage). # # Inspired by https://github.com/ngauthier/tubesock/blob/master/lib/tubesock.rb module Server require "websocket" requir...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/connection/identification.rb
Ruby
mit
303
master
2,468
# frozen_string_literal: true require "set" module LiteCable module Connection module Identification # :nodoc: module ClassMethods # :nodoc: # Mark a key as being a connection identifier index # that can then be used to find the specific connection again later. def identified_by(*i...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/connection/streams.rb
Ruby
mit
303
master
688
# frozen_string_literal: true module LiteCable module Connection # Manage the connection streams class Streams attr_reader :socket def initialize(socket) @socket = socket end # Start streaming from broadcasting to the channel. def add(channel_id, broadcasting) ...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/connection/base.rb
Ruby
mit
303
master
3,843
# frozen_string_literal: true module LiteCable module Connection # A Connection object represents a client "connected" to the application. # It contains all of the channel subscriptions. Incoming messages are then routed to these channel subscriptions # based on an identifier sent by the consumer. # ...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/connection/authorization.rb
Ruby
mit
303
master
296
# frozen_string_literal: true module LiteCable module Connection class UnauthorizedError < StandardError; end # Include methods to control authorization flow module Authorization def reject_unauthorized_connection raise UnauthorizedError end end end end
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/connection/subscriptions.rb
Ruby
mit
303
master
3,449
# frozen_string_literal: true module LiteCable class UnknownChannelError < StandardError attr_reader :channel_id def initialize(channel_id) @channel_id = channel_id super("Unknown channel: #{channel_id}") end end module Connection # Manage the connection channels and route messages ...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/server/subscribers_map.rb
Ruby
mit
303
master
2,038
# frozen_string_literal: true module LiteCable module Server # From https://github.com/rails/rails/blob/v5.0.1/actioncable/lib/action_cable/subscription_adapter/subscriber_map.rb class SubscribersMap attr_reader :streams, :sockets def initialize @streams = Hash.new do |streams, stream_id...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/server/client_socket.rb
Ruby
mit
303
master
231
# frozen_string_literal: true module LiteCable module Server module ClientSocket # :nodoc: require "lite_cable/server/client_socket/subscriptions" require "lite_cable/server/client_socket/base" end end end
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/server/middleware.rb
Ruby
mit
303
master
1,482
# frozen_string_literal: true module LiteCable module Server # Rack middleware to hijack the socket class Middleware class HijackNotAvailable < RuntimeError; end def initialize(_app, connection_class:) @connection_class = connection_class @heart_beat = HeartBeat.new end ...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/server/heart_beat.rb
Ruby
mit
303
master
934
# frozen_string_literal: true module LiteCable module Server # Sends pings to sockets class HeartBeat BEAT_INTERVAL = 3 def initialize @sockets = [] run end def add(socket) @sockets << socket end def remove(socket) @sockets.delete(socket)...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/server/client_socket/base.rb
Ruby
mit
303
master
4,037
# frozen_string_literal: true module LiteCable module Server module ClientSocket # Wrapper over web socket class Base include Logging include Subscriptions attr_reader :version, :active def initialize(env, socket, version) log(:debug, "WebSocket version #{v...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/server/client_socket/subscriptions.rb
Ruby
mit
303
master
629
# frozen_string_literal: true module LiteCable module Server module ClientSocket # Handle socket subscriptions module Subscriptions def subscribe(channel, broadcasting) LiteCable::Server.subscribers_map .add_subscriber(broadcasting, self, channel) end de...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/channel/streams.rb
Ruby
mit
303
master
2,180
# frozen_string_literal: true module LiteCable module Channel # Streams allow channels to route broadcastings to the subscriber. A broadcasting is a pubsub queue where any data # placed into it is automatically sent to the clients that are connected at that time. # Most commonly, the streamed broadcast ...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/channel/base.rb
Ruby
mit
303
master
5,049
# frozen_string_literal: true module LiteCable module Channel class Error < StandardError; end class RejectedError < Error; end class UnproccessableActionError < Error; end # The channel provides the basic structure of grouping behavior into logical units when communicating over the connection. ...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/channel/registry.rb
Ruby
mit
303
master
791
# frozen_string_literal: true module LiteCable module Channel # Stores channels identifiers and corresponding classes. module Registry class Error < StandardError; end class AlreadyRegisteredError < Error; end class UnknownChannelError < Error; end class << self def add(id,...
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/coders/json.rb
Ruby
mit
303
master
311
# frozen_string_literal: true require "json" module LiteCable module Coders # Wrapper over JSON module JSON class << self def decode(json_str) ::JSON.parse(json_str) end def encode(ruby_obj) ruby_obj.to_json end end end end end
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/coders/raw.rb
Ruby
mit
303
master
234
# frozen_string_literal: true module LiteCable module Coders # No-op coder module Raw class << self def decode(val) val end alias_method :encode, :decode end end end end
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/broadcast_adapters/memory.rb
Ruby
mit
303
master
236
# frozen_string_literal: true module LiteCable module BroadcastAdapters class Memory < Base def broadcast(stream, message, coder:) Server.subscribers_map.broadcast stream, message, coder end end end end
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/broadcast_adapters/base.rb
Ruby
mit
303
master
220
# frozen_string_literal: true module LiteCable module BroadcastAdapters class Base def initialize(**options) @options = options end private attr_reader :options end end end
github
palkan/litecable
https://github.com/palkan/litecable
lib/lite_cable/broadcast_adapters/any_cable.rb
Ruby
mit
303
master
233
# frozen_string_literal: true module LiteCable module BroadcastAdapters class AnyCable < Base def broadcast(stream, message, coder:) ::AnyCable.broadcast stream, coder.encode(message) end end end end
github
palkan/litecable
https://github.com/palkan/litecable
spec/spec_helper.rb
Ruby
mit
303
master
649
# frozen_string_literal: true begin require "debug" unless ENV["CI"] == "true" rescue LoadError end $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "lite_cable" require "lite_cable/server" Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f } RSpec.configure do |config| con...
github
palkan/litecable
https://github.com/palkan/litecable
spec/support/test_socket.rb
Ruby
mit
303
master
928
# frozen_string_literal: true require "rack" # Stub connection socket class TestSocket attr_reader :transmissions, :streams def initialize(coder: LiteCable::Coders::JSON, env: {}) @transmissions = [] @streams = {} @coder = coder @env = env end def transmit(websocket_message) @transmission...
github
palkan/litecable
https://github.com/palkan/litecable
spec/support/async_helpers.rb
Ruby
mit
303
master
351
# frozen_string_literal: true module AsyncHelpers # Wait for block to return true of raise error def wait(timeout = 1) until yield sleep 0.1 timeout -= 0.1 raise "Timeout error" unless timeout > 0 end end def concurrently(enum) enum.map { |*x| Concurrent::Future.execute { yield(*...
github
palkan/litecable
https://github.com/palkan/litecable
spec/support/sync_client.rb
Ruby
mit
303
master
2,315
# frozen_string_literal: true # Synchronous websocket client # Based on https://github.com/rails/rails/blob/v5.0.1/actioncable/test/client_test.rb class SyncClient require "websocket-client-simple" require "concurrent" WAIT_WHEN_EXPECTING_EVENT = 5 WAIT_WHEN_NOT_EXPECTING_EVENT = 0.5 attr_reader :pings ...
github
palkan/litecable
https://github.com/palkan/litecable
spec/lite_cable/config_spec.rb
Ruby
mit
303
master
296
# frozen_string_literal: true require "spec_helper" describe LiteCable::Config do let(:config) { LiteCable.config } it "sets defailts", :aggregate_failures do expect(config.coder).to eq LiteCable::Coders::JSON expect(config.identifier_coder).to eq LiteCable::Coders::Raw end end
github
palkan/litecable
https://github.com/palkan/litecable
spec/lite_cable/channel/base_spec.rb
Ruby
mit
303
master
2,392
# frozen_string_literal: true require "spec_helper" class TestChannel < LiteCable::Channel::Base attr_reader :subscribe, :unsubscribe, :follows, :received def subscribed reject if params["reject"] @subscribe = true end def unsubscribed @unsubscribe = true end def receive(data) @received...
github
palkan/litecable
https://github.com/palkan/litecable
spec/lite_cable/channel/streams_spec.rb
Ruby
mit
303
master
1,544
# frozen_string_literal: true require "spec_helper" class TestStreamsChannel < LiteCable::Channel::Base attr_reader :all_stopped def subscribed stream_from "notifications_#{user}" end def follow(data) stream_from "chat_#{data["id"]}" end def unfollow(data) stop_stream "chat_#{data["id"]}" ...
github
palkan/litecable
https://github.com/palkan/litecable
spec/lite_cable/server/subscribers_map_spec.rb
Ruby
mit
303
master
2,691
# frozen_string_literal: true require "spec_helper" describe LiteCable::Server::SubscribersMap do let(:socket) { spy("socket") } let(:socket2) { spy("socket2") } let(:coder) { LiteCable::Coders::JSON } subject { described_class.new } describe "#add_subscriber" do it "adds one socket" do subject....
github
palkan/litecable
https://github.com/palkan/litecable
spec/lite_cable/connection/identification_spec.rb
Ruby
mit
303
master
2,272
# frozen_string_literal: true require "spec_helper" class TestIdentificationConnection < LiteCable::Connection::Base identified_by :user, :john def connect @user = cookies["user"] @john = @user == "john" end end class CustomIdCoder class << self def encode(val) if val.is_a?(String) ...
github
palkan/litecable
https://github.com/palkan/litecable
spec/lite_cable/connection/base_spec.rb
Ruby
mit
303
master
1,983
# frozen_string_literal: true require "spec_helper" class TestBaseConnection < LiteCable::Connection::Base attr_reader :connected, :disconnected def connect @connected = true end def disconnect @disconnected = true end end describe TestBaseConnection do let(:socket_params) { {} } let(:socket)...
github
palkan/litecable
https://github.com/palkan/litecable
spec/lite_cable/connection/authorization_spec.rb
Ruby
mit
303
master
872
# frozen_string_literal: true require "spec_helper" class TestAuthorizationConnection < LiteCable::Connection::Base attr_reader :connected def connect reject_unauthorized_connection unless cookies["user"] @connected = true end end describe TestAuthorizationConnection do let(:cookies) { "" } let(:s...
github
palkan/litecable
https://github.com/palkan/litecable
spec/lite_cable/connection/subscriptions_spec.rb
Ruby
mit
303
master
3,714
# frozen_string_literal: true require "spec_helper" Class.new(LiteCable::Channel::Base) do identifier "subscription_test" def subscribed reject if params["reject"] == true @subscribed = true end def subscribed? @subscribed == true end def unsubscribed @unsubscribed = true end def u...
github
palkan/litecable
https://github.com/palkan/litecable
spec/integrations/server_spec.rb
Ruby
mit
303
master
4,900
# frozen_string_literal: true require "spec_helper" require "puma" describe "Lite Cable server", :async do module ServerTest # rubocop:disable Lint/ConstantDefinitionInBlock class << self def logs @logs ||= [] end end class Connection < LiteCable::Connection::Base identified_...
github
palkan/litecable
https://github.com/palkan/litecable
examples/sinatra/app.rb
Ruby
mit
303
master
912
# frozen_string_literal: true require "sinatra" require "sinatra/cookies" CABLE_URL = ENV.fetch("CABLE_URL", "/cable") class App < Sinatra::Application # :nodoc: set :public_folder, "assets" enable :sessions set :session_secret, "secret_key_with_size_of_32_bytes_dff054b19c2de43fc406f251376ad40" get "/" do ...
github
palkan/litecable
https://github.com/palkan/litecable
examples/sinatra/config.ru
Ruby
mit
303
master
434
# frozen_string_literal: true require_relative "config/environment" app = Rack::Builder.new do map "/" do run App end end unless ENV["ANYCABLE"] # Start built-in rack hijack middleware to serve websockets require "lite_cable/server" app.map "/cable" do use LiteCable::Server::Middleware, connection...
github
palkan/litecable
https://github.com/palkan/litecable
examples/sinatra/Gemfile
Ruby
mit
303
master
285
# frozen_string_literal: true source "https://rubygems.org" gem "sinatra" gem "sinatra-contrib" gem "slim" gem "puma" gem "pry-byebug" # litecable deps gem "litecable", path: "../../" # For Rack/Puma server gem "websocket", "~> 1.2.4" # For AnyCable gem "anycable", "1.0.0.rc1"
github
palkan/litecable
https://github.com/palkan/litecable
examples/sinatra/chat.rb
Ruby
mit
303
master
823
# frozen_string_literal: true require "litecable" require "anycable" # Sample chat application module Chat class Connection < LiteCable::Connection::Base # :nodoc: identified_by :user, :sid def connect self.user = cookies["user"] self.sid = request.params["sid"] reject_unauthorized_connec...
github
palkan/litecable
https://github.com/palkan/litecable
examples/sinatra/config/environment.rb
Ruby
mit
303
master
281
# frozen_string_literal: true lib = File.expand_path("../../../lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require_relative "../app" require_relative "../chat" LiteCable.config.log_level = Logger::DEBUG AnyCable.connection_factory = Chat::Connection
github
ankane/mapkick
https://github.com/ankane/mapkick
mapkick-rb.gemspec
Ruby
mit
303
master
540
require_relative "lib/mapkick/version" Gem::Specification.new do |spec| spec.name = "mapkick-rb" spec.version = Mapkick::VERSION spec.summary = "Create beautiful JavaScript maps with one line of Ruby" spec.homepage = "https://chartkick.com/mapkick" spec.license = "MIT" spec...
github
ankane/mapkick
https://github.com/ankane/mapkick
test/map_test.rb
Ruby
mit
303
master
3,610
require_relative "test_helper" class MapTest < Minitest::Test include Mapkick::Helper def setup @data = [{latitude: 1.23, longitude: 4.56}] end def test_js_map assert_map js_map(@data) end def test_area_map assert_map area_map([]) end def test_escape_data bad_data = "</script><scrip...
github
ankane/mapkick
https://github.com/ankane/mapkick
lib/mapkick.rb
Ruby
mit
303
master
516
# stdlib require "json" require "erb" # modules require_relative "mapkick/helper" require_relative "mapkick/utils" require_relative "mapkick/version" # integrations require_relative "mapkick/engine" if defined?(Rails) require_relative "mapkick/sinatra" if defined?(Sinatra) if defined?(ActiveSupport.on_load) Active...
github
ankane/mapkick
https://github.com/ankane/mapkick
lib/mapkick/utils.rb
Ruby
mit
303
master
850
module Mapkick module Utils # https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/deep_merge.rb def self.deep_merge(hash_a, hash_b) hash_a = hash_a.dup hash_b.each_pair do |k, v| tv = hash_a[k] hash_a[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? deep...
github
ankane/mapkick
https://github.com/ankane/mapkick
lib/mapkick/engine.rb
Ruby
mit
303
master
306
module Mapkick class Engine < ::Rails::Engine # for assets # for importmap initializer "mapkick.importmap" do |app| if app.config.respond_to?(:assets) && defined?(Importmap) && defined?(Sprockets) app.config.assets.precompile << "mapkick.bundle.js" end end end end
github
ankane/mapkick
https://github.com/ankane/mapkick
lib/mapkick/helper.rb
Ruby
mit
303
master
4,003
module Mapkick module Helper def js_map(data_source, **options) mapkick_map "Map", data_source, **options end def area_map(data_source, **options) mapkick_map "AreaMap", data_source, **options end private # don't break out options since need to merge with default options def...
github
jamesgolick/active_presenter
https://github.com/jamesgolick/active_presenter
Rakefile
Ruby
mit
303
master
292
require 'rake' require 'rdoc/task' require File.dirname(__FILE__)+'/lib/active_presenter' Dir.glob(File.dirname(__FILE__)+'/lib/tasks/**/*.rake').each { |l| load l } task :default => :test task :test do Dir['test/**/*_test.rb'].each { |l| require File.join(File.dirname(__FILE__),l)} end
github
jamesgolick/active_presenter
https://github.com/jamesgolick/active_presenter
active_presenter.gemspec
Ruby
mit
303
master
1,254
Gem::Specification.new do |s| s.name = %q{active_presenter} s.version = "3.2.2" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Golick", "Daniel Haran", "Josh Martin", "Johnno Loggie"] s.date = %q{2012-03-26} s.extra_rdoc_files = [ ...
github
jamesgolick/active_presenter
https://github.com/jamesgolick/active_presenter
lib/tasks/gem.rake
Ruby
mit
303
master
1,819
require 'rubygems/package_task' task :clean => :clobber_package spec = Gem::Specification.new do |s| s.name = ActivePresenter::NAME s.version = ActivePresenter::VERSION::STRING s.summary = s.description = "ActivePresenter is the presenter library you alr...
github
jamesgolick/active_presenter
https://github.com/jamesgolick/active_presenter
lib/tasks/doc.rake
Ruby
mit
303
master
620
desc 'Generate documentation for the ResourceController plugin.' Rake::RDocTask.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'ActivePresenter' rdoc.options << '--line-numbers' << '--inline-source' rdoc.rdoc_files.include('README') rdoc.rdoc_files.include('lib/**/*.rb') end task :upload_docs =>...
github
jamesgolick/active_presenter
https://github.com/jamesgolick/active_presenter
lib/active_presenter/base.rb
Ruby
mit
303
master
9,629
module ActivePresenter # Base class for presenters. See README for usage. # class Base extend ActiveModel::Callbacks extend ActiveModel::Naming extend ActiveModel::Translation include ActiveModel::MassAssignmentSecurity include ActiveModel::Conversion attr_reader :errors define_mo...
github
jamesgolick/active_presenter
https://github.com/jamesgolick/active_presenter
test/base_test.rb
Ruby
mit
303
master
8,864
require File.dirname(__FILE__)+'/test_helper' Expectations do expect nil do SignupPresenter.new.id end expect true do SignupPresenter.new.new_record? end expect :user => User, :account => Account do SignupPresenter.presented end expect User.create!(hash_for_user) do |u| SignupPresenter...
github
jamesgolick/active_presenter
https://github.com/jamesgolick/active_presenter
test/test_helper.rb
Ruby
mit
303
master
4,633
require 'expectations' require 'logger' ActiveRecord::Base.configurations = {'sqlite3' => {:adapter => 'sqlite3', :database => ':memory:'}} ActiveRecord::Base.establish_connection('sqlite3') ActiveRecord::Base.logger = Logger.new(STDERR) ActiveRecord::Base.logger.level = Logger::WARN I18n.backend.store_translations ...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
pdf-forms.gemspec
Ruby
mit
302
master
1,232
# coding: UTF-8 require File.expand_path("lib/pdf_forms/version", __dir__) Gem::Specification.new do |s| s.name = "pdf-forms" s.version = PdfForms::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Jens Krämer"] s.email = ["jk@jkraemer.net"] s.homepage = "http://github.com/...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
Rakefile
Ruby
mit
302
master
1,234
require "bundler" Bundler.setup require 'rake/testtask' desc 'Test the library.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' << 'test' t.pattern = 'test/**/*_test.rb' t.verbose = true t.warning = false end task :default => :test gemspec = eval(File.read("pdf-forms.gemspec")) task :build => "#{gemspec....
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
test/pdftk_wrapper_test.rb
Ruby
mit
302
master
4,575
# coding: utf-8 require 'test_helper' class PdftkWrapperTest < Minitest::Test def setup @pdftk = PdfForms.new 'pdftk', :data_format => data_format @pdftk_utf8 = PdfForms.new 'pdftk', utf8_fields: true, data_format: data_format @pdftk_options = PdfForms.new :flatten => true, :encrypt => true, :data_forma...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
test/xfdf_pdftk_wrapper_test.rb
Ruby
mit
302
master
821
# coding: UTF-8 require 'htmlentities' require 'test_helper' require 'pdftk_wrapper_test' class XfdfPdftkWrapperTest < PdftkWrapperTest def data_format 'XFdf' end def test_fill_form_with_japanese japanese_string = 'スペイン' @pdftk.fill_form 'test/fixtures/japanese.pdf', 'output.pdf', 'nationality' => ...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
test/pdf_test.rb
Ruby
mit
302
master
990
# coding: UTF-8 require 'test_helper' class PdfTest < Minitest::Test def setup @pdftk = PdfForms::PdftkWrapper.new 'pdftk' end def test_fields pdf = PdfForms::Pdf.new 'test/fixtures/form.pdf', @pdftk assert fields = pdf.fields assert fields.any? assert fields.detect{|f|f.name == 'program_n...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
test/field_test.rb
Ruby
mit
302
master
1,868
# coding: UTF-8 require 'test_helper' class FieldTest < Minitest::Test def setup end CHOICE_FIELD = <<-END FieldType: Choice FieldName: SomeChoiceField FieldFlags: 71696384 FieldValue: http://github.com foo FieldValueDefault: FieldJustification: Left FieldStateOption: FieldStateOption: 010 Foo Bar FieldS...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
test/fdf_hex_test.rb
Ruby
mit
302
master
815
# coding: UTF-8 require 'test_helper' # utf16 hex representation: # foo: 0066006F006F # bar: 006200610072 # qux: 007100750078 class FdfHexTest < Minitest::Test def test_fdf_generation fdf = PdfForms::FdfHex.new :field1 => 'foo', :other_field => 'bar qux' assert fdf_text = fdf.to_fdf assert_match %r{<</...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
test/xfdf_test.rb
Ruby
mit
302
master
1,059
# coding: UTF-8 require 'test_helper' class XfdfTest < Minitest::Test def test_fdf_generation fdf = PdfForms::XFdf.new :field1 => 'fieldvalue1', :other_field => 'some other value' assert fdf_text = fdf.to_fdf assert_match %r{<field name=\"field1\"><value>fieldvalue1</value></field>}, fdf_text assert...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
test/fdf_test.rb
Ruby
mit
302
master
717
# coding: UTF-8 require 'test_helper' class FdfTest < Minitest::Test def test_fdf_generation fdf = PdfForms::Fdf.new :field1 => 'fieldvalue1', :other_field => 'some other value' assert fdf_text = fdf.to_fdf assert_match %r{<</T\(field1\)/V\(fieldvalue1\)>>}, fdf_text assert_match %r{<</T\(other_fiel...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
lib/pdf_forms.rb
Ruby
mit
302
master
374
# coding: UTF-8 require 'pdf_forms/version' require 'pdf_forms/normalize_path' require 'pdf_forms/data_format' require 'pdf_forms/fdf' require 'pdf_forms/xfdf' require 'pdf_forms/fdf_hex' require 'pdf_forms/pdf' require 'pdf_forms/pdftk_wrapper' module PdfForms # shorthand for PdfForms::PdftkWrapper.new(...) def...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
lib/pdf_forms/fdf.rb
Ruby
mit
302
master
1,856
# coding: UTF-8 module PdfForms # Map keys and values to Adobe's FDF format. # # Straight port of Perl's PDF::FDF::Simple by Steffen Schwigon. # Parsing FDF files is not supported (yet). class Fdf < DataFormat def initialize(data = {}, options = {}) super end private def encode_data...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
lib/pdf_forms/fdf_hex.rb
Ruby
mit
302
master
1,089
# coding: UTF-8 module PdfForms # Map keys and values to Adobe's FDF format. # # This is a variation of the original Fdf data format, values are encoded in UTF16 hexadesimal # notation to improve compatibility with non ascii charsets. # # Information about hexadesimal FDF values was found here: # # htt...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
lib/pdf_forms/field.rb
Ruby
mit
302
master
1,579
# coding: UTF-8 module PdfForms class Field # FieldType: Button # FieldName: Sprachoptionen_Inverssuche_Widerspruch # FieldFlags: 0 # FieldJustification: Left # FieldStateOption: Ja # FieldStateOption: Off # # Representation of a PDF Form Field def initialize(field_description) ...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
lib/pdf_forms/pdftk_wrapper.rb
Ruby
mit
302
master
6,600
# coding: UTF-8 require 'tempfile' require 'cliver' require 'safe_shell' require 'securerandom' module PdfForms class PdftkError < StandardError end # Wraps calls to PdfTk class PdftkWrapper include NormalizePath attr_reader :pdftk, :options PDFTK = 'pdftk' # Initializes a new wrapper ins...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
lib/pdf_forms/data_format.rb
Ruby
mit
302
master
890
# coding UTF-8 module PdfForms class DataFormat attr_reader :options def initialize(data = {}, options = {}) @data = data @options = { :file => nil, :ufile => nil, :id => nil }.merge(options) end # generate PDF content in this data format def to_pdf_dat...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
lib/pdf_forms/pdf.rb
Ruby
mit
302
master
971
# coding: UTF-8 require 'pdf_forms/field' module PdfForms class Pdf include NormalizePath attr_reader :path, :options def initialize(path, pdftk, options = {}) @options = options @path = normalize_path(path) raise IOError unless File.readable?(@path) @pdftk = pdftk end ...
github
jkraemer/pdf-forms
https://github.com/jkraemer/pdf-forms
lib/pdf_forms/xfdf.rb
Ruby
mit
302
master
757
# coding: UTF-8 require 'rexml/document' module PdfForms # Map keys and values to Adobe's XFDF format. class XFdf < DataFormat def initialize(data = {}, options = {}) super end private def encode_data(pdf_data) pdf_data end def quote(value) REXML::Text.new(value.to_s)....
github
praxis/praxis
https://github.com/praxis/praxis
Rakefile
Ruby
mit
302
master
240
# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path('lib', __dir__) require 'praxis' require 'praxis/tasks' require 'rspec/core/rake_task' require 'bundler/gem_tasks' RSpec::Core::RakeTask.new(:spec) task default: :spec
github
praxis/praxis
https://github.com/praxis/praxis
praxis.gemspec
Ruby
mit
302
master
2,024
# frozen_string_literal: true lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'praxis/version' Gem::Specification.new do |spec| spec.name = 'praxis' spec.version = Praxis::VERSION spec.authors = ['Josep M. Blanquer', 'Dane Jensen'] spec.su...
github
praxis/praxis
https://github.com/praxis/praxis
Appraisals
Ruby
mit
302
master
333
# frozen_string_literal: true appraise 'active-6' do # Just for the query selector/filtering/ordering extensions etc... gem 'activerecord', '> 4', '< 7' gem 'sequel', '~> 5' end appraise 'active-7' do # Just for the query selector/filtering/ordering extensions etc... gem 'activerecord', '>=7' gem 'sequel'...
github
praxis/praxis
https://github.com/praxis/praxis
Guardfile
Ruby
mit
302
master
510
# frozen_string_literal: true guard :rspec, cmd: 'bundle exec rspec --format=Fuubar', \ all_after_pass: false, all_on_start: false, failed_mode: :focus do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { 'spec/' } watch('sp...
github
praxis/praxis
https://github.com/praxis/praxis
lib/praxis.rb
Ruby
mit
302
master
6,292
# frozen_string_literal: true require 'rack' require 'attributor' require 'active_support/concern' require 'praxis/request_superclassing' require 'active_support/inflector' $LOAD_PATH.unshift File.dirname(__FILE__) require 'mime' module MIME class Header attr_reader :headers end end module Praxis autoloa...
github
praxis/praxis
https://github.com/praxis/praxis
lib/praxis/media_type.rb
Ruby
mit
302
master
2,215
# frozen_string_literal: true module Praxis # An Internet Media Type as defined in RFC 1590, as used in HTTP (see RFC 2616). As used in the # Praxis framework, media types also define the structure and content of entities of that type: # the attributes that exist, their names and types. # # An object with a ...