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 | taganaka/polipus | https://github.com/taganaka/polipus | examples/error_handling.rb | Ruby | mit | 91 | master | 631 | # encoding: UTF-8
require 'polipus'
Polipus.crawler('rubygems', 'http://rubygems.org/') do |crawler|
# Handle connectivity errors
# Only runs when there is an error
crawler.on_page_error do |page|
# Don't store the page
page.storable = false
# Add the URL again to the queue
crawler.add_to_queue(p... |
github | taganaka/polipus | https://github.com/taganaka/polipus | examples/robots_txt_handling.rb | Ruby | mit | 91 | master | 364 | # encoding: UTF-8
require 'polipus'
options = {
user_agent: 'Googlebot', # Act as Google bot
obey_robots_txt: true # Follow /robots.txt rules if any
}
Polipus.crawler('rubygems', 'http://rubygems.org/', options) do |crawler|
crawler.on_page_downloaded do |page|
puts "Page title: '#{page.doc.at_css('title')... |
github | taganaka/polipus | https://github.com/taganaka/polipus | examples/survival.rb | Ruby | mit | 91 | master | 281 | # encoding: UTF-8
require 'polipus'
Polipus.crawler('rubygems', 'http://rubygems.org/') do |crawler|
# In-place page processing
crawler.on_page_downloaded do |page|
# A nokogiri object
puts "Page title: '#{page.doc.css('title').text}' Page url: #{page.url}"
end
end |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus.rb | Ruby | mit | 91 | master | 15,602 | # encoding: UTF-8
require 'redis'
require 'redis/connection/hiredis'
require 'redis-queue'
require 'polipus/version'
require 'polipus/http'
require 'polipus/storage'
require 'polipus/url_tracker'
require 'polipus/plugin'
require 'polipus/queue_overflow'
require 'polipus/robotex'
require 'polipus/signal_handler'
require... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/page.rb | Ruby | mit | 91 | master | 7,314 | # encoding: UTF-8
require 'nokogiri'
require 'json'
require 'ostruct'
require 'set'
require 'kconv'
module Polipus
class Page
# The URL of the page
attr_reader :url
# The raw HTTP response body of the page
attr_reader :body
# Headers of the HTTP response
attr_reader :headers
# URL of the ... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/robotex.rb | Ruby | mit | 91 | master | 3,691 | # encoding: UTF-8
require 'open-uri'
require 'uri'
require 'timeout'
module Polipus
# Original code taken from
# https://github.com/chriskite/robotex/blob/master/lib/robotex.rb
class Robotex
DEFAULT_TIMEOUT = 3
VERSION = '1.0.0'
attr_reader :user_agent
class ParsedRobots
def initialize(ur... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/http.rb | Ruby | mit | 91 | master | 8,307 | # encoding: UTF-8
require 'net/https'
require 'polipus/page'
require 'zlib'
require 'http/cookie'
module Polipus
class HTTP
# Maximum number of redirects to follow on each get_response
REDIRECT_LIMIT = 5
RESCUABLE_ERRORS = [
EOFError,
Errno::ECONNREFUSED,
Errno::ECONNRESET,
Errno:... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/storage.rb | Ruby | mit | 91 | master | 1,100 | require 'polipus/storage/base'
module Polipus
module Storage
COLLECTION = 'pages'
def self.mongo_store(mongo = nil, collection = COLLECTION, except = [])
require 'polipus/storage/mongo_store'
mongo ||= Mongo::Client.new(['localhost:27_017'], database: 'polipus')
fail 'First argument must b... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/queue_overflow.rb | Ruby | mit | 91 | master | 1,075 | # encoding: UTF-8
require 'polipus/queue_overflow/manager'
require 'polipus/queue_overflow/worker'
module Polipus
module QueueOverflow
def self.mongo_queue(mongo_db, queue_name, options = {})
require 'polipus/queue_overflow/mongo_queue'
mongo_db ||= Mongo::Client.new(['localhost:27_017'], database: 'p... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/signal_handler.rb | Ruby | mit | 91 | master | 714 | # encoding: UTF-8
require 'singleton'
module Polipus
class SignalHandler
include Singleton
attr_accessor :terminated
attr_accessor :enabled
def initialize
self.terminated = false
self.enabled = false
end
def self.enable
trap(:INT) do
exit unless self.enabled?
... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/plugin.rb | Ruby | mit | 91 | master | 240 | # encoding: UTF-8
module Polipus
module Plugin
@@plugins = {}
def self.register(plugin, options = {})
o = plugin.new(options)
@@plugins[o.class.name] = o
end
def self.plugins
@@plugins
end
end
end |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/url_tracker.rb | Ruby | mit | 91 | master | 621 | # encoding: UTF-8
module Polipus
module UrlTracker
def self.bloomfilter(options = {})
require 'polipus/url_tracker/bloomfilter'
options[:size] ||= 1_000_000
options[:error_rate] ||= 0.01
options[:key_name] ||= 'polipus-bloomfilter'
options[:redis] ||= Redis.current
... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/queue_overflow/mongo_queue_capped.rb | Ruby | mit | 91 | master | 785 | # encoding: UTF-8
require 'polipus/queue_overflow/mongo_queue'
module Polipus
module QueueOverflow
class MongoQueueCapped < MongoQueue
def initialize(mongo_db, queue_name, options = {})
super
@max = @options[:max]
end
def push(data)
super
@semaphore.synchronize d... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/queue_overflow/worker.rb | Ruby | mit | 91 | master | 746 | # encoding: UTF-8
module Polipus
module QueueOverflow
class Worker
def initialize(manager)
@logger = manager.polipus.logger
@delay = manager.polipus.options[:queue_overflow_manager_check_time]
@adapter = manager.polipus.queue_overflow_adapter
@manager = manager
end
... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/queue_overflow/dev_null_queue.rb | Ruby | mit | 91 | master | 498 | # encoding: UTF-8
require 'thread'
module Polipus
module QueueOverflow
class DevNullQueue
def initialize
end
def length
0
end
def empty?
true
end
def clear
end
def push(_data)
end
def pop(_ = false)
nil
end
... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/queue_overflow/manager.rb | Ruby | mit | 91 | master | 1,712 | # encoding: UTF-8
module Polipus
module QueueOverflow
class Manager
attr_accessor :url_filter
attr_reader :polipus
def initialize(polipus, main_q, item_limit)
@polipus = polipus
@main_q = main_q
@adapter = @polipus.queue_overflow_adapter
@item_limit = item_limit
... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/queue_overflow/mongo_queue.rb | Ruby | mit | 91 | master | 1,685 | # encoding: UTF-8
require 'thread'
require 'mongo'
module Polipus
module QueueOverflow
class MongoQueue
def initialize(mongo_db, queue_name, options = {})
@mongo_db = mongo_db
@collection_name = "polipus_q_overflow_#{queue_name}"
@semaphore = Mutex.new
@options = options
... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/url_tracker/bloomfilter.rb | Ruby | mit | 91 | master | 428 | # encoding: UTF-8
require 'redis-bloomfilter'
module Polipus
module UrlTracker
class Bloomfilter
def initialize(options = {})
@bf = Redis::Bloomfilter.new options
end
def visited?(url)
@bf.include?(url)
end
def visit(url)
@bf.insert url
end
def ... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/url_tracker/redis_set.rb | Ruby | mit | 91 | master | 499 | # encoding: UTF-8
module Polipus
module UrlTracker
class RedisSet
def initialize(options = {})
@redis = options[:redis] || Redis.current
@set_name = options[:key_name]
end
def visited?(url)
@redis.sismember(@set_name, url)
end
def visit(url)
@redi... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/plugins/cleaner.rb | Ruby | mit | 91 | master | 736 | # encoding: UTF-8
module Polipus
module Plugin
class Cleaner
def initialize(options = {})
@reset = options[:reset] ||= false
end
def on_initialize(crawler)
crawler.logger.info { 'Cleaner plugin loaded' }
unless @reset
crawler.logger.info { 'Cleaner plugin is di... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/plugins/sleeper.rb | Ruby | mit | 91 | master | 486 | # encoding: UTF-8
module Polipus
module Plugin
class Sleeper
def initialize(options = {})
@delay = options[:delay] ||= 1
end
def on_initialize(crawler)
crawler.logger.info { "Sleeper plugin loaded, sleep for #{@delay} after each request" }
proc do
# Set to 1 th... |
github | taganaka/polipus | https://github.com/taganaka/polipus | lib/polipus/plugins/sample.rb | Ruby | mit | 91 | master | 293 | # encoding: UTF-8
module Polipus
module Plugin
class Sample
def initialize(_options = {})
end
def on_initialize(_crawler)
proc do
@options.each { |k, v| @logger.info { "Polipus configuration: #{k} => #{v}" } }
end
end
end
end
end |
github | jackc/edge | https://github.com/jackc/edge | edge.gemspec | Ruby | mit | 91 | master | 1,008 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/edge/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Jack Christensen"]
gem.email = ["jack@jackchristensen.com"]
gem.description = %q{Graph functionality for ActiveRecord}
gem.summary = %q{Graph functionality f... |
github | jackc/edge | https://github.com/jackc/edge | Rakefile | Ruby | mit | 91 | master | 292 | #!/usr/bin/env rake
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new
task :default => :spec
namespace :db do
desc 'bootstrap database'
task :setup do
sh "createdb edge_test || true"
sh "psql edge_test < spec/database_structure.sql"
end
end |
github | jackc/edge | https://github.com/jackc/edge | Guardfile | Ruby | mit | 91 | master | 255 | # A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/edge/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
end |
github | jackc/edge | https://github.com/jackc/edge | lib/edge/forest.rb | Ruby | mit | 91 | master | 5,624 | module Edge
module Forest
# acts_as_forest models a tree/multi-tree structure.
module ActsAsForest
# options:
#
# * dependent - passed to children has_many (default: none)
# * foreign_key - column name to use for parent foreign_key (default: parent_id)
# * order - how to order ch... |
github | jackc/edge | https://github.com/jackc/edge | bench/forest_find.rb | Ruby | mit | 91 | master | 1,946 | require 'benchmark_helper'
options = {}
optparse = OptionParser.new do |opts|
options[:num_trees] = 50
opts.on '-t NUM', '--trees NUM', Integer, 'Number of trees to create' do |n|
options[:num_trees] = n
end
options[:depth] = 3
opts.on '-d NUM', '--depth NUM', Integer, 'Depth of trees' do |n|
opti... |
github | jackc/edge | https://github.com/jackc/edge | bench/benchmark_helper.rb | Ruby | mit | 91 | master | 451 | require 'edge'
require 'benchmark'
require 'securerandom'
require 'optparse'
database_config = YAML.load_file(File.expand_path("../database.yml", __FILE__))
ActiveRecord::Base.establish_connection database_config["bench"]
class ActsAsForestRecord < ActiveRecord::Base
acts_as_forest
end
def clean_database
ActsAsF... |
github | jackc/edge | https://github.com/jackc/edge | spec/forest_spec.rb | Ruby | mit | 91 | master | 7,270 | require 'spec_helper'
class Location < ActiveRecord::Base
acts_as_forest :order => "name"
end
class BodyPart < ActiveRecord::Base
acts_as_forest :foreign_key => "body_part_id"
end
Location.delete_all
describe "Edge::Forest" do
let(:skeleton) { BodyPart.create! }
let!(:usa) { Location.create! :name => "USA" ... |
github | jackc/edge | https://github.com/jackc/edge | spec/spec_helper.rb | Ruby | mit | 91 | master | 512 | require 'edge'
require 'yaml'
require 'rspec'
database_config = YAML.load_file(File.expand_path("../database.yml", __FILE__))
ActiveRecord::Base.establish_connection database_config["test"]
RSpec.configure do |config|
config.before(:all) do |example|
ActiveRecord::Base.connection.execute <<-SQL
truncate ... |
github | edisonywh/behaves | https://github.com/edisonywh/behaves | behaves.gemspec | Ruby | mit | 91 | master | 1,437 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "behaves/version"
Gem::Specification.new do |spec|
spec.name = "behaves"
spec.version = Behaves::VERSION
spec.authors = ["Edison Yap"]
spec.email = ["edisonywh@gmail.com"]
... |
github | edisonywh/behaves | https://github.com/edisonywh/behaves | spec/behaves_spec.rb | Ruby | mit | 91 | master | 7,888 | RSpec.describe Behaves do
it 'has a version number' do
expect(Behaves::VERSION).not_to be nil
end
before do
monkey_patch_behaves
Dog = Class.new
Animal = Class.new
Interface = Class.new
Implementor = Class.new
end
after do
class_cleaner(Animal, Dog, Interface, Implementor)
end... |
github | edisonywh/behaves | https://github.com/edisonywh/behaves | spec/spec_helper.rb | Ruby | mit | 91 | master | 425 | require "bundler/setup"
require 'pry'
require "behaves"
require 'rspec'
require 'rspec_junit_formatter'
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main... |
github | edisonywh/behaves | https://github.com/edisonywh/behaves | lib/behaves.rb | Ruby | mit | 91 | master | 2,472 | require 'behaves/version'
require 'set'
module Behaves
def implements(*methods, **opts)
@_public_behaviors ||= Set.new
@_private_behaviors ||= Set.new
if opts[:private] == true
@_private_behaviors += Set.new(methods)
else
@_public_behaviors += Set.new(methods)
end
end
def inje... |
github | maccman/dhash | https://github.com/maccman/dhash | dhash.gemspec | Ruby | mit | 91 | master | 825 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'dhash/version'
Gem::Specification.new do |spec|
spec.name = "dhash"
spec.version = Dhash::VERSION
spec.authors = ["Alex MacCaw"]
spec.email = ["info@eribium.o... |
github | maccman/dhash | https://github.com/maccman/dhash | lib/dhash.rb | Ruby | mit | 91 | master | 682 | require 'dhash/version'
require 'RMagick'
module Dhash extend self
def hamming(a, b)
(a^b).to_s(2).count('1')
end
def calculate(file, hash_size = 8)
image = Magick::Image.read(file).first
image = image.quantize(256, Magick::Rec601LumaColorspace, Magick::NoDitherMethod, 8)
image = image.resize!(h... |
github | maccman/dhash | https://github.com/maccman/dhash | test/test_dhash.rb | Ruby | mit | 91 | master | 913 | require 'minitest/autorun'
require 'dhash'
require 'pp'
describe Dhash do
it 'should have similar hashes for low/high of same image' do
hash1 = Dhash.calculate(File.expand_path('../images/face-high.jpg', __FILE__))
hash2 = Dhash.calculate(File.expand_path('../images/face-low.jpg', __FILE__))
assert Dhas... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | Rakefile | Ruby | apache-2.0 | 91 | master | 1,356 | require 'bundler/setup'
require 'bundler/gem_tasks'
# Immediately sync all stdout so that tools like buildbot can
# immediately load in the output.
$stdout.sync = true
$stderr.sync = true
# Change to the directory of this file.
Dir.chdir(File.expand_path("../", __FILE__))
if (Rake.application.top_level_tasks == ["bu... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | vagrant-chef-zero.gemspec | Ruby | apache-2.0 | 91 | master | 1,133 | $:.unshift File.expand_path("../lib", __FILE__)
require "vagrant-chef-zero/version"
Gem::Specification.new do |s|
s.name = "vagrant-chef-zero"
s.version = VagrantPlugins::ChefZero.get_version()
s.platform = Gem::Platform::RUBY
s.authors = "Andrew Gross, Miguel Ferreira, Timothy van Za... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | Gemfile | Ruby | apache-2.0 | 91 | master | 798 | source "https://rubygems.org"
gemspec
group :development do
# We depend on Vagrant for development, but we don't add it as a
# gem dependency because we expect to be installed within the
# Vagrant environment itself using `vagrant plugin`.
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag ... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | Vagrantfile | Ruby | apache-2.0 | 91 | master | 722 | Vagrant.require_plugin "vagrant-chef-zero"
#Vagrant.require_plugin "vagrant-berkshelf"
Vagrant.configure("2") do |config|
# config.berkshelf.enabled = true
config.chef_zero.chef_repo_path = "spec/vagrant-chef-zero/fixtures"
#config.chef_zero.nodes = "spec/vagrant-chef-zero/fixtures/nodes"
#config.chef_ze... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | lib/vagrant-chef-zero.rb | Ruby | apache-2.0 | 91 | master | 342 | begin
require "vagrant"
rescue LoadError
raise "The Vagrant Chef-Zero plugin must be run within Vagrant."
end
module VagrantPlugins
module ChefZero
autoload :Env, 'vagrant-chef-zero/env'
autoload :Action, 'vagrant-chef-zero/action'
autoload :Config, 'vagrant-chef-zero/config'
end
end
require "vagr... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | lib/vagrant-chef-zero/env_helpers.rb | Ruby | apache-2.0 | 91 | master | 4,050 | module VagrantPlugins
module ChefZero
module EnvHelpers
def self.mutex
# handle actions that may run in parallel with certain providers
@mutex ||= Mutex.new
end
def self.active_machines(env)
@active ||= env[:machine].env.active_machines
end
def write_knife_... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | lib/vagrant-chef-zero/plugin.rb | Ruby | apache-2.0 | 91 | master | 1,762 | require 'ridley'
# This is a sanity check to make sure no one is attempting to install
# this into an early Vagrant version.
if Vagrant::VERSION < "1.2.0"
raise "The Vagrant Chef Zero plugin is only compatible with Vagrant 1.2+"
end
module VagrantPlugins
module ChefZero
class Plugin < Vagrant.plugin("2")
... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | lib/vagrant-chef-zero/version.rb | Ruby | apache-2.0 | 91 | master | 876 | module VagrantPlugins
module ChefZero
VERSION = "1.0.1"
NAME = "vagrant-chef-zero"
def self.describe(opts={})
query = 'git describe --tags --match="v*"'
args = opts.map do |k, v|
"--#{k.to_s}=#{v.to_s}"
end.join(" ")
`#{query} #{args}`
end
def self.git_version(opt... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | lib/vagrant-chef-zero/server_helpers.rb | Ruby | apache-2.0 | 91 | master | 4,125 | require 'vagrant/util'
module VagrantPlugins
module ChefZero
module ServerHelpers
def start_chef_zero(env)
require 'chef_zero/server'
port = get_port(env)
host = get_host(env)
unless chef_zero_server_running?(host, port)
chef_zero_binary = get_chef_zero_binary(e... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | lib/vagrant-chef-zero/config.rb | Ruby | apache-2.0 | 91 | master | 2,644 | require "vagrant"
module VagrantPlugins
module ChefZero
class Config < Vagrant.plugin("2", :config)
# Path to role fixtures
#
# @return [String]
attr_accessor :roles
# Path to environment fixtures
#
# @return [String]
attr_accessor :environments
# Path to ... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | lib/vagrant-chef-zero/env.rb | Ruby | apache-2.0 | 91 | master | 692 | module VagrantPlugins
module ChefZero
# @author Jamie Winsor <reset@riotgames.com>
#
# Environment data to build up and persist through the middleware chain
class Env
# @return [Vagrant::UI::Colored]
attr_accessor :ui
# @return [ChefZero::Server]
attr_accessor :server
de... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | lib/vagrant-chef-zero/action.rb | Ruby | apache-2.0 | 91 | master | 1,217 | require 'vagrant/action/builder'
require 'vagrant-chef-zero/env_helpers'
require 'vagrant-chef-zero/server_helpers'
module VagrantPlugins
module ChefZero
module Action
include Vagrant::Action::Builtin
autoload :Reconfig, 'vagrant-chef-zero/action/reconfig'
autoload :Start, 'vagrant-chef-ze... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | lib/vagrant-chef-zero/action/start.rb | Ruby | apache-2.0 | 91 | master | 535 | module VagrantPlugins
module ChefZero
module Action
class Start
include VagrantPlugins::ChefZero::EnvHelpers
include VagrantPlugins::ChefZero::ServerHelpers
def initialize(app, env)
@app = app
@key = get_key_path(env)
end
def call(env)
... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | lib/vagrant-chef-zero/action/stop.rb | Ruby | apache-2.0 | 91 | master | 829 | module VagrantPlugins
module ChefZero
module Action
class Stop
include VagrantPlugins::ChefZero::EnvHelpers
include VagrantPlugins::ChefZero::ServerHelpers
def initialize(app, env)
@app = app
@key = get_key_path(env)
end
def call(env)
... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | lib/vagrant-chef-zero/action/upload.rb | Ruby | apache-2.0 | 91 | master | 6,928 | module VagrantPlugins
module ChefZero
module Action
class Upload
include VagrantPlugins::ChefZero::EnvHelpers
include VagrantPlugins::ChefZero::ServerHelpers
def initialize(app, env)
@conn = nil
@app = app
@env = env
@url = server_info(env)[... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | lib/vagrant-chef-zero/action/reconfig.rb | Ruby | apache-2.0 | 91 | master | 945 | module VagrantPlugins
module ChefZero
module Action
class Reconfig
include VagrantPlugins::ChefZero::EnvHelpers
include VagrantPlugins::ChefZero::ServerHelpers
def initialize(app, env)
@app = app
if chef_zero_enabled?(env)
@key = get_key_path(env)
... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | test/integration/Vagrantfile | Ruby | apache-2.0 | 91 | master | 1,410 | # -*- mode: ruby -*-
# vi: set ft=ruby :
test_machines = {
'windows' => {
'box' => ENV['VAGRANT_TEST_WINDOWS_BOX'], # sbp_windows_2012_r2_20141211_1
'communicator' => :winrm,
'guest' => :windows
},
'centos' => {
'box' => ENV['VAGRANT_TEST_CENTOS_BOX'], # opscode-centos-7.1
'co... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | spec/spec_helper.rb | Ruby | apache-2.0 | 91 | master | 381 | require 'json'
require 'simplecov'
require 'coveralls'
require_relative "../lib/vagrant-chef-zero"
require_relative "../lib/vagrant-chef-zero/server_helpers.rb"
require_relative "../lib/vagrant-chef-zero.rb"
RSpec.configure do |c|
c.expect_with(:rspec) { |c| c.syntax = :should }
end
SimpleCov.formatter = SimpleCov... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | spec/lib/config_spec.rb | Ruby | apache-2.0 | 91 | master | 2,818 | require_relative '../spec_helper'
describe "VagrantPlugins::ChefZero::Config" do
before do
class DummyClass < VagrantPlugins::ChefZero::Config
end
end
describe "config object is created" do
it "should set all paths to nil" do
d = DummyClass.new
d.finalize!
d.chef_repo_path.should... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | spec/lib/server_helpers_spec.rb | Ruby | apache-2.0 | 91 | master | 1,657 | require_relative '../spec_helper'
require 'chef_zero/server'
describe VagrantPlugins::ChefZero::ServerHelpers do
class DummyServerHelpers
include VagrantPlugins::ChefZero::ServerHelpers
end
class DummyChefZeroEnv < VagrantPlugins::ChefZero::Env
end
let(:d) { DummyServerHelpers.new }
let(:env) {
... |
github | schubergphilis/vagrant-chef-zero | https://github.com/schubergphilis/vagrant-chef-zero | spec/lib/action/upload_spec.rb | Ruby | apache-2.0 | 91 | master | 4,707 | require_relative '../../spec_helper'
describe "VagrantPlugins::ChefZero::Action::Upload" do
before(:each) do
# For now a silly helper to create fake nested env objects
ui = double("bar")
ui.stub(:warn).and_return(nil)
$fake_chef_zero = double("foo")
$fake_chef_zero.stub(:ui).and_return(ui)
... |
github | syedmusamah/grape_on_rails_routes | https://github.com/syedmusamah/grape_on_rails_routes | Gemfile | Ruby | mit | 91 | master | 577 | source 'https://rubygems.org'
# Declare your gem's dependencies in grape_on_rails_routes.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 are still in development here i... |
github | syedmusamah/grape_on_rails_routes | https://github.com/syedmusamah/grape_on_rails_routes | Rakefile | Ruby | mit | 91 | master | 229 | begin
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task default: :spec
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end |
github | syedmusamah/grape_on_rails_routes | https://github.com/syedmusamah/grape_on_rails_routes | grape_on_rails_routes.gemspec | Ruby | mit | 91 | master | 804 | $:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "grape_on_rails_routes/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "grape_on_rails_routes"
s.homepage = "https://github.com/syedmusamah/grape_on_rails_routes"
s.ver... |
github | syedmusamah/grape_on_rails_routes | https://github.com/syedmusamah/grape_on_rails_routes | spec/rake_grape_routes_spec.rb | Ruby | mit | 91 | master | 1,346 | require 'spec_helper'
require 'open3'
RSpec.describe 'rake grape:routes' do
let(:rails_app_dir) { File.expand_path('../dummy', __FILE__) }
it 'is included into list of all tasks' do
stdout, status = Open3.capture2("cd #{rails_app_dir} && rake --tasks")
expect(status).to be_success
expect(stdout).to in... |
github | syedmusamah/grape_on_rails_routes | https://github.com/syedmusamah/grape_on_rails_routes | spec/dummy/app/api/statuses_api.rb | Ruby | mit | 91 | master | 935 | class StatusesApi < Grape::API
version 'v1'
format :json
prefix :api
resource :statuses do
desc 'Return a public timeline.'
get :public_timeline do
[{text: "test"}]
end
desc 'Return a personal timeline.'
get :home_timeline do
[{text: "test"}]
end
desc 'Return a status.... |
github | syedmusamah/grape_on_rails_routes | https://github.com/syedmusamah/grape_on_rails_routes | spec/dummy/config/application.rb | Ruby | mit | 91 | master | 810 | 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 "sp... |
github | syedmusamah/grape_on_rails_routes | https://github.com/syedmusamah/grape_on_rails_routes | spec/dummy/config/environments/development.rb | Ruby | mit | 91 | master | 482 | 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 | syedmusamah/grape_on_rails_routes | https://github.com/syedmusamah/grape_on_rails_routes | spec/dummy/config/environments/test.rb | Ruby | mit | 91 | master | 1,171 | 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 "scratch space" for the test suit... |
github | syedmusamah/grape_on_rails_routes | https://github.com/syedmusamah/grape_on_rails_routes | lib/tasks/grape.rake | Ruby | mit | 91 | master | 1,548 | namespace :grape do
desc "show API routes"
task routes: :environment do
mapping = method_mapping
grape_klasses = ObjectSpace.each_object(Class).select { |klass| klass < Grape::API }
routes = grape_klasses.
flat_map(&:routes).
uniq { |r| r.send(mapping[:path]) + r.send(mapping[:method]).to_s... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | Gemfile | Ruby | mit | 91 | master | 390 | # frozen_string_literal: true
source "https://rubygems.org"
# Specify your gem's dependencies in protos.gemspec
gemspec
gem "benchmark"
gem "benchmark-ips"
gem "benchmark-memory"
gem "capybara"
gem "debug", require: "debug/prelude"
gem "memory_profiler"
gem "phlex-testing-capybara"
gem "rake"
gem "rspec"
gem "ruboco... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | protos.gemspec | Ruby | mit | 91 | master | 1,854 | # frozen_string_literal: true
require_relative "lib/protos/version"
Gem::Specification.new do |spec|
spec.name = "protos"
spec.version = Protos::VERSION
spec.authors = ["Nolan J Tait"]
spec.email = ["nolanjtait@gmail.com"]
spec.summary = "A UI component library built with phlex and daisyui"
spec.descript... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos.rb | Ruby | mit | 91 | master | 1,713 | # frozen_string_literal: true
require "json"
require "dry-types"
require "dry-initializer"
require "phlex"
require "tailwind_merge"
module Protos
class Error < StandardError; end
autoload :Version, "protos/version"
autoload :Types, "protos/types"
autoload :TokenList, "protos/token_list"
autoload :Component... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/collapse.rb | Ruby | mit | 91 | master | 3,615 | # frozen_string_literal: true
module Protos
# A collapsible container that can be expanded or collapsed. The title
# is visible at all times, and the content is only visible when expanded.
#
# @see https://daisyui.com/components/collapse/
#
# @example Basic collapse with checkbox
# render Protos::Colla... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/floating_action_button.rb | Ruby | mit | 91 | master | 1,024 | # frozen_string_literal: true
module Protos
# @see https://daisyui.com/components/fab
class FloatingActionButton < Component
autoload :OpenButton, "protos/floating_action_button/open_button"
autoload :CloseButton, "protos/floating_action_button/close_button"
option :flower, type: Types::Bool, default:... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/modal.rb | Ruby | mit | 91 | master | 2,009 | # frozen_string_literal: true
module Protos
# A modal component that can be triggered by a button or a link and
# will open a fullscreen modal, usually with a close button.
#
# @example Basic modal
# render Protos::Modal.new do |modal|
# modal.trigger { "Open Modal" }
# modal.dialog do
# ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/diff.rb | Ruby | mit | 91 | master | 1,930 | # frozen_string_literal: true
module Protos
# A diff component for comparing two items side by side with a resizable
# divider
#
# @example Basic diff comparison
# render Protos::Diff.new do |diff|
# diff.item_one do
# img(src: "image1.jpg", alt: "Before")
# end
# diff.resizer
#... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/alert.rb | Ruby | mit | 91 | master | 2,491 | # frozen_string_literal: true
module Protos
# A component that displays messages (usually from flashes). These can
# be used in combination with Protos::Toast to have popup notifications.
#
# @example
# render Protos::Alert.new(color: :success) do |alert|
# alert.icon { "✔️" }
# span { "Operati... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/toast.rb | Ruby | mit | 91 | master | 1,950 | # frozen_string_literal: true
module Protos
# A toast component that can be used to display messages to the user
# that popup at a fixed position on the screen.
#
# @see https://daisyui.com/components/toast/
#
# @example
# render Protos::Toast.new(position: :top_center) do |toast|
# div(class: "a... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/theme.rb | Ruby | mit | 91 | master | 2,971 | # frozen_string_literal: true
module Protos
# A class that holds data for a theme. This class is used to safely
# merge in user supplied css classes into a default theme.
# This is the object that is returned by `css` and used to set slots for
# a component style.
class Theme
class << self
def merg... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/dropdown.rb | Ruby | mit | 91 | master | 2,258 | # frozen_string_literal: true
module Protos
# A dropdown component is basically a popover with a specific list of
# items in a menu. It should be preferred to a popover when the content is
# a list of actions rather than some content in its own right.
#
# Dropdowns, and popovers in general, use tippy.js to p... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/tabs.rb | Ruby | mit | 91 | master | 1,647 | # frozen_string_literal: true
module Protos
# A tabs component
#
# @see https://daisyui.com/components/tab/
#
# @example
# render Protos::Tabs.new(type: :boxed, size: :lg) do |tabs|
# tabs.tab(active: true) { "Tab 1" }
# tabs.tab { "Tab 2" }
# tabs.tab(disabled: true) { "Tab 3" }
# ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/steps.rb | Ruby | mit | 91 | master | 1,079 | # frozen_string_literal: true
module Protos
# A steps component
#
# @see https://daisyui.com/components/steps/
#
# @example
# render Protos::Steps.new(vertical: true) do |steps|
# steps.step(type: :primary) { "Step 1" }
# steps.step(type: :primary) { "Step 2" }
# steps.step { "Step 3" }... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/button.rb | Ruby | mit | 91 | master | 3,093 | # frozen_string_literal: true
module Protos
# @see https://daisyui.com/components/button/
#
# @example Basic button
# render Protos::Button.new { "Click me" }
#
# @example Primary large button
# render Protos::Button.new(color: :primary, size: :lg) { "Submit" }
class Button < Component
Variants... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/status.rb | Ruby | mit | 91 | master | 1,469 | # frozen_string_literal: true
module Protos
# A status component
#
# @example
# render Protos::Status.new(type: :success, size: :lg) { "Active" }
#
# @example With different types
# render Protos::Status.new(type: :error) { "Error" }
# render Protos::Status.new(type: :warning) { "Warning" }
# ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/table.rb | Ruby | mit | 91 | master | 3,459 | # frozen_string_literal: true
module Protos
# A table component
#
# @see https://daisyui.com/components/table/
#
# @example
# render Protos::Table.new(size: :lg, striped: true) do |table|
# table.caption { "My Table Caption" }
# table.head do
# table.header { "Header 1" }
# end
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/menu.rb | Ruby | mit | 91 | master | 1,877 | # frozen_string_literal: true
module Protos
# A menu of links or actions
#
# @see https://daisyui.com/components/menu/
#
# @example Basic vertical menu
# render Protos::Menu.new(size: :lg) do |menu|
# menu.item { a(href: "/home") { "Home" } }
# menu.item { a(href: "/about") { "About" } }
# ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/component.rb | Ruby | mit | 91 | master | 3,403 | # frozen_string_literal: true
module Protos
# The base component class that all Protos components inherit from.
#
# Provides core functionality for:
# - Theme-based styling system
# - HTML attribute management
# - Dry::Initializer for component options
# - Phlex::HTML integration for view templates
#
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/typography.rb | Ruby | mit | 91 | master | 797 | # frozen_string_literal: true
module Protos
# The core typography module that can be mixedin to override the
# default elements with custom elements.
module Typography
autoload :Heading, "protos/typography/heading"
autoload :Paragraph, "protos/typography/paragraph"
autoload :InlineLink, "protos/typog... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/chat_bubble.rb | Ruby | mit | 91 | master | 2,416 | # frozen_string_literal: true
module Protos
# A chat bubble component that contains a message and possibly some
# metadata and an image. Each chat bubble would represent a single message
# in a larger chat history.
#
# @see https://daisyui.com/components/chat/
#
# @example Basic chat bubble
# render ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/combobox.rb | Ruby | mit | 91 | master | 3,232 | # frozen_string_literal: true
module Protos
# A combobox is a combination of a text input and a list of options.
# It makes selecting values from a large list easier by filtering the list.
# Comboboxes use popovers and command to create the list of options.
#
# @example Basic combobox
# render Protos::Co... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/card.rb | Ruby | mit | 91 | master | 3,115 | # frozen_string_literal: true
module Protos
# A card component for displaying content in a contained panel
#
# @see https://daisyui.com/components/card/
#
# @example Basic card
# render Protos::Card.new do |card|
# card.image { img(src: "image.jpg", alt: "Card image") }
# card.body do
# ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/mix.rb | Ruby | mit | 91 | master | 1,041 | # frozen_string_literal: true
module Protos
# This class is responsible for safely merging in both user supplied
# and default attributes. When a user adds { data: { controller: "foo" }} to
# their component. This will merge the value in so that any default
# controllers do not get overridden.
module Mix
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/timeline.rb | Ruby | mit | 91 | master | 1,995 | # frozen_string_literal: true
module Protos
# A timeline component
#
# @see https://daisyui.com/components/timeline/
#
# @example
# render Protos::Timeline.new(vertical: true) do |timeline|
# timeline.item do
# timeline.left { "2023" }
# timeline.center { "●" }
# timeline.ri... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/attributes.rb | Ruby | mit | 91 | master | 1,033 | # frozen_string_literal: true
module Protos
# A class that represents the attributes of a component. This would be
# all html options except for `class` and `theme`.
class Attributes
def initialize(attrs = {}, **kwargs)
@attrs = attrs.merge!(kwargs)
end
# Accesses the value for a given attribu... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/hero.rb | Ruby | mit | 91 | master | 1,957 | # frozen_string_literal: true
module Protos
# A hero component for a page. It will center the content and
# optionally layout an image for a responsive layout.
#
# @see https://daisyui.com/components/hero/
#
# @example Basic hero with content
# render Protos::Hero.new do |hero|
# hero.content do
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/stats.rb | Ruby | mit | 91 | master | 2,263 | # frozen_string_literal: true
module Protos
# A stats component that contains a collection of stats
#
# @see https://daisyui.com/components/stat/
#
# @example
# render Protos::Stats.new do |stats|
# stats.stat do
# stats.title { "Total Page Views" }
# stats.value { "89,400" }
# ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/drawer.rb | Ruby | mit | 91 | master | 2,458 | # frozen_string_literal: true
module Protos
# A drawer component that can be toggled via a trigger. The content of
# a drawer is displayed at all times and overlapped by the side when the
# trigger is clicked.
#
# @see https://daisyui.com/components/drawer/
#
# @example Basic drawer
# render Protos::... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/list.rb | Ruby | mit | 91 | master | 1,304 | # frozen_string_literal: true
module Protos
# A list of items that are joined together for easier styling with
# borders, border radius, etc.
#
# @example Basic unordered list
# render Protos::List.new do |list|
# list.item { "First item" }
# list.item { "Second item" }
# list.item { "Thi... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/command.rb | Ruby | mit | 91 | master | 3,635 | # frozen_string_literal: true
module Protos
# A command palette component that can be used to trigger a modal with
# filterable list of commands. Command modals are by default closable by
# clicking the overlay rather than a specific close button.
#
# @example Basic command palette
# render Protos::Comma... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/carousel.rb | Ruby | mit | 91 | master | 2,436 | # frozen_string_literal: true
module Protos
# A carousel component that contains items that can be scrolled
# through in a mobile friendly manner.
#
# @see https://daisyui.com/components/carousel/
#
# @example Basic horizontal carousel
# render Protos::Carousel.new(snap_to: :center) do |carousel|
# ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/accordion.rb | Ruby | mit | 91 | master | 2,279 | # frozen_string_literal: true
module Protos
# An accordion component that shows collapsible content sections
#
# @see https://daisyui.com/components/accordion/
#
# @example Basic accordion
# Protos::Accordion.new do |accordion|
# accordion.item do
# accordion.title { "Section 1" }
# ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/badge.rb | Ruby | mit | 91 | master | 2,264 | # frozen_string_literal: true
module Protos
# A badge component for displaying small pieces of information
#
# @see https://daisyui.com/components/badge/
#
# @example Basic badge
# render Protos::Badge.new { "New" }
#
# @example Colored badge with outline
# render Protos::Badge.new(type: :primary... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.