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
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/recursive_const_methods_spec.rb
Ruby
mit
93
main
1,705
# frozen_string_literal: true require 'rspec/support/recursive_const_methods' module RSpec module Support RSpec.describe RecursiveConstMethods do include described_class module Foo class Parent UNDETECTED = 'Not seen when looking up constants in Bar' end class Bar...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/deprecation_helpers_spec.rb
Ruby
mit
93
main
2,656
# frozen_string_literal: true require 'rspec/matchers/fail_matchers' RSpec.describe RSpecHelpers do def deprecate!(message) RSpec.configuration.reporter.deprecation(:message => message) end def fail_with(snippet) raise_error(RSpec::Mocks::MockExpectationError, snippet) end def raise_unrelated_expe...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/object_formatter_spec.rb
Ruby
mit
93
main
12,096
# frozen_string_literal: true require 'rspec/support/object_formatter' require 'rspec/matchers/fail_matchers' module RSpec module Support RSpec.describe ObjectFormatter, ".format" do context 'with an array object containing other objects for which we have custom formatting' do let(:time) { Time.u...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/with_keywords_when_needed_spec.rb
Ruby
mit
93
main
1,240
# frozen_string_literal: true require 'rspec/support/with_keywords_when_needed' module RSpec::Support RSpec.describe "WithKeywordsWhenNeeded" do describe ".class_exec" do extend RubyFeatures let(:klass) do Class.new do def self.check_argument(argument) raise ArgumentE...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/matcher_definition_spec.rb
Ruby
mit
93
main
1,228
# frozen_string_literal: true module RSpec module Support RSpec.describe "matcher definitions" do RSpec::Matchers.define :fake_matcher do |expected| match { |actual| expected == actual } description { :fake_matcher } end RSpec::Matchers.define :matcher_with_no_description do ...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/source_spec.rb
Ruby
mit
93
main
4,163
# frozen_string_literal: true require 'rspec/support/source' module RSpec::Support RSpec.describe Source, :skip => !RSpec::Support::RubyFeatures.ripper_supported? do subject(:source) do Source.new(source_string) end let(:source_string) { <<-END.gsub(/^ +\|/, '') } |2.times do | puts ...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/fuzzy_matcher_spec.rb
Ruby
mit
93
main
7,105
# frozen_string_literal: true require 'rspec/support/fuzzy_matcher' module RSpec module Support RSpec.describe FuzzyMatcher, ".values_match?" do matcher :match_against do |actual| match { |expected| FuzzyMatcher.values_match?(expected, actual) } end it 'returns true when given equal v...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/caller_filter_spec.rb
Ruby
mit
93
main
2,212
# frozen_string_literal: true require 'fileutils' require 'rspec/support/caller_filter' module RSpec describe CallerFilter do it 'can receive skip_frames and increment arguments' do expect(RSpec::CallerFilter.first_non_rspec_line(1, 5)).to include("#{__FILE__}:#{__LINE__}") end it 'returns the im...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/ruby_features_spec.rb
Ruby
mit
93
main
5,581
# frozen_string_literal: true require 'rspec/support/ruby_features' module RSpec module Support RSpec.describe OS do describe ".windows?" do %w[cygwin mswin mingw bccwin wince emx].each do |fragment| it "returns true when host os is #{fragment}" do stub_const("RbConfig::CONF...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/method_signature_verifier_spec.rb
Ruby
mit
93
main
40,204
# frozen_string_literal: true require 'rspec/support' require 'rspec/support/method_signature_verifier' module RSpec module Support RSpec.describe 'verifying methods' do let(:signature) { MethodSignature.new(test_method) } def valid_non_kw_args?(arity) described_class.new(signature, [nil] *...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/encoded_string_spec.rb
Ruby
mit
93
main
10,490
# encoding: utf-8 # frozen_string_literal: true require 'spec_helper' require 'rspec/support/encoded_string' require 'rspec/support/spec/string_matcher' module RSpec::Support RSpec.describe EncodedString do let(:utf8_encoding) { 'UTF-8' } delegated_methods = String.instance_methods.map(&:to_s) & %w[eql? li...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/directory_maker_spec.rb
Ruby
mit
93
main
1,625
# frozen_string_literal: true require "fileutils" RSpec::Support.require_rspec_support("directory_maker") module RSpec::Support RSpec.describe DirectoryMaker do shared_examples_for "an mkdir_p implementation" do include_context "isolated directory" let(:dirname) { File.join(%w[tmp a recursive stru...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/warnings_spec.rb
Ruby
mit
93
main
2,185
# frozen_string_literal: true require "rspec/support/warnings" require 'rspec/support/spec/shell_out' RSpec.describe "rspec warnings and deprecations" do include RSpec::Support::ShellOut let(:warning_object) do Object.new.tap { |o| o.extend(RSpec::Support::Warnings) } end it 'works when required in isol...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/comparable_version_spec.rb
Ruby
mit
93
main
1,458
# frozen_string_literal: true require 'rspec/support/comparable_version' module RSpec::Support RSpec.describe ComparableVersion do describe '#<=>' do [ ['1.2.3', '1.2.3', 0], ['1.2.4', '1.2.3', 1], ['1.3.0', '1.2.3', 1], ['1.2.3', ...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/reentrant_mutex_spec.rb
Ruby
mit
93
main
2,224
# frozen_string_literal: true require 'rspec/support/reentrant_mutex' require 'thread_order' RSpec.describe RSpec::Support::Mutex do it "allows ::Mutex to be mocked" do expect(Mutex).to receive(:new) ::Mutex.new end end # There are no assertions specifically # They pass if they don't deadlock RSpec.descr...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/differ_spec.rb
Ruby
mit
93
main
17,603
# frozen_string_literal: true require 'timeout' require 'rspec/support/spec/string_matcher' module RSpec module Support RSpec.describe "Differ" do describe '#diff' do let(:differ) { RSpec::Support::Differ.new } it "outputs unified diff of two strings" do expected = "foo\nzap\nba...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/spec/stderr_splitter_spec.rb
Ruby
mit
93
main
3,845
# frozen_string_literal: true require 'rspec/support/spec/stderr_splitter' require 'tempfile' require 'rspec/support/spec/in_sub_process' RSpec.describe 'RSpec::Support::StdErrSplitter' do include RSpec::Support::InSubProcess let(:splitter) { RSpec::Support::StdErrSplitter.new stderr } let(:stderr) { STDERR ...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/spec/with_isolated_std_err_spec.rb
Ruby
mit
93
main
534
# frozen_string_literal: true require 'rspec/support/spec' RSpec.describe 'isolating a spec from the stderr splitter' do include RSpec::Support::WithIsolatedStdErr it 'allows a spec to output a warning' do with_isolated_stderr do $stderr.puts "Imma gonna warn you" end end it 'resets $stderr to...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/spec/shell_out_spec.rb
Ruby
mit
93
main
1,582
# frozen_string_literal: true require 'rspec/support/spec/shell_out' RSpec.describe RSpec::Support::ShellOut, :slow do include described_class it 'shells out and returns stdout and stderr' do stdout, stderr, _ = shell_out("ruby", "-e", "$stdout.print 'yes'; $stderr.print 'no'") expect(stdout).to eq("yes"...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/spec/in_sub_process_spec.rb
Ruby
mit
93
main
1,502
# frozen_string_literal: true require 'tempfile' RSpec.describe 'isolating code to a sub process' do it 'isolates the block from the main process' do in_sub_process do module NotIsolated end expect(defined? NotIsolated).to eq "constant" end expect(defined? NotIsolated).to be_nil end ...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/source/node_spec.rb
Ruby
mit
93
main
3,417
# frozen_string_literal: true require 'rspec/support/source/node' class RSpec::Support::Source RSpec.describe Node, :skip => !RSpec::Support::RubyFeatures.ripper_supported? do let(:root_node) do Node.new(sexp) end let(:sexp) do require 'ripper' Ripper.sexp(source) end let(:so...
github
rspec/rspec
https://github.com/rspec/rspec
rspec-support/spec/rspec/support/source/token_spec.rb
Ruby
mit
93
main
2,294
# frozen_string_literal: true require 'rspec/support/source/token' class RSpec::Support::Source RSpec.describe Token, :skip => !RSpec::Support::RubyFeatures.ripper_supported? do let(:target_token) do tokens.first end let(:tokens) do Token.tokens_from_ripper_tokens(ripper_tokens) end ...
github
andresbravog/params_for
https://github.com/andresbravog/params_for
params_for.gemspec
Ruby
mit
93
master
1,369
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'params_for/version' Gem::Specification.new do |spec| spec.name = "params_for" spec.version = ParamsFor::VERSION spec.authors = ["andresbravog"] spec.email = [...
github
andresbravog/params_for
https://github.com/andresbravog/params_for
lib/params_for.rb
Ruby
mit
93
master
243
require 'active_support/hash_with_indifferent_access' require 'active_model' require 'params_for/version' module ParamsFor autoload :Base, 'params_for/base' module Connectors autoload :Glue, 'params_for/connectors/glue' end end
github
andresbravog/params_for
https://github.com/andresbravog/params_for
lib/params_for/base.rb
Ruby
mit
93
master
2,231
# app/validators/param_validator/base.rb module ParamsFor class Base include ActiveModel::Validations # Memoizes the accessor attributes in the @attributes variable to be able # to list them and access them # def self.attr_accessor(*vars) @attributes ||= [] @attributes.concat vars ...
github
andresbravog/params_for
https://github.com/andresbravog/params_for
lib/params_for/connectors/glue.rb
Ruby
mit
93
master
1,731
require 'active_support/concern' module ParamsFor module Connectors module Glue extend ActiveSupport::Concern module ClassMethods # Define params for and before_action all in the same method # # @param name [Symbol] camelcased validator class name # @param options [Ha...
github
andresbravog/params_for
https://github.com/andresbravog/params_for
spec/spec_helper.rb
Ruby
mit
93
master
395
$LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'params_for' require 'rspec' require 'pry' # Requires support files Dir[File.join(File.dirname(__FILE__), 'shared/**/*.rb')].each {|f| require f} RSpec.configure do |config| config.include Rack::Tes...
github
andresbravog/params_for
https://github.com/andresbravog/params_for
spec/shared/support/dummy_controller.rb
Ruby
mit
93
master
1,361
require 'action_controller' require 'params_for' require 'ostruct' module Rails def self.application @application ||= begin routes = ActionDispatch::Routing::RouteSet.new OpenStruct.new(:routes => routes, :env_config => {}) end end def self.app application end end module ControllerExa...
github
andresbravog/params_for
https://github.com/andresbravog/params_for
spec/params_for/base_spec.rb
Ruby
mit
93
master
2,794
require 'spec_helper' describe ParamsFor::Base do let(:validator_klass) do unless defined?(DummyValidator) class DummyValidator < ParamsFor::Base attr_accessor :id, :name, :type validates :type, inclusion: { in: %w{task project}, allow_nil: true } end end DummyValidator en...
github
andresbravog/params_for
https://github.com/andresbravog/params_for
spec/params_for/connectors/glue_spec.rb
Ruby
mit
93
master
1,162
require 'json' require 'spec_helper' describe DummyController, type: :controller do describe '.params_for' do it 'defines a before_action with given attributes' it 'defines a instance method to retrieve the params' it 'uses the class option if given' end describe '.index' do let(:valid_params) ...
github
joshuaclayton/polylines
https://github.com/joshuaclayton/polylines
polylines.gemspec
Ruby
mit
93
master
718
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "polylines/version" Gem::Specification.new do |s| s.name = "polylines" s.version = Polylines::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Josh Clayton"] s.email = ["joshua.clayton@gmail.com"] s...
github
joshuaclayton/polylines
https://github.com/joshuaclayton/polylines
Rakefile
Ruby
mit
93
master
200
require "rake" require "rake/tasklib" require 'bundler' Bundler::GemHelper.install_tasks Bundler.require require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:rspec) task :default => [:rspec]
github
joshuaclayton/polylines
https://github.com/joshuaclayton/polylines
spec/polylines/encoder_spec.rb
Ruby
mit
93
master
1,662
require "spec_helper" describe Polylines::Encoder, ".encode" do it "encodes a single point" do expect(Polylines::Encoder.encode(-179.9832104)).to eq "`~oia@" end it "encodes a single point with 1e6 precision" do expect(Polylines::Encoder.encode(-179.9832104, 1e6)).to eq "ruhhvI" end end describe Poly...
github
joshuaclayton/polylines
https://github.com/joshuaclayton/polylines
spec/polylines/decoder_spec.rb
Ruby
mit
93
master
1,737
require "spec_helper" describe Polylines::Decoder, ".decode" do it "decodes a single point" do expect(Polylines::Decoder.decode("`~oia@")).to be_within(0.00001).of(-179.9832104) end it "decodes a single point with 1e6 precision" do expect(Polylines::Decoder.decode("ruhhvI", 1e6)).to be_within(0.000001)....
github
joshuaclayton/polylines
https://github.com/joshuaclayton/polylines
lib/polylines/encoder.rb
Ruby
mit
93
master
614
module Polylines class Encoder < Base def self.encode_points(points, precision = 1e5) points_with_deltas = transform_to_array_of_lat_lng_and_deltas(points, precision) points_with_deltas.map {|point| encode(point, precision) }.join end def self.encode(number, precision = 1e5) self.new(nu...
github
joshuaclayton/polylines
https://github.com/joshuaclayton/polylines
lib/polylines/base.rb
Ruby
mit
93
master
2,970
module Polylines class Base attr_reader :current_value, :negative def initialize(current_value) @current_value = current_value end def step_2(precision = 1e5) @negative = current_value < 0 if encoding? encode! { (current_value * precision).round } decode! { current_value.to_...
github
joshuaclayton/polylines
https://github.com/joshuaclayton/polylines
lib/polylines/decoder.rb
Ruby
mit
93
master
923
module Polylines class Decoder < Base def self.decode_polyline(polyline, precision = 1e5) points_with_deltas = transform_to_array_of_lat_lng_and_deltas(polyline, precision) [].tap do |points| points << [points_with_deltas.shi...
github
maccman/stitch-rb
https://github.com/maccman/stitch-rb
stitch.gemspec
Ruby
mit
93
master
618
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "stitch/version" Gem::Specification.new do |s| s.name = "stitch-rb" s.version = Stitch::VERSION s.authors = ["Alex MacCaw"] s.email = ["maccman@gmail.com"] s.homepage = "" s.summary = %q{Stitch ported...
github
maccman/stitch-rb
https://github.com/maccman/stitch-rb
examples/compile.rb
Ruby
mit
93
master
258
$: << File.join(File.dirname(__FILE__), *%w[.. lib]) require "stitch" # puts Stitch::Package.new(:paths => ["app"], :dependencies => ["lib"]).compile puts Stitch::Package.new(:files => ["./app/index.js"], :root => './app', :dependencies => ["lib"]).compile
github
maccman/stitch-rb
https://github.com/maccman/stitch-rb
test/test_source.rb
Ruby
mit
93
master
1,451
require File.dirname(__FILE__) + "/test_helper.rb" class TestSource < Test::Unit::TestCase FIXTURES = Pathname.new(File.join(File.dirname(__FILE__), "fixtures")) def setup end def test_from_file sources = Stitch::Source.from_file(FIXTURES + "app" + "index.js") sources = sources.map {|s| s.path.relati...
github
maccman/stitch-rb
https://github.com/maccman/stitch-rb
test/test_stitch.rb
Ruby
mit
93
master
430
require File.dirname(__FILE__) + '/test_helper.rb' class TestJasmine < Test::Unit::TestCase def setup end def test_stitch root = File.dirname(__FILE__) File.open(root + '/jasmine/index.js', 'w+') do |f| f.write Stitch::Package.new( :files => [root + '/fixtures/app/index.js'], :root...
github
maccman/stitch-rb
https://github.com/maccman/stitch-rb
lib/stitch.rb
Ruby
mit
93
master
240
require "rubygems" require "json" require "stitch/version" module Stitch autoload :Compiler, "stitch/compiler" autoload :Package, "stitch/package" autoload :Source, "stitch/source" autoload :Server, "stitch/server" end
github
maccman/stitch-rb
https://github.com/maccman/stitch-rb
lib/stitch/compiler.rb
Ruby
mit
93
master
1,230
module Stitch class Compiler class << self def compilers @compilers ||= [] end def inherited(child) Compiler.compilers.unshift(child) end def all Compiler.compilers.select {|c| c.enabled? } end def all_extensions Compiler.all.map {|c| c....
github
maccman/stitch-rb
https://github.com/maccman/stitch-rb
lib/stitch/server.rb
Ruby
mit
93
master
215
module Stitch class Server def initialize(options = {}) @package = Package.new(options) end def call(env) [200, {"Content-Type" => "text/javascript"}, [@package.compile]] end end end
github
maccman/stitch-rb
https://github.com/maccman/stitch-rb
lib/stitch/source.rb
Ruby
mit
93
master
2,575
require "pathname" module Stitch class Source # Recursively load all the sources from a given directory # Usage: # sources = Source.from_path("./app") # def self.from_path(root, path = nil, result = []) path ||= root path = Pathname.new(path) if path.directory? path.c...
github
maccman/stitch-rb
https://github.com/maccman/stitch-rb
lib/stitch/package.rb
Ruby
mit
93
master
1,365
require "erb" module Stitch class Package DEFAULTS = { :identifier => "require", :paths => [], :files => [], :dependencies => [] } def initialize(options = {}) options = DEFAULTS.merge(options) @identifier = options[:identifier] @paths ...
github
maccman/stitch-rb
https://github.com/maccman/stitch-rb
lib/stitch/compilers/eco.rb
Ruby
mit
93
master
294
module Stitch class EcoCompiler < Compiler extensions :eco enabled begin require "eco" true rescue LoadError false end source true def compile(path) source = File.read(path) %{module.exports = #{Eco.compile(source)}} end end end
github
maccman/stitch-rb
https://github.com/maccman/stitch-rb
lib/stitch/compilers/coffeescript.rb
Ruby
mit
93
master
330
module Stitch class CoffeeScriptCompiler < Compiler extensions :cs, :coffee enabled begin require "coffee-script" true rescue LoadError false end source true def compile(path) source = File.read(path) CoffeeScript.compile(source, :filename => path.to_s) end...
github
maccman/stitch-rb
https://github.com/maccman/stitch-rb
lib/stitch/compilers/tmpl.rb
Ruby
mit
93
master
300
module Stitch class TmplCompiler < Compiler extensions :tmpl def compile(path) content = File.read(path) %{var template = jQuery.template(#{content.to_json}); module.exports = function(data){ return jQuery.tmpl(template, data); };} end end end
github
maccman/stitch-rb
https://github.com/maccman/stitch-rb
lib/stitch/compilers/mustache.rb
Ruby
mit
93
master
296
module Stitch class MustacheCompiler < Compiler extensions :mustache def compile(path) content = File.read(path) %{var template = #{content.to_json}; module.exports = function(view){ return Mustache.to_html(template, view); };} end end end
github
Acceis/exploit-CVE-2023-23752
https://github.com/Acceis/exploit-CVE-2023-23752
exploit.rb
Ruby
mit
93
master
4,521
#!/usr/bin/env ruby # Exploit ## Title: Joomla! < 4.2.8 - Unauthenticated information disclosure ## Exploit author: noraj (Alexandre ZANNI) for ACCEIS (https://www.acceis.fr) ## Author website: https://pwn.by/noraj/ ## Exploit source: https://github.com/Acceis/exploit-CVE-2023-23752 ## Date: 2023-03-24 ## Vendor Homep...
github
apotonick/uber
https://github.com/apotonick/uber
uber.gemspec
Ruby
mit
93
master
820
# -*- encoding: utf-8 -*- require File.expand_path('../lib/uber/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["Nick Sutterer"] gem.email = ["apotonick@gmail.com"] gem.description = %q{A gem-authoring framework.} gem.summary = %q{Gem-authoring tools like generic builde...
github
apotonick/uber
https://github.com/apotonick/uber
Rakefile
Ruby
mit
93
master
264
#!/usr/bin/env rake require "bundler/gem_tasks" require 'rake/testtask' desc 'Test the representable gem.' task :default => :test Rake::TestTask.new(:test) do |test| test.libs << 'test' test.test_files = FileList['test/*_test.rb'] test.verbose = true end
github
apotonick/uber
https://github.com/apotonick/uber
lib/uber/options.rb
Ruby
mit
93
master
1,986
require "uber/callable" require "uber/option" module Uber class Options < Hash def initialize(options) @static = options options.each do |k,v| self[k] = Option[v, instance_exec: true] end end # Evaluates every element and returns a hash. Accepts context and arbitrary argument...
github
apotonick/uber
https://github.com/apotonick/uber
lib/uber/delegates.rb
Ruby
mit
93
master
222
require 'forwardable' module Uber module Delegates def delegates(model, *names) mod = Module.new do extend Forwardable def_delegators model, *names end include mod end end end
github
apotonick/uber
https://github.com/apotonick/uber
lib/uber/option.rb
Ruby
mit
93
master
494
require "uber/callable" module Uber class Option def self.[](value, options={}) # TODO: instance_exec: true if value.is_a?(Proc) return ->(context, *args) { context.instance_exec(*args, &value) } if options[:instance_exec] return value end return value ...
github
apotonick/uber
https://github.com/apotonick/uber
lib/uber/inheritable_attr.rb
Ruby
mit
93
master
1,078
module Uber module InheritableAttr def inheritable_attr(name, options={}) instance_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{name}=(v) @#{name} = v end def #{name} return @#{name} if instance_variable_defined?(:@#{name}) @#{name} = InheritableAttribut...
github
apotonick/uber
https://github.com/apotonick/uber
lib/uber/callable.rb
Ruby
mit
93
master
236
module Uber # Include this module into a class or extend an object to mark it as callable. # E.g., in a dynamic option in Options::Value it will be treated like a Proc object # and invoked with +#call+. module Callable end end
github
apotonick/uber
https://github.com/apotonick/uber
lib/uber/builder.rb
Ruby
mit
93
master
782
require "uber/option" module Uber module Builder def self.included(base) base.extend DSL base.extend Build end class Builders < Array def call(context, *args) each do |block| klass = block.(context, *args) and return klass # Uber::Value#call() end con...
github
apotonick/uber
https://github.com/apotonick/uber
test/delegates_test.rb
Ruby
mit
93
master
733
require 'test_helper' require 'uber/delegates' class DelegatesTest < Minitest::Spec class Song extend Uber::Delegates delegates :model, :title def model Struct.new(:title).new("Helloween") end def title super.downcase end end # allows overriding in class. it { Song.new.t...
github
apotonick/uber
https://github.com/apotonick/uber
test/inheritable_attr_test.rb
Ruby
mit
93
master
2,402
require 'test_helper' require "uber/inheritable_attr" class InheritableAttrTest < Minitest::Spec describe "::inheritable_attr" do subject { Class.new(Object) do extend Uber::InheritableAttribute inheritable_attr :drinks inheritable_attr :glass inheritable_attr :guests, clone...
github
apotonick/uber
https://github.com/apotonick/uber
test/inheritance_test.rb
Ruby
mit
93
master
1,151
# require 'test_helper' # require 'uber/inheritable_included' # module InheritIncludedTo # def self.call(includer, proc) # proc.call(includer) # das will ich eigentlich machen # includer.class_eval do # @block = proc # def self.included(base) # # InheritIncludedTo.call(base, instance_va...
github
apotonick/uber
https://github.com/apotonick/uber
test/options_test.rb
Ruby
mit
93
master
1,016
require 'test_helper' require 'uber/options' class UberOptionsTest < Minitest::Spec Options = Uber::Options let (:dynamic) { Options.new(:volume =>1, :style => "Punkrock", :track => Proc.new { |i| i.to_s }) } describe "#evaluate" do it { dynamic.evaluate(Object.new, 999).must_equal({:volume =>1, :style => ...
github
apotonick/uber
https://github.com/apotonick/uber
test/option_test.rb
Ruby
mit
93
master
1,381
require "test_helper" require "uber/option" class OptionTest < Minitest::Spec Option = Uber::Option # proc it { Option[ ->(*args) { "proc! #{args.inspect}" } ].(1,2).must_equal "proc! [1, 2]" } it { Option[ lambda { "proc!" } ].().must_equal "proc!" } # proc with instance_exec it { Option[ ->(*args) { "#...
github
apotonick/uber
https://github.com/apotonick/uber
test/builder_test.rb
Ruby
mit
93
master
3,222
require 'test_helper' require "uber/builder" class BuilderTest < Minitest::Spec Evergreen = Struct.new(:title) Hit = Struct.new(:title) class Song include Uber::Builder builds do |options| if options[:evergreen] Evergreen elsif options[:hit] Hit end end def s...
github
apotonick/uber
https://github.com/apotonick/uber
test/zeugs.rb
Ruby
mit
93
master
911
module Feature module ClassMethods def feature end end # in uber, this would look somehow like # module Feature # module ClassMethods ... end # extend Uber::InheritableIncluded # inheritable_included do |includer| # includer.extend ClassMethods # end # end InheritedIncludedC...
github
apotonick/uber
https://github.com/apotonick/uber
test/builder-benchmark.rb
Ruby
mit
93
master
451
require "test_helper" require "uber/options" require "uber/option" require "benchmark/ips" proc = ->(options) { "great" } value = Uber::Options::Value.new(proc) option = Uber::Option[proc, instance_exec: true] Benchmark.ips do |x| x.report(:value) { value.(self, {}) } x.report(:option) { option.(self, {}) } en...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
smsonrails.gemspec
Ruby
mit
93
master
7,475
# Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = %q{smsonrails} s.version = "0.1.2" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :require...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
Rakefile
Ruby
mit
93
master
3,583
require 'rubygems' require 'rake' require 'rake/testtask' require 'rake/rdoctask' begin require 'jeweler' Jeweler::Tasks.new do |gem| gem.name = "smsonrails" gem.summary = %Q{Sms on Rails provides your app with instant SMS integration} gem.description = %Q{Sms on Rails provides your app with instant SM...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
app/models/sms_on_rails/outbound.rb
Ruby
mit
93
master
675
module SmsOnRails class Outbound < ActiveRecord::Base set_table_name 'sms_outbounds' belongs_to :draft, :class_name => 'SmsOnRails::Draft', :foreign_key => :sms_draft_id belongs_to :phone_number, :class_name => 'SmsOnRails::PhoneNumber', :foreign_key => :sms_phone_number_id #adding this here instead ...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
app/models/sms_on_rails/phone_number.rb
Ruby
mit
93
master
233
module SmsOnRails class PhoneNumber < ActiveRecord::Base set_table_name 'phone_numbers' include SmsOnRails::ModelSupport::PhoneNumberAssociations include SmsOnRails::ModelSupport::PhoneNumber end#end PhoneNumber end
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
app/models/sms_on_rails/draft.rb
Ruby
mit
93
master
262
module SmsOnRails class Draft < ActiveRecord::Base set_table_name 'sms_drafts' has_many :outbounds, :class_name => 'SmsOnRails::Outbound', :foreign_key => :sms_draft_id, :dependent => :nullify include SmsOnRails::ModelSupport::Draft end end
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
app/models/sms_on_rails/phone_carrier.rb
Ruby
mit
93
master
347
module SmsOnRails class PhoneCarrier < ActiveRecord::Base set_table_name 'sms_phone_carriers' acts_as_static_record :key => :name has_many :phone_numbers, :class_name => 'SmsOnRails::PhoneNumber', :foreign_key => 'carrier_id', :dependent => :nullify include SmsOnRails::ModelSuppor...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
app/helpers/sms_on_rails/phone_numbers_helper.rb
Ruby
mit
93
master
349
module SmsOnRails::PhoneNumbersHelper def phone_carriers_collection_select(form) form.collection_select('carrier_id',SmsOnRails::PhoneCarrier.find(:all), :id, :name) end def phone_number_carrier_link(phone_number) link_to(phone_number.carrier.name, sms_phone_carrier_path(phone_number.carrier_id)) if ph...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
app/helpers/sms_on_rails/sms_helper.rb
Ruby
mit
93
master
1,359
# To change this template, choose Tools | Templates # and open the template in the editor. module SmsOnRails::SmsHelper def link_to_sms_phone_number(phone_number) return '' unless phone_number link_to phone_number.human_display, sms_phone_number_url(:id => phone_number) end def link_to_sms_draft(draft, ...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
app/controllers/sms_on_rails_controller.rb
Ruby
mit
93
master
313
class SmsOnRailsController < ApplicationController helper SmsOnRails::SmsHelper helper SmsOnRails::PhoneNumbersHelper include SmsOnRails::CreationSupport layout 'sms_on_rails/basic.html' def index respond_to do |format| format.html { render :action => 'index.html.erb' } end end end
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
app/controllers/sms_on_rails/creation_support.rb
Ruby
mit
93
master
2,677
module SmsOnRails::CreationSupport def send_sms setup_new_draft respond_to do |format| format.html { render_send_sms_template } format.xml { render :xml => @draft } end end # GET /sms/new # GET /sms/new.xml def new; send_sms; end # GET /sms/1 # GET /sms/1 def show @dra...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
app/controllers/admin/sms_on_rails/base_controller.rb
Ruby
mit
93
master
200
class Admin::SmsOnRails::BaseController < ApplicationController helper SmsOnRails::SmsHelper helper SmsOnRails::PhoneNumbersHelper layout 'sms_on_rails/basic.html' def index end end
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
app/controllers/admin/sms_on_rails/outbounds_controller.rb
Ruby
mit
93
master
3,629
class Admin::SmsOnRails::OutboundsController < Admin::SmsOnRails::BaseController # GET /admin/sms/outbounds # GET /admin/sms/outbounds.xml def index if params[:sms_draft_id] @draft = SmsOnRails::Draft.find( params[:sms_draft_id], :include => :outbounds ) @outbounds = @draft.outbounds end ...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
app/controllers/admin/sms_on_rails/phone_carriers_controller.rb
Ruby
mit
93
master
2,617
class Admin::SmsOnRails::PhoneCarriersController < Admin::SmsOnRails::BaseController # GET /admin/sms/phone_carriers # GET /admin/sms/phone_carriers.xml def index @phone_carriers = SmsOnRails::PhoneCarrier.all :group => :name respond_to do |format| format.html # index.html.erb format.xml { r...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
app/controllers/admin/sms_on_rails/phone_numbers_controller.rb
Ruby
mit
93
master
3,037
class Admin::SmsOnRails::PhoneNumbersController < Admin::SmsOnRails::BaseController helper SmsOnRails::SmsHelper # GET /admin/sms_on_rails_phone_numbers # GET /admin/sms_on_rails_phone_numbers.xml def index if params[:sms_outbound_id] @outbounds = SmsOnRails::Outbound.find( params[:sms_outbound_id]...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
app/controllers/admin/sms_on_rails/drafts_controller.rb
Ruby
mit
93
master
1,757
class Admin::SmsOnRails::DraftsController < Admin::SmsOnRails::BaseController include SmsOnRails::CreationSupport # GET /admin/sms/drafts # GET /admin/sms/drafts.xml def index @drafts = SmsOnRails::Draft.all respond_to do |format| format.html # index.html.erb format.xml { render :xml =>...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
tasks/sms_on_rails_tasks.rake
Ruby
mit
93
master
2,515
require 'active_support' require File.dirname(__FILE__) + '/../lib/sms_on_rails/schema_helper' namespace :sms do desc 'Reset the Sms data' task :reset => [ :teardown, :setup ] desc 'Create Tables and seed them' task :setup => [ :create_tables, :seed_tables ] desc 'Teardown' task :teardown => [:drop_table...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
generators/sms_on_rails/sms_on_rails_generator.rb
Ruby
mit
93
master
9,296
require 'rails_generator/generators/applications/app/template_runner' require File.dirname(__FILE__) + '/commands/inserts.rb' require File.dirname(__FILE__) + '/commands/timestamps.rb' class SmsOnRailsGenerator < Rails::Generator::NamedBase default_options :skip_models => false, :skip_carriers => false, ...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
generators/sms_on_rails/runners/sms_on_rails_routes.rb
Ruby
mit
93
master
753
route <<-EOS #Resources for sms on rails admin routes #url: localhost:3000/admin/sms/drafts goes to the app/controllers/admin/sms_on_rails/draft_controller.rb map.resources :sms_drafts, :as => 'admin/sms/drafts', :controller => 'admin/sms_on_rails/drafts' do |draft| draft.resources :outbound...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
generators/sms_on_rails/runners/add_all_models.rb
Ruby
mit
93
master
212
append_file 'config/environment.rb', <<-EOS # Include vanilla sms models. If you wish to make changes and create your own # models/sms_on_rails this line should be removed. require 'sms_on_rails/all_models' EOS
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
generators/sms_on_rails/templates/migrate/schema_migration.rb
Ruby
mit
93
master
362
class <%= migration_name %> < ActiveRecord::Migration def self.up <%= SmsOnRails::SchemaHelper.create(*files) %> <% if migration_name.downcase.include?('carrier') -%> require "#{RAILS_ROOT}/vendor/plugins/smsonrails/db/seed_data.rb" <% else %> <%= migration_name %> <% end -%> end def self.down <%= SmsOnRail...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
generators/sms_on_rails/templates/migrate/sms_on_rails_update_phone_numbers.rb
Ruby
mit
93
master
1,420
class SmsOnRailsUpdatePhoneNumbers < ActiveRecord::Migration def self.up <% existing_columns = ActiveRecord::Base.connection.columns(:phone_numbers).collect { |each| each.name } columns = [ [:number, 't.string :number, :length => 20, :null => false'], [:carrier_id, 't.integer...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
generators/sms_on_rails/commands/inserts.rb
Ruby
mit
93
master
2,417
# Most of this was derived from the clearance gem work Rails::Generator::Commands::Base.class_eval do # Return true if the file contains the line (String or Regexp) def file_contains?(relative_destination, line) File.read(destination_path(relative_destination)).scan(line).any? end def margin_text(options=...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
generators/sms_on_rails/commands/timestamps.rb
Ruby
mit
93
master
1,186
Rails::Generator::Commands::Create.class_eval do #overwrite next migration string to add a count to the timestamp def next_migration_string(padding = 3)#:nodoc: if ActiveRecord::Base.timestamped_migrations time_str = Time.now.utc.strftime("%Y%m%d%H%M%S") time_str << "#{migration_count}" if migratio...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
lib/sms_on_rails.rb
Ruby
mit
93
master
425
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) Dir.glob(File.dirname(__FILE__) + '/sms_on_rails/activerecord_extensions/*.rb'){|f| require f} files = Dir.glob(File.dirname(__FILE__) + '/sms_on_rails/util/*.rb') files.concat Dir.glob(File.dirname(__FILE__) + '/sms_on_rails/service_providers/*.rb') files.c...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
lib/sms_on_rails/schema_helper.rb
Ruby
mit
93
master
1,373
module SmsOnRails class SchemaHelper class << self def create(*files) each_file(*files) {|file, options| file_to_string(file, options) } end def drop(*files) each_file(*files) {|file, options| drop_tables(file, options)} end def each_file(*files, &block) opt...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
lib/sms_on_rails/model_support/draft.rb
Ruby
mit
93
master
7,146
module SmsOnRails module ModelSupport module Draft def self.included(base)#:nodoc base.send :accepts_nested_attributes_for, :outbounds #base.acts_as_deliverable :fatal_exception => SmsOnRails::FatalSmsError base.validates_presence_of :message base.validate :validates_messa...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
lib/sms_on_rails/model_support/phone_carrier.rb
Ruby
mit
93
master
2,570
module SmsOnRails module ModelSupport module PhoneCarrier def self.included(base) base.send :validates_presence_of, :name base.send :include, InstanceMethods base.send :extend, ClassMethods end module ClassMethods # Returns the email address for sms # ...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
lib/sms_on_rails/model_support/phone_number.rb
Ruby
mit
93
master
9,395
module SmsOnRails module ModelSupport module PhoneNumber def self.included(base) base.send :include,InstanceMethods base.send :extend, ClassMethods base.send :validates_format_of, :phone_number_digits, :with => /^\d{5,30}$/, :message => 'must be a number and have at least 5 digits' ...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
lib/sms_on_rails/model_support/outbound.rb
Ruby
mit
93
master
4,937
module SmsOnRails module ModelSupport module Outbound mattr_accessor :default_options self.default_options = {} def self.included(base) base.has_a_sms_service_provider base.acts_as_deliverable :fatal_exception => SmsOnRails::FatalSmsError, ...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
lib/sms_on_rails/model_support/phone_number_associations.rb
Ruby
mit
93
master
423
module SmsOnRails module ModelSupport module PhoneNumberAssociations def self.included(base) base.send :has_many, :outbounds, :class_name => 'SmsOnRails::Outbound', :foreign_key => 'sms_phone_number_id', :dependent => :delete_all base.send :belongs_to, :carrier, :class_name ...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
lib/sms_on_rails/util/sms_error.rb
Ruby
mit
93
master
230
module SmsOnRails class SmsError < Exception attr_reader :sub_status def initialize(msg, new_sub_status = nil) super msg @sub_status = new_sub_status end end class FatalSmsError < SmsError end end
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
lib/sms_on_rails/activerecord_extensions/acts_as_substitutable.rb
Ruby
mit
93
master
2,290
module SmsOnRails module ActsAsSubstitutable def self.extended(base) base.send :class_inheritable_accessor, :acts_as_sub_options base.acts_as_sub_options = {} base.extend ClassMethods end module ClassMethods def acts_as_substitutable(method, options={}) defaults...
github
blythedunham/smsonrails
https://github.com/blythedunham/smsonrails
lib/sms_on_rails/activerecord_extensions/lockable_record.rb
Ruby
mit
93
master
6,127
module SmsOnRails module LockableRecord class UnableToLockRecord < Exception; end class AlreadyProcessed < UnableToLockRecord; end def self.extended(base) base.class_inheritable_hash :locrec_options base.locrec_options = { :log_lock_warnings => true, :columns => { ...