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 | Sutto/api_smith | https://github.com/Sutto/api_smith | spec/api_smith/base_spec.rb | Ruby | mit | 214 | master | 539 | require 'spec_helper'
describe APISmith::Base do
it 'should be a class' do
APISmith::Base.should be_a(Class)
end
it 'should mixin the client' do
APISmith::Base.should be < APISmith::Client
end
it 'should mixin httparty' do
APISmith::Base.should be < HTTParty
end
it 'should work in classes... |
github | Sutto/api_smith | https://github.com/Sutto/api_smith | spec/api_smith/client_spec.rb | Ruby | mit | 214 | master | 7,910 | require 'spec_helper'
describe APISmith::Client do
let(:client_klass) do
Class.new do
include APISmith::Client
base_uri "http://sham.local"
end
end
let(:client) { client_klass.new }
describe 'instrumentation' do
subject do
Class.new(client_klass) do
def instrument_reque... |
github | Sutto/api_smith | https://github.com/Sutto/api_smith | lib/api_smith.rb | Ruby | mit | 214 | master | 355 | # Provides a simple set of tools built on top of Hashie and HTTParty to make
# it easier to build clients for different apis.
# @see APISmith::Smash
# @see APISmith::Base
#
# @author Darcy Laycock
# @author Steve Webb
module APISmith
require 'api_smith/version'
require 'api_smith/smash'
require 'api_smith/clien... |
github | Sutto/api_smith | https://github.com/Sutto/api_smith | lib/api_smith/web_mock_extensions.rb | Ruby | mit | 214 | master | 1,678 | module APISmith
# A set of extensions to make using APISmith with WebMock (or most test utilities in general)
# simpler when it comes checking values. Please note this is primarily intended for use with
# rspec due to dependence on subject in some places.
#
# @author Darcy Laycock
# @author Steve Webb
mod... |
github | Sutto/api_smith | https://github.com/Sutto/api_smith | lib/api_smith/smash.rb | Ruby | mit | 214 | master | 8,157 | require 'hashie/dash'
module APISmith
# Extends Hashie::Dash to suppress unknown keys when passing data, but
# is configurable to raises an UnknownKey exception when accessing keys in the
# Smash.
#
# APISmith::Smash is a subclass of Hashie::Dash that adds several features
# making it suitable for use in w... |
github | Sutto/api_smith | https://github.com/Sutto/api_smith | lib/api_smith/client.rb | Ruby | mit | 214 | master | 13,641 | require 'httparty'
module APISmith
# A mixin providing the base set of functionality for building API clients.
#
# @see InstanceMethods
# @see ClassMethods
# @see HTTParty
#
# @author Darcy Laycock
# @author Steve Webb
module Client
# Hooks into the mixin process to add HTTParty and the two API... |
github | Sutto/api_smith | https://github.com/Sutto/api_smith | lib/api_smith/base.rb | Ruby | mit | 214 | master | 516 | require 'api_smith/client'
module APISmith
# A base class for building api clients (with a specified endpoint and general
# shared options) on top of HTTParty, including response unpacking and transformation.
#
# Used to convert APISmith::Client to a class (versus a mixin), making it useable
# in certain oth... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | Rakefile | Ruby | mit | 214 | master | 491 | require "rake/testtask"
require "rdoc/task"
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList["test/**/*_test.rb"]
end
RDoc::Task.new do |rdoc|
rdoc.rdoc_files.include("README.rdoc", "lib")
rdoc.main = "README.rdoc"
rdoc.title = "WaveFile Gem - Read/Write *.wav Files with Ruby"
rdoc.marku... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | wavefile.gemspec | Ruby | mit | 214 | master | 1,037 | $:.push File.expand_path("../lib", __FILE__)
require "wavefile"
Gem::Specification.new do |s|
s.name = "wavefile"
s.version = WaveFile::VERSION
s.author = "Joel Strait"
s.email = "joel dot strait at Google's popular web mail service"
s.homepage = "https://wavefilegem.com/"
s.platform = Gem::Platform::RUBY
... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | examples/generate_square_wave.rb | Ruby | mit | 214 | master | 304 | require 'wavefile'
include WaveFile
Writer.new("square.wav", Format.new(:mono, :pcm_16, 44100)) do |writer|
samples = ([0.5] * 100) + ([-0.5] * 100)
buffer_format = Format.new(:mono, :float, 44100)
220.times do
buffer = Buffer.new(samples, buffer_format)
writer.write(buffer)
end
end |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | examples/info.rb | Ruby | mit | 214 | master | 3,280 | require 'wavefile'
include WaveFile
file_name = ARGV[0]
if file_name.nil?
puts "No file name given."
exit
end
begin
reader = Reader.new(file_name)
audio_format = reader.native_format.audio_format
if !reader.native_format.sub_audio_format_guid.nil?
if reader.native_format.sub_audio_format_guid == SUB_FO... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | examples/append.rb | Ruby | mit | 214 | master | 231 | require 'wavefile'
include WaveFile
Writer.new("append.wav", Format.new(:mono, :pcm_16, 44100)) do |writer|
ARGV.each do |file_name|
Reader.new(file_name).each_buffer do |buffer|
writer.write(buffer)
end
end
end |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | test/unvalidated_format_test.rb | Ruby | mit | 214 | master | 15,841 | require "minitest/autorun"
require "wavefile"
include WaveFile
class UnvalidatedFormatTest < Minitest::Test
def test_initialize
format = UnvalidatedFormat.new({:audio_format => 65534,
:sub_audio_format_guid => SUB_FORMAT_GUID_PCM,
:channels... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | test/format_test.rb | Ruby | mit | 214 | master | 11,995 | require "minitest/autorun"
require "wavefile"
include WaveFile
class FormatTest < Minitest::Test
def test_valid_channels
[1, 2, 3, 4, 65535].each do |valid_channels|
assert_equal(valid_channels, Format.new(valid_channels, :pcm_16, 44100).channels)
end
assert_equal(1, Format.new(:mono, :pcm_16, 44... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | test/writer_test.rb | Ruby | mit | 214 | master | 17,808 | require "minitest/autorun"
require "wavefile"
require "wavefile_io_test_helper"
include WaveFile
class WriterTest < Minitest::Test
include WaveFileIOTestHelper
OUTPUT_FOLDER = "test/fixtures/actual_output"
def setup
# Make the output folder if it doesn't already exist
Dir.mkdir(OUTPUT_FOLDER) unless F... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | test/sampler_loop_test.rb | Ruby | mit | 214 | master | 7,938 | require "minitest/autorun"
require "wavefile"
include WaveFile
class SamplerLoopTest < Minitest::Test
def test_missing_keywords
assert_raises(ArgumentError) { SamplerLoop.new }
end
def test_valid_id
[0, 10, 4_294_967_295].each do |valid_value|
sampler_loop = SamplerLoop.new(id: valid_value,
... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | test/reader_test.rb | Ruby | mit | 214 | master | 62,577 | require "minitest/autorun"
require "wavefile"
require "wavefile_io_test_helper"
include WaveFile
class ReaderTest < Minitest::Test
include WaveFileIOTestHelper
FIXTURE_ROOT_PATH = "test/fixtures/wave"
def test_nonexistent_file
assert_raises(Errno::ENOENT) { Reader.new(fixture_path("i_do_not_exist.wav")) ... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | test/smpte_timecode_test.rb | Ruby | mit | 214 | master | 3,380 | require "minitest/autorun"
require "wavefile"
include WaveFile
class SMPTETimecodeTest < Minitest::Test
VALID_8_BIT_SIGNED_INTEGER_TEST_VALUES = [0, 1, -1, -128, 127]
INVALID_8_BIT_SIGNED_INTEGER_TEST_VALUES = ["dsfsfsdf", :foo, -129, 128, 2.5, 2.0, -2.0, [10], nil]
VALID_8_BIT_UNSIGNED_INTEGER_TEST_VALUES = [0... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | test/buffer_test.rb | Ruby | mit | 214 | master | 23,054 | require "minitest/autorun"
require "wavefile"
require "wavefile_io_test_helper"
include WaveFile
class BufferTest < Minitest::Test
include WaveFileIOTestHelper
def test_convert
old_format = Format.new(:mono, :pcm_16, 44100)
new_format = Format.new(:stereo, :pcm_16, 22050)
old_buffer = Buffer.new([-1... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | test/wavefile_io_test_helper.rb | Ruby | mit | 214 | master | 4,460 | module WaveFileIOTestHelper
CHANNEL_ALIAS = {mono: 1, stereo: 2, tri: 3}
SUPPORTED_BITS_PER_SAMPLE = {
pcm: [8, 16, 24, 32].freeze,
float: [32, 64].freeze,
}.freeze
SQUARE_WAVE_CYCLE = {}
SQUARE_WAVE_CYCLE[:mono] = {... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | test/duration_test.rb | Ruby | mit | 214 | master | 4,244 | require "minitest/autorun"
require "wavefile"
include WaveFile
class DurationTest < Minitest::Test
SECONDS_IN_MINUTE = 60
SECONDS_IN_HOUR = SECONDS_IN_MINUTE * 60
def test_constructor
# Test common sample rates (22050 and 44100), and some crazy arbitrary sample rate (12346)
[22050, 44100, 12346].each d... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | test/sampler_info_test.rb | Ruby | mit | 214 | master | 13,425 | require "minitest/autorun"
require "wavefile"
include WaveFile
class SamplerInfoTest < Minitest::Test
VALID_32_BIT_INTEGER_TEST_VALUES = [0, 10, 4_294_967_295]
INVALID_32_BIT_INTEGER_TEST_VALUES = ["dsfsfsdf", :foo, -1, 4_294_967_296, 2.5, 2.0, [10], nil]
def test_missing_keywords
assert_raises(ArgumentErr... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | test/chunk_readers/format_chunk_reader_test.rb | Ruby | mit | 214 | master | 4,955 | require "minitest/autorun"
require "wavefile"
include WaveFile
include WaveFile::ChunkReaders
class FormatChunkReaderTest < Minitest::Test
def test_basic_pcm_no_extension
io = StringIO.new
io.write([1].pack(UNSIGNED_INT_16)) # Audio format
io.write([2].pack(UNSIGNED_INT_16)) # Channels
io.write(... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile.rb | Ruby | mit | 214 | master | 1,505 | require "wavefile/buffer"
require "wavefile/chunk_readers"
require "wavefile/duration"
require "wavefile/format"
require "wavefile/reader"
require "wavefile/sampler_info"
require "wavefile/sampler_loop"
require "wavefile/smpte_timecode"
require "wavefile/unvalidated_format"
require "wavefile/writer"
module WaveFile
... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/smpte_timecode.rb | Ruby | mit | 214 | master | 2,622 | module WaveFile
# Public: Error that is raised when constructing a SMPTETimecode instance that is not valid.
# Valid means that each field is in the range that can be encoded in a *.wav file, but not
# not necessarily semantically correct. For example, a SMPTETimecode field can be constructed
# with a hours val... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/reader.rb | Ruby | mit | 214 | master | 8,702 | module WaveFile
# Public: Error that is raised when trying to read from a Reader instance that has been closed.
class ReaderClosedError < IOError; end
# Public: Provides the ability to read sample data out of a wave file, as well as query
# a wave file about its metadata (e.g. number of channels, sample rate, ... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/unvalidated_format.rb | Ruby | mit | 214 | master | 2,971 | module WaveFile
# Represents information about the data format for a Wave file, such as number of
# channels, bits per sample, sample rate, and so forth. A Format instance is used
# by Reader to indicate what format to read samples out as, and by Writer to
# indicate what format to write samples as.
class Unv... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/chunk_readers.rb | Ruby | mit | 214 | master | 328 | require "wavefile/chunk_readers/riff_reader"
require "wavefile/chunk_readers/base_chunk_reader"
require "wavefile/chunk_readers/format_chunk_reader"
require "wavefile/chunk_readers/data_chunk_reader"
require "wavefile/chunk_readers/sample_chunk_reader"
module WaveFile
# Internal
module ChunkReaders # :nodoc:
... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/buffer.rb | Ruby | mit | 214 | master | 10,361 | module WaveFile
# Public: Error that is raised when an attempt is made to perform an unsupported or
# undefined conversion between two sample data formats. For example, converting a Buffer
# with 4 channels into a Buffer with 3 channels is undefined.
class BufferConversionError < StandardError; end
# Public... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/sampler_info.rb | Ruby | mit | 214 | master | 8,627 | module WaveFile
# Public: Error that is raised when constructing a SamplerInfo instance that is invalid.
# "Invalid" means that one or more fields have a value that can't be encoded in the
# field inside a *.wav file. For example, there's no way to encode "-23" as a value
# for the midi_... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/format.rb | Ruby | mit | 214 | master | 11,134 | module WaveFile
# Public: Error that is raised when a file is not in a format supported by this Gem.
# For example, because it's a valid Wave file whose format is not supported by
# this Gem. Or, because it's a not a valid Wave file period.
class FormatError < StandardError; end
# Public: Error that is raise... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/writer.rb | Ruby | mit | 214 | master | 13,664 | module WaveFile
# Public: Error that is raised when trying to write to a Writer instance that has been closed.
class WriterClosedError < IOError; end
# Public: Provides the ability to write data to a wave file.
#
# When a Writer is constructed it can be given a block. All samples should be written inside thi... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/sampler_loop.rb | Ruby | mit | 214 | master | 6,448 | module WaveFile
# Public: Error that is raised when constructing a SamplerLoop instance that is invalid.
# "Invalid" means that one or more fields have a value that can't be encoded in the
# field inside a *.wav file. For example, there's no way to encode "-23" as a value
# for the start... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/duration.rb | Ruby | mit | 214 | master | 3,975 | module WaveFile
# Public: Calculates playback time given the number of sample frames and the sample rate.
# For example, you can use this to calculate how long a given Wave file is.
#
# The hours, minutes, seconds, and milliseconds fields return values like you would
# see on a stopwatch, and not the total am... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/chunk_readers/format_chunk_reader.rb | Ruby | mit | 214 | master | 2,386 | module WaveFile
module ChunkReaders
# Internal
class FormatChunkReader < BaseChunkReader # :nodoc:
def initialize(io, chunk_size)
@io = io
@chunk_size = chunk_size
end
def read
if @chunk_size < MINIMUM_CHUNK_SIZE
raise_error InvalidFormatError, "The form... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/chunk_readers/base_chunk_reader.rb | Ruby | mit | 214 | master | 623 | module WaveFile
module ChunkReaders
# Internal
class BaseChunkReader # :nodoc:
def read_entire_chunk_body(chunk_id)
raw_bytes = @io.read(@chunk_size)
if raw_bytes.nil?
raw_bytes = ""
end
if raw_bytes.length < @chunk_size
raise_error InvalidFormatEr... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/chunk_readers/data_chunk_reader.rb | Ruby | mit | 214 | master | 3,162 | module WaveFile
module ChunkReaders
# Internal
class DataChunkReader < BaseChunkReader # :nodoc:
def initialize(io, chunk_size, raw_native_format, format=nil)
@io = io
@raw_native_format = raw_native_format
@total_sample_frames = chunk_size / @raw_native_format.block_align
... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/chunk_readers/sample_chunk_reader.rb | Ruby | mit | 214 | master | 2,494 | module WaveFile
module ChunkReaders
# Internal
class SampleChunkReader < BaseChunkReader # :nodoc:
def initialize(io, chunk_size)
@io = io
@chunk_size = chunk_size
end
def read
if @chunk_size < CORE_BYTE_COUNT
raise_error InvalidFormatError, "The sample ... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | lib/wavefile/chunk_readers/riff_reader.rb | Ruby | mit | 214 | master | 3,803 | module WaveFile
module ChunkReaders
# Internal: Used to read the RIFF chunks in a wave file up until the data chunk. Thus it
# can be used to open a wave file and "queue it up" to the start of the actual sample data,
# as well as extract information out of pre-data chunks, such as the format chunk.
cl... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | tools/debug.rb | Ruby | mit | 214 | master | 17,237 | CHUNK_BODY_READERS = {
"RIFF" => :read_riff_chunk,
"fmt " => :read_format_chunk,
"fact" => :read_fact_chunk,
"PEAK" => :read_peak_chunk,
"cue " => :read_cue_chunk,
"smpl" => :read_sample_chunk,
"inst" => :read_instrument_chunk,
"LIST" => :read_list_chunk,
"data" => :read_data_chunk,
}
CHUNK_BODY_READE... |
github | jstrait/wavefile | https://github.com/jstrait/wavefile | tools/fixture_writer.rb | Ruby | mit | 214 | master | 10,245 | # This program creates example Wave files that can be used as test fixtures.
# The input YAML directory is recursively searched for YAML files, and each YAML
# file is used to generate a corresponding Wave file.
#
# This program intentionally does not try to validate the input, and will
# happily create invalid Wave fi... |
github | ngauthier/capybara-slow_finder_errors | https://github.com/ngauthier/capybara-slow_finder_errors | capybara-slow_finder_errors.gemspec | Ruby | mit | 214 | master | 843 | # coding: utf-8
Gem::Specification.new do |spec|
spec.name = "capybara-slow_finder_errors"
spec.version = "0.1.5"
spec.authors = ["Nick Gauthier"]
spec.email = ["ngauthier@gmail.com"]
spec.summary = %q{Raises an error when you use a Capybara finder improperly}
spec.descri... |
github | ngauthier/capybara-slow_finder_errors | https://github.com/ngauthier/capybara-slow_finder_errors | lib/capybara/slow_finder_errors.rb | Ruby | mit | 214 | master | 1,012 | # frozen_string_literal: true
require 'capybara'
module Capybara
ADDITIONAL_MESSAGE = 'Timeout reached while running a *waiting* Capybara finder...perhaps you wanted to return immediately? Use a non-waiting Capybara finder. More info: http://blog.codeship.com/faster-rails-tests?utm_source=gem_exception'
module N... |
github | balvig/chili | https://github.com/balvig/chili | Rakefile | Ruby | mit | 214 | main | 382 | #!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
APP_RAKEFILE = File.expand_path("../spec/example_app/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:s... |
github | balvig/chili | https://github.com/balvig/chili | chili.gemspec | Ruby | mit | 214 | main | 1,088 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/chili/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Jens Balvig"]
gem.email = ["jens@balvig.com"]
gem.description = %q{The spicy feature toggle framework}
gem.summary = %q{The spicy feature toggle framework}
... |
github | balvig/chili | https://github.com/balvig/chili | app/controllers/chili/application_controller.rb | Ruby | mit | 214 | main | 265 | module Chili
class ApplicationController < ::ApplicationController
before_filter :activate_feature
private
def activate_feature
raise ActionController::RoutingError, 'Feature Disabled' unless self.class.parent.active?(self)
end
end
end |
github | balvig/chili | https://github.com/balvig/chili | lib/chili.rb | Ruby | mit | 214 | main | 251 | require "deface"
require "chili/base"
require "chili/bundler"
require "chili/engine"
require "chili/feature"
require "chili/overrides"
require "chili/version"
require "generators/chili/generator_proxy"
module Chili
FEATURE_FOLDER = 'lib/chili'
end |
github | balvig/chili | https://github.com/balvig/chili | lib/chili/engine.rb | Ruby | mit | 214 | main | 470 | module Chili
class Engine < ::Rails::Engine
initializer "chili.add_autoload_paths", before: :set_autoload_paths do |app|
app.config.autoload_paths += Dir["#{app.config.root}/#{FEATURE_FOLDER}/*/lib"]
end
initializer 'chili.deface' do |app|
app.config.deface.namespaced = true
end
in... |
github | balvig/chili | https://github.com/balvig/chili | lib/chili/feature.rb | Ruby | mit | 214 | main | 254 | module Chili
class Feature
def initialize(short_name)
@short_name = short_name
end
def name
@short_name.to_s.underscore.gsub('_feature','') + '_feature'
end
def path
"#{FEATURE_FOLDER}/#{name}"
end
end
end |
github | balvig/chili | https://github.com/balvig/chili | lib/chili/base.rb | Ruby | mit | 214 | main | 211 | require "chili/activatable"
require "chili/engine_extensions"
module Chili
module Base
def self.extended(base)
base.extend(Activatable)
base::Engine.extend(EngineExtensions)
end
end
end |
github | balvig/chili | https://github.com/balvig/chili | lib/chili/engine_extensions.rb | Ruby | mit | 214 | main | 714 | module Chili
module EngineExtensions
def self.extended(base)
base.rake_tasks do
next if self.is_a?(Rails::Application)
next unless has_migrations?
namespace railtie_name do
namespace :db do
desc "Copy and migrate migrations from #{railtie_name}"
tas... |
github | balvig/chili | https://github.com/balvig/chili | lib/chili/activatable.rb | Ruby | mit | 214 | main | 283 | module Chili
module Activatable
def self.extended(base)
base.send(:unloadable) if base.respond_to?(:unloadable)
end
def active_if(&block)
@active_if = block
end
def active?(controller)
controller.instance_eval(&@active_if)
end
end
end |
github | balvig/chili | https://github.com/balvig/chili | lib/chili/overrides.rb | Ruby | mit | 214 | main | 482 | module Chili
module Overrides
def self.included(base)
base.send(:include, InstanceMethods)
base.before_filter :activate_overrides
end
module InstanceMethods
def activate_overrides
Deface::Override.all.values.map(&:values).flatten.each do |override|
engine = override.ra... |
github | balvig/chili | https://github.com/balvig/chili | lib/tasks/chili.rake | Ruby | mit | 214 | main | 533 | { spec: 'RSpec::Core::RakeTask', test: 'Rake::TestTask' }.each do |test_lib, rake_task|
if Rake::Task.task_defined?(test_lib)
Rake::Task[test_lib].clear
chili_specs = "#{Chili::FEATURE_FOLDER}/**/#{test_lib}/**/*_#{test_lib}.rb"
task = rake_task.constantize.new(test_lib => 'test:prepare')
task.patte... |
github | balvig/chili | https://github.com/balvig/chili | lib/generators/chili/generator_proxy.rb | Ruby | mit | 214 | main | 638 | module Chili
module GeneratorProxy
def self.included(base)
base.class_eval do
argument :generator, type: :string
argument :generator_options, type: :array, default: [], banner: "GENERATOR_OPTIONS"
def self.desc
"Generates resources (scaffold, model, migration etc) for #{ge... |
github | balvig/chili | https://github.com/balvig/chili | lib/generators/chili/feature/feature_generator.rb | Ruby | mit | 214 | main | 3,841 | module Chili
module Generators
class FeatureGenerator < Rails::Generators::NamedBase
def run_plugin_generator
ARGV[0] = feature.path
ARGV[1] = '--mountable'
ARGV[2] = '--skip-test-unit'
ARGV[3] = '--skip-bundle'
require 'rails/generators'
require 'rails/gene... |
github | balvig/chili | https://github.com/balvig/chili | spec/spec_helper.rb | Ruby | mit | 214 | main | 1,045 | # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../example_app/config/environment", __FILE__)
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rail... |
github | balvig/chili | https://github.com/balvig/chili | spec/generators/chili/feature_generator_spec.rb | Ruby | mit | 214 | main | 1,581 | require 'spec_helper'
describe 'FeatureGenerator' do
describe 'rails g chili:feature NAME' do
let(:app) { DummyApp.new }
let(:template_path) { File.expand_path("../../../dummy/blank_feature", __FILE__) }
before { app.setup! }
it 'creates a new feature with a correct file structure and appends it to... |
github | balvig/chili | https://github.com/balvig/chili | spec/generators/chili/generator_proxy_spec.rb | Ruby | mit | 214 | main | 1,411 | require 'spec_helper'
describe Chili::GeneratorProxy do
let(:app) { DummyApp.new }
before do
app.setup!
puts `cd #{app.path} && rails g chili:feature blank`
end
context 'running generator from a newly created feature' do
it "generates resources properly" do
puts `cd #{app.path} && rails g ... |
github | balvig/chili | https://github.com/balvig/chili | spec/support/dummy_app.rb | Ruby | mit | 214 | main | 347 | class DummyApp
def path
File.expand_path("../../dummy/app", __FILE__)
end
def gemfile
File.join(path, 'Gemfile')
end
def setup!
FileUtils.rm_rf File.join(path, 'lib')
FileUtils.rm_rf gemfile
File.open(gemfile, 'w') do |f|
f.write <<-RUBY
group :development do
gem 'somegem'
end
... |
github | balvig/chili | https://github.com/balvig/chili | spec/example_app/db/schema.rb | Ruby | mit | 214 | main | 1,418 | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative sou... |
github | balvig/chili | https://github.com/balvig/chili | spec/example_app/db/migrate/20120513032032_create_social_feature_likes.rb | Ruby | mit | 214 | main | 275 | # This migration comes from social_feature (originally 20120513031021)
class CreateSocialFeatureLikes < ActiveRecord::Migration
def change
create_table :social_feature_likes do |t|
t.integer :post_id
t.integer :user_id
t.timestamps
end
end
end |
github | balvig/chili | https://github.com/balvig/chili | spec/example_app/config/application.rb | Ruby | mit | 214 | main | 1,049 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
require "chili"
require "social_feature"
require "invites_feature"
module Dummy
class Application ... |
github | balvig/chili | https://github.com/balvig/chili | spec/example_app/config/boot.rb | Ruby | mit | 214 | main | 393 | # Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
$:.unshift File.expand_path('../../../../../lib', __FILE__)
$:.unshift File.expand_path('../../lib/chili/social_feature/lib', __FILE__)
$:.u... |
github | balvig/chili | https://github.com/balvig/chili | spec/example_app/config/initializers/secret_token.rb | Ruby | mit | 214 | main | 659 | # Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to diction... |
github | balvig/chili | https://github.com/balvig/chili | spec/example_app/lib/chili/social_feature/db/migrate/20120513031021_create_social_feature_likes.rb | Ruby | mit | 214 | main | 204 | class CreateSocialFeatureLikes < ActiveRecord::Migration
def change
create_table :social_feature_likes do |t|
t.integer :post_id
t.integer :user_id
t.timestamps
end
end
end |
github | balvig/chili | https://github.com/balvig/chili | spec/example_app/lib/chili/social_feature/app/controllers/social_feature/likes_controller.rb | Ruby | mit | 214 | main | 422 | module SocialFeature
class LikesController < ApplicationController
def index
@likes = current_user.likes
end
def create
@like = current_user.likes.create!(params[:like])
redirect_to :back, notice: 'Post liked!'
end
private
def current_user
super.becomes(SocialFeatur... |
github | balvig/chili | https://github.com/balvig/chili | spec/example_app/app/controllers/application_controller.rb | Ruby | mit | 214 | main | 229 | class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user, :logged_in?
def current_user
User.find_by_id(session[:user_id])
end
def logged_in?
current_user
end
end |
github | balvig/chili | https://github.com/balvig/chili | spec/example_app/app/controllers/sessions_controller.rb | Ruby | mit | 214 | main | 233 | class SessionsController < ApplicationController
def create
session[:user_id] = User.find_by_name(params[:name]).id
redirect_to root_path
end
def destroy
session[:user_id] = nil
redirect_to root_path
end
end |
github | balvig/chili | https://github.com/balvig/chili | spec/example_app/app/controllers/posts_controller.rb | Ruby | mit | 214 | main | 1,927 | class PostsController < ApplicationController
# GET /posts
# GET /posts.json
def index
@posts = Post.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @posts }
end
end
# GET /posts/1
# GET /posts/1.json
def show
@post = Post.find(params[:id])
... |
github | balvig/chili | https://github.com/balvig/chili | spec/example_app/app/controllers/users_controller.rb | Ruby | mit | 214 | main | 1,926 | class UsersController < ApplicationController
# GET /users
# GET /users.json
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @users }
end
end
# GET /users/1
# GET /users/1.json
def show
@user = User.find(params[:id])
... |
github | balvig/chili | https://github.com/balvig/chili | spec/dummy/app/config/application.rb | Ruby | mit | 214 | main | 1,103 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
require "chili"
Dir.glob(File.expand_path('../../lib/chili/*', __FILE__)).each do |dir|
require Fil... |
github | balvig/chili | https://github.com/balvig/chili | spec/dummy/app/config/boot.rb | Ruby | mit | 214 | main | 315 | # Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
$:.unshift File.expand_path('../../../../../lib', __FILE__)
$:.unshift File.expand_path('../../lib/chili/blank_feature/lib', __FILE__) |
github | balvig/chili | https://github.com/balvig/chili | spec/dummy/blank_feature/blank_feature.gemspec | Ruby | mit | 214 | main | 679 | $:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "blank_feature/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "blank_feature"
s.version = BlankFeature::VERSION
s.authors = ["GIT_AUTHOR"]
s.email = ["GIT... |
github | balvig/chili | https://github.com/balvig/chili | spec/chili/activatable_spec.rb | Ruby | mit | 214 | main | 515 | require 'spec_helper'
module Engine
extend Chili::Activatable
end
class DummyController
def logged_in? ; true end
def admin? ; false end
end
describe Chili::Activatable do
describe '#active_if & #active?' do
it "evaluates the active_if block within the context of the instance" do
Engine.active_if {... |
github | balvig/chili | https://github.com/balvig/chili | spec/features/social_feature_spec.rb | Ruby | mit | 214 | main | 1,407 | require 'spec_helper'
feature 'View overrides' do
scenario 'when user is not admin active_if toggles overrides off' do
login User.create!(admin: false)
visit '/posts'
page.should_not have_content('See Your Likes')
page.should_not have_content('Like functionality is in beta')
end
scenario 'when a... |
github | kaspth/active_job-performs | https://github.com/kaspth/active_job-performs | active_job-performs.gemspec | Ruby | mit | 214 | main | 1,129 | # frozen_string_literal: true
require_relative "lib/active_job/performs/version"
Gem::Specification.new do |spec|
spec.name = "active_job-performs"
spec.version = ActiveJob::Performs::VERSION
spec.authors = ["Kasper Timm Hansen"]
spec.email = ["hey@kaspth.com"]
spec.summary = "ActiveJob::Performs adds the ... |
github | kaspth/active_job-performs | https://github.com/kaspth/active_job-performs | Gemfile | Ruby | mit | 214 | main | 357 | # frozen_string_literal: true
source "https://rubygems.org"
# Specify your gem's dependencies in active_job-performs.gemspec
gemspec
gem "rake", "~> 13.0"
gem "minitest", "~> 5.0"
gem "minitest-sprint"
gem "debug"
# Fetch latest Active Job to test `ActiveJob.perform_all_later`
gem "activejob", ">= 7.1"
gem "ac... |
github | kaspth/active_job-performs | https://github.com/kaspth/active_job-performs | lib/active_job/performs.rb | Ruby | mit | 214 | main | 2,543 | # frozen_string_literal: true
require_relative "performs/version"
module ActiveJob; end
module ActiveJob::Performs
module Waiting
attr_reader :wait, :wait_until
def wait=(value)
@wait = normalize_wait(value)
end
def wait_until=(value)
@wait_until = normalize_wait(value)
end
de... |
github | kaspth/active_job-performs | https://github.com/kaspth/active_job-performs | test/test_helper.rb | Ruby | mit | 214 | main | 2,890 | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "active_job"
require "active_job/performs"
require "active_record"
require "debug"
require "minitest/autorun"
# We shouldn't generate the wrapping shared config Job at the top-level.
class Job; end
class ApplicationJob < Ac... |
github | kaspth/active_job-performs | https://github.com/kaspth/active_job-performs | test/active_job/test_performs.rb | Ruby | mit | 214 | main | 3,322 | # frozen_string_literal: true
require "test_helper"
class ActiveJob::TestPerforms < ActiveSupport::TestCase
setup do
Post::Publisher.performed = false
@publisher = Post::Publisher.new(1)
end
test "version number" do
refute_nil ::ActiveJob::Performs::VERSION
end
test "a general job class is def... |
github | kaspth/active_job-performs | https://github.com/kaspth/active_job-performs | test/active_job/active_record/test_performs.rb | Ruby | mit | 214 | main | 2,791 | require "test_helper"
module ActiveJob::ActiveRecord; end
class ActiveJob::ActiveRecord::TestPerforms < ActiveSupport::TestCase
setup { @invoice = Invoice.create! }
test "general job class definition" do
assert defined?(ApplicationRecord::Job)
assert defined?(Invoice::Job)
end
test "touch_later" do
... |
github | jgraichen/rails-timeago | https://github.com/jgraichen/rails-timeago | Gemfile | Ruby | mit | 213 | main | 434 | # frozen_string_literal: true
source 'https://rubygems.org'
# Specify your gem's dependencies in rails-timeago.gemspec
gemspec
group :development do
gem 'rake'
gem 'rake-release'
end
group :test do
gem 'capybara'
gem 'rackup'
gem 'rspec', '~> 3.12'
gem 'rubocop-config', github: 'jgraichen/rubocop-config... |
github | jgraichen/rails-timeago | https://github.com/jgraichen/rails-timeago | Rakefile | Ruby | mit | 213 | main | 1,896 | #!/usr/bin/env rake
# frozen_string_literal: true
require 'fileutils'
require 'pathname'
require 'shellwords'
require 'rake/release'
require 'rspec/core/rake_task'
CLONE_URL = 'https://github.com/rmm5t/jquery-timeago.git'
PATCH_FILE = File.join(__dir__, 'scripts/jquery.timeago.js.patch')
RSpec::Core::RakeTask.new(:... |
github | jgraichen/rails-timeago | https://github.com/jgraichen/rails-timeago | rails-timeago.gemspec | Ruby | mit | 213 | main | 1,480 | # frozen_string_literal: true
require_relative 'lib/rails-timeago/version'
Gem::Specification.new do |spec|
spec.name = 'rails-timeago'
spec.version = Rails::Timeago::VERSION
spec.authors = ['Jan Graichen']
spec.email = ['jgraichen@altimos.de']
spec.summary = 'jQuery Timeago helper for Rails 3'
... |
github | jgraichen/rails-timeago | https://github.com/jgraichen/rails-timeago | lib/rails-timeago.rb | Ruby | mit | 213 | main | 2,135 | # frozen_string_literal: true
require 'rails-timeago/version'
require 'rails-timeago/helper'
module Rails
module Timeago
if defined?(::Rails::Engine)
class Engine < ::Rails::Engine # :nodoc:
initializer 'rails-timeago', group: :all do |_app|
ActiveSupport.on_load(:action_controller) do
... |
github | jgraichen/rails-timeago | https://github.com/jgraichen/rails-timeago | lib/rails-timeago/helper.rb | Ruby | mit | 213 | main | 3,131 | # frozen_string_literal: true
require 'active_support/time'
module Rails
module Timeago
module Helper
# Create a time tag usable for jQuery timeago plugin.
#
# timeago_tag Time.zone.now
# => "<time datetime="2012-03-10T12:07:07+01:00"
# title="Sat, 10 Mar 2012 12:07... |
github | jgraichen/rails-timeago | https://github.com/jgraichen/rails-timeago | lib/rails-timeago/version.rb | Ruby | mit | 213 | main | 280 | # frozen_string_literal: true
module Rails
module Timeago
module VERSION
MAJOR = 2
MINOR = 20
PATCH = 0
STAGE = nil
STRING = [MAJOR, MINOR, PATCH, STAGE].compact.join('.').freeze
def self.to_s
STRING
end
end
end
end |
github | jgraichen/rails-timeago | https://github.com/jgraichen/rails-timeago | spec/spec_helper.rb | Ruby | mit | 213 | main | 549 | # frozen_string_literal: true
require 'active_support'
require 'active_support/core_ext'
require 'capybara'
require 'capybara/rspec'
require 'rails-timeago'
require_relative 'support/stub'
Capybara.app = Application.instance
Capybara.javascript_driver = :selenium_chrome_headless
Capybara.server = :webrick
RSpec.co... |
github | jgraichen/rails-timeago | https://github.com/jgraichen/rails-timeago | spec/timeago_spec.rb | Ruby | mit | 213 | main | 1,130 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'rails-timeago', :js, type: :feature do
subject(:element) { find 'body > time' }
let(:time) { 2.days.ago }
before do
Application.render do |args|
Time.zone = 'UTC'
render.call(*args)
end
end
before { visit '/' }
des... |
github | jgraichen/rails-timeago | https://github.com/jgraichen/rails-timeago | spec/support/stub.rb | Ruby | mit | 213 | main | 2,135 | # frozen_string_literal: true
class TimeagoStub
include Rails::Timeago::Helper
I18n.backend.store_translations :en, hello: 'World'
def time_tag(time, content, options = {})
options = options.map {|k, v| "#{k}=\"#{v}\"" }
"<time datetime=\"#{time.iso8601}\" #{options.join ' '}>#{content}</time>"
end
... |
github | jgraichen/rails-timeago | https://github.com/jgraichen/rails-timeago | spec/timeago/helper_spec.rb | Ruby | mit | 213 | main | 6,472 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Rails::Timeago::Helper do
let(:stub) { TimeagoStub.new }
let(:time) { Time.now }
describe '#timeago_tag' do
subject(:tag) { stub.timeago_tag(time, **kwargs) }
let(:kwargs) { {} }
it 'creates a time tag' do
expect(tag).to mat... |
github | ckruse/CFPropertyList | https://github.com/ckruse/CFPropertyList | Rakefile | Ruby | mit | 213 | master | 524 | require 'rubygems'
require 'rdoc/task'
require 'rake/testtask'
desc 'Generate RDoc documentation for the CFPropertyList module.'
Rake::RDocTask.new do |rdoc|
files = ['README.rdoc', 'LICENSE', 'lib/*.rb', 'lib/**/*.rb']
rdoc.rdoc_files.add(files)
rdoc.main = 'README.rdoc'
rdoc.title = 'CFPropertyList RDoc'
... |
github | ckruse/CFPropertyList | https://github.com/ckruse/CFPropertyList | cfpropertylist.gemspec | Ruby | mit | 213 | master | 1,131 | Gem::Specification.new do |s|
s.name = "CFPropertyList"
s.version = "4.0.0"
s.author = "Christian Kruse"
s.email = "cjk@defunct.ch"
s.homepage = "https://github.com/ckruse/CFPropertyList"
s.license = 'MIT'
s.platform = Gem::Platform::RUBY
s.summary = "Read, write and manipulate both binary and XML prope... |
github | ckruse/CFPropertyList | https://github.com/ckruse/CFPropertyList | lib/cfpropertylist/rbPlainCFPropertyList.rb | Ruby | mit | 213 | master | 4,542 | # -*- coding: utf-8 -*-
require 'strscan'
module CFPropertyList
# XML parser
class PlainParser < XMLParserInterface
# read a XML file
# opts::
# * :file - The filename of the file to load
# * :data - The data to parse
def load(opts)
@doc = nil
if(opts.has_key?(:file)) then
... |
github | ckruse/CFPropertyList | https://github.com/ckruse/CFPropertyList | lib/cfpropertylist/rbCFPlistError.rb | Ruby | mit | 213 | master | 567 | # -*- coding: utf-8 -*-
#
# Exceptions used:
# CFPlistError:: General base exception
# CFFormatError:: Format error
# CFTypeError:: Type error
#
# Easy and simple :-)
#
# Author:: Christian Kruse (mailto:cjk@wwwtech.de)
# Copyright:: Copyright (c) 2010
# License:: MIT License
# general plist error. All exceptions... |
github | ckruse/CFPropertyList | https://github.com/ckruse/CFPropertyList | lib/cfpropertylist/rbNokogiriParser.rb | Ruby | mit | 213 | master | 3,880 | # -*- coding: utf-8 -*-
require 'nokogiri'
module CFPropertyList
# XML parser
class NokogiriXMLParser < ParserInterface
PARSER_OPTIONS = Nokogiri::XML::ParseOptions::NOBLANKS|Nokogiri::XML::ParseOptions::NONET
# read a XML file
# opts::
# * :file - The filename of the file to load
# * :data - ... |
github | ckruse/CFPropertyList | https://github.com/ckruse/CFPropertyList | lib/cfpropertylist/rbBinaryCFPropertyList.rb | Ruby | mit | 213 | master | 18,467 | # -*- coding: utf-8 -*-
require 'stringio'
module CFPropertyList
# Binary PList parser class
class Binary
MAX_DEPTH = 512
# Read a binary plist file
def load(opts)
@unique_table = {}
@count_objects = 0
@object_refs = 0
@written_object_count = 0
@object_table = []
... |
github | ckruse/CFPropertyList | https://github.com/ckruse/CFPropertyList | lib/cfpropertylist/rbLibXMLParser.rb | Ruby | mit | 213 | master | 3,719 | # -*- coding: utf-8 -*-
require 'libxml'
module CFPropertyList
# XML parser
class LibXMLParser < XMLParserInterface
LibXML::XML::Error.set_handler(&LibXML::XML::Error::QUIET_HANDLER)
PARSER_OPTIONS = LibXML::XML::Parser::Options::NOBLANKS|LibXML::XML::Parser::Options::NONET
# read a XML file
# opt... |
github | ckruse/CFPropertyList | https://github.com/ckruse/CFPropertyList | lib/cfpropertylist/rbREXMLParser.rb | Ruby | mit | 213 | master | 3,695 | # -*- coding: utf-8 -*-
require 'rexml/document'
module CFPropertyList
# XML parser
class ReXMLParser < ParserInterface
# read a XML file
# opts::
# * :file - The filename of the file to load
# * :data - The data to parse
def load(opts)
doc = nil
if(opts.has_key?(:file)) then
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.