repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
pjk25/cf-uaa-lib | spec/token_issuer_spec.rb | #--
# Cloud Foundry
# Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.
#
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
# You may not use this product except in compliance with the License.
#
# This product includes a number of subcomponents with
# separate... |
pjk25/cf-uaa-lib | lib/uaa/token_coder.rb | <gh_stars>0
#--
# Cloud Foundry
# Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.
#
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
# You may not use this product except in compliance with the License.
#
# This product includes a number of subcomponents wit... |
pjk25/cf-uaa-lib | lib/uaa/info.rb | <filename>lib/uaa/info.rb
#--
# Cloud Foundry
# Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.
#
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
# You may not use this product except in compliance with the License.
#
# This product includes a number of sub... |
pjk25/cf-uaa-lib | spec/http_spec.rb | #--
# Cloud Foundry 2012.02.03 Beta
# Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved.
#
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
# You may not use this product except in compliance with the License.
#
# This product includes a number of subcomponents with
# se... |
pjk25/cf-uaa-lib | lib/uaa/scim.rb | <gh_stars>0
#--
# Cloud Foundry
# Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.
#
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
# You may not use this product except in compliance with the License.
#
# This product includes a number of subcomponents wit... |
pjk25/cf-uaa-lib | lib/uaa/token_issuer.rb | <reponame>pjk25/cf-uaa-lib<gh_stars>0
#--
# Cloud Foundry
# Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.
#
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
# You may not use this product except in compliance with the License.
#
# This product includes a n... |
pjk25/cf-uaa-lib | lib/uaa/http.rb | #--
# Cloud Foundry
# Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.
#
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
# You may not use this product except in compliance with the License.
#
# This product includes a number of subcomponents with
# separate... |
pjk25/cf-uaa-lib | spec/integration_spec.rb | <reponame>pjk25/cf-uaa-lib<gh_stars>0
#--
# Cloud Foundry
# Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.
#
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
# You may not use this product except in compliance with the License.
#
# This product includes a n... |
pjk25/cf-uaa-lib | spec/spec_helper.rb | <filename>spec/spec_helper.rb
#--
# Cloud Foundry
# Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.
#
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
# You may not use this product except in compliance with the License.
#
# This product includes a number of... |
alelievr/stalker_sama | sources/project_logger.rb | <reponame>alelievr/stalker_sama
require 'json'
require 'awesome_print'
require_relative 'api42'
class ProjectLogger < Api42
def get_infos(user_list, endpoint = '/v2/cursus_users')
return [] unless user_list.count.positive?
levels = []
[1..10].map do |page|
response = send_uri("#{endpoint}?filter[u... |
alelievr/stalker_sama | sources/slack_pinger.rb | require 'slack-ruby-client'
require 'json'
def log_slack_pinger(infos, login42, slack_id, hash, message)
puts 'infos -------------------------------------------------'
ap infos
puts 'slack_id ----------------------------------------------'
ap slack_id
puts 'login42 -------------------------------------------... |
alelievr/stalker_sama | sources/user_database.rb | require 'sqlite3'
require 'sequel'
class UserDatabase
USER_TABLE = 'Users'.freeze
DATABASE_FILE = 'stalker.db'.freeze
def initialize
@sqlite_db = SQLite3::Database.new DATABASE_FILE
@db = Sequel.connect("sqlite://#{DATABASE_FILE}")
stm1 = @sqlite_db.prepare "SELECT * FROM sqlite_master WHERE name =... |
alelievr/stalker_sama | sources/add_user.rb | <reponame>alelievr/stalker_sama<filename>sources/add_user.rb
#!env ruby
require 'oauth2'
require_relative 'slack_pinger.rb'
require_relative 'user_database.rb'
return p 'Give me the 42 login and slack user name' unless ARGV[0] && ARGV[1]
db = UserDatabase.new
sb = SlackPinger.new
client = OAuth2::Client.new(ENV['API... |
alelievr/stalker_sama | sources/api42.rb | <gh_stars>0
require 'oauth2'
class Api42
UID = ENV['API42_UID']
SECRET = ENV['API42_SECRET']
def initialize
@client = OAuth2::Client.new(UID, SECRET, site: 'https://api.intra.42.fr')
@token = @client.client_credentials.get_token
end
protected
def send_uri(uri)
sleep(3)
initialize if (Tim... |
alelievr/stalker_sama | sources/cluster_logger.rb | <gh_stars>0
require 'json'
require 'time'
require 'awesome_print'
require_relative 'api42'
def log(c1, c2, opts)
puts "\nTime: #{Time.now}"
ap c1
puts "\n"
ap c2 if c2
puts 'opts --------------------------------------------------'
ap opts
puts "-------------------------------------------------------\n\n"... |
alelievr/stalker_sama | sources/main.rb | require_relative 'cluster_logger.rb'
require_relative 'project_logger.rb'
require_relative 'user_database.rb'
require_relative 'slack_pinger.rb'
require_relative 'slack_bot.rb'
require 'awesome_print'
cluster = ClusterLogger.new
project = ProjectLogger.new
slack = SlackPinger.new
db = UserDatabase.new
SlackBot.new
lo... |
alelievr/stalker_sama | sources/slack_bot.rb | <reponame>alelievr/stalker_sama<gh_stars>0
require 'slack-ruby-client'
require 'awesome_print'
require 'json'
require 'http'
require 'final_redirect_url'
require 'nokogiri'
require 'open-uri'
require 'rubycards'
require_relative 'user_database.rb'
include RubyCards
class SlackBot
def initialize
Slack.configure d... |
selfcov/test_ruby | show_env.rb | #!/usr/bin/env ruby
require 'base64'
require 'json'
ENV.sort.map do |key, value|
puts key + '=' + value
end
puts Base64.encode64(ENV.to_hash.to_json)
|
codehearts/portfolio | _plugins/jekyll-gotenberg.rb | require 'net/http'
# Convert an HTML file to PDF
# The original HTML file is then removed
#
# This function makes a request to a Gotenberg server to render the site by URL
def convert_html_to_pdf(item)
# Read the global Jekyll config
pdf_config = item.site.config.fetch 'pdf', {}
gotenberg_config = pdf_config.fet... |
codehearts/portfolio | _plugins/jekyll-cache-busting.rb | require 'fileutils'
require 'digest'
module Jekyll
module CacheBusting
# Mapping of file paths to their cache busting versions
@@cached_files = Hash.new do |cache, path|
# If an entry doesn't exist, hash and create it
hash = Digest::MD5.hexdigest(File.read(path))[0..7]
cache[path] = path.s... |
Monkee45/PMO | spec/Runner/project_spec.rb | <reponame>Monkee45/PMO
require_relative 'spec_helper'
require 'Runner/project'
module Runner
describe Project do
before do
# $stdout = StringIO.new
@name = "terry"
@name1 = 'john'
@rating = 25
@member = TeamMember.new(@name, @rating)
@member1 = TeamMember.new(@name1)
@pro... |
Monkee45/PMO | lib/Runner/team_member.rb | <reponame>Monkee45/PMO
require_relative 'ratings'
module Runner
class TeamMember
attr_reader :name
attr_accessor :rating
attr_accessor :reviews
include Ratings
def initialize (name, rating=10, reviews=0)
@name = name.capitalize
@rating = rating
@reviews = reviews
end
def to_s... |
Monkee45/PMO | lib/Runner/ratings.rb | <filename>lib/Runner/ratings.rb
module Runner
module Ratings
def rated_up(factor=1)
@rating += (15*factor)
@reviews += 1
puts "Awesome! #{@name} got rated up and is now #{@rating}"
end
def rated_down(factor=1)
if (@rating -= (15*factor)) < 0
@rating = 0
end
@r... |
Monkee45/PMO | test.rb | puts(Dir.pwd())
|
Monkee45/PMO | PMO.gemspec | <filename>PMO.gemspec
Gem::Specification.new do |s|
s.name = "PMO_mw"
s.version = "1.0.0"
s.author = "<NAME>"
s.email = "<EMAIL>"
s.homepage = "https://au.linkedin.com/in/Monkee45"
s.summary = "basic project and team members with random rating system"
s.description = Fi... |
Monkee45/PMO | spec/Runner/manager_spec.rb | <gh_stars>0
require_relative 'spec_helper'
require 'Runner/manager'
module Runner
describe Manager do
before do
$stdout = StringIO.new
@rating = 50
@manager = Manager.new('mandy', @rating, 'manager')
end
it "can be identified as a manager" do
@manager.manager?.should == true
... |
Monkee45/PMO | lib/Runner/project.rb | <reponame>Monkee45/PMO
require_relative 'team_member'
require_relative 'die'
require 'CSV'
module Runner
class Project
attr_accessor :name
attr_reader :members
def initialize(name)
@name = name.capitalize
@members = []
end
def add_member(member)
@members << member
end
... |
Monkee45/PMO | lib/Runner/manager.rb | require_relative 'team_member'
module Runner
class Manager < TeamMember
def initialize(name, rating, type='manager')
super(name, rating)
@type = type.capitalize
@factor = 2
end
def manager?
@type == 'Manager'
end
def rated_up(factor=1)
puts "OMG! This is a Manager... |
Monkee45/PMO | spec/Runner/team_member_spec.rb | <reponame>Monkee45/PMO
require_relative 'spec_helper'
require 'Runner/team_member'
module Runner
describe TeamMember do
before do
$stdout = StringIO.new
@name = "terry"
@name1 = 'john'
@rating = 25
@member = TeamMember.new(@name, @rating)
@member1 = TeamMember.new(@name1)
... |
bjork24/gliss | gliss.gemspec | <reponame>bjork24/gliss
require './lib/gliss'
Gem::Specification.new do |s|
s.name = 'gliss-layout'
s.version = Gliss::VERSION
s.date = Gliss::DATE
s.authors = ['<NAME>']
s.email = ['<EMAIL>']
s.homepage = 'http://product.voxmedia.com'
s.license = 'MIT'
s.summary ... |
ozataman/acts_as_bucket_on | init.rb | <gh_stars>1-10
require 'acts_as_bucket_on'
ActiveRecord::Base.send :include, ActiveRecord::Acts::BucketOn
RAILS_DEFAULT_LOGGER.info "** acts_as_bucket_on: initialized properly." |
ozataman/acts_as_bucket_on | test/test_helper.rb | require 'rubygems'
# require File.dirname(__FILE__) + "/../../../../config/environment.rb"
require 'active_record'
require 'active_support'
require 'active_support/test_case'
require File.dirname(__FILE__) + '/../init'
class BucketableModel < ActiveRecord::Base
acts_as_bucket_on :horizon, :conditions => "self.due_at... |
ozataman/acts_as_bucket_on | test/acts_as_bucket_on_test.rb | <filename>test/acts_as_bucket_on_test.rb
require 'test_helper'
class ActsAsBucketOnTest < ActiveSupport::TestCase
test "that conditions are handled as expected" do
assert_raise InvalidConditions { BucketableModel.send(:build_bucketing_condition, :trial, {:conditions => 1234}) }
assert_nothing_raised { Bucket... |
ozataman/acts_as_bucket_on | lib/acts_as_bucket_on.rb | <reponame>ozataman/acts_as_bucket_on<filename>lib/acts_as_bucket_on.rb
require 'acts_as_bucket_on/acts_as_bucket_on' |
ozataman/acts_as_bucket_on | lib/acts_as_bucket_on/acts_as_bucket_on.rb | module ActiveRecord
module Acts
module BucketOn
def self.included(base)
base.send :extend, ClassMethods
end
module ClassMethods
class InvalidBucketName < StandardError; end
class InvalidConditions < StandardError; end
class InvalidObjectArray < StandardErro... |
vyorkin-forks/24pullrequests | app/models/archived_pull_requests.rb | class ArchivedPullRequest < ActiveRecord::Base
belongs_to :user
scope :year, -> (year) { where('EXTRACT(year FROM "created_at") = ?', year) }
end
|
vyorkin-forks/24pullrequests | app/models/archived_pull_request.rb | <gh_stars>0
class ArchivedPullRequest < ActiveRecord::Base
PAST_YEARS = [2013, 2012]
belongs_to :user
scope :year, -> (year) { where('EXTRACT(year FROM "created_at") = ?', year) }
end
|
vyorkin-forks/24pullrequests | spec/models/concerns/pull_review_spec.rb | require 'rails_helper'
describe Concerns::PullReview, type: :model do
let(:user) { create(:user) }
describe 'award_pullreview_coupon' do
before do
3.times { create(:pull_request, user: user) }
ENV['PULLREVIEW_COUPON'] = 'PULLREVIEW_COUPON'
end
it 'does not award PullReview coupon when les... |
vyorkin-forks/24pullrequests | app/models/concerns/pull_review.rb | <reponame>vyorkin-forks/24pullrequests
module Concerns
module PullReview
def award_pullreview_coupon
return unless coupon.present?
return coupon if pull_requests.year(CURRENT_YEAR).length > 23
end
private
def coupon
@coupon ||= ENV['PULLREVIEW_COUPON']
end
end
end |
alu0100831382/prct10 | lib/biblio/fichero.rb | class Bibliography
include Comparable
attr_accessor :title,:author, :date
def initialize(title,author,date)
@title = title
@author = author
@date = date
end
def <=>(other)
if(@author != other.author)
@author <=> other.author
elsif(@... |
alu0100831382/prct10 | spec/biblio_spec.rb | require 'spec_helper'
describe Biblio do
it 'has a version number' do
expect(Biblio::VERSION).not_to be nil
end
describe Biblio do
context "Las pruebas de los libros" do
before :each do
@l1 = Libro.new("Programming Ruby 1.9 & 2.0","<NAME>.","(2013)","(1 Edicion)","(2)","Inglate... |
thomas-yancey/action-cable-chat-template | config/routes.rb | <reponame>thomas-yancey/action-cable-chat-template
Rails.application.routes.draw do
root to: 'welcome#index'
resources :users, only: [:new, :index, :create]
resources :sessions, only: [:new, :destroy, :create]
resources :rooms, except: [:update, :edit, :destroy] do
resources :memberships, only: [:index, :c... |
thomas-yancey/action-cable-chat-template | app/controllers/messages_controller.rb | class MessagesController < ApplicationController
def create
@message = Message.new(message_params)
@message.save
redirect_to :back
end
private
def message_params
params.require(:message).permit(:room_id, :content).merge(user_id: current_user.id)
end
end
|
thomas-yancey/action-cable-chat-template | app/controllers/memberships_controller.rb | <filename>app/controllers/memberships_controller.rb<gh_stars>0
class MembershipsController < ApplicationController
before_action :verify_logged_in
def index
@room = Room.find(params[:room_id])
redirect_with_flash unless member_of_group
@memberships = Membership.where(room_id: params[:room_id])
@use... |
thomas-yancey/action-cable-chat-template | app/controllers/sessions_controller.rb | class SessionsController < ApplicationController
def new
@user = User.new
end
def create
@user = User.find_by(username: params[:session][:username])
#utilize bcrypts authenticate method to see if the password is correct
if @user && @user.authenticate(params[:session][:password])
session[:u... |
thomas-yancey/action-cable-chat-template | app/models/user.rb | <reponame>thomas-yancey/action-cable-chat-template
class User < ApplicationRecord
has_secure_password
has_many :memberships
has_many :rooms, through: :memberships
validates_uniqueness_of :username
validates_presence_of :username
validates :username, length: {maximum: 16}
end
|
thomas-yancey/action-cable-chat-template | app/controllers/users_controller.rb | <filename>app/controllers/users_controller.rb
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
session[:user_id] = @user.id
# Here we are pushing the first room which is
# going to be our open chat roo... |
thomas-yancey/action-cable-chat-template | app/models/room.rb | <reponame>thomas-yancey/action-cable-chat-template<gh_stars>0
class Room < ApplicationRecord
has_many :memberships
has_many :messages
has_many :users, through: :memberships
validates :name, presence: true,
length: { maximum: 10},
uniqueness: true
end
|
thomas-yancey/action-cable-chat-template | app/models/membership.rb | class Membership < ApplicationRecord
belongs_to :user
belongs_to :room
validates_presence_of :room_id
validates_presence_of :user_id
validates_uniqueness_of :user_id, :scope => :room_id
def name
User.find(self.user_id).username
end
end |
thomas-yancey/action-cable-chat-template | app/controllers/rooms_controller.rb | class RoomsController < ApplicationController
before_action :verify_logged_in
def show
@room = Room.find(params[:id])
redirect_with_flash unless member_of_group
@messages = @room.messages.order(id: :desc).limit(500).reverse
@message = Message.new
@users = @room.users
end
def index
@ro... |
thomas-yancey/action-cable-chat-template | app/models/message.rb | <filename>app/models/message.rb
class Message < ApplicationRecord
belongs_to :user
belongs_to :room
validates_presence_of :content
validates_presence_of :user_id
validates_presence_of :room_id
end |
thomas-yancey/action-cable-chat-template | app/controllers/application_controller.rb | <filename>app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
helper_method :current_user, :logged_in?, :member_of_group, :verified_log_in, :redirect_with_flash
def current_user
return unless session[:user_id]
@current_user ... |
GrahamMThomas/advent_of_code_2018 | 2/main.rb | <filename>2/main.rb
# Prompt https://adventofcode.com/2018/day/2
num_of_threes = 0
num_of_twos = 0
File.readlines("input.txt").each do |box_id|
box_id = box_id.strip
tracker = Hash.new(0)
box_id.each_char do |x|
tracker[x] += 1
end
occurance_tracker = tracker.each_with_object({}){|(k,v),o|(... |
GrahamMThomas/advent_of_code_2018 | 8/main.rb | <filename>8/main.rb
# Prompt https://adventofcode.com/2018/day/4
require 'awesome_print'
class Node
attr_accessor :children, :metadata_entries, :num_of_children, :num_of_metadata
def initialize()
@num_of_children = 0
@num_of_metadata = 0
@children = []
@metadata_entries = []
end
def get_chil... |
GrahamMThomas/advent_of_code_2018 | 3/main.rb | <reponame>GrahamMThomas/advent_of_code_2018<filename>3/main.rb<gh_stars>0
# Prompt https://adventofcode.com/2018/day/3
require "awesome_print"
class SquareInch
attr_accessor :claims
def initialize
@claims = []
end
end
fabric = Array.new(1000) { Array.new(1000) {SquareInch.new}}
File.readlines("... |
GrahamMThomas/advent_of_code_2018 | 4/main.rb | # Prompt https://adventofcode.com/2018/day/4
require "awesome_print"
guard_sleep_times = Hash.new(0)
guard_sleep_minute_tracker = Hash.new { |h,k| h[k] = Hash.new(0) }
current_guard_id = 0
current_sleep_start_time = 0
break_check = 0
File.readlines("input.txt").each do |event|
parsed_event = /\[\d{4}\-\d{2}\-\d{... |
GrahamMThomas/advent_of_code_2018 | 5b/main.rb | <gh_stars>0
# Prompt https://adventofcode.com/2018/day/5
require "awesome_print"
polymer_alphabet = Hash.new(0)
('a'..'z').to_a.each do |letter|
polymer = File.open('input.txt').read
done = false
while not done
skip_index = 0
tmp_polymer = polymer
tmp_polymer.gsub!(letter, '')
... |
GrahamMThomas/advent_of_code_2018 | 7/main.rb | <gh_stars>0
# Prompt https://adventofcode.com/2018/day/4
require "awesome_print"
class Step
attr_accessor :prereqs, :unlocks, :letter
def initialize
letter = ''
@prereqs = []
@unlocks = []
end
end
graph = Hash.new { |h,k| h[k] = Step.new }
File.readlines("input.txt").each do |st... |
GrahamMThomas/advent_of_code_2018 | 5/main.rb | # Prompt https://adventofcode.com/2018/day/5
require "awesome_print"
polymer = File.open('input.txt').read
done = false
while not done
skip_index = 0
tmp_polymer = polymer
done = true
(0...polymer.length-1).each do |x|
x -= skip_index
if polymer[x] != polymer[x+1] and polymer[x].dow... |
GrahamMThomas/advent_of_code_2018 | 1b/main.rb | <reponame>GrahamMThomas/advent_of_code_2018
# Prompt https://adventofcode.com/2018/day/1
frequency = 0
frequnecies = Hash.new(0)
frequnecies[0] = 1
while true
File.readlines("input.txt").each do |num|
frequency += num.to_i
if frequnecies[frequency] == 1
puts frequency.to_i
e... |
GrahamMThomas/advent_of_code_2018 | 8b/main.rb | <gh_stars>0
# Prompt https://adventofcode.com/2018/day/4
require 'awesome_print'
class Node
attr_accessor :children, :metadata_entries, :num_of_children, :num_of_metadata
def initialize()
@num_of_children = 0
@num_of_metadata = 0
@children = []
@metadata_entries = []
end
def get_children(tre... |
GrahamMThomas/advent_of_code_2018 | 7b/main.rb | <gh_stars>0
# Prompt https://adventofcode.com/2018/day/4
require "awesome_print"
class Step
attr_accessor :prereqs, :unlocks, :letter, :health
def initialize
letter = ''
health = 0
@prereqs = []
@unlocks = []
end
end
graph = Hash.new { |h,k| h[k] = Step.new }
# Build my ... |
GrahamMThomas/advent_of_code_2018 | 2b/main.rb | <filename>2b/main.rb
# Prompt https://adventofcode.com/2018/day/2
boxes = File.open("input.txt").read
boxes = boxes.split("\n").map(&:strip)
answer = "Shit."
File.readlines("input.txt").each do |box_id|
box_id = box_id.strip
tracker = Hash.new(0)
box_id.each_char do |x|
tracker[x] += 1
end
... |
GrahamMThomas/advent_of_code_2018 | 4b/main.rb | <reponame>GrahamMThomas/advent_of_code_2018<gh_stars>0
# Prompt https://adventofcode.com/2018/day/4
require "awesome_print"
guard_sleep_times = Hash.new(0)
guard_sleep_minute_tracker = Hash.new { |h,k| h[k] = Hash.new(0) }
current_guard_id = 0
current_sleep_start_time = 0
File.readlines("input.txt").each do |event|
... |
dehlen/atlas-framework | AtlasFramework.podspec | Pod::Spec.new do |s|
s.name = "AtlasFramework"
s.version = "1.2.0"
s.summary = "Atlas is a framework that helps you structure your iOS app using the MVVM-C architecture pattern."
s.description = <<-DESC
Atlas is a framework that helps you structure your iOS app using the MVVM-C architecture... |
JesterPrince/docker-web-framework-examples | rails/app/controllers/hello_controller.rb | <filename>rails/app/controllers/hello_controller.rb
class HelloController < ApplicationController
def home
render html: "Hello world with RAILS_ENV=#{ENV['RAILS_ENV']}"
end
end
|
JesterPrince/docker-web-framework-examples | rails/config/application.rb | <reponame>JesterPrince/docker-web-framework-examples
require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
re... |
JesterPrince/docker-web-framework-examples | rails/config/routes.rb | Rails.application.routes.draw do
# For details on the DSL available within this file:
# see http://guides.rubyonrails.org/routing.html
root to: 'hello#home'
# Set up a custom health check endpoint (no controller needed).
get '/healthy', to: ->(_) { [200, {}, ['']] }
end
|
OnkelDisMaster/retort | spec/models/retort_spec.rb | <reponame>OnkelDisMaster/retort
require "spec_helper"
path = "./plugins/retort/plugin.rb"
source = File.read(path)
plugin = Plugin::Instance.new(Plugin::Metadata.parse(source), path)
plugin.activate!
plugin.initializers.first.call
describe ::Retort::Retort do
before do
SiteSetting.load_settings(File.join(Rails.... |
OnkelDisMaster/retort | spec/controllers/retorts_controller_spec.rb | <filename>spec/controllers/retorts_controller_spec.rb
require "spec_helper"
path = "./plugins/retort/plugin.rb"
source = File.read(path)
plugin = Plugin::Instance.new(Plugin::Metadata.parse(source), path)
plugin.activate!
plugin.initializers.first.call
describe ::Retort::RetortsController do
routes { ::Retort::Engi... |
borisrorsvort/traduction_litteraire | helpers/page_title_helper.rb | # frozen_string_literal: true
module PageTitleHelper
def site_title
data.config.site.title
end
def title_separator
data.config.site.title_separator
end
def render_page_title
current_page.data.title + title_separator + site_title
end
end
|
borisrorsvort/traduction_litteraire | helpers/meta_tag_helper.rb | # frozen_string_literal: true
module MetaTagHelper
# Sets the page meta description and keywords, which can be composed by either
# a) data in config.yml (which is sitewide), or
# b) data set in the FrontMatter of each page
def meta_keywords
keywords = current_page.data.meta_keywords || data.config.si... |
borisrorsvort/traduction_litteraire | config.rb | <filename>config.rb<gh_stars>0
# --------------------------------------------------------------------------------------------------
# Helpers
# --------------------------------------------------------------------------------------------------
helpers do
# Helpers are defined in and can be added to `helpers/custom_he... |
tobytripp/text_to_noise | spec/text_to_noise/player_spec.rb | require "spec_helper"
module Rubygame
class Sound
class << self
attr_accessor :autoload_dirs
def []( sound_name )
end
def autoload_dirs()
@autoload_dirs ||= []
end
end
end
end
describe TextToNoise::Player do
describe "construction" do
it "adds the defa... |
tobytripp/text_to_noise | lib/text_to_noise/conditions/throttled_match_condition.rb | module TextToNoise::Conditions
class ThrottledMatchCondition
attr_accessor :last_played, :throttle_period
def initialize( period=0.25)
@throttle_period = period # seconds
@last_played = 0
end
def play?( match_data=nil )
if elapsed > throttle_period
self.last_played ... |
tobytripp/text_to_noise | spec/text_to_noise/log_reader_spec.rb | <reponame>tobytripp/text_to_noise
require 'spec_helper'
require 'stringio'
module TextToNoise
describe LogReader do
let( :io ) { StringIO.new "phantasm" }
let( :mapper ) { double( "LineToSoundMapper", :dispatch => nil ) }
subject { LogReader.new io, mapper }
describe "#call" do
it "reads ... |
tobytripp/text_to_noise | ssh.sounds.rb | match /sshd.*Accepted/ => %w[rooster hawk chicken crow]
|
tobytripp/text_to_noise | lib/text_to_noise/player.rb | <reponame>tobytripp/text_to_noise
module TextToNoise
class Player
include Logging
SOUND_DIR = File.expand_path File.join( APP_ROOT, 'sounds' )
class SoundNotFound < StandardError
def initialize( sound_name )
super "Could not locate '#{sound_name}' in #{Rubygame::Sound.autoload_dirs}"
... |
tobytripp/text_to_noise | features/support/env.rb | <reponame>tobytripp/text_to_noise
require 'aruba/cucumber'
lib = File.expand_path( '../../../lib/', __FILE__ )
$:.unshift lib unless $:.include?( lib )
require 'text_to_noise'
TextToNoise.logger = Logger.new "log/cucumber.log"
TextToNoise.logger.level = Logger::DEBUG
|
tobytripp/text_to_noise | lib/text_to_noise/command_line.rb | <gh_stars>1-10
require 'text_to_noise/logging'
module TextToNoise
class CommandLine
include Logging
attr_reader :options, :mapping
DEFAULT_FILE_DELAY = 100
def initialize( mapping_configurations, options={} )
@options = {
:input => $stdin
}.merge options
configs = A... |
tobytripp/text_to_noise | text_to_noise.gemspec | # -*- encoding: utf-8 -*-
lib = File.expand_path( '../lib/', __FILE__ )
$:.unshift lib unless $:.include?( lib )
require 'text_to_noise/version'
Gem::Specification.new do |spec|
spec.name = "text-to-noise"
spec.version = TextToNoise::VERSION
spec.platform = Gem::Platform::RUBY
spec.summary = "Play sound... |
tobytripp/text_to_noise | spec/text_to_noise/noise_mapping_spec.rb | <filename>spec/text_to_noise/noise_mapping_spec.rb
require 'spec_helper'
describe TextToNoise::NoiseMapping do
before do
TextToNoise.player = double( TextToNoise::Player )
now = Time.now
times = (0..60).map { |i| now + i }
Time.stub(:now) { times.shift }
end
describe "#initialize" do
... |
tobytripp/text_to_noise | lib/text_to_noise/logging.rb | <reponame>tobytripp/text_to_noise
require 'forwardable'
module TextToNoise
module Logging
extend Forwardable
def_delegators :logger, :warn, :debug, :error, :info
def logger() TextToNoise.logger; end
end
end
|
tobytripp/text_to_noise | spec/text_to_noise/sound_map.rb | match /macaw/ => "blue_amazon_macaw.wav"
match /canary/ => "canary.wav"
|
tobytripp/text_to_noise | lib/text_to_noise/conditions/iteration_mapping_condition.rb | module TextToNoise::Conditions
class IterationMappingCondition
attr_accessor :count
def initialize( count )
self.count = count
@iteration = 0
end
def play?( match_data=nil )
@iteration += 1
count == 1 || (@iteration % count == 0)
end
alias_method :call, :play?... |
tobytripp/text_to_noise | spec/text_to_noise/router_spec.rb | <reponame>tobytripp/text_to_noise
require 'spec_helper'
module TextToNoise
describe Router do
it "reloads its configuration if it has changed"
describe ".parse" do
let( :mapping ) { double( NoiseMapping, :to => nil ) }
context "given a nil configuration" do
it "raises an ArgumentEr... |
tobytripp/text_to_noise | lib/text_to_noise/router.rb | module TextToNoise
class Router
include Logging
attr_accessor :mappings
def initialize()
@mappings = []
end
def self.parse( config )
raise ArgumentError, "No configuration given" if config.nil? or config.strip.empty?
new.tap { |m|
m.instance_eval config
m.info "... |
tobytripp/text_to_noise | lib/text_to_noise.rb | <filename>lib/text_to_noise.rb
LIB_DIR = File.dirname File.expand_path( __FILE__ )
APP_ROOT = File.join LIB_DIR, '..'
$LOAD_PATH << LIB_DIR
require 'logger'
Dir["#{LIB_DIR}/text_to_noise/**/*.rb"].each { |lib|
lib =~ %r<lib/(.*)\.rb$>
require $1
}
module TextToNoise
include Logging
def player
@pla... |
tobytripp/text_to_noise | spec/spec_helper.rb | <gh_stars>1-10
require 'rspec'
lib = File.expand_path( '../lib/', __FILE__ )
$:.unshift lib unless $:.include?( lib )
require 'text_to_noise'
TextToNoise.logger = Logger.new "log/test.log"
TextToNoise.logger.level = Logger::DEBUG
Rspec.configure do |c|
c.mock_with :rspec
end
|
tobytripp/text_to_noise | sample.sounds.rb | <gh_stars>1-10
sound_path "tmp/sounds"
scale = 2
map /Rendered/ => %w(cardinal canary whipperwhill), :every => scale
map /Processing/ => "crickets", :every => scale * 2
map /User Load/ => %w"nightingale pigeons red_lories"
map /SessionsController#new/ => "owl-short"
map /404 Not Found/ => "hawk"
map /RoutingErro... |
tobytripp/text_to_noise | spec/text_to_noise/iteration_mapping_condition_spec.rb | require 'spec_helper'
describe TextToNoise::Conditions::IterationMappingCondition do
describe "construction" do
it "accepts a count" do
described_class.new 4
end
end
context "for value 1" do
subject { described_class.new 1 }
it "#play? returns true for all calls" do
3.times do
... |
tobytripp/text_to_noise | spec/text_to_noise/command_line_spec.rb | <reponame>tobytripp/text_to_noise<filename>spec/text_to_noise/command_line_spec.rb
require 'spec_helper'
module TextToNoise
describe TextToNoise::CommandLine do
let( :mapping ) { double( NoiseMapping ) }
let( :reader ) { double( LogReader, :call => nil ) }
before :each do
Router.stub!( :parse... |
tobytripp/text_to_noise | lib/text_to_noise/mute_player.rb | <gh_stars>1-10
module TextToNoise
class MutePlayer
include Logging
def play( sound_name )
info "Playing #{sound_name}"
end
def playing?() false; end
end
end
|
tobytripp/text_to_noise | lib/text_to_noise/noise_mapping.rb | # -*- coding: utf-8 -*-
module TextToNoise
class NoiseMapping
include Logging
attr_accessor :targets, :matcher_conditions, :filter_conditions
def initialize( expression_or_map, &block )
debug "Parsing expression: #{expression_or_map.inspect}"
@matcher_conditions = []
@filter_condit... |
tobytripp/text_to_noise | lib/text_to_noise/log_reader.rb | <reponame>tobytripp/text_to_noise<filename>lib/text_to_noise/log_reader.rb
module TextToNoise
class LogReader
attr_reader :io
def initialize( io, mapper )
@io, @mapper = io, mapper
end
def call()
while line = io.gets
@mapper.dispatch line
TextToNoise.throttle!
end
... |
tobytripp/text_to_noise | features/step_definitions/debugger_steps.rb | <reponame>tobytripp/text_to_noise<filename>features/step_definitions/debugger_steps.rb
When /^I am debugging$/ do
require 'ruby-debug'
debugger
end
|
tobytripp/text_to_noise | spec/text_to_noise/conditions/throttled_match_condition_spec.rb | require 'spec_helper'
describe TextToNoise::Conditions::ThrottledMatchCondition do
describe "#play?" do
before :each do
@now = Time.now
Time.stub!( :now ).and_return @now
end
it "returns true on the first call" do
subject.play?.should be_true
end
it "returns false if called ag... |
tobytripp/text_to_noise | watchr.rb | # Run me with:
# watchr watchr.rb
#
# I will automatically run the relevant specs when you change things.
# Aren't I convenient?
#
begin
require "g"
puts "Growl loaded"
rescue LoadError
puts "No growl library found"
end
def announce( message )
puts message
g message if Kernel.respond_to? :g
end
def spec( ... |
megorei/motionkit-example | app/views/example_view.rb | class ExampleView < UIView
def initWithFrame(frame)
super.tap do |v|
v.backgroundColor = UIColor.blackColor
v.addSubview(we)
v.addSubview(love)
v.addSubview(rubymotion)
end
end
def we
UILabel.alloc.init.tap do |l|
l.text = "We"
l.font = UIFont.systemFontOfSize(24)... |
megorei/motionkit-example | app/controllers/example_controller.rb | <filename>app/controllers/example_controller.rb
class ExampleController < UIViewController
# NOTICE: only use ONE of the methods. If both are active, the MotionKit layout will be rendered inside the already completed ExampleView instance
def loadView
self.view = ExampleView.alloc.initWithFrame(UIScreen.mainS... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.