repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
orslumen/record-cache | https://github.com/orslumen/record-cache/blob/9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6/lib/record_cache/datastore/active_record_32.rb | lib/record_cache/datastore/active_record_32.rb | module RecordCache
module ActiveRecord
module Base
class << self
def included(klass)
klass.extend ClassMethods
klass.class_eval do
class << self
alias_method_chain :find_by_sql, :record_cache
end
end
end
end
mo... | ruby | MIT | 9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6 | 2026-01-04T17:37:41.322462Z | false |
orslumen/record-cache | https://github.com/orslumen/record-cache/blob/9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6/lib/record_cache/datastore/active_record_41.rb | lib/record_cache/datastore/active_record_41.rb | module RecordCache
module ActiveRecord
module Base
class << self
def included(klass)
klass.extend ClassMethods
klass.class_eval do
class << self
alias_method_chain :find_by_sql, :record_cache
end
end
end
end
mo... | ruby | MIT | 9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6 | 2026-01-04T17:37:41.322462Z | false |
orslumen/record-cache | https://github.com/orslumen/record-cache/blob/9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6/lib/record_cache/datastore/active_record_31.rb | lib/record_cache/datastore/active_record_31.rb | module RecordCache
module ActiveRecord
module Base
class << self
def included(klass)
klass.extend ClassMethods
klass.class_eval do
class << self
alias_method_chain :find_by_sql, :record_cache
end
end
end
end
mo... | ruby | MIT | 9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6 | 2026-01-04T17:37:41.322462Z | false |
orslumen/record-cache | https://github.com/orslumen/record-cache/blob/9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6/lib/record_cache/datastore/active_record_40.rb | lib/record_cache/datastore/active_record_40.rb | module RecordCache
module ActiveRecord
module Base
class << self
def included(klass)
klass.extend ClassMethods
klass.class_eval do
class << self
alias_method_chain :find_by_sql, :record_cache
end
end
end
end
mo... | ruby | MIT | 9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6 | 2026-01-04T17:37:41.322462Z | false |
orslumen/record-cache | https://github.com/orslumen/record-cache/blob/9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6/lib/record_cache/datastore/active_record_30.rb | lib/record_cache/datastore/active_record_30.rb | module RecordCache
module ActiveRecord
module Base
class << self
def included(klass)
klass.extend ClassMethods
klass.class_eval do
class << self
alias_method_chain :find_by_sql, :record_cache
end
end
end
end
mo... | ruby | MIT | 9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6 | 2026-01-04T17:37:41.322462Z | false |
orslumen/record-cache | https://github.com/orslumen/record-cache/blob/9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6/lib/record_cache/strategy/index_cache.rb | lib/record_cache/strategy/index_cache.rb | module RecordCache
module Strategy
class IndexCache < Base
# parse the options and return (an array of) instances of this strategy
def self.parse(base, record_store, options)
return nil unless options[:index]
return nil unless base.table_exists?
raise "Index cache '... | ruby | MIT | 9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6 | 2026-01-04T17:37:41.322462Z | false |
orslumen/record-cache | https://github.com/orslumen/record-cache/blob/9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6/lib/record_cache/strategy/unique_index_cache.rb | lib/record_cache/strategy/unique_index_cache.rb | module RecordCache
module Strategy
class UniqueIndexCache < Base
# All attributes with a unique index for the given model
def self.attributes(base)
(@attributes ||= {})[base.name] ||= []
end
# parse the options and return (an array of) instances of this strategy
def self.pa... | ruby | MIT | 9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6 | 2026-01-04T17:37:41.322462Z | false |
orslumen/record-cache | https://github.com/orslumen/record-cache/blob/9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6/lib/record_cache/strategy/base.rb | lib/record_cache/strategy/base.rb | module RecordCache
module Strategy
class Base
# Parse the options and return (an array of) instances of this strategy.
def self.parse(base, record_store, options)
raise NotImplementedError
end
def initialize(base, attribute, record_store, options)
@base = base
@at... | ruby | MIT | 9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6 | 2026-01-04T17:37:41.322462Z | false |
orslumen/record-cache | https://github.com/orslumen/record-cache/blob/9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6/lib/record_cache/strategy/full_table_cache.rb | lib/record_cache/strategy/full_table_cache.rb | module RecordCache
module Strategy
class FullTableCache < Base
FULL_TABLE = 'full-table'
# parse the options and return (an array of) instances of this strategy
def self.parse(base, record_store, options)
return nil unless options[:full_table]
return nil unless base.table_exists... | ruby | MIT | 9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6 | 2026-01-04T17:37:41.322462Z | false |
orslumen/record-cache | https://github.com/orslumen/record-cache/blob/9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6/lib/record_cache/strategy/util.rb | lib/record_cache/strategy/util.rb | # Utility methods for the Cache Strategies
module RecordCache
module Strategy
module Util
CLASS_KEY = :c
ATTRIBUTES_KEY = :a
class << self
# serialize one record before adding it to the cache
# creates a shallow clone with a version and without associations
def serializ... | ruby | MIT | 9bf4285c0a086f831b4b6e1d3fc292fbe44a14d6 | 2026-01-04T17:37:41.322462Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/spec/spec_helper.rb | spec/spec_helper.rb | require 'pathname'
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
$:.unshift((ROOT + 'lib').to_s)
$:.unshift((ROOT + 'spec').to_s)
require 'bundler/setup'
require 'bacon'
require 'mocha-on-bacon'
require 'pretty_bacon'
require 'pathname'
require 'cocoapods'
Mocha::Configuration.prevent(:stubbing_non_existe... | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/spec/command/framework_spec.rb | spec/command/framework_spec.rb | require File.expand_path('../../spec_helper', __FILE__)
module Pod
describe Command::Framework do
describe 'CLAide' do
it 'registers it self' do
Command.parse(%w{ framework }).should.be.instance_of Command::Framework
end
end
end
end
| ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods_plugin.rb | lib/cocoapods_plugin.rb | require 'cocoapods'
require 'cocoapods-framework/config'
require 'cocoapods-framework/util'
require 'cocoapods-framework/xbuilder'
require 'cocoapods-framework/frameworker'
require 'cocoapods-framework/muti_frameworker'
#这个放在最后一个
require 'cocoapods-framework/command'
| ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework.rb | lib/cocoapods-framework.rb | require 'cocoapods-framework/gem_version'
| ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/command.rb | lib/cocoapods-framework/command.rb | require 'cocoapods-framework/command/framework'
require 'cocoapods-framework/command/muti_framework'
| ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/xbuilder.rb | lib/cocoapods-framework/xbuilder.rb | require 'cocoapods-framework/xbuilder/xcode_xbuild'
require 'cocoapods-framework/xbuilder/xcodeproj_helper'
module Pod
class XBuilder
include XcodeXBuilder
include XcodeProjHelper
include PodUtil
include Config::Mixin
def initialize(installer, source_dir, sandbox_root, spec, configuration)
# d... | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/frameworker.rb | lib/cocoapods-framework/frameworker.rb | module Pod
class Frameworker
include PodUtil
include DirUtil
include Config::Mixin
def initialize(name, source, spec_sources, subspecs, configuration, force, use_modular_headers, enable_bitcode)
@name = name
@source = source
@spec_sources = spec_sources
@subspecs = subspecs
... | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/muti_frameworker.rb | lib/cocoapods-framework/muti_frameworker.rb | module Pod
class MutiFrameworker
include Pod::PodUtil
include Pod::GitUtil
include Pod::DirUtil
include Config::Mixin
def initialize(name, source, spec_sources, configuration, force, use_modular_headers)
@name = name
@source = source
@spec_sources = spec_sources
@configurat... | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/config.rb | lib/cocoapods-framework/config.rb | module Pod
class Config
attr_accessor :xcframework_enable
alias_method :xcframework_enable?, :xcframework_enable
attr_accessor :static_library_enable
alias_method :static_library_enable?, :static_library_enable
end
end | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/gem_version.rb | lib/cocoapods-framework/gem_version.rb | module CocoapodsFramework
VERSION = "0.2.5"
end
| ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/util.rb | lib/cocoapods-framework/util.rb | require 'cocoapods-framework/util/error_util'
require 'cocoapods-framework/util/cmd'
require 'cocoapods-framework/util/git_util'
require 'cocoapods-framework/util/pod_util'
require 'cocoapods-framework/util/dir_util'
| ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/util/error_util.rb | lib/cocoapods-framework/util/error_util.rb | module Pod
module ErrorUtil
class << self
def error_report(command, output)
UI.puts "<<-EOF
Build command failed: #{command}
Output:
#{output.map { |line| " #{line}" }.join}
EOF"
end
end
end
end | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/util/cmd.rb | lib/cocoapods-framework/util/cmd.rb | module Pod
class Cmmd
class << self
def sh! command
UI.puts command
output = `#{command}`.lines.to_a
if $?.exitstatus != 0
Pod::ErrorUtil.error_report command,output
Process.exit -1
end
output
end
def sh? command
UI.puts comman... | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/util/pod_util.rb | lib/cocoapods-framework/util/pod_util.rb | module Pod
module PodUtil
include Config::Mixin
def to_native_platform name
case name
when 'iphoneos' then 'ios'
when 'macOS' then 'osx'
when 'appletvos' then 'tvos'
when 'watchos' then 'watchos'
when 'ios' then 'ios'
when 'macos' then 'osx'
when 'tvos' then 't... | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/util/dir_util.rb | lib/cocoapods-framework/util/dir_util.rb | module Pod
module DirUtil
def create_target_directory_path_by_spec spec,force
target_dir = "#{Dir.pwd}/#{spec.name}-#{spec.version}"
if File.exist? target_dir
if @force
Pathname.new(target_dir).rmtree
else
UI.warn "Target directory '#{target_dir}' already exists."
... | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/util/git_util.rb | lib/cocoapods-framework/util/git_util.rb | module Pod
module GitUtil
def prepare_git_with_configs configs, work_dir
index = 0
configs.each do |config|
name = config["name"]
git_url = config["git_url"]
git_branch = config["git_branch"]
command = "git clone #{git_url} -b #{git_branch} #{work_dir}/#{name}"
... | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/command/muti_framework.rb | lib/cocoapods-framework/command/muti_framework.rb | module Pod
class Command
# This is an example of a cocoapods plugin adding a top-level subcommand
# to the 'pod' command.
#
# You can also create subcommands of existing or new commands. Say you
# wanted to add a subcommand to `list` to show newly deprecated pods,
# (e.g. `pod list deprecated`... | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/command/framework.rb | lib/cocoapods-framework/command/framework.rb | module Pod
class Command
# This is an example of a cocoapods plugin adding a top-level subcommand
# to the 'pod' command.
#
# You can also create subcommands of existing or new commands. Say you
# wanted to add a subcommand to `list` to show newly deprecated pods,
# (e.g. `pod list deprecated`... | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/xbuilder/xcodeproj_helper.rb | lib/cocoapods-framework/xbuilder/xcodeproj_helper.rb | require 'xcodeproj'
module Pod
class XBuilder
module XcodeProjHelper
include PodUtil
def modify_xcode_project_sdk_to_simullator path
sdks = xcode_sdks
project = Xcodeproj::Project.open path
project.targets.each do |target|
simulator_sdk = to_native_simulator_platform... | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
TyrantDante/cocoapods-xcframework | https://github.com/TyrantDante/cocoapods-xcframework/blob/5397ca08580c80307da54acbaed2af7e627cee83/lib/cocoapods-framework/xbuilder/xcode_xbuild.rb | lib/cocoapods-framework/xbuilder/xcode_xbuild.rb | module Pod
class XBuilder
module XcodeXBuilder
def xcode_xbuild(defines, configuration, work_dir, build_dir = 'export')
if defined?(Pod::DONT_CODESIGN)
defines = "#{defines} CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO"
end
pwd = Pathname.pwd
Dir.chdir work_dir
... | ruby | MIT | 5397ca08580c80307da54acbaed2af7e627cee83 | 2026-01-04T17:37:47.238502Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/spec_helper.rb | spec/spec_helper.rb | # This file was generated by the `rspec --init` 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 need to explicitly require it in any files.... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/support/models.rb | spec/support/models.rb | require 'active_record'
ActiveRecord::Migration.verbose = false
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
class CreateModelsForTest < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name
t.integer :posts_count, :default => 0
... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/support/worker_adapter.rb | spec/support/worker_adapter.rb | class TestWorkerAdapter
def enqueue(delay, base_class, options)
options[:source_object_class_name] = base_class.constantize
counter_class = options[:counter].constantize
counter = counter_class.new(nil, options)
counter.save!
end
end
| ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/features/counter_spec.rb | spec/features/counter_spec.rb | require 'spec_helper'
require 'support/models'
require 'support/worker_adapter'
require 'fakeredis'
RSpec.describe "Counting" do
before do
CreateModelsForTest.migrate(:up)
Counter::Cache.configure do |c|
c.redis_pool = Redis.new
c.default_worker_adapter = TestWorkerAdapter.new
end
end
a... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/lib/counter/cache_spec.rb | spec/lib/counter/cache_spec.rb | require 'spec_helper'
RSpec.describe Counter::Cache do
describe '.included' do
let(:counter) { double(:counter) }
let(:clazz) { Class.new { include Counter::Cache } }
it 'listens to the after_create and after_destroy' do
expect(clazz).to receive(:after_create).with(an_instance_of(Counter::Cache::A... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/lib/counter/cache/buffer_counter_spec.rb | spec/lib/counter/cache/buffer_counter_spec.rb | require 'spec_helper'
RSpec.describe Counter::Cache::Counters::BufferCounter do
let(:options) { {} }
let(:source_object) { double }
let(:counter) { Counter::Cache::Counters::BufferCounter.new(source_object, options) }
describe "#update" do
it "calls update! on an instance of an updater" do
updater =... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/lib/counter/cache/redis_spec.rb | spec/lib/counter/cache/redis_spec.rb | require 'spec_helper'
RSpec.describe Counter::Cache::Redis do
let(:redis) { double }
let(:redis_pool) { double }
before do
Counter::Cache.configure do |c|
c.redis_pool = redis_pool
end
allow(redis_pool).to receive(:with).and_yield(redis)
end
let(:helper) { Counter::Cache::Redis.new }
... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/lib/counter/cache/options_parser_spec.rb | spec/lib/counter/cache/options_parser_spec.rb | require 'spec_helper'
RSpec.describe Counter::Cache::OptionsParser do
subject(:parser) { Counter::Cache::OptionsParser.new options }
let(:options) { {} }
describe "#cached?" do
describe "if cache is nil" do
it "it should be true" do
expect(parser.cached?).to eq(true)
end
end
de... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/lib/counter/cache/active_record_updater_spec.rb | spec/lib/counter/cache/active_record_updater_spec.rb | require 'spec_helper'
RSpec.describe Counter::Cache::ActiveRecordUpdater do
let(:counter_class) { double }
let(:counter) { double }
let(:options) { { counter_class: counter_class } }
subject { Counter::Cache::ActiveRecordUpdater.new(options) }
let(:record) { double }
describe "#after_create" do
it "C... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/lib/counter/cache/config_spec.rb | spec/lib/counter/cache/config_spec.rb | require 'spec_helper'
RSpec.describe Counter::Cache do
describe ".configure" do
let(:clazz) { Class.new }
it "sets counter class" do
Counter::Cache.configure do |config|
config.default_worker_adapter = clazz
end
expect(Counter::Cache.configuration.default_worker_adapter).to eq(claz... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/lib/counter/cache/buffer_counter/key_spec.rb | spec/lib/counter/cache/buffer_counter/key_spec.rb | require 'spec_helper'
RSpec.describe Counter::Cache::Counters::BufferCounter::Key do
let(:options) { double(relation_class_name: "Boo", relation: "boo", column: "boos_count", relation_id: nil) }
let(:source_object) { double(boo_id: 1) }
let(:key) { Counter::Cache::Counters::BufferCounter::Key.new(source_object, ... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/lib/counter/cache/buffer_counter/enqueuer_spec.rb | spec/lib/counter/cache/buffer_counter/enqueuer_spec.rb | require 'spec_helper'
RSpec.describe Counter::Cache::Counters::BufferCounter::Enqueuer do
let(:worker_adapter) { double }
let(:source_object_class_name) { "BooUser" }
let(:relation_id) { 1 }
let(:relation_type) { "Boo" }
describe '#enqueue' do
context "without touch column" do
before do
@... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/lib/counter/cache/buffer_counter/relation_finder_spec.rb | spec/lib/counter/cache/buffer_counter/relation_finder_spec.rb | require 'spec_helper'
RSpec.describe Counter::Cache::Counters::BufferCounter::RelationFinder do
let(:options) { double }
let(:source_object) { double }
let(:finder) { Counter::Cache::Counters::BufferCounter::RelationFinder.new(source_object, options) }
describe '#relation_class' do
context 'when relation_... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/lib/counter/cache/buffer_counter/updater_spec.rb | spec/lib/counter/cache/buffer_counter/updater_spec.rb | require 'spec_helper'
RSpec.describe Counter::Cache::Counters::BufferCounter::Updater do
let(:options) { double(relation: "boo", relation_class_name: "Boo", column: "boo", relation_id: nil, increment_by: 1) }
let(:source_object) { double(boo_id: 1) }
let(:updater) { Counter::Cache::Counters::BufferCounter::Updat... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/spec/lib/counter/cache/buffer_counter/saver_spec.rb | spec/lib/counter/cache/buffer_counter/saver_spec.rb | require 'spec_helper'
RSpec.describe Counter::Cache::Counters::BufferCounter::Saver do
class Boo
end
let(:relation_object) { double(boo_count: 2, boo_updated_at: DateTime.now) }
let(:options) { double(relation_class_name: "Boo", relation_id: 1, column: "boo_count", method: nil, source_object_class_name: Boo) ... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/lib/counter/cache.rb | lib/counter/cache.rb | require "counter/cache/version"
require "counter/cache/active_record_updater"
require "counter/cache/options_parser"
require "counter/cache/config"
require "counter/cache/counters/buffer_counter"
require "counter/cache/redis"
module Counter
module Cache
def self.configure
yield configuration
end
... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/lib/counter/cache/version.rb | lib/counter/cache/version.rb | module Counter
module Cache
VERSION = "0.3.0"
end
end
| ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/lib/counter/cache/redis.rb | lib/counter/cache/redis.rb | module Counter
module Cache
class Redis
def incr(key, val = 1)
with_redis do |redis|
redis.incrby key, val
end
end
def decr(key, val = 1)
with_redis do |redis|
redis.decrby(key, val)
end
end
def get(key)
with_redis do |red... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/lib/counter/cache/active_record_updater.rb | lib/counter/cache/active_record_updater.rb | module Counter
module Cache
class ActiveRecordUpdater < Struct.new(:options)
def after_create(record)
counter_for(record).update(:incr)
end
def after_destroy(record)
counter_for(record).update(:decr)
end
private
def counter_for(object)
counter_class.n... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/lib/counter/cache/config.rb | lib/counter/cache/config.rb | module Counter
module Cache
class Config
# TODO:: Confer with paul/kig about adapting the counting data store
attr_accessor :default_worker_adapter, :recalculation_delay, :redis_pool, :counting_data_store
def initialize
self.counting_data_store = Counter::Cache::Redis.new
end
... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/lib/counter/cache/options_parser.rb | lib/counter/cache/options_parser.rb | module Counter
module Cache
class OptionsParser < Struct.new(:options)
def worker_adapter
options[:worker_adapter] || Counter::Cache.configuration.default_worker_adapter
end
def source_object_class_name
options[:source_object_class_name]
end
def column
optio... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/lib/counter/cache/counters/buffer_counter.rb | lib/counter/cache/counters/buffer_counter.rb | require 'counter/cache/counters/buffer_counter/updater'
require 'counter/cache/counters/buffer_counter/saver'
module Counter
module Cache
module Counters
class BufferCounter
attr_accessor :source_object, :options
def initialize(source_object, options)
@options = Counter::Cache::O... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/lib/counter/cache/counters/buffer_counter/updater.rb | lib/counter/cache/counters/buffer_counter/updater.rb | require 'counter/cache/counters/buffer_counter/relation_finder'
require 'counter/cache/counters/buffer_counter/enqueuer'
require 'counter/cache/counters/buffer_counter/key'
module Counter
module Cache
module Counters
class BufferCounter
class Updater < Struct.new(:source_object, :options, :counter_... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/lib/counter/cache/counters/buffer_counter/key.rb | lib/counter/cache/counters/buffer_counter/key.rb | module Counter
module Cache
module Counters
class BufferCounter
class Key < Struct.new(:source_object, :options)
def to_s
"cc:#{relation_finder.relation_class.to_s[0..1]}:#{relation_finder.relation_id}:#{column}"
end
protected
def column
... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/lib/counter/cache/counters/buffer_counter/saver.rb | lib/counter/cache/counters/buffer_counter/saver.rb | module Counter
module Cache
module Counters
class BufferCounter
class Saver < Struct.new(:options)
def save!
return unless relation_object
old_value = current_column_value
new_value = calculate_new_value
save_new_value!(new_value)
... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/lib/counter/cache/counters/buffer_counter/enqueuer.rb | lib/counter/cache/counters/buffer_counter/enqueuer.rb | module Counter
module Cache
module Counters
class BufferCounter
class Enqueuer < Struct.new(:options, :source_object_class_name, :relation_id, :relation_class, :counter_class_name)
def enqueue!(source_object)
create_and_enqueue(options.wait(source_object), options.cached?)
... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
wanelo/counter-cache | https://github.com/wanelo/counter-cache/blob/d9d91a278fe615e1094022458f90bbb66e757a8a/lib/counter/cache/counters/buffer_counter/relation_finder.rb | lib/counter/cache/counters/buffer_counter/relation_finder.rb | module Counter
module Cache
module Counters
class BufferCounter
class RelationFinder < Struct.new(:source_object, :options)
def relation_class
return options.relation_class_name if options.relation_class_name
return polymorphic_type if options.polymorphic?
... | ruby | MIT | d9d91a278fe615e1094022458f90bbb66e757a8a | 2026-01-04T17:37:55.089939Z | false |
LendingHome/pipe_operator | https://github.com/LendingHome/pipe_operator/blob/3ce04188ed97c61eb70e8003990f1bfe8c33af4a/spec/pipe_operator_spec.rb | spec/pipe_operator_spec.rb | RSpec.describe PipeOperator do
describe ".gem" do
it "returns a Gem::Specification" do
gem = PipeOperator.gem
expect(gem).to be_a(::Gem::Specification)
expect(gem.name).to eq("pipe_operator")
expect(gem.version).to be_a(::Gem::Version)
end
end
describe ".root" do
it "returns a... | ruby | MIT | 3ce04188ed97c61eb70e8003990f1bfe8c33af4a | 2026-01-04T17:37:54.728860Z | false |
LendingHome/pipe_operator | https://github.com/LendingHome/pipe_operator/blob/3ce04188ed97c61eb70e8003990f1bfe8c33af4a/spec/spec_helper.rb | spec/spec_helper.rb | require "simplecov"
SimpleCov.start { add_filter("/vendor/bundle/") }
require "base64"
require "json"
require "pry"
require "pry-byebug"
ENV["PIPE_OPERATOR_FROZEN"] ||= "1"
require_relative "../lib/pipe_operator"
RSpec.configure do |config|
config.filter_run :focus
config.raise_errors_for_deprecations!
config.... | ruby | MIT | 3ce04188ed97c61eb70e8003990f1bfe8c33af4a | 2026-01-04T17:37:54.728860Z | false |
LendingHome/pipe_operator | https://github.com/LendingHome/pipe_operator/blob/3ce04188ed97c61eb70e8003990f1bfe8c33af4a/lib/pipe_operator.rb | lib/pipe_operator.rb | require "fiddle"
require "forwardable"
require "pathname"
require "set"
require_relative "pipe_operator/closure"
require_relative "pipe_operator/observer"
require_relative "pipe_operator/pipe"
require_relative "pipe_operator/proxy"
require_relative "pipe_operator/proxy_resolver"
module PipeOperator
def __pipe__(*ar... | ruby | MIT | 3ce04188ed97c61eb70e8003990f1bfe8c33af4a | 2026-01-04T17:37:54.728860Z | false |
LendingHome/pipe_operator | https://github.com/LendingHome/pipe_operator/blob/3ce04188ed97c61eb70e8003990f1bfe8c33af4a/lib/pipe_operator/proxy_resolver.rb | lib/pipe_operator/proxy_resolver.rb | module PipeOperator
class ProxyResolver
AUTOLOAD = ENV["PIPE_OPERATOR_AUTOLOAD"] == "1"
FROZEN = ENV["PIPE_OPERATOR_FROZEN"] == "1"
REBIND = ENV["PIPE_OPERATOR_REBIND"] == "1"
def initialize(object, resolved = ::Set.new)
@object = object
@resolved = resolved
@singleton = ::PipeOpera... | ruby | MIT | 3ce04188ed97c61eb70e8003990f1bfe8c33af4a | 2026-01-04T17:37:54.728860Z | false |
LendingHome/pipe_operator | https://github.com/LendingHome/pipe_operator/blob/3ce04188ed97c61eb70e8003990f1bfe8c33af4a/lib/pipe_operator/proxy.rb | lib/pipe_operator/proxy.rb | module PipeOperator
class Proxy < ::Module
def initialize(object, singleton)
@object = object if singleton.singleton_class?
@singleton = singleton
super()
end
def define(method)
if ::Proc == @object && method == :new
return method
elsif ::Symbol == @singleton && meth... | ruby | MIT | 3ce04188ed97c61eb70e8003990f1bfe8c33af4a | 2026-01-04T17:37:54.728860Z | false |
LendingHome/pipe_operator | https://github.com/LendingHome/pipe_operator/blob/3ce04188ed97c61eb70e8003990f1bfe8c33af4a/lib/pipe_operator/observer.rb | lib/pipe_operator/observer.rb | module PipeOperator
module Observer
def singleton_method_added(method)
ProxyResolver.new(self).proxy.define(method)
super
end
def singleton_method_removed(method)
ProxyResolver.new(self).proxy.undefine(method)
super
end
end
end
| ruby | MIT | 3ce04188ed97c61eb70e8003990f1bfe8c33af4a | 2026-01-04T17:37:54.728860Z | false |
LendingHome/pipe_operator | https://github.com/LendingHome/pipe_operator/blob/3ce04188ed97c61eb70e8003990f1bfe8c33af4a/lib/pipe_operator/closure.rb | lib/pipe_operator/closure.rb | module PipeOperator
class Closure < ::Proc
RESERVED = %i[
==
[]
__send__
call
class
kind_of?
].freeze
(::Proc.instance_methods - RESERVED).each(&method(:private))
def self.curry(curry, search, args)
index = curry.index(search)
prefix = index ? curry[0.... | ruby | MIT | 3ce04188ed97c61eb70e8003990f1bfe8c33af4a | 2026-01-04T17:37:54.728860Z | false |
LendingHome/pipe_operator | https://github.com/LendingHome/pipe_operator/blob/3ce04188ed97c61eb70e8003990f1bfe8c33af4a/lib/pipe_operator/pipe.rb | lib/pipe_operator/pipe.rb | module PipeOperator
class Pipe < ::BasicObject
undef :equal?
undef :instance_eval
undef :singleton_method_added
undef :singleton_method_removed
undef :singleton_method_undefined
def self.new(object, *args)
if block_given?
super.__call__
elsif args.none? || Closure === args... | ruby | MIT | 3ce04188ed97c61eb70e8003990f1bfe8c33af4a | 2026-01-04T17:37:54.728860Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/demo.rb | demo.rb | name "Demo"
button "Open/Close", pin: 4
sensor "Door", pin: 17, high: "Open", low: "Closed"
switch "Light", pin: 18
sensor "Ruby Version" do
RUBY_VERSION
end
| ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/spec/acceptance_spec.rb | spec/acceptance_spec.rb | require 'spec_helper'
require 'faraday'
require 'timeout'
describe 'Whipped Cream', :acceptance do
let(:http) { Faraday.new(url: url) }
let(:request_method) { :get }
let(:response) { http.send(request_method, path) }
let(:remote_url) { ENV['REMOTE_URL'] }
let(:url) { remote_url || 'http://127.0.0.1:35511' }... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/spec/spec_helper.rb | spec/spec_helper.rb | ENV['RUBY_ENV'] ||= 'test'
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
puts RUBY_DESCRIPTION
if ENV['coverage']
require 'simplecov'
SimpleCov.start do
add_filter '/spec/'
end
end
require 'whipped-cream'
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :expect
... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/spec/lib/whipped-cream_spec.rb | spec/lib/whipped-cream_spec.rb | require 'spec_helper'
describe WhippedCream do
it "should have a version number" do
expect(WhippedCream::VERSION).to_not be_empty
end
end
| ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/spec/lib/whipped-cream/deployer_spec.rb | spec/lib/whipped-cream/deployer_spec.rb | require 'spec_helper'
describe WhippedCream::Deployer do
subject { deployer }
let(:deployer) { described_class.new(plugin_filename, pi_address) }
let(:plugin_filename) { 'demo.rb' }
let(:pi_address) { '192.168.0.123' }
let(:net_ssh_double) {
double(Net::SSH, exec!: nil, open_channel: double(wait: nil))... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/spec/lib/whipped-cream/button_spec.rb | spec/lib/whipped-cream/button_spec.rb | require 'spec_helper'
describe WhippedCream::Button do
context 'valid button' do
subject(:button) { described_class.new(name, pin: valid_pin, block: block) }
let(:name) { "Open/Close" }
let(:valid_pin) { 4 }
let(:block) { nil }
describe '#name' do
subject { super().name }
it { is_ex... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/spec/lib/whipped-cream/switch_spec.rb | spec/lib/whipped-cream/switch_spec.rb | require 'spec_helper'
describe WhippedCream::Switch do
context 'valid switch' do
subject(:switch) { described_class.new(name, pin: valid_pin) }
let(:name) { "Light" }
let(:valid_pin) { 18 }
describe '#name' do
subject { super().name }
it { is_expected.to eq(name) }
end
describe... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/spec/lib/whipped-cream/cli_spec.rb | spec/lib/whipped-cream/cli_spec.rb | require 'spec_helper'
require 'fileutils'
require 'tmpdir'
describe WhippedCream::CLI do
subject { cli }
let(:cli) { described_class.new }
let(:plugin_filename) { File.join(tmpdir, "garage") }
let(:plugin_string) {
<<-PLUGIN
name "Garage"
button "Open/Close", pin: 4
PLUGIN
}
let(... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/spec/lib/whipped-cream/builder_spec.rb | spec/lib/whipped-cream/builder_spec.rb | require 'spec_helper'
describe WhippedCream::Builder do
subject { plugin }
let(:plugin) {
described_class.build do
name "Garage"
end
}
let(:plugin_file_path) { "foo/bar/baz" }
let(:plugin_string) {
<<-PLUGIN
name "Garage"
button "Open/Close", pin: 4
PLUGIN
}
it "r... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/spec/lib/whipped-cream/sensor_spec.rb | spec/lib/whipped-cream/sensor_spec.rb | require 'spec_helper'
describe WhippedCream::Sensor do
context 'valid sensor' do
subject(:sensor) { described_class.new(name, valid_options, &block) }
let(:name) { "Door" }
let(:valid_options) {
{
pin: 17,
high: "Open",
low: "Closed",
on_high: :door_opened
}
... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/spec/lib/whipped-cream/plugin_spec.rb | spec/lib/whipped-cream/plugin_spec.rb | require 'spec_helper'
describe WhippedCream::Plugin do
subject(:plugin) { described_class.new }
describe '#camera' do
subject { super().camera }
it { is_expected.to be_nil }
end
describe '#name' do
subject { super().name }
it { is_expected.to be_nil }
end
describe '#controls' do
subj... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/spec/lib/whipped-cream/server_spec.rb | spec/lib/whipped-cream/server_spec.rb | require 'spec_helper'
describe WhippedCream::Server do
subject(:server) { described_class.new(plugin, options) }
let(:plugin) {
WhippedCream::Plugin.build do
button "Open/Close", pin: 4
end
}
let(:options) { Hash.new }
before do
allow(Rack::Server).to receive :start
end
it "creates ... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/spec/lib/whipped-cream/runner_spec.rb | spec/lib/whipped-cream/runner_spec.rb | require 'spec_helper'
describe WhippedCream::Runner do
subject(:runner) { described_class.new(plugin) }
let(:plugin) {
WhippedCream::Plugin.build do
name "Garage"
end
}
describe '#name' do
subject { super().name }
it { is_expected.to eq("Garage") }
end
describe '.instance' do
s... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream.rb | lib/whipped-cream.rb | require 'whipped-cream/builder'
require 'whipped-cream/button'
require 'whipped-cream/cli'
require 'whipped-cream/deployer'
require 'whipped-cream/plugin'
require 'whipped-cream/runner'
require 'whipped-cream/sensor'
require 'whipped-cream/server'
require 'whipped-cream/switch'
require 'whipped-cream/version'
require '... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/version.rb | lib/whipped-cream/version.rb | module WhippedCream
VERSION = "0.2.0.beta1"
end
| ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/button.rb | lib/whipped-cream/button.rb | require 'whipped-cream/control'
module WhippedCream
# A Button represents a one-time action, such as momentarily turning on a
# pin, or sending a message to an object
class Button < Control
attr_reader :name, :pin, :duration, :block
def initialize(name, options = {})
raise "Invalid pin. The pin m... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/plugin.rb | lib/whipped-cream/plugin.rb | module WhippedCream
# Data representation of a Plugin
class Plugin
attr_accessor :camera, :name
def self.build(&block)
Builder.build(&block)
end
def self.from_file(path)
Builder.from_file(path)
end
def self.from_string(string)
Builder.from_string(string)
end
def... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/runner.rb | lib/whipped-cream/runner.rb | begin
require 'pi_piper'
rescue LoadError
require 'whipped-cream/pi_piper'
end
module WhippedCream
# Actor that manages all interaction with a plugin
class Runner
def self.instance
@instance
end
def self.create_instance(plugin)
@instance = new(plugin)
end
attr_reader :plugin
... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/cli.rb | lib/whipped-cream/cli.rb | require 'thor'
require 'dnssd'
module WhippedCream
# The CLI gets invoked from the binary, and encapsulates all user interaction
# logic
class CLI < Thor
default_task :usage
desc "usage", "Display usage banner", hide: true
def usage
puts [
"Whipped Cream #{WhippedCream::VERSION}",
... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/sensor.rb | lib/whipped-cream/sensor.rb | require 'whipped-cream/control'
module WhippedCream
# A Sensor displays the state of something, such as a pin's value, or the
# return value of the method. Sensors can also have callbacks associated with
# state changes.
class Sensor < Control
attr_reader :name, :pin, :low, :high, :on_low, :on_high, :block... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/control.rb | lib/whipped-cream/control.rb | module WhippedCream
# An abstract class for controls to inherit from
class Control
VALID_GPIO_PINS = [4, 17, 18, 22, 23, 24, 25, 27]
def id
name.downcase.gsub(/[^\w]+/, '_').gsub(/^_|_$/, '').to_sym
end
def type
self.class.to_s.split('::').last.downcase.to_sym
end
end
end
| ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/server.rb | lib/whipped-cream/server.rb | require 'rack'
require 'dnssd'
module WhippedCream
# A server handles building a plugin/runner and starting a web server
class Server
attr_reader :plugin, :options
def initialize(plugin, options = {})
@plugin = plugin
@options = options
end
def start
ensure_routes_built
en... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/deployer.rb | lib/whipped-cream/deployer.rb | require 'net/scp'
require 'net/ssh'
module WhippedCream
# Prepares a Pi for deployment, and deploys a plugin
class Deployer
attr_reader :plugin_filename, :pi_address
def initialize(plugin_filename, pi_address)
@plugin_filename = plugin_filename
@pi_address = pi_address
end
def deploy
... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/web.rb | lib/whipped-cream/web.rb | require 'sinatra'
module WhippedCream
# A Sinatra application skeleton that is used to build up the web server
# for this plugin.
class Web < Sinatra::Application
get '/' do
find_remote_servers
erb :index
end
private
def controls
runner.plugin.controls
end
def runner
... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/builder.rb | lib/whipped-cream/builder.rb | module WhippedCream
# Creates Plugin instances from a DSL
class Builder
def self.build(&block)
builder = new(&block)
builder.build
builder.plugin
end
def self.from_file(path)
contents = File.read(path)
from_string(contents)
end
def self.from_string(string)
... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/switch.rb | lib/whipped-cream/switch.rb | module WhippedCream
# A switch toggles a pin between on and off states
class Switch < Control
attr_reader :name, :pin
def initialize(name, options = {})
raise "Invalid pin. The pin must be one of "\
"the Raspberry Pi's valid GPIO pins: "\
"#{VALID_GPIO_PINS}" unless VALID_GPI... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/pi_piper.rb | lib/whipped-cream/pi_piper.rb | # Fake PiPiper
module PiPiper
# Just enough to imitate a pin
class Pin
attr_reader :pin, :direction
def initialize(options)
@pin = options[:pin]
@direction = options[:direction]
end
def read
@value ||= 0
end
def on
@value = 1
log "Pin #{pin} on"
end
... | ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
justincampbell/whipped-cream | https://github.com/justincampbell/whipped-cream/blob/8db401517a7bf6f7d85020686941dfe0bd554ff6/lib/whipped-cream/public/assets/config.rb | lib/whipped-cream/public/assets/config.rb | http_path = "/"
css_dir = "stylesheets"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"
preferred_syntax = :sass
| ruby | MIT | 8db401517a7bf6f7d85020686941dfe0bd554ff6 | 2026-01-04T17:37:55.113004Z | false |
jmmastey/bundler-stats | https://github.com/jmmastey/bundler-stats/blob/3e45b08db3ee779b125bb562eb366bb84ceab71e/spec/spec_helper.rb | spec/spec_helper.rb | require 'bundler'
require 'bundler/stats'
RSpec.configure do |config|
config.filter_run :focus
config.run_all_when_everything_filtered = true
config.expect_with :rspec do |expectations|
expectations.syntax = :expect
end
end
| ruby | MIT | 3e45b08db3ee779b125bb562eb366bb84ceab71e | 2026-01-04T17:38:05.426838Z | false |
jmmastey/bundler-stats | https://github.com/jmmastey/bundler-stats/blob/3e45b08db3ee779b125bb562eb366bb84ceab71e/spec/lib/bundler/stats/file_path_resolver_spec.rb | spec/lib/bundler/stats/file_path_resolver_spec.rb | require 'spec_helper'
describe Bundler::Stats::FilePathResolver do
let(:file_path_resolver) { described_class.new(specific_gemfile_path) }
context "with undefined specific gemfile path" do
let(:specific_gemfile_path) { nil }
before do
allow(File).to receive(:exist?).and_return(false)
end
c... | ruby | MIT | 3e45b08db3ee779b125bb562eb366bb84ceab71e | 2026-01-04T17:38:05.426838Z | false |
jmmastey/bundler-stats | https://github.com/jmmastey/bundler-stats/blob/3e45b08db3ee779b125bb562eb366bb84ceab71e/spec/lib/bundler/stats/calculator_spec.rb | spec/lib/bundler/stats/calculator_spec.rb | require 'spec_helper'
describe Bundler::Stats::Calculator do
subject { described_class }
let(:gemfile_path) { File.join(File.dirname(__FILE__), "../../../test_gemfile") }
let(:lockfile_path) { File.join(File.dirname(__FILE__), "../../../test_gemfile.lock") }
let(:calculator) { subject.new(lockfile_path) }
c... | ruby | MIT | 3e45b08db3ee779b125bb562eb366bb84ceab71e | 2026-01-04T17:38:05.426838Z | false |
jmmastey/bundler-stats | https://github.com/jmmastey/bundler-stats/blob/3e45b08db3ee779b125bb562eb366bb84ceab71e/spec/lib/bundler/stats/printer_spec.rb | spec/lib/bundler/stats/printer_spec.rb | require 'spec_helper'
describe Bundler::Stats::Printer do
subject { described_class }
def set_term_width(width)
allow(Kernel).to receive(:"`").and_return(width)
end
describe "#terminal_width" do
context "*nix systems" do
it "return the kernel width" do
set_term_width(180)
print... | ruby | MIT | 3e45b08db3ee779b125bb562eb366bb84ceab71e | 2026-01-04T17:38:05.426838Z | false |
jmmastey/bundler-stats | https://github.com/jmmastey/bundler-stats/blob/3e45b08db3ee779b125bb562eb366bb84ceab71e/spec/lib/bundler/stats/remover_spec.rb | spec/lib/bundler/stats/remover_spec.rb | require 'spec_helper'
LazyLazySpec = Struct.new(:name, :dependencies)
FakeLockfileParser = Struct.new(:specs)
describe Bundler::Stats::Remover do
subject { described_class }
def dep(name)
Gem::Dependency.new(name)
end
let(:full_tree) do
{ "rails" => LazyLazySpec.new("rails", [ dep("actionpack"... | ruby | MIT | 3e45b08db3ee779b125bb562eb366bb84ceab71e | 2026-01-04T17:38:05.426838Z | false |
jmmastey/bundler-stats | https://github.com/jmmastey/bundler-stats/blob/3e45b08db3ee779b125bb562eb366bb84ceab71e/spec/lib/bundler/stats/tree_spec.rb | spec/lib/bundler/stats/tree_spec.rb | require 'spec_helper'
describe Bundler::Stats::Tree do
subject { described_class }
let(:lock_path) { File.join(File.dirname(__FILE__), "../../../test_gemfile.lock") }
let(:parser) { Bundler::LockfileParser.new(File.read(lock_path)) }
let(:tree) { subject.new(lock_path) }
context "#new" do
it "initialize... | ruby | MIT | 3e45b08db3ee779b125bb562eb366bb84ceab71e | 2026-01-04T17:38:05.426838Z | false |
jmmastey/bundler-stats | https://github.com/jmmastey/bundler-stats/blob/3e45b08db3ee779b125bb562eb366bb84ceab71e/lib/bundler/stats.rb | lib/bundler/stats.rb | require_relative 'stats/calculator'
require_relative 'stats/file_path_resolver'
require_relative 'stats/printer'
require_relative 'stats/remover'
require_relative 'stats/skiplist'
require_relative 'stats/tree'
require_relative 'stats/version'
| ruby | MIT | 3e45b08db3ee779b125bb562eb366bb84ceab71e | 2026-01-04T17:38:05.426838Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.