text stringlengths 10 2.61M |
|---|
require 'rspec'
require_relative '../../lib/csv_import'
RSpec.describe CsvImport do
let(:agency_name) { "Some Agent" }
let!(:import) { described_class.new(filename, agency_name) }
describe "initializing" do
let(:filename) { "spec/fixtures/empty.csv" }
it "sets filename and agency name attribute" do
... |
module ApplicationHelper
def sidebar_link_options(section)
if %w( about documentation reference book blog videos
external-links downloads guis logos community
).include?(@section) && @section == section
{class: "active"}
else
{}
end
end
def partial(part)
render p... |
Rails.application.routes.draw do
root to: "pages#root"
get "fancy", to: "pages#fancy"
get "tooltip", to: "pages#tooltip"
get "datepicker", to: "pages#datepicker"
end
|
class Target < ActiveRecord::Base
belongs_to :age_group
belongs_to :provider
validates :age_group, :provider, presence: true
validates :provider, uniqueness: { scope: :age_group}
end
|
require 'spec_helper'
describe ItemsController do
before do
@user = Factory(:user)
@store = Factory(:store)
end
def valid_attributes
{ store_id: @store.id, name: 'Stuff and things' }
end
def valid_session
{ user_id: @user.id }
end
describe "POST create" do
describe "with valid par... |
require 'mechanize'
require 'singleton'
module Ayaneru
class Niconico
include Singleton
URL = {
login: 'https://secure.nicovideo.jp/secure/login?site=niconico',
search: 'http://api.search.nicovideo.jp/api/',
reserve: 'http://live.nicovideo.jp/api/watchingreservation'
}
attr_reader :agent, :logined
... |
class AddColumnToAboutUs < ActiveRecord::Migration
def change
add_column :about_us, :url, :string
end
end
|
#
# Author:: Matheus Francisco Barra Mina (<mfbmina@gmail.com>)
# © Copyright IBM Corporation 2015.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#
require 'fog/softlayer/models/account/brand'
module Fog
module Softlayer
class Account
class Brands < Fog::Collection
model Fog::Softlayer::Ac... |
class LocationPictureSerializer < ActiveModel::Serializer
attributes :id, :title, :location, :tags, :avatar, :user
end
|
module V1
class RunsController < V1Controller
before_action :set_run, only: [:show, :update, :destroy]
# GET /runs
def index
@runs = @athelete.runs.order(created_at: :desc)
render json: @runs
end
# POST /runs
def create
run_params['distance_in_meters']
@run = Run.new(... |
# frozen_string_literal: true
module Decidim
module Opinions
class NotifyOpinionsMentionedJob < ApplicationJob
def perform(comment_id, linked_opinions)
comment = Decidim::Comments::Comment.find(comment_id)
linked_opinions.each do |opinion_id|
opinion = Opinion.find(opinion_id)
... |
# frozen_string_literal: true
class AddStabbingToCausesOfDeath < ActiveRecord::Migration[5.0]
disable_ddl_transaction!
def change
execute <<-SQL
ALTER TYPE cause_of_death ADD VALUE 'stabbing';
SQL
end
end
|
require 'metatron_ruby_client'
require 'forwardable'
module Talis
module Bibliography
# Represents an eBook which is a type of asset associated with
# works and their manifestations.
#
# In order to perform remote operations, the client must be configured
# with a valid OAuth client that is allow... |
class RemoveStreetAddressColumnFromAdoptionRequests < ActiveRecord::Migration
def change
remove_column :adoption_requests, :street_address
end
end
|
module GHI
module Commands
class Status < Command
def options
OptionParser.new do |opts|
opts.banner = 'usage: ghi status'
end
end
def execute
begin
options.parse! args
@repo ||= ARGV[0] if ARGV.one?
rescue OptionParser::InvalidOpti... |
class Shot < ActiveRecord::Base
validates_presence_of :tape_id, :shot_in, :shot_out, :location, :province, :country, :keywords
end
|
require 'csv'
# CSV出力
CSV.generate do |csv|
csv_column_names = %w(id reception_number reception_day customer_name address
phone_number mobile_phone_number machine_model category
condition note progress contacted delivery reminder repair_staff completed)
csv <<... |
class PartnersController < ApplicationController
def create
end
def show
@partner = Partner.find(params[:id])
if @partner.reviews.blank?
@average_review = 0
else
@average_review = @partner.reviews.average(:rating).round(2)
end
end
end
|
# frozen_string_literal: true
# Migrate db
namespace :db do
require 'sequel'
DB = Sequel.connect 'sqlite://db/mscanalysis.sqlite3'
desc 'Generate migration'
task :generate, [:name] do |_, args|
name = args[:name]
abort('Missing migration file name') if name.nil?
content = <<~STR
# frozen_st... |
module Larvata::Signing
class Flow < ApplicationRecord
has_many :resources, class_name: "Larvata::Signing::Resource",
foreign_key: "larvata_signing_flow_id"
has_many :flow_stages, class_name: "Larvata::Signing::FlowStage",
foreign_key: "larvata_signing_flow_id"
# 取得指定簽核流程資料結構,並放入簽核單內
d... |
class Message < BaseREST
cache_expires 1.minute
delegate :attributes, :display, :attribute_unit, to: :sensor
def data
return "Parser not implemented" unless sensor_class
begin
sensor.attributes.inspect
rescue EOFError => err
return {}
end
end
def sensor_class
"Sensors::#{de... |
class Student < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:rememberable, :trackable, :validatable
has_many :records, dependent: :destroy
has_many :courses, through: :records
... |
require 'rails_helper'
RSpec.describe "Brands", type: :request do
before(:each) do
request_login_admin
end
describe "GET /brands" do
it "responded successfully" do
get brands_path
expect(response).to have_http_status(200)
end
end
end
|
require File.dirname(__FILE__) + '/../../spec_helper'
describe 'EC2.detach_volume' do
before(:all) do
@ec2 = Fog::AWS::EC2.gen
@instance_id = @ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
@volume_id = @ec2.create_volume(... |
class SearchController < ApplicationController
skip_authorization_check
def search
@results = params[:tag].present? ? Question.tagged_with(params[:tag]) : ThinkingSphinx.search(params[:q], classes: filters)
put_questions_at_top
end
private
def filters
search_in = []
search_in << Question if pa... |
class Picture < ActiveRecord::Base
belongs_to :user
belongs_to :album, :counter_cache => true
validates_presence_of :album_id,:message=>'请选择一个相册'
validates_presence_of :logo,:on=>:create,:message=>'请选择上传文件'
upload_column :logo,:process => '1024x1024',:versions => {:web => "600x600",:thumb=>"140x140"}
... |
module ApplicationHelper
def phone_number_display(phone_number)
# format the passed phone number for display
return nil if phone_number.blank?
PhoneNumberParser.format_for_display(phone_number)
end
def message_inbound_or_outbound(message)
# return a string indicating whether the message is inboun... |
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'uri'
require 'date' # needed to make it run on my osx machine for some reason
require 'builder' # for constructing formats of output
require 'trollop' # parsing command line arguments
# TODO
# - list tweets out that you wa... |
class Store
attr_reader :name, :city, :distance, :type, :phone
def initialize(store)
@name = store[:longName]
@city = store[:city]
@distance = store[:distance]
@type = store[:storeType]
@phone = store[:phone]
end
end |
# encoding: utf-8
require "fileutils"
require "rb.rotate/state"
require "rb.rotate/mail"
module RbRotate
module StorageModule
##
# Represents an item of some entry in storage.
#
class Item
##
# Parent entry.
#
... |
class AboutsController < ApplicationController
before_action :set_about, only: [:show, :edit, :update, :destroy]
def index
@about = About.first
if @about
redirect_to @about
else
About.create(content:'about as')
@about = About.first
redirect_to @about
end
end
def s... |
class Org < ActiveRecord::Base
belongs_to :contact, class_name: 'User'
has_many :apps
has_many :comments, as: :commentable
has_many :coaches, class_name: 'User', foreign_key: :coaching_org_id
validates_presence_of :name, :contact_id
validates_uniqueness_of :name
default_scope { order :name => :asc }
... |
class AddPathHashToDocuments < ActiveRecord::Migration
def change
add_column :documents, :path_hash, :string, :null => false, :default => '', :after => :path
add_index :documents, :path_hash
Document.all.each do |doc|
doc.path_hash = Document.generate_hash(doc.path)
doc.save
end
end
end... |
class AddColumnToInternalProjects < ActiveRecord::Migration
def change
add_column :internal_projects, :active, :boolean, :default => true
end
end
|
require 'spec_helper'
describe Mappable::Utils do
context 'classify_name' do
let(:name) { 'name-foo_bar_1!' }
subject { Mappable::Utils.classify_name(name) }
it 'converts the name to a class name' do
expect(subject).to eq('NameFooBar1')
end
end
end
|
require_relative '../../../spec_helper'
require_relative '../../../../robot_app/models/concerns/command_executor'
module RobotApp::Models
describe CommandExecutor do
class RobotTestClass < Robot
def initialize; end
end
let(:robot_test) { RobotTestClass.new }
describe :execute_command do
... |
=begin
Deaf grandma. Whatever you say to Grandma (whatever you type in), she should respond with this:
HUH? SPEAK UP, SONNY!
unless you shout it (type in all capitals). If you shout, she can hear you (or at least she think so) and yells back:
NO, NOT SINCE 1938!
To make program believable, have Grandma shout diff... |
helpers do
def entry(title, created, article)
"<h3 class='upcase'><a href='#' class='toggle' style='text-transform: uppercase;'>[+] #{title}<h2 class='upcase' style='text-transform: uppercase;'>#{created}</h2></a></h3>
<div class='hide'>
<p>#{article}</p>
</div>"
end... |
class Admin < Ohm::Model
include Shield::Model
include Ohm::Timestamps
include Ohm::DataTypes
attribute :email
attribute :crypted_password
attribute :blocked, Type::Boolean
unique :email
index :email
def self.fetch(email)
find(email: email).first
end
def self.with_serial_number(serial_numb... |
class RemoveUniqueIndexOnCollectionTitle < ActiveRecord::Migration[5.2]
def change
remove_index :collections, :title # remove the unique index
add_index :collections, :title # add a new non-unique index
end
end
|
module Fog
module Compute
class DigitalOceanV2
class Real
def get_ssh_key(key_id)
request(
:expects => [200],
:method => 'GET',
:path => "/v2/account/keys/#{key_id}"
)
end
end
# noinspection RubyStringKeysInHashInspecti... |
require 'caxlsx'
require 'caxlsx_rails'
require 'roo'
class FacilitiesManagement::DeliverableMatrixSpreadsheetCreator
include FacilitiesManagement::SummaryHelper
include ActionView::Helpers::SanitizeHelper
def initialize(contract_id)
@contract = FacilitiesManagement::ProcurementSupplier.find(contract_id)
... |
class IssuesController < ApplicationController
before_filter :authorize
# GET /issues
# GET /issues.json
def index
@issues = Issue.all
respond_to do |format|
format.html #index.html.erb
format.json { render json: @issues }
end
end
# GET /issues/1
# GET /issues/1.json
def show... |
Pod::Spec.new do |s|
s.name = "DataEntryToolbar"
s.version = "0.2.3"
s.summary = "A subclass of UIToolbar used to navigate up and down a dynamic tableView's text fields'."
s.description = <<-DESC
DataEntryToolbar is a subclass of UIToolbar intended for use... |
module Fog
module Compute
class DigitalOceanV2
class SshKey < Fog::Model
identity :id
attribute :fingerprint
attribute :public_key
attribute :name
def save
requires :name, :public_key
merge_attributes(service.create_ssh_key(name, public_key).body[... |
require File.join(File.dirname(__FILE__), 'lib', 'bard_bot')
Gem::Specification.new do |gem|
gem.name = 'bard_bot'
gem.version = BardBot::VERSION
gem.date = Date.today.to_s
gem.author = 'R. Scott Reis'
gem.email = 'reis.robert.s@gmail.com'
gem.license = 'MIT'
gem.homepage = 'https://github.com/EvilScott/... |
require "test_helper"
class ContextTest < MiniTest::Spec
class ParentCell < Cell::ViewModel
def user
context[:user]
end
end
let (:model) { Object.new }
let (:user) { Object.new }
let (:controller) { Object.new }
it do
cell = ParentCell.(model, admin: true, context: { user: user, control... |
# Helper Method
def position_taken?(board, index)
!(board[index].nil? || board[index] == " ")
end
# Define your WIN_COMBINATIONS constant
WIN_COMBINATIONS = [
[0,1,2], #top row win
[3,4,5], #middle row win
[6,7,8], #bottom row win
[0,4,8], #top left diagonal win
[2,4,6], #top right diagonal win
[0,3,6], ... |
class AlertsController < ApplicationController
before_action :authenticate_employee!
before_action :set_alert, only: [:show, :edit, :update, :destroy]
before_action :set_beacon, only: [:create, :destroy]
# GET /alerts
# GET /alerts.json
def index
org = Organization.find(current_employee.organization_id... |
require 'rails_helper'
RSpec.describe 'Destroy Item API' do
before :each do
@item = create(:item)
@invoice = create(:invoice)
@invoice_item = create(:invoice_item, item: @item, invoice: @invoice)
end
describe 'happy path' do
it "can destroy an item" do
expect{ delete "/api/v1/items/#{@item... |
class Fund
# * Module to setup the configuration
module Configuration
attr_accessor :default_currency, :supported_currencies, :currency_symbols
attr_accessor :currency_rates, :round_limit
class << self
# List of configurable keys for {Fund::Client}
# @return [Array] of option keys
def... |
class RemoveSlackWebhookUrlFromShop < ActiveRecord::Migration
def change
remove_column :shops, :slack_webhook_url
end
end
|
class RenameBasePollsToGamePolls < ActiveRecord::Migration
def change
rename_table :base_polls, :game_polls
remove_column :game_polls, :type
remove_column :game_polls, :video_link
end
end
|
# == Schema Information
#
# Table name: games
#
# id :integer not null, primary key
# name :string(255)
# date :datetime
# legend :text
# author :string(255)
# area :string(255)
# equipment :text
# coments :text
# created_at :datetime not null
# ... |
require 'tmpdir'
require 'vimrunner'
module Support
def assert_correct_indenting(string)
whitespace = string.scan(/^\s*/).first
string = string.split("\n").map { |line| line.gsub /^#{whitespace}/, '' }.join("\n").strip
File.open 'test.rb', 'w' do |f|
f.write string
end
@vim.edit 'test.rb'... |
#
# Cookbook Name:: chef-server
# Recipe:: install-server
#
# Greg Konradt. Intended for installing Chef server with kitchen or Chef local mode
bash 'set_hostname' do
user 'root'
cwd '/tmp'
code <<-EOH
echo chef-server > /etc/hostname
echo "#{node['ipaddress']} chef-server" >> /etc/hosts
hostname che... |
require 'rails_helper'
feature 'OpenWeatherMap Request' do
it 'queries the API for weather data' do
uri = URI.parse('http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139')
response = JSON.parse(Net::HTTP.get(uri))
expect(response['name']).to eq('Koh Tao')
end
end |
module DocumentGenerator
module Helpers
BASE_URI = 'http://data.rollvolet.be/%{resource}/%{id}'
def write_to_pdf(path, html, options = {})
default_options = {
margin: {
left: 0,
top: 14, # top margin on each page
bottom: 20, # height (mm) of the footer
ri... |
require 'sumac'
# make sure it exists
describe Sumac::Messages::Component::Exception do
# should be a subclass of Base
example do
expect(Sumac::Messages::Component::Exception < Sumac::Messages::Base).to be(true)
end
# ::from_object, #properties
# no message
example do
object = TypeError.new
... |
module CDI
module V1
class EducationalInstitutionSerializer < SimpleEducationalInstitutionSerializer
attributes :city_id, :state_id, :relation_with_me, :can_edit, :address
def address
object.address.present? ? InstitutionAddressSerializer.new(object.address) : nil
end
end
end
end... |
require 'iconv'
module Susanoo::Filter
CONV_TABLE = {
"\342\204\226" => "No.",
"\342\204\241" => "TEL",
"\342\205\240" => "I",
"\342\205\241" => "II",
"\342\205\242" => "III",
"\342\205\243" => "IV",
"\342\205\244" => "V",
"\342\205\245" => "VI",
"\342\205\246" => "VII",
"\342... |
require 'test_helper'
class PostTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test "Post must have title and body" do
p = Post.new
assert_not p.valid?
p.title = "title"
assert_not p.valid?
p.body = "body"
assert p.valid?
p.title = ""
assert_not p.va... |
class Movie < ActiveRecord::Base
validates_presence_of :title, :path
end
|
class UsersController < ApplicationController
def index
users = User.all
render json: users
end
def create
user = User.find_or_create_by(username: strong_params[:username])
render json: user
end
def show
user = User.find(params[:id])
bad_games = Game.where( time: "0:00:00" )
... |
class Number < ActiveRecord::Base
attr_accessible :active_race, :number, :race_id
belongs_to :race
end
|
require 'cgi'
module HBase
module Request
class BasicRequest
attr_reader :path
def initialize(path)
@path = path
end
protected
def pack_params columns
if columns.is_a? String
columns = [columns]
elsif columns.is_a? Array
else
r... |
# Q: I measured a cylinder with a string, and it was 50 cm around.
# I want to drill holes for 8 equidistant wheels centered 2cm from the bottom.
# Where do I drill?
# This is one of those "I want to see how you think" interview questions,
# which many studies have shown do not predict job performance.
# In fact, if ... |
require_relative 'db_connection'
require_relative '01_sql_object'
module Searchable
def where(params)
where_section = ""
params.each do |col, val|
where_section += "#{col.to_s} = #{val.to_s} AND "
end
where_string = where_section[0..-5]
results = DBConnection.execute(<<-SQL)
SELECT *... |
Pod::Spec.new do |s|
s.name = "SwiftUIPager"
s.version = ENV['LIB_VERSION'] # pod trunk me --verbose
s.summary = "Native pager for SwiftUI. Easily to use, easy to customize."
s.description = <<-DESC
This framework provides a pager build on top of SwiftUI native components. Views are recyc... |
module JavaClass
# The module Analyse is for separating namespaces. It contains various methods
# to analyse classes accross a whole code bases (Classpath). The functionality
# of all analysers is collected in Dsl::ClasspathAnalysers.
# Author:: Peter Kofler
module Analyse
# Analyser to... |
class AddIngredientRecipeIndex < ActiveRecord::Migration
def change
add_index :ingredients_recipes, [:recipe_id, :ingredient_id], :unique => true
end
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.network "private_network", ip: "192.168.56.16"
# full version WS2016
config.vm.box = "gusztavvargadr/w16s"
#... |
json.array!(@users) do |user|
json.extract! user, :name, :email, :hashed_password, :salt, :true_name, :student_number, :team_id, :portait_path, :type
json.url user_url(user, format: :json)
end
|
require 'spec_helper'
describe "Function form_migration_content:" do
before do
@add = ["add_index :report, :_id_test_plan"]
end
it "print migration skeleton with set name" do
migration = LolDba.form_migration_content("TestMigration", @add)
expect(migration).to match(/class TestMigration/i)
end
... |
class RenameTypeColumnToUserImages < ActiveRecord::Migration[5.0]
def change
rename_column :user_images, :type, :image_type
end
end
|
# The login functions allow users to log in (what enables them
# to mantain a list of saved theorems), new users to registrate
# and logged users to log out.
class LoginController < ApplicationController
before_filter :authorize, :except => [:login, :add_user]
# Add a new user to the database.
def add_user
... |
class Api::WeixinConfigsController < Api::BaseController
skip_before_action :authenticate_user!
def index
signature = Wechat.api.jsapi_ticket.signature params[:url] || request.referer
render json: {
appId: WxPay.appid, # 必填,公众号的唯一标识
timestamp: signature[:timestamp], # 必填,生成签名的时间戳
nonceSt... |
namespace :ghc do
VERSION = '7.10.1' #GHC_VERSION
PREFIX = "/opt/ghc#{VERSION}"
task :run, [:src] do |t, arg|
ENV['PORT'] = '9090'
sh "cabal exec runhaskell #{PROJ_DIR}/src/web/#{arg.src}"
end
desc "print ghc-package dependencies"
task :pkgs do
puts GHC_PACKAGE_PATH
end
task :packages => :... |
class TemplatesController < ApplicationController
before_filter :template, :only => [:edit, :show, :destroy, :compile]
before_filter do
@page_title = template.name if template
end
def index
@page_title = "Template Directory"
@templates = RailsTemplate.listed.recent.limit(30)
render :action =>... |
class Cart < ActiveRecord::Base
has_many :line_items
has_many :items, through: :line_items
belongs_to :user
def add_item(item_id)
new_item = Item.find_by(id: item_id)
if items.include?(new_item)
current_line_item = line_items.find_by(item_id: new_item.id)
current_line_item.quantity += 1
... |
class TeamSerializer
include FastJsonapi::ObjectSerializer
attributes :name, :division
attribute :coach do |object|
object.coach.proper_name
end
attribute :number_students do |object|
object.students.count
end
end
|
# coding: utf-8
$:.unshift('lib')
require 'natto/version'
Gem::Specification.new do |s|
s.name = 'natto'
s.version = Natto::VERSION
s.add_dependency('ffi', '>= 1.9.0')
s.license = 'BSD'
s.summary = 'A gem leveraging FFI (foreign function interface), natto combines the Ruby programming language with MeCab, th... |
# -*- coding: utf-8 -*-
require 'mini_magick' # image manipulation
require 'rtesseract' # OCR
require 'hpricot' #html analyzer
require 'net/http'
class Frigga
attr_reader :cookie, :user, :status
:READY
:SUCCESS
:FAIL
:CAPTCHA_WRONG
:USER_INFO_WRONG
def initialize(doretry=true)
@cookie = ""
@capt... |
# == Schema Information
#
# Table name: classrooms
#
# id :integer not null, primary key
# user_id :integer
# name :string(255)
# created_at :datetime
# updated_at :datetime
# school_id :integer
# teacher_id :integer
# code :string(255)
#
class Classroom < ActiveRecord::Base
... |
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision "ansible_local" do |ansible|
ansible.inventory_path = "tests/inventory"
ansible.limit = "localhost"
ansible.playbook = "tests/test.yml"
ansible.raw_arguments = [
"--connection=local",
"--sudo",... |
require_relative '../test_helper'
class ConfigTest < Ojo::OjoTestCase
def test_locations
Ojo.configuration.location = File.expand_path('../../tmp')
assert_equal File.expand_path('../../tmp'), Ojo.configuration.location
end
end
|
class DeleteRawData < ActiveRecord::Migration
def change
drop_table :raw_data
end
end
|
# frozen_string_literal: true
require 'bolt_spec/conn'
require 'bolt_spec/files'
require 'bolt_spec/integration'
describe "when running a plan that manipulates an execution result", ssh: true do
include BoltSpec::Conn
include BoltSpec::Files
include BoltSpec::Integration
let(:modulepath) { File.join(__dir__,... |
class QuestionsController < ApplicationController
before_action :require_user
before_action :require_admin
def new
@question = Question.new
@quiz = Quiz.find(params['quiz_id'])
#@answer = Answer.new
end
def create
@question = Question.new(question_params)
@quiz = Quiz.find(params[:quiz_id])
... |
# web elements and functions for page
class BrokenLinksPage
include Capybara::DSL
include RSpec::Matchers
include Capybara::RSpecMatchers
def initialize
@good_image = Element.new(:css, "[src='/images/Toolsqa.jpg']")
@broken_image = Element.new(:css, "[src='/images/Toolsqa_1.jpg']")
end
def visit
... |
class ExposureSerializer < ActiveModel::Serializer
attributes :id,:cvss_severity, :summary, :cve_id, :published, :title, :access_vector, :access_complexity, :integrity_impact, :availablility_impact, :cvss_v2_base_score
has_many :references
end
|
# frozen_string_literal: true
class TreasureHuntController < ApplicationController
def index
render json: TreasureHunt.all, status: :ok
end
def create
th = TreasureHunt.new(treasure_hunt_params)
if th.save
render json: { status: 'ok', distance: th.distance }, status: :ok
else
render ... |
# frozen_string_literal: true
require 'uri'
require 'net/http'
module PhoneValidation
class ValidationRequest
attr_accessor :phone_number, :token
BASE_URL = 'http://apilayer.net/api/validate'
RESPONSE_FIELDS = %w[
carrier
country_code
country_name
country_prefix
internation... |
require 'spec_helper'
describe "raw_touch_data/show" do
before(:each) do
@raw_touch_datum = assign(:raw_touch_datum, stub_model(RawTouchDatum,
:phase => 1,
:radius => 1.5,
:timestamp => 1.5,
:x => 1.5,
:y => 1.5
))
end
it "renders attributes in <p>" do
render
# Run ... |
# This method will return an array of arrays.
# Each subarray will have strings which are anagrams of each other
# Time Complexity: O(n)
# Space Complexity: O(n)
def grouped_anagrams(strings)
return [] if strings.empty?
anagram_hash = Hash.new()
strings.each do |string|
word_array = string.split("").sor... |
FactoryGirl.define do
factory :contract_responsible do
association :contract
name {Faker::Name.name}
office {Faker::Company.profession}
department {Faker::Company.name}
whatsapp {Faker::PhoneNumber.phone_number}
skype {Faker::Beer.name}
end
end
|
require 'mongoid/history'
module ActiveTriples
class MongoidStrategy
class Trackable < MongoidStrategy
##
# Overload initializer to enable tracking
def initialize(source)
super source
enable_tracking
end
##
# Roll back last change and update source graph
... |
require 'faraday'
require 'json'
module Overleap
class Report
attr_reader :propensity, :ranking
def initialize(url, data)
connection = Overleap::Report.make_connection(url)
response = Overleap::Report.get_response(connection, data)
@propensity = response["propensity"]
@ranking = respon... |
class AddFiresToCamps < ActiveRecord::Migration
def change
add_column :camps, :fires, :string
end
end
|
class Post < ActiveRecord::Base
attr_accessible :content
validates :content, :presence => true
validates :content, :length => { :minimum => 6 }
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.