text stringlengths 10 2.61M |
|---|
class PicasaWebRemoteAlbum < RemoteAlbum
def initialize(album_data)
@album_data = album_data
@id = album_data.elements['gphoto:id'].text
# the position of the thumbnail url depends on whether this
# data from from a feed of a list of albums or just one album
@thumbnail_url =
if alb... |
class AddOriginalFilenameToDocuments < ActiveRecord::Migration
def change
add_column :documents, :original_filename, :string
end
end
|
class CompanySerializer < ActiveModel::Serializer
embed :ids, include: true
attributes :id, :name, :address, :city, :country, :email, :phone
has_many :passports
end
|
require "spec_helper"
describe Mailer do
describe '#notify' do
let(:event) { Events::JobSucceeded.last }
let(:user) { users(:the_collaborator) }
let(:sent_mail) { Mailer.notify(user, event) }
it 'renders the notification header as the subject line' do
sent_mail.subject.should == event.header
... |
class ToauthController < ApplicationController
def entrar
@user = ToauthConnect.login(params[:code])
begin
sign_in_and_redirect @user, :event => :authentication
rescue
redirect_to '/500.html' #Porta para redirecionar havendo erro
end
end
def redirect
redirect_to ToauthConnect.auth_url
e... |
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module UserTask
class Application < Rails::Application
config.middleware.use Rack::Deflater
conf... |
$:.unshift(File.join(File.dirname(__FILE__), '/lib'))
require 'thumbs'
require 'sinatra/base'
require 'json'
class ThumbsWeb < Sinatra::Base
helpers Sinatra::GeneralHelpers
helpers Sinatra::WebhookHelpers
enable :logging
LogFile = File.join(File.dirname(__FILE__), 'log', 'unicorn.stdout.log')
get '/log' do... |
require 'rubygems'
require 'builder'
module YahooStock
# == DESCRIPTION:
# Convert results to xml
#
# == USAGE
# YahooStock::Result::XmlFormat.new("data as string"){[:keys => :values]}.output
#
# Mostly will be used as a separate strategy for formatting results to xml
class Result::XmlFormat < Res... |
#{{{ Marathon Fixture
require 'default'
#}}} Marathon Fixture
require 'assertions/assert_settings'
require 'settings/on_setting_window'
def test
java_recorded_version = '1.6.0_20'
original_use_top15_as_title = get_setting('UseTop15AsTitle')
original_default_karte_title = get_setting('DefaultKarteTitle')
o... |
require 'spec_helper'
describe 'postfix::lookup::database' do
let(:title) do
'/etc/postfix/test'
end
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
context 'with a hashed database' do
let(:params) do
{
type: ... |
# encoding: utf-8
RUNNER = File.join(File.expand_path(File.dirname(__FILE__)), "run.rb")
BASE_DIR = File.expand_path(File.dirname(__FILE__))
#
## script main
if ARGV.size != 1
$stderr.puts("usage: ruby suite.rb [suite file]")
exit(1)
end
@debug = !!ENV["DEBUG"]
tests = eval(IO.read(ARGV[0]))
tests.each do |te... |
require 'spec_helper'
describe 'Issues' do
describe 'issue creation and viewing' do
it 'should contain proper fields' do
visit new_issue_path
page.should have_selector("input#issue_title")
page.should have_selector("input#issue_description")
end
it 'should submit and create a issue' ... |
class AddTranchesToReplies < ActiveRecord::Migration[6.1]
def change
add_column :replies, :reply_of_reply, :boolean, default: false
add_column :replies, :ror_id, :integer
end
end
|
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'sidekiq/testing'
Sidekiq::Testing.inline!
class ActiveSupport::TestCase
set_fixture_class versions: PaperTrail::Version
fixtures :all
def assert_error model, attribute, type, options = {}
error = model.errors... |
class TodoList
# methods and stuff go here
attr_accessor :title, :items
def initialize(list_title)
@title = list_title.upcase!
@items = []
end
def add_item(new_item)
item = Item.new(new_item)
@items.push(item)
end
def delete_item(index)
@items.delete_at(index)
... |
module Jekyll
module Commands
module Gitlab
class Letsencrypt < ::Jekyll::Command
def self.init_with_program(prog)
prog.command(:letsencrypt) do |c|
c.description "Setup/Renew letsencrypt certificate"
c.action do |_args, _opts|
Jekyll::Gitlab::Letsenc... |
require "includes"
class KitTest < Minitest::Test
def test_kit_with_items
kit = Kit.new({"label1" => [1,2,3], "label2" => [4,5,6], "label3" => [7,8,9]}, 1, 16)
assert_equal(["label1", "label2", "label3"], kit.labels)
assert_equal([1,2,3], kit.get_sample_data("label1"))
assert_equal([4,5,6], kit.get_... |
class Plan < ApplicationRecord
belongs_to :restaurant
belongs_to :user
belongs_to :space
has_many :invites
validates :time, presence: true
validates :date, presence: true
validates :meeting_point, presence: true
end
|
class Post < ActiveRecord::Base
belongs_to :topic
belongs_to :user
delegate :username, :created_at, :to => :user, :prefix => true
attr_accessible :body
attr_accessible :body, :topic_id, :user_id, :as => :admin
validates :topic_id, :user_id, :presence => true
validates :body, :length => { :minimum => 5, ... |
=begin
puts "Who do you want to know more about: Gustavo, Duilio or Max?"
response = gets.downcase.chomp
case(response)
when "gustavo"
puts "Gustavo's favorite things to do in Berlin are go dancing, attending the ruby-learning meetup, and drinking beer."
when "Duilio"
puts "duilio's favorite things to d... |
require 'sequel'
module Bitcoin::Blockchain::Backends
# Storage backend using Sequel to connect to arbitrary SQL databases.
# Inherits from StoreBase and implements its interface.
class Archive < SequelBase
# sequel database connection
attr_accessor :db
DEFAULT_CONFIG = {
# TODO
mode: ... |
class Track < ActiveRecord::Base
validates_presence_of :symbol, message: "Symbol cannot be blank."
belongs_to :user
end |
require "rspec"
require "hanoi"
describe HanoiGame do
let(:game) { HanoiGame.new }
describe '#render' do
it 'renders the initial board state' do
expect(game.render).to eq("[1, 2, 3]\n[]\n[]\n")
end
end
describe '#move' do
it 'handles a single move' do
game.move(0, 1)
expect(game... |
require 'spec_helper'
describe Eway::Customer do
def create_customer
#create a customer
#customer
options = {}
options[:ref] = 'REF0001'
options[:title] = 'Mr'
options[:first_name] = 'Alvise'
options[:last_name] = 'Susmel'
@customer = Eway::Customer.new options
@customer.create
end
before(:all)... |
require_dependency "discovery/application_controller"
module Discovery
class CareerContentmentsController < ApplicationController
def create
@personality = Discovery::Personality.find(params[:personality_id])
@contentment = @personality.career_contentments.new(params[:career_contentment])
if @contentment.... |
# Use n-triples for indexing to prevent Fedora from blocking while assembling the RDF response
ActiveFedora::Fedora.class_eval do
def ntriples_connection
authorized_connection.tap { |conn| conn.headers['Accept'] = 'application/n-triples' }
end
def build_ntriples_connection
ActiveFedora::InitializingConne... |
#encoding: UTF-8
xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0" do
xml.channel do
xml.title "Startup Wichita - People"
xml.author "Startup Wichita"
xml.description "Bringing connections and collisions to the entrepreneur, startup, and tech communities in Wichita, Kansas."
xml.link "h... |
module Api
module V1
class BookSuggestionsController < ApiController
skip_before_action :authenticate_user!, only: [:create]
def create
book_s = BookSuggestion.create(book_suggestion_params)
if book_s.valid?
render json: book_s, status: :created
else
render ... |
require 'yaml'
require 'rexml/document'
require 'set'
# This module encapsulates the English to LOLspeak translator.
# See LOLspeak::Tranzlator for more information.
module LOLspeak
# A class to perform English to LOLspeak translation based on a dictionary
# of words.
class Tranzlator
# (bool -> false) Wethe... |
module InteractionErrors
InvalidUserError = Class.new(StandardError)
InvalidCredentialsError = Class.new(StandardError)
InvalidBillParamsError = Class.new(StandardError)
AchPaymentNotFound = Class.new(StandardError)
CreditCardNotFound = Class.new(StandardError)
class ActiveModelError < StandardError
... |
Redmine::Plugin.register :redmine_project_cf_autocomplete do
name 'Redmine Project Cf Autocomplete plugin'
author 'Bilel KEDIDI'
description 'This is a plugin for Redmine'
version '0.0.1'
url 'https://github.com/Atrasoftware/redmine_project_cf_autocomplete'
settings :default=>{
:choosed_cf=... |
module Hypgen
module Worker
class ExperimentRun
include Sidekiq::Worker
sidekiq_options queue: :experiment
sidekiq_options :retry => false
def perform(exp_id, profile_mappings, rabbitmq_location,
start_time, end_time, deadline)
Hypgen::Worker::Runner.
... |
# frozen_string_literal: true
# Query objects for follows
class FollowQuery
def initialize(scope = Follow.all)
@scope = scope
end
def distinct_count
@scope.count('DISTINCT follower_id')
end
end
|
class TriviaSession
attr_reader :session_id, :trivia, :curr_question_index
def initialize(session_id, trivia)
@session_id = session_id
@trivia = trivia
@status = []
@trivia.questions.length.times do |x|
@status << {:completion => "incomplete"}
end
@curr_question_index ... |
require 'omf-web/widget/abstract_widget'
require 'coderay'
#require 'ftools'
module OMF::Web::Widget::Code
# Maintains the context for a particular code rendering within a specific session.
#
class CodeWidget < OMF::Web::Widget::AbstractWidget
depends_on :css, "/resource/css/coderay.css"
at... |
# frozen_string_literal: true
class Maintenance
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
if show_maintenance_page?(request)
[200, {}, [maintenance_page]]
else
@app.call(env)
end
end
private
def show_maintenance_page?(request)
... |
class BloggersController < ApplicationController
def show
@blogger = User.find(params[:id])
@blogs = @blogger.blogs
@blogs = Blog.all.order('created_at').paginate(page: params[:page], per_page: 2)
end
end
|
require 'application'
class UketsukePdfsController < ApplicationController
def index
redirect_to :action => 'list'
end
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }... |
class ChangeDatatypePedalOfRoadbikes < ActiveRecord::Migration[5.0]
def change
change_column :roadbikes, :pedal, :boolean
end
end
|
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
module Comparable
def clamp(min, max)
return min if self <= min
return max if self >= max
self
end
end
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
require 'bosdk/webi_report_engine'
module BOSDK
describe WebiReportEngine do
before(:each) do
@enterprise_session = mock("EnterpriseSession").as_null_object
@report_engines = mock("ReportEngines").as_null_object
@webi_repo... |
require 'freeipmi/errorcodes'
module Freeipmi
class Connection
attr_accessor :options
def initialize(user, pass, host)
@options = ObservableHash.new
raise("Must provide a host to connect to") unless host
@options["hostname"] = host
# Credentials can also be stored in the freeipmi ... |
# frozen_string_literal: true
class Importer < Darlingtonia::Importer
##
# @return [Hash<Symbol, Object>]
def self.config
Rails.application.config_for(:importer)
end
def initialize(parser:, record_importer: default_record_importer)
super
end
def config
self.class.config
end
private
... |
class ApiController < ApplicationController
before_action :login_required_api
params_required :subscribe_id, only: :touch_all
params_required [:timestamp, :subscribe_id], only: :touch
params_required :since, only: [:item_count, :unread_count]
before_action :find_sub, only: [:all, :unread]
skip_before_action... |
class ChangeTagAlbumRelationship < ActiveRecord::Migration[5.0]
def change
remove_column(:tags, :album_id, :integer)
create_table(:albums_tags) do |t|
t.integer :album_id
t.integer :tag_id
end
end
end
|
require_relative 'test_helper'
begin
require 'tilt/yajl'
describe 'tilt/yajl' do
it "is registered for '.yajl' files" do
assert_equal Tilt::YajlTemplate, Tilt['test.yajl']
end
it "compiles and evaluates the template on #render" do
template = Tilt::YajlTemplate.new { "json = { :integer => ... |
class DbPeriodEn < ActiveRecord::Base
# Relations
belongs_to :db_period
end |
require 'httparty'
module Referly
class Client
include HTTParty
base_uri 'https://refer.ly/api/120701'
ssl_version :SSLv3
def initialize(key, secret)
@auth = { username: key, password: secret }
end
def post(path, params)
self.class.post(path, body: params, basic_auth: @auth)
... |
class TopController < ApplicationController
def index
@services = Service.order(position: :asc)
end
end
|
class CategoriesController < ApplicationController
before_action :load_category, :show_categories, only: %i(index show)
def index; end
def show
@comics = Comic.by_category(params[:id]).page(params[:page])
.per Settings.category.per_page
end
private
def load_category
return if ... |
require 'spec_helper'
describe "Divisions" do
before do
@division = FactoryGirl.create(:division)
end
describe "without admin login" do
it "should redirect to admin login" do
get divisions_path
response.should redirect_to(new_admin_session_path)
end
end
describe "with admin logged... |
# frozen_string_literal: true
module Validators
module TicketsValidatorHelper
POSITION_IN_FOLDER_ALREADY_TAKEN = I18n.t error.ticket.position_in_folder.already_taken
POSITION_IN_FOLDER_NOT_PRESENT = I18n.t error.ticket.position_in_folder.not_present
TITLE_NOT_PRESENT = I18n.t error.ticket.title.not_prese... |
class Item < ActiveRecord::Base
validates :name, presence: true
belongs_to :category
belongs_to :itemable, :polymorphic => true
has_many :item_orders
has_many :orders, through: :item_orders
belongs_to :skill_set
scope :admin_alpha, -> { order(name: :asc) }
def price
-1 * skill_set.money if skill_s... |
class Plan < ApplicationRecord
has_many :jobs
has_many :orders
belongs_to :currency
STATUS_ACTIVE = 'Active'.freeze
STATUS_EXPIRED = 'Expired'.freeze
enum status: {
draft: 0,
expired: 1,
active: 2
}
validates :name, :duration_days, :price, :currency, :presence => { :message => 'cann... |
require 'spec_helper'
describe "events/new" do
before(:each) do
assign(:event, stub_model(Event,
:address => "MyString",
:city => "MyString",
:zipcode => "MyString",
:latitude => 1.5,
:longitude => 1.5,
:user => nil
).as_new_record)
end
it "renders new event form" do
... |
require 'emoji'
require 'json'
require 'rexml/document'
class UnicodeCharacter
attr_reader :code, :description, :version, :aliases
class CharListener
CHAR_TAG = "char".freeze
def self.parse(io, &block)
REXML::Document.parse_stream(io, self.new(&block))
end
def initialize(&block)
@cal... |
# frozen_string_literal: true
require 'rails_helper'
require 'facilities/ppms/v0/client'
RSpec.describe Facilities::PPMS::V0::Client, team: :facilities do
let(:params) do
{
address: '58 Leonard Ave, Leonardo, NJ 07737',
bbox: [-75.91, 38.55, -72.19, 42.27]
}.with_indifferent_access
end
it '... |
class TwitterController < ApplicationController
def connect
@consumer = TwitterController.consumer
@request_token = @consumer.get_request_token(:oauth_callback => ENV['TWITTER_CALLBACK_URL'])
session[:request_token] = @request_token.token
session[:request_token_secret] = @request_token.secre... |
# frozen_string_literal: true
class TimeFrame < ActiveRecord::Base
belongs_to :group, class_name: 'TimeFrameGroup', inverse_of: :time_frames
has_many :lessons, inverse_of: :time_frame, dependent: :restrict_with_exception
validates :group, presence: true
validates :starts_at, presence: true, date: { before: :en... |
class AddColumnsToAdResultData < ActiveRecord::Migration
def change
change_table :ad_result_data do |t|
t.integer :date_type, null: false, default: 100
t.decimal :goal_cpa
t.integer :goal_l_conversion
t.decimal :goal_l_cpa
t.decimal :actual_cpa
t.integer :actual_l_conversion
... |
class AdminSessionsController < ApplicationController
def new
end
def create
@admin = Admin.find_by(username: params[:username])
if @admin
if @admin.authenticate(params[:password])
session[:username] = @admin.username
redirect_to root_path
else
flash.alert = "Incorrec... |
module Editor::Controllers::Document
class ExportLatex
include Editor::Action
def call(params)
id = params[:id]
document = DocumentRepository.find id
document = document.root_document
redirect_to "/error:#{id}?Document not found" if document == nil
e = Exporter.new(document)
... |
class Category < ApplicationRecord
has_and_belongs_to_many :products
belongs_to :category, class_name: 'Category', optional: true
has_many :categories, foreign_key: :category_id, class_name: 'Category'
end
|
class Con < ActiveRecord::Base
belongs_to :comparison
validates :body, :presence => true
before_save :sanitize_body
private
def sanitize_body
s = Rails::Html::FullSanitizer.new
self.body = s.sanitize self.body
end
end
|
class InfoSocialNetworksController < ApplicationController
before_filter :authenticate_user!
before_filter :has_admin_credentials?
def index
@info_social_networks = InfoSocialNetwork.find(:all, :order => "name ASC")
respond_to do |format|
format.html
format.json { render json: @info_social_n... |
# frozen_string_literal: true
require 'rails_helper'
require 'spec_helper'
feature 'User can like post' do
scenario 'successfully' do
visit '/users/sign_in'
fill_in 'Email', with: 'nick@test.com'
fill_in 'Password', with: '123456'
click_button 'Log in'
visit '/posts'
click_button 'like-1'
... |
class ItemsController < ApplicationController
def show
@item = Item.find_by(id: params[:id])
end
def new
@item = current_user.items.build if logged_in?
end
def create
@item = current_user.items.build(item_params)
if @item.save
flash[:success] = "投稿に成功しました"
redirect_to root_pa... |
# -*- mode: ruby -*-
# vi: set ft=ruby
Vagrant.configure("2") do |config|
# Configure the boxes
config.vm.box = "ubuntu/xenial64"
config.vm.provider "hyperv" do |v, override|
override.vm.box = "maxx/ubuntu16"
end
config.vm.define 'n1' do |n1|
n1.vm.hostname = 'n1'
n1.vm.network "private_network... |
User.create(
email: 'hello@jamesnewton.com',
password: 'password',
password_confirmation: 'password'
)
FactoryGirl.create(:post, published: true)
FactoryGirl.create(:post, published: true,
content: <<-MARKDOWN
# #{FFaker::Lorem.words(5).join(' ')}
## #{FFaker::Lorem.words(5).join(' ')}
### #{FFaker::Lorem.wor... |
class User < ActiveRecord::Base
attr_accessible :provider
attr_accessible :uid
attr_accessible :name # display name
attr_accessible :email
attr_accessible :is_admin
attr_protected :encrypted_password
attr_protected :salt
validates_uniqueness_of :uid, :scope => :provider, :message => 'was already used'... |
require "spec_helper"
describe "complex type definition node" do
def build_single_complex_type_node
XPain::Builder.new do |xsd|
xsd.schema do
xsd.define_complex_type "mystring" do
xsd.extension :base => "string" do
xsd.attribute :name => "type", :type => "string", :use => "opt... |
# Given a collection of distinct integers, return all possible permutations.
# Example:
# Input: [1,2,3]
# Output:
# [
# [1,2,3],
# [1,3,2],
# [2,1,3],
# [2,3,1],
# [3,1,2],
# [3,2,1]
# ]
# arr2 = ['a','b','c','d']
# def binary(a2, n, i)
# # arr = ['a','b','c','d']
# if (n < 1)
# puts "\nnew c... |
class Test < Formula
desc ""
homepage ""
url "https://github.com/caarlos0/test/releases/download/v4.0.7/test_4.0.7_macOS_64bits.binary"
version "4.0.7"
sha256 "8b4e4108c5fcee30327ec74a6b560da8ef00e614ebf5a876c0a83797a928c3c7"
def install
bin.install "moises"
bin.install "foo"
end
def caveats
... |
require 'spec_helper'
describe Charity do
describe "total_donations" do
before :each do
@charity = Charity.create(:legal_name => "Cool Charity")
end
it "should give us 0 if no donations found" do
@charity.total_donations.should == 0
end
it "should tell us the total donations for a s... |
# ApplicationController
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
# User authorization
include Pundit
rescue_from Pundit::NotAuthorizedError, with: :user_n... |
class CommentsController < ApplicationController
# skip_before_action :authorized
before_action :set_comment, only: [:show, :update, :destroy]
def index
@comments = Comment.all
# @comments = Comment.where('book_id = ?', params[:book_id])
# @comments = Comment.where('user_id = ?', params[:user_i... |
class ClosingStatement < ActiveRecord::Base
belongs_to :round
belongs_to :debate
belongs_to :author, class_name: "User", foreign_key: "author_id"
include ActionView::Helpers::SanitizeHelper
validate :check_word_count, on: [:update, :create]
# after_create :send_opponent_notification
def send_opponent_not... |
class Post < ActiveRecord::Base
belongs_to :user
belongs_to :blog
def to_param
"#{self.id}-#{self.created_at.strftime("%Y-%m-%d").parameterize}-#{self.title.parameterize}"
end
end
|
class DockerController < ApplicationController
helper_method :start_container
helper_method :stop_container
helper_method :kill_container
helper_method :delete_container
def dashboard
@docker_version = Docker.version
@docker_info = Docker.info
end
def containers
@containers = Docker::Contai... |
# encoding: utf-8
class Xi::DIP::Color::Convertor
SPACES = [:pixel, :hex, :rgb, :hsl, :hsv, :yiq, :xyz, :lab, :rgbc].freeze
RANGES = {
:rgb => [0.0..1.0, 0.0..1.0, 0.0..1.0],
:hsl => [0.0..1.0, 0.0..1.0, 0.0..1.0],
:hsv => [0.0..1.0, 0.0..1.0, 0.0..1.0],
:yiq => [0.0..1.0, 0.0..1.0, 0.0..1.0],
... |
require 'spec_helper'
describe Api::V1::Groups::MembershipsController do
render_views
# let(:resource_class) { GroupMembership }
describe "#index" do
let(:group) { FactoryGirl.create :group }
let(:resource_list) { FactoryGirl.create_list :group_membership, 3, group: group }
let(:action) { get :ind... |
#A class holding the Base62 characters
module Beheader
module Constants
URL_CHARACTERS = ('abcdefghijklmnopqrstuvwxyz' +
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
'0123456789')
.freeze
end
end |
# encoding: UTF-8
class Panel_map < Wx::Panel
attr_reader :window_map
#--------------------------------------------------------------------------------------------------------------------------------
# initialize
#---------------------------------------------------------------------------------------------------... |
require './spec/helper'
require 'yaml'
describe "Default configuration (no config file)" do
subject { Configuration.new }
it { is_expected.to include(:threshold => 100) }
it { is_expected.to include(:include => ['lib']) }
it { is_expected.to include(:single_line_report => true) }
it { is_expected.to run_thi... |
# Filter for front
module Italic
class WorkFilter
def self.build
new()
end
# Class Method
# ==============================================================================
class << self
def search(arg)
case arg... |
class C
def initialize(v)
@value = v
end
def getValue()
return @value
end
def setValue(v)
@value = v
end
end
c1 = C.new(10)
# p c1.value # 이렇게 하면 ruby는 value를 메서드로 인식하여 에러가 발생.
### value뒤에 괄호가 있는 것으로 판단하여 메서드 취급함.
### ruby에서는 인스턴스의 변수에 직접 접근하는 것이 허용되지 않음.
### 반면 python은 직접 접근이 허용됨.
### 그래서 g... |
class AddNegotiableToProperties < ActiveRecord::Migration[5.1]
def change
add_column :properties, :negotiable, :boolean
end
end
|
module Motor
class Motor
attr_reader :stall_current
attr_reader :stall_torque
attr_reader :free_speed
attr_reader :max_power
attr_reader :quantity
def initialize
@quantity = 1
end
def current(speed: nil, torque: nil)
unless speed.nil?
return @stall_current * (@fre... |
require_relative 'test_helper'
begin
require 'tilt/creole'
describe 'tilt/creole' do
it "is registered for '.creole' files" do
assert_equal Tilt::CreoleTemplate, Tilt['test.creole']
end
it "compiles and evaluates the template on #render" do
template = Tilt::CreoleTemplate.new { |t| "= Hel... |
class Filter::Genre < Filter
attr_accessor :genre
def initialize(params)
super
self.genre= @params[:genre]
end
def genre= genre
@genre = genre.present? ? ActsAsTaggableOn::Tag.find_by_name(genre).try(:name) : nil
end
def filter_movie_scope(movies)
@genre ? movies.tagged_with(genre) : movi... |
class LearningDaysController < ApplicationController
before_filter :require_teacher_or_admin
# GET /learning_days
# GET /learning_days.xml
def index
@school_class= SchoolClass.find(params[:school_class_id])
@learning_days = @school_class.learning_days.find(:all)
if params[:week].to_i >0
@week_... |
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user
before_filter :authenticate
private
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
def authenticate
unless current_user
flash[:notice] = "Please lo... |
# --- Day 4: Secure Container ---
# You arrive at the Venus fuel depot only to discover it's protected by a password. The Elves had written the password on a sticky note, but someone threw it out.
#
# However, they do remember a few key facts about the password:
#
# It is a six-digit number.
# The value is within the r... |
class AddUniqueConstraintOnLikes < ActiveRecord::Migration
def change
add_index :likes, [:resource_type, :resource_id, :user_id], unique: true, name: 'likes_resource_type_resource_id_user_id_unique_index'
end
end
|
class User < ActiveRecord::Base
has_secure_password
validates :username, presence: true, :uniqueness => true
validates :email, presence: true, :uniqueness => true
end
|
class Node
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::TagsArentHard
include AutoHtmlFor
has_and_belongs_to_many :nodes, class_name: "Node", inverse_of: :nodes, autosave: true
field :link
validates :link, presence: true
taggable_with :tags
auto_html_for :link do
html_escape
... |
module Inventory
class QueryAvailableMaterial
prepend SimpleCommand
def initialize(product_id, batches_ids, filter = {})
raise ArgumentError, 'product_id' if product_id.nil?
raise ArgumentError, 'batches_ids' if batches_ids.nil?
@product = Inventory::Product.find(product_id)
@plant_ta... |
class Task < ApplicationRecord
has_many :states
has_many :users, through: :states
end
|
class CreateResults < ActiveRecord::Migration
def change
create_table :results do |t|
t.integer :indoor_id
t.integer :indoorkadai_id
t.integer :user_id
t.integer :trial
t.string :type
t.text :review
t.timestamps null: false
end
end
end
|
# module for all operation in biobank
module BiobankOperationsModelExtension
module TubesOperations
# definition of operations
def aliquot_merging
#devo comportarmi come per la creazione delle piastre secche: la creazione dell'operazione
#è il primo passaggio, in cui colleziono tutto q... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.