text stringlengths 10 2.61M |
|---|
class ArmGroupRetroAssessment < PdfReport
def initialize(quote=[],account=[],policy_calculation=[],view)
super()
@quote = quote
@account = account
@policy_calculation = policy_calculation
@view = view
@group_fees =
if @quote.fees.nil?
0
else
@quote.fees
end
... |
class ApplicationController < ActionController::Base
include UsersHelper #UsersHelperをインクルードしてる(current_user?)
protect_from_forgery with: :exception
before_action :set_current_user #各コントローラで@current_userの呼び出しを可能にする
before_filter :configure_permitted_parameters, if: :devise_controller? #Adminの設定
def set_curre... |
require 'spec_helper'
describe DatasetDownloadsController do
let(:user) { users(:the_collaborator) }
let(:instance_account) { table.gpdb_instance.account_for_user!(user) }
let(:table) { datasets(:table) }
before do
log_in user
end
describe "#show" do
context "with valid file content" do
it ... |
class Circle < RTanque::Bot::Brain
include RTanque::Bot::BrainHelper
NAME = 'Circle'
def tick!
self.command.heading = self.sensors.heading + MAX_BOT_ROTATION
self.command.speed = MAX_BOT_SPEED
end
end
|
require 'rails_helper'
RSpec.describe Felica, :type => :model do
describe "#activate?" do
context "with true" do
let(:felica) { Fabricate(:felica, { idm: Faker::Lorem.characters, activation: true }) }
it "should return true" do
expect(felica.activation).to eql true
end
end
cont... |
module SPV
class Fixtures
# Prepares incoming raw list of fixtures to be used for inserting
# into VCR.
#
# Applies a given list of modifiers to list of fixtures.
class Handler
def initialize(options, convertor = Converter)
@options = options
@converter = convertor
end... |
require 'rspec'
require_relative '../../../src/stm'
describe 'Transaction basics' do
before do
class MyObject
@class_inst_var = nil
attr_accessor :attr_accessor_ivar
attr_reader :attr_reader_ivar
attr_writer :attr_writer_ivar
def initialize
@instance_var = nil
@att... |
# frozen_string_literal: true
module Dynflow
module Executors
module Abstract
class Core < Actor
attr_reader :logger
def initialize(world, heartbeat_interval, queues_options)
@logger = world.logger
@world = Type! world, World
@pools = ... |
Rails.application.routes.draw do
resources :employees, only: [:new, :create, :confirmation]
resources :warehouses, only: [:new, :create, :confirmation]
resources :parts, only: [:index, :create, :new, :edit, :remove, :new_line, :show, :update]
resources :orders, only: [:index, :new, :create, :show, :confirmation... |
module Android
module HomePage
class << self
include BasePage
# Header
TITLE = { id: PACKAGE + ':id/title' }
BALANCE = { id: PACKAGE + ':id/balance' }
# Main buttons
SEND_MONEY_BUTTON = { id: PACKAGE + ':id/btn_send_money' }
REQUEST_PAYMENT_BUTTON = { id: PACKAGE + ':id... |
class AddDefeatedByToPresidents < ActiveRecord::Migration[5.2]
def change
add_column :presidents, :defeated_by, :string
end
end
|
class CreateAssets < ActiveRecord::Migration
def change
create_table :assets do |t|
t.string :title, default: ''
t.string :alt, default: ''
t.references :page
t.string :link
t.string :attachment_uid, null: false
t.string :attachment_name, null: false
t.boolean :is_image, ... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :tweets, dependent: :destroy
has_many :comm... |
class Message < ActiveRecord::Base
belongs_to :sender, class_name: "User", primary_key: "sender_id"
belongs_to :recipient, class_name: "User", primary_key: "recipient_id"
validates :title, presence: true
has_attached_file :audio
validates_attachment_presence :audio
validates_attachment_content_type :audio... |
# frozen_string_literal: true
module SurveysUrlHelper
def course_survey_url(notification)
"#{survey_url(notification.survey)}?course_slug=#{notification.course.slug}"
end
end
|
require 'test_helper'
class Admin::UploadCategoriesControllerTest < ActionController::TestCase
def test_index
get :index
assert_template 'index'
end
def test_show
get :show, :id => UploadCategory.first
assert_template 'show'
end
def test_new
get :new
assert_template 'new'
end
d... |
class CreateInvites < ActiveRecord::Migration
def self.up
create_table :invites do |t|
t.references :sender
t.references :recipient
t.string :recipient_email
t.string :token
t.timestamp :accept_at
t.timestamps
end
end
def self.down
drop_table :invit... |
class CustomerController < ApplicationController
before_action :authorize_request
def index
@customers = Customer.all
render json: @customers,
status: 200,
key_transform: :camel_lower
end
def show
@customer = Customer.find_by id: customer_params[:id]
render json: @customer... |
class EventsController < ApplicationController
def index
@title = 'Events'
if current_user.admin == false
redirect_to current_user
end
end
def new
@event = Event.new
end
def create
@event = Event.new(event_params)
if @event.save
flash[:success] = "Event created!"
redirect_to events_p... |
class Quote
attr_reader :arr_quotes
def initialize
#perhaps use an input file for this
@arr_quotes = [
"Foo! Bar!",
"Do you parse the the words coming out of my mouth.",
"Leonardo of Pisa introduced the Fibonacci Sequence to the Western European Mathematics"
... |
class UpVote < ActiveRecord::Base
belongs_to :like_a_little, dependent: :destroy, counter_cache: true
belongs_to :student, dependent: :destroy
validates :student_id, presence: true
validates :like_a_little_id, presence: true
validates :student_id, :uniqueness => { :scope => :like_a_little_id }
end
|
# frozen_string_literal: true
require 'erb'
# weekday = Time.now.strftime('%A')
# simple_template = 'Today is <%= weekday %>'
#
# renderer = ERB.new(simple_template)
# puts output = renderer.result
def get_items
%w[bread milk eggs spam]
end
def get_template
%w[ Shopping List for <%= @date.strftime('%A %d %B %Y'... |
require 'spec_helper'
describe OrganizationsController do
let(:organization) { FactoryGirl.create(:organization) }
describe "GET show" do
it "has 200 status" do
{ :get => "/instituciones/#{organization.slug}.json" }
expect(response.status).to eq(200)
end
end
end
|
# encoding: utf-8
module Antelope
# The current running version of antelope.
VERSION = "0.4.1".freeze
end
|
class Book # < Struct.new(:number, :title)
attr_accessor :number, :title
def initialize (book_number, book_title)
@number = book_number
@title = book_title
end
end
class Library
attr_reader :books
def initialize
@books = []
@index = {}
end
def book(number)
@index.fetch(number) {
... |
class Activity
class Tab
include Pundit::Authorization
VALID_TAB_NAMES = [
"financials",
"other_funding",
"details",
"children",
"comments",
"transfers",
"historical_events"
].freeze
def initialize(activity:, current_user:, tab_name: "financials")
rais... |
require File.expand_path('../../../spec_helper', __FILE__)
describe Tapbot::Client::Exchanges do
describe "Exchange details" do
it "should be able to call to obtain details with exchange id" do
client = Tapbot::Client.new(rest_token: "rest-token", rest_secret: 'rest-secret')
stub_request... |
class ReceiveRingGroupCall
def initialize(to:, from:, sid:)
@ring_group = to.ring_group
@from = from
@sid = sid
end
def call
return Result.failure("Invalid to number") unless ring_group
ring_group_call = RingGroupCall.receive(ring_group: ring_group, from: from, sid: sid)
if connect_memb... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :project_history do
consultant
client_company { Faker::Name.name }
client_poc_name { Faker::Name.first_name }
client_poc_email { Faker::Internet.email(client_poc_name) }
start_date { 3.years.ago }
... |
module PryRailsDiffRoutes::ModernHashFormat
refine Hash do
alias old_to_s to_s
def to_s
old_to_s.gsub(%r{\:(\w+)\=\>}, "\\1: ")
end
end
end
|
require "pry"
# Enter your object-oriented solution here!
# PROBLEM: MULTIPLES OF 3 AND 5
# If we list all of the natural numbers below 10
# that are multiples of 3 or 5, we get 3, 5, 6, and 9.
# The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000.
class Multiples
attr_acces... |
class ChurchesController < ApplicationController
def index
scope = Church.all.approved
if params[:search]
@churches = scope.where('name ILIKE ?', "%#{params[:search]}%")
elsif params[:category_search]
@churches = scope.where(church_category_id: params[:category_search])
elsif params[:regio... |
# frozen_string_literal: true
require_relative '../config/game/g_18_chesapeake'
require_relative 'base'
module Engine
module Game
class G18Chesapeake < Base
register_colors(green: '#237333',
red: '#d81e3e',
blue: '#0189d1',
lightBlue: '#a2d... |
class ProcessSlackEvent
include Interactor
def call
process
rescue => error
context.fail!(error: error.message)
end
private
def process
case
when message_created? then create_message
when message_deleted? then destroy_message
when reaction_given? then create_reaction if chann... |
##################################################################
# Methods in Ruby
# 1. Introduction to methods in Ruby
# 2. What Ruby methods return
# 3. Difference Between Puts and Returning Values
# 4. Difference between class and instance methods in Ruby
# 5. Procs and Lambdas
# 6. Difference between Procs and La... |
require 'test_helper'
class ShoppingCartEntriesControllerTest < ActionController::TestCase
setup do
@shopping_cart_entry = shopping_cart_entries(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:shopping_cart_entries)
end
test "should get new" ... |
child @restaurant => "restaurants" do
attributes :chain_name , :most_recent, :unread
attribute :chain_logo =>"logo"
node :chain_logo do |res|
res.logo.fullpath if res.logo
end
#node(:unread) {|_| _.get_unread_message }
end
|
Ohai.plugin(:Precedence) do
provides 'precedence/lvl_15'
collect_data(:default) do
precedence Mash.new
precedence[:lvl_15] = "Precedence: automatic - Ohai Module: precedence.rb"
end
end
|
module Ratpack
# Manage a pool of Jabber ID's
class Pool
# Our strategy
attr_reader :strategy
# Members of the pool
attr_reader :members
def initialize( application, *members )
@application = application
@members = []
@members.concat( members.to_a.compact.flatten )
... |
# Переопределяет метод limited_nodes для применения кастомной пагинации.
# Если в query пришел аргумент pagination, то выполняется кастомная пагинация, иначе по умолчанию.
module Extensions
class CustomActiveRecordRelationConnection < GraphQL::Pagination::ActiveRecordRelationConnection
def limited_nodes
if... |
class CreatePlayers < ActiveRecord::Migration[5.1]
def change
create_table :players do |t|
t.string :name
t.string :world_in
t.string :email, limit: 40
t.boolean :email_verified
t.string :password_hash, limit: 128
t.string :device_id, limit: 100
t.boolean :is_deleted
... |
class CreateTransactions < ActiveRecord::Migration
def change
create_table :transactions do |t|
t.string :person
t.string :item
t.text :details
t.datetime :when
t.integer :state
t.timestamps null: false
end
end
end
|
class AddColumnToUserOptions < ActiveRecord::Migration[5.2]
def change
add_column :user_options, :option_id_1, :integer
add_column :user_options, :option_id_2, :integer
add_column :user_options, :option_id_3, :integer
end
end
|
module Elrond
class ValidatorsController < NetworkController
layout 'tabs'
before_action :set_validator_hash
before_action :breadcrumb
before_action :query_date, only: %i[show]
QUERY = BitqueryGraphql::Client.parse <<-'GRAPHQL'
query ($hash: String! $network: ElrondNetwork!){
... |
class ApplicationController < ActionController::Base
before_action :authenticate_user!
def main
render 'layouts/main'
end
end
|
require 'coursegen'
# Copyright string
COPYRIGHT_STRING = "Copyright (2014-2020) R. Pito Salas, pitosalas@brandeis.edu".freeze
# bucket for AWS Deployment of the course
AWS_BUCKET = "cosi105b".freeze
# Course short name
COURSE_SHORT_NAME = "Cosi 105b".freeze
COURSE_LONG_NAME = "Software Engineering for Scalability "... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
helper_method :current_user, :logged_in? ## This makes these methods available to the viewers!!
def current_us... |
class ProduitsController < ApplicationController
before_action :set_produit, only: [:show, :edit, :update, :destroy]
# GET /produits
# GET /produits.json
def index
@produits = Produit.all
end
# GET /produits/1
# GET /produits/1.json
def show
end
# GET /produits/new
def new
@produit = Pr... |
class Back::Transfer < Back
belongs_to :tax
validates :type, :customer_id, :value_in_cents, :account_recipient, :tax_id, presence: true
end |
class PostsController < ApplicationController
before_action :authenticate_user, {only: [:new, :show, :create, :edit, :update, :destroy, :ensure_correct_user]}
before_action :ensure_correct_user, {only: [:edit, :update, :destroy]}
def index
@posts = Post.all.order("created_at DESC").page(params[:page]).per(8)... |
require File.expand_path '../helper', __FILE__
require 'airbrake/rails/controller_methods'
require 'airbrake/rails/middleware'
module ActionDispatch
class ShowExceptions
private
def public_path
"/null"
end
# Silence logger
def logger
nil
end
end
end
class ActionControllerCatc... |
class CouchDB < FPM::Cookery::Recipe
description 'RESTful document oriented database'
name 'couchdb'
version '2.1.1'
revision '1'
source "http://apache.mirror.iphh.net/couchdb/source/#{version}/apache-couchdb-#{version}.tar.gz"
sha256 'd5f255abc871ac44f30517e68c7b30d1503ec0f6453267d641e00452c04e7bcc'... |
require 'rails_helper'
RSpec.feature 'New price in admin area', settings: false do
given!(:zone) { create(:zone, origin: 'test') }
background do
sign_in_to_admin_area
end
scenario 'it creates new price' do
open_list
open_form
fill_form
submit_form
expect(page).to have_text(t('admin.b... |
class Profile < ActiveRecord::Base
belongs_to :user
acts_as_gmappable
STRING_FIELDS = %w{fname lname}
VALID_GENDER = ["male", "female"]
BEGIN_DATE = 1900
VALID_DATES = DateTime.new(BEGIN_DATE)..DateTime.now
validates_presence_of :fname, :lname
validates_inclusion_of :gender, :in => VALID_GENDER.in... |
class AddDisplayNameToChangeLog < ActiveRecord::Migration[6.0]
def change
add_column :change_logs, :displayName, :string
add_column :change_logs, :fieldtype, :string
add_column :change_logs, :avatar, :string
end
end
|
# frozen_string_literal: true
module SC::Billing::Stripe::Plans
class CreateOperation < ::SC::Billing::BaseOperation
class Transformer < Transproc::Transformer[SC::Billing::Transform]
attrs_to_hash %i[
id
nickname
amount
currency
interval
interval_count
... |
Pod::Spec.new do |s|
s.name = 'testPod'
s.version = '0.0.2'
s.summary = '内选项目'
#添加第三方依赖
#s.dependency 'QMUIKit'
#s.dependency 'JSONModel'
#s.dependency 'Masonry'
#s.dependency 'PromiseKit', '~> 1.7'
#s.dependency 'MBTips'
<<-DESC
APP 内用到的选项目。
DESC
s.homepage ... |
class ProjectsController < ApplicationController
include ProjectsHelper
include SessionsHelper
def new
@project = Project.new
@project.user = current_user
end
def create
@project = Project.new(project_params)
@project.user = current_user
if @project.save
flash[:success] = "Project created successfu... |
# frozen_string_literal: true
class CourseSerializer < BaseSerializer
attributes :id, :name, :description, :editable, :locations, :track_points
link(:self) { api_v1_course_path(object) }
has_many :splits
belongs_to :organization
def locations
object.ordered_splits.select(&:has_location?).map do |split|... |
require 'jira-ruby'
require_relative 'file'
module Jira
class Client
@instance
attr_reader :agile_url, :greenhopper_url, :instance
def initialize(user)
@instance = self.class.instance(user)
@agile_url = Vortrics.config[:jira][:agile_url]
@greenhopper_url = Vortrics.config[:jira][:gree... |
require "rails_helper"
RSpec.describe Loaders::RecordLoader, type: :model do
it "can load a record" do
user = create(:user)
loaded_user = GraphQL::Batch.batch {
described_class.for(User).load(user.id)
}
expect(loaded_user.id).to eq(user.id)
end
end
|
Localization.define('ko_KO') do |l|
l.store "d", "일" # 심마로
l.store "h", "시간" # 심마로
l.store "m", "분" # 심마로
l.store "w", "주" # 심마로
l.store "To", "To"
l.store "by", "by"
l.store "or", "또는" # 심마로
l.store "Age", "생성일" # 심마로
l.store "All", "모두" # 심마로
l.store "Apr", "4월" # 심마로
l.store "Aug", "8월" # 심마로
... |
namespace :droplet do
desc "Updating the server"
task :setup do
on roles(:app) do
execute "echo 'export LANG=\"en_US.utf8\"' >> ~/.bashrc"
execute "echo 'export LANGUAGE=\"en_US.utf8\"' >> ~/.bashrc"
execute "echo 'export LC_ALL=\"en_US.UTF-8\"' >> ~/.bashrc"
execute "so... |
module OSMLib
module OSMChange
class Change
# The list of actions
attr_reader :actions
def initialize
@actions = []
end
def push(action)
if action.class == Action
@actions << action
end
end
def actions=(actions)
actions.each d... |
json.array!(@mages) do |mage|
json.extract! mage, :id
json.url mage_url(mage, format: :json)
end
|
Pod::Spec.new do |spec|
spec.name = "RSGithubRepoListing"
spec.version = "0.0.6"
spec.summary = "To get Github Repos from username."
spec.description = "This framework helps to list out all Github Repositories associated with given username."
spec.homepage = "https://github.com/rahulda... |
class RemoveColumnsProduct < ActiveRecord::Migration
def self.up
remove_column :products, :is_available
remove_column :products, :stock_quantity
end
end
|
module Collins; module Api; module Util
module Errors
protected
def handle_error response
if response.code >= 400 && rich_error_response?(response) then
raise RichRequestError.new(
"Error processing request", response.code, error_response(response), error_details(response)
)
... |
class Follow < ActiveRecord::Base
belongs_to :user
belongs_to :follower, foreign_key: "follower_id", class_name: "User"
validates_uniqueness_of :follower_id, :scope => [:user_id]
end
|
require 'rails_helper'
feature 'User plays shows at location' do
scenario 'they see the form on the landing page' do
visit root_path
fill_in 'city', with: 'New York'
click_button 'Go!'
expect(page).to have_css '.foobar-name', 'My foobar'
end
end |
class Show < ActiveRecord::Base
has_many :characters
has_many :actors, through: :characters
def self.genre
self.genre
end
def build_network
self.find(:call_letters)
end
end
|
require 'spec_helper'
describe "Micropost pages" do
subject { page }
let(:user) { FactoryGirl.create(:user) }
before { sign_in user }
describe "Creacion de micropost" do
before { visit root_path }
describe "con informacion invalida" do
it "no deberia crear un micropost" do
expect { cli... |
#######################################################################
# test_itunes_library.rb
#
# Test suite for the main library.
#######################################################################
require 'rubygems'
gem 'test-unit'
require 'test/unit'
require 'itunes_library'
class ITunesLibraryTest < Test::... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu-server-12042-x64-vbox4210"
config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210.box"
config.vm.network :private_network... |
class OperationsController < ApplicationController
def index
@operations = Operation.new
end
def create
if FileUpload.csv_file? operation_params["file"].original_filename
@job_id = OperationWorker.perform_async(operation_params["file"].path, operation_params["file"].original_filename )
redirect... |
class Practice < ActiveRecord::Base
has_many :swimsets, dependent: :destroy, inverse_of: :practice
accepts_nested_attributes_for :swimsets, allow_destroy: true
belongs_to :group
end
|
# frozen_string_literal: true
class ShareStatusToFacebookJob < ApplicationJob
queue_as :default
def perform(user_id, status_id)
user = User.find(user_id)
status= user.statuses.find(status_id)
work_image = status.work.work_image
image_url = if work_image.present? && Rails.env.production?
wor... |
require "rails_helper"
RSpec.describe UserMailer, type: :mailer do
around do |example|
ClimateControl.modify(
NOTIFY_WELCOME_EMAIL_TEMPLATE: "123",
DOMAIN: "test.local"
) do
example.run
end
end
let(:user) { create(:administrator) }
before { allow(user).to receive(:send).with(:se... |
# frozen_string_literal: true
class User < ApplicationRecord
has_secure_password
validates :username, presence: true, length: { minimum: 5, maximum: 50 }
validates :email, presence: true, uniqueness: true
validates :password, presence: true, length: { minimum: 7 }, on: :create
validates_inclusion_of :role, ... |
require_relative '../spec_helper'
describe 'Course API' do
before :all do
@vars = {}
end
it 'creates a course' do
request_data = {
title: random_text(16),
description: 'The New Course',
attachments: [],
category_id: random_id,
participants: [
{
... |
require 'fileutils'
module Cocoadex
class Keyword
attr_reader :term, :type, :docset, :url
attr_accessor :fk, :id
CLASS_METHOD_DELIM = '+'
INST_METHOD_DELIM = '-'
CLASS_PROP_DELIM = '.'
SCOPE_CHARS = [CLASS_PROP_DELIM,CLASS_METHOD_DELIM,INST_METHOD_DELIM]
def self.datastore
@st... |
# frozen_string_literal: true
module Plugin::Mastodon
class SSEPublicType < Diva::Model
field.has :server, Plugin::Mastodon::Instance, required: true
attr_reader :datasource_slug
attr_reader :title
attr_reader :perma_link
def token
nil
end
def public(only_media: false)
para... |
name 'basebox'
maintainer 'Etki'
maintainer_email 'etki@etki.name'
license 'MIT'
description 'Installs and configures shared Basebox components'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends 'apt', '~> 2.6.0'
depends 'locale', ... |
require "test_helper"
class CommutatorTest < MiniTest::Test
def test_each_side_is_180_degrees
commutator = ElectricMotor::Commutator.new
assert_equal :a, commutator.input
assert_equal :b, commutator.output
commutator.turn(180)
assert_equal :b, commutator.input
assert_equal :a, commutator.out... |
class ActivityCsvPresenter < ActivityPresenter
include CountryHelper
include CodelistHelper
def benefitting_countries
return if super.blank?
list_of_countries(to_model.benefitting_countries, BenefittingCountry)
end
def intended_beneficiaries
return if super.blank?
list_of_countries(to_model.... |
module Queries
class IndexPortfolioCoins < Queries::BaseQuery
type [Types::PortfolioCoin], null: true
description "Get the portfolio coins"
def resolve
return [] unless current_user
current_user.portfolio_coins
end
end
end
|
require 'formula'
class Tractorgen < Formula
homepage 'http://www.vergenet.net/~conrad/software/tractorgen/'
url 'http://www.vergenet.net/~conrad/software/tractorgen/dl/tractorgen-0.31.7.tar.gz'
sha1 '7d5d0c84a030a71840ee909b2124797b5281ddcc'
def install
system "./configure", "--disable-debug", "--disable... |
require_relative './interfaced_array.rb'
require_relative './interface/presenter.rb'
require_relative './human_presenter/present_track.rb'
require_relative './human_presenter/present_car.rb'
require_relative './human_presenter/present_loose_tire.rb'
# Presenter component for a human to play the game
class HumanPresen... |
# -*- coding: utf-8 -*-
module Mushikago
module Mitsubachi
class ScriptDeleteRequest < Mushikago::Http::DeleteRequest
def path; '/1/mitsubachi/script/delete' end
request_parameter :project_name
request_parameter :script_name
def initialize project_name, script_name, options={}
sup... |
class BookingsController < ApplicationController
def index
@user = current_user
@bookings = policy_scope(Booking).order(paid_at: :desc)
end
end
|
json.array!(@design_cases) do |design_case|
json.extract! design_case, :id
json.url design_case_url(design_case, format: :json)
end
|
#!/usr/bin/env ruby
require "pg_queue"
worker = PgQueue::Worker.new
["INT", "TERM"].each do |signal|
trap(signal) do
worker.stop
end
end
worker.start
|
require 'tinder'
require 'fetchers/project_fetcher'
task :report => :environment do
while true
sleep(10)
Build.update_all("last_checked_at = '#{Time.now.to_s(:db)}'")
campfire_settings = YAML.load_file(Rails.root + "config/campfire.yml")
campfire = Tinder::Campfire.new(campfire_settings["subdomain"],... |
class PropertyListingsController < ApplicationController
def index
render :json => PropertyListing.all end
def create
property_listing = PropertyListing.new(property_listing_params)
if property_listing.save
render :json => property_listing
else
render :text => "#{property_listing.error... |
require 'open-uri'
require 'json'
require 'nokogiri'
require 'pp'
DEBUG = ARGV.include?('-d') || ARGV.include?('--debug')
if DEBUG
ARGV.delete '--debug'
ARGV.delete '-d'
end
class Array
def count_hash
h = Hash.new {|h, k| h[k] = 0 }
each {|obj| h[obj] += 1 }
h
end
end
USER_AGENTS = ["Mozilla/5.0 ... |
# == Schema Information
#
# Table name: articles
#
# id :integer not null, primary key
# title :string not null
# source_name :string not null
# date :date not null
# author :string not null
# image_url :string not null
# a... |
class CreateWorkDays < ActiveRecord::Migration
def self.up
create_table :work_days do |t|
t.string :name
t.integer :start_hour
t.integer :end_hour
t.timestamps
end
end
def self.down
drop_table :work_days
end
end
|
# encoding: utf-8
Fabricator(:company) do
name { sequence(:account_name) { |i| "#{Faker::Company.name} {i}" } }
end
|
# encoding: utf-8
require 'spec_helper'
describe Scrapper do
context "mobydick" do
before(:all) do
VCR.use_cassette "mobydick" do
@school = Scrapper::scrap(:codigo => 12007243)
end
end
it "should get the correct code" do
@school[:codigo].should eq("12007243")
end
it "... |
class ConfirmsController < ApplicationController
before_action :set_confirm, only: [:show, :edit, :update, :destroy]
# GET /confirms
def index
@confirms = Confirm.all
set_respond
end
# GET /confirms/1
def show
set_respond
end
# GET /confirms/new
def new
@confirm = Confirm.new
se... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.