text stringlengths 10 2.61M |
|---|
class CleanupUsersTable < ActiveRecord::Migration
def change
remove_column :users, :full_address
remove_column :users, :city
remove_column :users, :state
remove_column :users, :zip
remove_column :users, :latitude
remove_column :users, :longitude
remove_column :users, :suspicion
remove_... |
class OrderLineItem < ApplicationRecord
belongs_to :inventory_item, required: false
belongs_to :order, required: false
before_save :save_total_price
#accepts_nested_attributes_for :order
#validates :order_item_qty, presence: true, numericality: { only_integer: true, greater_than: 0 }
def total_fixed_p... |
require 'rails_helper'
RSpec.describe 'Comp Card Types API' do
let!(:comp_card_type) { create(:comp_card_type)}
describe 'GET /comp_card_types' do
before { get '/comp_card_types'}
it 'return status code 200' do
expect(response).to have_http_status(200)
end
it 'return comp card types' do
... |
require "rails_helper"
RSpec.feature 'View a dasboard', :type => 'feature' do
before :each do
end
scenario "User acess the dashboards index" do
visit "dashboards"
expect(page).to have_text("Pipefy Recruitment Test")
expect(page).to have_text("Back-end Test")
expect(page).to have_text... |
# == Schema Information
#
# Table name: events
#
# id :integer(4) not null, primary key
# user_id :integer(4) not null
# surfspot_id :integer(4)
# report_id :integer(4)
# thirdparty_account_id :integer(4)
# type :string(255)
# acti... |
class FlickrService
def initialize(location)
@location = location
end
def forecast
Forecast.new(@location)
end
def latitude
forecast.latitude
end
def longitude
forecast.longitude
end
def all_photos
Flickr.configure do |config|
config.api_key = ENV['flickr_key']
... |
class DispatcherSerializer
include FastJsonapi::ObjectSerializer
attributes :id, :username, :email, :destination
attribute :formatted_destination do |object|
uri = object.destination.gsub(/ /, '+')
"https://www.google.com/maps/embed/v1/place?key=#{ENV['GOOGLE_MAPS_API_KEY']}&q=#{uri}"
end
end
|
# frozen_string_literal: true
# TODO: add tests
module Ringu
module Injector
extend self
def create(deps)
Module.new do
define_method(:deps) { deps }
def self.included(klass)
klass.extend ClassMethods
klass.send :include, InstanceMethods
end
end
e... |
require 'vanagon/component/dsl'
require 'vanagon/component/rules'
require 'vanagon/component/source'
require 'vanagon/component/source/rewrite'
require 'vanagon/logger'
class Vanagon
class Component
include Vanagon::Utilities
# @!attribute [r] files
# @return [Set] the list of files marked for install... |
class OrdersController < ApplicationController
before_filter :activate_tab, :shop_navigation, :set_current_item
before_filter :show_menu, :except => [:new]
# GET /orders
# GET /orders.xml
def index
@orders = (logged_in? ) ? Order.buyer(current_member).purchased : []
respond_to do |format|
f... |
class CreateStudentEmails < ActiveRecord::Migration
def change
create_table :student_emails do |t|
t.string :email
t.integer :course_id
t.string :random_url
t.datetime :created_at
t.datetime :updated_at
end
end
end
|
class Entry<ActiveRecord::Base
validates_presence_of :title
validates_presence_of :description
belongs_to :category,
inverse_of: :entries
default_scope order('updated_at DESC')
def rendered_category_name
if category == nil
""
else
category.name
end
end
def ordered_by_d... |
describe IGMarkets::DealingPlatform::SprintMarketPositionMethods do
let(:session) { IGMarkets::Session.new }
let(:platform) do
IGMarkets::DealingPlatform.new.tap do |platform|
platform.instance_variable_set :@session, session
end
end
it 'can retrieve the current sprint market positions' do
po... |
#coding : utf-8
#
# 系统任务
#
namespace :system do
#
# 系统维护后给用户发消息并进行补偿
# 执行命令 /opt/ruby/bin/ruby /opt/ruby/bin/rake system:send_system_message
#
desc '发送系统消息'
task(:send_system_message => :environment) do
system_message = '今天服务器维护,送叫花鸡3个,100000白银,祝愿大家玩的开心'
reward_type = '1001' # 例子
User.find_each(... |
class Api::V1::EventResource < Api::V1::EntriesBaseResource
model_name 'Event'
attributes *(ATTRIBUTES + [:date_start, :date_end])
attribute :has_time_start, delegate: :time_start
attribute :has_time_end, delegate: :time_end
# not for now:
# :public_speaker, :location_type, :support_wanted,
# actual no... |
require 'pry'
class String
def sentence?
if self.end_with?(".")
return true
else
false
end
end
def question?
if self.end_with?("?")
true
else
false
end
end
def exclamation?
if self.end_with?("!")
true
else
false
end
end
def... |
class Veiculo
attr_accessor :nome, :marca, :modelo
def initialize(nome, marca, modelo)
self.nome = nome
self.marca = marca
self.modelo = modelo
end
def ligar
puts "#{nome} esta pronto para iniciar o trajeto."
end
def buzinar
puts "Beep! B... |
class VotesController < ApplicationController
before_action :authorize!
def create
vote = Vote.create(user_id: current_user.id, episode_id: params[:episode_id])
flash[:warning] = "You already upvoted this episode." if vote.invalid?
redirect_to episodes_path
end
end
|
class EnrollmentsController < ApplicationController
# GET /enrollments
# GET /enrollments.json
def index
@enrollments = Enrollment.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @enrollments }
end
end
def view_enrollments_for
#render :text =... |
require_relative "Scheduler_QualificationPanel"
require_relative "Scheduler_CertificateDialog"
class CreateListItem < Wx::ListItem
def initialize
super
super.set_background_colour(changingColor())
end
end
class CertificatePanel < Wx::Panel
attr_accessor :ids, :descriptions, :se... |
require_relative 'dom'
require_relative 'exceptions'
module Dom
# Node can be seen as an **aspect** or feature of another Object. Therefore it can be mixed in to
# add node-functionality to a class.
# Such functionality is used by {CodeObject::Base code-objects} and {Document::Document documents}.
#
# Inst... |
class Category < ApplicationRecord
# t.integer "tag_id", null: false
# t.integer "business_id", null: false
belongs_to :businesses,
foreign_key: :business_id,
class_name: :Business
belongs_to :tags,
foreign_key: :tag_id,
class_name: :Tag
end
|
Gem::Specification.new do |s|
s.name = 'consolehelp'
s.version = '0.0.0'
s.summary = "For all of your console needs!"
s.description = "A simple hello world test gem"
s.authors = ["darkdarcool30"]
s.email = 'darkdarcool@gmail.com'
s.files = ["lib/main.rb"]
s.homepage =
... |
class CreateUpdates < ActiveRecord::Migration
def self.up
create_table :updates do |t|
t.integer :project_id
t.string :value
t.timestamp :created_at
end
end
def self.down
drop_table :updates
end
end
|
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/prawn_charts/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Dave McNelis"]
gem.email = ["davemcnelis@market76.com"]
gem.description = %q{Prawn::Charts, Chart module for Prawn
(adapted from Scruffy by Brasten Sager)}
... |
class Language < ActiveRecord::Base
has_and_belongs_to_many :users
has_many :lists
end
|
# == Schema Information
# Schema version: 0
#
# Table name: users
#require 'bcrypt'
class User < ActiveRecord::Base
#include BCrypt
attr_accessor :password
#attr_accessible :email, :name, :encrypted_password, :salt, :admin
email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, :prese... |
class StudentClass < ActiveRecord::Base
attr_accessible :name, :batch_id
belongs_to :batch
has_many :students
has_many :batch_counselor_advisors
has_many :batch_leadership_leaders
def student_section
"#{self.name}".to_s
end
end
|
Given(/^the user "([^\"]*)" exists$/) do |user_alias|
user = User.new
@test_world.add_user(user_alias, user)
end
When(/^I search for user "([^"]*)"$/) do |user_alias|
user = @test_world.get_user user_alias
@home.search user.name
end
Then(/^I should be on the search results for user "([^"]*)"$/) do |user_alias... |
require 'spec_helper'
describe Reading do
it { should belong_to :user }
it { should belong_to :book }
end |
class Dealvalue < ActiveRecord::Base
attr_accessible :comment, :deal_id, :user_id, :value
validates :comment, :deal_id, :user_id, :value, :presence => true
belongs_to :deal
end
|
require_relative 'globals'
require_relative 'logger_mixin'
module TextlabNLP
class TreeTaggerConfig
include Logging
attr_reader :enc_conv, :type
# @option opts [Symbol] lang ISO-639-2 language code (:fra or :swe).
# @option opts [String] encoding Input encoding (utf-8 or latin1).
def initiali... |
require 'thread'
module LRU_RB
class LruCache
attr_reader :max_size, :current_size
def initialize(max_size=100)
@max_size = max_size
@current_size = 0
@cache_h = Hash.new
@cache_lru = LinkedList.new
@mutex = Mutex.new
end
def add(key,val)
@mutex.synchronize do
... |
require "linguist"
class Jekyll::Tags::LinguistColors < Liquid::Tag
def initialize tag_name, markup, tokens
@attributes = {
:selector => ".language-{language}",
:property => "background"
}
markup.scan(Liquid::TagAttributes) { |key, value| @attributes[key.to_sym] = value }
super
end
def render ... |
require 'rails_helper'
require 'givdo/facebook'
RSpec.describe FriendsSerializer, :type => :serializer do
let(:friend_user) { build(:user, :uid => 'user-1234')}
let(:user) { build(:user, :uid => 'user-1234')}
let(:friends) { Givdo::Facebook::Friends.new(nil, {}) }
before { allow(friends).to receive(:next_page_... |
require 'test_helper'
class PhoneBookEntriesControllerTest < ActionController::TestCase
setup do
@user1 = FactoryGirl.create(:user)
pb = @user1.phone_books.first
@user1_phone_book_entry = FactoryGirl.create(
:phone_book_entry,
:phone_book_id => pb.id
)
@expected_status_if_not_... |
require 'aws-sdk'
require 'tempfile'
require 'json'
require 'active_support/core_ext/date/calculations'
module ReportsHelper
REPORT_TABLE = 'test_management_cucumber_report'
def self.bucket(project)
ApplicationHelper.report_params(project)['bucket']
end
def self.get_all_reports(project)
cut_time = (... |
require 'poke'
require 'game'
describe "Game" do
# 黑桃 spade, 红桃 heard, 梅花 club, 方块 diamond
it "return 0 if Royal Flush" do
royal_flush = [["spade", "A"], ["spade","K"], ["spade", "Q"], ["spade", "J"], ["spade", "10"]]
royal_flash_cards = convert_to_cards(royal_flush)
expect(game(royal_flash_cards)).to ... |
require 'strava/api/v3'
require 'logger'
module StravaArchiver
class StravaArchiver
@@logger = Logger.new(STDOUT)
@@logger.level = Logger::INFO
def initialize(output_dir: "#{ENV['HOME']}/strava-archive",
existing_data_file: nil,
access_token: nil,
... |
# simplified version of https://github.com/girishso/pluck_to_hash
module PluckH
extend ActiveSupport::Concern
module ClassMethods
def pluck_h(*keys)
pluck(*keys).map do |values|
if keys.one?
{keys.first => values}
else
Hash[keys.zip(values)]
end
end
... |
module I18n
module Counter
class Summary
DEFAULT_LOCALE = 'en'
attr :redis, :used, :unused
def initialize
@redis = I18nRedis.connection
@_redis_keys = {}
@used = []
@unused = []
@_count_by_locale = {}
@_sum_by_locale = {}
end
module R... |
class LikeType < ActiveHash::Base
self.data = [
{ id: 1, name: '--' },
{ id: 2, name: '優柔不断' },
{ id: 3, name: 'プライドが高い' },
{ id: 4, name: '協調性がない' },
{ id: 5, name: '飽きっぽい' },
{ id: 6, name: '傷つきやすい' },
{ id: 7, name: 'やや非常識' },
{ id: 8, name: '向上心がない' },
{ id: 9, name: '精神的に自立してい... |
# frozen-string-literal: true
#
# The pg_extended_date_support extension allows support
# for BC dates/timestamps by default, and infinite
# dates/timestamps if configured. Without this extension,
# BC and infinite dates/timestamps will be handled incorrectly
# or raise an error. This behavior isn't the default becau... |
require 'colorize'
module PageInmetrics
module Funcionario
class Funcionario < SitePrism::Page
set_url '/'
element :div_form, '[class*="validate-form"]'
element :div_table, '[id="tabela_wrapper"]'
element :btn_enviar, '[class*="cadastrar"]'
element :btn_novo_funcionario, 'li:nth-c... |
ENV['RACK_ENV'] = 'test'
require "test/unit"
require "domotics/core"
class DomoticsElementsTestCase < Test::Unit::TestCase
def test_dimmer
dimmer = Domotics::Core::Room[:test].dimmer
# Should turn on max and convert state to int
dimmer.set_state :on
assert_equal 255, dimmer.state
# Should turn o... |
class AddIncomingIpToCspReportCspReports < ActiveRecord::Migration
def change
add_column :csp_report_csp_reports, :incoming_ip, :string, null: true
CspReport::CspReport.all.each do |report|
report.incoming_ip = 'Unknown (captured prior to v0.2.0)'
report.save!
end
# Removes the default v... |
# frozen_string_literal: true
module PopulatePokemon
# Service to populate all pokemon
class Service
attr_reader :starting_number, :ending_number, :region
def initialize(starting_number, ending_number, region)
@starting_number = starting_number
@ending_number = ending_number
@region = ... |
require "boxing/kata/version"
require "boxing/kata/box_scheduler"
require "boxing/kata/family"
require 'csv'
module Boxing
module Kata
def self.report
unless has_input_file?
puts "Usage: ruby ./bin/boxing-kata <spec/fixtures/family_preferences.csv"
end
cmd_line = STDIN.gets
... |
class CreateUserWorkspaceRequests < ActiveRecord::Migration[6.0]
def change
create_table :user_workspace_requests do |t|
t.integer :user
t.integer :workspace
t.integer :status
t.timestamps
end
end
end
|
require 'pry'
class MusicLibraryController
attr_accessor :path
def initialize(path = "./db/mp3s")
@path = MusicImporter.new(path).import
end
def call
puts "Welcome to your music library!"
puts "To list all of your songs, enter 'list songs'."
puts "To list all of the artists in your l... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
layout :layout_by_resource
before_action :configure_permitted_parameters, if: :devise_controller?
protect_from_forgery with: :exception
protected
de... |
class AddDumpVariablesParameter < ActiveRecord::Migration
def up
GsParameter.create(:entity => 'dialplan', :section => 'parameters', :name => 'dump_variables', :value => 'false', :class_type => 'Boolean', :description => 'Log dialplan variables.')
end
def down
GsParameter.where(:entity => 'dialplan', :se... |
# frozen_string_literal: true
module AsciiDetector
VERSION = '0.1.0'
end
|
class Api::V1::ReviewsController < ApplicationController
before_action :authenticate_user!
before_action :authorize_destruction, :only => [:destroy]
skip_before_action :verify_authenticity_token, :only => [:create, :destroy]
def index
render json: Review.all
end
def create
@review = Review.new
... |
#!/usr/bin/env ruby
require 'sippy_cup'
require 'getoptlong'
def usage
puts "#{$0} [OPTS] </path/to/sippy_cup_definition.yml>"
puts
puts "--compile, -c Compile the given scenario manifest to XML and PCAP"
puts "--run, -r Run the scenario"
puts "--help, -h Print this usage information"
puts "--ve... |
#write your code here
def echo(input)
return input
end
def shout(input)
return input.upcase
end
def repeat(input, q=2)
return ([input]*q).join(' ')
end
def start_of_word(input, q)
return input[0..q-1]
end
def first_word(input)
return input.split.first
end
def titleize(input)
little_words = %w{and the o... |
class ThingsController < ApplicationController
def index
@things = Thing.rank(:row_order).all
end
def new
@thing = Thing.new
end
def show
@thing = Thing.find(params[:id])
end
def create
@thing = Thing.create(thing_params)
if @thing.save
redirect_to things_path
else
... |
module Squall
# OnApp IpAddress
class IpAddress < Base
# Returns a list of ip addresses for a network
#
# ==== Params
#
# * +network_id+ - ID of the network
def list(network_id)
response = request(:get, "/settings/networks/#{network_id}/ip_addresses.json")
response.collect { |ip|... |
class AddPostDateToWeeklyApps < ActiveRecord::Migration[5.2]
def change
add_column :weekly_apps, :post_date, :date
end
end
|
log "
*****************************************
* *
* Recipe:#{recipe_name} *
* *
*****************************************
"
thisdir = node[:clone12_2][:ebsprep][:workingdir]
rootusr = 'root'
root... |
require 'spec_helper'
require 'rails_helper'
include Warden::Test::Helpers
Warden.test_mode!
describe 'New address' do
before :each do
user = FactoryGirl.create(:user)
login_as(user)
end
it 'creates new address' do
visit new_address_path
fill_in('address_name', with:'Tom Jones')
fill_in('ad... |
require 'test_helper'
class TempusersControllerTest < ActionController::TestCase
setup do
@tempuser = tempusers(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:tempusers)
end
test "should get new" do
get :new
assert_response :success
... |
require "test_helper"
describe DashboardController do
Given(:user) { FactoryGirl.create(:user) }
describe "#show for" do
describe "authenticated user" do
Given { sign_in user }
Given { get dashboard_show_url }
Then { value(response).must_be :success? }
end
describe "logged out u... |
require 'rails_helper'
describe Transaction do
context 'attributes' do
it { is_expected.to respond_to(:invoice_id) }
it { is_expected.to respond_to(:credit_card_number) }
it { is_expected.to respond_to(:credit_card_expiration_date) }
it { is_expected.to respond_to(:result) }
it { is_expected.to r... |
JSONAPI.configure do |config|
config.json_key_format = :camelized_key
config.route_format = :dasherized_route
config.default_paginator = :none
config.default_page_size = 10
config.maximum_page_size = 100
config.top_level_meta_include_record_count = true
config.top_level_meta_record_count_key = :record_cou... |
class DocumentosController < ApplicationController
before_action :set_documento, only: [:show, :edit, :update, :destroy]
# GET /documentos
# GET /documentos.json
def index
@documentos = Documento.all
end
# GET /documentos/1
# GET /documentos/1.json
def show
respond_to do |format|
format.... |
class Admin::CheckoutsController < Admin::BaseController
resource_controller :singleton
belongs_to :order
before_filter :load_data
ssl_required
edit.before :edit_before
update.before :update_before
update.wants.html do
if @order.in_progress?
redirect_to edit_admin_order_shipment_url(@order, @... |
Spree::BaseController.class_eval do
before_filter :set_pages
private
def set_pages
@header_pages = Spree::Page.header_links.top_level.visible
@footer_pages = Spree::Page.footer_links.top_level.visible
end
end
|
Rails.application.routes.draw do
root to: 'pages#home'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resources :projects, only: [:index, :show]
get '/contact', to: 'contacts#new', as: 'new_message'
post 'contacs', to: 'contacs#create', as: 'create_messag... |
class Backend::AdminsController < Backend::ApplicationController
def update
if current_admin.update admin_params
response_json current_admin
else
raise LogicError, '更新失败'
end
end
private
def admin_params
params.require(:admin).permit(:name, :avatar, :password, :password_confirmatio... |
require "test_helper"
describe OrgsUser do
subject { OrgsUser }
describe "db" do
specify "columns & types" do
must_have_column(:org_id, :integer)
must_have_column(:user_id, :integer)
end
end
specify "associations" do
must_belong_to(:org)
must_belong_to(:user)
end
end
|
module IControl::ASM
##
# The WebApplicationGroup interface enables you to manipulate a group of ASM Web Applications.
class WebApplicationGroup < IControl::Base
set_id_name "group_names"
##
# Adds web applications to this web application group.
# @rspec_example
# @raise [IControl::IControl:... |
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network :private_network, ip: "192.168.19.20"
config.vm.network "forwarded_port", guest: 80, host: 8990
config.ssh.forward_agent = true
config.vm.synced_folder "~/Workspace/go-p... |
class TaskSerializer < ActiveModel::Serializer
include Rails.application.routes.url_helpers
attributes :id, :external_id, :accepted, :paid, :review_requested, :links, :budget, :resolver, :expenses, :orders, :potential_resolvers
private
def budget
object.budget.to_f
end
def potential_resolvers # TODO - ... |
class User < ActiveRecord::Base
rolify
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
validates :username, presence: true, uniquene... |
require 'socket'
module OTerm
class Server
attr_accessor :acceptThread
attr_accessor :stop
attr_accessor :listeners
attr_accessor :debug
def initialize(executor, port=6060, debug=false)
@debug = debug
@stop = false
@listeners = []
@acceptThread = Thread.start() do
... |
# == Schema Information
#
# Table name: host_lists
#
# id :integer not null, primary key
# token :string
# user_id :integer
# policy :string
# created_at :datetime not null
# updated_at :datetime not null
#
class HostList < ApplicationRecord
enumerize :policy, in: [... |
require 'rails_helper'
describe UserInfo do
describe '#create' do
it " すべてのデータがあり正常に登録できる" do
userinfo = build(:user)
expect(userinfo).to be_valid
end
it "first_nameなしでは保存不可" do
userinfo = build(:user_info, first_name: nil)
userinfo.valid?
expect(userinfo.errors[:first_nam... |
class SessionsController < ApplicationController
def create
auth = request.env["omniauth.auth"]
user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth)
session[:user_id] = user.id
do_redirect
end
def destroy
session[:user_id] = nil
... |
class CreateVotes < ActiveRecord::Migration
def change
create_table :votes do |t|
t.integer :score, :null => false, :default=>0
t.references :user, :null => false
t.references :votable, :polymorphic => true
t.timestamps
end
add_index :votes, [:user_id, :votable_id, :votable_type],... |
require "rails_helper"
def create_duplicate_patients
facility_blue = create(:facility, name: "Facility Blue")
user = create(:user, registration_facility: facility_blue)
patient_blue = create_patient_with_visits(registration_time: 6.month.ago, facility: facility_blue, user: user)
facility_red = create(:facility... |
class GmailImporter
attr_reader :email, :password
def initialize(email, password)
@email = email
@password = password
end
def import(number_of_messages)
@imap = Net::IMAP::Gmail.new('imap.gmail.com', ssl: true)
@imap.login(email, password)
@imap.examine(folder)
fetch(number_of_message... |
require "test_helper"
describe Api::V1::AreasController do
before do
@plains = Area.create(:name => "Plains", :width => 640, :height => 512)
@desert = Area.create(:name => "Desert", :width => 640, :height => 512)
@night_elf = Player.create(:name => "Night Elf", :direction => "down",
:x => 0, :y ... |
# == Schema Information
#
# Table name: addresses
#
# id :integer not null, primary key
# created_at :datetime
# updated_at :datetime
# addressable_id :integer not null
# addressable_type :string(255) not null
# tag_for_address :string(255)
# country :... |
#!/usr/bin/env ruby
# frozen_string_literal: true
require "kbsecret"
require "tty-prompt"
include KBSecret
$VERBOSE = nil # tty-prompt blasts us with irrelevant warnings on 2.4
cmd = CLI.create do |c|
c.slop do |o|
o.banner = <<~HELP
Usage:
kbsecret rm [options] <record>
HELP
o.string "... |
class AuthlogService
def initialize(params, message, status)
@params = params
@message = message
@status = status
end
def warn
auth_logger.warn(data_attributes)
end
def info
auth_logger.info(data_attributes)
end
def fatal
auth_logger.fatal(d... |
json.data do
json.proposal_image do
json.id @proposal_image.id
json.image url_for(@proposal_image.image)
json.proposal_item_id @proposal_image.proposal_item_id
end
end |
####
#
# LiteralSearch
#
# Responsible for exact match searches for the application.
#
# Used by search Controller - returns results as LiteralResults
#
#
####
#
class LiteralSearch
attr_reader :referrer, :query
# referrer: the model and action of the query being executed - one of Client,
# Payment, Pr... |
require "coolxbrl/edinet/document_information"
require "coolxbrl/edinet/xbrl"
require "coolxbrl/edinet/presentation"
require "coolxbrl/edinet/xsd"
require "coolxbrl/edinet/label"
module CoolXBRL
module EDINET
extend XSD
class << self
def parse(dir, language=Label::DEFAULT_LANGUAGE)
... |
module Jekyll
module OctopodFilters
# Escapes some text for CDATA
def cdata_escape(input)
input.gsub(/<!\[CDATA\[/, '<![CDATA[').gsub(/\]\]>/, ']]>')
end
# Replaces relative urls with full urls
#
# {{ "about.html" | expand_urls }} => "/about.html"
# {{ "about.... |
class Api::LessonsController < Api::ApplicationController
def index
lessons = Subject.find_by!(slug: params[:slug]).lessons
render json: lessons.map{ |lesson|
{
id: lesson.id,
name: lesson.name,
}
}
end
def show
subject = Subject.find_by(slug: params[:slug])
lesso... |
feature 'diaries' do
scenario 'return a list of diary entries' do
visit '/'
expect(page).to have_content 'Dear Diary'
end
end
|
require 'spec_helper'
describe "Session", :vcr, :record => :new_episodes, :type => :request do
context "successful login" do
before { setup_for_github_login }
it "enforces opensesame login" do
visit root_path
within("#opensesame-session") do
page.should have_content("Login")
cli... |
class Bomb
attr_reader :x, :y, :power
EXPLODE_TIME = 1500 #ms
def initialize(x, y, power=3)
@x, @y = x, y
@sprite = Gosu::Image.new('bomb.png', :tileable => true)
@timer = Gosu.milliseconds
@power = power
end
def draw
@sprite.draw(@x, @y, ZOrder::BOMB)
end
def update
explode! if... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu1404"
config.vm.define :viff do |master|
master.vm.network "forwarded_port", guest: 80, host: 8088
master.vm.network "forwarded_port", guest: 27017, host: ... |
module Adminpanel
class UsersController < Adminpanel::ApplicationController
private
def user_params
params.require(:user).permit(
:email,
:name,
:password,
:password_confirmation,
:role_id
)
end
end
end
|
class AddEmbedLinkToPost < ActiveRecord::Migration
def self.up
add_column :posts, :embed_link, :text, :default => nil
end
def self.down
remove_column :posts, :embed_link
end
end
|
require 'spec_helper'
describe Group do
subject(:group) { Group.new(vmt_userid, vmt_password, vmt_url) }
let(:vmt_userid) { VMT_USERID }
let(:vmt_password) { VMT_PASSWORD}
let(:vmt_url) { VMT_BASE_URL }
describe "Should be a valid VMT Object" do
it_behaves_like 'a VMT API object'
end
describe "#get_group_... |
class Authentication
def initialize(user_object)
email = user_object[:email]
@password = user_object[:password]
@user = User.find_by(email: email)
end
def authenticate
true if @user && @user.authenticate(@password)
end
def generate_token
JwtWebToken.encode(user_id: @user.id)
end
end |
class QuestionScore < ActiveRecord::Base
#Relationships
belongs_to :game_record
#Scopes
scope :for_game_record, ->(game_record_id) { where('game_record_id = ?', game_record_id) }
scope :for_landmark, ->(landmark_id) { where('landmark_id = ?', landmark_id) }
scope :for_question, ->(question_id) { where('question_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.