text
stringlengths
10
2.61M
# frozen_string_literal: true RSpec.describe 'Videos' do resource 'Videos' do let!(:video1) { create(:video) } let!(:video2) { create(:video) } let!(:video3) { create(:video, :with_category) } let!(:video4) { create(:video, :deleted) } # NOTE: Deleted records are not returned by default let!(:coa...
require 'maws/command' class SetPrefix < Command def description "set-prefix - sets prefix for specified EC2 instances" end def add_specific_options(parser) parser.opt :prefix_to_set, "Prefix to set", :short => "-P", :type => :string, :default => "" end def verify_options super prefix = @co...
# frozen_string_literal: true require 'bolt/cli' require 'bolt_spec/puppetdb' module BoltSpec module Integration include BoltSpec::PuppetDB def run_cli(arguments, rescue_exec: false, outputter: Bolt::Outputter::JSON) cli = Bolt::CLI.new(arguments) # prevent tests from reading users config ...
class PolyTreeNode require "byebug" attr_reader :parent, :value, :children def initialize(value) @parent = nil @value = value @children = [] end def parent=(node) # debugger if !@parent.nil? #parent exist # debugger @p...
class Build < ActiveRecord::Base belongs_to :commit belongs_to :user belongs_to :assignment belongs_to :course end
class EventsController < ApplicationController before_action :set_event, only: [:show, :update] def index @events = Event.includes(:group_event).where(deleted: false) render json: @events end def show if @event.deleted render json: nil, status: :not_found else render json: @event ...
class UsersController < ApplicationController rescue_from ActiveRecord::RecordNotFound do |exception| render :json => { :success => false }, :status => :not_found end # GET /users # GET /users.ext_json def index @users =User.all respond_to do |format| format.html # index.html.erb (no d...
=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 require "uri" module SwaggerClient class ObjectlinkApi attr_accessor :api_client def initialize(api_cli...
class Gallery < ActiveRecord::Base belongs_to :development has_many :pictures, :dependent => :destroy accepts_nested_attributes_for :pictures, allow_destroy: true end
require "fileutils" # extensions to copy types = %w(jpg jpeg png tiff bmp gif) types = (types + types.map(&:upcase)).join(",") # clear any files from running before renamed = Dir["renamed/**/*"] FileUtils.remove renamed # generate a new shuffled order for the files and rename files = Dir["original/**/*.{#{types}}"]....
require 'rails_helper' # TODO: requires more validation! RSpec.feature 'Creating user profile' do before do user = create(:user) sign_in_with user visit 'user_profile/1/edit' end context 'Valid user' do scenario 'can update to a valid user profile' do fill_in 'First name', with: 'testName'...
Rails.application.routes.draw do root 'buildings#index' devise_for :users, :controllers => { :registrations => 'users/registrations', :sessions => 'users/sessions', :invitations => 'users/invitations' } devise_scope :user do get "sign_in", :to => "users/sessions#new" get "sign_out", :to ...
Pod::Spec.new do |s| s.platform = :ios s.ios.deployment_target = '8.0' s.name = "AWIrmFramework" s.summary = "This framework does all IRM operations" s.requires_arc = true s.dependency 'ADAL', '~> 2.2.2' s.dependency 'CompoundFileReader' s.version = "0.0.49" s.license = { :type => "MIT", :file => "LICENSE" } ...
require "spec_helper" RSpec.describe Abaci::Metric do describe ".all" do it "returns all stats metrics" do Abaci[:testing].incr Abaci[:tests].incr Abaci[:other].incr expect(Abaci::Metric.all).to be_kind_of(Array) expect(Abaci::Metric.all).to include("testing") expect(Abaci::...
class Team < ActiveRecord::Base has_many :users, dependent: :destroy has_many :projects, dependent: :destroy validates :name, {presence: true, uniqueness: true} end
require 'test_helper' class ExcludeUrlsControllerTest < ActionDispatch::IntegrationTest setup do @exclude_url = exclude_urls(:one) end test "should get index" do get exclude_urls_url assert_response :success end test "should get new" do get new_exclude_url_url assert_response :success ...
module Activerecord module Mergetags class Merge def self.merge(string, obj) string.gsub(/\*\|([\w\.]+)\|\*/){|t| replace(t[2..-3], obj)} end private def self.replace(tag, obj) if tag.include? '.' portions = tag.split('.', 2) replace(portions[1], obj.se...
require 'action_dispatch' require 'rails_4_session_flash_backport/rails3/flash_hash' describe ActionDispatch::Flash::FlashHash, "hax" do let(:rails_2_marshaled) { "\x04\bIC:'ActionController::Flash::FlashHash{\a:\vnoticeI\"\x11I'm a notice\x06:\x06ET:\nerrorI\"\x11I'm an error\x06;\aT\x06:\n@used{\a;\x06T;\bF" } ...
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "rb-fsevent/version" Gem::Specification.new do |s| s.name = "rb-fsevent" s.version = FSEvent::VERSION s.platform = Gem::Platform::RUBY s.authors = ['Thibaud Guillaume-Gentil', 'Travis Tilley'] s.email = ['t...
class AddReportIndexOnTransports < ActiveRecord::Migration def self.up add_index :transports, [:receiver_id, :receiver_type], :name => 'index_on_receiver' add_index :transports, [:route_id] end def self.down remove_index :transports, [:receiver_id, :receiver_type], :name => 'index_on_receiver' re...
class AddMasterFeeParticularIdToInstantFeeDetail < ActiveRecord::Migration def self.up add_column :instant_fee_details, :master_fee_particular_id, :integer add_index :instant_fee_details, :master_fee_particular_id, :name => "index_by_mfp_id" end def self.down remove_index :instant_fee_details, :maste...
class Person attr_reader(:name, :happiness, :hygiene) attr_accessor(:bank_account) attr_writer(:happiness) def initialize(name) @name = name @bank_account = 25 @happiness = 8 @hygiene = 8 end def happiness=(user_num) if user_num > 10 @happiness = 10 elsif user_num < 0 @happiness = 0 else ...
require 'modules/core/helpers/layout_helper' require 'modules/core/helpers/registry_helper' require 'modules/core/helpers/routes_helper' require 'modules/core/helpers/exposures_helper' require 'action_view' module Core module Cells class Base < Cell::ViewModel include Glia::Cell include ActionView::H...
class RecoupmentObserver < ActiveRecord::Observer def after_save rec RecoupmentMailer.recoupment_changed(rec).deliver_now end end
require 'test_helper' class OrganizationTest < ActiveSupport::TestCase # test "the truth" do # assert true # end test "can create valid organization" do organization = Organization.new(name: "ORG", owner: "Terri") assert organization.save assert organization...
class UsersController < ApplicationController def login @user = User.find_by(email: params["user"][:email]) if @user && @user.password == params["user"][:password_hash] signin(@user) redirect_to @user else redirect_to '/' end end def create @user = User.new(user_params) ...
require 'rubygems' require 'role_model' class User < ActiveRecord::Base has_many :outcoming_tasks, class_name: "Task", foreign_key: "author_id" has_many :incoming_tasks, class_name: "Task", foreign_key: "user_id" before_create :accept_roles # Include default devise modules. Others available are: # :confirm...
class Api::V1::ParsController < ApplicationController before_action :Authenticate_user before_action :Classify_user def create par= Par.new(pars_params) par.client_id = 0 unless par.client_id par.status='pending' par.employer_id = @classified_user.employer_id par.requester = @current_user.u...
require 'test/unit' require_relative '../models/word_generator' class WordGeneratorTest < Test::Unit::TestCase def test_remove_forbidden_constant_clusters word = 'crharhbrh' word_gen = WordGenerator.new(['c', 'b', 'rh'], ['a'], [], [], []) cleaned_word = word_gen.remove_forbidden_constant_clusters(word)...
require 'json' require 'em-mongo' require 'sinatra/async' require 'mongodb' class AsyncTweaming < Sinatra::Base register Sinatra::Async attr_accessor :events_collection def initialize db = Tweaming::DB.connect @events_collection = db.collection('events') super end aget '/client' do body {...
module ApplicationHelper def form_errors_for(object=nil) render 'shared/form_errors', object: object unless object.blank? end def self.get_edit_request_for(current_user_id, app_id) return nil if current_user_id.nil? || app_id.nil? return nil unless App.belongs_to_user(app_id, current_user_id) App...
require 'test_helper' class ThemifyIconsRailsTest < ActionDispatch::IntegrationTest test "engine is loaded" do assert_equal ::Rails::Engine, ThemifyIcons::Rails::Engine.superclass end %w(eot ttf woff svg).each do |ext| test "themify.#{ext} is served" do get "/assets/themify.#{ext}" assert_r...
# frozen_string_literal: true module SauceBindings VERSION = '1.0.0' end
require 'json' require 'salt' module Salt class Master < Minion def initialize(name, info) self['master_config'] = {} self['minions'] = {} self['syndics'] = {} super end def registerMinion(minion) self['minions'][minion.name] = minion minion['master'...
class FontOpticianSans < Formula head "https://github.com/anewtypeofinterference/Optician-Sans/raw/master/OpenType-PS/Optician-Sans.otf", verified: "github.com/anewtypeofinterference/Optician-Sans/" desc "Optician Sans" homepage "https://optician-sans.com/" def install (share/"fonts").install "Optician-Sans...
class CreateRawMotionData < ActiveRecord::Migration def change create_table :raw_motion_data do |t| t.float :pitch t.float :quaternion_w t.float :quaternion_x t.float :quaternion_y t.float :quaternion_z t.float :roll t.float :rotation_rate_x t.float :rotation_rate_y...
# encoding: utf-8 class ReportGenerators::GooglePlusReport < ReportGenerators::Base def self.can_process? type type == GooglePlusDatum end def add_to(document) if !google_datum.empty? add_information_to document end end private def google_datum social_network.google_plus_data.where...
# frozen_string_literal: true class SigninUser < ApplicationService attr_reader :user def initialize(user) @user = user end def call token = AuthToken::Encoder.call({ user_id: user.id }) user.update(token: token) token end end
require 'fluent/plugin/output' module Fluent::Plugin class ForkOutput < Output class MaxForkSizeError < StandardError; end Fluent::Plugin.register_output('fork', self) helpers :event_emitter def initialize super end config_param :output_tag, :string config_param :output_key, ...
ENV["RAILS_ENV"] ||= "test" require File.expand_path("../dummy/config/environment.rb", __FILE__) require File.expand_path("../../lib/waste_exemptions_shared", __FILE__) require "spec_helper" require "rspec/rails" require "factory_bot_rails" require "capybara/rails" require "capybara/rspec" require "shoulda-matchers"...
class PaymentsPreview < ActionMailer::Preview # Accessible from http://localhost:3000/rails/mailers/notifier/welcome def pending_payment PaymentsMailer.with(client: Client.first, project: Project.first, payment: Payment.first).pending_payment end end
source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.0.0', '>= 5.0.0.1' # Use Puma as the app server gem 'puma', '~> 3.0' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # U...
require 'rails_helper' describe "post a park route", :type => :request do before do post '/parks', params: { :name => 'Yellowstone', :location => 'Wyoming', :description => 'National park in Wyoming', :park_type => 'National P...
module SolidusMultipleRecipients module EstimatorConcerns extend ActiveSupport::Concern included do prepend(InstanceMethods) end module InstanceMethods def shipping_methods(package) package.shipping_methods .available_for_address(package.shipment.address) .inc...
# Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :shop_request do shop_owner_profile { create(:shop_owner).profile } salesperson_profile_id nil location { create(:location) } shop nil request "MyText" shop_name "Some shop" end end
projects = @projects json.array! projects.each do |project| json.extract! project, :id, :name json.users project.users.each do |user| json.extract! user, :id, :name end json.todos project.todos.each do |todo| json.extract! todo, :id, :name, :status, :project_id json.user_name todo.users_todo.user...
class CategoriesController < ApplicationController def show p params @products = Category.find(params[:id]).products render :show, handlers: [:json, :rabl] end end
class CreateVers < ActiveRecord::Migration def self.up create_table :vers do |t| t.string :assesseeVerName t.string :fatherName t.string :place t.date :date t.string :identificationNoOfTRP t.string :nameOfTRP t.decimal :reImbFrmGov, :precision =>16 , :scale =>2 t.in...
require "banks_api/ynab/bulk_transactions_converter" module BanksApi module Ynab class Sync def self.run(*args) new(*args).run end def initialize(ynab_budget_id:, ynab_account_id:, bank_name:, credentials:, bank_account_id:, date_from:, date_to:) @ynab_budget_id = ynab_budget_i...
# # Write a method that will take a string as input, and return a new # # string with the same letters in reverse order. # # # # Don't use String's reverse method; that would be too simple. # # # # Difficulty: easy. # # def reverse(string) # # i=0 # length = string.length # reverse_word = "" # # while (i < leng...
require_relative 'monster.rb' require_relative 'character.rb' require_relative 'util/monster_type_randomizer.rb' require_relative 'weapon_templates/axe_template.rb' require_relative 'weapon_templates/knife_template.rb' require_relative 'weapon_templates/sword_template.rb' require_relative 'effects/critical_strike.rb' r...
# frozen_string_literal: true require 'json' require 'open-uri' module Capwatch module Providers class CoinMarketCap attr_accessor :body attr_reader :config NoCoinInProvider = Class.new(RuntimeError) TICKER_URL = 'https://api.coinmarketcap.com/v1/ticker/' PAGE_LIMIT = 100 F...
# # Platform specific settings # case node['platform'] # when 'redhat','centos' # package_name 'httpd' # when 'ubuntu','debian' # package_name 'apache2' # end # package package_name do # action :install # end # service 'httpd' do # action [:enable, :start] # end package "Install Apache" do pac...
# Default recipe for the chef cookbook # A file with a simple amount of content file '/etc/hello' do action :create content 'Hello world' end # A file with variable content #file '/etc/hello' do # action :create # content node['demo']['greeting'] #end # A long file #cookbook_file '/etc/hello' do # action :cre...
class User < ActiveRecord::Base ROLES = %w(admin user) # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable validates :role, presence: ...
# # Authors: Christopher M Wood (<woodc@us.ibm.com>) # John F Hutchinson (<jfhutchi@us.ibm.com) # © Copyright IBM Corporation 2015. # # LICENSE: MIT (http://opensource.org/licenses/MIT) # require_relative 'lpar' require_relative 'lun' class Vio < Lpar attr_reader :available_disks, :used_disks def initia...
class CardDatum < ApplicationRecord belongs_to :kind_name, :foreign_key => :kind, :primary_key => :proper_id, :class_name => 'ProperName' end
class Router def initialize(controller) @controller = controller end def run loop do gets_choice choice = gets.chomp.to_i dispatch_choice(choice) end end private def gets_choice puts "What do you want to do ?" puts "1. New task" puts "2. Edit task" puts "3. ...
describe ProposalQuery do describe "#step_users" do it "returns users for all individual steps" do user = create(:user) proposal = create(:proposal, :with_approver, approver_user: user) users = ProposalQuery.new(proposal).step_users expect(users).to match_array([user]) end end d...
require 'bundler/setup' require 'oauth' class AccessTokenFixture def self.get(oauth_consumer) @token = "access" @secret = "token" return ::OAuth::AccessToken.new(oauth_consumer, @token, @secret) end end
class AddOtherFieldsToExpressCheckouts < ActiveRecord::Migration def change add_column :express_checkouts, :TRANSACTIONID, :string add_column :express_checkouts, :PAYMENTINFO_0_AMT, :string add_column :express_checkouts, :PAYMENTINFO_0_PAYMENTSTATUS, :string add_column :express_checkouts, :PAYMENTINFO...
class Food include Comparable attr :eficiencia_energetica # Devuelve el valor del atributo # attr_accessor :name, :proteins, :carbohydrates, :lipids, :gei, :ground, :amount # Se redefine la comparación para que se realice en base a la eficiencia energética # # @param other [Food] tipo del parámetro # @retu...
class UsersContent < ActiveRecord::Migration def change add_column :users, :twitter_handel, :string add_column :users, :github_handel, :string end end
require 'yaml' if (!File.exist?('servers.yaml')) then File.open('servers.yaml', 'w') { |file| file.write("#Variables:\n# name = Server Name, this should match to the hiera profile\n# environment = The enviornment the node should use when connecting to puppet - Default is set to development\n# clone = If r10k n...
require "test_helper" class ListaControllerTest < ActionDispatch::IntegrationTest setup do @listum = lista(:one) end test "should get index" do get lista_url assert_response :success end test "should get new" do get new_listum_url assert_response :success end test "should create li...
require 'rails_helper' feature 'User can delete links from answer', %( In order to remove unnecessary links from my answer As an answer's author I'd like to be able to delete links ) do given(:user) { create(:user) } given(:question) { create(:question, user: user) } given(:answer) { create(:answer, questi...
class ChangeFulfillmentsCreatedByToUserId < ActiveRecord::Migration def change remove_column :fulfillments, :created_by, :integer add_column :fulfillments, :creator_id, :integer add_index :fulfillments, :creator_id remove_column :fulfillments, :performed_by, :integer add_column :fulfillments, :per...
class Route attr_reader :pattern, :http_method, :controller_class, :action_name def initialize(pattern, http_method, controller_class, action_name) @pattern = pattern @http_method = http_method @controller_class = controller_class @action_name = action_name end def matches?(req) req_action...
class CreateMeasurements < ActiveRecord::Migration[4.2] def change create_table :measurements do |t| t.references :observation, index: true t.references :user, index: true t.integer :orig_user_id t.references :trait, index: true t.references :standard, index: true t.string :val...
class User < ApplicationRecord validates :name, :age, :mail, presence: true validates :name, length: {maximum: 10} validates :age, numericality: {only_integer: ture}, inclusion: {20..29} validates :mail, format: {with: /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/} def name(s) write_attribute(:name, s.to_s.titleize)...
class NewsPost < ActiveRecord::Base belongs_to :author, :class_name => 'Admin', :foreign_key => 'author_id' attr_accessible :author_id, :body, :position, :published_at, :title, :file, :file_cache attr_accessible :tag_list acts_as_taggable acts_as_list extend FriendlyId friendly_id :title, use: :s...
class Payment < ApplicationRecord belongs_to :participation, inverse_of: :payments, foreign_key: [:participant_pesel, :group_id] delegate :group, to: :participation delegate :participant, to: :participation validates :amount, numericality: { greater_than: 0 } validates :date, presence: true end
#Rudimentary ATB System v1.0d #----------# # #Features: Active Time Battles! Roughly and quickly written. Mostly works. # #~ #----------# #-- Script by: V.M of D.T # #- Questions or comments can be: # given by email: sumptuaryspade@live.ca # provided on facebook: http://www.facebook.com/DaimoniousTailsGames # A...
require 'rails_helper' RSpec.describe "the idea view", type: :feature do let(:user) { User.create(username: 'Jenna', password: 'password', role: 0) } it "cannot login without valid username and password" do visit login_path fill_in 'username', :with => nil fill_in 'password', :with => "password" clic...
Then /^they should appear in the videos stream container$/ do page.should have_xpath("//img[@src=\"#{@a_video.source.thumb.url}\"]") #page.should have_content "/url/to/my_vid" #page.should have_content "30" #within('#videos-stream') do # @elements = all('div').collect do |v| # [v.find("img")['src']] ...
cask 'hyperdither' do version '1.3' sha256 'd91952bff7faf69255c03896a26c907fca256bbad4d1444a05b75b2ebdf10785' url 'http://www.tinrocket.com/wp-content/plugins/download-monitor/download.php?id=1' name 'HyperDither' homepage 'http://www.tinrocket.com/content/hyperdither/' app "HyperDither #{version}/HyperDi...
class SponsorTask < ApplicationRecord belongs_to :task belongs_to :sponsor end
class ChangeDateToBeDateInRuns < ActiveRecord::Migration def change change_column :runs, :date, :date end end
require 'battman/dsl/every_block' module Battman module DSL class WatchBlock def initialize(battman, battery) @battman = battman @battery = battery end def every(interval) raise ArgumentError.new('no block given') unless block_given? yield EveryBlock.new(@batt...
class ClientsController < ApplicationController before_filter :signed_in_user def new @client=Client.new end def create @client = Client.new(params[:client]) if @client.save redirect_to @client else render 'new' end end def update @client = Client.find(params[:id]) if @client.update_attri...
class Store < ApplicationRecord validates :address, presence: true, length: { in: 10..100 } validates :telephone, presence: true, numericality: { only_integer: true }, length: { minimum: 8, maximum: 8 } end
class Token < ActiveRecord::Base belongs_to :user validates :token, presence: true, uniqueness: { message: "has already been logged out." } end
# Exception handling is a way to manage the flow of a program when an error occurs. # It allows a program to respond to an error without actually exiting the program entirely.
class RestaurantsController < ApplicationController def index @restaurants = Restaurant.all @restaurants.map do |restaurant| restaurant.image_url = restaurant.image_url.nil? ? "/assets/unknown.png" : restaurant.image_url end end def show @restaurant = Restaurant.find(params[:id]) end ...
# # A couple of rake tasks to make the creation of YQL tables easier. # This caters specifically to my setup, as I am hosting my YQL tables at github.com # # Author: Sebastian Spier (http://twitter.com/#!/sebastianspier/) # require 'rubygems' require 'rake' require 'nokogiri' require 'open-uri' YQL_XSD_ONLINE = "h...
require 'beefcake' module AliyunSls module Protobuf # message Log # { # required uint32 time = 1; // UNIX Time Format # message Content # { # required string key = 1; # required string value = 2; # } # repeated Content contents= 2; # } # message LogGroup # { # repeated Log...
class Ability include CanCan::Ability def initialize(user) user ||= User.new # guest user # admin abilities if user.role?("Admin") can :manage, :all # auditor abilities elsif user.role?("Auditor") can :read, [Call, Contact, Device, DeviceAssignment, DeviceProblem, DeviceType,...
class JournalFavoritesController < FavoritesController private def get_favable @favable = Journal.find(params[:id]) end def get_favorite @favorite = current_profile.favorites.journals.find_by_favable_id(@favable.id) end end
class PracticesController < ApplicationController def index @practices = Practice.all @practice = Practice.new end def create @practice = Practice.new(practice_params) if @practice.save redirect_to @practice else render action: "show" end end def match @practice = Pra...
module Api module V1 class ApiController < ActionController::API before_action :check_basic_auth def check_basic_auth unless session[:user_id].present? && User.find_by_id(session[:user_id]).present? render json: { message: 'Unauthenticated' }, status: 401 end @curre...
require 'exifr/jpeg' class Image def initialize(image_file) unless File.exist?(image_file) raise ArgumentError, "#{image_file} is not a valid file" end @image_file = image_file end def self.gps_coordinates(image_file) new(image_file).coordinates end def coordinates [latitude, lo...
require 'spec_helper' describe RedPenTeacher::CssSelectorMarker do before do @html = '<html><body><div id="main"><div class="content"></div></div></body></html>' end it 'returns true when answer contains element selected by selector' do marker = RedPenTeacher::CssSelectorMarker.new '#main .content' e...
class AmazonSearch require 'yaml' #for when i extract require 'vacuum' def initialize(isbn) @isbn = isbn end def amazon_request req = Vacuum.new .configure( aws_access_key_id: 'AKIAIYOWFSJWSGLL7FZQ', aws_secret_access_key: '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', assoc...
class Admin::FriendEventAttendancesController < AdminController def create friend_id_array = friend_event_attendance_params[:friend_id].reject { |f| f.empty? } if friend_id_array.present? friend_id = friend_id_array[0].to_i @friend_event_attendance = FriendEventAttendance.new(event_id: event.id, f...
class Model::Section::ContactAndLocationBody < SitePrism::Section elements :tables, "table" def telephone_enquiries tables.first end def visitor_opening_hours tables.last end end
## Runa is a job/background task runner powered by a backend Redis database. ## This library can be easily added onto an application to replace a system like delayed_job ## or the existing Codebase library 'WorkHorse'. require 'yaml' require 'redis' require 'logger' require 'runa/job' require 'runa/queued_job' requir...
require 'rails_helper' describe 'ログインのシステムテスト', type: :system do let(:user) { FactoryBot.create(:user) } before do visit login_path end context '有効な情報を送信した場合' do before do fill_in 'login_email', with: user.email fill_in 'login_password', with: user.password click_button 'ログイン' e...
class RenameArticlesContentToSupplementalContent < ActiveRecord::Migration def change rename_column :articles, :content, :supplemental_content end end
class RegexTester def initialize(pattern=nil) @pattern = pattern unless pattern.nil? end attr_accessor :pattern def statements @statements end def statements=(arr) begin raise TypeError unless arr.class == Array raise RuntimeError if arr.empty? ...
require 'pry' require 'pp' def getTF(entry) tf = Hash.new(0) n = 0 entry.entry_word_relations.each do |relation| next unless relation.word.pos === "名詞" n += 1 tf[relation.word.surface_form] += 1 end tf.each do |key, val| tf[key] = val/n.to_f end return tf end def getTfIdf(tf) tf_idf = H...