repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
railsrumble/r13-team-46 | config/initializers/errbit.rb | <reponame>railsrumble/r13-team-46
Airbrake.configure do |config|
config.api_key = '22b2740ec5056ec9a40d245b6d6be604'
config.host = 'errbit.welaika.com'
config.port = 80
config.secure = config.port == 443
end
|
railsrumble/r13-team-46 | app/mailers/recurrence_mailer.rb | class RecurrenceMailer < ActionMailer::Base
default from: "<EMAIL>"
helper :tasks
helper :recurrences
helper :application
def notify(user, task)
@user = user
@task = task
mail(to: @user.email, subject: 'Evry.io notification')
end
end
|
railsrumble/r13-team-46 | spec/repositories/create_repository_spec.rb | <filename>spec/repositories/create_repository_spec.rb<gh_stars>0
require 'unit_spec_helper'
describe CreateRepository do
let(:repository) { CreateRepository.new }
let(:attributes) { stub }
let(:klass) { stub }
let(:buy) { stub(:persisted? => true) }
before do
repository.stubs(:klass).returns(klass)
... |
railsrumble/r13-team-46 | db/migrate/20131019085603_create_recurrences.rb | <filename>db/migrate/20131019085603_create_recurrences.rb<gh_stars>0
class CreateRecurrences < ActiveRecord::Migration
def change
create_table :recurrences do |t|
t.references :task, index: true
t.boolean :auto_schedule
t.datetime :next
t.string :expression
t.datetime :starting
... |
railsrumble/r13-team-46 | app/repositories/create_task.rb | class CreateTask < CreateRepository
def after_create_hooks
[ SyncTaskRecurrence ]
end
end
|
railsrumble/r13-team-46 | spec/support/database_cleaner.rb | <gh_stars>0
require 'database_cleaner'
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:deletion)
end
config.before(:each) do
if defined?(Capybara) && Capybara.current_driver == :rack_test
DatabaseCleaner.strategy = :transaction
else
DatabaseCleaner.strate... |
railsrumble/r13-team-46 | spec/unit_spec_helper.rb | RAILS_ROOT = File.expand_path('../../', __FILE__)
$LOAD_PATH.unshift(RAILS_ROOT) unless $LOAD_PATH.include?(RAILS_ROOT)
require 'fileutils'
require 'active_support/dependencies'
require 'active_support/concern'
require 'active_support/core_ext'
require 'active_model'
require 'mocha/api'
require 'timecop'
require 'ostr... |
railsrumble/r13-team-46 | db/migrate/20131019102652_add_fields_to_tasks.rb | <filename>db/migrate/20131019102652_add_fields_to_tasks.rb
class AddFieldsToTasks < ActiveRecord::Migration
def change
rename_column :tasks, :title, :action
add_column :tasks, :time_expression, :string
end
end
|
railsrumble/r13-team-46 | app/controllers/tasks_controller.rb | class TasksController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource
inherit_resources
respond_to :html
respond_to :js, only: [ :create, :update, :destroy, :schedule ]
def create
@task = CreateTask.create(params[:task].merge(user_id: current_user.id))
if @ta... |
railsrumble/r13-team-46 | app/models/task.rb | <gh_stars>0
class Task < ActiveRecord::Base
belongs_to :user
has_one :recurrence, dependent: :destroy
attr_accessible :time_expression, :action, :description, :user_id
validates :time_expression, :action, :user_id, presence: true
scope :by_next_at, -> { joins(:recurrence).order('next_at asc') }
end
|
WolfMeister/homebrew-cask | Casks/boom-3d.rb | <reponame>WolfMeister/homebrew-cask<filename>Casks/boom-3d.rb<gh_stars>0
cask 'boom-3d' do
version '1.1.2,1519729669'
sha256 '14c645ab8b85a696052dc01ad810487cdc4a21fae3f702eee156dd9ec9af2895'
# devmate.com/com.globaldelight.Boom3D was verified as official when first introduced to the cask
url "https://dl.devma... |
dannyflatiron/Rails-App | app/controllers/users_controller.rb | class UsersController < ApplicationController
before_action :authenticate_user!, except: [:show, :index]
def new
end
def create
end
def show
@user = User.find(params[:id])
end
private
def user_params
params.require(:user).permit(:name, :email, :uid, :encrypted_pas... |
dannyflatiron/Rails-App | app/controllers/application_controller.rb | class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
protect_from_forgery with: :exception
# before_action :authenticate_user!
helper_method :morse_encode, :morse_encode_word
MORSE_CODE = {
"a" => ".-... |
dannyflatiron/Rails-App | config/routes.rb | Rails.application.routes.draw do
root to: "welcome#home"
devise_for :users, controllers: {
omniauth_callbacks: 'omniauth' }
get '/signup' => 'users#new'
post '/signup' => 'users#create'
resources :messages
# Nested Routes
resources :users, only: [:show] do
resources :missions, only: [:new, :c... |
dannyflatiron/Rails-App | app/models/category.rb | <filename>app/models/category.rb<gh_stars>0
class Category < ApplicationRecord
has_many :missions
validates :name, presence: true, format: { with: /\A[a-zA-Z]+\z/,
message: "Only letters allowed" }
end
|
dannyflatiron/Rails-App | app/models/mission.rb | class Mission < ApplicationRecord
belongs_to :user #gives the reader and writer method
belongs_to :category
has_many :messages, dependent: :delete_all
has_many :users, through: :messages #gives only the writer method for the plural
validates :content, :title, presence: true
scope :alphabetical_order, -> {... |
dannyflatiron/Rails-App | app/controllers/missions_controller.rb | <reponame>dannyflatiron/Rails-App
class MissionsController < ApplicationController
before_action :authenticate_user!
def index
if params[:user_id] && @user = User.find_by_id(params[:user_id])
@missions = @user.missions.alphabetical_order
else
@error = "That user does not exist" if ... |
dannyflatiron/Rails-App | app/models/user.rb | <reponame>dannyflatiron/Rails-App
class User < ApplicationRecord
has_many :missions, dependent: :delete_all
has_many :categories, through: :missions, dependent: :delete_all
has_many :messages, dependent: :delete_all
has_many :messaged_missions, through: :messages, source: :mission, dependent: :delete_all
# I... |
dannyflatiron/Rails-App | app/helpers/messages_helper.rb | module MessagesHelper
def index_display_header
end
end
|
dannyflatiron/Rails-App | app/controllers/messages_controller.rb | class MessagesController < ApplicationController
before_action :authenticate_user!
before_action :set_message, only: [:show]
def index
if params[:mission_id] && @mission = Mission.find_by_id(params[:mission_id])
@messages = @mission.messages
else
@error = "That mission does not ex... |
opti/street-address | test/test_street_address.rb | <filename>test/test_street_address.rb
require 'test/unit'
require 'street_address'
class StreetAddressUsTest < Test::Unit::TestCase
def setup
@addr1 = "2730 S Veitch St Apt 207, Arlington, VA 22206"
@addr2 = "44 Canal Center Plaza Suite 500, Alexandria, VA 22314"
@addr3 = "1600 Pennsylvania Ave Washingt... |
idynkydnk/mastermind | lib/mastermind/computer.rb | module Mastermind
class Computer
@@password = []
@feedback = []
@guesses = 0
@possible_codes =*("0000".."5555")
def self.password
<PASSWORD>
end
def self.feedback
@feedback
end
def self.choose_password colors
(0..3).each do |i|
@@password[i] = colors.s... |
idynkydnk/mastermind | spec/feedback_cell_spec.rb | <filename>spec/feedback_cell_spec.rb<gh_stars>0
require_relative "spec_helper"
module Mastermind
describe FeedbackCell do
context "#initialize" do
it "is initialized with a value of '' by default" do
cell = FeedbackCell.new
expect(cell.color).to eq("")
end
it "can be in... |
idynkydnk/mastermind | lib/mastermind/test.rb | @possible_codes =*("0000".."5555")
$colors = ["blue", "green", "purple", "red", "yellow", "Orange"]
def not_possible_codes(feedback, guess)
puts "We're in the method now"
not_possible = {one: "", two: "", three: "", four: ""}
new_possible_codes = []
guess = colors_to_numbers(guess)
temp_code = guess
put... |
idynkydnk/mastermind | lib/mastermind/player.rb | module Mastermind
class Player
@guess = []
@code = []
def self.guess
@guess
end
def self.code
@code
end
def self.code=(code)
@code
end
def self.get_guess colors
puts "Available colors: " + colors.join(", ")
print "Guess the code: "
@gues... |
idynkydnk/mastermind | lib/mastermind/play.rb | <reponame>idynkydnk/mastermind
require_relative 'board'
module Mastermind
my_board = Board.new
my_board.play
end
|
idynkydnk/mastermind | lib/mastermind/ui.rb | module Mastermind
class UI
def self.draw_board(cells, feedback_cells)
i = 0
cells.each_slice(4) do |main_row|
main_row.each do |cell|
if cell.color != ""
print " " + cell.color + " "
else
print " _ "
end
end
print " "
... |
idynkydnk/mastermind | spec/cell_spec.rb | <reponame>idynkydnk/mastermind
require_relative "spec_helper"
module Mastermind
describe Cell do
context "#initialize" do
it "is initialized with a value of '' by default" do
cell = Cell.new
expect(cell.color).to eq("")
end
it "can be initialized with a color" do
cell... |
idynkydnk/mastermind | lib/mastermind/board.rb | <filename>lib/mastermind/board.rb
require_relative 'cell'
require_relative 'ui'
require_relative 'feedback_cell'
require_relative 'computer'
require_relative 'player'
module Mastermind
$colors = ["blue", "green", "purple", "red", "yellow", "Orange"]
class Board
def initialize
@cells = []
... |
idynkydnk/mastermind | lib/mastermind.rb | require "mastermind/version"
module Mastermind
end
require_relative "./mastermind/cell.rb"
require_relative "./mastermind/feedback_cell.rb"
require_relative "./mastermind/board.rb"
require_relative "./mastermind/computer.rb"
require_relative "./mastermind/player.rb" |
idynkydnk/mastermind | spec/board_spec.rb | <filename>spec/board_spec.rb
require_relative "spec_helper"
module Mastermind
describe Board do
context "#initialize" do
it "is initializes a board with 40 cells" do
board = Board.new
expect(board.cells.size).to eq 40
end
end
context "#update_board" do
it "updates the... |
idynkydnk/mastermind | lib/mastermind/string.rb | <filename>lib/mastermind/string.rb
class String
def bg_black; "\e[40m#{self}\e[0m" end
def bg_red; "\e[41m#{self}\e[0m" end
def bg_green; "\e[42m#{self}\e[0m" end
def bg_blue; "\e[44m#{self}\e[0m" end
def bg_purple; "\e[45m#{self}\e[0m" end
def bg_gray; "\e[47m#{self}\... |
panterch/railsmplayer | vendor/rails/railties/lib/rails/rack/metal.rb | require 'active_support/ordered_hash'
module Rails
module Rack
class Metal
NotFoundResponse = [404, {}, []].freeze
NotFound = lambda { NotFoundResponse }
cattr_accessor :metal_paths
self.metal_paths = ["#{Rails.root}/app/metal"]
cattr_accessor :requested_metals
def self.meta... |
panterch/railsmplayer | vendor/rails/railties/guides/rails_guides.rb | pwd = File.dirname(__FILE__)
$: << pwd
$: << File.join(pwd, "../../activesupport/lib")
$: << File.join(pwd, "../../actionpack/lib")
require "action_controller"
require "action_view"
# Require rubygems after loading Action View
require 'rubygems'
begin
gem 'RedCloth', '>= 4.1.1'# Need exactly 4.1.1
rescue Gem::LoadE... |
panterch/railsmplayer | lib/mplayer.rb | <filename>lib/mplayer.rb
require 'thread'
require 'singleton'
class Mplayer
include Singleton
attr_accessor :recent, :log
def initialize( opts = '' )
@recent = [ DEFAULT_URL ]
@log = [ ]
debug 'initializing mplayer singleton'
ObjectSpace.define_finalizer self, Mplayer.create_finalizer(self)
... |
panterch/railsmplayer | config/deploy.rb | set :application, "project_zero"
role :app, "mieze.panter.local"
role :web, "mieze.panter.local"
role :db, "mieze.panter.local"
set :rails_env, 'production'
set :deploy_via, :remote_cache
set :git_enable_submodules, 1
set :scm, :git
set :default_run_options, { :pty => true }
set :repository, "<EMAIL>:panter/railsmpl... |
panterch/railsmplayer | vendor/rails/railties/guides/rails_guides/indexer.rb | <filename>vendor/rails/railties/guides/rails_guides/indexer.rb
module RailsGuides
class Indexer
attr_reader :body, :result, :level_hash
def initialize(body)
@body = body
@result = @body.dup
end
def index
@level_hash = process(body)
end
private
def process(string, curr... |
panterch/railsmplayer | app/controllers/commands_controller.rb | <filename>app/controllers/commands_controller.rb
class CommandsController < ApplicationController
Mplayer.instance.public_methods(false).grep(/[^=]$/).each do |method|
class_eval %{
def #{method}
Mplayer.instance.#{method}
render_nothing
end
}
end
def play
url = params[:... |
nezhyborets/AsyncNinja | AsyncNinja.podspec | <reponame>nezhyborets/AsyncNinja
Pod::Spec.new do |s|
s.name = 'AsyncNinja'
s.version = '1.4.0'
s.summary = 'A complete set of primitives for concurrency and reactive programming on Swift'
s.homepage = 'https://async.ninja'
s.license = { :type => ... |
denislaliberte/sobriquet | lib/sobriquet/command.rb | module Sobriquet
# Command hold value of the command
class Command
attr_reader :value, :alias, :description, :type
def initialize(data)
@value = data[0]
@alias = data[1]
@description = data[2]
@type = data[3]
end
end
end
|
denislaliberte/sobriquet | spec/command_collection_spec.rb | <gh_stars>0
require 'sobriquet'
include Sobriquet
RSpec.describe CommandCollection do
let(:command_data) do
['git status', 'gs', 'get the status of the git directory']
end
let(:persistance) do
instance_double('Persistance', 'workspace/path')
end
it 'add and get a new command' do
allow(persistanc... |
denislaliberte/sobriquet | sobriquet.gemspec | require File.join([File.dirname(__FILE__), 'lib', 'sobriquet', 'version.rb'])
spec = Gem::Specification.new do |s|
s.name = 'sobriquet'
s.description = 'sobiquet is a command line tool that help you to save quickly new shell alias variables'
s.version = Sobriquet::VERSION
s.author = '<NAME>'
s.email = '<EMAIL... |
denislaliberte/sobriquet | lib/sobriquet/persistance.rb | require 'CSV'
module Sobriquet
# Persistance handle interaction with the file system
class Persistance
def initialize(workspace)
@workspace = workspace
end
def get(type)
_title, *data = CSV.read(@workspace, 'rb', col_sep: ' | ')
data.map { |a| Command.new(a) }.select { |a| a.type == ... |
denislaliberte/sobriquet | lib/sobriquet.rb | <filename>lib/sobriquet.rb
require 'sobriquet/version.rb'
require 'sobriquet/persistance.rb'
require 'sobriquet/command.rb'
require 'sobriquet/command_collection.rb'
|
denislaliberte/sobriquet | lib/sobriquet/command_collection.rb | require 'mustache'
require 'yaml'
module Sobriquet
# Contain a collection of commands
class CommandCollection
def initialize(persistance)
@persistance = persistance
@commands = []
@title = %w(command alias description type)
end
def get
@commands
end
def add(data)
... |
denislaliberte/sobriquet | spec/persistance_spec.rb | require 'sobriquet'
include Sobriquet
RSpec.describe Persistance do
let(:title) do
%w(command alias description type)
end
let(:csv) do
'command | alias | description | type
"git status" | gs | "get the status of the git directory" | command
"origin master" | om | "no description" | variable
'
end
le... |
ph/logstash-input-kafka | spec/inputs/kafka_spec.rb | # encoding: utf-8
require 'spec_helper'
describe 'inputs/kafka' do
let (:kafka_config) {{'topic_id' => 'test'}}
it "should register" do
input = LogStash::Plugin.lookup("input", "kafka").new(kafka_config)
expect {input.register}.to_not raise_error
end
it 'should populate kafka config with default val... |
POSpulse/harmonizer_redis | lib/harmonizer_redis/idf_scorer.rb | module HarmonizerRedis
module IdfScorer
# class self
class << self
def add_document(phrase_id)
self.incr_doc_count
text = HarmonizerRedis::Phrase.get_content(phrase_id)
word_set = Set.new
text.split.each do |word|
unless word_set.include? word
word_s... |
POSpulse/harmonizer_redis | lib/harmonizer_redis/base_object.rb | <reponame>POSpulse/harmonizer_redis<filename>lib/harmonizer_redis/base_object.rb
module HarmonizerRedis
class BaseObject
attr_accessor :id
def generate_id
Redis.current.incr("#{self.class}").to_i - 1
end
def save
#creates a new id only when object is being saved
klass = "#{self.cla... |
POSpulse/harmonizer_redis | lib/harmonizer_redis/phrase.rb | module HarmonizerRedis
class Phrase < BaseObject
attr_accessor :content
def initialize(content)
@content = content
end
def save
super()
HarmonizerRedis::IdfScorer.add_document(@id)
Redis.current.set("#{self.class}:[#{@content}]", "#{@id}")
end
class << self
def... |
POSpulse/harmonizer_redis | spec/tfidf_table_spec.rb | <reponame>POSpulse/harmonizer_redis<filename>spec/tfidf_table_spec.rb
require 'spec_helper'
describe HarmonizerRedis::IdfScorer do
before :all do
Redis.current = Redis.new
end
before :each do
Redis.current.flushall
phrases = ['this this is test', 'test is this', 'this is testing']
phrases.each_w... |
POSpulse/harmonizer_redis | spec/benchmark_spec.rb | require 'spec_helper'
require 'benchmark'
describe 'Benchmarking' do
before :all do
Redis.current = Redis.new(:driver => :hiredis)
end
before :each do
Redis.current.flushall
@to_add = []
file = File.open('/Users/tianwang/Documents/POSpulse/shopscout_data/douglas/all.txt', 'r')
file.each_line... |
POSpulse/harmonizer_redis | lib/harmonizer_redis/category.rb | module HarmonizerRedis
class Category < BaseObject
attr_reader :id
def initialize(id)
@id = id
end
def save
super()
end
class << self
# Add linkage to category group
def add_linkage(linkage)
category_id = linkage.category_id
linkage_id = linkage.id
... |
POSpulse/harmonizer_redis | ext/white_similarity/extconf.rb | require 'mkmf'
$CFLAGS = '--std=c99 -O'
create_makefile('harmonizer_redis/white_similarity')
|
POSpulse/harmonizer_redis | spec/linkage_spec.rb | require 'spec_helper'
describe HarmonizerRedis::Linkage do
before :all do
Redis.current = Redis.new
end
before :each do
Redis.current.flushall
@linkage = HarmonizerRedis::Linkage.new(content: 'testing', category_id: 3)
end
it '#new' do
expect(@linkage).to be_instance_of(HarmonizerRedis::Lin... |
POSpulse/harmonizer_redis | lib/harmonizer_redis.rb | require 'harmonizer_redis/version'
require 'harmonizer_redis/base_object'
require 'harmonizer_redis/linkage'
require 'harmonizer_redis/phrase'
require 'harmonizer_redis/idf_scorer'
require 'harmonizer_redis/white_similarity'
require 'harmonizer_redis/category'
require 'active_support/all'
require 'redis/connection/hire... |
POSpulse/harmonizer_redis | lib/harmonizer_redis/linkage.rb | <gh_stars>0
module HarmonizerRedis
class Linkage < BaseObject
attr_reader :id
def generate_id
SecureRandom.uuid
end
def initialize(params={})
@content = params[:content]
@category_id = params[:category_id]
end
def save # make sure that new phrase is saved
# if phrase... |
POSpulse/harmonizer_redis | spec/integration_spec.rb | <reponame>POSpulse/harmonizer_redis
require 'spec_helper'
describe 'Integration Tests' do
before :all do
Redis.current = Redis.new(driver: :hiredis)
end
before :each do
Redis.current.flushall
data = [['Abcd.zzz', 1], ['abcDzzz', 1], ['abcdefg', 1],
['hijk lmnop', 1], ['abcd zzz', 2], ['z... |
POSpulse/harmonizer_redis | test/manual.rb | <gh_stars>0
require 'harmonizer_redis'
Redis.current = Redis.new(:driver => :hiredis)
Redis.current.flushall
douglas_path = '/Users/tianwang/Documents/POSpulse/shopscout_data/douglas/all.txt'
ey_path = '/Users/tianwang/Documents/POSpulse/shopscout_data/ey/raw_store_name_input.txt'
to_add = []
file = File.open(ey_path... |
rollbar/resque-rollbar | spec/spec_helper.rb | require "rubygems"
require "bundler/setup"
require "resque"
require "resque-rollbar"
|
rollbar/resque-rollbar | lib/resque-rollbar.rb | require "resque-rollbar/version"
require "resque/failure/rollbar"
require "resque/rollbar" |
rollbar/resque-rollbar | lib/resque/failure/rollbar.rb | <gh_stars>0
module Resque
module Failure
class Rollbar < Base
def save
::Rollbar.report_exception(exception, payload)
end
end
end
end
|
rollbar/resque-rollbar | lib/resque/rollbar.rb | module Resque
class Worker
alias_method :initialize_original, :initialize
def initialize(queues = [], options = {})
# Force synchronous reporting
::Rollbar.configure do |config|
config.use_async = false
end
initialize_original queues, options
end
end
end
|
rollbar/resque-rollbar | lib/resque-rollbar/version.rb | <reponame>rollbar/resque-rollbar<gh_stars>0
module Resque
module Rollbar
VERSION = "0.0.1"
end
end
|
rollbar/resque-rollbar | spec/resque/failure/rollbar_spec.rb | <reponame>rollbar/resque-rollbar
describe Resque::Failure::Rollbar do
it "notifies" do
exception = StandardError.new("BOOM")
worker = Resque::Worker.new(:test)
queue = "test"
payload = {'class' => Object, 'args' => 66}
::Rollbar = mock("rollbar")
::Rollbar.should_receive(:report_exception).wi... |
yusayusa/HighlightTextView | HighlightTextView.podspec | Pod::Spec.new do |spec|
spec.name = "HighlightTextView"
spec.version = "0.6.0"
spec.summary = "Highlight TextView."
spec.homepage = "https://github.com/yusayusa/HighlightTextView"
spec.license = "MIT"
spec.author = { "yusayusa" => "<EMAIL>" }
spec.swift_version = "5... |
grokify/glip-sdk-ruby | glip_sdk.gemspec | lib = 'glip_sdk'
lib_file = File.expand_path("../lib/#{lib}.rb", __FILE__)
File.read(lib_file) =~ /\bVERSION\s*=\s*["'](.+?)["']/
version = $1
#require File.expand_path('../lib/ringcentral_sdk/version', __FILE__)
Gem::Specification.new do |s|
s.name = lib
s.version = version
s.date = '2017-03-1... |
grokify/glip-sdk-ruby | lib/glip_sdk/rest/client.rb | <filename>lib/glip_sdk/rest/client.rb
require 'multi_json'
require 'glip_sdk/rest/cache/groups'
module GlipSdk
module REST
class Client
attr_accessor :api
attr_accessor :logger
attr_accessor :groups
attr_accessor :groups_cache
attr_accessor :persons
attr_accessor :posts
... |
grokify/glip-sdk-ruby | lib/glip_sdk/rest/cache.rb | <gh_stars>0
module GlipSdk
module REST
module Cache
autoload :Groups, 'glip_sdk/rest/cache/groups'
end
end
end
|
grokify/glip-sdk-ruby | lib/glip_sdk.rb | module GlipSdk
VERSION = '0.0.5'.freeze
autoload :REST, 'glip_sdk/rest'
class << self
def new(client, opts = {})
GlipSdk::REST::Client.new client, opts
end
end
end
|
grokify/glip-sdk-ruby | lib/glip_sdk/rest/persons.rb | <reponame>grokify/glip-sdk-ruby
module GlipSdk
module REST
class Persons
def initialize(rc_sdk)
@api = rc_sdk
end
def get(opts = {})
if opts.key? :personId
return @api.http.get "glip/persons/#{opts[:personId]}"
end
nil
end
end
end
end
|
grokify/glip-sdk-ruby | lib/glip_sdk/rest/cache/groups.rb | module GlipSdk::REST::Cache
class Groups
attr_accessor :groups
attr_accessor :groups_name2id
attr_accessor :teams
attr_accessor :teams_name2id
def initialize
@groups = {}
@teams = {}
@teams_name2id = {}
@groups_name2id = {}
end
def load_groups(groups)
if grou... |
grokify/glip-sdk-ruby | lib/glip_sdk/rest/groups.rb | <filename>lib/glip_sdk/rest/groups.rb
module GlipSdk
module REST
class Groups
attr_accessor :cache
attr_accessor :subscription
def initialize(rc_sdk)
@api = rc_sdk
end
def get(opts = {})
if opts.key? :groupId
return @api.http.get "glip/groups/#{opts[:group... |
grokify/glip-sdk-ruby | lib/glip_sdk/rest/posts.rb | require 'multi_json'
module GlipSdk
module REST
class Posts
attr_accessor :groups_cache
def initialize(rc_sdk)
@api = rc_sdk
@logger_prefix = " -- #{self.class.name}: "
end
def post(opts = {})
unless opts.key? :text
raise ArgumentError, "Text must be pr... |
grokify/glip-sdk-ruby | scripts/groups.rb | #!ruby
require 'dotenv'
require 'logger'
require 'multi_json'
require 'ringcentral_sdk'
require 'glip_sdk'
Dotenv.load
rc = RingCentralSdk::REST::Client.new do |config|
config.server_url = ENV['RC_SERVER_URL']
config.app_key = ENV['RC_APP_KEY']
config.app_secret = ENV['RC_APP_SECRET']
config.username = ENV[... |
grokify/glip-sdk-ruby | lib/glip_sdk/rest.rb | module GlipSdk
# REST is the namespace for the RingCentral REST API class in the
# RingCentral Ruby SDK
module REST
autoload :Cache, 'glip_sdk/rest/cache'
autoload :Client, 'glip_sdk/rest/client'
autoload :Groups, 'glip_sdk/rest/groups'
autoload :Persons, 'glip_sdk/rest/persons'
autoload :Post... |
ffknob/logstash-output-rocketchat | lib/logstash/outputs/rocketchat.rb | <gh_stars>0
# encoding: utf-8
require "logstash/outputs/base"
require "logstash/namespace"
# Rocket.Chat is free, unlimited and open source. Replace email, HipChat & Slack with the ultimate team chat software solution.
#
# This Logstash output plugin allows to send events as messages to channels and groups of a Rocket... |
ffknob/logstash-output-rocketchat | logstash-output-rocketchat.gemspec | Gem::Specification.new do |s|
s.name = 'logstash-output-rocketchat'
s.version = '0.1.3'
s.licenses = ['Apache-2.0']
s.summary = 'Sends messages to a Rocketchat server with information from the events.'
s.description = 'Rocket.Chat is the leading open source team chat software solut... |
indirect/rails-footnotes | spec/controllers/log_note_controller_spec.rb | <filename>spec/controllers/log_note_controller_spec.rb<gh_stars>10-100
require 'spec_helper'
require 'stringio'
describe 'log note', type: :controller do
class ApplicationController < ActionController::Base
end
controller do
def index
Rails.logger.error 'foo'
Rails.logger.warn 'bar'
rende... |
indirect/rails-footnotes | lib/rails-footnotes/filter.rb | <gh_stars>10-100
module Footnotes
class Filter
@@no_style = false
@@multiple_notes = false
@@klasses = []
@@lock_top_right = false
@@font_size = '11px'
# Default link prefix is textmate
@@prefix = 'txmt://open?url=file://%s&line=%d&column=%d'
# Edit notes
@@notes = [ :con... |
indirect/rails-footnotes | lib/rails-footnotes/notes/view_note.rb | module Footnotes
module Notes
class ViewNote < AbstractNote
cattr_accessor :template
def self.start!(controller)
@subscriber ||= ActiveSupport::Notifications.subscribe('render_template.action_view') do |*args|
event = ActiveSupport::Notifications::Event.new *args
self.temp... |
indirect/rails-footnotes | lib/rails-footnotes/notes/files_note.rb | module Footnotes
module Notes
class FilesNote < AbstractNote
def initialize(controller)
@files = scan_text(controller.response.body)
parse_files!
end
def row
:edit
end
def content
if @files.empty?
""
else
"<ul><li>%s</li><... |
indirect/rails-footnotes | spec/notes/assigns_note_spec.rb | require "spec_helper"
require 'action_controller'
require "rails-footnotes/notes/assigns_note"
describe Footnotes::Notes::AssignsNote do
let(:note) do
@controller = double
allow(@controller).to receive(:instance_variables).and_return([:@action_has_layout, :@status])
@controller.instance_variable_set(:@ac... |
indirect/rails-footnotes | lib/rails-footnotes.rb | <filename>lib/rails-footnotes.rb
require 'rails'
require 'action_controller'
require 'rails-footnotes/abstract_note'
require 'rails-footnotes/each_with_rescue'
require 'rails-footnotes/filter'
require 'rails-footnotes/notes/all'
require 'rails-footnotes/extension'
module Footnotes
mattr_accessor :before_hooks
@@be... |
indirect/rails-footnotes | spec/notes/view_note_spec.rb | <reponame>indirect/rails-footnotes<filename>spec/notes/view_note_spec.rb
require "spec_helper"
require "rails-footnotes/notes/view_note"
describe Footnotes::Notes::ViewNote do
it "should not be valid if view file not exist" do
note = Footnotes::Notes::ViewNote.new(double)
allow(note).to receive(:filename).an... |
indirect/rails-footnotes | lib/rails6-footnotes.rb | require_relative "./rails-footnotes"
|
indirect/rails-footnotes | lib/rails-footnotes/extension.rb | require 'active_support/concern'
module Footnotes
module RailsFootnotesExtension
extend ActiveSupport::Concern
included do
prepend_before_action :rails_footnotes_before_filter
after_action :rails_footnotes_after_filter
end
def rails_footnotes_before_filter
Footnotes::Filter.start!... |
indirect/rails-footnotes | rails-footnotes.gemspec | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "rails-footnotes/version"
Gem::Specification.new do |s|
s.name = "rails-footnotes"
s.version = Footnotes::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["<NAME>", "<NAME>", "<NAME>", "<NAME>", "<NAME>", "<NA... |
dpep/ruby_gem_template | spec/spec_helper.rb | <reponame>dpep/ruby_gem_template
require "byebug"
require "rspec"
require "simplecov"
SimpleCov.start do
add_filter /spec/
end
if ENV["CI"] == "true" || ENV["CODECOV_TOKEN"]
require "codecov"
SimpleCov.formatter = SimpleCov::Formatter::Codecov
end
# load this gem
gem_name = Dir.glob("*.gemspec")[0].split(".")[... |
dpep/ruby_gem_template | lib/MY_NEW_GEM.rb | <filename>lib/MY_NEW_GEM.rb
require "MY_NEW_GEM/version"
module MY_NEW_GEM
end
|
shjang7/Enumerable | lib/enumerable.rb | # frozen_string_literal: true
module Enumerable
def my_each
return (is_a? Enumerator) ? self : to_enum(:my_each) unless block_given?
for x in self
yield(x)
end
end
def my_each_with_index
return to_enum(:my_each_with_index) unless block_given?
i = 0
my_each do |x|
yield(x, i... |
heaptracetechnology/yaml | app.rb | #!/usr/bin/env ruby
require 'json'
require 'sinatra'
require "sinatra/namespace"
require 'yaml'
set :port, 8080
set :bind, '0.0.0.0'
set :show_exceptions, false
post '/format' do
data = JSON.parse request.body.read
YAML.dump(data['data'])
end
namespace '/parse' do
before do
content_type :json
end
pos... |
michaelvobrien/furigana | lib/furigana/formatter/html.rb | module Furigana
module Formatter
class HTML < Formatter::Base
def replacement(surface_form, reading)
"<ruby><rb>%s</rb><rp>【</rp><rt>%s</rt><rp>】</rp></ruby>" % [surface_form, reading]
end
end
end
end
|
michaelvobrien/furigana | lib/furigana/formatter/json.rb | require 'json'
module Furigana
module Formatter
class JSON < Formatter::Base
def render
@kanji_tokens.to_json
end
end
end
end
|
michaelvobrien/furigana | lib/furigana/formatters.rb | require_relative 'formatter/base'
require_relative 'formatter/text'
require_relative 'formatter/yomikata'
require_relative 'formatter/html'
require_relative 'formatter/json'
|
michaelvobrien/furigana | lib/furigana/formatter/text.rb | module Furigana
module Formatter
class Text < Formatter::Base
def replacement(surface_form, reading)
"%s【%s】" % [surface_form, reading]
end
end
end
end
|
michaelvobrien/furigana | test/reader_test.rb | <filename>test/reader_test.rb
# -*- coding: utf-8 -*-
require 'test_helper'
class ReaderTest < Test::Unit::TestCase
test "食べる" do
text = "食べる"
expected = [['食', 'た']]
assert_equal expected, Furigana::Reader.new.reading(text)
end
test "勉強" do
text = "勉強"
expected = [['勉強', 'べんきょう']]
assert... |
michaelvobrien/furigana | test/html_formatter_test.rb | <gh_stars>10-100
# -*- coding: utf-8 -*-
require 'test_helper'
class HTMLFormatterTest < Test::Unit::TestCase
test "食べる" do
text = "食べる"
expected = "<ruby><rb>食</rb><rp>【</rp><rt>た</rt><rp>】</rp></ruby>べる"
assert_equal expected, Furigana::Formatter::HTML.new(text, Furigana::Reader.new.reading(text)).rend... |
michaelvobrien/furigana | lib/furigana/formatter/base.rb | module Furigana
module Formatter
class Base
SURFACE_FORM, READING = 0, 1
def initialize(text, kanji_tokens)
@text = text
@kanji_tokens = kanji_tokens
end
def render
reset
@text.each_char do |char|
if no_more_kanji_tokens?
@new_text +... |
michaelvobrien/furigana | lib/furigana/reader.rb | require 'diff/lcs'
require 'nkf'
module Furigana
class Reader
def reading(text)
Mecab.tokenize(text).reduce([]) do |list, token|
with_reading = add_reading(token)
list += with_reading if with_reading
list
end
end
private
def k2h(k)
return nil if k.nil?
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.