text stringlengths 10 2.61M |
|---|
class Account
attr_reader :balance, :transactions, :transaction
MIN_BALANCE = 0
def initialize(statement = Statement.new)
@balance = MIN_BALANCE
@transactions = []
@transaction = Transaction
@statement = statement
end
def deposit(amount)
@balance += amount
transactions << transactio... |
require 'rails_helper'
RSpec.describe LookupCsv::LookupCsvGenerator do
let(:target_data) do
[
%w[Id Name CategoryName],
['1', 'Product 1', 'Category 10'],
['2', 'Product 2', 'Category 1'],
['3', 'Product 3', 'Category 3'],
['4', 'Product 4', 'Category 1'],
['5', 'Product 5', '... |
require 'spec_helper'
RSpec.describe DomainObjectArgumentError do
it do
expect { raise described_class.new('argument error') }
.to raise_error(described_class) do |error|
expect(error).to_not be_translatable
expect(error.message).to eq('argument error')
end
end
it do
expect {... |
class MenusController < UITableViewController
attr_accessor :delegate
MENUS_CELL_ID = "MenusCell"
def self.new(args = {})
s = self.alloc
s.delegate = args[:delegate]
s
end
def viewDidLoad
super
load_data
rmq.stylesheet = MenusControllerStylesheet
view.tap do |table|
tab... |
# encoding: utf-8
# copyright: 2016, you
# license: All rights reserved
# date: 2015-08-28
# description: All directives specified in this STIG must be specifically set (i.e. the server is not allowed to revert to programmed defaults for these directives). Included files should be reviewed if they are used. Procedure... |
require 'rails_helper'
RSpec.describe ConfirmationOfSuppliedDetails, type: :model do
let(:populated_confirmation_of_supplied_details) { described_class.new(email_receipt: 'test@example.com') }
context 'when correctly populated' do
it 'returns the correct email receipt' do
expect(populated_confirmation... |
module Photos
class Cli
class Utilities
def initialize
menu_options = [
[ :generate_thumbnails, 'Generate Thumbnails' ]
]
menu = View::Select.new('Which utility?', menu_options) { |o| o[1] }
case menu.selection[0]
when :generate_thumbnails
... |
class AddDefaultValueToSubFollowersCount < ActiveRecord::Migration
def change
change_column :sub_seddits, :followers_count, :integer, :default => 0,
:null => false
end
end
|
class LeadMailer < ApplicationMailer
default from: 'leads@therout.com'
def lead_email(name, model, email)
@name = name
@model = model
@email = email
mail(to: 'treygeorge+routleads@gmail.com', subject: 'therout lead')
end
end
|
require 'rails_helper'
RSpec.describe Meal, type: :model do
describe 'associations' do
it { should belong_to(:user) }
it { should have_many(:orders) }
it { should have_many(:meal_items).dependent(:destroy) }
end
describe 'validations' do
it { should validate_presence_of(:title) }
it { should... |
Vagrant.configure('2') do |config|
config.vm.provider 'docker' do |docker|
docker.image = 'fhirbase/fhirbase-build:0.0.9-alpha3'
docker.ports = ['5432:5432']
end
end
|
class Employee < ActiveRecord::Base
validates :name, presence:true
validates :function, presence:true
mount_uploader :photo, GalleryUploader
extend FriendlyId
friendly_id :name, use: [:slugged, :history]
end
|
require 'mechanize'
AGENT ||= Mechanize.new
class HttpScraper
# Specifically for Google search results
def self.scrape_titles(text)
text.css("#ires > ol > div > h3 > a").map(&:content)
end
def self.scrape_links(text)
text.css("#ires > ol > div > h3 > a").map do |node|
link = node.attributes[... |
class Tag < ActiveRecord::Base
attr_accessible :name
belongs_to :city
validates :name, :presence => true
end
|
class FontAoboshiOne < Formula
head "https://github.com/google/fonts/raw/main/ofl/aoboshione/AoboshiOne-Regular.ttf", verified: "github.com/google/fonts/"
desc "Aoboshi One"
homepage "https://fonts.google.com/specimen/Aoboshi+One"
def install
(share/"fonts").install "AoboshiOne-Regular.ttf"
end
test do
... |
# frozen_string_literal: true
# == Schema Information
#
# Table name: invitations
#
# id :integer not null, primary key
# email :string not null
# account_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# token :string not... |
describe "image requests" do
os_id = compute.operating_systems.first.id
let(:image_format) do
{
"id" => String,
"name" => String,
"customer" => Fog::Nullable::String,
"os_settings" => Hash,
"modified_by" => Fog::Nullable::Strin... |
require 'belafonte/dsl/definition'
module Belafonte
# A DSL for making apps
module DSL
def self.included(klass)
klass.extend(Belafonte::DSL::Definition)
end
end
end
|
class Attempt < ApplicationRecord
belongs_to :game
has_many :answers, dependent: :destroy
validates :game_id, :presence => true
validates :username, :presence => true, :uniqueness => {:case_sensitive => false}
end
|
class String
primitive 'hash' , 'hash' # So class Hash will operate
MAGLEV_EXTRACT_BASE_TABLE = {"0b" => 2, "0d" => 10, "0o" => 8, "0x" => 16, "0" => 8 ,
"0B" => 2, "0D" => 10, "0O" => 8, "0X" => 16
}
MAGLEV_EXTRACT_BASE_TABLE.freeze
end
String.__... |
require 'spec_helper'
describe Stormpath::Resource::PasswordPolicy, :vcr do
describe "instances should respond to attribute property methods" do
let(:application) { test_application }
let(:directory) { test_api_client.directories.create(name: random_directory_name) }
let(:password_policy) { directory.pas... |
class Gps < ActiveRecord::Base
has_many :rides
validates :battery, numericality: true
def self.create_from_model(hash)
error_messages = self.create(:battery => hash[:battery].nil? ? 0.0 : hash[:battery]).errors.messages #creates a ride or gets the error messsages
if error_messages.to_a.length != 0 #If... |
module Fauve::Rails
# Tie Fauve options to Rails.
class Railtie < ::Rails::Railtie
config.fauve = ActiveSupport::OrderedOptions.new
initializer :fauve_setup do |app|
config.fauve.config_file = File.join(Rails.root, 'config/fauve.yml') unless config.fauve.config_file
Fauve::Scheme::ColourMap.i... |
# find images in source folder
require 'FileUtils'
def isImage?(path)
ext = File.extname(path).downcase
ext == ".jpg" || ext == ".png" || ext == ".bmp" || ext == ".gif"
end
def isMovie?(path)
ext = File.extname(path).downcase
ext == ".mp4" || ext == ".wmv"
end
class ImageFinder
attr_reader :root
def init... |
require 'rails_helper'
RSpec.describe SectionHelper do
describe '#sec(key, default: "some default string")' do
it 'returns a string related to the passed in key' do
key = keygen
text = "default text for #{key}"
test_section = FactoryGirl.create(:section, key: key, content: text)
expect(... |
class Page < ActiveRecord::Base
belongs_to :story
has_attached_file :image, styles: Artwork::STYLES
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/
end
|
##
# Send a breaking news alert
#
module Job
class SendBreakingNewsEmail < Base
@queue = "#{namespace}:breaking_news_email"
class << self
def perform(id)
@alert = BreakingNewsAlert.find(id)
@alert.publish_email
end
end
end
end
|
class CreateCars < ActiveRecord::Migration[5.2]
def change
create_table :cars do |t|
t.string :zipcode
t.integer :price
t.integer :milage
t.string :body_style
t.string :interior_color
t.string :exterior_color
t.belongs_to :model, foreign_key: true
t.timestamps
... |
require 'rails_helper'
describe User do
describe '#create' do
context 'can save' do
it "必須項目が存在すれば登録できること" do
user = build(:user)
expect(user).to be_valid
end
it "パスワード(password) 7文字以上かつ128文字以下で半角英数字両方を含んでいれば登録できること" do
user = build(:user, password: "abcd12... |
#!/usr/bin/ruby
=begin
Michael Trotter
mjt5v
rosetta.rb
Programming Languages
=end
#Edge class
class Edge
attr_reader :start, :end;
attr_accessor :visited;
#constructor
def initialize(task, prereq)
@start = task;
@end = prereq;
@visited = false;
end
#define to string
def to_s
retur... |
class RemoveDefaultFromSinglesUpdatedAt < ActiveRecord::Migration
def up
change_column_default :singles, :updated_at, nil
end
def down
change_column_default :singles, :updated_at, DateTime.new(2010, 1, 1)
end
end
|
ActiveAdmin::Dashboards.build do
# Define your dashboard sections here. Each block will be
# rendered on the dashboard in the context of the view. So just
# return the content which you would like to display.
# == Simple Dashboard Section
# Here is an example of a simple dashboard section
#
# section ... |
# 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... |
# encoding: UTF-8
class YTAnalytics
module Parser #:nodoc:
class FeedParser #:nodoc:
def initialize(content)
@content = (content =~ URI::regexp(%w(http https)) ? open(content).read : content)
rescue OpenURI::HTTPError => e
raise OpenURI::HTTPError.new(e.io.status[0],e)
rescue
... |
class AddValueAndWaranteeToCustomers < ActiveRecord::Migration
def change
add_column :customers, :value, :string
add_column :customers, :warantee, :integer
end
end
|
class TopsController < ApplicationController
before_action :authenticate_user?, except: :about
before_action :set_top, only: [:show, :edit, :update, :destroy]
# GET /tops
# GET /tops.json
def index
if current_user.amount.nil?
redirect_to users_p20_path(current_user.id)
else
redirect_to us... |
require "rails_helper"
RSpec.describe Question, :type => :model do
it "Creo domanda per una proprietà" do
user = User.create(:email => "giacominoalberobello@omega.it", :password => "password", :password_confirmation => "password", :username => "giacominoalberobello")
property = Property.create(:title => "Ec... |
require 'spec_helper'
class Test1
def sleep_sec
sleep 0.1
end
def sleep_three_secs
3.times { sleep_sec }
end
end
class Test2
def raise_error
raise ArgumentError, 'Hey, I am an argument error'
end
def sleep_fifth_sec
sleep 0.02
end
def sleep_sec
5.times { sleep_fifth_sec }
en... |
FactoryGirl.define do
factory :photo do
album nil
user nil
image "MyString"
original_filename "MyString"
content_type "MyString"
file_size 1
active false
position 1
caption "MyString"
tags "MyString"
end
end
|
module BonuslyDashboard
class DashboardController < ApplicationController
skip_after_filter :intercom_rails_auto_include
after_filter :allow_iframe, only: :index
def index
override_x_frame_options('ALLOW-FROM *')
render layout: false
end
def version
response = {status: :ok, mes... |
module Auth
class UsersController < BaseController
before_action :set_user, only: [:show]
def index
@users = User.page(params[:page])
end
def show
end
private
def set_user
@user = User.find(params[:id])
end
end
end
|
#!/usr/bin/env ruby
require './run_loop'
require './globals'
require 'delegate'
def usage
puts "Usage: #{$0} <filename>"
exit 1
end
filename = ARGV.first
usage unless filename && !filename.empty?
RunLoop.new.tap do |l|
DelegateClass(Globals).new(Globals.new(l)).instance_eval(File.read(filename))
end.start
|
class RenameCommentUserid < ActiveRecord::Migration
def change
rename_column :comments, :userid, :user_id
end
end
|
# frozen_string_literal: true
FactoryBot.define do
factory :registration_option do
association :registration
association :event_option
end
end
|
class Api::UsersController < ApplicationController
def index
@users = User.all
render json: @users
end
def show
@user = User.find(params[:id])
render json: @user
@posts = User.find(params[:id]).posts
end
def create
@user = User.create(user_params)
render json: @user
end
d... |
class EveningForecastMock
def self.forecast
{:latitude=>39.7392358,
:longitude=>-104.990251,
:timezone=>"America/Denver",
:currently=>
{:time=>1579150800,
:summary=>"Clear",
:icon=>"clear-night",
:precipIntensity=>0.001,
:precipProbability=>0.01,
:precipType=>"snow",
:precipAccumulation=>0.... |
# -*- coding: utf-8 -*-
=begin
''Nome ao contrário em maiúsculas.''' Faça um programa que permita ao usuário
digitar o seu nome e em seguida mostre o nome do usuário de trás para frente
utilizando somente letras maiúsculas. Dica: lembre−se que ao informar o nome o
usuário pode digitar letras maiúsculas ou minúsculas.
... |
module ProposalConfig
extend ActiveSupport::Concern
included do
has_many :steps
has_many :approval_steps, class_name: "Steps::Approval"
has_many :purchase_steps, class_name: "Steps::Purchase"
has_many :completers, through: :steps, source: :completer
has_many :api_tokens, through: :steps
ha... |
# coding: utf-8
require 'spec_helper'
describe ContactsController do
# モックの生成
let(:admin) { build_stubbed(:admin) }
let(:user) { build_stubbed(:user) }
let(:contact) { build_stubbed(:contact, firstname: 'Lawrence', lastname: 'Smith') }
let(:phones) {
[
attributes_for(:contact, phone_type: 'home'),... |
# -*- encoding: utf-8 -*-
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require "allure-ruby-adaptor-api/version"
Gem::Specification.new do |s|
s.name = 'allure-ruby-adaptor-api'
s.version = AllureRubyAdaptorApi::Version::STRING
s.platform = Gem::Platform::RUBY
s.authors ... |
module Byebug
#
# Reopens the +info+ command to define the +line+ subcommand
#
class InfoCommand < Command
#
# Information about current location
#
class LineSubcommand < Command
def regexp
/^\s* l(?:ine)? \s*$/x
end
def execute
puts "Line #{@state.line} of \"#... |
class SuppliersController < ApplicationController
load_and_authorize_resource
def index
@suppliers = Supplier.find(:all)
end
def create
if @supplier.save
flash[:notice] = "Supplier successfully created."
redirect_to suppliers_path
else
render :action => 'new'
end
end
def... |
require "sinatra"
require "sinatra/reloader" if development?
require "tilt/erubis"
require "sinatra/content_for"
configure do
enable :sessions
set :session_secret, 'secret'
set :erb, :escape_html => true
end
helpers do
def list_complete?(list)
todos_count(list) > 0 && todos_remaining_count(list) == 0
en... |
module TicTacToe
require "set"
class Game
WIN_COMBOS = [[1,2,3],[4,5,6],[7,8,9],[1,4,7],[2,5,8],[3,6,9],[1,5,9],[3,5,7]]
def initialize
@board = Array.new(10)
player_setup
@current_player_id = 0
end
def player_setup
print "Player 1: "
player1 = Player.n... |
require "propay/command/base"
module ProPay
module Command
class CreatePaymentMethod < Base
def initialize(params = {})
super
pmt = @params[:payment_method_type]
@request = Nokogiri::XML::Builder.new do |xml|
xml["soapenv"].Envelope("xmlns:soapenv" => "http://schemas.xml... |
def alphabetic_number_sort input
sorted_array = [8, 18, 11, 15, 5, 4, 14, 9, 19, 1, 7, 17, 6, 16, 10, 13, 3, 12, 2, 0]
sorted_return = []
while !input.empty?
sorted_array.each do | value |
if input.include?(value)
sorted_return << input.delete(value)
break
end
end
end
ret... |
class CartsController < ApplicationController
before_action :logged_in_user, only: [:show]
def show
@cart = Cart.find(params[:id])
end
def new
@items = []
if cart_ss[:items].count >0
cart_ss[:items].each do |item|
@items << {product: Product.find(item[:product_id]),quantity: item[:quantity]}
end
... |
class Post < ActiveRecord::Base
include PgSearch
include Likeable
include Taggable
multisearchable :against => :tags_string
# pg_search_scope :search_by_tags, :against => :tags_string
pg_search_scope :search_by_tags, :associated_against => {
:taggings => :name
}
belongs_to :blog, counter_cache: true
h... |
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :authenticate_user!
rescue_from CanCan::AccessDenied do |exception|
redirect_to root_url, alert: exception.message
end
protected
def configure_permitted_parameters
... |
#! /usr/bin/ruby
#
# filtFlag.rb
#
# Copyright (c) 2016 - Ryo Kanno
#
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php
#
require_relative "SAMReader.rb"
require "optparse"
Version="1.0.5"
banner = "Usage: filtFlag.rb [option] <flag array> <input SAM file>\n+Filter re... |
name 'zprezto-user'
maintainer 'Primoz Verdnik'
maintainer_email 'primoz.verdnik@gmail.com'
license 'MIT'
description 'Provides a simple definition for installing zprezto (zsh) for a given user'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.... |
class PackingList < ApplicationRecord
acts_as_paranoid
belongs_to :deal
has_one :address, as: :belongable, class_name: "Address", dependent: :destroy
accepts_nested_attributes_for :address, allow_destroy: true
has_many :pics, as: :belongable, class_name: "Pic", dependent: :destroy
accepts_nested_attributes_... |
class CentroResponseBuilder
def self.create_from(centro)
{
'centro': {
'id': centro.id,
'nombre': centro.nombre,
'latitud': centro.latitud,
'longitud': centro.longitud
}
}.to_json
end
def self.create_from_all(centros)
output = { 'centros': [] }
centros... |
class Meal < ActiveRecord::Base
validates :name, presence: true
validates :price, presence: true, numericality: true
validate :positive_price
belongs_to :restaurant
def positive_price
errors.add(:price,' must be equal or greater than zero!') unless price && price >= 0
end
end
|
require 'rails_helper'
require 'shoulda-matchers'
RSpec.describe Omelette, type: :model do
it { should validate_presence_of(:title) }
it { should validate_presence_of(:description) }
it { should validate_presence_of(:ingredients) }
it { should belong_to(:reg_user) }
it { should have_many(:reviews) }
end
|
class ChangeNeighborhoodInUser < ActiveRecord::Migration[5.2]
def change
rename_column :users, :neighborhood, :neighborhood_id
end
end
|
class Classifieds::RentsController < ApplicationController
# GET /classifieds/rents
# GET /classifieds/rents.json
def index
@classifieds_rents = Classifieds::Rent.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @classifieds_rents }
end
end
# GET /cl... |
namespace :init do
desc "create and seed a new ghc project"
task :proj, [:name] do |t,arg|
raise "new project name required, e.g.: rake init:proj[tim]" if arg.name.nil?
NEW_PROJ_DIR = File.expand_path("#{PROJ_HOME}/../#{arg.name}")
sh "rake dev:rsync_proj[#{arg.name},true]"
Dir.c... |
class CreateMensajesEspecialesPropiedadesJoin < ActiveRecord::Migration
def change
create_table :mensajes_propiedades, :id => false do |t|
t.integer "mensaje_id"
t.integer "propiedad_id"
end
add_index :mensajes_propiedades, ["mensaje_id" , "propiedad_id"]
end
end
|
module Shoperb module Theme module Editor
module Mounter
module Model
class ProductSearch
include Pagy::Backend
attr_reader :word, :options
def initialize(word:, **options)
@word = word
@options = options
end
def paginate(page: 1, per: 12)
... |
require 'rails_helper'
RSpec.describe IdentityCounter, type: :model do
it { is_expected.to belong_to(:identity) }
describe "#update_counter" do
it 'should increment counter' do
identity = create(:identity)
identity_counter = create(:identity_counter, identity: identity, tasks_count: 0)
Id... |
class CreatePatient < ActiveRecord::Migration[6.0]
def change
create_table :patients do |t|
t.string :first_name
t.string :middle_name
t.string :last_name
t.string :mr
t.datetime :dob
t.references :admission
t.integer :gender, default: 0
end
end
def down
drop... |
class Comment < ActiveRecord::Base
belongs_to :spot
validates_presence_of :title, :commenter, :body, :on => :create, :message => "can't be blank"
validates_numericality_of :rating, :on => :create, :message => "is not a number"
validate :rating_between_1_and_5
protected
def rating_between_1_and_5
e... |
class CreateAddIndexForPolls < ActiveRecord::Migration[5.0]
def change
add_index :polls, [:title, :author_id]
end
end
|
class WordGame
attr_reader :game_over, :blank_word
def initialize(play_word)
@play_word = play_word
@guess_count = play_word.length + 3
@past_guess = []
@game_over = false
@blank_word = word_hider
end
def play_mode(guess)
game_play(guess)
win_lose
end
private
def gues... |
require 'test_helper'
class IssuesControllerTest < ActionDispatch::IntegrationTest
setup do
@issue = issues(:one)
end
test "should get index" do
get issues_url
assert_response :success
end
test "should get new" do
get new_issue_url
assert_response :success
end
test "should create i... |
FactoryBot.define do
factory :grouping do
association :group
association :assignment
end
factory :grouping_with_inviter, class: Grouping do
association :group
association :assignment
inviter { FactoryBot.create(:student) }
end
factory :grouping_with_inviter_and_submission, parent: :group... |
# kitchen-docker-host::default
package 'postfix' do
action :remove
end
include_recipe 'sysctl::default'
include_recipe 'yum-epel::default'
package %w[htop squid bc]
docker_service 'default' do
host %w[tcp://0.0.0.0:2375]
bip '172.17.42.1/16'
storage_driver 'devicemapper'
action %i[create start]
end
cookb... |
# Crée une relation avec articles
class Category < ApplicationRecord
has_many :articles
end
|
#==============================================================================#
# ** IEX(Icy Engine Xelion) - Advance Item Check
#------------------------------------------------------------------------------#
# ** Created by : IceDragon (http://www.rpgmakervx.net/)
# ** Script-Status : Addon (Interpreter)
# ** Scr... |
class Libstdcxx < BasePackage
desc "GNU Standard C++ Library"
name 'libstdc++'
# todo:
#homepage ""
#url ""
release version: '4.9', crystax_version: 3
release version: '5', crystax_version: 3
release version: '6', crystax_version: 3
build_depends_on 'platforms'
build_depends_on 'libcrystax'
... |
require File.dirname(__FILE__) + '/../../../spec_helper'
describe 'Storage.get_object' do
describe 'success' do
before(:each) do
Google[:storage].put_bucket('foggetobject')
Google[:storage].put_object('foggetobject', 'fog_get_object', lorem_file,{'x-goog-acl' => 'public-read'})
end
after(:e... |
require "rails_helper"
RSpec.describe ConfigurationsController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/configurations").to route_to("configurations#index")
end
it "routes to #new" do
expect(:get => "/configurations/new").to route_to("configurations... |
class AddViewTokenToOrders < ActiveRecord::Migration
def change
add_column :orders, :view_token, :string
end
end
|
require_relative 'answer'
# This class keeps track of answers
class AnswerController
# Starts woth an empty array
def initialize
@answers = []
end
# Adds some answers to the array
# This is a seperate method so if we don't want
# default answers we don't have to have them
def ... |
module Api
module Controllers
module Sessions
class New
include Api::Action
def call(_params)
user = UserRepository.new.authenticate(auth_hash)
warden.set_user user
status 200, user.to_h.to_json
end
private
def auth_hash
requ... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string not null
# password_digest :string not null
# session_token :string not null
# created_at :datetime ... |
class TestError < StandardError; end
module Kernel
def test_suite &blk
@@r = get_config
@@t = blk
@@result = true
end
def bln_color val
(val) ? "[\e[33m#{val}\e[m]" : "[\e[36m#{val}\e[m]"
end
def should_be val
ret = @@r[self] == val
puts "[TEST CASE] #{bln_color ret} #{self} (#{@@r[sel... |
class Project < ActiveRecord::Base
has_many :categories
has_many :images, through: :categories
end
|
FactoryBot.define do
factory :material do
event
user
topic
name { Faker::Lorem.words(number: 5).join }
url { Faker::Internet.url }
end
end
|
class Person < ApplicationRecord
has_many :works, dependent: :destroy
has_many :proyects, through: :works
end
|
class Genre < ApplicationRecord
has_many :trainings, dependent: :destroy
enum class_status:{有効: 0, 無効: 1}
validates :genre_name,presence: true
end
|
RACK_ENV = 'test' unless defined?(RACK_ENV)
require File.expand_path(File.dirname(__FILE__) + '/../../config/boot')
Dir[File.expand_path(File.dirname(__FILE__) + '/../../app/helpers/**/*.rb')].each(&method(:require))
# necessary to load, among others methods, the controller ones, such as 'get', 'post', 'delete', etc
R... |
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.2'
# API
gem 'pg'
gem 'jbuilder', '~> 1.2'
gem 'gon'
gem 'haml-rails'
gem 'omniauth-github'
gem 'compass-rails'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem 'bootstrap-sass', '~> 3.1.1.0'
group :test, :development do
... |
class SendTweetJob < ApplicationJob
queue_as :default
def perform(proposal)
return unless proposal.visible? && ENV["TWITTER_ACCESS_TOKEN"].present?
client = build_client
body = build_message_body_for(proposal)
if body.length < 200 && Rails.env.production?
client.update(body)
else
... |
module XPash
class CmdOptionParser < OptionParser
attr_accessor :min_args, :default_opts
def initialize(banner = nil, width = 16, indent = ' ' * 4)
@min_args = 0
@default_opts = {}
super(banner, width, indent) {|o|
o.on_tail("-h", "--help", "Show this help message.") {
put... |
Pod::Spec.new do |ddyspec|
ddyspec.name = 'DDYQRCode'
ddyspec.version = '1.1.1'
ddyspec.summary = '二维码/条形码生成'
ddyspec.homepage = 'https://github.com/RainOpen/DDYQRCode'
ddyspec.license = 'MIT'
ddyspec.authors = {'Rain' => '634778311@qq.com'}
ddyspec.platform ... |
class Search
attr_reader :term
def initialize options = {}
@term = options.fetch(:term, "").downcase
end
def images
# Image.where("keywords @> ?", "{#{@term}}")
ActiveRecord::Base.connection.execute("SELECT * FROM images WHERE '#{@term}'=ANY(keywords)")
end
end
|
#!/usr/bin/env ruby
require 'yajl'
require 'ruby-graphviz'
def main
graph = GraphViz.new(:dependency_graph, {
:type => :digraph
})
graph[:ranksep] = 4
graph.node[:shape] = "rectangle"
graph.edge[:arrowsize] = 2
Dir.entries(src_dir).each do |dir|
path = "#{src_dir}/#{dir}"
next if [".", ".."]... |
require 'inject'
describe Array do
it { is_expected.to respond_to :kinject}
describe 'kinject' do
let subject {[1,2,3,4]}
expect(subject.kinject('+')).to eq(10)
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.