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 | nicholasjackson/minke | https://github.com/nicholasjackson/minke | lib/minke/docker/network.rb | Ruby | mit | 45 | master | 728 | module Minke
module Docker
class Network
def initialize network_name, shell_runner
@network_name = network_name
@shell_runner = shell_runner
@created_network = false
end
def create
if find_network.to_s == ''
@shell_runner.execute("docker network create ... |
github | nicholasjackson/minke | https://github.com/nicholasjackson/minke | lib/minke/docker/consul.rb | Ruby | mit | 45 | master | 1,769 | module Minke
module Docker
class Consul
def initialize args
@health_check = args[:health_check]
@service_discovery = args[:service_discovery]
@consul_loader = args[:consul_loader]
@docker_runner = args[:docker_runner]
@network = args[:network]
@project_name = ... |
github | nicholasjackson/minke | https://github.com/nicholasjackson/minke | lib/minke/docker/service_discovery.rb | Ruby | mit | 45 | master | 3,213 | module Minke
module Docker
##
# ServiceDiscovery allows you to look up the publicly accessible address and port for a server
class ServiceDiscovery
def initialize project_name, docker_runner, docker_network = nil
@project_name = project_name
@docker_runner = docker_runner
@do... |
github | nicholasjackson/minke | https://github.com/nicholasjackson/minke | lib/minke/docker/docker_runner.rb | Ruby | mit | 45 | master | 7,965 | module Minke
module Docker
class DockerRunner
def initialize logger, network = nil, project = nil
@network = network ||= 'bridge'
@logger = logger
@project = project
end
##
# returns the ip address that docker is running on
def get_docker_ip_address
#... |
github | nicholasjackson/minke | https://github.com/nicholasjackson/minke | lib/minke/helpers/shell.rb | Ruby | mit | 45 | master | 1,150 | module Minke
module Helpers
class Shell
def initialize logger
@logger = logger
end
##
# Executes a shell command and returns the return status
def execute command, ignore_error=false
@logger.debug command
Open3.popen2e(command) do |stdin, stdout_err,... |
github | nicholasjackson/minke | https://github.com/nicholasjackson/minke | lib/minke/helpers/copy.rb | Ruby | mit | 45 | master | 348 | module Minke
module Helpers
class Copy
##
# copy assets from one location to another
def copy_assets from, to
directory = to
if File.directory?(to)
directory = File.dirname(to)
end
Dir.mkdir directory unless Dir.exist? to
FileUtils.cp_r from, to... |
github | nicholasjackson/minke | https://github.com/nicholasjackson/minke | lib/minke/helpers/ruby.rb | Ruby | mit | 45 | master | 410 | module Minke
module Helpers
class Ruby
def initialize
load_ruby_files
end
def load_ruby_files
$LOAD_PATH.unshift Dir.pwd
Dir[File.join(Dir.pwd, "*.rb")].each {|file| require File.basename(file) }
end
##
# invoke a rake task
def invoke_task(... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | rubocop-i18n.gemspec | Ruby | apache-2.0 | 45 | master | 1,062 | # frozen_string_literal: true
require_relative 'lib/rubocop/i18n/version'
Gem::Specification.new do |spec|
spec.name = 'rubocop-i18n'
spec.version = RuboCop::I18n::VERSION
spec.authors = ['Puppet', 'Brandon High', 'TP Honey', 'Helen Campbell']
spec.summary = 'RuboCop rules for i18n... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | Rakefile | Ruby | apache-2.0 | 45 | master | 230 | # frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task default: :test
task test: %i[rubocop spec]
desc 'Run RuboCop'
task :rubocop do
sh 'rubocop'
end |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | Gemfile | Ruby | apache-2.0 | 45 | master | 320 | # frozen_string_literal: true
source 'https://rubygems.org'
# Specify your gem's dependencies in rubocop-i18n.gemspec
gemspec
gem 'bundler', '>= 1.17.3'
gem 'pry', '~> 0.13.1'
gem 'rake', '>= 12.3.3'
gem 'rb-readline', '~> 0.5.5'
gem 'rspec', '~> 3.0'
gem 'rubocop-performance'
gem 'rubocop-rake'
gem 'rubocop-rspec' |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | lib/rubocop-i18n.rb | Ruby | apache-2.0 | 45 | master | 202 | # frozen_string_literal: true
require 'rubocop'
require_relative 'rubocop/i18n'
require_relative 'rubocop/i18n/version'
require_relative 'rubocop/i18n/plugin'
require_relative 'rubocop/cop/i18n_cops' |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | lib/rubocop/cop/i18n_cops.rb | Ruby | apache-2.0 | 45 | master | 490 | # frozen_string_literal: true
require_relative 'i18n/gettext'
require_relative 'i18n/gettext/decorate_string'
require_relative 'i18n/gettext/decorate_function_message'
require_relative 'i18n/gettext/decorate_string_formatting_using_interpolation'
require_relative 'i18n/gettext/decorate_string_formatting_using_percent'... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | lib/rubocop/cop/i18n/rails_i18n.rb | Ruby | apache-2.0 | 45 | master | 555 | # frozen_string_literal: true
module RuboCop
module Cop
module I18n
# The Rails I18n module contains cops used to lint and enforce the use of strings
# in rails applications that want to use the I18n gem.
module RailsI18n
def self.supported_decorators
%w[
t
... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | lib/rubocop/cop/i18n/gettext.rb | Ruby | apache-2.0 | 45 | master | 995 | # frozen_string_literal: true
module RuboCop
module Cop
module I18n
module GetText
def self.supported_methods
%w[raise fail]
end
# Supports decorators from
# * mutoh/gettext https://github.com/mutoh/gettext/blob/master/lib/gettext.rb
# * grosser/fast_gette... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | lib/rubocop/cop/i18n/rails_i18n/decorate_string_formatting_using_interpolation.rb | Ruby | apache-2.0 | 45 | master | 1,932 | # frozen_string_literal: true
module RuboCop
module Cop
module I18n
module RailsI18n
# When using an decorated string to support I18N, any strings inside the decoration should not contain
# the '#{}' interpolation string as this makes it hard to translate the strings.
#
# @e... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | lib/rubocop/cop/i18n/rails_i18n/decorate_string.rb | Ruby | apache-2.0 | 45 | master | 5,192 | # frozen_string_literal: true
module RuboCop
module Cop
module I18n
module RailsI18n
# Looks for strings that appear to be sentences but are not decorated.
# Sentences are determined by the SENTENCE_REGEXP. (Upper case character, at least one space,
# and sentence punctuation at the... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | lib/rubocop/cop/i18n/gettext/decorate_string_formatting_using_percent.rb | Ruby | apache-2.0 | 45 | master | 2,371 | # frozen_string_literal: true
module RuboCop
module Cop
module I18n
module GetText
# When using a decorated string to support I18N, any strings inside the decoration should not contain sprintf
# style formatting as this makes it hard to translate the string. This cop checks the decorators l... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | lib/rubocop/cop/i18n/gettext/decorate_string_formatting_using_interpolation.rb | Ruby | apache-2.0 | 45 | master | 1,981 | # frozen_string_literal: true
module RuboCop
module Cop
module I18n
module GetText
# When using an decorated string to support I18N, any strings inside the decoration should not contain
# the '#{}' interpolation string as this makes it hard to translate the strings.
#
# Chec... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | lib/rubocop/cop/i18n/gettext/decorate_function_message.rb | Ruby | apache-2.0 | 45 | master | 5,998 | # frozen_string_literal: true
module RuboCop
module Cop
module I18n
module GetText
# rubocop:disable Metrics/ClassLength
class DecorateFunctionMessage < Base
extend AutoCorrector
# rubocop:disable Metrics/PerceivedComplexity
def on_send(node)
retur... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | lib/rubocop/cop/i18n/gettext/decorate_string.rb | Ruby | apache-2.0 | 45 | master | 2,368 | # frozen_string_literal: true
module RuboCop
module Cop
module I18n
module GetText
# Looks for strings that appear to be sentences but are not decorated.
# Sentences are determined by the STRING_REGEXP. (Upper case character, at least one space,
# and sentence punctuation at the end... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | lib/rubocop/i18n/plugin.rb | Ruby | apache-2.0 | 45 | master | 739 | # frozen_string_literal: true
require 'lint_roller'
module RuboCop
module I18n
# A plugin that integrates rubocop-i18n with RuboCop's plugin system.
class Plugin < LintRoller::Plugin
def about
LintRoller::About.new(
name: 'rubocop-i18n',
version: VERSION,
homepage... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | spec/spec_helper.rb | Ruby | apache-2.0 | 45 | master | 1,190 | # frozen_string_literal: true
require 'rubocop-i18n'
require 'rubocop/rspec/support'
require 'shared_examples'
require 'shared_functions'
RSpec.configure do |config|
# These two settings work together to allow you to limit a spec run
# to individual examples or groups you care about by tagging them with
# `:fo... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | spec/shared_functions.rb | Ruby | apache-2.0 | 45 | master | 298 | # frozen_string_literal: true
def investigate(cop, src, filename = nil)
processed_source = RuboCop::ProcessedSource.new(src, RUBY_VERSION.to_f, filename)
team = RuboCop::Cop::Team.new([cop], configuration, raise_error: true)
report = team.investigate(processed_source)
report.offenses
end |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | spec/shared_examples.rb | Ruby | apache-2.0 | 45 | master | 872 | # frozen_string_literal: true
require 'rubocop/rspec/support'
shared_examples 'accepts' do |code|
let(:source) { code }
it 'does not register an offense' do
expect_no_offenses(source)
end
end
shared_examples 'a_detecting_cop' do |unfixed, _function, expected_warning|
let(:source) { unfixed.to_s }
it '... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | spec/rubocop/cop/i18n/get_text/decorate_function_message_spec.rb | Ruby | apache-2.0 | 45 | master | 4,158 | # frozen_string_literal: true
describe RuboCop::Cop::I18n::GetText::DecorateFunctionMessage, :config do
before do
@offenses = investigate(cop, source)
end
RuboCop::Cop::I18n::GetText.supported_methods.each do |function|
context "#{function} with undecorated double-quote message" do
it_behaves_like... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | spec/rubocop/cop/i18n/get_text/decorate_string_formatting_using_interpolation_spec.rb | Ruby | apache-2.0 | 45 | master | 2,005 | # frozen_string_literal: true
describe RuboCop::Cop::I18n::GetText::DecorateStringFormattingUsingInterpolation, :config do
before do
@offenses = investigate(cop, source)
end
context 'when using .call shorthand syntax' do
it_behaves_like 'accepts', 'Object.method(:to_s).()'
end
RuboCop::Cop::I18n::G... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | spec/rubocop/cop/i18n/get_text/decorate_string_formatting_using_percent_spec.rb | Ruby | apache-2.0 | 45 | master | 3,381 | # frozen_string_literal: true
describe RuboCop::Cop::I18n::GetText::DecorateStringFormattingUsingPercent, :config do
before do
@offenses = investigate(cop, source)
end
context 'when using .call shorthand syntax' do
it_behaves_like 'accepts', 'Object.method(:to_s).()'
end
RuboCop::Cop::I18n::GetText... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | spec/rubocop/cop/i18n/get_text/decorate_string_spec.rb | Ruby | apache-2.0 | 45 | master | 2,875 | # frozen_string_literal: true
describe RuboCop::Cop::I18n::GetText::DecorateString, :config do
before do
@offenses = investigate(cop, source)
end
context 'decoration needed for string' do
it_behaves_like 'a_detecting_cop', 'a = "A sentence that is not decorated."', '_', 'decorator is missing around sent... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | spec/rubocop/cop/i18n/rails_i18n/decorate_string_formatting_using_interpolation_spec.rb | Ruby | apache-2.0 | 45 | master | 1,859 | # frozen_string_literal: true
describe RuboCop::Cop::I18n::RailsI18n::DecorateStringFormattingUsingInterpolation, :config do
before do
@offenses = investigate(cop, source)
end
RuboCop::Cop::I18n::RailsI18n.supported_decorators.each do |decorator|
# rubocop:disable RSpec/LeakyLocalVariable -- `error_mess... |
github | rubocop/rubocop-i18n | https://github.com/rubocop/rubocop-i18n | spec/rubocop/cop/i18n/rails_i18n/decorate_string_spec.rb | Ruby | apache-2.0 | 45 | master | 7,896 | # frozen_string_literal: true
describe RuboCop::Cop::I18n::RailsI18n::DecorateString, :config do
before do
@offenses = investigate(cop, source)
end
context 'decoration needed for string' do
it_behaves_like 'a_detecting_cop', 'a = "A sentence that is not decorated."', 't', 'decorator is missing around se... |
github | fluent/fluent-plugin-splunk | https://github.com/fluent/fluent-plugin-splunk | Rakefile | Ruby | apache-2.0 | 45 | master | 266 | require 'bundler/gem_tasks'
require 'rake/testtask'
Rake::TestTask.new do |test|
test.libs << 'test'
test.pattern = 'test/test_*.rb'
test.verbose = true
end
task default: :test
task :coverage do |t|
ENV['SIMPLE_COV'] = '1'
Rake::Task['test'].invoke
end |
github | fluent/fluent-plugin-splunk | https://github.com/fluent/fluent-plugin-splunk | fluent-plugin-splunk-enterprise.gemspec | Ruby | apache-2.0 | 45 | master | 1,066 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |spec|
spec.name = "fluent-plugin-splunk-enterprise"
spec.version = "0.10.2"
spec.authors = ["Yuki Ito", "Masahiro Nakagawa"]
spec.email = ["... |
github | fluent/fluent-plugin-splunk | https://github.com/fluent/fluent-plugin-splunk | lib/fluent/plugin/out_splunk_tcp.rb | Ruby | apache-2.0 | 45 | master | 4,145 | require 'fluent/output'
require 'fluent/formatter'
require 'fluent/config/error'
require 'socket'
require 'openssl'
require 'json'
# http://dev.splunk.com/view/event-collector/SP-CAAAE6P
module Fluent
class SplunkTCPOutput < ObjectBufferedOutput
Fluent::Plugin.register_output('splunk_tcp', self)
config_par... |
github | fluent/fluent-plugin-splunk | https://github.com/fluent/fluent-plugin-splunk | lib/fluent/plugin/out_splunk_hec.rb | Ruby | apache-2.0 | 45 | master | 6,592 | require 'fluent/output'
require 'httpclient'
require 'json'
require 'securerandom'
# http://dev.splunk.com/view/event-collector/SP-CAAAE6P
module Fluent
class SplunkHECOutput < ObjectBufferedOutput
Fluent::Plugin.register_output('splunk_hec', self)
config_param :host, :string
config_param :port, :integ... |
github | fluent/fluent-plugin-splunk | https://github.com/fluent/fluent-plugin-splunk | test/test_out_splunk_hec.rb | Ruby | apache-2.0 | 45 | master | 28,585 | require 'helper'
require 'test/unit'
require 'fluent/test'
require 'fluent/plugin/out_splunk_hec'
require 'net/https'
require 'uri'
require 'json'
require 'securerandom'
class SplunkHECOutputTest < Test::Unit::TestCase
self.test_order = :random
def setup
Fluent::Test.setup
end
def teardown
end
CONF... |
github | fluent/fluent-plugin-splunk | https://github.com/fluent/fluent-plugin-splunk | test/helper.rb | Ruby | apache-2.0 | 45 | master | 1,144 | def to_version(version_str)
Gem::Version.new(version_str)
end
SPLUNK_VERSION = to_version(ENV['SPLUNK_VERSION'])
## query(8088, 'source="SourceName"')
def get_events(port, search_query, expected_num = 1)
retries = 0
events = []
while events.length != expected_num
print '-' unless retries == 0
sleep(3)... |
github | fluent/fluent-plugin-splunk | https://github.com/fluent/fluent-plugin-splunk | test/test_out_splunk_tcp.rb | Ruby | apache-2.0 | 45 | master | 16,958 | require 'helper'
require 'test/unit'
require 'fluent/test'
require 'fluent/plugin/out_splunk_tcp'
require 'net/https'
require 'uri'
require 'json'
require 'securerandom'
class SplunkTCPOutputTest < Test::Unit::TestCase
def setup
Fluent::Test.setup
end
def teardown
end
CONFIG = %[
host 127.0.0.1
... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | cassandra_migrations.gemspec | Ruby | mit | 45 | master | 1,662 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'cassandra_migrations/version'
Gem::Specification.new do |s|
s.name = 'cassandra_migrations'
s.version = CassandraMigrations::VERSION
s.date = '2016-06-14'
s.license ... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations.rb | Ruby | mit | 45 | master | 296 | require 'cassandra_migrations/version'
require 'cassandra_migrations/config'
require 'cassandra_migrations/errors'
require 'cassandra_migrations/cassandra'
require 'cassandra_migrations/migrator'
require 'cassandra_migrations/migration'
require 'cassandra_migrations/railtie' if defined?(Rails) |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/migration.rb | Ruby | mit | 45 | master | 2,713 | # encoding: utf-8
require 'cassandra_migrations/migration/table_operations'
require 'cassandra_migrations/migration/column_operations'
module CassandraMigrations
# Base class for all cassandra migration
class Migration
include TableOperations
include ColumnOperations
# Makes +execute+ met... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/migrator.rb | Ruby | mit | 45 | master | 3,150 | # encoding: utf-8
module CassandraMigrations
module Migrator
METADATA_TABLE = 'cassandra_migrations_metadata'
def self.up_to_latest!
current_version = read_current_version
new_migrations = get_all_migration_names.sort.select do |migration_name|
get_version_from_migration_name(migration... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/cassandra.rb | Ruby | mit | 45 | master | 2,143 | # encoding: utf-8
require 'yaml'
require 'cassandra'
require_relative 'cql-rb-wrapper'
require 'cassandra_migrations/cassandra/queries'
require 'cassandra_migrations/cassandra/query_result'
require 'cassandra_migrations/cassandra/keyspace_operations'
module CassandraMigrations
module Cassandra
extend Queries
... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/cql-rb-wrapper.rb | Ruby | mit | 45 | master | 2,117 | # encoding: utf-8
require 'cassandra'
require 'ione'
class PreparedStatement
attr_reader :statement
def initialize(client, statement)
@client = client
@statement = statement
end
def execute(*args)
@client.execute(@statement, *args)
end
end
class BatchStatement
def initialize(client, batch)
... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/capistrano.rb | Ruby | mit | 45 | master | 493 | # encoding : utf-8
Capistrano::Configuration.instance(:must_exist).load do
after 'bundle:install', 'cassandra:migrate'
namespace :cassandra do
task :migrate, :roles => :cassandra do
rake = fetch(:rake, "rake")
rails_env = fetch(:rails_env, "production")
directory = latest_release
... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/errors.rb | Ruby | mit | 45 | master | 1,512 | # encoding: utf-8
require 'colorize'
module CassandraMigrations
module Errors
class CassandraError < StandardError
def initialize(msg)
# Makes all exception messages red
if msg.frozen?
super(msg.dup.red)
else
super(msg.red)
end
end
end
cl... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/railtie.rb | Ruby | mit | 45 | master | 562 | # encoding : utf-8
class CassandraMigrations::Railtie < ::Rails::Railtie
initializer "cassandra_migrations.initializer" do
require File.expand_path('railtie/initializer', File.dirname(__FILE__))
end
rake_tasks do
Dir[File.expand_path("railtie/**/*.rake", File.dirname(__FILE__))].each do |file|
... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/config.rb | Ruby | mit | 45 | master | 2,070 | # encoding: utf-8
module CassandraMigrations
module Config
# See valid options at https://github.com/datastax/ruby-driver/blob/master/lib/cassandra.rb#L163
CASSANDRA_CONNECTION_VALID_FIELDS = [
:credentials, :auth_provider, :compression, :hosts, :logger, :port,
:load_balancing_policy, :reconne... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/cassandra/queries.rb | Ruby | mit | 45 | master | 4,597 | # encoding: utf-8
module CassandraMigrations
module Cassandra
module Queries
def write!(table, value_hash, options={})
columns = []
values = []
value_hash.each do |column, value|
columns << column.to_s
values << to_cql_value(column, value, table, options)
... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/cassandra/query_result.rb | Ruby | mit | 45 | master | 883 | # encoding: utf-8
module CassandraMigrations
module Cassandra
class QueryResult
def initialize(cql_query_result)
@cql_query_result = cql_query_result
end
# We don't want to flood the console or the log with an inspection of
# a lot of loaded data
def inspect
... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/cassandra/keyspace_operations.rb | Ruby | mit | 45 | master | 2,247 | # encoding: utf-8
require 'cassandra'
require 'active_support/core_ext/string/strip'
module CassandraMigrations
module Cassandra
module KeyspaceOperations
def create_keyspace!(env)
config = Config.configurations[env]
execute(create_keyspace_statement(config))
begin
use(co... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/railtie/tasks.rake | Ruby | mit | 45 | master | 2,597 | # encoding : utf-8
namespace :cassandra do
task :start do
CassandraMigrations::Cassandra.start!
end
desc 'Create the keyspace in config/cassandra.yml for the current environment'
task :create do
begin
CassandraMigrations::Cassandra.start!
puts "Keyspace #{CassandraMigrations::Config.keysp... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/railtie/initializer.rb | Ruby | mit | 45 | master | 966 | # encoding : utf-8
# In production (when Passenger is used with smart spawn), many ruby processes are created
# by forking the original spawner. Since the child process is a different process, it shares
# no memory with its father. Because of that we have to connect to cassandra again.
# It is also common that file de... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/railtie/generators/cassandra_configuration/cassandra_configuration_generator.rb | Ruby | mit | 45 | master | 1,131 | class CassandraConfigurationGenerator < Rails::Generators::Base
source_root File.expand_path('templates', File.dirname(__FILE__))
# Creates configuration file and migration directory
#
# Any public method in the generator is run automatically when
# the generator is run. To understand fully see
# http://as... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/railtie/generators/cassandra_migration/cassandra_migration_generator.rb | Ruby | mit | 45 | master | 702 | class CassandraMigrationGenerator < Rails::Generators::Base
source_root File.expand_path('templates', File.dirname(__FILE__))
argument :migration_name, :type => :string
# Interpolates template and creates migration in the application
#
# Any public method in the generator is run automatically when
# ... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/migration/table_operations.rb | Ruby | mit | 45 | master | 2,701 | # encoding: utf-8
require 'cassandra_migrations/migration/table_definition'
module CassandraMigrations
class Migration
# Module grouping methods used in migrations to make table operations like:
# - creating tables
# - dropping tables
module TableOperations
# Creates a new table in the keysp... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/migration/column_operations.rb | Ruby | mit | 45 | master | 1,386 | # encoding: utf-8
require 'cassandra_migrations/migration/table_definition'
module CassandraMigrations
class Migration
# Module grouping methods used in migrations to make table operations like:
# - adding/removing columns
# - changing column types
# - renaming columns
module ColumnOperatio... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | lib/cassandra_migrations/migration/table_definition.rb | Ruby | mit | 45 | master | 12,454 | # encoding: utf-8
module CassandraMigrations
class Migration
# Used to define a table in a migration of table creation or to
# add columns to an existing table.
#
# An instance of this class is passed to the block of the method
# +create_table+, available on every migration.
#
# This cla... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | spec/spec_helper.rb | Ruby | mit | 45 | master | 375 | require 'bundler'
Bundler.setup
require 'simplecov'
require 'coveralls'
Coveralls.wear!
require 'rails/all'
require 'rspec'
require 'cassandra_migrations'
SimpleCov.command_name 'Unit Tests'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Fo... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | spec/cassandra_migrations_spec.rb | Ruby | mit | 45 | master | 12,390 | # encoding : utf-8
require 'spec_helper'
module CassandraMigrations
# Temporarily monkey path Migration to allow for testing generated CQL
# and suppress announcements
class Migration
attr_reader :cql
def execute(cql)
@cql = cql
end
private
def announce_migration(message); end
... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | spec/cassandra_migrations/config_spec.rb | Ruby | mit | 45 | master | 3,333 | # encoding : utf-8
require 'spec_helper'
describe CassandraMigrations::Config do
before do
CassandraMigrations::Config.configurations = nil
end
it 'should fetch values in config for the right environment' do
allow(Rails).to receive(:root).and_return Pathname.new("spec/fixtures")
allow(Rails).to rec... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | spec/cassandra_migrations/cassandra_spec.rb | Ruby | mit | 45 | master | 4,172 | # encoding : utf-8
require 'spec_helper'
describe CassandraMigrations::Cassandra do
before do
allow(Rails).to receive(:root).and_return Pathname.new("spec/fixtures")
allow(Rails).to receive(:env).and_return ActiveSupport::StringInquirer.new("development")
end
after do
CassandraMigrations::Cassandra... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | spec/cassandra_migrations/migrator_spec.rb | Ruby | mit | 45 | master | 2,124 | # encoding : utf-8
require 'spec_helper'
require_relative '../fixtures/db/cassandra_migrate/20160523185719_create_test_table'
require_relative '../fixtures/db/cassandra_migrate/12345_release_12345'
describe CassandraMigrations::Migrator do
before do
allow(Rails).to receive(:root).and_return Pathname.new("#{Dir.... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | spec/cassandra_migrations/cassandra/queries_spec.rb | Ruby | mit | 45 | master | 12,306 | # encoding : utf-8
require 'spec_helper'
describe CassandraMigrations::Cassandra::Queries do
def set_column_info(type)
@column_info = [{'type' => "#{type}"}]
end
before :each do
@client = double("client", {keyspace: 'test_keyspace'})
allow(TestQueryExecutor).to receive(:client).and_return(@client)
... |
github | hsgubert/cassandra_migrations | https://github.com/hsgubert/cassandra_migrations | spec/cassandra_migrations/cassandra/keyspace_operations_spec.rb | Ruby | mit | 45 | master | 1,259 | # encoding : utf-8
require 'spec_helper'
describe CassandraMigrations::Cassandra::KeyspaceOperations do
describe "#create_keyspace_statement" do
let(:config) { CassandraMigrations::Config.configurations[env] }
let(:extended_object) { Object.new.extend(described_class) }
before do
allow(Rails).to ... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | mention_system.gemspec | Ruby | mit | 45 | master | 1,434 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'mention_system/version'
Gem::Specification.new do |spec|
spec.name = "mention_system"
spec.version = MentionSystem::VERSION
spec.authors = ["Pablo Martin Viva", "Bilal ... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | Appraisals | Ruby | mit | 45 | master | 215 | appraise "rails6.0.0" do
gem "rails", "6.0.0"
end
appraise "rails6.0.1" do
gem "rails", "6.0.1"
end
appraise "rails6.0.2" do
gem "rails", "6.0.2"
end
appraise "rails6.0.2.1" do
gem "rails", "6.0.2.1"
end |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | lib/mention_system.rb | Ruby | mit | 45 | master | 773 | require 'mention_system/mention'
require 'mention_system/mention_processor'
require 'mention_system/mentionee'
require 'mention_system/mentioner'
###
# MentionSystem module
#
# This module defines common behavior in mention system
###
module MentionSystem
###
# Specifies if self can be mentioned by {Mentioner} obj... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | lib/generators/mention_system/mention_system_generator.rb | Ruby | mit | 45 | master | 1,003 | require 'rails/generators/migration'
require 'rails/generators/active_record'
###
# MentionSystemGenerator class
#
# This class generates the mention model migration in mention system
###
class MentionSystemGenerator < Rails::Generators::Base
###
# Includes Rails::Generators::Migration
###
include Rails::Gener... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | lib/generators/mention_system/templates/migration.rb | Ruby | mit | 45 | master | 1,327 | ###
# CreateMentions class
#
# This class defines the create mentions migration in mention system
###
class CreateMentions < ActiveRecord::Migration[5.0]
###
# Changes the database
###
def change
###
# Mentions table creation
###
create_table :mentions do |t|
###
# Mentionee id field... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | lib/mention_system/mention_processor.rb | Ruby | mit | 45 | master | 3,416 | ###
# MentionSystem module
#
# This module defines common behavior in mention system
###
module MentionSystem
###
# MentionProcessor class
#
# This class defines mention processor behavior in mention system
###
class MentionProcessor
###
# Constructor of the MentionProcessor class
###
def in... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | lib/mention_system/mention.rb | Ruby | mit | 45 | master | 4,470 | ###
# MentionSystem module
#
# This module defines common behavior in mention system
###
module MentionSystem
###
# Mention class
#
# This class defines the mention model in mention system
###
class Mention < ActiveRecord::Base
###
# Belongs to mentionee association configuration
###
belongs... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | lib/mention_system/mentionee.rb | Ruby | mit | 45 | master | 1,298 | ###
# MentionSystem module
#
# This module defines common behavior in mention system
###
module MentionSystem
###
# Mentionee module
#
# This module defines mentionee behavior in mention system
###
module Mentionee
###
# Extends ActiveSupport::Concern
###
extend ActiveSupport::Concern
#... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | lib/mention_system/mentioner.rb | Ruby | mit | 45 | master | 2,118 | ###
# MentionSystem module
#
# This module defines common behavior in mention system
###
module MentionSystem
###
# Mentioner module
#
# This module defines mentioner behavior in mention system
###
module Mentioner
###
# Extends ActiveSupport::Concern
###
extend ActiveSupport::Concern
#... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | spec/spec_helper.rb | Ruby | mit | 45 | master | 4,891 | require 'support/active_record'
require 'support/shoulda_matchers'
require 'mention_system'
# 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... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | spec/db/migrate/20140926000005_create_dummy_mentioners.rb | Ruby | mit | 45 | master | 428 | ###
# CreateDummyMentioners class
#
# This class defines the create dummy mentioners migration in mention system
###
class CreateDummyMentioners < ActiveRecord::Migration[5.0]
###
# Changes the database
###
def change
###
# Dummy mentioners table creation
###
create_table :dummy_mentioners do |t... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | spec/db/migrate/20140926000010_create_dummy_mentionees.rb | Ruby | mit | 45 | master | 428 | ###
# CreateDummyMentionees class
#
# This class defines the create dummy mentionees migration in mention system
###
class CreateDummyMentionees < ActiveRecord::Migration[5.0]
###
# Changes the database
###
def change
###
# Dummy mentionees table creation
###
create_table :dummy_mentionees do |t... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | spec/db/migrate/20140926000000_create_mentions.rb | Ruby | mit | 45 | master | 1,332 | ###
# CreateMentions class
#
# This class defines the test create mentions migration in mention system
###
class CreateMentions < ActiveRecord::Migration[5.0]
###
# Changes the database
###
def change
###
# Mentions table creation
###
create_table :mentions do |t|
###
# Mentionee id ... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | spec/mention_system/mentioner_spec.rb | Ruby | mit | 45 | master | 2,307 | require 'spec_helper'
###
# Shared examples for MentionSystem::Mentioner
###
shared_examples_for MentionSystem::Mentioner do
###
# Let mentionee be DummyMentionee.create
###
let(:mentionee) { DummyMentionee.create }
###
# Let mentioner be DummyMentioner.create
###
let(:mentioner) { DummyMentioner.crea... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | spec/mention_system/mention_processor_spec.rb | Ruby | mit | 45 | master | 5,481 | require 'spec_helper'
###
# Describes MentionSystem::MentionProcessor
###
describe MentionSystem::MentionProcessor do
###
# Let mention_processor be MentionSystem::MentionProcessor.new
###
let(:mention_processor) { MentionSystem::MentionProcessor.new }
###
# Let mentionee be DummyMentionee.create
###
... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | spec/mention_system/mentionee_spec.rb | Ruby | mit | 45 | master | 1,540 | require 'spec_helper'
###
# Shared examples for MentionSystem::Mentionee
###
shared_examples_for MentionSystem::Mentionee do
###
# Let mentionee be DummyMentionee.create
###
let(:mentionee) { DummyMentionee.create }
###
# Let mentioner be DummyMentioner.create
###
let(:mentioner) { DummyMentioner.crea... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | spec/mention_system/mention_spec.rb | Ruby | mit | 45 | master | 5,071 | require 'spec_helper'
###
# Describes MentionSystem::Mention
###
describe MentionSystem::Mention, type: :model do
###
# Let mentionee be DummyMentionee.create
###
let(:mentionee) { DummyMentionee.create }
###
# Let mentioner be DummyMentioner.create
###
let(:mentioner) { DummyMentioner.create }
###... |
github | pmviva/mention_system | https://github.com/pmviva/mention_system | spec/support/active_record.rb | Ruby | mit | 45 | master | 294 | require 'active_record'
###
# Active record database configuration
###
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
###
# Active record migrator configuration
###
ActiveRecord::MigrationContext.new('spec/db/migrate', ActiveRecord::SchemaMigration).migrate |
github | jm/stump | https://github.com/jm/stump | stump.gemspec | Ruby | mit | 45 | master | 1,177 | Gem::Specification.new do |s|
s.name = "stump"
s.version = "0.0.2"
s.date = "2008-10-30"
s.summary = "Stubbing and mocking that isn't painful."
s.email = "jeremy@entp.com"
s.homepage = "http://github.com/jeremymcanally/stump"
s.description = "Stubbing and mocking that isn't painful, fanciful,... |
github | jm/stump | https://github.com/jm/stump | test/test_stub.rb | Ruby | mit | 45 | master | 1,693 | require File.dirname(__FILE__) + '/test_helper.rb'
class TestStub < Test::Unit::TestCase
def setup
end
def test_stub_is_set
stub_me = MyStump.new
assert_nothing_raised do
stub_me.stub!(:pants)
stub_me.pants
end
end
def test_stub_value_is_returned
stub_me = MyStump.new
... |
github | jm/stump | https://github.com/jm/stump | test/test_mock.rb | Ruby | mit | 45 | master | 2,199 | require File.dirname(__FILE__) + '/test_helper.rb'
class TestMock < Test::Unit::TestCase
def setup
end
def test_mock_is_set
mock_me = MyStump.new
assert_nothing_raised do
mock_me.mock!(:pants)
mock_me.pants
end
end
def test_mock_value_is_returned
mock_me = MyStump.new
... |
github | jm/stump | https://github.com/jm/stump | test/test_proxy.rb | Ruby | mit | 45 | master | 2,566 | require File.dirname(__FILE__) + '/test_helper.rb'
class ProxyPants
def method_missing(method_name, arguments)
if method_name.to_s =~ /fun_/
return "whoo #{method_name} party!!"
else
super
end
end
end
class TestProxy < Test::Unit::TestCase
def setup
end
def test_proxy_is_set
p... |
github | jm/stump | https://github.com/jm/stump | test/test_helper.rb | Ruby | mit | 45 | master | 236 | require 'test/unit'
require File.dirname(__FILE__) + '/../lib/stump'
class MyStump
def tree
"oak"
end
def trunk(name)
return name.upcase
end
def branch(factor, initial = 1)
return factor * initial
end
end |
github | jm/stump | https://github.com/jm/stump | config/hoe.rb | Ruby | mit | 45 | master | 2,508 | require 'stump/version'
AUTHOR = 'Jeremy McAnally' # can also be an array of Authors
EMAIL = "jeremy@entp.com"
DESCRIPTION = "Stubbing and mocking that isn't painful."
GEM_NAME = 'stump' # what ppl will type to install your gem
RUBYFORGE_PROJECT = 'stump' # The unix name for your project
HOMEPATH = "http://#{RUBYFORG... |
github | jm/stump | https://github.com/jm/stump | lib/stump.rb | Ruby | mit | 45 | master | 306 | $:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
require 'stump/version'
require 'stump/metaid'
require 'stump/core_ext/test_case'
require 'stump/stub'
require 'stump/mocks'
require 'stump/mock'
require 'stump/proxy' |
github | jm/stump | https://github.com/jm/stump | lib/stump/proxy.rb | Ruby | mit | 45 | master | 3,582 | class Object
# Creates a proxy method on an object. In this setup, it places an expectation on an object (like a mock)
# but still calls the original method. So if you want to make sure the method is called and still return
# its value, or simply want to invoke the side effects of a method and return a stubbed ... |
github | jm/stump | https://github.com/jm/stump | lib/stump/stub.rb | Ruby | mit | 45 | master | 827 | class Object
# Create a stub method on an object. Simply returns a value for a method call on
# an object.
#
# ==== Examples
#
# my_string = "a wooden rabbit"
# my_string.stub!(:retreat!, :return => "run away! run away!")
#
# # test/your_test.rb
# my_string.retreat! # => "run a... |
github | jm/stump | https://github.com/jm/stump | lib/stump/mock.rb | Ruby | mit | 45 | master | 1,620 | class Object
# Create a mock method on an object. A mock object will place an expectation
# on behavior and cause a test failure if it's not fulfilled.
#
# ==== Examples
#
# my_string = "a wooden rabbit"
# my_string.mock!(:retreat!, :return => "run away! run away!")
# my_string.mock!(:questi... |
github | jm/stump | https://github.com/jm/stump | lib/stump/mocks.rb | Ruby | mit | 45 | master | 377 | module Stump
# A class to track the mocks and proxies that have been satisfied
class Mocks
class <<self
def add(mock)
@mocks ||= []
@mocks << mock
end
def verify(mock)
@mocks.delete(mock)
end
def failures
@mocks
end
d... |
github | jm/stump | https://github.com/jm/stump | lib/stump/metaid.rb | Ruby | mit | 45 | master | 481 | # thanks _why
# http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html
class Object
# The hidden singleton lurks behind everyone
def metaclass; class << self; self; end; end
def meta_eval &blk; metaclass.instance_eval &blk; end
# Adds methods to a metaclass
def meta_def name, &blk
meta_eval {... |
github | jm/stump | https://github.com/jm/stump | lib/stump/core_ext/test_case.rb | Ruby | mit | 45 | master | 482 | module Test
module Unit
class TestCase
def stumpdown!
begin
if !Stump::Mocks.failures.nil? && !Stump::Mocks.failures.empty?
fails = Stump::Mocks.failures.map {|object, method| "#{object.inspect} expected #{method}"}.join(", ")
flunk "Unmet expectations: #... |
github | tkersey/isbn | https://github.com/tkersey/isbn | isbn.gemspec | Ruby | mit | 45 | master | 870 | # -*- encoding: utf-8 -*-
$:.unshift("lib") unless $:.include?("lib")
version = open("VERSION").read.strip
Gem::Specification.new do |s|
s.name = "isbn"
s.version = version
s.date = Time.now.strftime('%Y-%m-%d')
s.summary = %Q{a simple library of functions on ISBN... |
github | tkersey/isbn | https://github.com/tkersey/isbn | Rakefile | Ruby | mit | 45 | master | 596 | $:.unshift("lib") unless $:.include?("lib")
version = open("VERSION").read.strip
desc "Build, Install and Cleanup gem"
task :install do
`gem build isbn.gemspec`
`gem install isbn-#{version}.gem`
`rm isbn-#{version}.gem`
end
task :default => :test
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
te... |
github | tkersey/isbn | https://github.com/tkersey/isbn | test/isbn_spec.rb | Ruby | mit | 45 | master | 4,304 | require "minitest/spec"
require_relative "../lib/isbn"
MiniTest.autorun
describe ISBN do
ISBNS = [ ["0820472670","9780820472676"], ["0763740381","9780763740382"], ["0547168292","9780547168296"],
["0415990793","9780415990790"], ["1596670274","9781596670273"], ["0618800565","9780618800568"],
[... |
github | tkersey/isbn | https://github.com/tkersey/isbn | lib/isbn.rb | Ruby | mit | 45 | master | 3,146 | module ISBN
extend self
def ten(isbn)
raise InvalidISBNError unless isbn.is_a? String
isbn = isbn.delete("-")
raise No10DigitISBNAvailable if isbn =~ /^979/
case isbn.size
when 10 then isbn = isbn[0..8]
when 13 then isbn = isbn[/(?:^978|^290)*(.{9})\w/,1]
else raise Invalid10DigitISBN... |
github | marcoroth/turbo-ruby | https://github.com/marcoroth/turbo-ruby | Gemfile | Ruby | mit | 45 | main | 201 | # frozen_string_literal: true
source "https://rubygems.org"
# Specify your gem's dependencies in turbo-ruby.gemspec
gemspec
gem "rake", "~> 13.0"
gem "minitest", "~> 5.0"
gem "rubocop", "~> 1.21" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.