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 | y10k/rims | https://github.com/y10k/rims | test/test_cksum_kvs.rb | Ruby | mit | 45 | master | 3,519 | # -*- coding: utf-8 -*-
require 'pp' if $DEBUG
require 'rims'
require 'test/unit'
module RIMS::Test
class Checksum_KeyValueStoreTest < Test::Unit::TestCase
def setup
@db = {}
@builder = RIMS::KeyValueStore::FactoryBuilder.new
@builder.open{|name| RIMS::Hash_KeyValueStore.new(@db) }
@buil... |
github | y10k/rims | https://github.com/y10k/rims | test/test_passwd.rb | Ruby | mit | 45 | master | 6,089 | # -*- coding: utf-8 -*-
require 'digest'
require 'logger'
require 'pp' if $DEBUG
require 'rims'
require 'test/unit'
module RIMS::Test
class PasswordPlainSourceTest < Test::Unit::TestCase
def setup
@logger = Logger.new(STDOUT)
@logger.level = ($DEBUG) ? Logger::DEBUG : Logger::FATAL
@username ... |
github | y10k/rims | https://github.com/y10k/rims | test/test_protocol_auth.rb | Ruby | mit | 45 | master | 5,706 | # -*- coding: utf-8 -*-
require 'logger'
require 'rims'
require 'test/unit'
module RIMS::Test
class ProtocolAuthenticationReaderTest < Test::Unit::TestCase
include RIMS::Test::PseudoAuthenticationUtility
def setup
src_time = Time.at(1404360345)
random_seed = 212687380986801693724170864620978811... |
github | y10k/rims | https://github.com/y10k/rims | test/test_db.rb | Ruby | mit | 45 | master | 20,045 | # -*- coding: utf-8 -*-
require 'pp' if $DEBUG
require 'rims'
require 'set'
require 'test/unit'
module RIMS::Test
class DBMetaTest < Test::Unit::TestCase
def setup
@kvs = {}
@db = RIMS::DB::Meta.new(RIMS::Hash_KeyValueStore.new(@kvs))
end
def teardown
pp @kvs if $DEBUG
end
de... |
github | y10k/rims | https://github.com/y10k/rims | test/cmd/test_command.rb | Ruby | mit | 45 | master | 110,302 | # -*- coding: utf-8 -*-
require 'fileutils'
require 'logger'
require 'net/imap'
require 'open3'
require 'pathname'
require 'pp' if $DEBUG
require 'rims'
require 'set'
require 'test/unit'
require 'time'
require 'timeout'
require 'yaml'
module RIMS::Test
class CommandTest < Test::Unit::TestCase
include Timeout
... |
github | livebg/smstools | https://github.com/livebg/smstools | smstools.gemspec | Ruby | mit | 45 | master | 1,111 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'sms_tools/version'
Gem::Specification.new do |spec|
spec.name = 'smstools'
spec.version = SmsTools::VERSION
spec.authors = ['Dimitar Dimitrov']
spec.email = [... |
github | livebg/smstools | https://github.com/livebg/smstools | spec/sms_tools/gsm_encoding_spec.rb | Ruby | mit | 45 | master | 1,266 | require 'spec_helper'
require 'sms_tools'
describe SmsTools::GsmEncoding do
describe 'from_utf8' do
it 'converts simple UTF-8 text to GSM 03.38' do
SmsTools::GsmEncoding.from_utf8('simple').must_equal 'simple'
end
it 'converts UTF-8 text with double-byte chars to GSM 03.38' do
SmsTools::GsmE... |
github | livebg/smstools | https://github.com/livebg/smstools | spec/sms_tools/encoding_detection_spec.rb | Ruby | mit | 45 | master | 8,684 | require 'spec_helper'
require 'sms_tools'
describe SmsTools::EncodingDetection do
it "exposes the original text as a method" do
detection_for('foo').text.must_equal 'foo'
end
describe "encoding" do
it "defaults to ASCII encoding for empty messages" do
detection_for('').encoding.must_equal :ascii
... |
github | livebg/smstools | https://github.com/livebg/smstools | lib/sms_tools.rb | Ruby | mit | 45 | master | 609 | require 'sms_tools/version'
require 'sms_tools/encoding_detection'
require 'sms_tools/gsm_encoding'
require 'sms_tools/unicode_encoding'
if defined?(::Rails) and ::Rails.version >= '3.1'
require 'sms_tools/rails/engine'
end
module SmsTools
class << self
def use_gsm_encoding?
@use_gsm_encoding.nil? ? tru... |
github | livebg/smstools | https://github.com/livebg/smstools | lib/sms_tools/unicode_encoding.rb | Ruby | mit | 45 | master | 608 | module SmsTools
module UnicodeEncoding
extend self
BASIC_PLANE = 0x0000..0xFFFF
# UCS-2/UTF-16 is used for unicode text messaging. UCS-2/UTF-16 represents characters in minimum
# 2-bytes, any characters in the basic plane are represented with 2-bytes, so each codepoint
# within the Basic Plane c... |
github | livebg/smstools | https://github.com/livebg/smstools | lib/sms_tools/gsm_encoding.rb | Ruby | mit | 45 | master | 8,224 | module SmsTools
# UTF-8 to GSM-7 (GSM 03.38) mapping. Based on code from:
# https://github.com/threez/smspromote/blob/master/lib/smspromote/encoding.rb
module GsmEncoding
extend self
GSM_EXTENSION_TABLE_ESCAPE_CODE = "\x1B".freeze
UTF8_TO_GSM_BASE_TABLE = {
0x0040 => "\x00", # COMMERCIAL AT
... |
github | livebg/smstools | https://github.com/livebg/smstools | lib/sms_tools/encoding_detection.rb | Ruby | mit | 45 | master | 1,744 | require 'sms_tools/gsm_encoding'
module SmsTools
class EncodingDetection
MAX_LENGTH_FOR_ENCODING = {
ascii: {
normal: 160,
concatenated: 153,
},
gsm: {
normal: 160,
concatenated: 153,
},
unicode: {
normal: 70,
concate... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | administrate_exportable.gemspec | Ruby | mit | 45 | main | 1,669 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "administrate_exportable/version"
Gem::Specification.new do |spec|
spec.name = "administrate_exportable"
spec.version = AdministrateExportable::VERSION
spec.authors = ["Jônatas Rancan", "Andrei Bondarev"]
... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/rails_helper.rb | Ruby | mit | 45 | main | 370 | # frozen_string_literal: true
ENV["RAILS_ENV"] ||= "test"
require "rails/all"
require "dummy/config/environment"
# Setup test database
ActiveRecord::Tasks::DatabaseTasks.drop_current
ActiveRecord::Tasks::DatabaseTasks.create_current
ActiveRecord::Tasks::DatabaseTasks.load_schema_current
require "rspec/rails"
requir... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/administrate_exportable_spec.rb | Ruby | mit | 45 | main | 268 | require "rails_helper"
RSpec.describe AdministrateExportable do
it "has a version number" do
expect(AdministrateExportable::VERSION).not_to be nil
end
it "has a PAGE_PARAM constant" do
expect(AdministrateExportable::PAGE_PARAM).not_to be nil
end
end |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/spec_helper.rb | Ruby | mit | 45 | main | 345 | require "bundler/setup"
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 do |c|
c.sy... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/administrate_exportable/exporter_concern_spec.rb | Ruby | mit | 45 | main | 492 | require "rails_helper"
RSpec.describe "Exporter Concern", type: :request do
describe "GET export" do
it "returns a csv file" do
get export_admin_users_url(format: :csv)
expect(response.header["Content-Type"]).to include "text/csv"
end
it "calls ExporterService" do
expect(AdministrateE... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/administrate_exportable/exporter_service_spec.rb | Ruby | mit | 45 | main | 3,342 | require "rails_helper"
RSpec.describe AdministrateExportable::ExporterService, type: :helper do
describe "#csv" do
let(:result) { AdministrateExportable::ExporterService.csv(UserDashboard.new, User, User.all) }
let(:parsed_data) { CSV.parse(result) }
before do
user = User.create(first_name: "John"... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/dummy/Gemfile | Ruby | mit | 45 | main | 409 | source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", "~> 7.1.0"
gem "sqlite3"
gem "administrate", "~> 0.19.0"
gem "administrate_exportable", path: File.path("../../")
group :development, :test do
gem "rb-readline"
gem "byebug", platforms: [:mri, :mingw, :x64_m... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/dummy/app/controllers/admin/application_controller.rb | Ruby | mit | 45 | main | 384 | # All Administrate controllers inherit from this `Admin::ApplicationController`,
# making it the ideal place to put authentication logic or other
# before_actions.
#
# If you want to add pagination or other controller-level concerns,
# you're free to overwrite the RESTful controller actions.
module Admin
class Applic... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/dummy/app/dashboards/user_dashboard.rb | Ruby | mit | 45 | main | 1,706 | require "administrate/base_dashboard"
class UserDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/dummy/app/dashboards/cat_dashboard.rb | Ruby | mit | 45 | main | 1,386 | require "administrate/base_dashboard"
class CatDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout ... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/dummy/app/dashboards/dog_dashboard.rb | Ruby | mit | 45 | main | 1,546 | require "administrate/base_dashboard"
class DogDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout ... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/dummy/db/schema.rb | Ruby | mit | 45 | main | 1,527 | # 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.
#
# This file is the source Rails uses to define your schema when running `bin/rai... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/dummy/config/routes.rb | Ruby | mit | 45 | main | 204 | Rails.application.routes.draw do
namespace :admin do
resources :users, :dogs, :cats do
get :export, on: :collection
end
root to: "users#index"
end
root to: redirect("/admin")
end |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/dummy/config/application.rb | Ruby | mit | 45 | main | 1,088 | require_relative "boot"
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
# require "action_mailer/railtie"
require "action_view/railtie"
# require "action_cab... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/dummy/config/environments/test.rb | Ruby | mit | 45 | main | 1,462 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suit... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | spec/dummy/config/environments/development.rb | Ruby | mit | 45 | main | 1,691 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | lib/administrate_exportable.rb | Ruby | mit | 45 | main | 354 | require "administrate_exportable/version"
require "administrate_exportable/exporter_service"
require "administrate_exportable/exporter"
require "administrate/version"
module AdministrateExportable
PAGE_PARAM = (Gem::Version.create(Administrate::VERSION) >= Gem::Version.create("0.15.0")) ? "_page" : "page"
class E... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | lib/administrate_exportable/exporter.rb | Ruby | mit | 45 | main | 749 | module AdministrateExportable
module Exporter
extend ActiveSupport::Concern
included do
exportable
end
class_methods do
def exportable
define_method(:export) do
search_term = params[:search].to_s.strip
resources = Administrate::Search.new(scoped_resource,
... |
github | SourceLabsLLC/administrate_exportable | https://github.com/SourceLabsLLC/administrate_exportable | lib/administrate_exportable/exporter_service.rb | Ruby | mit | 45 | main | 2,613 | require "csv"
module AdministrateExportable
class ExporterService
def self.csv(dashboard, resource_class, resources)
new(dashboard, resource_class, resources).csv
end
def initialize(dashboard, resource_class, resources)
@dashboard = dashboard
@resource_class = resource_class
@res... |
github | xwaynec/active_merchant_allpay | https://github.com/xwaynec/active_merchant_allpay | Rakefile | Ruby | mit | 45 | master | 325 | require "bundler/gem_tasks"
require 'rake/testtask'
desc "Run the unit test suite"
task :default => 'test:units'
task :test => 'test:units'
namespace :test do
Rake::TestTask.new(:units) do |t|
t.pattern = 'test/unit/**/*_test.rb'
t.ruby_opts << '-rubygems'
t.libs << 'test'
t.verbose = true
end
... |
github | xwaynec/active_merchant_allpay | https://github.com/xwaynec/active_merchant_allpay | active_merchant_allpay.gemspec | Ruby | mit | 45 | master | 1,248 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'active_merchant_allpay/version'
Gem::Specification.new do |spec|
spec.name = "active_merchant_allpay"
spec.version = ActiveMerchantAllpay::VERSION
spec.authors = ["xway... |
github | xwaynec/active_merchant_allpay | https://github.com/xwaynec/active_merchant_allpay | lib/active_merchant_allpay.rb | Ruby | mit | 45 | master | 316 | require 'action_view'
require 'active_merchant_allpay/version'
require 'active_merchant'
require 'money'
require 'offsite_payments'
module OffsitePayments
module Integrations
autoload :Allpay, 'offsite_payments/integrations/allpay'
end
end
ActionView::Base.send(:include, OffsitePayments::ActionViewHelper) |
github | xwaynec/active_merchant_allpay | https://github.com/xwaynec/active_merchant_allpay | lib/offsite_payments/integrations/allpay.rb | Ruby | mit | 45 | master | 1,710 | require File.dirname(__FILE__) + '/allpay/helper.rb'
require File.dirname(__FILE__) + '/allpay/notification.rb'
module OffsitePayments #:nodoc:
module Integrations #:nodoc:
module Allpay
PAYMENT_CREDIT_CARD = 'Credit'
PAYMENT_ATM = 'ATM'
PAYMENT_CVS = 'CVS'
PAYMENT_ALIPAY ... |
github | xwaynec/active_merchant_allpay | https://github.com/xwaynec/active_merchant_allpay | lib/offsite_payments/integrations/allpay/helper.rb | Ruby | mit | 45 | master | 6,492 | require 'digest/md5'
module OffsitePayments #:nodoc:
module Integrations #:nodoc:
module Allpay
class Helper < OffsitePayments::Helper
### 預設介面
# 廠商編號(由 allpay 提供)
# type: Varchar(10)
# presense: true
# example: 2000132
# description:
mapping :mercha... |
github | xwaynec/active_merchant_allpay | https://github.com/xwaynec/active_merchant_allpay | lib/offsite_payments/integrations/allpay/notification.rb | Ruby | mit | 45 | master | 3,624 | require 'net/http'
module OffsitePayments #:nodoc:
module Integrations #:nodoc:
module Allpay
class Notification < OffsitePayments::Notification
def status
if rtn_code == '1'
true
else
false
end
end
# TODO 使用查詢功能實作 acknowledge
... |
github | xwaynec/active_merchant_allpay | https://github.com/xwaynec/active_merchant_allpay | test/test_helper.rb | Ruby | mit | 45 | master | 2,608 | #!/usr/bin/env ruby
$:.unshift File.expand_path('../../lib', __FILE__)
begin
require 'rubygems'
require 'bundler'
Bundler.setup
rescue LoadError => e
puts "Error loading bundler (#{e.message}): \"gem install bundler\" for bundler support."
end
require 'active_merchant_allpay'
require 'test/unit'
require 'mon... |
github | xwaynec/active_merchant_allpay | https://github.com/xwaynec/active_merchant_allpay | test/unit/integrations/allpay_notification_test.rb | Ruby | mit | 45 | master | 1,186 | require 'test_helper'
class AllpayNotificationTest < Test::Unit::TestCase
include OffsitePayments::Integrations
def setup
OffsitePayments::Integrations::Allpay.hash_key = '5294y06JbISpM5x9'
OffsitePayments::Integrations::Allpay.hash_iv = 'v77hoKGq4kWxNNIS'
@allpay = Allpay::Notification.new(http_raw_d... |
github | xwaynec/active_merchant_allpay | https://github.com/xwaynec/active_merchant_allpay | test/unit/integrations/allpay_helper_test.rb | Ruby | mit | 45 | master | 1,965 | require 'test_helper'
class AllpayHelperTest < Test::Unit::TestCase
include OffsitePayments::Integrations
def setup
end
def test_check_mac_value
@helper = Allpay::Helper.new 'sdfasdfa', '12345678'
@helper.add_field 'ItemName', 'sdfasdfa'
@helper.add_field 'MerchantID', '12345678'
@helper.add_... |
github | xwaynec/active_merchant_allpay | https://github.com/xwaynec/active_merchant_allpay | test/unit/integrations/allpay_module_test.rb | Ruby | mit | 45 | master | 229 | require 'test_helper'
class AllpayModuleTest < Test::Unit::TestCase
include OffsitePayments::Integrations
def test_notification_method
assert_instance_of Allpay::Notification, Allpay.notification('name=cody')
end
end |
github | tomykaira/qspec | https://github.com/tomykaira/qspec | qspec.gemspec | Ruby | mit | 45 | master | 922 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'qspec/version'
Gem::Specification.new do |gem|
gem.name = "qspec"
gem.version = Qspec::VERSION
gem.authors = ["tomykaira"]
gem.email = ["tomykaira@g... |
github | tomykaira/qspec | https://github.com/tomykaira/qspec | lib/qspec.rb | Ruby | mit | 45 | master | 567 | require 'rspec/core'
require 'qspec/version'
require 'qspec/ipc'
require 'qspec/command_line'
require 'qspec/formatters/redis_formatter'
require 'qspec/config'
require 'qspec/helper'
module Qspec
class << self
def path(filename)
File.join(tmp_directory_path, filename)
end
def tmp_directory_path
... |
github | tomykaira/qspec | https://github.com/tomykaira/qspec | lib/qspec/command_line.rb | Ruby | mit | 45 | master | 4,313 | require 'parallel'
module Qspec
class CommandLine
TIME_LOG_NAME = 'elapsed_time'
DEFAULT_ELAPSED_TIME = 3.0
attr_reader :ipc, :config, :id
def initialize(args)
@config = Config.new()
@ipc = IPC.from_config(@config)
@id = rand(10000)
@stats = []
@rspec_options = RSpec::Co... |
github | tomykaira/qspec | https://github.com/tomykaira/qspec | lib/qspec/config.rb | Ruby | mit | 45 | master | 1,217 | require 'yaml'
module Qspec
class Config
DEFAULT_PATH = '.qspec.yml'
def initialize(path = DEFAULT_PATH)
@path = path
if File.exists?(path)
@config = YAML.load_file(path)
else
STDERR.puts "You do not have #{path}. Initialize with `qspec-helper init`"
exit 1
e... |
github | tomykaira/qspec | https://github.com/tomykaira/qspec | lib/qspec/ipc.rb | Ruby | mit | 45 | master | 622 | module Qspec
# abstract
class IPC
def self.from_config(config)
name = config['ipc']
@@default =
case name
when 'redis'
require 'qspec/ipc/redis'
IPC::Redis.new(config['redis'])
when 'file', nil
require 'qspec/ipc/file'
IPC::File.new(con... |
github | tomykaira/qspec | https://github.com/tomykaira/qspec | lib/qspec/helper.rb | Ruby | mit | 45 | master | 227 | module Qspec
class Helper
def initialize(argv)
@argv = argv
end
def serve
case @argv.last
when 'init'
puts "Creating template"
Config.create_template
end
end
end
end |
github | tomykaira/qspec | https://github.com/tomykaira/qspec | lib/qspec/formatters/redis_formatter.rb | Ruby | mit | 45 | master | 1,083 | require 'rspec/core/formatters/base_formatter'
module Qspec
module Formatters
module RedisFormatterFactory
def self.build(id, file)
Class.new(RSpec::Core::Formatters::BaseFormatter) do
RSpec::Core::Formatters.register self, :dump_summary, :dump_failures
@@id = id
@@fil... |
github | tomykaira/qspec | https://github.com/tomykaira/qspec | lib/qspec/ipc/redis.rb | Ruby | mit | 45 | master | 435 | require 'redis'
module Qspec
class IPC
class Redis < IPC
def initialize(config)
config ||= {}
@redis = ::Redis.new(config)
@namespace = config['namespace'] || 'qspec'
end
[:del, :lpop, :rpush, :llen].each do |method|
define_method(method) do |*args|
key... |
github | tomykaira/qspec | https://github.com/tomykaira/qspec | lib/qspec/ipc/file.rb | Ruby | mit | 45 | master | 1,304 | require 'fileutils'
module Qspec
class IPC
class File < IPC
def initialize(config)
end
def del(key)
::File.unlink(Qspec.path(key)) rescue nil
end
def lpop(key)
open(key, :rw) do |f|
list = safe_load(f)
f.truncate(0)
f.rewind
... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | Rakefile | Ruby | mit | 45 | master | 1,381 | require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specificati... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | Gemfile | Ruby | mit | 45 | master | 362 | source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
# gem "activesupport", ">= 2.3.5"
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
gem "shoulda", ">= 0"
gem "bundler", "~> 1.0.0"
gem "jewe... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | social_engine.gemspec | Ruby | mit | 45 | master | 5,291 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{social_engine}
s.version = "0.0.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | lib/social_engine.rb | Ruby | mit | 45 | master | 313 | SOCIAL_ENGINE_PATH = File.dirname(__FILE__) + "/social_engine"
require "#{SOCIAL_ENGINE_PATH}/core_ext/array.rb"
require "#{SOCIAL_ENGINE_PATH}/core_ext/hash.rb"
require "#{SOCIAL_ENGINE_PATH}/engine.rb"
require "inherited_resources"
require "haml"
require "formtastic"
require "yettings"
module SocialEngine
end |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | lib/generators/social_engine/user_reputation/user_reputation_generator.rb | Ruby | mit | 45 | master | 651 | require 'rails/generators'
require 'rails/generators/migration'
module SocialEngine
class UserReputationGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root File.join(File.dirname(__FILE__), 'templates')
def self.next_migration_number(dirname)
sleep 1
if ... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | lib/generators/social_engine/install/install_generator.rb | Ruby | mit | 45 | master | 1,476 | require 'rails/generators'
require 'rails/generators/migration'
module SocialEngine
class InstallGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root File.join(File.dirname(__FILE__), 'templates')
def self.next_migration_number(dirname)
sleep 1
if ActiveR... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | lib/generators/social_engine/install/templates/create_friendings_table.rb | Ruby | mit | 45 | master | 527 | class CreateFriendingsTable < ActiveRecord::Migration
def self.up
create_table :friendings, :force => true do |t|
t.integer :friendor_id
t.integer :friendee_id
t.boolean :confirmed, :default => false
t.boolean :rejected, :default => false
t.timestamps
end
add_index :frie... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | lib/generators/social_engine/install/templates/create_comments_table.rb | Ruby | mit | 45 | master | 723 | class CreateCommentsTable < ActiveRecord::Migration
def self.up
create_table :comments, :force => true do |t|
t.string :commentable_type
t.integer :commentable_id
t.integer :user_id
t.text :comment
t.string :unauthenticated_name
t.string :unauthenticated_email
t.string :u... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | lib/generators/social_engine/install/templates/create_reputations_table.rb | Ruby | mit | 45 | master | 566 | class CreateReputationsTable < ActiveRecord::Migration
def self.up
create_table :reputations, :force => true do |t|
t.integer :user_id
t.integer :reputation_action_id
t.integer :value
t.timestamps
end
add_index :reputations, [:user_id,:reputation_action_id], :name => "user_rep... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | lib/generators/social_engine/install/templates/create_ratings_table.rb | Ruby | mit | 45 | master | 591 | class CreateRatingsTable < ActiveRecord::Migration
def self.up
create_table :ratings, :force => true do |t|
t.string :rateable_type
t.integer :rateable_id
t.integer :value
t.integer :user_id
t.string :ip_address
t.string :session_hash
t.string :browser_fingerprint
... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | lib/generators/social_engine/install/templates/create_favorites_table.rb | Ruby | mit | 45 | master | 587 | class CreateFavoritesTable < ActiveRecord::Migration
def self.up
create_table :favorites, :force => true do |t|
t.string :favoriteable_type
t.integer :favoriteable_id
t.integer :user_id
t.string :ip_address
t.string :session_hash
t.string :browser_fingerprint
t.timestamps... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | lib/generators/social_engine/install/templates/create_reputation_actions_table.rb | Ruby | mit | 45 | master | 299 | class CreateReputationActionsTable < ActiveRecord::Migration
def self.up
create_table :reputation_actions, :force => true do |t|
t.string :name
t.text :description
t.integer :value
t.timestamps
end
end
def self.down
drop_table :reputation_actions
end
end |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | lib/generators/social_engine/install/templates/create_votes_table.rb | Ruby | mit | 45 | master | 583 | class CreateVotesTable < ActiveRecord::Migration
def self.up
create_table :votes, :force => true do |t|
t.string :voteable_type
t.integer :voteable_id
t.integer :user_id
t.integer :value
t.string :ip_address
t.string :session_hash
t.string :browser_fingerprint ... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | lib/social_engine/engine.rb | Ruby | mit | 45 | master | 1,896 | require "social_engine"
require "rails"
module SocialEngine
class Engine < Rails::Engine
initializer 'social_engine.ar_extensions', :before=>"action_controller.deprecated_routes" do |app|
ActiveRecord::Base.extend SocialEngine::Voteable
ActiveRecord::Base.extend SocialEngine::Commentable
Active... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | lib/social_engine/core_ext/hash.rb | Ruby | mit | 45 | master | 635 | class Hash
def recursively_symbolize_keys!
self.symbolize_keys!
self.values.each do |v|
if v.is_a? Hash
v.recursively_symbolize_keys!
elsif v.is_a? Array
v.recursively_symbolize_keys!
end
end
self
end
def optional_reverse_merge!(defaults,required=[],symbolize=t... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | lib/social_engine/core_ext/array.rb | Ruby | mit | 45 | master | 250 | class Array
def to_options_hash
hash = {}
self.each do |element|
if element.is_a? Symbol
hash[element] = {}
elsif element.is_a? Hash
hash[element.keys[0]] = element.values[0]
end
end
hash
end
end |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/Gemfile | Ruby | mit | 45 | master | 415 | source 'http://rubygems.org'
gem 'rails', '3.2.22.5'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'social_engine', :path => File.expand_path("../../", __FILE__)
group :test do
gem 'cucumber'
gem 'cucumber-rails'
gem 'capybara'
gem 'database_cleaner'
gem 'launchy'
gem "autotest-rails"
gem "autotest-noti... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/features/step_definitions/web_steps.rb | Ruby | mit | 45 | master | 6,079 | # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/features/step_definitions/social_engine_steps.rb | Ruby | mit | 45 | master | 5,284 | require 'systemu'
MIGRATION_FILES = ["create_comments_table",
"create_votes_table",
"create_ratings_table",
"create_favorites_table",
"create_reputations_table",
"create_reputation_actions_table",
"create_... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/features/support/paths.rb | Ruby | mit | 45 | master | 1,217 | module NavigationHelpers
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
#
# step definition in web_steps.rb
#
def path_to(page_name)
case page_name
when /the home\s?page/
'/'
when /the comments test form page/
'/articles/1/comments_test/'
... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/features/support/env.rb | Ruby | mit | 45 | master | 1,570 | require 'cucumber/rails'
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
# order to ease the transition to Capybara we set the default here. If you'd
# prefer to use XPath just remove this line and adjust any selectors in your
# steps to use the XPath syntax.
Capybara.default_selector =... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/db/schema.rb | Ruby | mit | 45 | master | 2,133 | # 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 source for your
# dat... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/db/migrate/20110121044132_create_article_table.rb | Ruby | mit | 45 | master | 245 | class CreateArticleTable < ActiveRecord::Migration
def self.up
create_table :articles, :force => true do |t|
t.string :name
t.integer :user_id
t.timestamps
end
end
def self.down
drop_table :articles
end
end |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/db/migrate/20110127034054_add_email_website_to_users.rb | Ruby | mit | 45 | master | 249 | class AddEmailWebsiteToUsers < ActiveRecord::Migration
def self.up
add_column :users, :email, :string
add_column :users, :website, :string
end
def self.down
remove_column :users, :website
remove_column :users, :email
end
end |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/db/migrate/20110207033938_create_reviews_table.rb | Ruby | mit | 45 | master | 496 | class CreateReviewsTable < ActiveRecord::Migration
def self.up
create_table :reviews, :force => true do |t|
t.string :reviewable_type
t.integer :reviewable_id
t.integer :user_id
t.string :unauthenticated_name
t.string :unauthenticated_email
t.string :unauthenticated_website
... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/spec/spec_helper.rb | Ruby | mit | 45 | master | 1,774 | require 'rubygems'
require 'spork'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
end
Spork.each_run do
# This code will be run each time yo... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/spec/models/favorites_spec.rb | Ruby | mit | 45 | master | 367 | require 'spec_helper'
describe Favorite do
it "should be able to favorite and unfavorite an article" do
user = mock_model(User, :id => 1,:name => "Mock Name", :email=>"mock@email.com", :website=>"http://mockwebsite.com")
article = Article.create(name:"test")
article.favorites.create(user_id:user.id)
... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/spec/models/friendings_spec.rb | Ruby | mit | 45 | master | 1,999 | require 'spec_helper'
describe Friending do
fixtures :users, :friendings
it "should find john's friends" do
john = users(:john)
friends = john.friends
friends.should include(users(:johns_friend))
friends.should include(users(:everyones_friend))
friends.should_not include(users(:rejected_frie... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/spec/models/ratings_spec.rb | Ruby | mit | 45 | master | 1,109 | require 'spec_helper'
describe Rating do
fixtures :articles
before(:each) do
@article = Article.find(99)
end
it "should be able to rate an article with a rating" do
@article.ratings.create(value:5)
@article.ratings.size.should eq 1
@article.ratings.first.value.should eq 5
end
it "should... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/spec/models/votes_spec.rb | Ruby | mit | 45 | master | 1,505 | require 'spec_helper'
describe Vote do
it "should be able to vote an article" do
article =Article.create(name: "test")
article.votes.create(:value=>1)
article.votes.size.should eq 1
end
it "should show the total vote count of an article as 1 after one upvote" do
article =Article.create(name: "... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/spec/models/reputation_spec.rb | Ruby | mit | 45 | master | 2,369 | require 'spec_helper'
describe SocialEngine::Reputatable do
it "should show that user is attached to sociable things" do
post = Post.create(name: "post")
user = User.create(name:"john")
user.votes.size.should eq 0
user.comments.size.should eq 0
user.ratings.size.should eq 0
post.votes.create(... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/spec/models/social_engine_spec.rb | Ruby | mit | 45 | master | 694 | require 'spec_helper'
describe SocialEngine do
it "should include its methods in AR" do
ActiveRecord::Base.methods.include?(:is_commentable).should be true
ActiveRecord::Base.methods.include?(:is_rateable).should be true
ActiveRecord::Base.methods.include?(:is_favoriteable).should be true
ActiveR... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/spec/models/comments_spec.rb | Ruby | mit | 45 | master | 1,786 | require 'spec_helper'
describe Comment do
fixtures :articles
before(:each) do
@article = Article.find(99)
end
it "should be able to save a comment for an article" do
@article.comments.create(:comment=>"this is a test comment")
@article.comments.size.should eq 1
@article.comments[0].comment.sho... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/spec/core_ext/array_spec.rb | Ruby | mit | 45 | master | 395 | require 'spec_helper'
describe Array do
it "should the options hash from an array" do
a = [:name, {:email=>{:label=>"test"}}, :website]
expected = {:name=>{},:email=>{:label=>"test"},:website=>{}}
a.to_options_hash.should eq expected
end
it "should return empty hash if no options in array" do
... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/spec/core_ext/hash_spec.rb | Ruby | mit | 45 | master | 1,320 | require 'spec_helper'
describe Hash do
it "should recursively symbolize itself" do
test = {"what"=>{"is"=>"this"}}
expected_result = {:what=>{:is=>"this"}}
test.recursively_symbolize_keys!.should eq expected_result
end
it "should merge options and return the defaults if options are blank" do
... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/config/routes.rb | Ruby | mit | 45 | master | 481 | TestApp::Application.routes.draw do
resources :articles do
collection do
get :comments_list
end
resources :comments,:votes,:ratings,:favorites
end
match "/third_party/tweetme", to: "third_party#tweetme"
match "/third_party/fb_like", to: "third_party#fb_like"
match "/third_party/fb_friend_box... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/config/initializers/secret_token.rb | Ruby | mit | 45 | master | 498 | # Be sure to restart your server when you modify this file.
# Your secret key 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 dictionary attac... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/app/controllers/application_controller.rb | Ruby | mit | 45 | master | 261 | class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user, :logged_in?
def current_user
@current_user ||= User.find(session[:user_id]) rescue nil
end
def logged_in?
current_user != nil
end
end |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | test_app/app/controllers/mock_auth_controller.rb | Ruby | mit | 45 | master | 217 | # Mocking login/ logout
class MockAuthController < ApplicationController
def login
session[:user_id] = 1
redirect_to :back
end
def logout
session[:user_id] = nil
redirect_to :back
end
end |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | app/controllers/comments_controller.rb | Ruby | mit | 45 | master | 361 | class CommentsController < InheritedResources::Base
def create
create! do |success, failure|
success.html do
add_fingerprint_and_user_id(@comment,true)
add_able_rep("commented on",@comment)
Reputation.add("commentor",current_user)
redirect_to :back
end
failure.htm... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | app/controllers/social_engine_controller.rb | Ruby | mit | 45 | master | 1,015 | require 'digest/sha2'
module SocialEngineController
def add_fingerprint_and_user_id(obj,save=false)
obj[:ip_address]=request.remote_ip
obj[:session_hash]=request.session_options[:id]
obj[:browser_fingerprint]=browser_fingerprint
obj[:user_id] = current_user.id if current_user
obj.save if save
e... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | app/controllers/favorites_controller.rb | Ruby | mit | 45 | master | 486 | class FavoritesController < InheritedResources::Base
def create
create! do |success, failure|
success.html do
add_fingerprint_and_user_id(@favorite,true)
add_able_rep("favorited",@favorite)
redirect_to :back
end
failure.html { redirect_to :back }
end
end
def de... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | app/controllers/ratings_controller.rb | Ruby | mit | 45 | master | 388 | class RatingsController < InheritedResources::Base
def create
@rating = Rating.new(params[:rating])
set_polymorphic_vars(@rating,"rateable")
add_fingerprint_and_user_id(@rating)
create! do |success, failure|
success.html do
Reputation.add("rated",current_user)
redirect_to :back
... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | app/controllers/reputation_actions_controller.rb | Ruby | mit | 45 | master | 237 | class ReputationActionsController < InheritedResources::Base
def create
create!{reputation_actions_url}
end
def update
update!{reputation_actions_url}
end
def destroy
destroy!{reputation_actions_url}
end
end |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | app/controllers/votes_controller.rb | Ruby | mit | 45 | master | 423 | class VotesController < InheritedResources::Base
def create
@vote = Vote.new(params[:vote])
set_polymorphic_vars(@vote)
add_fingerprint_and_user_id(@vote)
create! do |success, failure|
success.html do
add_able_rep("upvote",@vote) if @vote.up?
add_able_rep("downvote",@vote) if @vo... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | app/models/rating.rb | Ruby | mit | 45 | master | 318 | class Rating < ActiveRecord::Base
belongs_to :rateable, :polymorphic=>true
belongs_to :user
validates_uniqueness_of :rateable_type, :scope=> SocialEngine::Helpers::Fingerprint.fingerprint_type(:rateable_id),
:if => Proc.new { |x| SocialEngineYetting.fingerprint_method != "none" }
end |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | app/models/reputation_action.rb | Ruby | mit | 45 | master | 474 | class ReputationAction < ActiveRecord::Base
has_many :reputations, :dependent=>:destroy
def self.list_from_rails_source
list = []
files = Dir.glob("{#{Rails.root.to_s},#{SocialEngine::Engine.root.to_s}}/app/{controllers,models}/**/*.rb")
files.each do |file|
source = IO.read(file)
source.... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | app/models/reputation.rb | Ruby | mit | 45 | master | 815 | class Reputation < ActiveRecord::Base
belongs_to :user
belongs_to :reputation_action
def self.add(name,*users)
reputation_action = ReputationAction.where(:name=>name).first
if reputation_action.present? and users
users.each do |user|
if user.present?
self.create(:user_id=>user.i... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | app/models/vote.rb | Ruby | mit | 45 | master | 370 | class Vote < ActiveRecord::Base
belongs_to :voteable, :polymorphic=>true
validates_uniqueness_of :voteable_type, :scope=> SocialEngine::Helpers::Fingerprint.fingerprint_type(:voteable_id),
:if => Proc.new { |x| SocialEngineYetting.fingerprint_method != "none" }
def up?
self.value... |
github | charlotte-ruby/social_engine | https://github.com/charlotte-ruby/social_engine | app/models/comment.rb | Ruby | mit | 45 | master | 220 | class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic=>true
belongs_to :user
validates_presence_of :comment
is_voteable
is_commentable
is_rateable
include SocialEngine::Helpers::User
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.