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 | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/domain_spec.rb | Ruby | mit | 89 | main | 10,345 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Domain do
subject { described_class.new('example.com') }
context 'domain parsing' do
it 'downcases the domain' do
domain = described_class.new('EXAMPLE.com')
expect(domain.host.to_s).to eql('example.com')
end
it ... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/disk_cache_spec.rb | Ruby | mit | 89 | main | 898 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::DiskCache do
subject { described_class.new(tmpdir) }
before do
FileUtils.rm_rf(tmpdir)
Dir.mkdir(tmpdir)
end
it 'writes a value to disk' do
foo = Typhoeus::Request.new('foo')
path = File.expand_path foo.cache_key, t... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/endpoint_spec.rb | Ruby | mit | 89 | main | 7,869 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Endpoint do
subject { described_class.new('http://example.com') }
it 'downcases the host' do
endpoint = described_class.new('http://EXAMPLE.com')
expect(endpoint.host.to_s).to eql('example.com')
end
it 'strips www from the h... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/cache_spec.rb | Ruby | mit | 89 | main | 384 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Cache do
it 'stores a cache value' do
subject.set 'foo', 'bar'
expect(subject.instance_variable_get(:@memory)['foo']).to eql('bar')
end
it 'retrieves values from the cache' do
subject.instance_variable_set(:@memory, 'foo' =... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/endpoint/sniffer_spec.rb | Ruby | mit | 89 | main | 4,091 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Endpoint::Sniffer do
def stub_header(header, value)
allow(subject.endpoint.headers).to receive(:headers) { { header => value } }
end
def set_cookie(key, value)
cookies = [
CGI::Cookie.new(
'name' => 'foo',
... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/endpoint/cookies_spec.rb | Ruby | mit | 89 | main | 1,974 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Endpoint::Cookies do
context 'without cookies' do
subject do
stub_request(:head, 'http://example.com/')
.to_return(status: 200, body: '')
endpoint = SiteInspector::Endpoint.new('http://example.com')
described_c... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/endpoint/whois_spec.rb | Ruby | mit | 89 | main | 677 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Endpoint::Whois do
subject do
stub_request(:head, site).to_return(status: 200)
endpoint = SiteInspector::Endpoint.new(site)
described_class.new(endpoint)
end
let(:site) { 'https://example.com' }
it 'returns the whois for... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/endpoint/hsts_spec.rb | Ruby | mit | 89 | main | 2,941 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Endpoint::Hsts do
subject do
headers = { 'strict-transport-security' => 'max-age=31536000; includeSubDomains;' }
stub_request(:head, 'http://example.com/')
.to_return(status: 200, headers:)
endpoint = SiteInspector::Endpoi... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/endpoint/check_spec.rb | Ruby | mit | 89 | main | 1,053 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Endpoint::Check do
subject do
stub_request(:head, 'http://example.com/').to_return(status: 200)
endpoint = SiteInspector::Endpoint.new('http://example.com')
described_class.new(endpoint)
end
it 'returns the endpoint' do
... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/endpoint/accessibility_spec.rb | Ruby | mit | 89 | main | 2,430 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Endpoint::Accessibility do
subject do
endpoint = SiteInspector::Endpoint.new('http://example.com')
described_class.new(endpoint)
end
it "retrieve's pa11y's version" do
pending('Pa11y not installed') unless described_class.p... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/endpoint/dns_spec.rb | Ruby | mit | 89 | main | 5,202 | # frozen_string_literal: true
require 'spec_helper'
require 'dnsruby'
describe SiteInspector::Endpoint::Dns do
subject do
stub_request(:head, 'http://github.com/').to_return(status: 200)
endpoint = SiteInspector::Endpoint.new('http://github.com')
described_class.new(endpoint)
end
it 'inits the reso... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/endpoint/wappalyzer_spec.rb | Ruby | mit | 89 | main | 248 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Endpoint::Wappalyzer do
subject { described_class.new(endpoint) }
let(:domain) { 'http://example.com' }
let(:endpoint) { SiteInspector::Endpoint.new(domain) }
end |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/endpoint/content_spec.rb | Ruby | mit | 89 | main | 3,699 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Endpoint::Content do
subject do
body = <<-BODY
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta name="generator" co... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/endpoint/well_known_spec.rb | Ruby | mit | 89 | main | 325 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Endpoint::WellKnown do
subject do
stub_request(:head, 'http://example.com/')
.to_return(status: 200, headers: { foo: 'bar' })
endpoint = SiteInspector::Endpoint.new('http://example.com')
described_class.new(endpoint)
end... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/endpoint/https_spec.rb | Ruby | mit | 89 | main | 1,446 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Endpoint::Https do
subject do
stub_request(:head, 'https://example.com/')
.to_return(status: 200)
endpoint = SiteInspector::Endpoint.new('https://example.com')
allow(endpoint.response).to receive(:return_code).and_return(:... |
github | benbalter/site-inspector | https://github.com/benbalter/site-inspector | spec/site_inspector/endpoint/headers_spec.rb | Ruby | mit | 89 | main | 1,715 | # frozen_string_literal: true
require 'spec_helper'
describe SiteInspector::Endpoint::Headers do
subject do
stub_request(:head, 'http://example.com/')
.to_return(status: 200, headers: { foo: 'bar' })
endpoint = SiteInspector::Endpoint.new('http://example.com')
described_class.new(endpoint)
end
... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | ruby-clock.gemspec | Ruby | mit | 89 | main | 1,814 | require_relative 'lib/ruby-clock/version'
Gem::Specification.new do |spec|
spec.name = "ruby-clock"
spec.version = RubyClock::VERSION
spec.authors = ["John Bachir"]
spec.email = ["j@jjb.cc"]
spec.summary = 'A job scheduler which runs jobs each in their own thread in a pers... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | example-rails-7-app/Gemfile | Ruby | mit | 89 | main | 2,300 | source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '>= 3.0'
gem 'ruby-clock', path: '../'
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.4"
# The original asset pipeline for Rails [https://github.com/rails/sprocket... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | example-rails-7-app/app/models/example.rb | Ruby | mit | 89 | main | 391 | class Example < ApplicationRecord
def self.check_for_global_method
if defined?(schedule)
"💥 Oh no, the ruby-clock DSL is in the global environment! 💥"
else
"✅"
end
end
def self.check_for_runner
if defined?(shell) || defined?(rake)
"💥 Oh no, the runners got included in the glo... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | example-rails-7-app/config/application.rb | Ruby | mit | 89 | main | 712 | require_relative "boot"
require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module ExampleRailsApp
class Application < Rails::Application
# Initialize configuration defaults for originally generated... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | example-rails-7-app/config/environments/production.rb | Ruby | mit | 89 | main | 3,903 | require "active_support/core_ext/integer/time"
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 applica... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | example-rails-7-app/db/schema.rb | Ruby | mit | 89 | main | 917 | # 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.
#
# This file is the source Rails uses to define your schema when running `bin/rai... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | example-rails-6-app/Gemfile | Ruby | mit | 89 | main | 2,305 | source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '>= 3.0'
gem 'ruby-clock', path: '../', require: false
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.1.7'
# Use sqlite3 as the database for Active Record
gem 'sqlite... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | example-rails-6-app/config/application.rb | Ruby | mit | 89 | main | 713 | require_relative "boot"
require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module ExampleRails6App
class Application < Rails::Application
# Initialize configuration defaults for originally generate... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | example-rails-6-app/config/environments/development.rb | Ruby | mit | 89 | main | 2,771 | require "active_support/core_ext/integer/time"
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 any time
# it changes. This slows down response time but is perfect for developme... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | example-rails-6-app/config/environments/production.rb | Ruby | mit | 89 | main | 5,346 | require "active_support/core_ext/integer/time"
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 applica... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | example-rails-6-app/db/schema.rb | Ruby | mit | 89 | main | 941 | # 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.
#
# This file is the source Rails uses to define your schema when running `bin/rai... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | lib/ruby-clock.rb | Ruby | mit | 89 | main | 1,298 | require "ruby-clock/version"
require "ruby-clock/rake"
require "ruby-clock/shell"
require "ruby-clock/around_actions"
require "ruby-clock/rails"
require 'rufus-scheduler'
require 'singleton'
class RubyClock
include Singleton
include RubyClock::Rails::InstanceMethods
extend RubyClock::Rails::ClassMethods
includ... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | lib/rufus_monkeypatch.rb | Ruby | mit | 89 | main | 675 | require 'method_source'
class Rufus::Scheduler::Job
UNDESIRED_ELEMENTS = ['', '}', 'end']
def identifier
@identifier ||= begin
return name if name
lines = handler.source.split("\n")
whitespace_removed = lines.map(&:strip)
undesired_removed = whitespace_removed - UNDESIRED_ELEMENTS
... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | lib/ruby-clock/rake.rb | Ruby | mit | 89 | main | 1,189 | # See https://code.jjb.cc/running-rake-tasks-from-within-ruby-on-rails-code
module RubyClock::Rake
def prepare_rake
if defined?(::Rails) && Rails.application
Rails.application.load_tasks
Rake::Task.tasks.each{|t| t.prerequisites.delete 'environment' }
@rake_mutex = Mutex.new
else
puts ... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | lib/ruby-clock/shell.rb | Ruby | mit | 89 | main | 829 | module RubyClock::Shell
def shell_runner
@shell_runner ||= begin
require 'terrapin'
unless Terrapin::CommandLine.runner.class == Terrapin::CommandLine::ProcessRunner
puts <<~MESSAGE
🤷 terrapin is installed, but for some reason terrapin is
using backticks as its runner.
... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | lib/ruby-clock/around_actions.rb | Ruby | mit | 89 | main | 1,209 | module RubyClock::AroundActions
attr_accessor :around_actions
def freeze_around_actions
@around_actions.freeze
end
def set_up_around_actions
@around_actions = []
def schedule.around_trigger(job_info, &job_proc)
RubyClock.instance.call_with_around_action_stack(
RubyClock.instance.aro... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | lib/ruby-clock/rails.rb | Ruby | mit | 89 | main | 572 | # There is also rails-relevant code in rake.rb
module RubyClock::Rails
module ClassMethods
def detect_and_load_rails_app
begin
require './config/environment.rb'
puts "Detected rails app has been loaded."
rescue LoadError
end
end
end
module InstanceMethods
def add_rai... |
github | jjb/ruby-clock | https://github.com/jjb/ruby-clock | lib/ruby-clock/dsl.rb | Ruby | mit | 89 | main | 835 | module RubyClock::DSL
refine ::Kernel do
def schedule
RubyClock.instance.schedule
end
def on_error(&on_error_block)
RubyClock.instance.on_error = on_error_block
def schedule.on_error(job, error)
RubyClock.instance.on_error.call(job, error)
end
end
def around_actio... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | Rakefile | Ruby | mit | 89 | master | 346 | require "rspec/core/rake_task"
require 'rubygems/tasks'
task :default => [:spec]
desc "Run all specs"
RSpec::Core::RakeTask.new do |t|
t.pattern = "spec/**/*_spec.rb"
t.rspec_opts = "-b"
end
desc "Run mutation tests"
task :mutant do
system "mutant --fail-fast --include lib --require ruby-wpdb --use rspec '::WP... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | ruby-wpdb.gemspec | Ruby | mit | 89 | master | 1,489 | $:.push File.expand_path("../lib", __FILE__)
require "ruby-wpdb/version"
Gem::Specification.new do |s|
s.name = "ruby-wpdb"
s.version = WPDB::VERSION
s.date = Date.today.strftime("%Y-%m-%d")
s.summary = "A Ruby ORM wrapper for WordPress"
s.description = "ruby-wpdb gives you a painless way to access and inte... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | Guardfile | Ruby | mit | 89 | master | 227 | guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
end
guard :bundler do
watch('Gemfile')
watch(%r{gemspec$})
end |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | lib/ruby-wpdb.rb | Ruby | mit | 89 | master | 2,082 | require 'bundler/setup'
require 'sequel'
require 'pry'
require 'pathname'
require_relative 'ruby-wpdb/config'
module WPDB
class ConfigFileError < StandardError; end
class << self
attr_accessor :db, :prefix, :user_prefix, :initialized
# Given the path to a YAML file, will initialise WPDB using the
#... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | lib/ruby-wpdb/post.rb | Ruby | mit | 89 | master | 1,988 | Sequel.inflections do |inflect|
# Unless we tell Sequel otherwise, it will try to inflect the singular
# of "postmeta" using the "data" -> "datum" rule, leaving us with the
# bizarre "postmetum".
inflect.uncountable 'postmetas'
end
module WPDB
class Post < Sequel::Model(:"#{WPDB.prefix}posts")
include Te... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | lib/ruby-wpdb/config.rb | Ruby | mit | 89 | master | 1,943 | require "yaml"
require "erb"
module WPDB
module Config
module ConfigFormat
def initialize(file)
if file.respond_to? :read
@contents = file.read
else
@contents = File.read(file)
end
parse
end
def config
uri = 'mysql2://'
uri ... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | lib/ruby-wpdb/comment.rb | Ruby | mit | 89 | master | 860 | Sequel.inflections do |inflect|
# Unless we tell Sequel otherwise, it will try to inflect the singular
# of "commentmeta" using the "data" -> "datum" rule, leaving us with the
# bizarre "commentmetum".
inflect.uncountable 'commentmeta'
end
module WPDB
class Comment < Sequel::Model(:"#{WPDB.prefix}comments")
... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | lib/ruby-wpdb/user.rb | Ruby | mit | 89 | master | 1,092 | require 'digest/md5'
Sequel.inflections do |inflect|
# Unless we tell Sequel otherwise, it will try to inflect the singular
# of "usermeta" using the "data" -> "datum" rule, leaving us with the
# bizarre "usermetum".
inflect.uncountable 'usermeta'
end
module WPDB
class User < Sequel::Model(:"#{WPDB.user_pre... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | lib/ruby-wpdb/term.rb | Ruby | mit | 89 | master | 1,125 | module WPDB
class Term < Sequel::Model(:"#{WPDB.prefix}terms")
plugin :validation_helpers
plugin :sluggable, source: :name, target: :slug
one_to_many :termtaxonomies, class: 'WPDB::TermTaxonomy'
def validate
super
validates_presence :name
end
end
module Termable
# For object... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | lib/ruby-wpdb/gravityforms.rb | Ruby | mit | 89 | master | 6,029 | require 'php_serialize'
require 'json'
require 'csv'
module WPDB
module GravityForms
class Form < Sequel::Model(:"#{WPDB.prefix}rg_form")
one_to_many :leads, :class => :'WPDB::GravityForms::Lead'
one_to_one :meta, :class => :'WPDB::GravityForms::FormMeta'
def fields
begin
di... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | lib/ruby-wpdb/term_taxonomy.rb | Ruby | mit | 89 | master | 543 | module WPDB
class TermTaxonomy < Sequel::Model(:"#{WPDB.prefix}term_taxonomy")
one_to_many :termrelationships, class: 'WPDB::TermRelationship'
many_to_one :term, class: 'WPDB::Term'
many_to_many :posts,
left_key: :term_taxonomy_id,
right_key: :object_id,
join_table: "#{WPDB.prefix}term... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | lib/ruby-wpdb/term_relationship.rb | Ruby | mit | 89 | master | 363 | module WPDB
class TermRelationship < Sequel::Model(:"#{WPDB.prefix}term_relationships")
def_column_alias(:obj_id, :object_id)
many_to_one :post, class: 'WPDB::Post', key: :object_id
many_to_one :link, class: 'WPDB::Link', key: :object_id
many_to_one :termtaxonomy,
class: 'WPDB::TermTaxonom... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | lib/ruby-wpdb/option.rb | Ruby | mit | 89 | master | 571 | module WPDB
class Option < Sequel::Model(:"#{WPDB.prefix}options")
plugin :validation_helpers
def validate
super
validates_presence [:option_name]
end
def before_validation
self.autoload ||= "yes"
super
end
# Given the name of an option, will return the option value ... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | lib/ruby-wpdb/link.rb | Ruby | mit | 89 | master | 406 | module WPDB
class Link < Sequel::Model(:"#{WPDB.prefix}links")
include Termable
one_to_many :termrelationships,
key: :object_id,
key_method: :obj_id,
class: 'WPDB::TermRelationship'
many_to_many :termtaxonomy,
left_key: :object_id,
right_key: :term_taxonomy_id,
join_t... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | spec/spec_helper.rb | Ruby | mit | 89 | master | 396 | $:.unshift File.expand_path('../lib', File.dirname(__FILE__))
require 'bundler/setup'
require 'yaml'
require 'sequel'
require 'ruby-wpdb'
WPDB.from_config(Pathname(__FILE__) + ".." + ".." + "config.yml")
RSpec.configure do |c|
c.around(:each) do |example|
WPDB.db.transaction(rollback: :always){ example.run }... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | spec/lib/ruby-wpdb_spec.rb | Ruby | mit | 89 | master | 2,286 | require_relative "../spec_helper"
describe WPDB do
describe ".underscoreize" do
it "converts spaces to underscores" do
WPDB.underscoreize("foo bar").should == "foo_bar"
end
it "copes with multiple spaces" do
WPDB.underscoreize("foo bar").should == "foo_bar"
end
it "removes ... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | spec/lib/ruby-wpdb/user_spec.rb | Ruby | mit | 89 | master | 1,010 | require_relative '../../spec_helper'
module WPDB
describe User do
before do
@user = User.create(
user_login: 'test',
user_pass: 'test',
user_nicename: 'Testy Testerson',
user_email: 'test@example.com',
user_registered: DateTime.now
)
end
it "creates a ... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | spec/lib/ruby-wpdb/post_spec.rb | Ruby | mit | 89 | master | 1,261 | require_relative '../../spec_helper'
module WPDB
describe Post do
before do
@post = Post.create(post_title: 'Hello world', post_author: 1)
end
it "creates a new post" do
@post.ID.should be > 0
end
it "fetches all posts" do
Post.all.should_not be_empty
end
it "manages ... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | spec/lib/ruby-wpdb/option_spec.rb | Ruby | mit | 89 | master | 614 | require_relative '../../spec_helper'
module WPDB
describe Option do
before do
@option = Option.create(option_name: 'test', option_value: 'test')
end
it "creates options" do
@option.option_id.should be > 0
end
it "enforces the uniqueness of option names" do
expect {
Opt... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | spec/lib/ruby-wpdb/readme_spec.rb | Ruby | mit | 89 | master | 1,158 | require_relative '../../spec_helper'
# Examples from the README; it's obviously important that they work
# since they're people's first exposure to the project!
module WPDB
describe "README" do
it "performs more complex queries" do
post = Post.create(:post_title => 'aaaaa', :post_author => 1)
post.ad... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | spec/lib/ruby-wpdb/config_spec.rb | Ruby | mit | 89 | master | 5,081 | require_relative '../../spec_helper'
require "open-uri"
module WPDB
describe Config do
let(:sample_yaml) {
<<-EOYML
username: username_here
password: password_here
hostname: localhost
database: database_name_here
prefix: wp_
EOYML
}
let(:sample_wordpress) {
<<-EOWP
define('DB_USER', ... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | spec/lib/ruby-wpdb/gravityforms_spec.rb | Ruby | mit | 89 | master | 2,683 | require_relative '../../spec_helper'
module WPDB
describe GravityForms do
let(:sample_fields) {
[
{ "id" => 1, "label" => "First name" },
{ "id" => 2, "label" => "Last name" }
]
}
let(:sample_details) {
[
GravityForms::Detail.new(lead_id: 1, form_id: 1, field_nu... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | spec/lib/ruby-wpdb/comment_spec.rb | Ruby | mit | 89 | master | 1,061 | require_relative '../../spec_helper'
module WPDB
describe Comment do
before do
@comment = Comment.create(
comment_author: 'Testy Testerson',
comment_author_email: 'testy@example.com',
comment_content: 'Test'
)
end
it "creates a new comment" do
@comment.comment_I... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | spec/lib/ruby-wpdb/term_spec.rb | Ruby | mit | 89 | master | 1,406 | require_relative '../../spec_helper'
module WPDB
describe Term do
before do
@term = Term.create(name: 'test')
@term_taxonomy = TermTaxonomy.create(term_id: @term.term_id, taxonomy: 'category')
end
it "saves terms" do
@term.term_id.should be > 0
end
it "attaches terms to posts"... |
github | robmiller/ruby-wpdb | https://github.com/robmiller/ruby-wpdb | spec/lib/ruby-wpdb/link_spec.rb | Ruby | mit | 89 | master | 604 | require_relative '../../spec_helper'
module WPDB
describe Link do
before do
@link = Link.create(link_url: 'http://example.com', link_name: 'Example')
end
it "creates links" do
@link.link_id.should be > 0
end
it "can attach terms to links" do
term = Term.create(name: 'terming l... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | trackoid.gemspec | Ruby | mit | 88 | master | 965 | # encoding: utf-8
$:.push File.expand_path("../lib", __FILE__)
require "trackoid/version"
Gem::Specification.new do |s|
s.name = "trackoid"
s.version = Trackoid::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Jose Miguel Perez"]
s.email = "josemiguel@perezruiz.com"
s.homepage = "http://github.com/... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | Gemfile | Ruby | mit | 88 | master | 242 | source "http://rubygems.org"
# Declare your gem's dependencies in trackoid.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | lib/trackoid.rb | Ruby | mit | 88 | master | 341 | # encoding: utf-8
require 'trackoid/version'
require 'mongoid/tracking'
require 'mongoid/tracking/errors'
require 'mongoid/tracking/core_ext'
require 'mongoid/tracking/reader_extender'
require 'mongoid/tracking/readers'
require 'mongoid/tracking/tracker'
require 'mongoid/tracking/aggregates'
require 'mongoid/tracking... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | lib/mongoid/tracking.rb | Ruby | mit | 88 | master | 2,348 | # encoding: utf-8
module Mongoid #:nodoc:
module Tracking #:nodoc:
# Include this module to add analytics tracking into a +root level+ document.
# Use "track :field" to add a field named :field and an associated mongoid
# field named after :field
def self.included(base)
base.class_eval do
... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | lib/mongoid/tracking/readers.rb | Ruby | mit | 88 | master | 1,894 | # encoding: utf-8
module Mongoid #:nodoc:
module Tracking
# Reader methods (previously known as "accessors")
module Readers
# Access methods
def today
whole_data_for(Time.now)
end
def yesterday
whole_data_for(Time.now - 1.day)
end
def first_value
... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | lib/mongoid/tracking/tracker_aggregates.rb | Ruby | mit | 88 | master | 1,257 | # encoding: utf-8
module Mongoid #:nodoc:
module Tracking
# This internal class handles all interaction of an aggregation token.
class TrackerAggregates
def initialize(owner, token, key_selector, track_field = nil)
@owner, @token = owner, token
@key = key_selector.first
@track_... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | lib/mongoid/tracking/reader_extender.rb | Ruby | mit | 88 | master | 2,219 | # encoding: utf-8
module Mongoid #:nodoc:
module Tracking
# ReaderExtender is used in cases where we need to return an integer
# (class Numeric) while extending their contents. It would allow to
# perform advanced calculations in some situations:
#
# Example:
#
# a = visits.today # W... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | lib/mongoid/tracking/errors.rb | Ruby | mit | 88 | master | 942 | # encoding: utf-8
module Mongoid #:nodoc
module Tracking #:nodoc
module Errors #:nodoc
class ClassAlreadyDefined < RuntimeError
def initialize(klass)
@klass = klass
end
def message
"#{@klass} already defined, can't aggregate!"
end
end
class A... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | lib/mongoid/tracking/tracker.rb | Ruby | mit | 88 | master | 7,218 | # encoding: utf-8
module Mongoid #:nodoc:
module Tracking
# This internal class handles all interaction for a track field.
class Tracker
include Readers
def initialize(owner, field, aggregate_data)
@owner, @for = owner, field
@for_data = @owner.internal_track_name(@for)
... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | lib/mongoid/tracking/aggregates.rb | Ruby | mit | 88 | master | 5,565 | # encoding: utf-8
module Mongoid #:nodoc:
module Tracking #:nodoc:
module Aggregates
DEPRECATED_TOKENS = ['hour', 'hours']
# This module includes aggregate data extensions to Trackoid instances
def self.included(base)
base.class_eval do
extend ClassMethods
class_a... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | lib/mongoid/tracking/core_ext/time.rb | Ruby | mit | 88 | master | 1,251 | # encoding: utf-8
class Time
# Functions to construct the MongoDB field key for trackers
#
# to_i_timestamp returns the computed UTC timestamp regardless of the
# timezone.
#
# Examples:
# 2011-01-01 00:00:00 UTC ===> 14975
# 2011-01-01 23:59:59 UTC ===> 14975
# 2011-01-02 00:00:00 UTC ===... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | lib/mongoid/tracking/core_ext/range.rb | Ruby | mit | 88 | master | 1,581 | # encoding: utf-8
class Range
# Adds some enumerable capabilities to Time ranges
# (Normally they raise a "Can't iterate time ranges")
#
# It works by assuming days while iterating the time range, but you can
# pass an optional parameter
HOURS = 3600
DAYS = 24*HOURS
DEFAULT_TIME_GRANULARITY = DAYS
#... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | spec/aggregates_spec.rb | Ruby | mit | 88 | master | 16,738 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
class TestModel
include Mongoid::Document
include Mongoid::Tracking
field :name # Dummy field
# Note that references to "track" and "aggregate" in this test are mixed
# for testing purposes. Trackoid does not make any difference in the
#... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | spec/trackoid_spec.rb | Ruby | mit | 88 | master | 7,531 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
class Test
include Mongoid::Document
include Mongoid::Tracking
field :name # Dummy field
track :visits
end
describe Mongoid::Tracking do
it "should ensure allow_dynamic_fields option is turned off" do
Mongoid::Config.settings[:allow_dy... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | spec/timezone_spec.rb | Ruby | mit | 88 | master | 10,047 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe Mongoid::Tracking do
describe "Testing the system TZ for Europe/Madrid" do
before do
ENV['TZ'] = 'Europe/Madrid'
end
it "should convert dates to UTC" do
t = Time.now
t.should_not be_utc
t.utc
t.shoul... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | spec/embedded_spec.rb | Ruby | mit | 88 | master | 3,080 | #
# This is a simple spec to check if tracking works within embedded documents
# If this passes, the rest of the funcionality it's assumed to work (TZ, etc)
#
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
class TestEmbedOne
include Mongoid::Document
field :name # Dummy field
embeds_one :em... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | spec/reader_extender_spec.rb | Ruby | mit | 88 | master | 1,874 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe Mongoid::Tracking::ReaderExtender do
it "should behave like a number" do
num = Mongoid::Tracking::ReaderExtender.new(5, [])
num.should == 5
num.should < 10
(num * 10).should == 50
end
it "should behave like a float" do
... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | spec/spec_helper.rb | Ruby | mit | 88 | master | 452 | # FIXME: We should modify the load path here.
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'mongoid'
require 'trackoid'
require 'rspec'
require 'rspec/autorun'
RSpec.configure do |config|
config.before(:suite) do
Mongoid.load!(File.expand_p... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | spec/readers_spec.rb | Ruby | mit | 88 | master | 1,914 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
class Test
include Mongoid::Document
include Mongoid::Tracking
field :name # Dummy field
track :visits
end
describe "Testing Readers with a model" do
before do
Test.delete_all
Test.create(:name => "test")
@object_id = Test.firs... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | spec/ext/range_spec.rb | Ruby | mit | 88 | master | 3,264 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Range do
describe "using the diff method" do
before do
ENV['TZ'] = 'America/Los_Angeles'
end
it "should work for normal ranges" do
(0..2).diff.should == 3
(0...2).diff.should == 2
end
it "should work... |
github | twoixter/trackoid | https://github.com/twoixter/trackoid | spec/ext/time_spec.rb | Ruby | mit | 88 | master | 5,295 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Time do
describe "when working with UTC dates" do
it "should return the correct timestamp" do
time1 = Time.utc(2011, 1, 1, 0, 0, 0)
time1.to_i_timestamp.should == 14975
time2 = Time.utc(2011, 1, 1, 23, 59, 59)
... |
github | maerch/ruby-drawille | https://github.com/maerch/ruby-drawille | drawille.gemspec | Ruby | mit | 88 | master | 815 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'drawille/version'
Gem::Specification.new do |gem|
gem.name = "drawille"
gem.version = Drawille::VERSION
gem.authors = ["Marcin Skirzynski"]
gem.description ... |
github | maerch/ruby-drawille | https://github.com/maerch/ruby-drawille | examples/conway.rb | Ruby | mit | 88 | master | 1,612 | require 'drawille'
require 'curses'
class Conway
OFFSET_MATRIX = [[-1,-1], [0, -1], [1, -1],
[-1, 0], [1, 0],
[-1, 1], [0, 1], [1, 1]]
def initialize height, width
@height = height
@width = width
@world = initialize_world { |x, y| rand(0..1) }
en... |
github | maerch/ruby-drawille | https://github.com/maerch/ruby-drawille | examples/stencil.rb | Ruby | mit | 88 | master | 497 | require 'drawille'
require 'chunky_png'
include ChunkyPNG
canvas = Drawille::Canvas.new
def draw canvas, img, xoffset=0
(0..img.dimension.width-1).each do |x|
(0..img.dimension.height-1).each do |y|
r = Color.r(img[x,y])
g = Color.g(img[x,y])
b = Color.b(img[x,y])
canvas.set(x+xoffset, ... |
github | maerch/ruby-drawille | https://github.com/maerch/ruby-drawille | spec/drawille_spec.rb | Ruby | mit | 88 | master | 7,761 | # -*- encoding: utf-8 -*-
require 'spec_helper'
include Drawille
describe Canvas do
subject(:canvas) { Canvas.new }
describe '#set' do
it 'sets pixel in the first char in the first row' do
set_and_check_char (0..1), (0..3), 0, 0
end
it 'sets pixel in the third char in the first row' do
s... |
github | maerch/ruby-drawille | https://github.com/maerch/ruby-drawille | spec/spec_helper.rb | Ruby | mit | 88 | master | 308 | # -*- encoding: utf-8 -*-
require 'drawille'
BRAILLE = %w[⠁ ⠉ ⠋ ⠛ ⠟ ⠿ ⡿ ⣿ ⠀]
def set_and_check_char px_range, py_range, cx, cy
i = 0
py_range.each do |y|
px_range.each do |x|
canvas.set(x, y)
expect(canvas.char(cx, cy)).to eq BRAILLE[i]
i += 1
end
end
end |
github | maerch/ruby-drawille | https://github.com/maerch/ruby-drawille | lib/drawille/frameable.rb | Ruby | mit | 88 | master | 1,128 | # -*- encoding: utf-8 -*-
module Drawille
module Frameable
PIXEL_MAP = [[0x01, 0x08],
[0x02, 0x10],
[0x04, 0x20],
[0x40, 0x80]]
BRAILLE_CHAR_OFFSET = 0x2800
def row y, options={}
chars = options[:chars] || @chars
row = chars[y]
min = options[:min_x]
ma... |
github | maerch/ruby-drawille | https://github.com/maerch/ruby-drawille | lib/drawille/brush.rb | Ruby | mit | 88 | master | 1,707 | # -*- encoding: utf-8 -*-
module Drawille
class Brush
attr_accessor :canvas
def initialize canvas
@canvas = canvas
@state = {
x: 0,
y: 0,
up: true,
rotation: 0
}
end
def down
@state[:up] = false
end
def up
... |
github | maerch/ruby-drawille | https://github.com/maerch/ruby-drawille | lib/drawille/canvas.rb | Ruby | mit | 88 | master | 1,019 | # -*- encoding: utf-8 -*-
module Drawille
class Canvas
include Frameable
attr_reader :chars
def initialize
clear
@snapshots = [{}]
end
def paint &block
Brush.new(self).instance_eval(&block)
self
end
def clear
@chars = Hash.new { |h,v| h[v] = Hash.new(0) ... |
github | maerch/ruby-drawille | https://github.com/maerch/ruby-drawille | lib/drawille/flipbook.rb | Ruby | mit | 88 | master | 1,405 | # -*- encoding: utf-8 -*-
require 'curses'
module Drawille
class FlipBook
include Frameable
def initialize
clear
end
def clear
@snapshots = []
@chars = {}
end
def snapshot canvas
@snapshots << canvas.frame
@chars = canvas.chars
end
def each_... |
github | solutious/rudy | https://github.com/solutious/rudy | rudy.gemspec | Ruby | mit | 88 | master | 5,543 | @spec = Gem::Specification.new do |s|
s.name = "rudy"
s.rubyforge_project = 'rudy'
s.version = "0.9.8.020"
s.summary = "Rudy: Not your grandparents' EC2 deployment tool."
s.description = s.summary
s.author = "Delano Mandelbaum"
s.email = "delano@solutious.com"
s.homepage = "http://solutious.com/projects... |
github | solutious/rudy | https://github.com/solutious/rudy | Rakefile | Ruby | mit | 88 | master | 1,950 | require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/testtask'
require 'rake/runtest'
require 'fileutils'
include FileUtils
task :default => :test
begin
require 'hanna/rdoctask'
rescue LoadError
require 'rake/rdoctask'
end
# PACKAGE =============================================================
na... |
github | solutious/rudy | https://github.com/solutious/rudy | tryouts/40_routines/10_keypair_handler_tryouts.rb | Ruby | mit | 88 | master | 1,577 | group "Routines"
library :rudy, 'lib'
tryout "Keypair Handler" do
Rudy::Huxtable.update_config # Read config files
set :user, Rudy::Utils.strand(4)
set :keydir, '/tmp'
set :global, Rudy::Huxtable.global
set :config, Rudy::Huxtable.config
set :test_env, 'env_' << Rudy::Utils.strand
setup do
... |
github | solutious/rudy | https://github.com/solutious/rudy | tryouts/40_routines/11_group_handler_tryouts.rb | Ruby | mit | 88 | master | 990 | group "Routines"
library :rudy, 'lib'
tryout "Group Handler" do
set :group, 'grp-' << Rudy::Utils.strand(4)
set :global, Rudy::Huxtable.global
set :config, Rudy::Huxtable.config
set :test_env, 'env_' << Rudy::Utils.strand
setup do
#Rudy.enable_debug
Rudy::Huxtable.update_config # Read conf... |
github | solutious/rudy | https://github.com/solutious/rudy | tryouts/26_ec2_instances/10_instance_tryouts.rb | Ruby | mit | 88 | master | 3,122 | group "EC2 Instances"
library :rudy, 'lib'
tryouts "Instances" do
set :global, Rudy::Huxtable.global
set :config, Rudy::Huxtable.config
setup do
Rudy::Huxtable.update_config
Rudy::AWS::EC2.connect global.accesskey, global.secretkey, global.region
@ami = config.machines.find(global.region, :ami)
end... |
github | solutious/rudy | https://github.com/solutious/rudy | tryouts/01_mixins/01_hash_tryouts.rb | Ruby | mit | 88 | master | 552 | group "Mixins"
library :rudy, File.expand_path(File.join(GYMNASIUM_HOME, '..', 'lib'))
tryout "Hash" do
setup do
def one_lvl; {:empty=>1}; end
def two_lvls; {:l1 => {:empty=>1}}; end
def three_lvls; { :l1 => { :l2 => {:empty=>1, :empty=>1} } }; end
def six_lvls; {:l1 => {:l2 => {:l3 => {:l4 => {:l5 =... |
github | solutious/rudy | https://github.com/solutious/rudy | tryouts/20_simpledb/20_objects_tryouts.rb | Ruby | mit | 88 | master | 1,449 | library :rudy, 'lib'
group "SimpleDB"
tryouts "Objects" do
set :test_domain, 'test_' << Rudy::Utils.strand
set :produce, Hash[
'orange' => (rand(100) * 10).to_s,
'celery' => (rand(100) * 100).to_s,
'grapes' => 'green'
]
setup do
Rudy::Huxtable.update_config
global = Rudy::Huxtable.globa... |
github | solutious/rudy | https://github.com/solutious/rudy | tryouts/20_simpledb/10_domains_tryouts.rb | Ruby | mit | 88 | master | 698 | library :rudy, 'lib'
group "SimpleDB"
tryouts "Domains" do
set :test_domain, 'test_' << Rudy::Utils.strand
setup do
Rudy::Huxtable.update_config
global = Rudy::Huxtable.global
akey, skey, region = global.accesskey, global.secretkey, global.region
@sdb = Rudy::AWS::SDB.new(akey, skey, region)
en... |
github | solutious/rudy | https://github.com/solutious/rudy | tryouts/exploration/machine.rb | Ruby | mit | 88 | master | 485 | #!/usr/bin/env ruby
# Tryout - A basic use-case
#
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
%w{drydock caesars rye}.each { |dir| $: << File.join(File.dirname(__FILE__), '..', '..', dir, 'lib') }
require 'rudy'
machine1 = Rudy::Machine.new
Rudy::Huxtable.change_environment(:prod)
machine2 = Rudy::Ma... |
github | solutious/rudy | https://github.com/solutious/rudy | tryouts/exploration/console.rb | Ruby | mit | 88 | master | 1,829 | RUDY_HOME = File.join(File.dirname(__FILE__), '..')
RUDY_LIB = File.join(RUDY_HOME, 'lib')
$:.unshift RUDY_LIB # Put our local lib in first place
require 'yaml'
require 'date'
require 'tryouts'
require 'console'
raise "Sorry Ruby 1.9 only!" unless RUBY_VERSION =~ /1.9/
before do
@title = "RUDY v0.3"
@now_utc = ... |
github | solutious/rudy | https://github.com/solutious/rudy | tryouts/15_huxtable/20_user_tryouts.rb | Ruby | mit | 88 | master | 1,244 | group "Rudy::Huxtable"
library :rudy, 'lib'
tryout "User related methods" do
set :user, Rudy::Utils.strand(4)
set :keydir, '/tmp'
set :global, Rudy::Huxtable.global
set :config, Rudy::Huxtable.config
setup do
#Rudy.enable_debug
Rudy::Huxtable.update_config # Read config files
config.defa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.