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 | patbenatar/rbexy | https://github.com/patbenatar/rbexy | lib/rbexy/nodes/component_prop.rb | Ruby | mit | 49 | master | 668 | module Rbexy
module Nodes
class ComponentProp < AbstractAttr
def precompile
[ComponentProp.new(name, precompile_value)]
end
def compile
key = ActiveSupport::Inflector.underscore(name)
"#{key}: #{value.compile}"
end
private
def precompile_value
... |
github | patbenatar/rbexy | https://github.com/patbenatar/rbexy | lib/rbexy/nodes/abstract_node.rb | Ruby | mit | 49 | master | 1,535 | module Rbexy
module Nodes
class AbstractNode
PrecompileRequired = Class.new(StandardError)
attr_reader :compile_context
def precompile
[self]
end
def compile
raise PrecompileRequired, "#{self.class.name} must be precompiled first"
end
def inject_compil... |
github | patbenatar/rbexy | https://github.com/patbenatar/rbexy | lib/rbexy/nodes/abstract_attr.rb | Ruby | mit | 49 | master | 207 | module Rbexy
module Nodes
class AbstractAttr < AbstractNode
attr_accessor :name, :value
def initialize(name, value)
@name = name
@value = value
end
end
end
end |
github | patbenatar/rbexy | https://github.com/patbenatar/rbexy | lib/rbexy/nodes/expression_group.rb | Ruby | mit | 49 | master | 2,345 | module Rbexy
module Nodes
class ExpressionGroup < AbstractNode
using Rbexy::Refinements::Array::MapTypeWhenNeighboringType
using Rbexy::Refinements::Array::InsertBetweenTypes
attr_accessor :members
attr_reader :outer_template, :inner_template
DEBUGGERS = %w[debugger binding.pry]
... |
github | patbenatar/rbexy | https://github.com/patbenatar/rbexy | lib/rbexy/nodes/html_attr.rb | Ruby | mit | 49 | master | 225 | module Rbexy
module Nodes
class HTMLAttr < AbstractAttr
def precompile
[
Raw.new(" #{name}=\""),
value.precompile,
Raw.new("\"")
].flatten
end
end
end
end |
github | patbenatar/rbexy | https://github.com/patbenatar/rbexy | lib/rbexy/nodes/text.rb | Ruby | mit | 49 | master | 252 | module Rbexy
module Nodes
class Text < AbstractNode
attr_accessor :content
def initialize(content)
@content = content
end
def precompile
[Raw.new(Util.escape_string(content))]
end
end
end
end |
github | patbenatar/rbexy | https://github.com/patbenatar/rbexy | lib/rbexy/rails/component_template_resolver.rb | Ruby | mit | 49 | master | 3,394 | require "active_support/digest"
module Rbexy
module Rails
class ComponentTemplateResolver < ActionView::FileSystemResolver
COMMENT_SYNTAX = {
rbx: "# %s",
erb: "<%%# %s %%>",
haml: "-# %s",
slim: "/ %s"
}
def _find_all(name, prefix, partial, details, key, locals... |
github | patbenatar/rbexy | https://github.com/patbenatar/rbexy | lib/rbexy/rails/controller_helper.rb | Ruby | mit | 49 | master | 470 | module Rbexy
module Rails
module ControllerHelper
extend ActiveSupport::Concern
include ComponentContext
included do
helper_method :rbexy_context, :create_context, :use_context
end
class_methods do
def inherited(klass)
super
Rbexy.configuration.t... |
github | patbenatar/rbexy | https://github.com/patbenatar/rbexy | lib/rbexy/rails/engine.rb | Ruby | mit | 49 | master | 1,768 | require "rbexy/rails"
require "action_view/dependency_tracker"
# Rails 7.1 implements development-mode template caching in a way that only works with view paths registered as
# strings with `prepend_view_path`. Since we register our view paths as `ComponentTemplateResolver` instances (which
# are subclasses of Rails `... |
github | patbenatar/rbexy | https://github.com/patbenatar/rbexy | lib/rbexy/rails/rbx_dependency_tracker.rb | Ruby | mit | 49 | master | 1,121 | module Rbexy
module Rails
class RbxDependencyTracker < ActionView::DependencyTracker::ERBTracker
def dependencies
super + rbexy_component_dependencies
end
private
def render_dependencies
dependencies = []
# Scan for render calls inside Rbexy {expr} expressions
... |
github | yez/validates_type | https://github.com/yez/validates_type | validates_type.gemspec | Ruby | mit | 49 | master | 1,144 | lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
require './version'
Gem::Specification.new do |s|
s.name = 'validates_type'
s.version = ValidatesType::VERSION
s.summary = %q{Type validation for ActiveModel/ActiveRecord attributes}
s.description = %q{Thi... |
github | yez/validates_type | https://github.com/yez/validates_type | spec/active_model_helper.rb | Ruby | mit | 49 | master | 1,607 | module ActiveModel
class TypeValidationTestClass
include Validations
# Creates and returns a new instance of TypeValidationTestClass with
# a "long" style validator:
#
# class TypeValidationTestClass
# attr_accessor :attribute
#
# validates_type :attribute, :string
# end
#... |
github | yez/validates_type | https://github.com/yez/validates_type | spec/arguments_spec.rb | Ruby | mit | 49 | master | 2,072 | require 'spec_helper'
require_relative '../lib/arguments'
describe ValidatesType::Arguments do
let(:attribute_name) { :foo }
let(:attribute_type) { :string }
let(:options) { { extra: :options } }
subject { described_class.new(attribute_name, attribute_type, options) }
describe '#to_validation_attri... |
github | yez/validates_type | https://github.com/yez/validates_type | spec/active_record_helper.rb | Ruby | mit | 49 | master | 871 | ActiveRecord::Base.establish_connection(
"adapter" => "sqlite3",
"database" => ":memory:"
)
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :type_validation_tests do |t|
t.string :test_attribute
end
end
def drop_and_create_column_with_type(column_type)
ActiveRe... |
github | yez/validates_type | https://github.com/yez/validates_type | spec/active_model/modifiers_spec.rb | Ruby | mit | 49 | master | 8,309 | require_relative '../spec_helper'
describe 'ValidatesType' do
[:set_accessor_and_long_validator,
:set_accessor_and_validator].each do |validate_version|
context "#{ validate_version }" do
context 'custom modifiers' do
before do
subject.attribute = value
end
describe ... |
github | yez/validates_type | https://github.com/yez/validates_type | spec/active_model/base_spec.rb | Ruby | mit | 49 | master | 1,249 | require_relative '../spec_helper'
describe 'ValidatesType' do
context 'validates_type :attribute' do
subject { ActiveModel::TypeValidationTestClass.set_accessor_and_long_validator(:string) }
it 'adds a validator to the subject' do
klass = subject.class
expect(klass.validators).to_not be_empty
... |
github | yez/validates_type | https://github.com/yez/validates_type | spec/active_model/types_spec.rb | Ruby | mit | 49 | master | 8,241 | require_relative '../spec_helper'
describe 'ValidatesType' do
context 'supported types' do
before do
subject.attribute = value
end
describe 'String' do
subject { ActiveModel::TypeValidationTestClass.set_accessor_and_long_validator(:string) }
context 'field value is a String' do
... |
github | yez/validates_type | https://github.com/yez/validates_type | spec/activerecord/types_spec.rb | Ruby | mit | 49 | master | 11,498 | require_relative '../spec_helper'
describe 'ValidatesType' do
context 'supported types' do
before do
subject.test_attribute = value
end
describe 'Array' do
drop_and_create_column_with_type(:string)
subject { TypeValidationTest.set_accessor_and_long_validator(:array) }
context '... |
github | yez/validates_type | https://github.com/yez/validates_type | spec/activerecord/modifiers_spec.rb | Ruby | mit | 49 | master | 8,167 | require_relative '../spec_helper'
describe 'ValidatesType' do
[:set_accessor_and_long_validator,
:set_accessor_and_validator].each do |validate_version|
context "#{ validate_version }" do
context 'custom modifiers' do
before do
subject.test_attribute = value
end
desc... |
github | yez/validates_type | https://github.com/yez/validates_type | spec/activerecord/base_spec.rb | Ruby | mit | 49 | master | 1,213 | require_relative '../spec_helper'
describe 'ValidatesType' do
context 'validates_type :attribute' do
subject { TypeValidationTest.set_accessor_and_long_validator(:string) }
it 'adds a validator to the subject' do
klass = subject.class
expect(klass.validators).to_not be_empty
expect(klass.v... |
github | yez/validates_type | https://github.com/yez/validates_type | lib/validates_type.rb | Ruby | mit | 49 | master | 6,017 | require 'ruby-boolean'
require 'active_model'
require 'active_support/i18n'
I18n.load_path << File.dirname(__FILE__) + '/../locale/en.yml'
require_relative '../errors/unsupported_type'
require_relative './arguments'
module ActiveModel
module Validations
class TypeValidator < ActiveModel::EachValidator
# ... |
github | yez/validates_type | https://github.com/yez/validates_type | lib/arguments.rb | Ruby | mit | 49 | master | 1,363 | module ValidatesType
# Wrapper class for arguments consumed by validates_with
class Arguments
# @initialize
# param: attribute_name <Symbol> - name of attribute that will be validated
# param: attribute_type <Symbol> - type for which to validate the attribute against
# param: options <Hash> - ... |
github | aki77/csb | https://github.com/aki77/csb | csb.gemspec | Ruby | mit | 49 | main | 1,485 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "csb/version"
Gem::Specification.new do |spec|
spec.name = "csb"
spec.version = Csb::VERSION
spec.authors = ["aki77"]
spec.email = ["aki77@users.noreply.github.com"]
spec.s... |
github | aki77/csb | https://github.com/aki77/csb | lib/csb.rb | Ruby | mit | 49 | main | 278 | require 'csb/version'
require 'csb/railtie'
require 'csb/configuration'
require 'csb/builder'
require 'csb/cols'
module Csb
class << self
def configure
yield(configuration)
end
def configuration
@configuration ||= Configuration.new
end
end
end |
github | aki77/csb | https://github.com/aki77/csb | lib/csb/template.rb | Ruby | mit | 49 | main | 1,036 | module Csb
class Template
attr_accessor :utf8_bom, :filename, :streaming, :items, :cols, :csv_options
def initialize(streaming:)
@streaming = streaming
@cols = Cols.new
@items = []
end
def build
streaming ? build_enumerator : build_string
end
def streaming?
!!s... |
github | aki77/csb | https://github.com/aki77/csb | lib/csb/cols.rb | Ruby | mit | 49 | main | 603 | require 'active_support/core_ext/object/deep_dup'
require 'csb/col'
module Csb
class Cols
include Enumerable
attr_reader :cols
def initialize
@cols = []
yield(self) if block_given?
end
def copy!(other)
@cols = other.cols.deep_dup
end
def each(&block)
cols.each(... |
github | aki77/csb | https://github.com/aki77/csb | lib/csb/builder.rb | Ruby | mit | 49 | main | 858 | require 'csv'
require 'csb/cols'
module Csb
class Builder
UTF8_BOM = "\xEF\xBB\xBF".freeze
attr_reader :output, :utf8_bom, :items, :cols, :csv_options
attr_accessor :items
def initialize(output = +'', items: [], **kwargs)
@output = output
@cols = Cols.new
@items = items
@utf... |
github | aki77/csb | https://github.com/aki77/csb | lib/csb/handler.rb | Ruby | mit | 49 | main | 837 | # frozen_string_literal: true
require 'csb/template'
module Csb
class Handler
class_attribute :default_format
self.default_format = :csv
def self.call(template, source = nil)
source ||= template.source
<<~RUBY
csv = ::Csb::Template.new(
streaming: ::Csb.configuration.stre... |
github | aki77/csb | https://github.com/aki77/csb | lib/csb/col.rb | Ruby | mit | 49 | main | 387 | module Csb
class Col
attr_reader :name
def initialize(name, value = nil, &block)
@name = name
@value = block ? block : value
end
def value_by_item(item)
case value
when ::Symbol
item.public_send(value)
when ::Proc
value.call(item)
else
valu... |
github | aki77/csb | https://github.com/aki77/csb | lib/csb/configuration.rb | Ruby | mit | 49 | main | 296 | module Csb
class Configuration
attr_accessor :utf8_bom, :streaming, :after_streaming_error, :ignore_class_names, :csv_options
def initialize
@utf8_bom = false
@streaming = true
@csv_options = {}
@ignore_class_names = %w[Puma::ConnectionError]
end
end
end |
github | aki77/csb | https://github.com/aki77/csb | lib/csb/railtie.rb | Ruby | mit | 49 | main | 261 | require 'rails'
module Csb
class Railtie < Rails::Railtie
initializer :csb do
ActiveSupport.on_load :action_view do
require 'csb/handler'
ActionView::Template.register_template_handler :csb, Csb::Handler
end
end
end
end |
github | aki77/csb | https://github.com/aki77/csb | spec/spec_helper.rb | Ruby | mit | 49 | main | 359 | require "bundler/setup"
require "csb"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
config.expect_with :rspec d... |
github | aki77/csb | https://github.com/aki77/csb | spec/lib/csb/col_spec.rb | Ruby | mit | 49 | main | 692 | require 'ostruct'
RSpec.describe Csb::Col do
describe '#value_by_item' do
subject { col.value_by_item(item) }
let(:item) { OpenStruct.new(name: 'tester', email: 'dummy@dummy.test') }
context 'block' do
let(:col) { Csb::Col.new('Name') { |item| item.name } }
it { is_expected.to eq 'tester' ... |
github | aki77/csb | https://github.com/aki77/csb | spec/lib/csb/builder_spec.rb | Ruby | mit | 49 | main | 1,116 | require 'ostruct'
RSpec.describe Csb::Builder do
describe '#build' do
subject { builder.build }
let(:items) do
[
OpenStruct.new(name: 'tester1', email: 'dummy1@dummy.test'),
OpenStruct.new(name: 'tester2', email: 'dummy2@dummy.test')
]
end
before do
builder.cols.ad... |
github | aki77/csb | https://github.com/aki77/csb | spec/lib/csb/testing_spec.rb | Ruby | mit | 49 | main | 840 | require 'ostruct'
require 'csb/testing'
RSpec.describe Csb::Cols do
let(:cols) { Csb::Cols.new }
before do
cols.add('Name') { |item| item.name }
cols.add('Email', :email)
cols.add('Dummy')
end
describe '#col_pairs' do
subject { cols.col_pairs(item) }
let(:item) { OpenStruct.new(name: 'te... |
github | aki77/csb | https://github.com/aki77/csb | spec/lib/csb/template_spec.rb | Ruby | mit | 49 | main | 1,416 | require 'ostruct'
require 'csb/template'
RSpec.describe Csb::Template do
describe '#build' do
before do
template.items = [
OpenStruct.new(name: 'tester1', email: 'dummy1@dummy.test'),
OpenStruct.new(name: 'tester2', email: 'dummy2@dummy.test')
]
template.cols.add('Name') { |item... |
github | aki77/csb | https://github.com/aki77/csb | spec/lib/csb/cols_spec.rb | Ruby | mit | 49 | main | 532 | require 'ostruct'
RSpec.describe Csb::Cols do
let(:cols) { Csb::Cols.new }
before do
cols.add('Name') { |item| item.name }
cols.add('Email', :email)
cols.add('Dummy')
end
describe '#headers' do
subject { cols.headers }
it { is_expected.to eq %w[Name Email Dummy] }
end
describe '#val... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | freeswitcher.gemspec | Ruby | mit | 49 | master | 12,865 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{freeswitcher}
s.version = "0.4.10"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Jayson Vaughn", "Michael Fellinger", "Kevin Berry", "TJ Vanderpoel"]
s.date = %q{2010-0... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | Rakefile | Ruby | mit | 49 | master | 1,437 | require 'rake/clean'
require "rubygems"
require "./lib/fsr"
require "pathname"
ENV["RUBYLIB"] = ".:#{ENV['RUBYLIB']}"
PROJECT_COPYRIGHT = Pathname(__FILE__).dirname.join("License.txt").read
PROJECT_README = Pathname(__FILE__).dirname.join("README").expand_path.to_s
PROJECT_FILES = %x{git ls-files}.split
RELEASE_FILES... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr_listener_helper.rb | Ruby | mit | 49 | master | 897 | require File.join(File.expand_path("../", __FILE__), "../lib/fsr")
require FSR::ROOT/".."/:spec/:helper
require FSR::ROOT/:fsr/:listener/:outbound
require "em-spec/bacon"
EM.spec_backend = EventMachine::Spec::Bacon
require "fileutils"
# Shared contexts to make describing listener behavior easier
shared :fsr_listener ... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/helper.rb | Ruby | mit | 49 | master | 356 | begin
require 'bacon'
rescue LoadError
begin
require "rubygems"
require "bacon"
rescue LoadError
puts <<-EOS
To run these tests you must install bacon.
Quick and easy install for gem:
gem install bacon
EOS
exit(0)
end
end
Bacon.summary_on_exit
require File.expand_path(File.join(Fil... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/listener.rb | Ruby | mit | 49 | master | 265 | require "spec/helper"
require "fsr/listener"
describe "Basic FSR::Listener module" do
it "Aliases itself as FSL" do
FSL.should == FSR::Listener
end
it "Defines #receive_data" do
FSR::Listener.method_defined?(:receive_data).should == true
end
end |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/file_methods.rb | Ruby | mit | 49 | master | 887 | require "spec/helper"
require "fsr/file_methods"
describe "Basic FSR::App::FileMethods module" do
before do
@testee = Class.new do
include ::FSR::App::FileMethods
end.new
end
it "should have a test_files method" do
@testee.test_files("bla").should.equal true
end
it "should only test... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/loading.rb | Ruby | mit | 49 | master | 1,307 | require 'spec/helper'
describe "Testing FSR module loading methods" do
# When you add applications you must modify the expected apps_loaded behavior
it "Loads all applications" do
all_apps = [:play_and_get_digits, :uuid_dump, :uuid_setvar, :uuid_getvar, :read, :set, :transfer, :speak, :fs_sleep, :playback, :... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/callcenter.rb | Ruby | mit | 49 | master | 377 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("callcenter")
describe "Testing FSR::App::Callcenter" do
it "Sends the call to callcenter" do
callcenter = FSR::App::Callcenter.new("support@default")
callcenter.sendmsg.should == "call-command: execute\nexecute-app-name: callcenter\nexecute-a... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/set.rb | Ruby | mit | 49 | master | 398 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("set")
describe "Testing FSR::App::Set" do
# Utilize the [] shortcut to start a conference
it "Sets a single variable" do
set = FSR::App::Set.new("hangup_after_bridge", true)
set.sendmsg.should == "call-command: execute\nexecute-app-name: se... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/ring_ready.rb | Ruby | mit | 49 | master | 297 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("ring_ready")
describe "Testing FSR::App::RingReady" do
it "sends ring_ready to incoming call" do
ans = FSR::App::RingReady.new
ans.sendmsg.should == "call-command: execute\nexecute-app-name: ring_ready\n\n"
end
end |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/conference.rb | Ruby | mit | 49 | master | 363 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("conference")
describe "Testing FSR::App::Conference" do
# Utilize the [] shortcut to start a conference
it "Executes a conference using Conference[conf_spec]" do
conf = FSR::App::Conference["5290-192.168.6.30"]
conf.should == "conference(52... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/execute_app.rb | Ruby | mit | 49 | master | 594 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("execute_app")
describe "Testing FSR::App::ExecuteApp" do
it "executes arbitrary app with one argument" do
log = FSR::App::ExecuteApp.new("att_xfer", "sofia/user/1")
log.sendmsg.should == "call-command: execute\nexecute-app-name: att_xfer\nexe... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/fs_sleep.rb | Ruby | mit | 49 | master | 347 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("fs_sleep")
describe "Testing FSR::App::FsSleep" do
it "should put FreeSWITCH leg to sleep for 7000 miliseconds" do
fs_sleep = FSR::App::FSSleep.new(7000)
fs_sleep.sendmsg.should == "call-command: execute\nexecute-app-name: sleep\nexecute-app... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/answer.rb | Ruby | mit | 49 | master | 275 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("answer")
describe "Testing FSR::App::Answer" do
it "answers the incoming call" do
ans = FSR::App::Answer.new
ans.sendmsg.should == "call-command: execute\nexecute-app-name: answer\n\n"
end
end |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/playback.rb | Ruby | mit | 49 | master | 899 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("playback")
describe "Testing FSR::App::Playback" do
it "Plays a file or stream" do
playback = FSR::App::Playback.new("shout://scfire-ntc-aa01.stream.aol.com/stream/1035")
playback.sendmsg.should == "call-command: execute\nexecute-app-name: pl... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/log.rb | Ruby | mit | 49 | master | 339 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("log")
describe "Testing FSR::App::Log" do
it "Logs to the console" do
log = FSR::App::Log.new(1, "This is a test! :-)")
log.sendmsg.should == "call-command: execute\nexecute-app-name: log\nexecute-app-arg: 1 This is a test! :-)\nevent-lock:tr... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/play_and_get_digits.rb | Ruby | mit | 49 | master | 3,909 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("play_and_get_digits")
describe "Testing FSR::App::PlayAndGetDigits" do
# Utilize the [] shortcut to start a conference
it "Send a play_and_gets_digits command, default args" do
tmp = FSR::App::PlayAndGetDigits.new("soundfile.wav", "invalid.wav"... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/hangup.rb | Ruby | mit | 49 | master | 511 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("hangup")
describe "Testing FSR::App::Hangup" do
it "Hangs up the channel" do
hangup = FSR::App::Hangup.new
hangup.sendmsg.should == "call-command: execute\nexecute-app-name: hangup\nexecute-app-arg: \n\n"
end
it "Hangs up the channel usi... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/transfer.rb | Ruby | mit | 49 | master | 361 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("transfer")
describe "Testing FSR::App::Transfer" do
it "Transfers the call" do
transfer = FSR::App::Transfer.new("500", "XML", "default")
transfer.sendmsg.should == "call-command: execute\nexecute-app-name: transfer\nexecute-app-arg: 500 XML ... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/fs_break.rb | Ruby | mit | 49 | master | 288 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("fs_break")
describe "Testing FSR::App::FsBreak" do
it "should break a connection" do
fs_break = FSR::App::FSBreak.new
fs_break.sendmsg.should == "call-command: execute\nexecute-app-name: break\n\n"
end
end |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/bridge.rb | Ruby | mit | 49 | master | 1,579 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("bridge")
describe "Testing FSR::App::Bridge" do
describe "with a single endpoint" do
before do
@bridge = FSR::App::Bridge.new("user/bougyman")
end
# Utilize the [] shortcut to start a conference
it "bridges a call, for FSR::Lis... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/limit.rb | Ruby | mit | 49 | master | 1,128 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("limit")
describe "Testing FSR::App::Limit" do
## Calls ##
# Interface to calls
it "FSR::App::Limit should send proper limit command only passing an id" do
limit = FSR::App::Limit.new("fsr_caller")
limit.raw.should == "limit($${domain} fsr... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/pre_answer.rb | Ruby | mit | 49 | master | 293 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("pre_answer")
describe "Testing FSR::App::PreAnswer" do
it "pre_answers the incoming call" do
ans = FSR::App::PreAnswer.new
ans.sendmsg.should == "call-command: execute\nexecute-app-name: pre_answer\n\n"
end
end |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/valet_park.rb | Ruby | mit | 49 | master | 947 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("valet_park")
describe "Testing FSR::App::ValetPark" do
it "puts the call into valet lot" do
valet = FSR::App::ValetPark.new("mylot", :stall_number => '5555')
valet.sendmsg.should == "call-command: execute\nexecute-app-name: valet_park\nexecu... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/fifo.rb | Ruby | mit | 49 | master | 846 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("fifo")
describe "Testing FSR::App::Fifo" do
# Utilize the [] shortcut to start a conference
it "Puts a call into a queue, with #new" do
fifo = FSR::App::Fifo.new("myqueue", "in")
fifo.raw.should == "fifo(myqueue in)"
end
it "Puts a cal... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/app/bind_meta_app.rb | Ruby | mit | 49 | master | 784 | require 'spec/helper'
require "fsr/app"
FSR::App.load_application("bind_meta_app")
describe "Testing FSR::App::BindMetaApp" do
it "binds a meta app" do
meta_app = FSR::App::BindMetaApp.new :key => 1, :listen_to => "a",
:respond_on => "s", :application => "hangup"
meta_app.sendmsg.should == "call-comman... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/listener/outbound.rb | Ruby | mit | 49 | master | 4,527 | require 'spec/helper'
require 'lib/fsr'
require "fsr/listener"
require "fsr/listener/inbound"
require "fsr/listener/outbound"
require "em-spec/bacon"
EM.spec_backend = EventMachine::Spec::Bacon
# Bare class to use for testing
class MyListener < FSR::Listener::Outbound
attr_accessor :recvd_reply, :state_machine_test, ... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/listener/header_and_content_response.rb | Ruby | mit | 49 | master | 1,544 | require 'spec/helper'
require 'fsr/listener/header_and_content_response'
describe FSL::HeaderAndContentResponse do
HCR = FSL::HeaderAndContentResponse
before do
header = {:foo => "bar", :jumbo => "shrimp"}
content = {:response => "w00t\n"}
@hcr = HCR.new({:headers => header, :content => content})
en... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/listener/inbound.rb | Ruby | mit | 49 | master | 3,859 | require 'spec/helper'
require 'lib/fsr'
require "fsr/listener"
require "fsr/listener/inbound"
require "em-spec/bacon"
EM.spec_backend = EventMachine::Spec::Bacon
# Bare class to use for testing
class InboundListener < FSR::Listener::Inbound
attr_accessor :custom_event
def post_init
before_session
end
# St... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/utils/dtmf.rb | Ruby | mit | 49 | master | 501 | require "spec/helper"
describe "FSR::Utils::DTMF module" do
it "Converts letters to numbers" do
require "fsr/utils/dtmf"
FSR::Utils::DTMF.from_string("afr").should.equal '237'
end
it "Doesn't Affect numbers" do
require "fsr/utils/dtmf"
FSR::Utils::DTMF.from_string("1234567890").should.equal '1234... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/channels.rb | Ruby | mit | 49 | master | 469 | require 'spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("channels")
describe "Testing FSR::Cmd::Channels" do
## Channels ##
# Interface to channels
it "FSR::Cmd::Channels should send show channels" do
sofia = FSR::Cmd::Channels.new(nil, false)
sofia.raw.should == "show channels"
end
it "FSR::C... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/uuid_dump.rb | Ruby | mit | 49 | master | 337 | require 'spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("uuid_dump")
describe "Testing FSR::Cmd::UuidDump" do
## Calls ##
# Interface to calls
it "FSR::Cmd::UuidDump should send uuid_dump <uid>" do
cmd = FSR::Cmd::UuidDump.new(nil, "abcd-1234-efgh-5678")
cmd.raw.should == "uuid_dump abcd-1234-efgh-... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/call_center.rb | Ruby | mit | 49 | master | 2,461 | require './spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("call_center")
describe "Testing FSR::Cmd::Callcenter" do
## Call Center ##
# Interface to mod_callcenter
it "FSR::Cmd::Callcenter should list agents " do
cmd = FSR::Cmd::CallCenter.new nil, :agent
cmd.list.raw.should == "callcenter_config a... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/sched_hangup.rb | Ruby | mit | 49 | master | 1,403 | require './spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("sched_hangup")
describe "Testing FSR::Cmd::SchedHangup" do
## Scheduled Hangup ##
it "FSR::Cmd::SchedHangup should schedule a hangup with default " do
cmd = FSR::Cmd::SchedHangup.new nil, uuid: 1234
cmd.raw.should == 'sched_hangup +1 1234 "UN... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/valet_info.rb | Ruby | mit | 49 | master | 298 | require 'spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("valet_info")
describe "Testing FSR::Cmd::ValetInfo" do
## ValetInfo ##
# Interface to valet_info
it "FSR::Cmd::ValetInfo should send valet_info" do
cmd = FSR::Cmd::ValetInfo.new
cmd.raw.should == "valet_info"
end
end |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/conference.rb | Ruby | mit | 49 | master | 2,986 | require 'spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("conference")
describe "Testing FSR::Cmd::Conference" do
it "Cannot use conference without :conference_name" do
lambda { FSR::Cmd::Conference.new(nil) }.should.raise(ArgumentError).
message.should.match(/Cannot use conference without :conference... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/calls.rb | Ruby | mit | 49 | master | 272 | require 'spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("calls")
describe "Testing FSR::Cmd::Calls" do
## Calls ##
# Interface to calls
it "FSR::Cmd::Calls should send show calls" do
cmd = FSR::Cmd::Calls.new
cmd.raw.should == "show calls"
end
end |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/enum.rb | Ruby | mit | 49 | master | 964 | require 'spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("enum")
describe "Testing FSR::Cmd::Enum" do
## Enum ##
# Interface to enum
it "FSR::Cmd::Enum should send enum <did>" do
cmd = FSR::Cmd::Enum.new(nil, "13012221111")
cmd.raw.should == "enum 13012221111"
end
it "FSR::Cmd::Enum should re... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/originate.rb | Ruby | mit | 49 | master | 2,166 | require 'spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("originate")
describe "Testing FSR::Cmd::Originate" do
# Invalid originates
it "Must be passed an argument hash" do
lambda { FSR::Cmd::Originate.new(nil, :endpoint) }.should.raise(ArgumentError).
message.should.match(/args \(Passed: <<<.*?>>>\... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/uuid_send_dtmf.rb | Ruby | mit | 49 | master | 842 | require './spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("uuid_send_dtmf")
describe "Testing FSR::Cmd::UuidSendDtmf" do
## UUID Send DTMF Tones ##
#uuid_send_dtmf <uuid> <uuid_data>
it "FSR::Cmd::UuidSendData should Send DTMF with digits" do
cmd = FSR::Cmd::UuidSendDtmf.new nil, uuid: 1234, dtmf: "555... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/sofia.rb | Ruby | mit | 49 | master | 2,128 | require 'spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("sofia")
describe "Testing FSR::Cmd::Sofia" do
## Sofia ##
# Interface to sofia
it "FSR::Cmd::Sofia should interface to sofia" do
sofia = FSR::Cmd::Sofia.new
sofia.raw.should == "sofia"
end
## Sofia Status ##
it "FSR::Cmd::Sofia should ... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/uuid_transfer.rb | Ruby | mit | 49 | master | 1,150 | require './spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("uuid_transfer")
describe "Testing FSR::Cmd::UuidTransfer" do
## UUID Transfer ##
#uuid_transfer <uuid> [-bleg|-both] <dest-exten> [<dialplan>] [<context>]
it "FSR::Cmd::UuidTransfer should Transfer with defaults" do
cmd = FSR::Cmd::UuidTransfer... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/sched_transfer.rb | Ruby | mit | 49 | master | 1,125 | require './spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("sched_transfer")
describe "Testing FSR::Cmd::SchedTransfer" do
## Scheduled Transfer ##
it "FSR::Cmd::SchedTransfer should schedule a Transfer with defaults" do
cmd = FSR::Cmd::SchedTransfer.new nil, uuid: 1234, to: "5555"
cmd.raw.should == '... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | spec/fsr/cmd/sofia/profile.rb | Ruby | mit | 49 | master | 2,173 | require 'spec/helper'
require "fsr/cmd"
FSR::Cmd.load_command("sofia")
describe "FSR::Cmd::Sofia::Profile" do
## Sofia profile ##
it "should allow FSR::Cmd::Sofia.new.profile (no arguments) through Sofia instance" do
sofia = FSR::Cmd::Sofia.new
profile = sofia.profile
profile.raw.should == "sofia prof... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/callerid_lookup/start.rb | Ruby | mit | 49 | master | 364 | # Use this file directly like `ruby start.rb` if you don't want to use the
# `ramaze start` command.
# All application related things should go into `app.rb`, this file is simply
# for options related to running the application locally.
require File.expand_path('app', File.dirname(__FILE__))
Ramaze.start(:adapter => ... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/callerid_lookup/app.rb | Ruby | mit | 49 | master | 435 | # This file contains your application, it requires dependencies and necessary
# parts of the application.
#
# It will be required from either `config.ru` or `start.rb`
require 'rubygems'
require 'ramaze'
# Add the directory this file resides in to the load path, so you can run the
# app from any other working directo... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/callerid_lookup/config.ru | Ruby | mit | 49 | master | 556 | #!/usr/bin/env rackup
#
# config.ru for ramaze apps
# use thin >= 1.0.0
# thin start -R config.ru
#
# rackup is a useful tool for running Rack applications, which uses the
# Rack::Builder DSL to configure middleware and build up applications easily.
#
# rackup automatically figures out the environment it is run in, and... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/callerid_lookup/spec/main.rb | Ruby | mit | 49 | master | 573 | require 'ramaze'
require 'ramaze/spec'
require __DIR__('../start')
Ramaze.options.roots = __DIR__('../')
describe MainController do
behaves_like :mock
should 'show start page' do
get('/').status.should == 200
last_response['Content-Type'].should == 'text/html'
last_response.should =~ /<h1>Welcome to ... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/callerid_lookup/controller/init.rb | Ruby | mit | 49 | master | 261 | # Define a subclass of Ramaze::Controller holding your defaults for all
# controllers
class Controller < Ramaze::Controller
layout :default
helper :xhtml
engine :Etanni
end
# Here go your requires for subclasses of Controller:
require 'controller/main' |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/callerid_lookup/controller/main.rb | Ruby | mit | 49 | master | 739 | # Default url mappings are:
# a controller called Main is mapped on the root of the site: /
# a controller called Something is mapped on: /something
# If you want to override this, add a line like this inside the class
# map '/otherurl'
# this will force the controller to be mounted on: /otherurl
class MainControll... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/callerid/lib/callerid_lookup.rb | Ruby | mit | 49 | master | 1,018 | #!/usr/bin/env ruby
require "rubygems"
require "fsr"
$stdout.flush
require "fsr/listener/outbound"
class CalleridLookup < FSR::Listener::Outbound
def session_initiated
@inbound_number = @session.headers[:caller_caller_id_number] # Grab the inbound caller id
@outbound_number = @session.headers[:caller_desti... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/conferenceme/start_common.rb | Ruby | mit | 49 | master | 338 | require 'rubygems'
require 'ramaze'
# Add directory start.rb is in to the load path, so you can run the app from
# any other working path
$LOAD_PATH.unshift(__DIR__)
# Initialize controllers and models
require "fsr"
require "fsr/command_socket"
require 'model/init'
require 'controller/init'
require 'model/init'
FSR.... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/conferenceme/start.ru | Ruby | mit | 49 | master | 537 | #!/usr/bin/env rackup
# start.ru for ramaze apps
# use thin>=0.6.3
# thin start -r start.ru
#
# rackup is a useful tool for running Rack applications, which uses the
# Rack::Builder DSL to configure middleware and build up applications easily.
#
# rackup automatically figures out the environment it is run in, and runs ... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/conferenceme/helper/form.rb | Ruby | mit | 49 | master | 2,849 | require 'ramaze/gestalt'
module Ramaze
module Helper
module Form
def form_ac(function, label, name, value = nil)
ac_options = "ajax_get:#{function}, minchars:1, autowidth:true, multi:true"
input(
label,
:onfocus => "$(this).autocomplete({#{ac_options}})",
:typ... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/conferenceme/model/user.rb | Ruby | mit | 49 | master | 1,431 | class User < Sequel::Model
set_schema do
primary_key :id
varchar :login, :unique => true
varchar :nick, :unique => true
varchar :digest
varchar :openid, :unique => true
varchar :email, :unique => true
end
create_table!
attr_accessor :pass
def self.authenticate(hash)
login, pass... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/conferenceme/model/conference.rb | Ruby | mit | 49 | master | 341 | require "fsr"
require "fsr/command_socket"
class Conference
def list
require "hpricot"
@sock ||= FSR::CommandSocket.new
confs = Hpricot(@sock.say("api conference xml_list")["body"])
all_conf_names = (confs/:conferences/:conference).map { |n| n[:name] }
end
def self.exists?(name)
new.list.incl... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/conferenceme/spec/main.rb | Ruby | mit | 49 | master | 583 | require 'ramaze'
require 'ramaze/spec/helper'
require __DIR__('../start')
describe MainController do
behaves_like 'http', 'xpath'
ramaze :view_root => __DIR__('../view'),
:public_root => __DIR__('../public')
it 'should show start page' do
got = get('/')
got.status.should == 200
puts got.bo... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/conferenceme/controller/init.rb | Ruby | mit | 49 | master | 335 | # Define a subclass of Ramaze::Controller holding your defaults for all
# controllers
class Controller < Ramaze::Controller
layout '/page'
helper :xhtml, :user, :form, :stack
engine :Haml
end
# Here go your requires for subclasses of Controller:
require 'controller/main'
require 'controller/auth'
require 'contr... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/conferenceme/controller/main.rb | Ruby | mit | 49 | master | 2,968 | class MainController < Controller
def about
@title = "Welcome to ConfMe, The Conference Service that calls You!"
end
# the index action is called automatically when no other action is specified
def index
@title = "Welcome to ConfMe, The Conference Service that calls You!"
end
def start
phone_n... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | contrib/apps/conferenceme/controller/auth.rb | Ruby | mit | 49 | master | 3,564 | class AuthController < Controller
map '/auth'
helper :simple_captcha, :identity
def index
redirect_referer if request.referer =~ /\/auth\/\w+$/
redirect Rs(:login)
end
def new
redirect_referrer if logged_in?
@user = User.prepare(request.params)
# they will be used in the form
@login,... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | tasks/bacon.rake | Ruby | mit | 49 | master | 1,828 | desc 'Run all bacon specs with pretty output'
task :bacon => :install_dependencies do
require 'open3'
require 'scanf'
require 'matrix'
specs = PROJECT_SPECS
some_failed = false
specs_size = specs.size
len = specs.map{|s| s.size }.sort.last
total_tests = total_assertions = total_failures = total_errors... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | tasks/gem_installer.rake | Ruby | mit | 49 | master | 1,693 | task :gem_installer do
class GemInstaller
def initialize(options = {}, &block)
@gems = []
@options = options
run(&block)
end
def run(&block)
instance_eval(&block) if block_given?
end
def gem(name, version = nil, options = {})
if version.respond_to?(:merge!)
... |
github | bougyman/freeswitcher | https://github.com/bougyman/freeswitcher | tasks/gem.rake | Ruby | mit | 49 | master | 581 | require 'rake/gempackagetask'
desc "make a gemspec"
task :gemspec => [:manifest, :changelog, :authors] do
gemspec_file = "#{GEMSPEC.name}.gemspec"
File.open(gemspec_file, 'w+'){|gs| gs.puts(GEMSPEC.to_ruby) }
end
desc "package and install from gemspec"
task :install => [:gemspec] do
sh "gem build #{GEMSPEC.name... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.