text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
class BaseMonad
include Dry::Monads[:do, :maybe, :result]
def find(model, **query)
Maybe(model.find_by(**query))
end
end
|
#encoding: utf-8
module ModeloQytetet
class Jugador
attr_accessor :casilla_actual,:encarcelado, :saldo, :propiedades
attr_writer :carta
attr_reader :nombre, :factorEspeculador
def initialize(n)
@encarcelado = false
@nombre = n
@saldo = 7500
@casilla_actual = nil
... |
class VietnamesesController < ApplicationController
before_action :set_vietnamese, only: [:show, :edit, :update, :destroy]
before_action :check_login
# GET /vietnameses
# GET /vietnameses.json
def index
if(params[:search] && params[:search]!="")
@vietnameses = Vietnamese.admin_se... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
# frozen_string_literal: true
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
ENV['SAUCE_BUILD_NAME'] = "Ruby EmuSim Local - #{Time.now.to_i}"
# parallel_test gem setting for how many to run in parallel
ENV['TEST_ENV_NUMBER'] = '25'
desc 'Android Emulator'
task :android do
ENV['DEVICE_NAME'] = 'Andr... |
class Advert2sController < ApplicationController
before_action :set_advert2, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
# GET /advert2s
# GET /advert2s.json
def index
@advert2s = Advert2.all
end
# GET /advert2s/1
# GET /advert2s/1.json
def show
end
# GET /adve... |
class AddCompanyToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :name, :string, null:false
add_column :users, :indutry_type, :string, null:false
add_column :users, :foundation_date, :date, null:false
add_column :users, :capital, :integer, null:false
... |
##----------------------------------------------------------------------------##
## The Legend of NeonBlack's Maus Romancing Sa-Ga Script v1.0
## Created by Neon Black
##
## For both commercial and non-commercial use as long as credit is given to
## Neon Black and any additional authors. Licensed under Creative Common... |
module Notifier
module PushBullet
def self.notify(message, title="SimpleCMS", url=nil)
return unless ENV['PUSHBULLET_ACCESS_TOKEN']
access_token = ENV['PUSHBULLET_ACCESS_TOKEN']
params = {
:title => title,
:body => message
}
if url
params[:type] = "link"
... |
class CreateLearningDeliveries < ActiveRecord::Migration
def change
create_table :learning_deliveries do |t|
t.string :format_type
t.text :description
t.datetime :delivery_date
t.integer :delivery_kind
t.references :learning_dynamic, index: true
t.timestamps null: false
en... |
module Sequel
# This module makes it easy to add deprecation functionality to other classes.
module Deprecation
# This sets the output stream for the deprecation messages. Set it to an IO
# (or any object that responds to puts) and it will call puts on that
# object with the deprecation message. Set t... |
class UserGoal < ActiveRecord::Base
include ActivityLog
after_create :create_goal_log
belongs_to :user
has_many :activities, as: :targetable
def create_goal_log
create_log self, self.user_id, Settings.activity_type.create_goal
end
end
|
class MasterFaceSerializer < ActiveModel::Serializer
embed :ids
attributes :id, :name, :email
has_many :battle_faces
end
|
class PolyTreeNode
def initialize(value)
@value = value
@parent = nil
@children = []
end
def parent
@parent
end
def children
@children
end
def value
@value
end
def parent=(node)
if @parent != node
if node != ... |
class Site < ActiveRecord::Base
has_many :studysites
has_many :studies, through: :studysites
#validates_uniqueness_of :name, scope: :location, allow_nil: true
validates :name, uniqueness: {message: 'The site name and location already exists.', case_sensitive: false, scope: :location}
validates :name, :location, ... |
=begin
#qTest Manager API Version 8.6 - 9.1
#qTest Manager API Version 8.6 - 9.1
OpenAPI spec version: 8.6 - 9.1
Generated by: https://github.com/swagger-api/swagger-codegen.git
=end
# Common files
require 'swagger_client/api_client'
require 'swagger_client/api_error'
require 'swagger_client/version'... |
#!/usr/bin/env ruby
require File.expand_path('../../config/environment', __FILE__)
require "csv"
require "aws/s3"
raise "S3_KEY must be set in ENV" unless ENV['S3_KEY'].present?
raise "S3_SECRET must be set in ENV" unless ENV['S3_SECRET'].present?
AWS::S3::Base.establish_connection!(
:access_key_id => ENV['S3... |
class AddColumnToAttempt < ActiveRecord::Migration
def change
add_column :attempts, :enrollmentendsat, :datetime
end
end |
# frozen_string_literal: true
class BoardObject
attr_accessor :updated
HORIZONTAL_LIMIT = 512
VERTICAL_LIMIT = 256
def initialize
super
@updated = true
end
protected
def within_vertical_boundary?(pos)
pos.positive? && pos < VERTICAL_LIMIT
end
def within_horizontal_boundary?(pos)
... |
require 'rails_helper'
describe FetchFriendsForUser do
let(:request) { FetchFriendsForUserRequest.new(facebook_token: 'some token'.maybe)}
let(:listener_spy) { spy(ListenerSpy) }
subject { FetchFriendsForUser.new(request, listener_spy)}
describe '#perform' do
context 'without a facebook token' do
l... |
class Romano
ValoresBasicos = {
1 => "I",
4 => "IV",
5 => "V",
9 => "IX",
10 => "X",
20 => "X",
30 => "X",
40 => "XL",
50 => "L",
90 => "XC",
100 => "C",
200 => "C",
300 => "C",
400 => "CD",
500 =... |
class PostitsController < ApplicationController
def index
@postits = Postit.all
end
def show
@postit = Postit.find(params[:id])
end
def new
@postit = Postit.new
end
def edit
@postit = Postit.find(params[:id])
end
def create
@postit = Postit.new(postit_params)
if @postit.sa... |
class CreateModels < ActiveRecord::Migration[5.2]
def change
create_table :models do |t|
t.string :name, null: false
t.datetime :release_date, null: false
t.references :brand, null: false
t.references :category, null: false
t.string :processor
t.string :ram
t.string :stor... |
class CreateScreenings < ActiveRecord::Migration
def change
create_table :screenings do |t|
t.references :movie, index: true, foreign_key: true
t.references :user, index: true, foreign_key: true
t.references :theater, index: true, foreign_key: true
t.references :offer, index: true, foreign... |
class Team < ActiveRecord::Base
before_create :inactive_season
has_many :match_results
validates :name, presence: true, length: { minimum: 3 }, uniqueness: true
def inactive_season
raise 'Sezon jest już rozpoczęty.' if Season.find(1).status == 'active'
end
# include Comparable
#
# def <=>(other)
... |
require File.dirname(__FILE__) + '/spec_helper'
describe "the SJCL BitArray" do
it "work with extract" do
SJCL::BitArray.extract([1415934836, 543256164, 544042866], 0, 24).should eql(5530995)
SJCL::BitArray.extract([-123123, 2345], 8, 16).should eql(65055)
end
it "should handle partials" do
SJCL::Bit... |
# Shorten this sentence:
advice = "Few things in life are as important as house training your pet dinosaur."
# ...remove everything starting from "house".
# Review the String#slice! documentation, and use that method to make the return value "Few things in life are as important as ". But leave the advice variable as... |
class ChangeColumnsInComments < ActiveRecord::Migration
def change
add_column :comments, :commentable_id, :integer
add_column :comments, :commentable_type, :string
remove_reference( :comments, :user, index: true, foreign_key: true)
remove_reference( :comments, :product, index: true, foreign_key: true)... |
#coding:utf-8
# == Schema Information
#
# Table name: collaborators
#
# id :integer not null, primary key
# name :string(255)
# email :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# password_digest :string(255)
# rem... |
class PricesController < ApplicationController
def index
@prices = Price.order('name')
end
def show
@price = Price.includes(:products).find(params[:id])
redirect_to @price, :status => :moved_permanently if request.path != price_path(@price)
end
end
|
class Post < ApplicationRecord
belongs_to :user
mount_uploader :post_image, PostImageUploader
validates :user_id, :description, presence: true
acts_as_likeable
end
|
require 'pg_search'
class Media < ApplicationRecord
belongs_to :artist
belongs_to :category
has_many :photos, dependent: :destroy
has_many :taggings, dependent: :destroy
has_many :rentals, dependent: :destroy
belongs_to :subscription_type
has_many :tags, through: :taggings
has_many :media_to_package_li... |
require 'active_support'
module Easy
module ReferenceData
def self.refresh(clazz, unique_attribute_symbol, unique_attribute_value, attributes)
self.update_or_create(clazz, attributes.merge(unique_attribute_symbol => unique_attribute_value), keys: [unique_attribute_symbol])
end
def self.update_or_... |
ActiveAdmin.register Post do
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
config.per_page = 10
permit_params do
permitted = [:text, :user_id]
permitted << :other if params[:action] == 'create' && current_user.admin?
permitted
... |
# frozen_string_literal: true
class Product < ApplicationRecord
belongs_to :user
belongs_to :category
has_one_attached :image
has_many :order_products
validates :title, :price, :quantity, :description, :image, presence: true
end
|
Deface::Override.new(:virtual_path => "spree/admin/properties/_form",
:name => "properties_globalization_form",
:replace => "[data-hook='admin_property_form']",
:partial => "spree/admin/shared/properties_globalization_form") |
require 'test/unit'
class TestArticle < Test::Unit::TestCase
def setup
@tests = []
@test1 = Article.new("title","content bla bla bla","author")
@test2 = Article.new("title2","content2","author2")
@test3 = Article.new("title3","content3","author3")
@test4 = Article.new("title4","content4","author... |
require_relative 'test_helper'
require_relative '../lib/merchant'
class MerchantTest < Minitest::Test
def test_it_exists
merchant = Merchant.new({:id => 5,
:name => "Turing School",
:created_at => Time.now,
:... |
module Crawler
class Fnv1
PRIME = 16777619
OFFSET_BASIS = 2166136261
MASK = 2 ** 32 - 1
def self.calc(str)
hash = OFFSET_BASIS
str.bytes.each do |octet|
hash = (hash * PRIME) & MASK
hash ^= octet
end
hash
end
end
end
|
class BonusDrink
BONUS_PER = 3
BONUS_GET = 1
class << self
def total_count_for(purchase)
purchase + calculate_bonus(purchase)
end
private
def calculate_bonus(empty_bottle)
# 空き瓶3本目まではおまけなし
return 0 if empty_bottle < BONUS_PER
# 最初のおまけ + (最初のおまけと交換した空き瓶を引いた残り本数) / (2本目の... |
# Create a person class with at least 2 attributes and 2 behaviors. Call all
# person methods below the class so that they print their result to the
# terminal.
class Person
attr_reader :name, :height, :happiness, :working
def initialize(name, height, happiness)
@name = name
@height = height
@happine... |
=begin
Aeon Party
by Fomar0153
Version 1.1
----------------------
Notes
----------------------
This script allows you to summon actors in the style of FFX's aeons.
----------------------
Instructions
----------------------
See the thread or blog post for a change.
Also if using an actor battler script add:
SceneManage... |
# frozen_string_literal: true
require 'ipaddr'
module Keycard
# looks up institution ID(s) by IP address
class InstitutionFinder
INST_QUERY = <<~SQL
SELECT inst FROM aa_network WHERE
? >= dlpsAddressStart
AND ? <= dlpsAddressEnd
AND dlpsAccessSwitch = 'allow'
... |
class PhotosController < ApplicationController
layout 'admin'
before_action :user_check
before_action :parent
def index
@photos = @gallery.photos.order('position DESC')
end
def new
@photos = Photo.new({:name=>"Tytuł?", :gallery_id => @gallery.id, :position => (@gallery.photos.count + 1)})
@gal... |
# frozen_string_literal: true
RSpec.describe SparseInclude do
let(:klass) do
Class.new
end
let(:source_module) do
Module.new do
def foo
42
end
end
end
before do
klass.include SparseInclude[source_module, foo: :bar]
klass.extend SparseInclude[source_module, foo: :bazz... |
# frozen_string_literal: true
module AsciiPngfy
module Settings
# Provides the interface for all the Setting implementations in a way that
# each inclusion of this module forces the including class to override
# the behaviour for #set and #get
#
# If the #get or #set method is called, but it is n... |
class RenameTablePicturesTagsToPictureTags < ActiveRecord::Migration[5.0]
def change
rename_table :pictures_tags, :picture_tags
end
end
|
class ByteSizeValidator < ActiveModel::EachValidator
include ActionView::Helpers::NumberHelper
def validate_each(record, attribute, value)
return if value.nil?
actual_size = value.bytesize
if options.key?(:minimum)
if actual_size < options[:minimum]
record.errors.add attribute, :too_smal... |
module EasyCRUD
module Extensions
module CrudModel
extend ActiveSupport::Concern
included do
class_attribute :_crud_model
class << self
def crudify(model_name, opts = {})
self._crud_model = EasyCRUD.build_crud_model(model_name, opts)
end
end
... |
module TestDB
def self.database
FileUtils.mkdir_p("#{File.dirname(__FILE__)}/../../tmp")
db = JSONDb.new("db-#{ENV['RACK_ENV']}.json")
db.delete!
db
end
end |
class AddVendorIdToProducts < ActiveRecord::Migration
def change
add_column :products, :vendorID, :int
end
end
|
class UserMailer < ActionMailer::Base
default from: ENV["EMAIL_FROM_ADDRESS"]
def violations_report(recipient:, violations:)
@recipient = recipient
@violations = violations
mail to: @recipient.email,
subject: "Heat Seek Daily Violations Report",
cc: ENV["VIOLATIONS_REPORT_CC_EMAIL"]
end
... |
# frozen-string-literal: true
require 'auto_reloader/version'
require 'singleton'
require 'forwardable'
require 'monitor'
require 'thread' # for Mutex
require 'set'
require 'time' unless defined?(Process::CLOCK_MONOTONIC)
class AutoReloader
include Singleton
extend SingleForwardable
# default_await_before_unlo... |
class SalesItems < ActiveRecord::Migration
def change
create_table :sales_items do |t|
t.integer :sale_id
t.integer :item_id
t.integer :quantity
end
end
end
|
# frozen_string_literal: true
class GuruLettersController < ApplicationController
skip_before_action :authenticate_user!, only: %i[new create]
def new
@guru_letter = GuruLetter.new
end
def create
@guru_letter = GuruLetter.new(letter_params)
if @guru_letter.valid?
GuruLettersMailer.contact_u... |
class WelcomeController < ApplicationController
def home
if current_user.present?
redirect_to products_path
else
redirect_to new_user_session_path
end
end
end
|
class Api::Mobile::V1::ShopsController < Api::Mobile::V1::ApplicationController
helper_method :count_available_books_in_store
def index
@publisher_id = params[:id]
@shops = Shop.joins(shop_items: {book: :publisher}).where("publishers.id = ?", @publisher_id).distinct
end
def mark_as_sold
shop = Sh... |
class Post < ActiveRecord::Base
self.table_name = 'posts'
belongs_to :topic
def self.from_user(user_id)
where(user_id: user_id)
end
def self.posted_since(time = 1.minute.ago)
where(arel_table[:created_at].gt time)
end
def updatable_attributes
attributes.slice(*%w(id title text user_... |
#
# tkextlib/bwidget/scrolledwindow.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/frame'
require 'tkextlib/bwidget.rb'
module Tk
module BWidget
class ScrolledWindow < TkWindow
end
end
end
class Tk::BWidget::ScrolledWindow
TkCommandNames = ['S... |
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2018, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
if Rails.env.production?
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :timeoutable, :timeout_in =>... |
require 'test_helper'
class AchievementsControllerTest < ActionDispatch::IntegrationTest
setup do
@achievement = achievements(:one)
end
test "should get index" do
get achievements_url
assert_response :success
end
test "should get new" do
get new_achievement_url
assert_response :success
... |
require 'rails_helper'
RSpec.feature 'sign in' do
scenario 'with valid data' do
user = create(:user)
visit new_user_session_path
fill_in 'Email', with: user.email
fill_in 'Password', with: user.password
click_on 'Log in'
expect(current_path).to eq root_path
end
scenario 'with invalid... |
# typed: true
class CreateLocalLawPipelines < ActiveRecord::Migration[6.0]
def change
create_table :local_law_pipelines do |t|
t.text :title
t.text :paragraph
t.text :local_law_link
t.integer :paragraph_number
t.string :book
t.references :local_law_pipeline, null: false, foreig... |
require 'elasticsearch/model'
class User < ActiveRecord::Base
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
geocoded_by :full_street_address
after_validation :geocode unless Rails.env.test?
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeouta... |
class Projects < ActiveRecord::Migration
def change
create_table "projects", force: true do |t|
t.string "name"
t.string "category"
t.string "project_id"
t.string "acct_number"
t.boolean "active", default: true
t.integer "user_id"
t.datetime "created_at"
t.datetime ... |
class Survey < ActiveRecord::Base
belongs_to :creator, class_name: "User"
has_many :completed_surveys, class_name: "Completion"
has_many :survey_takers, class_name: "User", through: :completions
has_many :questions
end
|
require "test_helper"
class LoggingTest < Test::Unit::TestCase
def setup
@old_logger = Logging.logger
end
def teardown
Logging.logger = @old_logger
end
def test_log_message_with_default_level
logger = mock("logger")
logger.expects(:info).with("foo")
Logging.logger = logger
Logging.... |
require 'rgl/topsort' # acyclic
class AgentArc < ApplicationRecord
belongs_to :target, foreign_key: 'target_id', class_name: 'Agent', inverse_of: :in_arcs
belongs_to :source, foreign_key: 'source_id', class_name: 'Agent', inverse_of: :out_arcs
alias_attribute :agent, :source
alias_attribute :depends_on, :targ... |
class Post < ActiveRecord::Base
belongs_to :user
has_many :comments
has_many :connections
has_many :categories, through: :connectinos
end |
Rails.application.routes.draw do
get 'exceptions/show'
root 'recipes#homepage'
resources :recipes, only: %w[show]
end
|
class AddBomIdentifierToParts < ActiveRecord::Migration
def change
add_column :parts, :bom_identifier, :string
end
end
|
#
# Library Preparation
#
begin
require 'spec'
rescue LoadError
require 'rubygems' unless ENV['NO_RUBYGEMS']
gem 'rspec'
require 'spec'
end
$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'xpash'
#
# Constants
#
FIXTURE_DIR = "#{File.dirname(__FILE__)}/fixture"
FIXTURE_URL = "http://www.ruby-lang.org... |
class LinkedList
attr_accessor :head
def initialize
@head = nil
end
def new_node(value)
Node.new(value)
end
def append(value)
empty? ? set_head(value) : set_tail(value)
end
def remove_at(index)
removed_node = at(index)
prev_node = at(index - 1)
next_node = at(index + 1)
p... |
class Team
attr_reader :name, :motto, :members
def initialize(name,motto)
@name, @motto = name, motto
@members = []
end
def addMembers(*members)
members.each {|member| @members << member}
end
end
|
class QuestionFollower
attr_reader :id, :user_id, :question_id
def self.find_by_id(id)
query = <<-SQL
SELECT
*
FROM
question_followers
WHERE
id = ?
SQL
QuestionFollower.new(QuestionsDatabase.instance.execute(query, id)[0])
end
def self.followers_for_question_id(id)
... |
FactoryBot.define do
factory :cond_like do
url 'https://instagram.com/someurl'
association :event
end
end
|
class RemoveFieldsFromCompletedTripTasks < ActiveRecord::Migration
def change
remove_column :completed_trip_tasks, :trip, :string
remove_column :completed_trip_tasks, :task, :string
end
end
|
require 'player'
describe Player do
subject(:player) {described_class.new "Tommy"}
describe '#initialize' do
it 'will return the requested player name' do
expect(player.name).to eq "Tommy"
end
it 'will return the requested player healthpoints' do
expect(player.healthpoints).to eq 100
... |
RSpec.shared_context 'Github Client', shared_context: :metadata do
let(:endpoint) { 'https://api.github.com/graphql' }
let(:headers) do
{
'Authorization' => "Bearer #{ENV['GITHUB_ACCESS_TOKEN']}",
'Content-Type' => 'application/json'
}
end
let(:client) do
Graphlient::Client.new(
... |
require 'rails_helper'
RSpec.describe User, type: :model do
let(:user) { User.new(username: 'admin') }
describe 'associations' do
it { is_expected.to have_many(:events) }
end
describe 'validations' do
it 'is valid with valid attributes' do
expect(user).to be_valid
end
it 'is not valid wit... |
#!/usr/bin/env ruby
# :title: PlanR::Content::ResourceNode
=begin rdoc
(c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org>
=end
require 'plan-r/content_repo/content_node'
require 'find'
module PlanR
module ContentRepo
=begin rdoc
Document resource, e.g. an image, stylesheet, or template.
=end
class Re... |
module CDI
module V1
class SimpleLearningTrackReviewSerializer < ActiveModel::Serializer
root false
attributes :id, :learning_track_id, :student_class_id, :comment,
:user_id, :review_type, :review_type_text, :score,
:review_types_texts, :created_at, :updated_at
... |
class Image < ApplicationRecord
validates_presence_of :title
validates_presence_of :attachment_address
manage_with_tolaria using: {
icon: :image,
priority: 1,
category: "Media",
permit_params: [
:title,
:alternate_text,
:credit,
:keywords,
:attachment_address,
]... |
class GamesController < ApplicationController
def index
@games = Game.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @games }
end
end
def new
@game = Game.new
respond_to do |format|
format.html # new.html.erb
format.json { render ... |
json.books @books do |book|
json.extract! book, :isbn, :title, :des
json.comments book.comments do |comment|
json.extract! comment, :commenter, :body
end
json.authors book.authors do |author|
json.extract! author, :name
end
json.extract! book.category, :id, :category_name
end |
require 'xcode-installer/logout'
command :logout do |c|
c.syntax = 'xcode-installer logout'
c.summary = 'Remove account credentials'
c.description = ''
c.action XcodeInstaller::Logout, :action
end
|
class PersonFactory
def initialize max_id
@max_id = max_id
end
def build_person
new_person = Person.new(next_id)
end
def build_fake_person_list qty
persons = Array.new
qty.times do |i|
fake_person_id = next_id + i
persons << Person.new(
fake_person_id,
"fullname#{fake_person_id}",
"em... |
require 'stringio'
module RubyCraft
# Utils for manipulating bytes back and forth as strings, strings and numbers
module ByteConverter
def toByteString(array)
array.pack('C*')
end
def intBytes(i)
[i >> 24, (i >> 16) & 0xFF, (i >> 8) & 0xFF, i & 0xFF]
end
def stringToByteArray(str)... |
class SecretariatDecorator < Draper::Decorator
delegate_all
def image_url
h.image_tag model.image_url_url
end
end |
class UserSessionsController < ApplicationController
skip_before_filter :require_login, except: [:destroy]
def create
if @user = login(params[:name], params[:password])
redirect_to '/'
else
flash.now[:alert] = 'Login failed'
redirect_to :back
end
end
def destroy
logout
re... |
# coding: utf-8
require 'spec_helper'
describe Cleanweb::Spam do
context "spam?" do
let(:params) { {subject: "subject", body: "body"} }
let(:cleanweb) { Cleanweb.new params }
let(:ok_response) { File.read(File.join("spec", "mocks", "ok.xml")) }
let(:links_response) { File.read(File.join("spec", "moc... |
#encoding: utf-8
require 'rubygems'
require 'sqlite3'
require 'sinatra'
require 'sinatra/reloader'
def init_db
@db = SQLite3::Database.new 'blogsin.db'
@db.results_as_hash = true
end
before do
init_db
end
configure do
init_db
@db.execute 'CREATE TABLE IF NOT EXISTS
"Posts"
(
"id" INTEGER PRIMARY KEY AU... |
module Spree
class Calculator::PercentOffSalePriceCalculator < Spree::Calculator
# TODO validate that the sale price is between 0 and 1
def self.description
"Calculates the sale price for a Variant by taking off a percentage of the original price"
end
def compute(sale_price)
(1.0 - sale_p... |
class Game < ApplicationRecord
validates :name, presence: true, uniqueness: { message: 'not unique: This game is already in our database'}
validates :summary, presence: true
validates :cover_url, presence: true
has_many :reviews
end
|
module RequestHelper
def valid_signin(user)
visit new_user_session_path
fill_in 'Email', with: user.email.upcase
fill_in 'Password', with: user.password
click_button "Log in"
end
def update_author_with(name)
fill_in 'author_name', with: name
click_button "Update author"
end
def up... |
name 'yum-repoforge'
maintainer 'Chef Software, Inc.'
maintainer_email 'cookbooks@chef.io'
license 'Apache-2.0'
description 'Installs and onfigures yum-repoforge aka RPMforge'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '2.0.1'
depends 'compat_resource', '>= 12.16.3'
depends 'yum-e... |
require 'sinatra'
require 'net/http'
require 'json'
ROOT_DIR=File.dirname(__FILE__)
require "#{ROOT_DIR}/lib/google/resources_parser"
get '/' do
haml :index
end
get '/api/v1/google/resources' do
uri = URI('https://apps-apis.google.com/a/feeds/calendar/resource/2.0/taptera.com/')
req = Net::HTTP::Get.new(uri)
r... |
require 'spec_helper'
require 'topicz/commands/stats_command'
describe Topicz::Commands::StatsCommand do
it 'generates no output if no changes were made' do
with_testdata do
expect {
Topicz::Commands::StatsCommand.new(nil, %w(-y 2000 -w 1)).execute
}.to output('').to_stdout
end
end
... |
module Roglew
module GLX
WINDOW_BIT_SGIX ||= 0x00000001
RGBA_BIT_SGIX ||= 0x00000001
PIXMAP_BIT_SGIX ||= 0x00000002
COLOR_INDEX_BIT_SGIX ||= 0x00000002
SCREEN_EXT ||= 0x800C
DRAWABLE_TYPE_SGIX ||= 0x8010
RENDER_TYPE_SGIX ||= 0x8011
X_REN... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.