repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
megorei/motionkit-example | app/views/example_motion_kit_layout.rb | class ExampleMotionKitLayout < MotionKit::Layout
def layout
root :root do
add UIImageView, :love
add UILabel, :we
add UILabel, :rubymotion
end
end
def root_style
backgroundColor UIColor.blackColor
end
def love_style
image UIImage.imageWithContentsOfFile("#{App.resources_pa... |
Seanyo89/Game_Hub | lib/biggest_video_game_companies_cli.rb | require 'open-uri'
require 'nokogiri'
require 'pry'
require_relative "./biggest_video_game_companies_cli/version"
require_relative './biggest_video_game_companies_cli/company'
require_relative './biggest_video_game_companies_cli/cli'
|
Seanyo89/Game_Hub | lib/biggest_video_game_companies_cli/company.rb | class BiggestVideoGameCompaniesCli::Company
attr_accessor :name, :position, :url
def self.today
self.scrape_companies
end
def self.scrape_companies
companies = []
companies << self.scrape_alltopeverything
companies
end
def self.alltopeverything
doc = Nokogiri::HTML(open("https://allt... |
Seanyo89/Game_Hub | lib/biggest_video_game_companies_cli/cli.rb | <filename>lib/biggest_video_game_companies_cli/cli.rb
class BiggestVideoGameCompaniesCli::Cli
def call
list_companies
menu
goodbye
end
def list_companies
put"10 Biggest Video Game Companies:"
@companies = BiggestVideoGameCompaniesCli::Company.today
@companies.each.with.index(... |
shaunmckinnon/scmcms | db/seeds.rb | <gh_stars>0
if Rails.env.development?
User.create! do |u|
u.email = '<EMAIL>'
u.password = '<PASSWORD>'
end
end |
shaunmckinnon/scmcms | config/routes.rb | <filename>config/routes.rb
Rails.application.routes.draw do
devise_for :users
root to: "home#index"
end
|
norcams/sensu-plugins-himlar | bin/check-file-missing.rb | <gh_stars>0
#! /usr/bin/env ruby
#
# check-file-exists
#
# DESCRIPTION:
# Simple file check
require 'sensu-plugin/check/cli'
class CheckFileExists < Sensu::Plugin::Check::CLI
option :file,
short: '-f /path/to/file',
long: '--file /path/to/file',
default: '/'
option :severity,
... |
norcams/sensu-plugins-himlar | bin/check-imagebuild.rb | <reponame>norcams/sensu-plugins-himlar<gh_stars>0
#! /usr/bin/env ruby
#
# check-imagebuild
#
# DESCRIPTION:
# check if imagebuild failed
#
require 'sensu-plugin/check/cli'
require 'jsonl'
class CheckImagebuild < Sensu::Plugin::Check::CLI
option :distro,
short: '-d distro'
def run
file = "/var/log/... |
norcams/sensu-plugins-himlar | lib/sensu-plugins-himlar.rb | require 'sensu-plugins-himlar/version'
|
norcams/sensu-plugins-himlar | sensu-plugins-himlar.gemspec | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'date'
require_relative 'lib/sensu-plugins-himlar'
Gem::Specification.new do |s|
s.name = 'sensu-plugins-himlar'
s.version = SensuPluginsHimlar::Version::VER_STRING
s.author = 'Norcam... |
norcams/sensu-plugins-himlar | bin/metrics-ceph.rb | #! /usr/bin/env ruby
#
# metrics-ceph
#
# DESCRIPTION:
# Overall ceph throughput
#
# OUTPUT:
# metric data
#
# PLATFORMS:
# Linux
#
# DEPENDENCIES:
# gem: sensu-plugin
# gem: english
# ceph client
#
# USAGE:
# #YELLOW
#
# NOTES:
# Runs 'ceph status' command to output cluster status and metrics,
# May ... |
jrduncans/highcard | ruby/lib/cards.rb | # Copyright 2006 <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software... |
jrduncans/highcard | ruby/lib/highcard.rb | #!/usr/bin/env ruby
# Copyright 2006 <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
jrduncans/highcard | ruby/test/test_cards.rb | #!/usr/bin/ruby
# Copyright 2006 <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to ... |
jrduncans/highcard | ruby/spec/cards_spec.rb | $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'cards'
include Cards
describe Card, '(Ace of Clubs)' do
before(:each) do
@card = Card.new('Ace', 'Clubs')
end
it "should include 'ace' and 'clubs' in display" do
@card.to_s.should match(/\bace\b.+\bclubs\b/i)
end
it 'should equal anoth... |
maromaro0013/hakoirisolver-rails | ext/hakoirisolver/test.rb | <reponame>maromaro0013/hakoirisolver-rails<gh_stars>0
require "json"
require "./hakoirisolver.o"
stage0 = JSON.parse '{"framesize":{"w":4,"h":5},"endpoint":{"x":3,"y":5},"panels":[{"x":0,"y":0,"w":1,"h":2,"type":"common"},{"x":1,"y":0,"w":2,"h":2,"type":"target"},{"x":3,"y":0,"w":1,"h":2,"type":"common"},{"x":0,"y":2,... |
maromaro0013/hakoirisolver-rails | hakoirisolver-rails.gemspec | <reponame>maromaro0013/hakoirisolver-rails
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'hakoirisolver/rails/version'
Gem::Specification.new do |spec|
spec.name = "hakoirisolver-rails"
spec.version = Hakoirisolver::Rails::... |
maromaro0013/hakoirisolver-rails | ext/hakoirisolver/extconf.rb | <gh_stars>0
require "mkmf"
create_makefile("hakoirisolver/hakoirisolver")
|
maromaro0013/hakoirisolver-rails | lib/hakoirisolver/rails.rb | <filename>lib/hakoirisolver/rails.rb<gh_stars>0
require "hakoirisolver/rails/version"
require "hakoirisolver/hakoirisolver"
module Hakoirisolver
module Rails
# Your code goes here...
end
end
|
crushton/acmetools | udplog4jr/udplog4jr.rb | <gh_stars>1-10
#!/usr/bin/env ruby
###
## Copyright (c) 2012, <NAME>
##
## Permission to use, copy, modify, and distribute this software for any
## purpose with or without fee is hereby granted, provided that the above
## copyright notice and this permission notice appear in all copies.
##
## THE SOFTWARE IS PROVIDED "... |
zeroc0d3/deploy-laravel | config/deploy.rb | # config valid for current version and patch releases of Capistrano
lock "~> 3.11.2"
set :application, "myapp-deploy"
set :repo_url, "<EMAIL>:zeroc0d3/deploy-laravel.git"
# Default branch is :master
set :branch, "dev-master"
set :source, "src"
# Default deploy_to directory is /var/www/my_app_name
set :root_path, "/v... |
zeroc0d3/deploy-laravel | config/deploy/myapp-staging.rb | ask(:password, nil, echo: false)
# Unsecure Deploy
# server '192.168.127.12', user: 'u5780022', roles: %w{app web db}
# Secure Deploy
server '192.168.127.12', user: 'root', port: 22, roles: %w{app web db}
set :application, "myapp-deploy"
set :repo_url, "<EMAIL>:zeroc0d3/deploy-laravel.git"
# Default branch is :maste... |
Dreamle/WBZImportInvoice | WBZImportInvoice.podspec |
Pod::Spec.new do |s|
s.name = "WBZImportInvoice"
s.version = "0.0.16"
s.summary = "微报账项目集合微信和支付宝的卡包导入发票"
s.description = <<-DESC
微报账项目集合微信和支付宝的卡包导入发票,供别人方便使用
DESC
s.homepage = "https://github.com/Dreamle/WBZImportInvoice"
s.license = 'MIT'
s.... |
YUUKIToriyama/miopon-api | main.rb | <filename>main.rb
#!/usr/bin/ruby
require 'net/http'
require 'json'
uri = URI.parse("https://api.iijmio.jp/mobile/d/v2/log/packet/")
req = Net::HTTP::Get.new(uri)
req["X-IIJmio-Developer"] = open("./.developer_id").read
req["X-IIJmio-Authorization"] = open("./.access_token").read
https = Net::HTTP.new(uri.host, uri... |
greensnark/re2 | spec/re2_spec.rb | <gh_stars>0
require "spec_helper"
describe RE2 do
describe "#Replace" do
it "only replaces the first occurrence of the pattern" do
RE2.Replace("woo", "o", "a").must_equal("wao")
end
it "performs replacement based on regular expressions" do
RE2.Replace("woo", "o+", "e").must_equal("we")
e... |
greensnark/re2 | spec/re2/match_data_spec.rb | <gh_stars>0
# -*- coding: utf-8 -*-
require "spec_helper"
describe RE2::MatchData do
describe "#to_a" do
it "is populated with the match and capturing groups" do
a = RE2::Regexp.new('w(o)(o)').match('woo').to_a
a.must_equal(["woo", "o", "o"])
end
it "populates optional capturing groups with... |
greensnark/re2 | spec/kernel_spec.rb | <gh_stars>0
require "spec_helper"
describe Kernel do
describe "#RE2" do
it "returns an RE2::Regexp instance given a pattern" do
RE2('w(o)(o)').must_be_instance_of(RE2::Regexp)
end
it "returns an RE2::Regexp instance given a pattern and options" do
re = RE2('w(o)(o)', :case_sensitive => false... |
greensnark/re2 | ext/re2/extconf.rb | # re2 (http://github.com/mudge/re2)
# Ruby bindings to re2, an "efficient, principled regular expression library"
#
# Copyright (c) 2010-2012, <NAME> (http://mudge.name)
# Released under the BSD Licence, please see LICENSE.txt
require 'mkmf'
incl, lib = dir_config("re2", "/usr/local/include", "/usr/local/lib")
$CFLA... |
greensnark/re2 | spec/re2/consumer_spec.rb | <reponame>greensnark/re2
require "spec_helper"
describe RE2::Consumer do
describe "#regexp" do
it "returns the original pattern for the consumer" do
re = RE2::Regexp.new('(\w+)')
consumer = re.consume("It is a truth")
consumer.regexp.must_be_same_as(re)
end
end
describe "#string" do
... |
greensnark/re2 | spec/re2/regexp_spec.rb | <reponame>greensnark/re2
# -*- coding: utf-8 -*-
require "spec_helper"
describe RE2::Regexp do
describe "#initialize" do
it "returns an instance given only a pattern" do
re = RE2::Regexp.new('woo')
re.must_be_instance_of(RE2::Regexp)
end
it "returns an instance given a pattern and options" d... |
greensnark/re2 | re2.gemspec | Gem::Specification.new do |s|
s.name = "re2"
s.summary = "Ruby bindings to re2."
s.description = 'Ruby bindings to re2, "an efficient, principled regular expression library".'
s.version = "0.6.0.pre"
s.authors = ["<NAME>"]
s.homepage = "http://github.com/mudge/re2"
s.email = "<EMAIL>"
s.extensions = ["e... |
greensnark/re2 | spec/re2/string_spec.rb | <gh_stars>0
require "spec_helper"
require "re2/string"
class String
include RE2::String
end
describe RE2::String do
describe "#re2_sub!" do
it "delegates to RE2.Replace to perform replacement" do
"My name is <NAME>".re2_sub!('Robert', 'Crobert').must_equal("My name is <NAME>")
end
it "does perf... |
greensnark/re2 | lib/re2/consumer.rb | <reponame>greensnark/re2<filename>lib/re2/consumer.rb<gh_stars>0
module RE2
class Consumer
include Enumerable
def each
if block_given?
while matches = consume
yield matches
end
else
to_enum(:each)
end
end
end
end
|
aidantwoods/secure_headers | spec/lib/secure_headers/middleware_spec.rb | <gh_stars>0
# frozen_string_literal: true
require "spec_helper"
module SecureHeaders
describe Middleware do
let(:app) { lambda { |env| [200, env, "app"] } }
let(:cookie_app) { lambda { |env| [200, env.merge("Set-Cookie" => "foo=bar"), "app"] } }
let(:middleware) { Middleware.new(app) }
let(:cookie_m... |
aidantwoods/secure_headers | spec/lib/secure_headers/headers/policy_management_spec.rb | # frozen_string_literal: true
require "spec_helper"
module SecureHeaders
describe PolicyManagement do
before(:each) do
reset_config
Configuration.default
end
let (:default_opts) do
{
default_src: %w(https:),
img_src: %w(https: data:),
script_src: %w('unsafe-inli... |
aidantwoods/secure_headers | lib/secure_headers/headers/policy_management.rb | # frozen_string_literal: true
module SecureHeaders
module PolicyManagement
def self.included(base)
base.extend(ClassMethods)
end
DEFAULT_CONFIG = {
default_src: %w(https:),
img_src: %w(https: data: 'self'),
object_src: %w('none'),
script_src: %w(https:),
style_src: %w(... |
Pazzik/barbershop | app.rb | require 'rubygems'
require 'sinatra'
require 'sinatra/reloader'
require 'sqlite3'
def get_db
db = SQLite3::Database.new 'barbershop.db'
db.results_as_hash = true
return db
end
def is_barber_exist? db,person
db.execute('select * from Persons where person=?',[person]).length > 0
end
def seed_db db, persons
perso... |
annomusa/MonoDylib | MonoDylib.podspec | <reponame>annomusa/MonoDylib<filename>MonoDylib.podspec<gh_stars>0
#
# Always run `pod lib lint MonoDylib.podspec' before pushing to git
# Syntax: https://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'MonoDylib'
s.version = '0.1.1'
s.summary = 'This pod c... |
kerven88/tubekit | tubekit.rb | <filename>tubekit.rb
class Tubekit < Formula
desc "Tool that helps you to operate Kubernetes clusters more effectively"
homepage "https://github.com/reconquest/tubekit"
url "https://github.com/reconquest/tubekit/releases/download/v3/tubekit_3_Darwin_x86_64.tar.gz"
sha256 "b966e7b014e0d16e22f0d15dbd7c80a084160c6... |
jackg0h/cookie-brutefocer | twitter.rb | require 'mechanize'
def run
found = "nope"
key = "auth_token"
url = "https://twitter.com"
agent = Mechanize.new
count = 0
while found == "nope" do
#value = SecureRandom.urlsafe_base64
value = SecureRandom.hex(20)
cookie = Mechanize::Cookie.new(key, value)
coo... |
ronin/payu | lib/payu.rb | # encoding: utf-8
require 'yaml'
require 'payu/version'
require 'payu/pos'
require 'payu/timestamp'
require 'payu/transaction'
require 'payu/response'
require 'payu/signature'
require 'payu/errors'
module Payu
ENCODINGS = ['ISO', 'WIN', 'UTF']
@@pos_table = {}
class SignatureInvalid < StandardError; end
cl... |
johanesteves/rails-workout-app | config/routes.rb | Rails.application.routes.draw do
devise_for :users, :controllers => { registrations: 'registrations', :omniauth_callbacks => "users/omniauth_callbacks" }
root 'application#index'
get 'workouts/current_week', to: 'workouts#current_week', as: 'workout_current_week'
resources :workouts
get 'workouts/:id/exerci... |
kandayo/likee | spec/integration/video_comments_spec.rb | <reponame>kandayo/likee
# frozen_string_literal: true
RSpec.describe 'Video Comments' do
before do
WebMock.allow_net_connect!
end
after do
WebMock.disable_net_connect!
end
it 'returns video comments' do
api = Likee::Api.new
collection = api.video_comments(video_id: '7025013457556632887')
... |
kandayo/likee | spec/integration/user_videos_spec.rb | <reponame>kandayo/likee<filename>spec/integration/user_videos_spec.rb
# frozen_string_literal: true
RSpec.describe 'Creator Videos' do
before do
WebMock.allow_net_connect!
end
after do
WebMock.disable_net_connect!
end
it 'returns creator videos' do
api = Likee::Api.new
collection = api.crea... |
kandayo/likee | spec/integration/trending_hashtags_spec.rb | <reponame>kandayo/likee
# frozen_string_literal: true
RSpec.describe 'Trending Hashtags' do
before do
WebMock.allow_net_connect!
end
after do
WebMock.disable_net_connect!
end
it 'returns trending hashtags' do
api = Likee::Api.new
collection = api.trending_hashtags
expect(collection).to ... |
kandayo/likee | lib/likee/mappings/hashtag_collection_mapping.rb | # frozen_string_literal: true
require_relative 'hashtag_mapping'
module Likee
class HashtagCollectionMapping
def self.call(data)
new(data).call
end
def initialize(data)
@data = data
freeze
end
def call
collection = data.dig('data', 'eventList')
return [] if collec... |
kandayo/likee | lib/likee/mappings/hashtag_mapping.rb | # frozen_string_literal: true
require_relative '../models/hashtag'
module Likee
class HashtagMapping
def self.call(data)
new(data).call
end
def initialize(data)
@data = data
freeze
end
def call
Hashtag.new(
id:,
name:,
videos_count:,
play... |
kandayo/likee | lib/likee/mappings/creator_mapping.rb | # frozen_string_literal: true
require_relative '../models/creator'
module Likee
class CreatorMapping
def self.call(data)
new(data).call
end
def initialize(data)
@data = data
freeze
end
def call
Creator.new(
id:,
username:,
nickname:,
avat... |
kandayo/likee | spec/factories/config.rb | # frozen_string_literal: true
FactoryBot.define do
factory :config, class: Likee::Configuration do
user_agent { 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' }
referer { 'https://likee.video/' }
custom_device_id { nil }
custom_user_id { nil }
open_timeout { 5 }
re... |
kandayo/likee | lib/likee/resources/comment_resource_collection.rb | # frozen_string_literal: true
require_relative 'resource_collection'
require_relative 'comment_resource'
module Likee
class CommentResourceCollection < ResourceCollection
def resource_class
CommentResource
end
def fetch_resource(cursor:)
api.video_comments(video_id: video.id, cursor:)
e... |
kandayo/likee | lib/likee/resources/video_resource_collection.rb | <reponame>kandayo/likee
# frozen_string_literal: true
require_relative 'resource_collection'
require_relative 'video_resource'
module Likee
class VideoResourceCollection < ResourceCollection
def resource_class
VideoResource
end
def fetch_resource(cursor:)
api.creator_videos(creator_id: crea... |
kandayo/likee | lib/likee/resources/creator_resource.rb | <reponame>kandayo/likee
# frozen_string_literal: true
require_relative 'resource'
require_relative 'video_resource_collection'
module Likee
class CreatorResource < Resource
def self.find(username, api:)
resource = api.find_creator(username)
new(api:, resource:)
end
def videos
@videos ... |
kandayo/likee | spec/likee/client_spec.rb | # frozen_string_literal: true
RSpec.describe Likee::Client do
let(:api) { double(:api) }
subject { described_class.new(api_class: api) }
describe '#find_creator' do
let(:creator) { build(:creator) }
let(:creator_videos_page1) { build_list(:video, 5) }
let(:creator_videos_page2) { build_list(:video,... |
kandayo/likee | lib/likee/resources/video_resource.rb | # frozen_string_literal: true
require_relative 'resource'
require_relative 'comment_resource_collection'
require_relative 'creator_resource'
module Likee
class VideoResource < Resource
def comments
@comments ||= CommentResourceCollection.new(api:, parent: self)
end
def creator
return parent... |
kandayo/likee | likee.gemspec | <reponame>kandayo/likee<gh_stars>1-10
# frozen_string_literal: true
require_relative 'lib/likee/version'
Gem::Specification.new do |spec|
spec.name = 'likee'
spec.version = Likee::VERSION
spec.authors = ['kandayo']
spec.email = ['<EMAIL>']
spec.summary = 'Likee API client for Ruby'
... |
kandayo/likee | spec/likee/mappings/comment_mapping_spec.rb | <reponame>kandayo/likee
# frozen_string_literal: true
RSpec.describe Likee::CommentMapping do
describe '#call' do
context 'comment with quote reply' do
let(:comment_data) { load_fixture('single_comment_with_reply') }
subject { described_class.new(comment_data) }
it 'parses the comment data' do... |
kandayo/likee | lib/likee/transport/exception_manager.rb | <reponame>kandayo/likee
# frozen_string_literal: true
module Likee
class Transport
class TransportError < StandardError
end
####
## Low level network errors
##
class ConnectionError < TransportError
end
class TimeoutError < ConnectionError
end
CONNECTION_ERROR_EXCEPTION_ME... |
kandayo/likee | spec/likee/instrumentation_spec.rb | # frozen_string_literal: true
RSpec.describe Likee::Instrumentation do
before do
described_class.clear
end
after do
described_class.clear
end
describe '#subscribe' do
it 'subscribes with block' do
callable = -> {}
described_class.subscribe('spec', &callable)
expect(described_c... |
kandayo/likee | lib/likee/transport.rb | <reponame>kandayo/likee<gh_stars>1-10
# frozen_string_literal: true
require 'net/http/persistent'
require_relative 'instrumentation'
require_relative 'transport/exception_manager'
require_relative 'transport/request'
require_relative 'transport/response'
require_relative 'util'
module Likee
class Transport
def... |
kandayo/likee | lib/likee/mappings/video_mapping.rb | # frozen_string_literal: true
require 'time'
require_relative '../models/snowflake'
require_relative '../models/video'
require_relative '../util'
module Likee
class VideoMapping
def self.call(data)
new(data).call
end
def initialize(data)
@data = data
freeze
end
def call
... |
kandayo/likee | lib/likee/client.rb | <gh_stars>1-10
# frozen_string_literal: true
require_relative 'resources/creator_resource'
require_relative 'resources/trending_videos_resource_collection'
require_relative 'api'
module Likee
class Client
def initialize(api_class: Likee::Api, **args)
@api = api_class.new(**args)
freeze
end
... |
kandayo/likee | spec/factories/creator.rb | <filename>spec/factories/creator.rb<gh_stars>1-10
# frozen_string_literal: true
FactoryBot.define do
factory :creator, class: Likee::Creator do
sequence(:id, &:to_s)
sequence(:username) { |n| "user_#{n}" }
nickname { 'Nickname' }
avatar_url { 'https://likee.video/no_avatar.png' }
country { 'RU' }... |
kandayo/likee | spec/likee/transport_spec.rb | # frozen_string_literal: true
RSpec.describe Likee::Transport do
let(:config) { build(:config) }
subject { described_class.new(config) }
describe '#get' do
it 'without query params' do
expected_request =
stub_request(:get, 'https://test.host/videos')
.with(
headers: {
... |
kandayo/likee | lib/likee/models/creator.rb | <reponame>kandayo/likee<gh_stars>1-10
# frozen_string_literal: true
module Likee
Creator = Struct.new(
:id,
:username,
:nickname,
:avatar_url,
:country,
:gender,
:birthday,
:star_sign,
:bio,
:likes_count,
:fans_count,
:following_count,
keyword_init: true
)
end
|
kandayo/likee | lib/likee/mappings/video_collection_mapping.rb | <gh_stars>1-10
# frozen_string_literal: true
require_relative 'video_mapping'
module Likee
class VideoCollectionMapping
def self.call(data)
new(data).call
end
def initialize(data)
@data = data
freeze
end
def call
collection = data.dig('data', 'videoList')
return [... |
kandayo/likee | spec/likee/mappings/hashtag_mapping_spec.rb | # frozen_string_literal: true
RSpec.describe Likee::HashtagMapping do
describe '#call' do
let(:hashtag_data) { load_fixture('single_hashtag_from_get_recommend_hashtag') }
subject { described_class.new(hashtag_data) }
it 'parses the hashtag data' do
hashtag = subject.call
expect(hashtag.id).... |
kandayo/likee | lib/likee/resources/trending_videos_resource_collection.rb | <filename>lib/likee/resources/trending_videos_resource_collection.rb<gh_stars>1-10
# frozen_string_literal: true
require_relative 'resource_collection'
require_relative 'video_resource'
module Likee
class TrendingVideosResourceCollection < ResourceCollection
def initialize(country:, language:, start:, **args)
... |
kandayo/likee | spec/likee/mappings/video_mapping_spec.rb | <reponame>kandayo/likee<filename>spec/likee/mappings/video_mapping_spec.rb
# frozen_string_literal: true
RSpec.describe Likee::VideoMapping do
describe '#call' do
context 'POST /likee-activity-flow-micro/videoApi/getUserVideo' do
context 'when cloudMusic attribute is present' do
let(:video_data) { ... |
kandayo/likee | lib/likee/transport/content_type.rb | <reponame>kandayo/likee
# frozen_string_literal: true
require 'uri'
require_relative '../util'
module Likee
module ContentType
class Entry
attr_reader :mime_type
def initialize(mime_type:, serializer:, deserializer:)
@mime_type = mime_type
@serializer = serializer
@deseriali... |
kandayo/likee | lib/likee/util.rb | # frozen_string_literal: true
require 'securerandom'
begin
require 'oj'
rescue LoadError
require 'json'
end
module Likee
module Util
class << self
def dump_json(hash)
if Object.const_defined?(:Oj)
Oj.dump(hash, mode: :compat)
else
hash.to_json
end
end... |
kandayo/likee | lib/likee/models/hashtag.rb | # frozen_string_literal: true
module Likee
Hashtag = Struct.new(
:id,
:name,
:videos_count,
:play_count,
keyword_init: true
)
end
|
kandayo/likee | spec/integration/user_profile_spec.rb | # frozen_string_literal: true
RSpec.describe 'Creator Profile' do
before do
WebMock.allow_net_connect!
end
after do
WebMock.disable_net_connect!
end
it 'finds a creator by username' do
api = Likee::Api.new
creator = api.find_creator('Likee_USA')
expect(creator.id).to eq('30007')
end
e... |
kandayo/likee | spec/support/fixtures.rb | <filename>spec/support/fixtures.rb
# frozen_string_literal: true
require 'oj'
module Fixture
def load_fixture(fixture_name)
Oj.load(load_fixture_raw(fixture_name))
end
def load_fixture_raw(fixture_name)
fixture_path = File.join(File.dirname(__FILE__), '..', 'fixtures', "#{fixture_name}.json")
File.... |
kandayo/likee | lib/likee/models/snowflake.rb | <filename>lib/likee/models/snowflake.rb
# frozen_string_literal: true
require 'time'
module Likee
class Snowflake
include Comparable
attr_reader :id, :timestamp
def initialize(id)
@id = id.is_a?(Integer) ? id : Integer(id)
@timestamp = Time.at(@id >> 32)
freeze
end
def <=>(o... |
kandayo/likee | lib/likee/transport/response.rb | <reponame>kandayo/likee
# frozen_string_literal: true
require_relative 'content_type'
module Likee
class Transport
class Response
attr_reader :status, :body
def self.from_net_http(net_http_response)
status = net_http_response.code
body = net_http_response.body
content_type =... |
kandayo/likee | spec/likee_spec.rb | <filename>spec/likee_spec.rb<gh_stars>1-10
# frozen_string_literal: true
RSpec.describe Likee do
describe '.build_api' do
it 'instantiates and return an Likee::Api instance' do
instance = double(:instance)
options = {
proxy: 'proxy.org'
}
expect(Likee::Api).to receive(:new).with(*... |
kandayo/likee | lib/likee/models/comment.rb | <filename>lib/likee/models/comment.rb
# frozen_string_literal: true
module Likee
Comment = Struct.new(
:id,
:created_at,
:user_id,
:user_username,
:user_nickname,
:user_avatar_url,
:content,
:reply_user_id,
:reply_user_nickname,
:reply_content,
:likes_count,
keyword_in... |
kandayo/likee | lib/likee/mappings/comment_mapping.rb | # frozen_string_literal: true
require_relative '../models/comment'
require_relative '../util'
module Likee
class CommentMapping
def self.call(data)
new(data).call
end
def initialize(data)
@data = data.freeze
end
def call
Comment.new(
id:,
created_at:,
... |
kandayo/likee | lib/likee/resources/resource_collection.rb | # frozen_string_literal: true
require_relative 'resource'
module Likee
class ResourceCollection < Resource
include Enumerable
def initialize(**args)
super
@cached_collection ||= {}
end
# @abstract Subclass is expected to implement #resource_class
# @!method resource_class
# T... |
kandayo/likee | lib/likee/instrumentation.rb | <reponame>kandayo/likee
# frozen_string_literal: true
require_relative 'util'
module Likee
class Instrumentation
class Event
attr_reader :duration, :http_status, :method, :url, :exception, :config
def initialize(duration:, http_status:, method:, url:, config:, exception: nil)
@duration = du... |
kandayo/likee | lib/likee/api.rb | <gh_stars>1-10
# frozen_string_literal: true
require_relative 'transport'
require_relative 'mappings/comment_collection_mapping'
require_relative 'mappings/creator_mapping'
require_relative 'mappings/hashtag_collection_mapping'
require_relative 'mappings/video_collection_mapping'
require_relative 'configuration'
requi... |
kandayo/likee | spec/likee/util_spec.rb | # frozen_string_literal: true
RSpec.describe Likee::Util do
describe '.dump_json' do
let(:hash) do
{ a: 1 }
end
context 'when Oj is defined' do
it 'dumps using Oj' do
allow(Object).to receive(:const_defined?).with(:Oj) { false }
expect(Oj).to_not receive(:dump)
expect... |
kandayo/likee | lib/likee/transport/request.rb | # frozen_string_literal: true
require_relative 'content_type'
module Likee
class Transport
class Request
attr_reader :uri, :method, :request_content_type, :body
def initialize(method:, endpoint:, query_params: {}, request_format: :plain, body: nil)
@uri = build_uri(endpoint, query_params:)
... |
kandayo/likee | spec/integration/hashtag_videos_spec.rb | # frozen_string_literal: true
RSpec.describe 'Hashtag Videos' do
before do
WebMock.allow_net_connect!
end
after do
WebMock.disable_net_connect!
end
it 'returns hashtag videos' do
api = Likee::Api.new
collection = api.hashtag_videos(hashtag_id: '7034231050079308729')
expect(collection).t... |
kandayo/likee | lib/likee/mappings/comment_collection_mapping.rb | # frozen_string_literal: true
require_relative 'comment_mapping'
module Likee
class CommentCollectionMapping
def self.call(data)
new(data).call
end
def initialize(data)
@data = data
freeze
end
def call
collection = data['data']
return [] if collection.nil? || !col... |
kandayo/likee | spec/factories/video.rb | <filename>spec/factories/video.rb
# frozen_string_literal: true
FactoryBot.define do
factory :video, class: Likee::Video do
sequence(:id, &:to_s)
uploaded_at { Time.now }
sequence(:creator_id, &:to_s)
sequence(:creator_username) { |n| "user_#{n}" }
creator_nickname { 'Creator Nickname' }
crea... |
kandayo/likee | spec/likee/mappings/creator_mapping_spec.rb | <gh_stars>1-10
# frozen_string_literal: true
RSpec.describe Likee::CreatorMapping do
describe '#call' do
let(:creator_data) { load_fixture('creator_profile_data') }
subject { described_class.new(creator_data) }
it 'parses the creator data' do
creator = subject.call
expect(creator.id).to eq(... |
kandayo/likee | lib/likee/configuration.rb | # frozen_string_literal: true
module Likee
class Configuration
attr_reader :user_agent, :referer, :custom_device_id, :custom_user_id,
:open_timeout, :read_timeout, :write_timeout,
:keep_alive_idle_timeout, :proxy
def initialize(
user_agent:,
referer:,
custom... |
kandayo/likee | spec/support/instrumentation.rb | # frozen_string_literal: true
RSpec.configure do |config|
def reset_instrumentation
Likee.instrumentation.clear
end
config.before(:suite) do
reset_instrumentation
end
config.before(:each) do
reset_instrumentation
end
end
|
kandayo/likee | lib/likee/resources/comment_resource.rb | <gh_stars>1-10
# frozen_string_literal: true
require_relative 'resource'
module Likee
class CommentResource < Resource
def video
parent
end
end
end
|
kandayo/likee | spec/likee/models/snowflake_spec.rb | # frozen_string_literal: true
RSpec.describe Likee::Snowflake do
describe '#timestamp' do
context 'when snowflake is a Integer' do
subject { described_class.new(6914348117433371910) }
it 'returns the timestamp' do
expect(subject.timestamp).to eq(Time.parse('2021-01-05T18:42:02Z'))
end
... |
kandayo/likee | lib/likee/resources/resource.rb | <reponame>kandayo/likee
# frozen_string_literal: true
module Likee
class Resource
def initialize(api:, resource: nil, parent: nil)
@api = api
@resource = resource
@parent = parent
end
def inspect
io = StringIO.new
io << self.class.name
if resource
io << '{'
... |
kandayo/likee | spec/factories/comment.rb | # frozen_string_literal: true
FactoryBot.define do
factory :comment, class: Likee::Comment do
sequence(:id, &:to_s)
created_at { Time.now }
sequence(:user_id, &:to_s)
sequence(:user_username) { |n| "user_#{n}" }
user_nickname { 'Creator Nickname' }
user_avatar_url { 'https://likee.video/no_av... |
kandayo/likee | lib/likee/models/video.rb | <reponame>kandayo/likee
# frozen_string_literal: true
module Likee
Video = Struct.new(
:id,
:uploaded_at,
:creator_id,
:creator_username,
:creator_nickname,
:creator_avatar_url,
:title,
:description,
:height,
:width,
:thumbnail_url,
:url,
:sound_id,
:sound_name... |
kandayo/likee | lib/likee.rb | <reponame>kandayo/likee
# frozen_string_literal: true
require_relative 'likee/api'
require_relative 'likee/client'
require_relative 'likee/version'
module Likee
class << self
# Builds an instance of the Likee API client.
#
# @param user_agent [String] the User-Agent header used by the library
#
... |
kandayo/likee | spec/likee/configuration_spec.rb | # frozen_string_literal: true
RSpec.describe Likee::Configuration do
subject do
described_class.new(
user_agent: 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
referer: 'https://likee.video/',
custom_device_id: '111',
custom_user_id: '222',
open_timeout:... |
kandayo/likee | examples/quickstart.rb | # frozen_string_literal: true
require 'likee'
# please refer to the documentation to find all available options
# the default options are sensible, however you might need a proxy depending
# on your use case
client = Likee.build_client
# 💃🏻 find a creator by username
creator = client.find_creator('charlidamelio')
... |
kronus/angular-ruby-2014-example | spec/spec_helper.rb | <reponame>kronus/angular-ruby-2014-example
require 'rubygems'
require 'spork'
require 'database_cleaner'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.... |
kronus/angular-ruby-2014-example | app/models/employee.rb | <gh_stars>10-100
class Employee < ActiveRecord::Base
validates_presence_of :first_name, on: :create
validates_presence_of :last_name, on: :create
validates_presence_of :email, on: :create
validates_presence_of :start_date, on: :create
end
|
kronus/angular-ruby-2014-example | db/seeds.rb | <reponame>kronus/angular-ruby-2014-example
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Cope... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.