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 | brookemckim/hlspider | https://github.com/brookemckim/hlspider | Rakefile | Ruby | mit | 48 | master | 238 | require 'bundler/gem_tasks'
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs.push 'lib'
t.libs.push 'spec'
t.test_files = FileList['spec/**/*_spec.rb']
t.verbose = true
end
task :default => [:test]
task :spec => [:test] |
github | brookemckim/hlspider | https://github.com/brookemckim/hlspider | hlspider.gemspec | Ruby | mit | 48 | master | 915 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "hlspider/version"
Gem::Specification.new do |s|
s.name = "hlspider"
s.version = HLSpider::VERSION
s.authors = ["brookemckim"]
s.email = ["brooke.mckim@gmail.com"]
s.homepage = "http://www.github.com/brooke... |
github | brookemckim/hlspider | https://github.com/brookemckim/hlspider | lib/hlspider.rb | Ruby | mit | 48 | master | 259 | $:.push File.dirname(__FILE__)
require 'hlspider/version'
require 'hlspider/downloader'
require 'hlspider/playlist_line'
require 'hlspider/playlist'
require 'hlspider/spider'
module HLSpider
def self.new(*args)
HLSpider::Spider.new(*args)
end
end |
github | brookemckim/hlspider | https://github.com/brookemckim/hlspider | lib/hlspider/playlist_line.rb | Ruby | mit | 48 | master | 2,878 | # Internal: A set of methods for examining individual lines of m3u8 playlists.
module HLSpider
module PlaylistLine
# Internal: Checks if String str contains a .ts file extension
#
# str - String to be checked
#
# Examples
#
# has_segment?("video_01.ts")
# #=> true
#
# has... |
github | brookemckim/hlspider | https://github.com/brookemckim/hlspider | lib/hlspider/spider.rb | Ruby | mit | 48 | master | 2,916 | # Public: Asynchronsoly downloads .m3u8 playlist files from specified URLs.
#
#
# Examples
#
# Spider.new(["http://host.tld/video1/playlist_1.m3u8", "http://host.tld/video1/playlist_2.m3u8"])
# # => #<HLSpider::Spider:0x10cab12d0>
#
# Spider.new("http://host.tld/video1/parent_playlist.m3u8")
# # => #<HLSpider:... |
github | brookemckim/hlspider | https://github.com/brookemckim/hlspider | lib/hlspider/response.rb | Ruby | mit | 48 | master | 244 | # Internal: Reponse from the downloader which contains the response body
# and the request url.
module HLSpider
class Response
def initialize(url, body)
@url = url
@body = body
end
attr_reader :url, :body
end
end |
github | brookemckim/hlspider | https://github.com/brookemckim/hlspider | lib/hlspider/downloader.rb | Ruby | mit | 48 | master | 947 | require 'net/http'
require 'hlspider/response'
# Internal: Asynchronsoly downloads urls and returns Array of responses.
module HLSpider
module Downloader
# Internal: Download given URLs.
#
# urls - An Array of strings or a single string of URL(s)
#
# Examples
#
# download(["http://www.g... |
github | brookemckim/hlspider | https://github.com/brookemckim/hlspider | lib/hlspider/playlist.rb | Ruby | mit | 48 | master | 5,600 | # Internal: Parses out and exposes the parts of M3U8 playlist files.
#
# M3U8 References:
# http://developer.apple.com/library/ios/#documentation/networkinginternet/conceptual/streamingmediaguide/HTTPStreamingArchitecture/HTTPStreamingArchitecture.html
#
# Examples
#
# p = Playlist.new(File.read("/path/to/playlist.... |
github | brookemckim/hlspider | https://github.com/brookemckim/hlspider | spec/hlspider_spec.rb | Ruby | mit | 48 | master | 229 | require 'spec_helper'
describe HLSpider do
before do
@spider = HLSpider.new("http://host.com/playlist.m3u8")
end
it "should instansiate a Spider class" do
@spider.must_be_kind_of(HLSpider::Spider)
end
end |
github | brookemckim/hlspider | https://github.com/brookemckim/hlspider | spec/hlspider/playlist_line_spec.rb | Ruby | mit | 48 | master | 2,576 | require 'spec_helper'
describe HLSpider::PlaylistLine do
before do
class PlaylistLine; extend HLSpider::PlaylistLine; end
@segment_line = "http://host.tld/video1/video_123123023030.ts?session=12391239"
@playlist_line = "http://host.told/video1/playlist_123213.m3u8"
@duration_line = "EXT-X-TARGE... |
github | brookemckim/hlspider | https://github.com/brookemckim/hlspider | spec/hlspider/spider_spec.rb | Ruby | mit | 48 | master | 2,798 | require 'spec_helper'
describe HLSpider::Spider do
include WebMock::API
before do
WebMock.reset!
@playlist = "http://host.com/playlist.m3u8"
@playlists = ["http://host.com/playlist.m3u8", "http://host.com/playlist2.m3u8"]
stub_request(:get, "http://host.com/playlist.m3u8").to_return({:status => 2... |
github | brookemckim/hlspider | https://github.com/brookemckim/hlspider | spec/hlspider/playlist_spec.rb | Ruby | mit | 48 | master | 5,174 | require 'spec_helper'
describe HLSpider::Playlist do
before do
@segments_playlist = %q{#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:7.12,
segment00000.ts
segment00001.ts
/absolute/path/segment00002.ts
#EXT-X-ENDLIST
}
@variable_playlist = %q{... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | Rakefile | Ruby | mit | 48 | master | 804 | #!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
RDoc::Task = Rake::RDocTask
end
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.r... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | Guardfile | Ruby | mit | 48 | master | 904 | guard 'bundler' do
watch('Gemfile')
watch(/^.+\.gemspec/)
end
guard 'rspec', :version => 2, :cli => "--color --format documentation" do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^lib/(.+)\.rb$}) { |m| "s... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | manageable_content.gemspec | Ruby | mit | 48 | master | 1,094 | $:.push File.expand_path("../lib", __FILE__)
require "manageable_content/version"
Gem::Specification.new do |s|
s.name = "manageable_content"
s.version = ManageableContent::VERSION
s.authors = ["Fabio Kreusch"]
s.email = ["fabiokr@gmail.com"]
s.homepage = "https://github.com/fabiokr/... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | db/migrate/20110814003912_create_manageable_content_page_contents.rb | Ruby | mit | 48 | master | 369 | class CreateManageableContentPageContents < ActiveRecord::Migration
def change
create_table :manageable_content_page_contents do |t|
t.references :page
t.string :key
t.boolean :short, :default => false
t.text :content
t.timestamps
end
add_index :manageable_content_page_cont... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | db/migrate/20110814002730_create_manageable_content_pages.rb | Ruby | mit | 48 | master | 279 | class CreateManageableContentPages < ActiveRecord::Migration
def change
create_table :manageable_content_pages do |t|
t.string :key
t.string :locale
t.timestamps
end
add_index :manageable_content_pages, [:key, :locale], :unique => true
end
end |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | lib/tasks/manageable_content_tasks.rake | Ruby | mit | 48 | master | 426 | namespace :manageable_content do
desc "Generates ManageableContent::Page (check documentation for ManageableContent::Manager.generate!)"
task :generate => :environment do
locales = ManageableContent::Engine.config.locales
puts "Generating pages for locales #{locales}..."
controllers = ManageableCo... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | lib/manageable_content/manager.rb | Ruby | mit | 48 | master | 5,395 | module ManageableContent
class Manager
# Retrieves a list of Controllers eligible for having manageable content.
# A Controller is eligible if it has set contents with :manageable_content_for.
# This method is cached if Rails.configuration.cache_classes is true.
def self.eligible_controllers
if... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | lib/manageable_content/engine.rb | Ruby | mit | 48 | master | 718 | require 'rails'
require 'manageable_content/controllers/dsl'
require 'manageable_content/manager'
module ManageableContent
def self.table_name_prefix
'manageable_content_'
end
class Engine < Rails::Engine
initializer 'manageable_content.setup_locales' do |app|
# Configures the managable locales a... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | lib/manageable_content/controllers/dsl.rb | Ruby | mit | 48 | master | 5,228 | module ManageableContent
module Controllers
module Dsl
extend ActiveSupport::Concern
mattr_accessor :manageable_layout_content_keys
self.manageable_layout_content_keys = {}
included do
class_attribute :manageable_content_custom_key_evaluator
class_attribute :manageable_co... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | app/models/manageable_content/page_content.rb | Ruby | mit | 48 | master | 359 | class ManageableContent::PageContent < ActiveRecord::Base
belongs_to :page, :touch => true
attr_accessible :content
validates :page_id, :presence => true
validates :key, :presence => true
default_scope order("#{ActiveRecord::Base.connection.quote_column_name('short')} DESC, #{ActiveRecord::Base.connect... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | app/models/manageable_content/page.rb | Ruby | mit | 48 | master | 595 | class ManageableContent::Page < ActiveRecord::Base
validates :locale, :presence => true
has_many :page_contents, :dependent => :delete_all
scope :with_contents, lambda { includes(:page_contents).joins(:page_contents) }
attr_accessible :page_contents_attributes
accepts_nested_attributes_for :page_contents
... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/spec_helper.rb | Ruby | mit | 48 | master | 931 | ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require 'rspec/rails'
require 'database_cleaner'
require 'shoulda-matchers'
require 'factory_girl'
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/integration/manageable_content_usage_spec.rb | Ruby | mit | 48 | master | 4,125 | require 'spec_helper'
describe "The demo application" do
context "with manageable content" do
before :each do
ManageableContent::Manager.generate!
# Application layout
page = ManageableContent::Manager.page('application').first
page.page_content(:title).update_attributes(:content => "App... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/models/manageable_content/page_content_spec.rb | Ruby | mit | 48 | master | 1,101 | require 'spec_helper'
describe ManageableContent::PageContent do
context "fields" do
it { should have_db_column(:page_id).of_type(:integer) }
it { should have_db_column(:key).of_type(:string) }
it { should have_db_column(:content).of_type(:text) }
it { should have_db_column(:short).of_type(:boolean)... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/models/manageable_content/page_spec.rb | Ruby | mit | 48 | master | 1,464 | require 'spec_helper'
describe ManageableContent::Page do
context "fields" do
it { should have_db_column(:key).of_type(:string) }
it { should have_db_column(:locale).of_type(:string) }
it { should have_db_column(:created_at).of_type(:datetime) }
it { should have_db_column(:updated_at).of_type(:datet... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/dummy/config/routes.rb | Ruby | mit | 48 | master | 492 | Dummy::Application.routes.draw do
match "home" => "home#index", :as => 'home'
match "contact" => "contact#index", :as => 'contact'
match "blog" => "blog/home#index", :as => 'blog_home'
match "staticpage1" => "static_pages#index", :defaults => { :page => "static/page1" }, :as => 'staticpage1'
mat... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/dummy/config/application.rb | Ruby | mit | 48 | master | 1,897 | require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
Bundler.require
require "manageable_cont... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/dummy/config/initializers/manageable_content.rb | Ruby | mit | 48 | master | 205 | ManageableContent::Engine.config.locales = [:en, :pt]
ManageableContent::Engine.config.custom_pages = {
"static/page1" => {:body => :text},
"static/page2" => {:body => :text, :footer => :string}
} |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/dummy/config/initializers/secret_token.rb | Ruby | mit | 48 | master | 496 | # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/dummy/config/environments/production.rb | Ruby | mit | 48 | master | 1,898 | Dummy::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
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_c... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/dummy/config/environments/development.rb | Ruby | mit | 48 | master | 996 | Dummy::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 ser... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/dummy/db/schema.rb | Ruby | mit | 48 | master | 1,518 | # encoding: UTF-8
# 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 sou... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/dummy/app/controllers/application_controller.rb | Ruby | mit | 48 | master | 367 | class ApplicationController < ActionController::Base
include ManageableContent::Controllers::Dsl
protect_from_forgery
manageable_layout_content_for :footer_contact, :type => :string
manageable_layout_content_for :footer_copyright, :type => :text
manageable_content_for :title, :type => :string
manage... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/dummy/app/controllers/blog/application_controller.rb | Ruby | mit | 48 | master | 215 | class Blog::ApplicationController < ActionController::Base
include ManageableContent::Controllers::Dsl
protect_from_forgery
layout 'blog'
manageable_layout_content_for :blog_title, :layout => 'blog'
end |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/lib/manageable_content/manager_spec.rb | Ruby | mit | 48 | master | 6,825 | require 'spec_helper'
describe ManageableContent::Manager do
context "class methods" do
context "eligible_controllers" do
it "should list the eligible controllers" do
ManageableContent::Manager.eligible_controllers.should ==
[ApplicationController, ContactController, HomeController]
... |
github | fabiokr/manageable_content | https://github.com/fabiokr/manageable_content | spec/lib/manageable_content/controllers/dsl_spec.rb | Ruby | mit | 48 | master | 6,885 | require 'spec_helper'
describe "The Controller Dsl" do
context "class methods" do
context "manageable_layout_content_for" do
it "should configure the layout content keys for layout" do
ManageableContent::Controllers::Dsl.manageable_layout_content_keys['application'].should ==
{:footer_c... |
github | gtarnovan/simple_audit | https://github.com/gtarnovan/simple_audit | simple_audit.gemspec | Ruby | mit | 47 | master | 2,375 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{simple_audit}
s.version = "0.2.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :requi... |
github | gtarnovan/simple_audit | https://github.com/gtarnovan/simple_audit | Rakefile | Ruby | mit | 47 | master | 1,623 | require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the simple_audit plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for th... |
github | gtarnovan/simple_audit | https://github.com/gtarnovan/simple_audit | lib/simple_audit.rb | Ruby | mit | 47 | master | 322 | require 'active_record'
require 'action_view'
require 'simple_audit/simple_audit'
require 'simple_audit/audit'
require 'simple_audit/helper'
if defined?(ActiveRecord::Base)
ActiveRecord::Base.send :include, SimpleAudit::Model
end
if defined?(ActionView::Base)
ActionView::Base.send :include, SimpleAudit::Helper
e... |
github | gtarnovan/simple_audit | https://github.com/gtarnovan/simple_audit | lib/simple_audit/audit.rb | Ruby | mit | 47 | master | 1,333 | module SimpleAudit #:nodoc:
# Changes of the audited models will be stored here.
class Audit < ActiveRecord::Base
belongs_to :auditable, :polymorphic => true
belongs_to :user, :polymorphic => true
serialize :change_log
# Computes the differences of the change logs between two audits.
... |
github | gtarnovan/simple_audit | https://github.com/gtarnovan/simple_audit | lib/simple_audit/simple_audit.rb | Ruby | mit | 47 | master | 2,721 | # Use this macro if you want changes in your model to be saved in an audit table.
# The audits table must exist.
#
# class Booking
# simple_audit
# end
#
# See SimpleAudit::ClassMethods#simple_audit for configuration options
module SimpleAudit
module Model
def self.included(base) #:nodoc:
base.sen... |
github | gtarnovan/simple_audit | https://github.com/gtarnovan/simple_audit | lib/simple_audit/helper.rb | Ruby | mit | 47 | master | 1,678 | module SimpleAudit #:nodoc:
module Helper
# Render the change log for the given audited model
def render_audits(audited_model)
return '' unless audited_model.respond_to?(:audits)
audits = (audited_model.audits || []).dup.sort{|a,b| b.created_at <=> a.created_at}
res = ''
audi... |
github | gtarnovan/simple_audit | https://github.com/gtarnovan/simple_audit | lib/generators/simple_audit/migration/migration_generator.rb | Ruby | mit | 47 | master | 749 | require 'rails/generators/migration'
module SimpleAudit
class MigrationGenerator < Rails::Generators::Base
include Rails::Generators::Migration
desc "Generates migration for Audit model"
def self.orm
Rails::Generators.options[:rails][:orm]
end
def self.source_root
File.join(File.di... |
github | gtarnovan/simple_audit | https://github.com/gtarnovan/simple_audit | lib/generators/simple_audit/migration/templates/active_record/migration.rb | Ruby | mit | 47 | master | 553 | class SimpleAuditMigration < ActiveRecord::Migration
def self.up
create_table :audits do |t|
t.belongs_to :auditable, :polymorphic => true
t.belongs_to :user, :polymorphic => true
t.string :username
t.string :action
t.text :change_log
t.timestamps
end
add_in... |
github | gtarnovan/simple_audit | https://github.com/gtarnovan/simple_audit | generators/simple_audit_migration/simple_audit_migration_generator.rb | Ruby | mit | 47 | master | 221 | class SimpleAuditMigrationGenerator < Rails::Generator::Base
def manifest
record do |m|
m.migration_template 'migration.rb', "db/migrate", :migration_file_name => 'simple_audit_migration'
end
end
end |
github | gtarnovan/simple_audit | https://github.com/gtarnovan/simple_audit | test/test_helper.rb | Ruby | mit | 47 | master | 1,667 | require 'rubygems'
require 'test/unit'
require 'active_support/all'
require 'active_record'
require 'active_record/fixtures'
require 'action_controller'
require 'ruby-debug'
require 'ostruct'
require File.join(File.dirname(__FILE__), "..", "generators", "simple_audit_migration", "templates", "migration.rb")
require Fi... |
github | gtarnovan/simple_audit | https://github.com/gtarnovan/simple_audit | test/unit/simple_audit_test.rb | Ruby | mit | 47 | master | 2,624 | require 'test_helper'
class SimpleAuditTest < ActiveSupport::TestCase
include SimpleAudit
test "should audit entity creation" do
assert_difference 'Audit.count', 4 do
assert_difference 'Person.count', 2 do
Person.create(:name => "Mihai Tarnovan", :email => "mihai.tarnovan@cubus.ro", :address ... |
github | colinhumber/itunes_transporter_generator | https://github.com/colinhumber/itunes_transporter_generator | itmsp.gemspec | Ruby | mit | 47 | master | 899 | $:.push File.expand_path("../lib", __FILE__)
require "itunes"
Gem::Specification.new do |s|
s.name = 'itunes_transporter_generator'
s.version = Itunes::VERSION
s.platform = Gem::Platform::RUBY
s.summary = "iTunes Transporter App Store Package Generator"
s.description = "A command-line tool ... |
github | colinhumber/itunes_transporter_generator | https://github.com/colinhumber/itunes_transporter_generator | lib/itunes/transporter.rb | Ruby | mit | 47 | master | 4,709 | module Itunes
module Transporter
class Achievement < Struct.new(:id, :name, :points, :hidden, :reusable, :should_remove, :locales)
def to_s
"#{self.id} #{self.name}"
end
end
class AchievementLocale < Struct.new(:name, :title, :before_earned_description, :after_earned_description, :achievemen... |
github | colinhumber/itunes_transporter_generator | https://github.com/colinhumber/itunes_transporter_generator | lib/itunes/transporter/helpers.rb | Ruby | mit | 47 | master | 8,528 | require 'yaml'
require 'itunes/transporter'
module Itunes
module Transporter
module Helpers
KNOWN_DISPLAY_TARGETS = {'ipad' => 'iOS-iPad', 'iphone_3.5in' => 'iOS-3.5-in', 'iphone_4in' =>'iOS-4-in', 'iphone_4.7in' => 'iOS-4.7-in', 'iphone_5.5in' => 'iOS-5.5-in'}
def metadata_from_yaml(yaml_file)
... |
github | colinhumber/itunes_transporter_generator | https://github.com/colinhumber/itunes_transporter_generator | lib/itunes/transporter/locale.rb | Ruby | mit | 47 | master | 229 | module Itunes
module Transporter
class Locale
attr_accessor :language
attr_accessor :title
def initialize(language, title)
@language = language
@title = title
end
end
end
end |
github | colinhumber/itunes_transporter_generator | https://github.com/colinhumber/itunes_transporter_generator | lib/itunes/transporter/generator.rb | Ruby | mit | 47 | master | 11,620 | require 'builder'
require 'digest'
require 'fileutils'
require 'itunes/transporter/helpers'
module Itunes
module Transporter
class Generator
include Itunes::Transporter::Helpers
attr_reader :files_to_process
attr_reader :images_to_process
attr_accessor :id_prefix
attr_accessor :pro... |
github | colinhumber/itunes_transporter_generator | https://github.com/colinhumber/itunes_transporter_generator | lib/itunes/transporter/in_app_purchase.rb | Ruby | mit | 47 | master | 750 | module Itunes
module Transporter
class InAppPurchase < Struct.new(:product_id, :reference_name, :type, :duration, :free_trial_duration, :bonus_duration, :products, :locales, :review_screenshot_image, :review_notes, :should_remove)
def to_s
"Product ID: #{self.product_id} Reference Name: #{self.reference_na... |
github | colinhumber/itunes_transporter_generator | https://github.com/colinhumber/itunes_transporter_generator | lib/itunes/transporter/commands/package.rb | Ruby | mit | 47 | master | 899 | require 'itunes/transporter/generator'
command :package do |c|
c.syntax = 'itmsp package [options]'
c.summary = ''
c.description = 'Generates iTunes Metadata Store Package (.itmsp) from provided achievement, leaderboard, and/or in-app purchases provided'
c.example 'description', 'command example'
c.option '-... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | Gemfile | Ruby | mit | 47 | master | 2,115 | 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.2.6'
gem 'pg', '~> 0.21'
gem 'sqlite3'
gem 'bootstrap... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/models/user_agent.rb | Ruby | mit | 47 | master | 514 | class UserAgent < ApplicationRecord
validates :user_agent, presence: true
class CookieJar
def initialize(user_agent)
@user_agent = user_agent
if @user_agent.cookies.present?
File.open path, 'w' do |f|
f.write @user_agent.cookies
end
end
end
def path
F... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/models/episode.rb | Ruby | mit | 47 | master | 306 | class Episode < ApplicationRecord
belongs_to :podcast
mount_uploader :media, MediaUploader
validates :title, presence: true
validates :published_at, presence: true
scope :recent, -> { order('published_at DESC') }
def size
media_size || media.size
end
def url
media.url
end
end |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/models/podcast.rb | Ruby | mit | 47 | master | 764 | class Podcast < ApplicationRecord
validates :origin_id, :title, :accessed_at, presence: true
has_many :episodes, dependent: :destroy, class_name: 'AudioEpisode'
has_many :audio_episodes, dependent: :destroy, class_name: 'AudioEpisode'
has_many :video_episodes, dependent: :destroy, class_name: 'VideoEpisode'
... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/models/video.rb | Ruby | mit | 47 | master | 1,032 | class Video
attr_reader :origin_id
delegate :id, :title, :description, :mime_type, :url, :size, to: :episode
delegate :url, :size, to: :audio_episode, allow_nil: true, prefix: :audio
delegate :size, to: :video_episode, allow_nil: true, prefix: :video
def initialize(origin_id, episode=nil)
@origin_id = or... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/views/feedbacks/index.atom.builder | Ruby | mit | 47 | master | 395 | atom_feed do |feed|
feed.title(t(:feedbacks_list))
feed.updated(@feedbacks[0].created_at) if @feedbacks.length > 0
@feedbacks.each do |feedback|
feed.entry(feedback) do |entry|
entry.title("#{feedback.title} - #{feedback.category}")
entry.content(feedback.body, type: 'text')
entry.author d... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/views/channels/show.atom.builder | Ruby | mit | 47 | master | 743 | atom_feed do |feed|
feed.title @podcast.title
feed.updated @videos.first.published_at if @videos.present?
@videos.each do |video|
feed.entry video, url: video_url(video.origin_id, utm_medium: :feed, utm_source: @podcast.origin_id, utm_campaign: video.origin_id) do |entry|
entry.author do |author|
... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/helpers/application_helper.rb | Ruby | mit | 47 | master | 1,020 | module ApplicationHelper
def google_tag_manager_head
return if ENV['GOOGLE_TAG_MANAGER_ID'].blank?
raw <<-CODE
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.cr... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/controllers/application_controller.rb | Ruby | mit | 47 | master | 788 | class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
rescue_from ActiveRecord::RecordNotFound do
render plain: 'Not found', status: 404
end
helper_method :stats
before_action :set_locale
private
include ActionView::Helpers::NumberHelper
def stats(key)
c... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/controllers/stats_controller.rb | Ruby | mit | 47 | master | 289 | class StatsController < ApplicationController
PENDING_AUDIO_EPISODES_KEY = 'pending audio episodes'
PENDING_VIDEO_EPISODES_KEY = 'pending video episodes'
VIDEO_EPISODES_KEY = 'video episodes'
AUDIO_EPISODES_KEY = 'audio episodes'
PODCASTS_KEY = 'podcasts'
def index
end
end |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/controllers/feedbacks_controller.rb | Ruby | mit | 47 | master | 920 | class FeedbacksController < ApplicationController
before_action :set_feedback, only: [:show, :edit, :update, :destroy]
# GET /feedbacks
def index
@feedbacks = Feedback.order('created_at DESC').limit(20)
respond_to do |format|
format.atom
end
end
# GET /feedbacks/1
def show
end
# GET... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/controllers/channels_controller.rb | Ruby | mit | 47 | master | 3,644 | class ChannelsController < ApplicationController
PODCAST_SOURCE_TYPE = nil.freeze
PODCAST_YT_KLASS = Yt::Channel.freeze
helper_method :new_videos
class Channel < Podcast
attr_accessor :url
end
def create
if playlist_id.present?
create_podcast playlist_id, 'playlist', Yt::Playlist.new(id: pl... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/controllers/videos_controller.rb | Ruby | mit | 47 | master | 533 | class VideosController < ApplicationController
def show
@video = Video.new params[:id]
respond_to do |format|
format.html
if Flipper.enabled? :video
format.mp4 do
redirect_to video_url(@video.origin_id)
end
end
end
end
def index
@videos = VideosReposit... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/uploaders/media_uploader.rb | Ruby | mit | 47 | master | 1,599 | class MediaUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
if ENV['AWS_ACCESS_KEY_ID'].present?
storage :fog
elsif ENV['FTP_HOST'].present?
stor... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/jobs/cleanup_outdated_job.rb | Ruby | mit | 47 | master | 1,273 | class CleanupOutdatedJob < ApplicationJob
queue_as :low_priority
PERIOD_TO_KEEP = 1.week
MIN_EPISODES_TO_STORE = ENV.fetch('MIN_EPISODES_TO_STORE', 10)
MAX_EPISODES_TO_STORE = ENV.fetch('MAX_EPISODES_TO_STORE', 50)
def perform(podcast=nil)
if podcast.present?
cleanup_episodes_scope podcast.audio_e... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/jobs/update_podcast_job.rb | Ruby | mit | 47 | master | 1,227 | class UpdatePodcastJob < ApplicationJob
queue_as :high_priority
def perform(podcast)
@podcast = podcast
MarkPodcastAsRemovedJob.perform_later podcast
return if podcast.deleted?
new_youtube_videos.each do |video|
add_pending_episode video.id
FetchAudioEpisodeJob.perform_later(@podcast... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/jobs/update_all_podcasts_job.rb | Ruby | mit | 47 | master | 828 | class UpdateAllPodcastsJob < ApplicationJob
queue_as :high_priority
def perform
Podcast.where.not(deleted: true).find_each do |podcast|
next unless is_popular?(podcast)
next if is_fresh_enough?(podcast)
UpdatePodcastJob.perform_later(podcast)
end
end
private
def is_popular?(podcas... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/jobs/mark_podcast_as_removed_job.rb | Ruby | mit | 47 | master | 201 | class MarkPodcastAsRemovedJob < ApplicationJob
queue_as :default
def perform(podcast)
unless podcast.youtube_video_list.exists?
podcast.update_attribute :deleted, true
end
end
end |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/jobs/fetch_audio_episode_job.rb | Ruby | mit | 47 | master | 2,626 | class FetchAudioEpisodeJob < ApplicationJob
queue_as :default
EPISODES_RELATION = 'episodes'.freeze
EVENT_CATEGORY = 'audio'.freeze
# Do not try to fetche the same episode more often then THROTTLE_PERIOD
THROTTLE_PERIOD = 1.hour.freeze
class LiveStreamIsNotFinished < StandardError; end;
attr_reader :l... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/jobs/update_stats_job.rb | Ruby | mit | 47 | master | 847 | class UpdateStatsJob < ApplicationJob
queue_as :high_priority
KEEP_PENDINGS_PERIOD = 1.day
def perform
t = Time.now
SimpleMetric::Metric.add_data_point StatsController::PODCASTS_KEY, t, Podcast.count
SimpleMetric::Metric.add_data_point StatsController::VIDEO_EPISODES_KEY, t, VideoEpisode.count
... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/jobs/cleanup_local_media_job.rb | Ruby | mit | 47 | master | 356 | class CleanupLocalMediaJob < ApplicationJob
queue_as :high_priority
def perform
Dir.glob(Rails.root.join('tmp', 'youtube', '**', '*')).each do |path|
if File.mtime(path) < 3.hours.ago
next unless File.file?(path)
Rails.logger.info "Removing outdated tmp file: #{path}"
FileUtils.rm... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/jobs/fetch_video_episode_job.rb | Ruby | mit | 47 | master | 1,507 | class FetchVideoEpisodeJob < FetchAudioEpisodeJob
EPISODES_RELATION = 'video_episodes'.freeze
EVENT_CATEGORY = 'video'.freeze
class Fetcher < FetchAudioEpisodeJob::Fetcher
private
def fetch_media(id)
YoutubeDl.new.fetch_video_url id
end
end
def perform(podcast, youtube_video_id, fetcher=F... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/services/youtube_dl.rb | Ruby | mit | 47 | master | 1,421 | class YoutubeDl
class UnknownError < StandardError; end;
class IncompleteYoutubeId < UnknownError; end;
MAX_FILE_SIZE = ENV.fetch('MAX_FILE_SIZE', '1G').freeze
def fetch_audio(id)
exec "-f worstaudio[ext=m4a] --max-filesize #{MAX_FILE_SIZE} -o '#{Rails.root.join('tmp', 'youtube', 'audios', '%(id)s.%(ext)... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/services/throttler.rb | Ruby | mit | 47 | master | 718 | # Throttler.throttle "Update feeds", 1.minute do
# ...
# end
class Throttler
def initialize(period, name)
@period = period
@name = name
end
def action(&block)
return if ever? && last_action_at > @period.ago
execute_and_track(block)
end
def self.throttle(name, period, &block)
new(perio... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/services/user_agents_pool.rb | Ruby | mit | 47 | master | 1,049 | class UserAgentsPool
class NoFreeUsersLeft < StandardError; end;
IDLE_PERIOD = ENV.fetch('USER_AGENT_IDLE_PERIOD', '30').to_i.seconds
# Get exclusive lock for a free user
#
# UserAgentsService.with_user_agent do |ua|
# # do something with user_agent here
# end
def self.with_user_agent
raise NoFr... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/services/search.rb | Ruby | mit | 47 | master | 711 | class Search
LIMIT = 100
def self.call(query)
Search.new.call query
end
def initialize
end
def call(query)
select(query).map do |row|
case row['type']
when 'Podcast'
Podcast.find(row['id'])
when 'Episode'
Video.new row['origin_id'], Episode.find(row['id'])
... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/services/youtube_playlist.rb | Ruby | mit | 47 | master | 697 | class YoutubePlaylist < YoutubeVideoList
class PlaylistItemWrapper
attr_reader :id, :title, :published_at
def initialize(item)
@id = item.id
@title = item.title
@published_at = nil
end
end
def videos
yt_list.playlist_items.take(100).reverse[0..10].map(&:video).map do |v|
... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/services/tracker.rb | Ruby | mit | 47 | master | 637 | class Tracker
include Singleton
attr_reader :staccato
def initialize
@staccato = Staccato.tracker(Rails.configuration.x.google_analytics_id, nil, ssl: true)
end
def event(*args)
staccato.event(*args)
slack_notifier.try(:ping, hash_to_message(args[0]))
end
def self.event(*args)
instance... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | app/repositories/videos_repository.rb | Ruby | mit | 47 | master | 647 | class VideosRepository
SUBQUERY = <<-SQL
SELECT DISTINCT ON (origin_id) * FROM episodes
SQL
def page(number)
if Flipper.enabled?(:video)
scope_all.page(number)
else
scope_audio.page(number)
end
end
private
def scope_audio
AudioEpisode.order('created_at DESC')
end
def ... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | db/schema.rb | Ruby | mit | 47 | master | 3,845 | # 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 | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | db/migrate/20170705183806_create_episodes.rb | Ruby | mit | 47 | master | 207 | class CreateEpisodes < ActiveRecord::Migration[5.1]
def change
create_table :episodes do |t|
t.integer :podcast_id
t.timestamps
end
add_foreign_key :episodes, :podcasts
end
end |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | db/migrate/20190404064854_create_feedbacks.rb | Ruby | mit | 47 | master | 266 | class CreateFeedbacks < ActiveRecord::Migration[5.1]
def change
create_table :feedbacks do |t|
t.string :email, null: false
t.string :title, null: false
t.string :category, null: false
t.text :body
t.timestamps
end
end
end |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | db/migrate/20170706051113_add_deatails_to_episode.rb | Ruby | mit | 47 | master | 268 | class AddDeatailsToEpisode < ActiveRecord::Migration[5.1]
def change
add_column :episodes, :title, :string
add_column :episodes, :media_size, :integer
add_column :episodes, :description, :text
add_column :episodes, :published_at, :datetime
end
end |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | db/migrate/20170807182221_create_user_agents.rb | Ruby | mit | 47 | master | 226 | class CreateUserAgents < ActiveRecord::Migration[5.1]
def change
create_table :user_agents do |t|
t.datetime :last_pageview_at
t.string :user_agent
t.text :cookies
t.timestamps
end
end
end |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | db/migrate/20170807051337_fill_podcasts_titles.rb | Ruby | mit | 47 | master | 207 | class FillPodcastsTitles < ActiveRecord::Migration[5.1]
def up
Podcast.find_each do |p|
p.update_attribute(:title, (p.youtube_video_list.send(:yt_list).title rescue 'Unknown'))
end
end
end |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | db/migrate/20170807061310_add_accessed_at_to_podcasts.rb | Ruby | mit | 47 | master | 235 | class AddAccessedAtToPodcasts < ActiveRecord::Migration[5.1]
def up
add_column :podcasts, :accessed_at, :datetime
Podcast.update_all accessed_at: Time.now
end
def down
remove_column :podcasts, :accessed_at
end
end |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | db/migrate/20170904181704_create_pending_episodes.rb | Ruby | mit | 47 | master | 207 | class CreatePendingEpisodes < ActiveRecord::Migration[5.1]
def change
create_table :pending_episodes do |t|
t.string :origin_id
t.string :episode_type
t.timestamps
end
end
end |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | db/migrate/20170705181613_create_podcasts.rb | Ruby | mit | 47 | master | 227 | class CreatePodcasts < ActiveRecord::Migration[5.1]
def change
create_table :podcasts do |t|
t.string :origin_id, null: false
t.timestamps
end
add_index :podcasts, :origin_id, unique: true
end
end |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | db/migrate/20170904150353_add_metrics.rb | Ruby | mit | 47 | master | 219 | class AddMetrics < ActiveRecord::Migration[5.1]
def change
create_table :metrics do |t|
t.string :key
t.text :data_set
t.timestamps
end
add_index :metrics, :key, unique: true
end
end |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | db/migrate/20180628172821_create_flipper_tables.rb | Ruby | mit | 47 | master | 581 | class CreateFlipperTables < ActiveRecord::Migration[5.1]
def self.up
create_table :flipper_features do |t|
t.string :key, null: false
t.timestamps null: false
end
add_index :flipper_features, :key, unique: true
create_table :flipper_gates do |t|
t.string :feature_key, null: false
... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | config/application.rb | Ruby | mit | 47 | master | 1,319 | require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
# require "action_mailer/railtie"
require "action_view/railtie"
# require "action_cable/engine"
# require "sprockets/ra... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | config/routes.rb | Ruby | mit | 47 | master | 485 | Rails.application.routes.draw do
resources :feedbacks do
collection do
get 'thank_you', action: :thank_you
end
end
get 'about', to: 'pages#about'
get 'search/index'
get 'stats', to: 'stats#index'
resources :videos, only: %w( show index )
resources :playlists, only: %w( show )
resource... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | config/initializers/carierwave.rb | Ruby | mit | 47 | master | 1,394 | CarrierWave.configure do |config|
if ENV['AWS_ACCESS_KEY_ID'].present?
config.fog_provider = 'fog/aws' # required
config.fog_credentials = {
provider: 'AWS', # required
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'], # required
... |
github | sergio-fry/youtube-fetcher | https://github.com/sergio-fry/youtube-fetcher | config/initializers/cron.rb | Ruby | mit | 47 | master | 409 | if ENV['SCHEDULER_CONFIGURE'] == 'true'
begin
Delayed::Job.where.not(cron: nil).delete_all
UpdateStatsJob.set(cron: '45 * * * *').perform_later
UpdateAllPodcastsJob.set(cron: '*/10 * * * *').perform_later
CleanupLocalMediaJob.set(cron: '3 * * * *').perform_later
CleanupOutdatedJob.set(cron: '33 * ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.