source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/test_helper.rb | Ruby | mit | 98 | master | 1,028 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'jpush'
require 'minitest/autorun'
conf =
if File.exist? conf_file = File.expand_path('../config.yml', __FILE__)
require "yaml"
require "erb"
template = File.read(conf_file)
erb_result = ERB.new(template).result
YAML.load(erb_res... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/jpush_test.rb | Ruby | mit | 98 | master | 200 | require 'test_helper'
class JPushTest < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::JPush::VERSION
end
def test_it_does_something_useful
# assert false
end
end |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/jpush/schedule_test.rb | Ruby | mit | 98 | master | 1,849 | require_relative '../test_helper'
module JPush
class PushTest < JPush::Test
def setup
@audience = Push::Audience.new().set_registration_id($test_common_registration_id)
@push_payload = Push::PushPayload.new(platform: 'all', audience: @audience, notification: 'hello from schedule api')
@schedul... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/jpush/device_test.rb | Ruby | mit | 98 | master | 5,407 | require_relative '../test_helper'
module JPush
class DeviceTest < JPush::Test
def setup
@devices = @@jpush.devices
end
def test_show
response = @devices.show($test_common_registration_id)
assert_equal 200, response.http_code
body = response.body
assert_true body.has_key?(... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/jpush/report_test.rb | Ruby | mit | 98 | master | 3,976 | require_relative '../test_helper'
module JPush
class ReportTest < JPush::Test
def setup
pusher = @@jpush.pusher
@audience = Push::Audience.new().set_registration_id($test_common_registration_id)
push_payload = Push::PushPayload.new(platform: 'all', audience: @audience, notification: 'hello fro... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/jpush/tag_test.rb | Ruby | mit | 98 | master | 5,115 | require_relative '../test_helper'
module JPush
class TagTest < JPush::Test
def setup
@tags = @@jpush.tags
end
def test_list
response = @tags.list
assert_equal 200, response.http_code
body = response.body
assert_equal 1, body.length
assert_true body.has_key?('tags')
... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/jpush/push_test.rb | Ruby | mit | 98 | master | 5,527 | require_relative '../test_helper'
module JPush
class PushTest < JPush::Test
def setup
@pusher = @@jpush.pusher
@audience = Push::Audience.new().set_registration_id($test_common_registration_id)
end
def test_validate
push_payload = Push::PushPayload.new(platform: 'all', audience: @audi... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/jpush/alias_test.rb | Ruby | mit | 98 | master | 1,895 | require_relative '../test_helper'
module JPush
class AliasTest < JPush::Test
def setup
@aliases = @@jpush.aliases
@devices = @@jpush.devices
end
def test_show
test_alias = 'TEST_ALIAS'
@devices.update_alias($test_common_registration_id, test_alias)
response = @aliases.sho... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/jpush/schedule/schedule_payload_test.rb | Ruby | mit | 98 | master | 1,729 | require_relative '../../test_helper'
module JPush
module Schedule
class SchedulePayloadTest < JPush::Test
def setup
@push_payload = Push::PushPayload.new(platform: 'all', audience: 'all', notification: 'hello')
end
def test_single
schedule_payload = SchedulePayload.new('jpush'... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/jpush/schedule/trigger_test.rb | Ruby | mit | 98 | master | 857 | require_relative '../../test_helper'
module JPush
module Schedule
class TriggerTest < JPush::Test
def setup
@trigger = Trigger.new
end
def test_single
trigger = @trigger.set_single(Time.now).to_hash
assert_instance_of Hash, trigger
assert_equal 1, trigger.size
... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/jpush/push/single_push_payload_test.rb | Ruby | mit | 98 | master | 1,150 | require_relative '../../test_helper'
module JPush
module Push
class SinglePushPayloadTest < JPush::Test
def setup
@hello_payload = SinglePushPayload.new(platform: 'all', target: 'hello')
end
def test_platform_and_target
single_push_payload = SinglePushPayload.new(
pl... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/jpush/push/audience_test.rb | Ruby | mit | 98 | master | 933 | require_relative '../../test_helper'
module JPush
module Push
class AudienceTest < JPush::Test
def setup
@audience = Audience.new
end
def test_set_tag
result = @audience.set_tag('jpush').to_hash
assert_equal 1, result.size
assert_true result.has_key?(:tag)
... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/jpush/push/notification_test.rb | Ruby | mit | 98 | master | 4,366 | require_relative '../../test_helper'
module JPush
module Push
class NotificationTest < JPush::Test
def setup
@notification = Notification.new
end
def test_new_notification
assert_raises Utils::Exceptions::JPushError do
@notification.to_hash
end
end
... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | test/jpush/push/push_payload_test.rb | Ruby | mit | 98 | master | 2,778 | require_relative '../../test_helper'
module JPush
module Push
class PushPayloadTest < JPush::Test
def setup
@audience = Audience.new().set_registration_id($test_common_registration_id)
@hello_payload = PushPayload.new(platform: 'all', audience: @audience, notification: 'hello')
end
... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/client.rb | Ruby | mit | 98 | master | 662 | require 'jpush/device'
require 'jpush/pusher'
require 'jpush/report'
require 'jpush/schedules'
module JPush
class Client
attr_reader :app_key
attr_reader :master_secret
def initialize(app_key, master_secret)
@app_key = app_key
@master_secret = master_secret
end
def devices
@d... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/report.rb | Ruby | mit | 98 | master | 2,764 | require 'jpush/http/client'
require 'jpush/handler'
module JPush
class Report < Handler
TIME_UNIT = ['HOUR', 'DAY', 'MONTH']
TIME_FORMAT = { hour: '%F %H', day: '%F', month: '%Y-%m' }
MAX_DURATION = { hour: 24, day: 60, month: 2 }
# GET /v3/received
# 送达统计
def received(msg_ids)
msg_id... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/schedules.rb | Ruby | mit | 98 | master | 1,543 | require 'jpush/schedule/schedule_payload'
require 'jpush/http/client'
require 'jpush/handler'
module JPush
class Schedules < Handler
def initialize(jpush)
@jpush = jpush;
end
# POST https://api.jpush.cn/v3/schedules
# 创建一个新的定时任务
def create(schedule_payload)
schedule_payload = sched... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/pusher.rb | Ruby | mit | 98 | master | 2,774 | require 'jpush/http/client'
require 'jpush/push/push_payload'
require 'jpush/push/single_push_payload'
require 'jpush/handler'
module JPush
class Pusher < Handler
# POST https://api.jpush.cn/v3/push/validate
# 验证推送调用是否能够成功,与推送 API 的区别在于:不向用户发送任何消息
def validate(push_payload)
url = base_url + 'valid... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/device.rb | Ruby | mit | 98 | master | 4,466 | require 'jpush/http/client'
require 'jpush/handler'
module JPush
class Device < Handler
# GET /v3/devices/{registration_id}
# 获取当前设备的所有属性
def show(registration_id)
url = base_url + registration_id
Http::Client.get(@jpush, url)
end
# POST /v3/devices/{registration_id}
# 更新当前设备的指定... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/schedule/schedule_payload.rb | Ruby | mit | 98 | master | 1,308 | require 'jpush/push/push_payload'
require 'jpush/schedule/trigger'
module JPush
module Schedule
class SchedulePayload
def initialize(name, trigger, push_payload, enabled = nil)
@name = name
@trigger = build_trigger(trigger)
@push_payload = build_push_payload(push_payload)
@... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/schedule/trigger.rb | Ruby | mit | 98 | master | 1,291 | module JPush
module Schedule
class Trigger
WEEK = ['MON','TUE','WED','THU','FRI','SAT','SUN']
MDAY = ('01'..'31').to_a
def set_single(time)
@periodical = nil
@single = { time: time.strftime('%F %T') }
self
end
def set_periodical(start_time, end_time, time, ... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/push/single_push_payload.rb | Ruby | mit | 98 | master | 1,064 | require 'jpush/push/notification'
module JPush
module Push
class SinglePushPayload
def initialize(platform: , target: )
@platform = 'all' == platform ? 'all' : build_platform(platform)
@target = target
end
def set_notification(notification)
@notification = notification... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/push/audience.rb | Ruby | mit | 98 | master | 1,020 | module JPush
module Push
class Audience
def set_tag(tags)
@tag = [tags].flatten
self
end
def set_tag_and(tags)
@tag_and = [tags].flatten
self
end
def set_tag_not(tags)
@tag_not = [tags].flatten
self
end
def set_alias(ali... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/push/notification.rb | Ruby | mit | 98 | master | 3,634 | module JPush
module Push
class Notification
def set_alert(alert)
@alert = alert
self
end
def set_not_alert
@alert = ''
self
end
def set_android(alert: , title: nil, builder_id: nil, channel_id: nil,
priority: nil, category: nil, style: nil, ... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/push/push_payload.rb | Ruby | mit | 98 | master | 2,167 | require 'jpush/push/audience'
require 'jpush/push/notification'
module JPush
module Push
class PushPayload
attr_reader :cid
def initialize(platform: , audience: , notification: nil, message: nil)
@platform = 'all' == platform ? 'all' : build_platform(platform)
@audience = 'all' == a... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/utils/exceptions.rb | Ruby | mit | 98 | master | 888 | module JPush
module Utils
module Exceptions
class JPushError < StandardError
attr_reader :message
def initialize(message)
@message = message
end
end
class JPushResponseError < JPushError
attr_reader :http_code, :error_code, :error_message
def ... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/http/response.rb | Ruby | mit | 98 | master | 918 | module JPush
module Http
class Response
attr_accessor :http_code, :body, :heades
def initialize(raw_response)
@http_code = raw_response.code.to_i
@body = parse_body(raw_response.body)
build_error unless raw_response.kind_of? Net::HTTPSuccess
end
private
... |
github | jpush/jpush-api-ruby-client | https://github.com/jpush/jpush-api-ruby-client | lib/jpush/http/client.rb | Ruby | mit | 98 | master | 2,864 | require_relative 'response'
require 'net/http'
require 'json'
require 'jpush/utils/exceptions'
module JPush
module Http
class Client
class << self
def get(jpush, url, params: nil, headers: {})
request(jpush, :get, url, params: params, headers: headers)
end
def post(jpus... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | Gemfile | Ruby | mit | 98 | master | 2,164 | source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.6'
# Use sqlite3 as the database for Active Record... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | config/schedule.rb | Ruby | mit | 98 | master | 742 | # Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
# Example:
#
# set :output, "/path/to/my/cron_log.log"
#
# every 2.hours do
# command "/usr/bin/some_great_command"
# runner "MyModel.some_m... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | config/routes.rb | Ruby | mit | 98 | master | 702 | Rails.application.routes.draw do
devise_for :users
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :videos, only:[:index, :show] do
collection do
get :search
post :fave
delete :unfave
end
end
resources :actors, only:[:ind... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | config/application.rb | Ruby | mit | 98 | master | 609 | require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module JavLibraryRails
class Application < Rails::Application
# Settings in config/environments/* take precedence over tho... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | config/initializers/new_framework_defaults.rb | Ruby | mit | 98 | master | 1,196 | # Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.0 upgrade.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
Rails.application.config.action_controller.raise_on_unfiltered_parameters = true
# Enable per-form CSRF toke... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | config/initializers/devise.rb | Ruby | mit | 98 | master | 13,724 | # Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmat... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | config/environments/production.rb | Ruby | mit | 98 | master | 3,590 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web serve... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | config/environments/development.rb | Ruby | mit | 98 | master | 1,983 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | db/schema.rb | Ruby | mit | 98 | master | 5,595 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# dat... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | db/migrate/20171117130144_create_users_videos.rb | Ruby | mit | 98 | master | 267 | class CreateUsersVideos < ActiveRecord::Migration[5.0]
def change
create_table :users_videos do |t|
t.belongs_to :user, index: true
t.belongs_to :video, index: true
end
add_index :users_videos, [:user_id, :video_id], unique: true
end
end |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | db/migrate/20170922124028_create_actors.rb | Ruby | mit | 98 | master | 202 | class CreateActors < ActiveRecord::Migration[5.0]
def change
create_table :actors do |t|
t.string :name
t.string :actor_label
t.string :type
t.timestamps
end
end
end |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | db/migrate/20170923053510_add_videos_actors_table.rb | Ruby | mit | 98 | master | 217 | class AddVideosActorsTable < ActiveRecord::Migration[5.0]
def change
create_table :actors_videos, id: false do |t|
t.belongs_to :video, index: true
t.belongs_to :actor, index: true
end
end
end |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | db/migrate/20170922124434_create_videos.rb | Ruby | mit | 98 | master | 348 | class CreateVideos < ActiveRecord::Migration[5.0]
def change
create_table :videos do |t|
t.string :video_id
t.string :video_name
t.string :release_date
t.string :length
t.string :director
t.string :maker
t.string :label
t.string :rating
t.string :img
t.t... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | db/migrate/20170924132742_create_stars.rb | Ruby | mit | 98 | master | 220 | class CreateStars < ActiveRecord::Migration[5.0]
def change
create_table :stars do |t|
t.string :name
t.string :rank
t.string :img
t.string :actor_label
t.timestamps
end
end
end |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | db/migrate/20170923053646_add_videos_genres_table.rb | Ruby | mit | 98 | master | 217 | class AddVideosGenresTable < ActiveRecord::Migration[5.0]
def change
create_table :genres_videos, id: false do |t|
t.belongs_to :video, index: true
t.belongs_to :genre, index: true
end
end
end |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | db/migrate/20171109091006_add_actors_and_users_table.rb | Ruby | mit | 98 | master | 292 | class AddActorsAndUsersTable < ActiveRecord::Migration[5.0]
def change
create_table :actors_users do |t|
t.belongs_to :actor, index: true
t.belongs_to :user, index: true
t.timestamps
end
add_index :actors_users, [:actor_id, :user_id], unique: true
end
end |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | app/models/video.rb | Ruby | mit | 98 | master | 341 | class Video < ApplicationRecord
validates :video_id, uniqueness: true
has_and_belongs_to_many :genres
has_and_belongs_to_many :actors
has_and_belongs_to_many :users, -> { distinct }
def actors_string
result = String.new
self.actors.each do |actor|
result << actor.name << " "
end
res... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | app/models/actor.rb | Ruby | mit | 98 | master | 1,243 | class Actor < ApplicationRecord
# Actor: actor_label should be unique
validates :actor_label, uniqueness: true
has_and_belongs_to_many :videos
has_and_belongs_to_many :users, -> { distinct }
def followers
self.users.size
end
def first_year
Time.new(self.videos.sort_by(&:release_date).first.rele... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | app/models/user.rb | Ruby | mit | 98 | master | 2,140 | class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_and_belongs_to_many :actors, -> { distinct }
has... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | app/controllers/relationships_controller.rb | Ruby | mit | 98 | master | 477 | class RelationshipsController < ApplicationController
before_action :authenticate_user!
def create
@actor = Actor.find(params[:actor_id])
current_user.follow(@actor.id)
respond_to do |format|
format.html { redirect_to @actor }
format.js
end
end
def destroy
@actor = Actor.find(p... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | app/controllers/actors_controller.rb | Ruby | mit | 98 | master | 467 | class ActorsController < ApplicationController
def index
@actors = Actor.paginate(:page => params[:page], :per_page => 30)
@q = Actor.ransack(params[:q])
@actor = @q.result(distinct: true)
end
def show
@actor = Actor.find(params[:id])
end
def output
@actor = Actor.find(params[:id])
... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | app/controllers/videos_controller.rb | Ruby | mit | 98 | master | 956 | class VideosController < ApplicationController
before_action :validate_search_key, only: [:index, :search]
def index
@videos = Video.paginate(:page => params[:page], :per_page => 30)
end
def show
@video = Video.find(params[:id])
end
def search
if @query_string.present?
@videos = search_p... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | app/controllers/users_controller.rb | Ruby | mit | 98 | master | 375 | class UsersController < ApplicationController
def show
@user = User.find(params[:id])
end
def videos
@user = current_user
@videos = @user.videos
end
def feed
@user = User.find(params[:id])
@videos = @user.recent_videos_without_actors
respond_to do |format|
format.html
for... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | app/controllers/application_controller.rb | Ruby | mit | 98 | master | 455 | class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit :sign_up, keys: [:username, :email, :password]
# devise_paramet... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | app/helpers/flashes_helper.rb | Ruby | mit | 98 | master | 273 | module FlashesHelper
FLASH_CLASSES = { alert: "danger", notice: "success", warning: "warning"}.freeze
def flash_class(key)
FLASH_CLASSES.fetch key.to_sym, key
end
def user_facing_flashes
flash.to_hash.slice "alert", "notice","warning"
end
end |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | app/helpers/videos_helper.rb | Ruby | mit | 98 | master | 368 | module VideosHelper
def format_video_name(str)
str = str[0..-1] if str.size < 30
str = str[0..30] + "···" if str.size >= 30
str
end
def video_genres(video)
genres = []
video.genres.each do |genre|
genres << genre.name
end
genres
end
def video_rating_format(rating)
retur... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | app/views/users/feed.rss.builder | Ruby | mit | 98 | master | 482 | xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0" do
xml.channel do
xml.title "Videos"
xml.description "User " + @user.username
xml.link "http://www.syhdaily.com"
@videos.each do |video|
xml.item do
xml.title video.video_name
xml.description video.actors_string
... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | lib/tasks/actor_crawler.rake | Ruby | mit | 98 | master | 2,463 | namespace :crawler do
desc 'Download all actors'
task :actor => :environment do
get_all_actors()
end
desc 'Get all javbus actors labels'
task :javbus_label => :environment do
get_all_actors_label_from_javbus()
end
desc 'Format all javbus labels(remove "nowprinting.gif")'
task :javbus_label_for... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | lib/tasks/genre_crawler.rake | Ruby | mit | 98 | master | 502 | namespace :crawler do
desc 'Download all genres'
task :genre => :environment do
get_all_genres()
end
end
# --- Method ---
def get_all_genres
response = Mechanize.new; genres = Array.new
response.get "#{$JAVLIBRARY_URL}/cn/genres.php"
Nokogiri::HTML(response.page.body).search('//div[@class="genreitem"... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | lib/tasks/label_crawler.rake | Ruby | mit | 98 | master | 3,151 | namespace :crawler do
desc 'Download all video labels'
task :label => :environment do
create()
end
desc 'Update all video labels'
task :label_update => :environment do
update()
end
desc 'Update all new release labels'
task :labels_update_release => :environment do
update_new_release()
en... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | lib/tasks/star_crawler.rake | Ruby | mit | 98 | master | 933 | namespace :crawler do
desc 'Download all stars'
task :star => :environment do
Star.delete_all
get_all_stars()
end
end
# --- Method ---
def get_all_stars
url = "#{$JAVLIBRARY_URL}/cn/star_mostfav.php"
response = Mechanize.new do |agent|
# Set timeout preference here
agent.open_timeout = 5
... |
github | syhsyh9696/javlibrary-rails | https://github.com/syhsyh9696/javlibrary-rails | lib/tasks/video_crawler.rake | Ruby | mit | 98 | master | 3,329 | namespace :crawler do
desc 'Download all videos'
task :video => :environment do
Label.where('downloaded = ?', 0).each do |label|
next if label.downloaded?
sign = video_downloader(label.video_label, label.id)
next if sign == 0
if sign
label.downloaded = true
label.save
... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | themoviedb-api.gemspec | Ruby | mit | 98 | master | 1,244 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'tmdb/version'
Gem::Specification.new do |s|
s.name = 'themoviedb-api'
s.version = Tmdb::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ['18Months']
s.... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/collection_spec.rb | Ruby | mit | 98 | master | 1,528 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Collection do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Collection }
it { is_expected.to re... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/spec_helper.rb | Ruby | mit | 98 | master | 1,060 | # This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
requi... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/api_spec.rb | Ruby | mit | 98 | master | 867 | require 'rspec'
require 'spec_helper'
describe Tmdb::Api do
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
let!(:api) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
Tmdb::Api
end
it { expect(Tmdb::Api).to respond_to(:params) }
it { expect(Tmdb::Api).to respond_to(:key)... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/credit_spec.rb | Ruby | mit | 98 | master | 849 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Credit do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Credit }
it { is_expected.to respond_to... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/tv_spec.rb | Ruby | mit | 98 | master | 8,982 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::TV do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::TV }
it { is_expected.to respond_to(:detail... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/search_spec.rb | Ruby | mit | 98 | master | 3,432 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Search do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Search }
it { is_expected.to respond_to... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/certification_spec.rb | Ruby | mit | 98 | master | 1,501 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Certification do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Certification }
it { is_expected... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/network_spec.rb | Ruby | mit | 98 | master | 570 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Network do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Network }
it { is_expected.to respond_... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/genre_spec.rb | Ruby | mit | 98 | master | 1,542 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Genre do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Genre }
it { is_expected.to respond_to(:... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/person_spec.rb | Ruby | mit | 98 | master | 5,062 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Person do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Person }
it { is_expected.to respond_to... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/configuration_spec.rb | Ruby | mit | 98 | master | 919 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Configuration do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Configuration }
it { is_expected... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/movie_spec.rb | Ruby | mit | 98 | master | 9,408 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Movie do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Movie }
it { is_expected.to respond_to(:... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/job_spec.rb | Ruby | mit | 98 | master | 676 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Job do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Job }
it { is_expected.to respond_to(:list... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/change_spec.rb | Ruby | mit | 98 | master | 1,462 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Change do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Change }
it { is_expected.to respond_to... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/discover_spec.rb | Ruby | mit | 98 | master | 1,075 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Discover do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Discover }
it { is_expected.to respon... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/find_spec.rb | Ruby | mit | 98 | master | 2,615 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Find do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Find }
it { is_expected.to respond_to(:mo... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/keyword_spec.rb | Ruby | mit | 98 | master | 1,052 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Keyword do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Keyword }
it { is_expected.to respond_... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/resource_spec.rb | Ruby | mit | 98 | master | 1,028 | require 'rspec'
require 'spec_helper'
describe Tmdb::Resource do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
let(:resource) { Tmdb::Resource.new('/configuration', {}) }
let(:con... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/company_spec.rb | Ruby | mit | 98 | master | 977 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Company do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Company }
it { is_expected.to respond_... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/review_spec.rb | Ruby | mit | 98 | master | 592 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Network do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Network }
it { is_expected.to respond_... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/tv/season_spec.rb | Ruby | mit | 98 | master | 3,773 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Tv::Season do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Tv::Season }
it { is_expected.to re... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | spec/tv/episode_spec.rb | Ruby | mit | 98 | master | 3,873 | require 'rspec'
require 'spec_helper'
require 'vcr'
describe Tmdb::Tv::Episode do
before(:all) do
Tmdb::Api.key(TmdbDefaultApiKey)
Tmdb::Api.language(TmdbDefaultLanguage)
end
after(:all) do
Tmdb::Api.key(nil)
Tmdb::Api.language(nil)
end
subject { Tmdb::Tv::Episode }
it { is_expected.to ... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb.rb | Ruby | mit | 98 | master | 1,664 | require 'json'
require 'rest-client'
require 'ostruct'
require 'tmdb/api'
require 'tmdb/error'
require 'tmdb/struct'
require 'tmdb/utils'
require 'tmdb/resource'
require 'tmdb/account'
require 'tmdb/authentication'
require 'tmdb/backdrop'
require 'tmdb/certification'
require 'tmdb/change'
require 'tmdb/change_item'
... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/find.rb | Ruby | mit | 98 | master | 1,020 | module Tmdb
class Find < Struct
def self.movie(id, filters={})
result = Resource.new("/find/#{id}", filters).get
result['movie_results'].map do |entry|
Movie.new(entry)
end
end
def self.people(id, filters={})
result = Resource.new("/find/#{id}", filters).get
resul... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/image.rb | Ruby | mit | 98 | master | 414 | module Tmdb
class Image < Struct
def convert_media_multiple!
results.each do |result|
media_type = find_media_type(result)
result.media = media_type.new(result.media.to_h)
end
end
private
def find_media_type(obj)
case obj.media_type
when 'movie'
M... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/discover.rb | Ruby | mit | 98 | master | 568 | module Tmdb
class Discover < Struct
def self.movie(filters={})
result = Resource.new('/discover/movie', filters).get
discover = self.new(result.except('results'))
discover.results = result['results'].map do |result|
Movie.new(result)
end
discover
end
def self.tv(f... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/api.rb | Ruby | mit | 98 | master | 432 | module Tmdb
class Api
VERSION = '3'
BASE_URI = "http://api.themoviedb.org/#{VERSION}"
JSON_HEADERS = {
content_type: 'application/json; charset=utf-8',
accept: 'application/json'
}
def self.params
@@params ||= {}
end
def self.key(api_key)
self.params[... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/change.rb | Ruby | mit | 98 | master | 929 | module Tmdb
class Change < Struct
def self.movie(filters={})
result = Resource.new("/movie/changes", filters).get
change = self.new(result.except('results'))
change.results = result['results'].map do |result|
Movie.new(result)
end
change
end
def self.person(filter... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/search.rb | Ruby | mit | 98 | master | 2,303 | module Tmdb
class Search < Struct
def self.company(query, filters={})
filters.merge!(query: query)
get_result = Resource.new('/search/company', filters).get
result = Result.new(get_result.except('results'))
result.results = get_result['results'].map do |movie|
Company.new(movie)... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/tv.rb | Ruby | mit | 98 | master | 3,917 | module Tmdb
class TV < Struct
def self.detail(id, filters={})
result = Resource.new("/tv/#{id}", filters).get
create_new_instance_with_normalized_data(result)
end
def self.alternative_titles(id, filters={})
result = Resource.new("/tv/#{id}/alternative_titles", filters).get
resu... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/collection.rb | Ruby | mit | 98 | master | 714 | module Tmdb
class Collection < Struct
def self.detail(id, filters={})
result = Resource.new("/collection/#{id}", filters).get
collection = self.new(result.except('parts'))
collection.parts = result['parts'].map do |part|
Movie.new(part)
end
collection
end
def self... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/credit.rb | Ruby | mit | 98 | master | 690 | module Tmdb
class Credit < Struct
def self.detail(id, filters={})
result = Resource.new("/credit/#{id}", filters).get
media = result['media']
credit = self.new(result.except('media', 'person'))
credit.media = Media.new(media.except('episodes', 'seasons'))
if media['episodes'].pre... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/certification.rb | Ruby | mit | 98 | master | 660 | module Tmdb
class Certification < Struct
def self.movie_list(filters={})
output = {}
result = Resource.new('/certification/movie/list', filters).get
result['certifications'].map do |nation, certification_list|
output[nation.to_sym] = certification_list.map { |cert| self.new(cert) }
... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/keyword.rb | Ruby | mit | 98 | master | 477 | module Tmdb
class Keyword < Struct
def self.detail(keyword_id, filters={})
result = Resource.new("/keyword/#{keyword_id}", filters).get
self.new(result)
end
def self.movies(keyword_id, filters={})
result = Resource.new("/keyword/#{keyword_id}/movies", filters).get
keyword = self... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/person.rb | Ruby | mit | 98 | master | 2,202 | module Tmdb
class Person < Struct
def self.detail(id, filters={})
result = Resource.new("/person/#{id}", filters).get
self.new(result)
end
def self.movie_credits(id, filters={})
result = Resource.new("/person/#{id}/movie_credits", filters).get
self.new(result)
end
def se... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/struct.rb | Ruby | mit | 98 | master | 431 | module Tmdb
class Struct < OpenStruct
def initialize(data=nil)
@table = {}
if data
data.each do |k,v|
self[k] = analyze_value(v)
end
end
end
def analyze_value(v)
case v
when Hash
self.class.new(v)
when Array
v.map do |... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/resource.rb | Ruby | mit | 98 | master | 726 | module Tmdb
class Resource
include Utils
attr_reader :params, :query_url
def initialize(query_url, filters={})
@params = filters
@query_url = query_url
end
def get
request_params = Api.params.merge(@params)
begin
response = RestClient.get Api::BASE_URI + query_... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/company.rb | Ruby | mit | 98 | master | 445 | module Tmdb
class Company < Struct
def self.detail(id, filters={})
result = Resource.new("/company/#{id}", filters).get
self.new(result)
end
def self.movies(id, filters={})
result = Resource.new("/company/#{id}/movies", filters).get
company = self.new(result.except('results'))
... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/genre.rb | Ruby | mit | 98 | master | 674 | module Tmdb
class Genre < Struct
def self.movie_list(filters={})
result = Resource.new('/genre/movie/list', filters).get
result['genres'].map do |genre|
self.new(genre)
end
end
def self.tv_list(filters={})
result = Resource.new('/genre/tv/list', filters).get
resul... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.