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 | deepcerulean/passive_record | https://github.com/deepcerulean/passive_record | lib/passive_record/core/query.rb | Ruby | mit | 198 | master | 4,980 | module PassiveRecord
module Core
class Query
include Enumerable
extend Forwardable
include PassiveRecord::ArithmeticHelpers
attr_reader :conditions
def initialize(klass,conditions={},scope=nil)
@klass = klass
@conditions = conditions
@scope = scope
end... |
github | deepcerulean/passive_record | https://github.com/deepcerulean/passive_record | lib/passive_record/associations/has_many.rb | Ruby | mit | 198 | master | 1,176 | module PassiveRecord
module Associations
class HasManyAssociation < Struct.new(:parent_class, :child_class_name, :children_name_sym)
def to_relation(parent_model)
HasManyRelation.new(self, parent_model)
end
def target_name_symbol
children_name_sym
end
def habtm
... |
github | deepcerulean/passive_record | https://github.com/deepcerulean/passive_record | lib/passive_record/associations/has_one.rb | Ruby | mit | 198 | master | 1,343 | module PassiveRecord
module Associations
class HasOneAssociation < Struct.new(:parent_class, :child_class_name, :child_name_sym)
def to_relation(parent_model)
HasOneRelation.new(self, parent_model)
end
def target_name_symbol
child_name_sym
end
def children_name_sym;... |
github | deepcerulean/passive_record | https://github.com/deepcerulean/passive_record | lib/passive_record/associations/has_many_through.rb | Ruby | mit | 198 | master | 3,337 | module PassiveRecord
module Associations
class HasManyThroughAssociation < Struct.new(:parent_class, :child_class_name, :target_name_symbol, :through_class, :base_association, :habtm)
def to_relation(parent_model)
HasManyThroughRelation.new(self, parent_model)
end
end
class HasManyThr... |
github | deepcerulean/passive_record | https://github.com/deepcerulean/passive_record | lib/passive_record/associations/belongs_to.rb | Ruby | mit | 198 | master | 913 | module PassiveRecord
module Associations
class BelongsToAssociation < Struct.new(:child_class, :parent_class_name, :target_name_symbol)
def to_relation(child_model)
BelongsToRelation.new(self, child_model)
end
def parent_class
@parent_class ||= (
module_name = child_cl... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | Gemfile | Ruby | mit | 198 | master | 356 | source 'https://rubygems.org'
gemspec
gem 'rake'
group :development do
gem 'kicker'
gem 'colored' # for examples
end
group :spec do
gem 'bacon'
gem 'json', '< 3'
gem 'mocha-on-bacon'
gem 'prettybacon'
gem 'parallel', '<= 1.19.2'
gem 'rubocop', '<= 0.81.0'
gem 'rubocop-performance', '<= 1.5.2', :r... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | Rakefile | Ruby | mit | 198 | master | 1,365 | # encoding: utf-8
#-- Bootstrap --------------------------------------------------------------#
desc 'Initializes your working copy to run the specs'
task :bootstrap do
if system('which bundle')
title 'Installing gems'
sh 'bundle install'
else
$stderr.puts "\033[0;31m" \
"[!] Please install the ... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | claide.gemspec | Ruby | mit | 198 | master | 882 | # -*- encoding: utf-8 -*-
$:.unshift File.expand_path('../lib', __FILE__)
require File.expand_path('../lib/claide/gem_version', __FILE__)
Gem::Specification.new do |s|
s.name = "claide"
s.version = CLAide::VERSION
s.license = "MIT"
s.email = ["eloy.de.enige@gmail.com", "fabiopelosin@gmail.com"]
s.ho... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | examples/make.rb | Ruby | mit | 198 | master | 3,361 | # encoding: utf-8
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
require 'claide'
# Loading this third-party gem will automatically cause CLAide to color some of
# its output.
require 'colored'
class BeverageMaker < CLAide::Command
self.abstract_command = true
self.description = 'Make delicious be... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | examples/argv.rb | Ruby | mit | 198 | master | 679 | # encoding: utf-8
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
require 'claide'
argv = CLAide::ARGV.new(['tea', '--no-milk', '--sweetener=honey'])
p argv.shift_argument # => 'tea'
p argv.shift_argument # => nil
p argv.flag?('milk') # => false
p argv.flag?('milk') # => nil
p argv.... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/argv_spec.rb | Ruby | mit | 198 | master | 4,750 | # encoding: utf-8
require File.expand_path('../spec_helper', __FILE__)
module CLAide
describe ARGV do
describe 'in general' do
before do
parameters = %w(--flag --option=VALUE ARG1 ARG2 --no-other-flag)
@argv = ARGV.new(parameters)
end
it 'converts objects into strings while pa... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/argument_spec.rb | Ruby | mit | 198 | master | 612 | # encoding: utf-8
require File.expand_path('../spec_helper', __FILE__)
module CLAide
describe Argument do
before do
@subject = Argument
end
it 'converts a single name into a 1-item array' do
@subject.new('STRING', true).names.should == ['STRING']
end
it 'accepts an array of names' ... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/command_spec.rb | Ruby | mit | 198 | master | 15,121 | # encoding: utf-8
require File.expand_path('../spec_helper', __FILE__)
module CLAide
describe Command do
before do
@command = Fixture::Command
end
describe 'in general' do
it 'registers the subcommand classes' do
@command.subcommands.map(&:command).should ==
%w(spec-file)
... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/ansi_spec.rb | Ruby | mit | 198 | master | 1,033 | # encoding: utf-8
require File.expand_path('../spec_helper', __FILE__)
module CLAide
describe ANSI do
before do
@subject = ANSI
end
describe '::code_for_key' do
it 'returns the code for a given key' do
@subject.code_for_key(:red, ANSI::COLORS).should == 1
end
it 'raises... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/spec_helper.rb | Ruby | mit | 198 | master | 1,388 | # encoding: utf-8
require 'simplecov'
SimpleCov.start
#-----------------------------------------------------------------------------#
require 'pathname'
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
$LOAD_PATH.unshift((ROOT + 'lib').to_s)
$LOAD_PATH.unshift((ROOT + 'spec').to_s)
require 'bundler/setup'
... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/help_spec.rb | Ruby | mit | 198 | master | 789 | # encoding: utf-8
require File.expand_path('../spec_helper', __FILE__)
module CLAide
describe Help do
#-------------------------------------------------------------------------#
describe 'in general' do
it 'shows just the banner if no error message is specified' do
banner = 'A descriptive ban... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/spec_helper/string_ext.rb | Ruby | mit | 198 | master | 620 | class String
# @return [String] The method strips the characters preceding a special
# margin character. Useful for HEREDOCs and other multi-line strings.
#
# @example
#
# code = <<-END.strip_margin('|')
# |def test
# | some_method
# | other_method
# |end
# END
#
# #=> ... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/spec_helper/rubygems.rb | Ruby | mit | 198 | master | 516 | module SpecHelper
module RubyGems
module_function
def fixture_spec_with_file(file)
Gem::Specification.new do |s|
s.name = 'fixture-demo-plugin'
s.version = '1.0.0'
s.files = [file.to_s]
s.require_paths = ['']
def s.full_gem_path
File.expand_path('..', f... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/spec_helper/fixtures.rb | Ruby | mit | 198 | master | 1,542 | # encoding: utf-8
module Fixture
class Error < StandardError
include CLAide::InformativeError
end
class Command < CLAide::Command
self.command = 'bin'
self.ansi_output = false
class << self
attr_accessor :latest_instance
end
def initialize(*args)
self.class.latest_instance ... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/command/argument_suggester_spec.rb | Ruby | mit | 198 | master | 1,799 | # encoding: utf-8
require File.expand_path('../../spec_helper', __FILE__)
class CLAide::Command
describe ArgumentSuggester do
describe '::levenshtein_distance' do
it 'returns the distance among two strings' do
suggester = ArgumentSuggester
suggester.levenshtein_distance('word 1', 'word 2')... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/command/plugin_manager_spec.rb | Ruby | mit | 198 | master | 2,784 | # encoding: utf-8
require File.expand_path('../../spec_helper', __FILE__)
module CLAide
describe Command::PluginManager do
before do
extend SpecHelper::RubyGems
@manager = Command::PluginManager
@manager.instance_variable_set(:@loaded_plugins, nil)
@manager.stubs(:require)
@path = ... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/command/banner_spec.rb | Ruby | mit | 198 | master | 11,698 | # encoding: utf-8
require File.expand_path('../../spec_helper', __FILE__)
class CLAide::Command
describe Banner do
describe 'in general' do
it 'combines the summary/description, commands, and options' do
banner = Banner.new(Fixture::Command::SpecFile::Create)
banner.formatted_banner.should... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/ansi/graphics_spec.rb | Ruby | mit | 198 | master | 1,137 | # encoding: utf-8
require File.expand_path('../../spec_helper', __FILE__)
module CLAide
describe ANSI::Graphics do
before do
@subject = ANSI::Graphics
end
it 'returns the escape sequence for a text attribute' do
@subject.text_attribute(:underline).should == "\e[4m"
end
it 'returns ... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/ansi/string_escaper_spec.rb | Ruby | mit | 198 | master | 2,194 | # encoding: utf-8
require File.expand_path('../../spec_helper', __FILE__)
module CLAide
describe ANSI::StringEscaper do
before do
ANSI.disabled = false
@subject = 'test string'
end
it "doesn't edit in place the original string" do
@subject.ansi.yellow.should == "\e[33mtest string\e[39... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/ansi/cursor_spec.rb | Ruby | mit | 198 | master | 1,444 | require File.expand_path('../../spec_helper', __FILE__)
module CLAide
describe ANSI::Cursor do
before do
@subject = ANSI::Cursor
end
it 'returns the escape sequence to set the cursor position' do
@subject.set_cursor_position(10, 15).should == "\e[10;15H"
end
it 'returns the escape s... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | spec/fixture/command/demo_plugin.rb | Ruby | mit | 198 | master | 437 | # encoding: utf-8
module Fixture
class CommandPluginable
class DemoPlugin < CommandPluginable
self.summary = 'Plugins!'
self.description = <<-DESC
Let’s add plugins to CLAide and CocoaPods.
DESC
self.arguments = [
CLAide::Argument.new('NAME', false),
]
attr_rea... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | lib/claide.rb | Ruby | mit | 198 | master | 298 | # encoding: utf-8
# The mods of interest are {CLAide::ARGV}, {CLAide::Command}, and
# {CLAide::InformativeError}
#
module CLAide
require 'claide/ansi'
require 'claide/argument'
require 'claide/argv'
require 'claide/command'
require 'claide/help'
require 'claide/informative_error'
end |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | lib/claide/argv.rb | Ruby | mit | 198 | master | 9,998 | # encoding: utf-8
module CLAide
# This class is responsible for parsing the parameters specified by the user,
# accessing individual parameters, and keep state by removing handled
# parameters.
#
class ARGV
# @return [ARGV] Coerces an object to the ARGV class if needed.
#
# @param [Object] argv
... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | lib/claide/command.rb | Ruby | mit | 198 | master | 20,696 | # encoding: utf-8
require 'claide/command/banner'
require 'claide/command/plugin_manager'
require 'claide/command/argument_suggester'
module CLAide
# This class is used to build a command-line interface
#
# Each command is represented by a subclass of this class, which may be
# nested to create more granular ... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | lib/claide/help.rb | Ruby | mit | 198 | master | 1,635 | # encoding: utf-8
module CLAide
require 'claide/informative_error'
# The exception class that is raised to indicate a help banner should be
# shown while running {Command.run}.
#
class Help < StandardError
include InformativeError
# @return [String] The banner containing the usage instructions of t... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | lib/claide/ansi.rb | Ruby | mit | 198 | master | 3,263 | # encoding: utf-8
require 'claide/ansi/cursor'
require 'claide/ansi/graphics'
module CLAide
# Provides support for ANSI Escape sequences
#
# For more information see:
#
# - http://ascii-table.com/ansi-escape-sequences.php
# - http://en.wikipedia.org/wiki/ANSI_escape_code
#
# This functionality has bee... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | lib/claide/informative_error.rb | Ruby | mit | 198 | master | 612 | # encoding: utf-8
module CLAide
# Including this module into an exception class will ensure that when raised,
# while running {Command.run}, only the message of the exception will be
# shown to the user. Unless disabled with the `--verbose` flag.
#
# In addition, the message will be colored red, if {Command.... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | lib/claide/argument.rb | Ruby | mit | 198 | master | 1,898 | # encoding: utf-8
module CLAide
# This class is used to represent individual arguments to present to
# the command help banner
#
class Argument
# The string used for ellipsis / repeatable arguments in the banner
#
ELLIPSIS = '...'
# @return [Array<String>]
# List of alternate names... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | lib/claide/ansi/string_escaper.rb | Ruby | mit | 198 | master | 2,410 | module CLAide
class ANSI
# Provides support to wrap strings in ANSI sequences according to the
# `ANSI.disabled` setting.
#
class StringEscaper < String
# @param [String] string The string to wrap.
#
def initialize(string)
super
end
# @return [StringEscaper] Wra... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | lib/claide/ansi/cursor.rb | Ruby | mit | 198 | master | 2,072 | # encoding: utf-8
module CLAide
class ANSI
# Provides support for generating escape sequences relative to the position
# of the cursor and to erase parts of text.
#
module Cursor
# @return [String] The escape sequence to set the cursor at the
# given line.
#
# @param ... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | lib/claide/ansi/graphics.rb | Ruby | mit | 198 | master | 1,929 | # encoding: utf-8
module CLAide
class ANSI
# Provides support for generating escape sequences relative to the graphic
# mode.
#
module Graphics
# @return [String] The escape sequence for a text attribute.
#
# @param [Symbol] key
# The name of the text attribute.
... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | lib/claide/command/banner.rb | Ruby | mit | 198 | master | 10,276 | # encoding: utf-8
module CLAide
class Command
# Creates the formatted banner to present as help of the provided command
# class.
#
class Banner
# @return [Class] The command for which the banner should be created.
#
attr_accessor :command
# @param [Class] command @see command... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | lib/claide/command/plugin_manager.rb | Ruby | mit | 198 | master | 4,201 | # encoding: utf-8
module CLAide
class Command
# Handles plugin related logic logic for the `Command` class.
#
# Plugins are loaded the first time a command run and are identified by the
# prefix specified in the command class. Plugins must adopt the following
# conventions:
#
# - Support ... |
github | CocoaPods/CLAide | https://github.com/CocoaPods/CLAide | lib/claide/command/argument_suggester.rb | Ruby | mit | 198 | master | 3,229 | # encoding: utf-8
module CLAide
class Command
class ArgumentSuggester
# @param [String] argument
# The unrecognized argument for which to make a suggestion.
#
# @param [Class] command_class
# The class of the command which encountered the unrecognized
# ... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | Rakefile | Ruby | mit | 198 | master | 230 | require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
RuboCop::RakeTask.new do |task|
task.requires << 'rubocop-performance'
end
RSpec::Core::RakeTask.new(:spec)
task default: %w[spec rubocop] |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | screen-recorder.gemspec | Ruby | mit | 198 | master | 1,670 | lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'screen-recorder/version'
Gem::Specification.new do |spec|
spec.name = 'screen-recorder'
spec.version = ScreenRecorder::VERSION
spec.required_ruby_version = '>= 2.0.0'
spec.auth... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | Gemfile | Ruby | mit | 198 | master | 329 | source 'https://rubygems.org'
ruby '~> 3.0'
gemspec
gem 'pry-byebug', '~> 3.10' unless RUBY_PLATFORM == 'java'
gem 'rake', '>= 12.0'
gem 'rspec', '~> 3.0'
gem 'rubocop', '~> 1.64'
gem 'rubocop-performance', '~> 1.0'
gem 'rubocop-rake', '~> 0.6.0'
gem 'rubocop-rspec', '~> 2.0'
gem 'simplecov', '~> 0.22'
gem 'watir', ... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | spec/spec_helper.rb | Ruby | mit | 198 | master | 3,358 | require 'bundler/setup'
require 'simplecov'
require_relative '../lib/screen-recorder/os'
SimpleCov.start do
add_filter %r{/spec/}
end
require 'rspec'
require 'screen-recorder'
require 'watir'
require 'pry-byebug' unless RUBY_PLATFORM == 'java'
RSpec.configure do |config|
# Enable flags like --only-failures and -... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | spec/screen-recorder/window_spec.rb | Ruby | mit | 198 | master | 1,032 | # Only gdigrab supports window capture
RSpec.describe ScreenRecorder::Window, if: ScreenRecorder::OS.windows? do
let(:test_website) { 'https://google.com' }
it 'raises an error when a title is not given' do
# noinspection RubyArgCount
expect { described_class.new(output: test_output) }.to raise_error(Argum... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | spec/screen-recorder/desktop_spec.rb | Ruby | mit | 198 | master | 3,245 | RSpec.describe ScreenRecorder::Desktop do
describe '#new' do
let(:recorder) { described_class.new(output: test_options) }
it 'accepts input: as a parameter' do
expect { described_class.new(input: test_input, output: test_output) }.not_to raise_exception
end
# @todo Figure out how to test this ... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | spec/screen-recorder/common_spec.rb | Ruby | mit | 198 | master | 880 | RSpec.describe ScreenRecorder::Common do
context 'when the gem is loaded' do
after { ScreenRecorder.logger.level = :ERROR }
it 'has a version number' do
expect(ScreenRecorder::VERSION).not_to be_nil
end
it 'can find the FFmpeg binary' do
# noinspection RubyResolve
expect(`#{ScreenR... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | spec/screen-recorder/screenshot_spec.rb | Ruby | mit | 198 | master | 999 | RSpec.describe 'ScreenRecorder::Screenshot' do
describe '.screenshot' do
let(:recorder) { ScreenRecorder::Desktop.new(input: test_input, output: test_output) }
let(:image_file) { "#{Dir.pwd}/screenshot-#{Time.now.to_i}.png" }
context 'when recording a desktop' do
it 'can take a screenshot' do
... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | spec/screen-recorder/titles_spec.rb | Ruby | mit | 198 | master | 2,083 | RSpec.describe ScreenRecorder::Titles do
describe '.fetch' do
context 'when the user is using Linux or MacOS', if: ScreenRecorder::OS.linux? || ScreenRecorder::OS.mac? do
it 'raises error when OS is not Microsoft Windows' do
# @todo Raise StandardError instead.
expect { described_class.fetch... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | spec/screen-recorder/options_spec.rb | Ruby | mit | 198 | master | 2,916 | RSpec.describe ScreenRecorder::Options do
let(:options) { described_class.new(test_options) }
describe 'new' do
it '#accepts a Hash' do
expect { described_class.new(test_options) }.not_to raise_exception # ArgumentError
end
it 'raise ArgumentError if user provides an object other than a Hash' do... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | lib/screen-recorder.rb | Ruby | mit | 198 | master | 2,089 | require 'logger'
require 'streamio-ffmpeg'
# @since 1.0.0.beta11
module ScreenRecorder
#
# Uses user given FFMPEG binary
#
# @example
# ScreenRecorder.ffmpeg_binary = 'C:\ffmpeg.exe'
#
def self.ffmpeg_binary=(bin)
ScreenRecorder.logger.debug 'Setting ffmpeg path...'
FFMPEG.ffmpeg_binary = bin
... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | lib/screen-recorder/desktop.rb | Ruby | mit | 198 | master | 988 | # @since 1.0.0-beta11
module ScreenRecorder
# @since 1.0.0-beta11
class Desktop < Common
include Screenshot
DEFAULT_INPUT_WIN = 'desktop'.freeze
DEFAULT_INPUT_LINUX = ENV.fetch('DISPLAY', ':0').freeze
DEFAULT_INPUT_MAC = ENV.fetch('DISPLAY', '1').freeze
#
# Desktop recording mode.
#
... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | lib/screen-recorder/errors.rb | Ruby | mit | 198 | master | 406 | module ScreenRecorder
# @since 1.0.0-beta5
module Errors
# @since 1.0.0-beta3
class ApplicationNotFound < StandardError
def message
'expected application was not found by ffmpeg.'
end
end
# @since 1.0.0-beta5
class DependencyNotFound < StandardError
def message
... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | lib/screen-recorder/window.rb | Ruby | mit | 198 | master | 2,321 | # @since 1.0.0-beta11
module ScreenRecorder
# @since 1.0.0-beta11
class Window < Common
include Screenshot
#
# Window recording mode.
#
def initialize(title:, output:, advanced: {})
raise 'Window recording is only supported on Microsoft Windows.' unless OS.windows?
super(input: %(t... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | lib/screen-recorder/titles.rb | Ruby | mit | 198 | master | 454 | module ScreenRecorder
# @since 1.0.0-beta4
module Titles
#
# Returns a list of available window titles for the given process (application) name.
#
# @return [Array]
#
# @example
# ScreenRecorder::Titles.fetch('chrome')
# #=> ["New Tab - Google Chrome"]
def self.fetch(applicat... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | lib/screen-recorder/os.rb | Ruby | mit | 198 | master | 1,697 | module ScreenRecorder
# @api private
module OS
module_function
def home
@home ||= Dir.home
end
def engine
@engine ||= RUBY_ENGINE.to_sym
end
def os
host_os = RbConfig::CONFIG['host_os']
@os ||= case host_os
when /mswin|msys|mingw|cygwin|bccwin|wince|e... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | lib/screen-recorder/screenshot.rb | Ruby | mit | 198 | master | 1,188 | module ScreenRecorder
# All screenshot related code
module Screenshot
#
# Takes a screenshot in the current context (input) - desktop or current window
#
def screenshot(filename, resolution = nil, log = 'ffmpeg.log')
ScreenRecorder.logger.debug "Screenshot filename: #{filename}, resolution: #{... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | lib/screen-recorder/type_checker.rb | Ruby | mit | 198 | master | 382 | module ScreenRecorder
# @since 1.0.0.beta10
#
# @api private
module TypeChecker
#
# Compares the given object's type (class) to the desired object type.
# Raises an ArgumentError if the object is not of desired type.
#
def self.check(obj, klass)
raise ArgumentError, "Expected #{klass},... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | lib/screen-recorder/common.rb | Ruby | mit | 198 | master | 4,127 | # @since 1.0.0-beta11
module ScreenRecorder
# @since 1.0.0-beta11
#
# @api private
class Common
PROCESS_TIMEOUT = 5 # Seconds to wait for ffmpeg to quit
attr_reader :options, :video
def initialize(input:, output:, advanced: {})
raise Errors::DependencyNotFound unless ffmpeg_exists?
@o... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | lib/screen-recorder/childprocess.rb | Ruby | mit | 198 | master | 3,299 | # frozen_string_literal: true
module ScreenRecorder
#
# @api private
#
# @since 1.7.0
#
# Combined version of:
# https://github.com/SeleniumHQ/selenium/blob/trunk/rb/lib/selenium/webdriver/common/child_process.rb
# https://github.com/enkessler/childprocess/blob/master/lib/childprocess/process_spawn_pro... |
github | kapoorlakshya/screen-recorder | https://github.com/kapoorlakshya/screen-recorder | lib/screen-recorder/options.rb | Ruby | mit | 198 | master | 3,979 | # @since 1.0.0-beta11
#
# @api private
module ScreenRecorder
# @since 1.0.0-beta11
class Options
attr_reader :all
DEFAULT_LOG_FILE = 'ffmpeg.log'.freeze
DEFAULT_FPS = 15.0
DEFAULT_MAC_INPUT_PIX_FMT = 'uyvy422'.freeze # For avfoundation
DEFAULT_PIX_FMT = 'yuv420p'.freeze
def initialize(opti... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | cassandra_object.gemspec | Ruby | isc | 198 | master | 628 | Gem::Specification.new do |s|
s.name = 'cassandra_object'
s.version = '0.6.0.pre'
s.email = "michael@koziarski.com"
s.author = "Michael Koziarski"
s.description = %q{Gives you most of the familiarity of ActiveRecord, but with the scalability of cassandra.}
s.summary = %q{Maps your objects into ca... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | Rakefile | Ruby | isc | 198 | master | 791 | require 'rubygems'
require 'rake'
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.test_files=Dir.glob( "test/**/*_test.rb" ).sort
t.verbose = true
end
Rake::TestTask.new(:legacy_test) do |t|
t.libs << "test/legacy"
t.libs << "test"
t.test_files=Dir.glob( "test/**/*_test.rb" ).s... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/z_mock_test.rb | Ruby | isc | 198 | master | 1,039 | # The filename is so that this test gets loaded last, since it depends on all the other tests.
# Suggestions of less janky ways to do this would be appreciated. -rk
require 'test_helper'
class MockTest < CassandraObjectTestCase
context CassandraObject::Base do
should "respond to use_mock!" do
assert Cass... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/index_test.rb | Ruby | isc | 198 | master | 2,393 | require 'test_helper'
class IndexTest < CassandraObjectTestCase
context "A non-unique index" do
setup do
@last_name = ActiveSupport::SecureRandom.hex(5)
@koz = Customer.create :first_name=>"Michael", :last_name=>@last_name, :date_of_birth=>28.years.ago.to_date
@wife = Customer.create :first_nam... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/cursor_test.rb | Ruby | isc | 198 | master | 2,223 | require 'test_helper'
class CursorTest < CassandraObjectTestCase
context "A Cursor working with a Super Column with mixed valid / invalid keys" do
setup do
@customer = Customer.create :first_name => "Michael",
:last_name => "Koziarski",
... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/basic_scenarios_test.rb | Ruby | isc | 198 | master | 6,716 | require 'test_helper'
class BasicScenariosTest < CassandraObjectTestCase
def setup
super
@customer = Customer.create :first_name => "Michael",
:last_name => "Koziarski",
:date_of_birth => Date.parse("1980/08/15")
@customer_key = @cust... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/validation_test.rb | Ruby | isc | 198 | master | 699 | require 'test_helper'
class ValidationTest < CassandraObjectTestCase
test "save! raises an error" do
begin
customer = Customer.new :first_name=>"steve", :date_of_birth=>Date.parse("1979/12/25")
customer.save!
flunk "Should have failed to save"
rescue CassandraObject::Validation::RecordIn... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/types_test.rb | Ruby | isc | 198 | master | 6,743 | require 'test_helper'
class TypesTest < CassandraObjectTestCase
context "IntegerType" do
context "encode" do
should "return an int with no errors" do
assert_nothing_raised {
i = 12
assert_equal i.to_s, CassandraObject::IntegerType.encode(i)
}
end
should "ra... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/callbacks_test.rb | Ruby | isc | 198 | master | 464 | require 'test_helper'
class CallbacksTest < CassandraObjectTestCase
def setup
super
end
context "a newly created record" do
setup do
@customer = Customer.create! :first_name => "Tom",
:last_name => "Ward",
:date_of_birth ... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/migration_test.rb | Ruby | isc | 198 | master | 641 | require 'test_helper'
class MigrationTest < CassandraObjectTestCase
test "a new invoice should have the right schema version" do
i = mock_invoice
assert_equal 2, i.schema_version
end
test " a new invoice should have an empty gst_number" do
assert_equal nil, mock_invoice.gst_number
end
test ... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/fixture_models.rb | Ruby | isc | 198 | master | 2,061 | module ReverseStorage
def encode(str)
str.reverse
end
module_function :encode
def decode(str)
str.reverse
end
module_function :decode
end
class Customer < CassandraObject::Base
attribute :first_name, :type => :string
attribute :last_name, :type => :string
attribute :date_of_birth, ... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/test_helper.rb | Ruby | isc | 198 | master | 234 | require 'rubygems'
require 'bundler'
Bundler.setup
require 'cassandra_object'
require 'connection'
require 'test/unit'
require 'active_support/test_case'
require 'shoulda'
require 'fixture_models'
require 'pp'
require 'test_case' |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/time_test.rb | Ruby | isc | 198 | master | 903 | require 'test_helper'
class TimeTest < CassandraObjectTestCase
test "new raises an error" do
begin
appt = Appointment.new :start_time => 1
flunk "Should have failed to save"
rescue ArgumentError => e
assert_equal "CassandraObject::TimeType requires a Time", e.message
end
end
test ... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/connection.rb | Ruby | isc | 198 | master | 614 | ENV['CASSANDRA'] ||= "/usr/local/cassandra/bin/cassandra"
if ENV['CASSANDRA_REQUIRED']
tmp = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp'))
config = File.expand_path(File.join(File.dirname(__FILE__), 'config'))
$pid = fork {
Dir.chdir(tmp)
puts "CASSANDRA_INCLUDE=#{config}/cassandra.in... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/one_to_many_associations_test.rb | Ruby | isc | 198 | master | 5,655 | require 'test_helper'
class OneToManyAssociationsTest < CassandraObjectTestCase
context "A customer with no invoices added to its invoice association" do
setup do
@customer = Customer.create :first_name => "Michael",
:last_name => "Koziarski",
... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/test_case.rb | Ruby | isc | 198 | master | 917 | class CassandraObjectTestCase < ActiveSupport::TestCase
def teardown
CassandraObject::Base.connection.clear_keyspace!
end
def mock_invoice
Invoice.create :number=>Time.now.to_i*(rand(5)), :total=>Time.now.to_f
end
def connection
CassandraObject::Base.connection
end
def assert_ordered(expe... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/dirty_test.rb | Ruby | isc | 198 | master | 1,099 | require 'test_helper'
class DirtyTest < CassandraObjectTestCase
def setup
super
@customer = Customer.create :first_name => "Michael",
:last_name => "Koziarski",
:date_of_birth => Date.parse("1980/08/15")
@customer_key = @customer.key... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/legacy/test_helper.rb | Ruby | isc | 198 | master | 256 | require 'rubygems'
gem 'activesupport', "~> 2.3.5"
puts "LEGACY TEST"
require 'cassandra_object'
require 'connection'
require 'test/unit'
require 'active_support/test_case'
require 'shoulda'
require 'fixture_models'
require 'pp'
require 'test_case' |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | test/identity/natural_key_factory_test.rb | Ruby | isc | 198 | master | 2,895 | require 'test_helper'
module Identity
class NaturalKeyFactoryTest < CassandraObjectTestCase
context "With one attribute" do
setup do
@key_factory = CassandraObject::Identity::NaturalKeyFactory.new :attributes => :name
@james = Person.new("name" => "james")
end
should "have a ke... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object.rb | Ruby | isc | 198 | master | 617 | require 'rubygems'
require 'i18n'
require 'active_support'
require 'active_support/version'
module CassandraObject
class << self
attr_accessor :old_active_support
end
self.old_active_support = false
VERSION = "0.5.0"
end
if ActiveSupport::VERSION::STRING =~ /^2/
vendor = File.expand_path(File.dirnam... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/legacy_callbacks.rb | Ruby | isc | 198 | master | 749 | module CassandraObject
module Callbacks
extend ActiveSupport::Concern
include ActiveSupport::Callbacks
included do
define_model_callbacks :save, :create, :destroy, :update
end
module ClassMethods
def define_model_callbacks(*callbacks)
callbacks.each do |callback|
... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/types.rb | Ruby | isc | 198 | master | 3,248 | module CassandraObject
module IntegerType
REGEX = /\A[-+]?\d+\Z/
def encode(int)
return '' if int.nil?
raise ArgumentError.new("#{self} requires an Integer. You passed #{int.inspect}") unless int.kind_of?(Integer)
int.to_s
end
module_function :encode
def decode(str)
return... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/identity.rb | Ruby | isc | 198 | master | 1,744 | require 'cassandra_object/identity/abstract_key_factory'
require 'cassandra_object/identity/key'
require 'cassandra_object/identity/uuid_key_factory'
require 'cassandra_object/identity/natural_key_factory'
module CassandraObject
# Some docs will be needed here but the gist of this is simple. Instead of returning a ... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/callbacks.rb | Ruby | isc | 198 | master | 209 | module CassandraObject
module Callbacks
extend ActiveSupport::Concern
included do
extend ActiveModel::Callbacks
define_model_callbacks :save, :create, :destroy, :update
end
end
end |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/cursor.rb | Ruby | isc | 198 | master | 2,380 | module CassandraObject
class Cursor
def initialize(target_class, column_family, key, super_column, options={})
@target_class = target_class
@column_family = column_family
@key = key.to_s
@super_column = super_column
@options = options
@validators = []
e... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/indexes.rb | Ruby | isc | 198 | master | 3,950 | module CassandraObject
module Indexes
extend ActiveSupport::Concern
included do
class_inheritable_accessor :indexes
end
class UniqueIndex
def initialize(attribute_name, model_class, options)
@attribute_name = attribute_name
@model_class = model_class
end
... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/persistence.rb | Ruby | isc | 198 | master | 6,040 | module CassandraObject
module Persistence
extend ActiveSupport::Concern
included do
class_inheritable_writer :write_consistency
class_inheritable_writer :read_consistency
end
VALID_READ_CONSISTENCY_LEVELS = [:one, :quorum, :all]
VALID_WRITE_CONSISTENCY_LEVELS = VALID_READ_CONSISTENCY_... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/associations.rb | Ruby | isc | 198 | master | 1,108 | require 'cassandra_object/associations/one_to_many'
require 'cassandra_object/associations/one_to_one'
module CassandraObject
module Associations
extend ActiveSupport::Concern
included do
class_inheritable_hash :associations
end
module ClassMethods
def column_family_configuration
... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/collection.rb | Ruby | isc | 198 | master | 235 | module CassandraObject
class Collection < Array
attr_accessor :last_column_name
def inspect
"<CassandraObject::Collection##{object_id} contents: #{super} last_column_name: #{last_column_name.inspect}>"
end
end
end |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/validation.rb | Ruby | isc | 198 | master | 1,225 | module CassandraObject
module Validation
class RecordInvalidError < StandardError
attr_reader :record
def initialize(record)
@record = record
super("Invalid record: #{@record.errors.full_messages.to_sentence}")
end
def self.raise_error(record)
raise new(recor... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/mocking.rb | Ruby | isc | 198 | master | 321 | require 'cassandra/mock'
module CassandraObject
module Mocking
extend ActiveSupport::Concern
module ClassMethods
def use_mock!(really=true)
if really
self.connection_class = Cassandra::Mock
else
self.connection_class = Cassandra
end
end
end
end
end |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/attributes.rb | Ruby | isc | 198 | master | 2,597 | module CassandraObject
class Attribute
attr_reader :name, :converter, :expected_type
def initialize(name, owner_class, converter, expected_type, options)
@name = name.to_s
@owner_class = owner_class
@converter = converter
@expected_type = expected_type
@options ... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/base.rb | Ruby | isc | 198 | master | 2,541 | require 'cassandra'
require 'set'
require 'cassandra_object/attributes'
require 'cassandra_object/dirty'
require 'cassandra_object/persistence'
if CassandraObject.old_active_support
require 'cassandra_object/legacy_callbacks'
else
require 'cassandra_object/callbacks'
end
require 'cassandra_object/validation'
requ... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/type_registration.rb | Ruby | isc | 198 | master | 661 | CassandraObject::Base.register_attribute_type(:integer, Integer, CassandraObject::IntegerType)
CassandraObject::Base.register_attribute_type(:float, Float, CassandraObject::FloatType)
CassandraObject::Base.register_attribute_type(:date, Date, CassandraObject::DateType)
CassandraObject::Base.register_attribute_type(:tim... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/migrations.rb | Ruby | isc | 198 | master | 2,064 | module CassandraObject
module Migrations
extend ActiveSupport::Concern
included do
class_inheritable_array :migrations
class_inheritable_accessor :current_schema_version
self.current_schema_version = 0
end
class Migration
attr_reader :version
def initialize(version, ... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/dirty.rb | Ruby | isc | 198 | master | 604 | module CassandraObject
module Dirty
extend ActiveSupport::Concern
include ActiveModel::Dirty
module InstanceMethods
def attributes_changed!(attributes)
attributes.each do |attr_name|
attribute_will_change!(attr_name)
end
end
def save
super.tap { change... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/identity/natural_key_factory.rb | Ruby | isc | 198 | master | 975 | module CassandraObject
module Identity
class NaturalKeyFactory < AbstractKeyFactory
class NaturalKey
include Key
attr_reader :value
def initialize(value)
@value = value
end
def to_s
value
end
def to_param
value
... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/identity/uuid_key_factory.rb | Ruby | isc | 198 | master | 954 | module CassandraObject
module Identity
# Key factories need to support 3 operations
class UUIDKeyFactory < AbstractKeyFactory
class UUID < SimpleUUID::UUID
include Key
def to_param
to_guid
end
def to_s
# FIXME - this should probably write the... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/identity/abstract_key_factory.rb | Ruby | isc | 198 | master | 1,217 | module CassandraObject
module Identity
# Key factories need to support 3 operations
class AbstractKeyFactory
# Next key takes an object and returns the key object it should use.
# object will be ignored with synthetic keys but could be useful with natural ones
#
# @param [CassandraObj... |
github | NZKoz/cassandra_object | https://github.com/NZKoz/cassandra_object | lib/cassandra_object/identity/key.rb | Ruby | isc | 198 | master | 668 | module CassandraObject
module Identity
# An "interface" that keys need to implement
#
# You don't have to include this. But, there's no reason I can think of not to.
#
module Key
# to_param should return a nice-readable representation of the key suitable to chuck into URLs
#
# @... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.