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 | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/strategies/default_strategy_test.rb | Ruby | mit | 185 | master | 1,218 | require File.expand_path("../../../test_helper", __FILE__)
describe Flipflop::Strategies::DefaultStrategy do
before do
Flipflop::FeatureSet.current.replace do
Flipflop.configure do
feature :one, default: true
feature :two
end
end
end
describe "with defaults" do
subject do... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/strategies/redis_strategy_test.rb | Ruby | mit | 185 | master | 2,419 | require File.expand_path("../../../test_helper", __FILE__)
require "fakeredis"
describe Flipflop::Strategies::RedisStrategy do
before do
Redis.new.flushall
end
describe "with defaults" do
subject do
Flipflop::Strategies::RedisStrategy.new.freeze
end
it "should have default name" do
... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | test/unit/strategies/lambda_strategy_test.rb | Ruby | mit | 185 | master | 2,980 | require File.expand_path("../../../test_helper", __FILE__)
describe Flipflop::Strategies::LambdaStrategy do
subject do
Flipflop::Strategies::LambdaStrategy.new.freeze
end
describe "with defaults" do
it "should have default name" do
assert_equal "lambda", subject.name
end
it "should have t... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop.rb | Ruby | mit | 185 | master | 1,040 | require "active_support/concern"
require "active_support/core_ext/hash/slice"
require "active_support/core_ext/object/blank"
require "active_support/core_ext/object/try"
require "active_support/inflector"
require "flipflop/configurable"
require "flipflop/facade"
require "flipflop/feature_cache"
require "flipflop/featu... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/configurable.rb | Ruby | mit | 185 | master | 1,123 | module Flipflop
module Configurable
attr_accessor :current_group
def group(group)
self.current_group = GroupDefinition.new(group)
yield
ensure
self.current_group = nil
end
def feature(feature, **options)
options = options.merge(group: current_group)
feature = Featur... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/facade.rb | Ruby | mit | 185 | master | 475 | require "forwardable"
module Flipflop
module Facade
extend Forwardable
delegate [:configure, :enabled?] => :feature_set
alias_method :on?, :enabled?
def feature_set
FeatureSet.current
end
def respond_to_missing?(method, include_private = false)
FeatureSet.current.facade.respond_... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/feature_cache.rb | Ruby | mit | 185 | master | 1,133 | module Flipflop
class FeatureCache
class Middleware
def initialize(app)
@app = app
end
def call(env)
return @app.call(env) if FeatureCache.current.enabled?
FeatureCache.current.enable!
response = @app.call(env)
response[2] = Rack::BodyProxy.new(response[... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/group_definition.rb | Ruby | mit | 185 | master | 204 | module Flipflop
class GroupDefinition
attr_reader :key, :name, :title
def initialize(key)
@key = key
@name = @key.to_s.freeze
@title = @name.humanize.freeze
end
end
end |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/engine.rb | Ruby | mit | 185 | master | 2,102 | module Flipflop
class Engine < ::Rails::Engine
attr_accessor :rake_task_executing
isolate_namespace Flipflop
# The following middleware needs to be inserted for this engine, because it
# may not be available in Rails API only apps.
middleware.use Rack::MethodOverride
middleware.use ActionDis... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/feature_set.rb | Ruby | mit | 185 | master | 3,064 | module Flipflop
class FeatureError < StandardError
def initialize(key, error)
super("Feature '#{key}' #{error}.")
end
end
class StrategyError < StandardError
def initialize(key, error)
super("Strategy '#{key}' #{error}.")
end
end
class Callback < StandardError
def initialize(... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/feature_definition.rb | Ruby | mit | 185 | master | 632 | module Flipflop
class FeatureDefinition
attr_reader :key, :name, :title, :description, :default, :group, :location
def initialize(key, **options)
@key = key
@name = @key.to_s.freeze
@title = options.delete(:title).freeze || @name.humanize.freeze
@description = options.delete(:descript... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/feature_loader.rb | Ruby | mit | 185 | master | 773 | module Flipflop
class FeatureLoader
@@lock = Monitor.new
class << self
def current
@current or @@lock.synchronize { @current ||= new }
end
private :new
end
extend Forwardable
delegate [:execute, :updated?] => :checker
def initialize
@paths = []
end
... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/strategies/redis_strategy.rb | Ruby | mit | 185 | master | 885 | module Flipflop
module Strategies
class RedisStrategy < AbstractStrategy
class << self
def default_description
"Stores features in Redis. Applies to all users."
end
end
def initialize(**options)
@client = options.delete(:client) || ::Redis.new
@prefix =... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/strategies/test_strategy.rb | Ruby | mit | 185 | master | 707 | module Flipflop
module Strategies
class TestStrategy < AbstractStrategy
@@lock = Mutex.new
def initialize(**options)
@features = {}
super(**options)
end
def switchable?
true
end
def enabled?(feature)
@@lock.synchronize do
@features[f... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/strategies/session_strategy.rb | Ruby | mit | 185 | master | 900 | module Flipflop
module Strategies
class SessionStrategy < AbstractStrategy
class << self
def default_description
"Stores features in the user session. Applies to current user."
end
end
def initialize(**options)
@prefix = options.delete(:prefix).to_s.freeze
... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/strategies/query_string_strategy.rb | Ruby | mit | 185 | master | 633 | module Flipflop
module Strategies
class QueryStringStrategy < AbstractStrategy
class << self
def default_description
"Interprets query string parameters as features."
end
end
def initialize(**options)
@prefix = options.delete(:prefix).to_s.freeze
super(... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/strategies/options_hasher.rb | Ruby | mit | 185 | master | 376 | require "digest/md5"
module Flipflop
module Strategies
class OptionsHasher
def initialize(value)
@hasher = Digest::MD5.new
@value = value
end
def generate
@hasher << begin
Marshal.dump(@value)
rescue TypeError
@value.object_id.to_s
en... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/strategies/sequel_strategy.rb | Ruby | mit | 185 | master | 1,687 | module Flipflop
module Strategies
class SequelStrategy < AbstractStrategy
class << self
def default_description
"Stores features in database. Applies to all users."
end
def define_feature_class
return Flipflop::Feature if defined?(Flipflop::Feature)
mo... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/strategies/abstract_strategy.rb | Ruby | mit | 185 | master | 2,939 | module Flipflop
module Strategies
class AbstractStrategy
module RequestInterceptor
class << self
def request
Thread.current.thread_variable_get(:flipflop_request)
end
def request=(request)
Thread.current.thread_variable_set(:flipflop_request, re... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/strategies/lambda_strategy.rb | Ruby | mit | 185 | master | 762 | module Flipflop
module Strategies
class LambdaStrategy < AbstractStrategy
class << self
def default_description
"Resolves feature settings with custom code."
end
end
def initialize(**options)
@lambda = (options.delete(:lambda) || ->(*) { }).freeze
super... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/strategies/active_record_strategy.rb | Ruby | mit | 185 | master | 1,470 | module Flipflop
module Strategies
class ActiveRecordStrategy < AbstractStrategy
class << self
def default_description
"Stores features in database. Applies to all users."
end
def define_feature_class
return Flipflop::Feature if defined?(Flipflop::Feature)
... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/strategies/cookie_strategy.rb | Ruby | mit | 185 | master | 1,212 | module Flipflop
module Strategies
class CookieStrategy < AbstractStrategy
class << self
def default_description
"Stores features in a browser cookie. Applies to current user."
end
end
def initialize(**options)
# TODO: Support :expires as a runtime-evaluated opt... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/flipflop/strategies/default_strategy.rb | Ruby | mit | 185 | master | 305 | module Flipflop
module Strategies
class DefaultStrategy < AbstractStrategy
class << self
def default_description
"Uses feature default status."
end
end
def enabled?(feature)
FeatureSet.current.feature(feature).default
end
end
end
end |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/generators/flipflop/migration/migration_generator.rb | Ruby | mit | 185 | master | 694 | require "rails"
require "rails/generators/migration"
require "rails/generators/active_record"
class Flipflop::MigrationGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path("../templates", __FILE__)
def create_migration_file
migration_template("create_feature... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/generators/flipflop/migration/templates/create_features.rb | Ruby | mit | 185 | master | 321 | class CreateFeatures < ActiveRecord::Migration<%= Rails.version >= "5" ? "[#{ActiveRecord::Migration.current_version}]" : "" %>
def change
create_table :flipflop_features do |t|
t.string :key, null: false
t.boolean :enabled, null: false, default: false
t.timestamps null: false
end
end
end |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/generators/flipflop/install/install_generator.rb | Ruby | mit | 185 | master | 1,429 | require "generators/flipflop/features/features_generator"
require "generators/flipflop/migration/migration_generator"
require "generators/flipflop/routes/routes_generator"
class Flipflop::InstallGenerator < Rails::Generators::Base
def invoke_generators
Flipflop::FeaturesGenerator.new([], options).invoke_all
... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/generators/flipflop/features/features_generator.rb | Ruby | mit | 185 | master | 203 | class Flipflop::FeaturesGenerator < Rails::Generators::Base
source_root File.expand_path("../templates", __FILE__)
def copy_features_file
copy_file "features.rb", "config/features.rb"
end
end |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/generators/flipflop/features/templates/features.rb | Ruby | mit | 185 | master | 506 | Flipflop.configure do
# Strategies will be used in the order listed here.
strategy :cookie
strategy :active_record
strategy :default
# Other strategies:
#
# strategy :sequel
# strategy :redis
#
# strategy :query_string
# strategy :session
#
# strategy :my_strategy do |feature|
# # ... you... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/tasks/flipflop.rake | Ruby | mit | 185 | master | 1,031 | require_relative 'support/methods'
namespace :flipflop do
# Encapsulates support methods to prevent name collision with global
# rake namespace
m = Object.new
m.extend Flipflop::Rake::SupportMethods
desc 'Enables a feature with the specified strategy.'
task :turn_on, %i[feature strategy] => :environment d... |
github | voormedia/flipflop | https://github.com/voormedia/flipflop | lib/tasks/support/methods.rb | Ruby | mit | 185 | master | 1,799 | require 'terminal-table'
module Flipflop
module Rake
module SupportMethods
def status_label(enabled)
enabled.nil? ? '' : (enabled ? 'ON' : 'OFF')
end
def switch_feature!(feature_name, strategy_name, value)
feature = find_feature_by_name(feature_name)
strategy = find_str... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | async-websocket.gemspec | Ruby | mit | 186 | main | 1,257 | # frozen_string_literal: true
require_relative "lib/async/websocket/version"
Gem::Specification.new do |spec|
spec.name = "async-websocket"
spec.version = Async::WebSocket::VERSION
spec.summary = "An async websocket library on top of protocol-websocket."
spec.authors = ["Samuel Williams", "Simon Crocker", "Olle... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | gems.rb | Ruby | mit | 186 | main | 466 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2015-2024, by Samuel Williams.
source "https://rubygems.org"
gemspec
# gem "protocol-websocket", path: "../protocol-websocket"
group :maintenance, optional: true do
gem "bake-gem"
gem "bake-modernize"
gem "utopia-project"
end
group ... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | examples/mud/client.rb | Ruby | mit | 186 | main | 897 | #!/usr/bin/env ruby
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
# Copyright, 2020, by Juan Antonio Martín Lucas.
require "async"
require "async/http/endpoint"
require "async/websocket/client"
USER = ARGV.pop || "anonymous"
URL = ARGV.pop || "http://127.... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | examples/mud/config.ru | Ruby | mit | 186 | main | 2,431 | #!/usr/bin/env -S falcon serve --count 1 --bind http://127.0.0.1:7070 -c
# frozen_string_literal: true
require "async/websocket/adapters/rack"
class Room
def initialize(name, description = nil)
@name = name
@description = description
@actions = {}
@users = []
end
attr :name
attr :description
attr ... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | examples/binance/client.rb | Ruby | mit | 186 | main | 510 | #!/usr/bin/env ruby
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2021-2024, by Samuel Williams.
require "async"
require "async/http"
require "async/websocket"
URL = "wss://stream.binance.com:9443/ws/btcusdt@bookTicker"
Async do |task|
endpoint = Async::HTTP::Endpoint.parse(URL, alpn... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | examples/chat/config.ru | Ruby | mit | 186 | main | 3,366 | #!/usr/bin/env -S falcon serve --bind https://localhost:8080 --count 1 -c
# frozen_string_literal: true
require_relative "../../lib/async/websocket/adapters/rack"
require "async/clock"
require "async/semaphore"
require "set"
# GC.disable
class Room
def initialize
@connections = Set.new
@semaphore = Async::Sema... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | examples/chat/multi-client.rb | Ruby | mit | 186 | main | 2,221 | #!/usr/bin/env ruby
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
require "async"
require "async/semaphore"
require "async/clock"
require "async/http/endpoint"
require_relative "../../lib/async/websocket/client"
require "samovar"
# GC.disable
GC::Profile... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | examples/chat/client.rb | Ruby | mit | 186 | main | 743 | #!/usr/bin/env ruby
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2018-2024, by Samuel Williams.
require "async"
require "async/http/endpoint"
require_relative "../../lib/async/websocket/client"
USER = ARGV.pop || "anonymous"
URL = ARGV.pop || "https://localhost:8080"
ENDPOINT = Async:... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | examples/rack/client.rb | Ruby | mit | 186 | main | 493 | #!/usr/bin/env ruby
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
require "async"
require "async/http/endpoint"
require "async/websocket/client"
URL = ARGV.pop || "http://127.0.0.1:7070"
Async do |task|
endpoint = Async::HTTP::Endpoint.parse(URL)
Asy... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | examples/rack/gems.rb | Ruby | mit | 186 | main | 203 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2022-2024, by Samuel Williams.
source "https://rubygems.org"
gem "puma"
gem "falcon"
gem "async-websocket", path: "../../" |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | examples/rack/config.ru | Ruby | mit | 186 | main | 341 | #!/usr/bin/env -S falcon serve --bind http://127.0.0.1:7070 --count 1 -c
# frozen_string_literal: true
require "async/websocket/adapters/rack"
app = lambda do |env|
response = Async::WebSocket::Adapters::Rack.open(env) do |connection|
while message = connection.read
connection.write message
end
end or [404, ... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | test/async/websocket/connection.rb | Ruby | mit | 186 | main | 611 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2015-2024, by Samuel Williams.
# Copyright, 2019, by Simon Crocker.
require "async/websocket/connection"
describe Async::WebSocket::Connection do
let(:framer) {Protocol::WebSocket::Framer.new(nil)}
let(:connection) {subject.new(framer)}
... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | test/async/websocket/response.rb | Ruby | mit | 186 | main | 466 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2023-2024, by Samuel Williams.
require "async/websocket/response"
describe Async::WebSocket::Response do
it "fails if the version is not recognized" do
request = Protocol::HTTP::Request.new(nil, nil, "GET", "/", "frob/2.0")
expect d... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | test/async/websocket/client.rb | Ruby | mit | 186 | main | 6,866 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2023-2024, by Samuel Williams.
# Copyright, 2023, by Thomas Morgan.
require "async/websocket/client"
require "async/websocket/adapters/http"
require "sus/fixtures/async/http/server_context"
ClientExamples = Sus::Shared("a websocket client"... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | test/async/websocket/server.rb | Ruby | mit | 186 | main | 4,337 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
require "protocol/http/middleware/builder"
require "async/websocket/client"
require "async/websocket/server"
require "async/websocket/adapters/http"
require "sus/fixtures/async/http/server_context"
ServerExa... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | test/async/websocket/request.rb | Ruby | mit | 186 | main | 993 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2023-2024, by Samuel Williams.
require "async/websocket/request"
describe Async::WebSocket::Request do
let(:request) {subject.new("https", "localhost", "/")}
let(:connection) {Async::WebSocket::Connection.new(nil)}
it "can detect webso... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | test/async/websocket/adapters/rack.rb | Ruby | mit | 186 | main | 1,699 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2015-2024, by Samuel Williams.
# Copyright, 2019, by Simon Crocker.
require "async/websocket"
require "async/websocket/client"
require "async/websocket/adapters/rack"
require "async/websocket/rack_application"
describe Async::WebSocket::Ada... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket.rb | Ruby | mit | 186 | main | 219 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2015-2024, by Samuel Williams.
require_relative "websocket/version"
require_relative "websocket/server"
require_relative "websocket/client" |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket/client.rb | Ruby | mit | 186 | main | 3,309 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2015-2024, by Samuel Williams.
# Copyright, 2019, by Bryan Powell.
# Copyright, 2019, by Janko Marohnić.
# Copyright, 2023, by Thomas Morgan.
require_relative "request"
require_relative "connection"
require "protocol/websocket/headers"
requ... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket/request.rb | Ruby | mit | 186 | main | 1,334 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
require_relative "connect_request"
require_relative "upgrade_request"
require_relative "error"
module Async
module WebSocket
class Request
include ::Protocol::WebSocket::Headers
def self.websocket... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket/connect_response.rb | Ruby | mit | 186 | main | 983 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
require "protocol/http/response"
require "async/http/body/hijack"
module Async
module WebSocket
# The response from the server back to the client for negotiating HTTP/2 WebSockets.
class ConnectResponse <... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket/server.rb | Ruby | mit | 186 | main | 614 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2018-2024, by Samuel Williams.
# Copyright, 2019, by Simon Crocker.
require_relative "connection"
require_relative "response"
require "protocol/http/middleware"
module Async
module WebSocket
class Server < ::Protocol::HTTP::Middleware
... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket/upgrade_response.rb | Ruby | mit | 186 | main | 1,025 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
# Copyright, 2023, by Thomas Morgan.
require "async/http/body/hijack"
require "protocol/http/response"
require "protocol/websocket/headers"
module Async
module WebSocket
# The response from the server back ... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket/response.rb | Ruby | mit | 186 | main | 694 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
require_relative "upgrade_response"
require_relative "connect_response"
require_relative "error"
module Async
module WebSocket
module Response
# Send the request to the given connection.
def self.for... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket/error.rb | Ruby | mit | 186 | main | 543 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
require "protocol/websocket/error"
module Async
module WebSocket
class ProtocolError < ::Protocol::WebSocket::ProtocolError
end
class Error < ::Protocol::WebSocket::Error
end
class Unsupported... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket/connection.rb | Ruby | mit | 186 | main | 1,028 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2018-2024, by Samuel Williams.
# Copyright, 2019, by Janko Marohnić.
require "protocol/websocket/connection"
require "protocol/websocket/headers"
require "json"
module Async
module WebSocket
Frame = ::Protocol::WebSocket::Frame
# T... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket/upgrade_request.rb | Ruby | mit | 186 | main | 2,235 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
# Copyright, 2023, by Thomas Morgan.
# Copyright, 2024, by Ryu Sato.
require "protocol/http/middleware"
require "protocol/http/request"
require "protocol/http/headers"
require "protocol/websocket/headers"
req... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket/connect_request.rb | Ruby | mit | 186 | main | 1,907 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
# Copyright, 2023, by Thomas Morgan.
require "protocol/http/request"
require "protocol/http/headers"
require "protocol/websocket/headers"
require "protocol/http/body/readable"
require "async/variable"
module ... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket/adapters/http.rb | Ruby | mit | 186 | main | 1,619 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2021-2024, by Samuel Williams.
# Copyright, 2021, by Aurora Nockert.
require_relative "../connection"
require_relative "../response"
require "protocol/websocket/extensions"
module Async
module WebSocket
module Adapters
module HTTP
... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket/adapters/rack.rb | Ruby | mit | 186 | main | 675 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
require_relative "http"
require "protocol/rack/request"
require "protocol/rack/adapter"
module Async
module WebSocket
module Adapters
module Rack
include ::Protocol::WebSocket::Headers
def s... |
github | socketry/async-websocket | https://github.com/socketry/async-websocket | lib/async/websocket/adapters/rails.rb | Ruby | mit | 186 | main | 472 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2021-2024, by Samuel Williams.
# Copyright, 2023, by Emily Love Mills.
require_relative "rack"
module Async
module WebSocket
module Adapters
module Rails
def self.open(request, **options, &block)
if response = Rack.open(reque... |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | olive_branch.gemspec | Ruby | mit | 185 | main | 785 | $:.push File.expand_path("../lib", __FILE__)
require "olive_branch/version"
Gem::Specification.new do |s|
s.name = "olive_branch"
s.version = OliveBranch::VERSION
s.summary = "Handle camel/snake/dash case conversion"
s.description = "Handle camel/snake/dash case conversion"
s.authors = ["... |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | Appraisals | Ruby | mit | 185 | main | 461 | # frozen_string_literal: true
# Will not work on Ruby 2.6.1
# appraise 'rails-4.1' do
# gem 'rails', '~> 4.1.16'
# end
appraise 'rails-4.2' do
gem 'rails', '~> 4.2.11'
end
appraise 'rails-5.0' do
gem 'rails', '~> 5.0.7.1'
end
appraise 'rails-5.1' do
gem 'rails', '~> 5.1.6.1'
end
appraise 'rails-5.2' do
g... |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | Rakefile | Ruby | mit | 185 | main | 233 | require "bundler/gem_tasks"
begin
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
task default: :spec
rescue LoadError
end
task :benchmark do
sh "BENCHMARK_REPETITIONS=1000 rspec spec/benchmark_spec.rb"
end |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | lib/olive_branch/middleware.rb | Ruby | mit | 185 | main | 3,662 | require "multi_json"
module OliveBranch
class Checks
def self.content_type_check(content_type)
content_type =~ /application\/json/ || content_type =~ /application\/vnd\.api\+json/
end
def self.default_exclude(env)
false
end
end
class Transformations
class << self
def trans... |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | spec/benchmark_spec.rb | Ruby | mit | 185 | main | 737 | require 'rails_helper'
BENCHMARK_REPETITIONS ||= Integer(ENV["BENCHMARK_REPETITIONS"] || 0)
if BENCHMARK_REPETITIONS > 0
RSpec.describe 'Benchmark thingerer', :type => :request do
let(:url) { '/posts/complex' }
let(:headers) do
{ "CONTENT_TYPE" => "application/json", 'X-Key-Inflection' => 'camel' }
... |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | spec/integration_spec.rb | Ruby | mit | 185 | main | 2,299 | require 'rails_helper'
RSpec.describe 'Integration Test', :type => :request do
let(:url) { '/posts/1234?categoryFilter[categoryName][]=food' }
let(:headers) do
{ "CONTENT_TYPE" => "application/json", 'Key-Inflection' => 'camel' }
end
let(:params) do
{ 'post' => { 'authorName' => 'John Smith' } }
end
... |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | spec/spec_helper.rb | Ruby | mit | 185 | main | 4,785 | require 'olive_branch'
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a nee... |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | spec/rails_helper.rb | Ruby | mit | 185 | main | 419 | # This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../test_app/config/environment', __FILE__)
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'
RSpec.configure ... |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | spec/olive_branch/middleware_spec.rb | Ruby | mit | 185 | main | 12,913 | require "rails_helper"
RSpec.describe OliveBranch::Middleware do
describe "modifying request" do
let(:params) do
{
"action_dispatch.request.request_parameters" => {
"post" => {
"authorName" => "Adam Smith"
}
}
}
end
it "snake cases incoming par... |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | spec/test_app/app/controllers/posts_controller.rb | Ruby | mit | 185 | main | 465 | # PostsController
class PostsController < ApplicationController
COMPLEX_RESPONSE ||= JSON.parse(
File.read(Rails.root.join('example_responses/complex.json'))
)
def update
request.env['params_spy'] = params
payload = {
post_author_name: params[:post][:author_name],
category_filter_name: (... |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | spec/test_app/config/application.rb | Ruby | mit | 185 | main | 397 | require_relative 'boot'
require 'action_controller/railtie'
require 'olive_branch'
Bundler.require(*Rails.groups)
module TestApp
# Application
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1 if config.respond_to?(... |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | spec/test_app/config/routes.rb | Ruby | mit | 185 | main | 274 | Rails.application.routes.draw do
# NOTE: The camelized path parameter is used to test that we do *not* apply
# any transformations on path parameters.
put 'posts/:postId', format: :json, to: 'posts#update'
get 'posts/complex', format: :json, to: 'posts#complex'
end |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | spec/test_app/config/environments/test.rb | Ruby | mit | 185 | main | 349 | Rails.application.configure do
config.cache_classes = true
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_dispatch.show_exceptions = false
config.action_controller.allow_forgery_protection = false
config.active_suppo... |
github | vigetlabs/olive_branch | https://github.com/vigetlabs/olive_branch | spec/test_app/config/environments/production.rb | Ruby | mit | 185 | main | 499 | Rails.application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.read_encrypted_secrets = true
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.log_... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | librarian-ansible.gemspec | Ruby | mit | 185 | master | 923 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'librarian/ansible/version'
Gem::Specification.new do |gem|
gem.name = "librarian-ansible"
gem.version = Librarian::Ansible::VERSION
gem.authors = ["Benjamin C... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | spec/functional/ansible/cli_spec.rb | Ruby | mit | 185 | master | 1,491 | require_relative "../../support/spec_helper"
require "librarian/ansible/cli"
module Librarian
module Ansible
describe Cli do
include Librarian::RSpec::Support::CliMacro
describe "init" do
before do
cli! "init"
end
it "should create a file named Ansiblefile" do
... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | spec/integration/ansible/source/git_spec.rb | Ruby | mit | 185 | master | 13,292 | require 'librarian'
require 'librarian/helpers'
require 'librarian/error'
require 'librarian/action/resolve'
require 'librarian/action/install'
require 'librarian/action/update'
require 'librarian/ansible'
require 'support/project_path'
module Librarian
module Ansible
module Source
describe Git do
... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | spec/support/spec_helper.rb | Ruby | mit | 185 | master | 655 | require "librarian/rspec/support/cli_macro"
class FileMatcher < Librarian::RSpec::Support::CliMacro::FileMatcher
def actual_content
@actual_content ||= begin
content = full_path.read
content = JSON.parse(content) if type == :json
content = YAML.load(content) if type == :yaml
content
e... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/librarian/ansible/manifest_reader.rb | Ruby | mit | 185 | master | 967 | require 'json'
require 'yaml'
require 'librarian/manifest'
module Librarian
module Ansible
module ManifestReader
extend self
def manifest_path(path)
path.join("meta/main.yml")
end
def read_manifest(name, manifest_path)
if [".yml", ".yaml"].include?(manifest_path.extname... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/librarian/ansible/dsl.rb | Ruby | mit | 185 | master | 350 | require 'librarian/dsl'
require 'librarian/ansible/source'
module Librarian
module Ansible
class Dsl < Librarian::Dsl
dependency :role
source :git => Source::Git
source :github => Source::Github
source :path => Source::Path
source :galaxy => Source::Galaxy
source :site => So... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/librarian/ansible/source.rb | Ruby | mit | 185 | master | 203 | require 'librarian/ansible/source/path'
require 'librarian/ansible/source/git'
require 'librarian/ansible/source/github'
require 'librarian/ansible/source/galaxy'
require 'librarian/ansible/source/site' |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/librarian/ansible/environment.rb | Ruby | mit | 185 | master | 596 | require "librarian/environment"
require "librarian/ansible/dsl"
require "librarian/ansible/source"
require "librarian/ansible/version"
require "ext/librarian/dsl/target"
module Librarian
module Ansible
class Environment < Environment
def adapter_name
"ansible"
end
def adapter_version... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/librarian/ansible/cli.rb | Ruby | mit | 185 | master | 1,668 | require 'librarian/helpers'
require 'librarian/cli'
require 'librarian/ansible'
require 'librarian/ansible/action'
module Librarian
module Ansible
class Cli < Librarian::Cli
module Particularity
def root_module
Ansible
end
end
extend Particularity
source_root... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/librarian/ansible/action/install.rb | Ruby | mit | 185 | master | 428 | require 'librarian/action/install'
module Librarian
module Ansible
module Action
class Install < Librarian::Action::Install
private
def create_install_path
install_path.rmtree if install_path.exist? && destructive?
install_path.mkpath
end
def destructi... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/librarian/ansible/source/galaxy.rb | Ruby | mit | 185 | master | 2,244 | require "librarian/ansible/source/git"
require "faraday"
# Lookup an Ansible role in Galaxy API, using
# github_user and package name.
module Librarian
module Ansible
module Source
class Galaxy
@@galaxy_api = "https://galaxy.ansible.com/api/v1/"
class << self
def galaxy_api=(ga... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/librarian/ansible/source/git.rb | Ruby | mit | 185 | master | 685 | require 'librarian/source/git'
require 'librarian/ansible/source/local'
# Install an ansible role based on git url.
module Librarian
module Ansible
module Source
class Git < Librarian::Source::Git
include Local
private
def install_perform_step_copy!(found_path, install_path)
... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/librarian/ansible/source/site.rb | Ruby | mit | 185 | master | 598 | require 'librarian/source/path'
require 'librarian/ansible/source/git'
require 'librarian/ansible/source/galaxy'
# Set the Galaxy API url, using the
# site directive.
module Librarian
module Ansible
module Source
class Site
class << self
def lock_name
Git.lock_name
... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/librarian/ansible/source/github.rb | Ruby | mit | 185 | master | 588 | require 'librarian/ansible/source/git'
# Install an ansible role based on github_user/github_repo
# format.
module Librarian
module Ansible
module Source
class Github
class << self
def lock_name
Git.lock_name
end
def from_lock_options(environment, option... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/librarian/ansible/source/local.rb | Ruby | mit | 185 | master | 2,511 | require 'librarian/ansible/manifest_reader'
# Install a local role.
module Librarian
module Ansible
module Source
module Local
def install!(manifest)
manifest.source == self or raise ArgumentError
info { "Installing #{manifest.name} (#{manifest.version})" }
debug { ... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/librarian/ansible/source/path.rb | Ruby | mit | 185 | master | 268 | require 'librarian/source/path'
require 'librarian/ansible/source/local'
# Install local dependency based on
# file path.
module Librarian
module Ansible
module Source
class Path < Librarian::Source::Path
include Local
end
end
end
end |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/ext/librarian/lockfile/parser.rb | Ruby | mit | 185 | master | 1,541 | require 'librarian/manifest'
require 'librarian/dependency'
require 'librarian/manifest_set'
# Override the lockfile parser, to allow '.' in package names.
module Librarian
class Lockfile
class Parser
def extract_and_parse_sources(lines)
sources = []
while source_type_names.include?(lines.... |
github | bcoe/librarian-ansible | https://github.com/bcoe/librarian-ansible | lib/ext/librarian/dsl/target.rb | Ruby | mit | 185 | master | 1,031 | require 'librarian/spec'
# Override the default librarian DSL to pass the 'name'
# parameter to a source.
module Librarian
class Dsl
class Target
def dependency(name, *args)
options = args.last.is_a?(Hash) ? args.pop : {}
source = source_from_options(options, name) || @source
dep =... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | Gemfile | Ruby | mit | 185 | staging | 292 | source 'https://rubygems.org'
group :development do
gem 'geminabox'
gem 'overcommit'
gem 'rubocop', '~> 1.75.0'
gem 'rubocop-rake'
gem 'rubocop-rspec'
# TODO: remove when geminabox is fixed, see https://github.com/geminabox/geminabox/pull/572
gem 'rubygems-generate_index'
end |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl-repo/Gemfile | Ruby | mit | 185 | staging | 286 | source 'https://rubygems.org'
gemspec
if ENV.has_key?('OS_BUILD_ID')
gem 'libosctl', source: 'https://rubygems.vpsfree.cz'
else
gem 'libosctl', path: '../libosctl'
end
group :development do
gem 'md2man'
gem 'rake'
gem 'yard'
end
group :test do
gem 'rspec', '~> 3.13'
end |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl-repo/osctl-repo.gemspec | Ruby | mit | 185 | staging | 942 | lib = File.expand_path('lib', __dir__)
$:.unshift(lib) unless $:.include?(lib)
require 'osctl/repo/version'
Gem::Specification.new do |s|
s.name = 'osctl-repo'
s.version = if ENV['OS_BUILD_ID']
"#{OsCtl::Repo::VERSION}.build#{ENV['OS_BUILD_ID']}"
else
OsCtl::Repo::VER... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl-repo/Rakefile | Ruby | mit | 185 | staging | 1,179 | require 'bundler/gem_tasks'
require 'md2man/rakefile'
require 'md2man/roff/engine'
require 'md2man/html/engine'
require 'yard'
# Override markdown engine to add extra parameter
[Md2Man::Roff, Md2Man::HTML].each do |mod|
mod.send(:remove_const, :ENGINE)
mod.send(:const_set, :ENGINE, Redcarpet::Markdown.new(mod.cons... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl-repo/lib/osctl/repo.rb | Ruby | mit | 185 | staging | 434 | require 'libosctl'
require 'require_all'
module OsCtl
module Repo
module Base; end
# Classes for manipulation of the repository on the server-side
module Local; end
# Classes for working with a remote repository over HTTP
module Remote; end
module Downloader; end
end
end
require_rel 're... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl-repo/lib/osctl/repo/exceptions.rb | Ruby | mit | 185 | staging | 835 | module OsCtl
module Repo
class ImageNotFound < StandardError
def initialize(image)
super(image.to_s)
end
end
class FormatNotFound < StandardError
def initialize(image, format)
super("#{image}: #{format}")
end
end
class BadHttpResponse < StandardError
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl-repo/lib/osctl/repo/cli/repo.rb | Ruby | mit | 185 | staging | 4,129 | require 'json'
require 'osctl/repo/cli/command'
module OsCtl::Repo
class Cli::Repo < Cli::Command
def init
repo = Local::Repository.new(Dir.pwd)
raise 'repository already exists' if repo.exist?
repo.create
end
def local_list
repo = Local::Repository.new(Dir.pwd)
raise 'rep... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.