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
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
config/initializers/mime_types.rb
Ruby
mit
47
master
286
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf Mime::Type.register "video/mp4", :mp4 Mime::Type.register "audio/mpeg", :mp3 Mime::Type.register "application/rss+xml", :podcast
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
config/initializers/assets.rb
Ruby
mit
47
master
546
# Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '2.0' # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path Rails.application.config....
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
config/environments/production.rb
Ruby
mit
47
master
3,396
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
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
config/environments/development.rb
Ruby
mit
47
master
1,358
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
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/rails_helper.rb
Ruby
mit
47
master
949
require 'spec_helper' ENV['RAILS_ENV'] = 'test' require File.expand_path('../../config/environment', __FILE__) abort("The Rails environment is running in production mode!") if Rails.env.production? require 'rspec/rails' Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } RSpec.configure do |config| ...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/spec_helper.rb
Ruby
mit
47
master
4,160
require 'simplecov' SimpleCov.start 'rails' require 'vcr' VCR.configure do |c| c.cassette_library_dir = 'spec/cassettes' c.hook_into :webmock c.configure_rspec_metadata! c.ignore_hosts 'aws', '0.0.0.0' end # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| # rspe...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/requests/feedbacks_spec.rb
Ruby
mit
47
master
301
require 'rails_helper' RSpec.describe "Feedbacks", type: :request do describe "GET /feedbacks" do it "works! (now write some real specs)" do FactoryGirl.create :feedback get feedbacks_path, params: { format: :atom } expect(response).to have_http_status(200) end end end
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/views/channels/show.html.erb_spec.rb
Ruby
mit
47
master
1,033
require 'rails_helper' RSpec.describe "channels/show", type: :view do subject { rendered } let(:podcast) { FactoryGirl.create(:podcast, title: 'My Podcast') } let!(:episode) { FactoryGirl.create(:episode, title: 'My Episode') } let!(:video_episode) { FactoryGirl.create(:video_episode, origin_id: episode.origin...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/repositories/videos_repository_spec.rb
Ruby
mit
47
master
554
require 'rails_helper' RSpec.describe VideosRepository do describe '#page' do subject { described_class.new.page(page) } let(:page) { 1 } let!(:episode) { FactoryGirl.create :episode } it { is_expected.to be_present } context 'when video episode exist' do before { FactoryGirl.create :vide...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/jobs/cleanup_outdated_job_spec.rb
Ruby
mit
47
master
1,290
require 'rails_helper' RSpec.describe CleanupOutdatedJob, type: :job do let(:podcast) { FactoryGirl.create :podcast } let!(:episode) { FactoryGirl.create :audio_episode, podcast: podcast } let(:episode_exists) { described_class.new.perform(podcast); AudioEpisode.exists?(episode.id)} let(:episode_is_deleted) {...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/jobs/mark_podcast_as_removed_job_spec.rb
Ruby
mit
47
master
1,237
require 'rails_helper' RSpec.describe MarkPodcastAsRemovedJob, type: :job do context 'Channel' do let(:youtube_channel_id) { 'UCX0nHcqZWDSsAPog-LXdP7A' } let(:podcast) { FactoryGirl.create :podcast, origin_id: youtube_channel_id } it 'should not mark existed channel as removed' do VCR.use_cassette...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/jobs/fetch_audio_episode_job_spec.rb
Ruby
mit
47
master
2,287
require 'rails_helper' RSpec.describe FetchAudioEpisodeJob, type: :job do include MediaFilesHelper def perform_job VCR.use_cassette :fetch_video do job.perform(podcast, youtube_video_id) end end let(:job) { FetchAudioEpisodeJob.new } let(:podcast) { FactoryGirl.create :podcast, updated_at: 1....
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/jobs/fetch_video_episode_job_spec.rb
Ruby
mit
47
master
1,880
require 'rails_helper' RSpec.describe FetchVideoEpisodeJob, type: :job do include MediaFilesHelper def perform_job VCR.use_cassette :fetch_video do job.perform(podcast, youtube_video_id) end end let(:job) { FetchVideoEpisodeJob.new } let(:podcast) { FactoryGirl.create :podcast, updated_at: 1....
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/jobs/update_all_podcasts_job_spec.rb
Ruby
mit
47
master
2,142
require 'rails_helper' RSpec.describe UpdateAllPodcastsJob, type: :job do let!(:podcast) { FactoryGirl.create :podcast, fetched_at: 2.hours.ago } it 'should work' do UpdateAllPodcastsJob.new.perform end it 'should update podcast' do expect(UpdatePodcastJob).to receive(:perform_later).with(podcast) ...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/jobs/update_podcast_job_spec.rb
Ruby
mit
47
master
1,124
require 'rails_helper' RSpec.describe UpdatePodcastJob, type: :job do let(:podcast) { FactoryGirl.create :podcast, origin_id: 'UCX0nHcqZWDSsAPog-LXdP7A' } it 'should work' do VCR.use_cassette :fetch_channel do UpdatePodcastJob.new.perform(podcast) end end it 'should update fetched_at field' do ...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/services/youtube_playlist_spec.rb
Ruby
mit
47
master
834
# 404 playlist PLKxLRVPSSlq_vwA7WLgNjw30ZZiDRdVK2 RSpec.describe YoutubePlaylist do describe '.videos' do let(:youtube_playlist_id) { 'PLOGi5-fAu8bH_T9HhH9V2B5izEE4G5waV' } it 'should give a list of videos' do VCR.use_cassette :fetch_playlist_list do channel = YoutubePlaylist.new youtube_playlist...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/services/youtube_channel_spec.rb
Ruby
mit
47
master
432
# 404 playlist PLKxLRVPSSlq_vwA7WLgNjw30ZZiDRdVK2 RSpec.describe YoutubeChannel do describe '.videos' do let(:youtube_channel_id) { 'UCX0nHcqZWDSsAPog-LXdP7A' } it 'should give a list of videos' do VCR.use_cassette :fetch_channel_list do channel = YoutubeChannel.new youtube_channel_id e...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/services/tracker_spec.rb
Ruby
mit
47
master
266
require 'rails_helper' RSpec.describe Tracker do it 'should track event' do VCR.use_cassette :google_analytics_event do expect do Tracker.event category: :video, action: :download, label: 'ABC123' end.not_to raise_error end end end
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/services/user_agents_pool_spec.rb
Ruby
mit
47
master
1,541
require 'rails_helper' RSpec.describe UserAgentsPool do before { UserAgent.delete_all } describe '.with_user_agent' do context 'a single user exists' do let!(:user_agent) { FactoryGirl.create :user_agent } it 'should get free user' do described_class.with_user_agent do |ua| expec...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/services/search_spec.rb
Ruby
mit
47
master
1,075
require 'rails_helper' RSpec.describe Search do describe 'search results' do subject(:results) { Search.call(query).map(&:origin_id) } context 'when search "mos"' do let(:query) { 'mos' } let!(:podcast_moscow) { FactoryGirl.create :podcast, title: 'Moscow' } let!(:podcast_london) { Factor...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/services/youtube_dl_spec.rb
Ruby
mit
47
master
848
require 'rails_helper' RSpec.describe YoutubeDl do let(:youtube_dl) { YoutubeDl.new } before do allow(youtube_dl).to receive(:exec) { 'some-response' } allow_any_instance_of(Normalizer).to receive(:normalize) end describe '#fetch_audio' do it 'should work' do youtube_dl.fetch_audio 'ABC123'...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/services/throttler_spec.rb
Ruby
mit
47
master
867
require 'rails_helper' RSpec.describe Throttler do let(:throttler) { described_class.new period, 'test action' } let(:period) { 1.minute } let(:object) do obj = double(:object) allow(obj).to receive(:touch) obj end before { Rails.cache.clear } it 'should make an action' do expect(object)...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/services/normalizer_spec.rb
Ruby
mit
47
master
274
require 'rails_helper' RSpec.describe Normalizer do include MediaFilesHelper let(:normalizer) { Normalizer.new } let(:audio_file) { audio_file_example_path } it 'should normalize' do expect(File.exists?(normalizer.normalize(audio_file))).to eq true end end
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/controllers/videos_controller_spec.rb
Ruby
mit
47
master
525
require 'rails_helper' RSpec.describe VideosController, type: :controller do render_views describe "GET #show" do let!(:episode) { FactoryGirl.create :episode } it "returns http success" do get :show, params: { id: episode.origin_id } expect(response).to have_http_status(:success) end e...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/controllers/feedbacks_controller_spec.rb
Ruby
mit
47
master
5,152
require 'rails_helper' # This spec was generated by rspec-rails when you ran the scaffold generator. # It demonstrates how one might use RSpec to specify the controller code that # was generated by Rails when you ran the scaffold generator. # # It assumes that the implementation code is generated by the rails scaffold...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/controllers/playlists_controller_spec.rb
Ruby
mit
47
master
1,032
require 'rails_helper' RSpec.describe PlaylistsController, type: :controller do render_views def make_request VCR.use_cassette :fetch_playlist do get :show, params: { id: youtube_playlist_id }, format: :atom end end let(:youtube_playlist_id) { 'PLOGi5-fAu8bH_T9HhH9V2B5izEE4G5waV' } let(:podc...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/controllers/stats_controller_spec.rb
Ruby
mit
47
master
227
require 'rails_helper' RSpec.describe StatsController, type: :controller do describe "GET #index" do it "returns http success" do get :index expect(response).to have_http_status(:success) end end end
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/controllers/search_controller_spec.rb
Ruby
mit
47
master
228
require 'rails_helper' RSpec.describe SearchController, type: :controller do describe "GET #index" do it "returns http success" do get :index expect(response).to have_http_status(:success) end end end
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/controllers/channels_controller_spec.rb
Ruby
mit
47
master
4,135
require 'rails_helper' RSpec.describe ChannelsController, type: :controller do describe 'GET /show' do render_views def make_request(format=:atom, type=nil) VCR.use_cassette :fetch_channel do get :show, params: { id: youtube_channel_id, type: type }, format: format end end let(...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/helpers/videos_helper_spec.rb
Ruby
mit
47
master
376
require 'rails_helper' # Specs in this file have access to a helper object that includes # the VideosHelper. For example: # # describe VideosHelper do # describe "string concat" do # it "concats two strings with spaces" do # expect(helper.concat_strings("this","that")).to eq("this that") # end # end ...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/helpers/welcome_helper_spec.rb
Ruby
mit
47
master
379
require 'rails_helper' # Specs in this file have access to a helper object that includes # the WelcomeHelper. For example: # # describe WelcomeHelper do # describe "string concat" do # it "concats two strings with spaces" do # expect(helper.concat_strings("this","that")).to eq("this that") # end # en...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/helpers/feedbacks_helper_spec.rb
Ruby
mit
47
master
442
require 'rails_helper' # Specs in this file have access to a helper object that includes # the FeedbacksHelper. For example: # # describe FeedbacksHelper do # describe "string concat" do # it "concats two strings with spaces" do # expect(helper.concat_strings("this","that")).to eq("this that") # end # ...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/helpers/stats_helper_spec.rb
Ruby
mit
47
master
373
require 'rails_helper' # Specs in this file have access to a helper object that includes # the StatsHelper. For example: # # describe StatsHelper do # describe "string concat" do # it "concats two strings with spaces" do # expect(helper.concat_strings("this","that")).to eq("this that") # end # end # ...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/helpers/channels_helper_spec.rb
Ruby
mit
47
master
382
require 'rails_helper' # Specs in this file have access to a helper object that includes # the ChannelsHelper. For example: # # describe ChannelsHelper do # describe "string concat" do # it "concats two strings with spaces" do # expect(helper.concat_strings("this","that")).to eq("this that") # end # ...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/helpers/search_helper_spec.rb
Ruby
mit
47
master
433
require 'rails_helper' # Specs in this file have access to a helper object that includes # the SearchHelper. For example: # # describe SearchHelper do # describe "string concat" do # it "concats two strings with spaces" do # expect(helper.concat_strings("this","that")).to eq("this that") # end # end ...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/routing/feedbacks_routing_spec.rb
Ruby
mit
47
master
1,049
require "rails_helper" RSpec.describe FeedbacksController, type: :routing do describe "routing" do it "routes to #index" do expect(:get => "/feedbacks").to route_to("feedbacks#index") end it "routes to #new" do expect(:get => "/feedbacks/new").to route_to("feedbacks#new") end it "ro...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/support/files.rb
Ruby
mit
47
master
473
module MediaFilesHelper # this file is safe to remove def audio_file_example_path src = Rails.root.join('spec', 'fixtures', 'audio.mp3') dst = Rails.root.join('tmp', 'test', "audio-#{rand}.mp3") `cp #{src} #{dst}` dst end # this file is safe to remove def video_file_example_path src = R...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/factories/podcasts.rb
Ruby
mit
47
master
220
FactoryGirl.define do factory :podcast do title 'Some Podcast' sequence(:origin_id) { |n| "CHANNEL-ID-#{n}" } accessed_at { Time.now } trait :playlist do source_type 'playlist' end end end
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/factories/episodes.rb
Ruby
mit
47
master
527
FactoryGirl.define do factory :audio_episode do podcast sequence(:title) { |n| "Video #{n}" } published_at { Time.now } media File.open(Rails.root.join('spec', 'fixtures', 'audio.mp3')) sequence(:origin_id) { |n| "ABC-#{n}" } end factory :video_episode do podcast title 'Video title' ...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/utils/proxy_object_spec.rb
Ruby
mit
47
master
635
require 'rails_helper' RSpec.describe ProxyObject do class RealObject def func1 1 end def func2 2 end end class MyProxy < ProxyObject def func2 2.2 end end let(:real_object) { RealObject.new } let(:proxy_object) { MyProxy.new real_object } it 'should proxy t...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/models/podcast_spec.rb
Ruby
mit
47
master
911
require 'rails_helper' RSpec.describe Podcast, type: :model do let(:podcast) { FactoryGirl.create :podcast } describe '#episodes_per_week' do subject { podcast.episodes_per_week } context 'when has no episodes' do it { is_expected.to eq 0 } end context do before do FactoryGir...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/models/user_agent_spec.rb
Ruby
mit
47
master
673
require 'rails_helper' RSpec.describe UserAgent, type: :model do describe '#cookies_jar' do before do `rm -rf #{Rails.root.join('tmp', 'cookies', '*')}` end context 'when cookies is blank' do let!(:user_agent) { FactoryGirl.create :user_agent, cookies: nil } it 'should not be exists' ...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/features/feedback_spec.rb
Ruby
mit
47
master
342
require 'rails_helper' RSpec.feature "Feedbacks", type: :feature do scenario "user fills in feedback form and see Thank You text" do visit "/" click_on "Feedback" fill_in 'Title', with: 'Nice site' fill_in 'Email', with: 'my@email.com' click_on 'Send Feedback' expect(page).to have_content "...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/features/display_videos_spec.rb
Ruby
mit
47
master
275
require 'rails_helper' RSpec.feature "DisplayVideos", type: :feature do scenario 'Display existed video' do episode = FactoryGirl.create :episode, title: 'Video title' visit video_path(episode.origin_id) expect(page).to have_content 'Video title' end end
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/features/new_channels_spec.rb
Ruby
mit
47
master
1,218
require 'rails_helper' RSpec.feature "Add new channel", type: :feature do it 'should add new channel' do VCR.use_cassette :fetch_channel do visit new_channel_url fill_in 'Paste Youtube channel/playlist URL here', with: 'https://www.youtube.com/channel/UCX0nHcqZWDSsAPog-LXdP7A' click_on 'Conve...
github
sergio-fry/youtube-fetcher
https://github.com/sergio-fry/youtube-fetcher
spec/features/search_spec.rb
Ruby
mit
47
master
380
require 'rails_helper' RSpec.feature "Search", type: :feature do scenario 'Type query and sea results' do podcast = FactoryGirl.create :podcast, title: 'Peter Episode' episode = FactoryGirl.create :episode, title: 'Moscow Episode' visit '/' fill_in 'Search', with: 'Peter' click_on 'Submit' ...
github
mperham/politics
https://github.com/mperham/politics
Rakefile
Ruby
mit
47
master
340
require 'rake/rdoctask' require 'rake/testtask' desc "Run tests" Rake::TestTask.new do |t| t.libs << ['test', 'lib'] t.test_files = FileList['test/*_test.rb'] end desc "Create rdoc" Rake::RDocTask.new do |rd| rd.main = "README.rdoc" rd.rdoc_files.include("README.rdoc", "History.rdoc", "lib/**/*.rb") end tas...
github
mperham/politics
https://github.com/mperham/politics
politics.gemspec
Ruby
mit
47
master
1,227
Gem::Specification.new do |s| s.name = "politics" s.version = "0.2.5" s.authors = "Mike Perham" s.email = "mperham@gmail.com" s.homepage = "http://github.com/mperham/politics/" s.summary = "Algorithms and Tools for Distributed Computing in Ruby." s.description = s.summary s.require_path = 'lib' # get this ea...
github
mperham/politics
https://github.com/mperham/politics
lib/politics.rb
Ruby
mit
47
master
228
module Politics def self.log=(value) @log = log end def self.log @log ||= if defined?(RAILS_DEFAULT_LOGGER) RAILS_DEFAULT_LOGGER else require 'logger' Logger.new(STDOUT) end end end
github
mperham/politics
https://github.com/mperham/politics
lib/politics/discoverable_node.rb
Ruby
mit
47
master
4,131
require 'socket' require 'ipaddr' require 'uri' require 'drb' require 'net/dns/mdns-sd' require 'net/dns/resolv-mdns' require 'net/dns/resolv-replace' =begin IRB setup: require 'lib/politics' require 'lib/politics/discoverable_node' require 'lib/politics/convention' Object.send(:include, Election::Candidate) p = Obje...
github
mperham/politics
https://github.com/mperham/politics
lib/politics/static_queue_worker.rb
Ruby
mit
47
master
7,508
require 'socket' require 'ipaddr' require 'uri' require 'drb' begin require 'net/dns/mdns-sd' require 'net/dns/resolv-mdns' require 'net/dns/resolv-replace' rescue LoadError => e puts "Unable to load net-mdns, please run `sudo gem install net-mdns`: #{e.message}" exit(1) end begin require 'memcache' rescue Lo...
github
mperham/politics
https://github.com/mperham/politics
lib/politics/token_worker.rb
Ruby
mit
47
master
5,725
begin require 'memcache' rescue LoadError => e puts "Unable to load memcache client, please run `sudo gem install memcache-client`: #{e.message}" exit(1) end module Politics # An algorithm to provide leader election between a set of identical processing daemons. # # Each TokenWorker is an instance which n...
github
mperham/politics
https://github.com/mperham/politics
examples/token_worker_example.rb
Ruby
mit
47
master
819
#gem 'mperham-politics' require 'politics' require 'politics/token_worker' # Test this example by starting memcached locally and then in two irb sessions, run this: # =begin require 'token_worker_example' p = Politics::TokenWorkerExample.new p.start =end # # You can then watch as one of them is elected leader. You...
github
mperham/politics
https://github.com/mperham/politics
examples/queue_worker_example.rb
Ruby
mit
47
master
934
#gem 'mperham-politics' require 'politics' require 'politics/static_queue_worker' # Test this example by starting memcached locally and then in two irb sessions, run this: # =begin require 'queue_worker_example' p = Politics::QueueWorkerExample.new p.start =end # # You can then watch as one of them is elected leade...
github
mperham/politics
https://github.com/mperham/politics
test/token_worker_test.rb
Ruby
mit
47
master
2,000
require 'test_helper' class TokenWorkerTest < Test::Unit::TestCase context "token workers" do setup do @harness = Class.new @harness.send(:include, Politics::TokenWorker) @harness.any_instance.stubs(:cleanup) @harness.any_instance.stubs(:loop?).returns(false) @harness.any_instanc...
github
mperham/politics
https://github.com/mperham/politics
test/static_queue_worker_test.rb
Ruby
mit
47
master
771
require File.dirname(__FILE__) + '/test_helper' Thread.abort_on_exception = true class Worker include Politics::StaticQueueWorker def initialize register_worker 'worker', 10, :iteration_length => 10 end def start process_bucket do |bucket| sleep 1 end end end class StaticQueueWorkerTes...
github
mperham/politics
https://github.com/mperham/politics
test/test_helper.rb
Ruby
mit
47
master
474
require 'rubygems' require 'test/unit' begin gem 'thoughtbot-shoulda', '>=2.0.2' require 'shoulda' rescue GemError, LoadError => e puts "Please install shoulda: `sudo gem install thoughtbot-shoulda -s http://gems.github.com`" end begin require 'mocha' rescue LoadError => e puts "Please install mocha: `sudo ...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
Gemfile
Ruby
mit
47
master
1,083
# frozen_string_literal: true source 'https://rubygems.org' ruby '2.6.3' # Declare your gem's dependencies in monarchy.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec # Declare any dependencies that ...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
monarchy.gemspec
Ruby
mit
47
master
1,251
# frozen_string_literal: true lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'monarchy/version' # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = 'monarchy' s.version = Monarchy::VERSION s.authors = ['E...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
dummy/config/application.rb
Ruby
mit
47
master
889
# frozen_string_literal: true require File.expand_path('boot', __dir__) require 'rails/all' Bundler.require(*Rails.groups) module Dummy class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in ...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
dummy/config/initializers/monarchy.rb
Ruby
mit
47
master
1,814
# frozen_string_literal: true Monarchy.configure do |config| # REQUIRED SETTINGS # You have to define which role will be the default one (read only) during inheritance. # Example role: :guest # Real case on resources: # project: (you have no roles) # section: (you have no roles) # task: (you have ...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
dummy/config/environments/production.rb
Ruby
mit
47
master
3,343
# frozen_string_literal: true 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, a...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
dummy/config/environments/test.rb
Ruby
mit
47
master
1,821
# frozen_string_literal: true Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "s...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
dummy/db/schema.rb
Ruby
mit
47
master
4,203
# 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
Exelord/Monarchy
https://github.com/Exelord/Monarchy
dummy/db/migrate/20160221133215_monarchy_create_memberships.rb
Ruby
mit
47
master
1,156
class MonarchyCreateMemberships < ActiveRecord::Migration def change create_table :monarchy_members do |t| t.belongs_to :user t.belongs_to :hierarchy t.timestamps null: false end create_table :monarchy_roles do |t| t.string :name, null: false t.integer :level, default: 0, nu...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
dummy/db/migrate/20160221132205_monarchy_create_hierarchies.rb
Ruby
mit
47
master
742
class MonarchyCreateHierarchies < ActiveRecord::Migration def change create_table :monarchy_hierarchies do |t| t.integer :parent_id t.integer :resource_id, null: false t.string :resource_type, null: false t.timestamps null: false end create_table :monarchy_hierarchy_hierarchies, i...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
dummy/db/migrate/20160815163909_task_model.rb
Ruby
mit
47
master
215
class TaskModel < ActiveRecord::Migration def change create_table :tasks do |t| t.string :name t.integer :resource_id t.string :resource_type t.timestamps null: false end end end
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
dummy/db/migrate/20160502212213_parent_as_setup.rb
Ruby
mit
47
master
200
class ParentAsSetup < ActiveRecord::Migration def change remove_column :resources, :memo_id add_column :projects, :parent_id, :integer add_column :memos, :project_id, :integer end end
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
dummy/app/models/project.rb
Ruby
mit
47
master
292
# frozen_string_literal: true class Project < ActiveRecord::Base acts_as_resource parent_as: :resource belongs_to :resource, foreign_key: :parent_id has_one :status after_create :create_status def create_status Status.create(project: self, name: 'Monarchy is OK!') end end
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
lib/monarchy.rb
Ruby
mit
47
master
1,635
# frozen_string_literal: true require 'closure_tree' require 'configurations' require 'active_record_union' require 'monarchy/exceptions' require 'monarchy/validators' require 'monarchy/tasks' require 'monarchy/engine' require 'monarchy/acts_as_role' require 'monarchy/acts_as_member' require 'monarchy/acts_as_user' ...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
lib/generators/monarchy/setup_generator.rb
Ruby
mit
47
master
699
# frozen_string_literal: true require 'rails/generators/active_record' module Monarchy class SetupGenerator < Rails::Generators::Base include Rails::Generators::Migration desc 'This generator setups Monarchy' source_root File.expand_path('../templates', __dir__) def setup_monarchy template '...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
lib/generators/monarchy/resource_generator.rb
Ruby
mit
47
master
630
# frozen_string_literal: true require 'rails/generators/active_record' module Monarchy class ResourceGenerator < Rails::Generators::NamedBase include Rails::Generators::Migration desc 'This generator creates a resourcify model' source_root File.expand_path('../templates', __dir__) def create_resou...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
lib/generators/templates/config.rb
Ruby
mit
47
master
1,881
Monarchy.configure do |config| # REQUIRED SETTINGS # You have to define which role will be the default one (read only) during inheritance. # Example role: :guest # Real case on resources: # project: (you have no roles) # section: (you have no roles) # task: (you have a member role here) # When yo...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
lib/generators/templates/migrations/hierarchy.rb
Ruby
mit
47
master
743
class MonarchyCreateHierarchies < ActiveRecord::Migration def change create_table :monarchy_hierarchies do |t| t.integer :parent_id t.integer :resource_id, null: false t.string :resource_type, null: false t.timestamps null: false end create_table :monarchy_hierarchy_hierarchies, ...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
lib/monarchy/acts_as_user.rb
Ruby
mit
47
master
6,282
# frozen_string_literal: true module Monarchy module ActsAsUser extend ActiveSupport::Concern module ClassMethods def acts_as_user extend Monarchy::ActsAsUser::SupportMethods has_many :members, class_name: "::#{Monarchy.member_class}", dependent: :destroy has_many :hierarchies...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
lib/monarchy/tasks.rb
Ruby
mit
47
master
816
# frozen_string_literal: true require 'tqdm' module Monarchy class << self def rebuild! p 'Rebuilding Monarchy...' hierarhization reparentize p 'Rebuilding Monarchy ended!' end private def hierarhization p 'Monarchy hierarchization...' Monarchy.resource_classes....
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
lib/monarchy/validators.rb
Ruby
mit
47
master
2,196
# frozen_string_literal: true module Monarchy module Validators class << self def last_role?(member, role) member(member) role(role) (member.roles - [role]).empty? end def default_role?(resource, role) resource(resource) role(role) role == resou...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
lib/monarchy/acts_as_member.rb
Ruby
mit
47
master
2,562
# frozen_string_literal: true module Monarchy module ActsAsMember extend ActiveSupport::Concern module ClassMethods def acts_as_member extend Monarchy::ActsAsMember::SupportMethods self.table_name = 'monarchy_members' delegate :resource, :resource_id, :resource_type, to: :hie...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
lib/monarchy/acts_as_role.rb
Ruby
mit
47
master
889
# frozen_string_literal: true module Monarchy module ActsAsRole extend ActiveSupport::Concern module ClassMethods def acts_as_role self.table_name = 'monarchy_roles' has_many :members_roles, dependent: :destroy, class_name: 'Monarchy::MembersRole' has_many :members, through: :...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
lib/monarchy/acts_as_resource.rb
Ruby
mit
47
master
4,451
# frozen_string_literal: true module Monarchy module ActsAsResource extend ActiveSupport::Concern module ClassMethods def acts_as_resource(options = {}) extend Monarchy::ActsAsResource::SupportMethods setup_acting parent_as(options[:parent_as]) if options[:parent_as] ...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
lib/monarchy/exceptions.rb
Ruby
mit
47
master
2,194
# frozen_string_literal: true module Monarchy module Exceptions class Error < StandardError; end class ClassNotDefined < Error def initialize(class_name) @class_name = class_name end def message "#{@class_name} class has to be initialized or exist!" end end ...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
lib/monarchy/acts_as_hierarchy.rb
Ruby
mit
47
master
6,233
# frozen_string_literal: true module Monarchy module ActsAsHierarchy extend ActiveSupport::Concern module ClassMethods def acts_as_hierarchy extend Monarchy::ActsAsHierarchy::SupportMethods self.table_name = 'monarchy_hierarchies' has_closure_tree dependent: :destroy i...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
app/models/monarchy/members_role.rb
Ruby
mit
47
master
309
# frozen_string_literal: true class Monarchy::MembersRole < ActiveRecord::Base self.table_name = 'monarchy_members_roles' belongs_to :member, class_name: "::#{Monarchy.member_class}" belongs_to :role, class_name: "::#{Monarchy.role_class}" validates :role_id, uniqueness: { scope: :member_id } end
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
spec/rails_helper.rb
Ruby
mit
47
master
2,972
# frozen_string_literal: true # This file is copied to spec/ when you run 'rails generate rspec:install' ENV['RAILS_ENV'] ||= 'test' require 'support/simplecov' require File.expand_path('../dummy/config/environment', __dir__) # Prevent database truncation if the environment is production abort('The Rails environment i...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
spec/spec_helper.rb
Ruby
mit
47
master
4,694
# frozen_string_literal: true require 'support/helpers/is_expected_block' # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will ...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
spec/support/database_cleaner.rb
Ruby
mit
47
master
311
# frozen_string_literal: true require 'database_cleaner' RSpec.configure do |config| config.before(:suite) do DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation) end config.around(:each) do |example| DatabaseCleaner.cleaning do example.run end end end
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
spec/support/simplecov.rb
Ruby
mit
47
master
463
# frozen_string_literal: true require 'simplecov' SimpleCov.start('rails') do adapters.delete(:root_filter) filters.clear add_filter 'dummy/' add_filter 'spec/' add_filter 'lib/generators/' add_filter 'lib/monarchy/version.rb' add_filter 'vendor/' add_filter do |src| src.filename !~ /^#{SimpleCov...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
spec/factories/hierarchy.rb
Ruby
mit
47
master
330
# frozen_string_literal: true FactoryBot.define do factory :hierarchy, class: Monarchy::Hierarchy do before(:create) do |hierarchy| unless hierarchy.resource Project.automatic_hierarchy = false hierarchy.resource = Project.create Project.automatic_hierarchy = true end end ...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
spec/models/member_spec.rb
Ruby
mit
47
master
6,088
# frozen_string_literal: true require 'rails_helper' describe Monarchy::Member, type: :model do it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:hierarchy) } it { is_expected.to have_many(:roles).through(:members_roles) } it { is_expected.to have_many(:members_roles).dependent(:destroy) }...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
spec/models/resource_spec.rb
Ruby
mit
47
master
14,566
# frozen_string_literal: true require 'rails_helper' describe Resource, type: :model do it { is_expected.to have_many(:members).through(:hierarchy) } it { is_expected.to have_one(:hierarchy).dependent(:destroy) } describe '.parent_as' do let!(:resource) { described_class.create } let!(:project) { creat...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
spec/models/user_spec.rb
Ruby
mit
47
master
19,203
# frozen_string_literal: true require 'rails_helper' describe User, type: :model do let!(:memo) { create :memo, parent: project } let!(:project) { create :project } let(:user) { create :user } let!(:manager_role) { create(:role, name: :manager, level: 2) } let!(:member_role) { create(:role, name: :member, l...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
spec/models/hierarchy_spec.rb
Ruby
mit
47
master
17,946
# frozen_string_literal: true require 'rails_helper' describe Monarchy::Hierarchy, type: :model do it { is_expected.to have_many(:members).dependent(:destroy) } it { is_expected.to belong_to(:resource) } it { is_expected.to validate_presence_of(:resource_id) } it { is_expected.to validate_presence_of(:resour...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
spec/models/role_spec.rb
Ruby
mit
47
master
344
# frozen_string_literal: true require 'rails_helper' describe Monarchy::Role, type: :model do it { is_expected.to have_many(:members).through(:members_roles) } it { is_expected.to have_many(:members_roles).dependent(:destroy) } it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_pr...
github
Exelord/Monarchy
https://github.com/Exelord/Monarchy
spec/monarchy/validators_spec.rb
Ruby
mit
47
master
8,632
# frozen_string_literal: true require 'rails_helper' describe Monarchy::Validators do let!(:guest_role) { create(:role, name: :guest, level: 0, inherited: false) } let!(:member_role) { create(:role, name: :member, level: 1, inherited: false, inherited_role: guest_role) } let!(:user) { create(:user) } let!(:r...
github
oruen/oa-vkontakte
https://github.com/oruen/oa-vkontakte
Rakefile
Ruby
mit
47
master
240
require 'bundler' Bundler::GemHelper.install_tasks require 'rspec/core/rake_task' require 'rake/contrib/sshpublisher' RSpec::Core::RakeTask.new(:spec) do |t| end task :default => :spec require 'yard' YARD::Rake::YardocTask.new do |t| end
github
oruen/oa-vkontakte
https://github.com/oruen/oa-vkontakte
oa-vkontakte.gemspec
Ruby
mit
47
master
955
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "oa-vkontakte/version" Gem::Specification.new do |s| s.name = %q{oa-vkontakte} s.version = Oa::Vkontakte::VERSION s.authors = ["Nick Recobra"] s.summary = %q{OmniAuth extension for vkontakte.ru authentication} s.description = %q{O...
github
oruen/oa-vkontakte
https://github.com/oruen/oa-vkontakte
spec/spec_helper.rb
Ruby
mit
47
master
278
require 'rubygems' require 'bundler' Bundler.setup require 'rspec' require 'omniauth/test' require 'rack/test' require 'oa-vkontakte' Rspec.configure do |c| c.mock_with :rspec c.include Rack::Test::Methods c.extend OmniAuth::Test::StrategyMacros, :type => :strategy end
github
oruen/oa-vkontakte
https://github.com/oruen/oa-vkontakte
spec/omniauth/strategires/vkontakte_spec.rb
Ruby
mit
47
master
2,532
# encoding: utf-8 require File.dirname(__FILE__) + '/../../spec_helper' describe OmniAuth::Strategies::Vkontakte, :type => :strategy do include OmniAuth::Test::StrategyTestCase def strategy [OmniAuth::Strategies::Vkontakte, 1983892, '6FF1PUlZfEyutJxctvtd'] end describe 'POST /auth/vkontakte_open_api/cal...
github
oruen/oa-vkontakte
https://github.com/oruen/oa-vkontakte
lib/omniauth/strategies/vkontakte.rb
Ruby
mit
47
master
2,021
require 'omniauth/vkontakte' require 'omniauth/strategies/vkontakte/view_helper' module OmniAuth class Configuration attr_accessor :vkontakte_app_id attr_accessor :vkontakte_app_key attr_accessor :vkontakte_params end end module OmniAuth module Strategies class Vkontakte include OmniAuth::...
github
oruen/oa-vkontakte
https://github.com/oruen/oa-vkontakte
lib/omniauth/strategies/vkontakte/view_helper.rb
Ruby
mit
47
master
4,264
# coding: utf-8 module OmniAuth module Strategies class Vkontakte class ViewHelper module PageHelper def vkontakte_login_page vkontakte_header + vkontakte_login_button + vkontakte_footer end def vkontakte_header <<-HEADER <!DOCTYPE...