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 | byroot/explicit-parameters | https://github.com/byroot/explicit-parameters | spec/spec_helper.rb | Ruby | mit | 19 | master | 389 | require 'action_controller'
require 'explicit_parameters'
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.disable_monk... |
github | byroot/explicit-parameters | https://github.com/byroot/explicit-parameters | lib/explicit_parameters.rb | Ruby | mit | 19 | master | 383 | require 'action_pack/version'
module ExplicitParameters
IS_RAILS5 = ActionPack.version >= Gem::Version.new('5.0.0')
BaseError = Class.new(StandardError)
InvalidParameters = Class.new(BaseError)
end
require 'explicit_parameters/version'
require 'explicit_parameters/parameters'
require 'explicit_parameters/contro... |
github | byroot/explicit-parameters | https://github.com/byroot/explicit-parameters | lib/explicit_parameters/controller.rb | Ruby | mit | 19 | master | 1,506 | module ExplicitParameters
module Controller
extend ActiveSupport::Concern
Boolean = Axiom::Types::Boolean
class << self
attr_accessor :last_parameters
end
included do
rescue_from ExplicitParameters::InvalidParameters, with: :render_parameters_error
end
module ClassMethods
... |
github | byroot/explicit-parameters | https://github.com/byroot/explicit-parameters | lib/explicit_parameters/railtie.rb | Ruby | mit | 19 | master | 239 | module ExplicitParameters
class Railtie < ::Rails::Railtie
initializer 'explicit_parameters.controller' do
ActiveSupport.on_load(:action_controller) do
include ExplicitParameters::Controller
end
end
end
end |
github | byroot/explicit-parameters | https://github.com/byroot/explicit-parameters | lib/explicit_parameters/parameters.rb | Ruby | mit | 19 | master | 3,189 | require 'virtus'
require 'active_model'
module ExplicitParameters
class Parameters
include Virtus.model
include ActiveModel::Validations
include Enumerable
class CoercionValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.validate_attribute_coercio... |
github | technicalpickles/has_ip_address | https://github.com/technicalpickles/has_ip_address | Rakefile | Ruby | mit | 19 | master | 1,407 | require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "has_ip_address"
gem.summary = %Q{An extension to ActiveRecord to store IP Addresses in the database as integers}
gem.description = %Q{An extension to ActiveRecord to store IP Addresses in the database as i... |
github | technicalpickles/has_ip_address | https://github.com/technicalpickles/has_ip_address | lib/has_ip_address.rb | Ruby | mit | 19 | master | 841 | require 'ipaddr'
require 'has_ip_address/extensions'
module HasIpAddress
def self.included(other)
other.class_eval do
extend ClassMethods
end
end
module ClassMethods
def has_ip_address(column = :ip_address)
define_method "#{column}=" do |address|
ipaddr = address.to_ipaddr
... |
github | technicalpickles/has_ip_address | https://github.com/technicalpickles/has_ip_address | lib/has_ip_address/extensions.rb | Ruby | mit | 19 | master | 580 | IPAddr.class_eval do
# hack so == doesn't blow up when passed false
def ==(other)
return false if other.kind_of?(TrueClass) || other.kind_of?(FalseClass)
# copied from original IPAddr#==
if other.kind_of?(IPAddr) && @family != other.family
return false
end
return (@addr == other.to_i)
e... |
github | technicalpickles/has_ip_address | https://github.com/technicalpickles/has_ip_address | spec/spec_helper.rb | Ruby | mit | 19 | master | 260 | $LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'has_ip_address'
require 'acts_as_fu'
require 'spec'
require 'spec/autorun'
Spec::Runner.configure do |config|
config.include ActsAsFu
end |
github | technicalpickles/has_ip_address | https://github.com/technicalpickles/has_ip_address | spec/has_ip_address_spec.rb | Ruby | mit | 19 | master | 1,207 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "has_ip_address" do
describe "with default column" do
before do
build_model :visits do
integer :ip_address
has_ip_address
end
end
describe "and setting and getting" do
before do
visit = V... |
github | pengwynn/transparency-data | https://github.com/pengwynn/transparency-data | Rakefile | Ruby | mit | 19 | master | 231 | require "mg"
MG.new("transparency_data.gemspec")
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.ruby_opts = ['-rubygems'] if defined? Gem
test.libs << 'lib' << 'test'
test.pattern = 'test/**/*_test.rb'
end |
github | pengwynn/transparency-data | https://github.com/pengwynn/transparency-data | transparency_data.gemspec | Ruby | mit | 19 | master | 1,183 | Gem::Specification.new do |s|
s.name = "transparency_data"
s.version = "0.0.4"
s.date = "2010-06-24"
s.summary = "Wrapper for the Sunlight Transparency data API"
s.description = "Wrapper for the Sunlight Transparency data API"
s.homepage = "http:/... |
github | pengwynn/transparency-data | https://github.com/pengwynn/transparency-data | test/transparency_data_test.rb | Ruby | mit | 19 | master | 567 | require File.dirname(__FILE__) + '/helper'
class TransparencyDataTest < Test::Unit::TestCase
context "when consuming the Sunlight Transparency Data API" do
should "should set the API key on the module" do
TransparencyData.configure do |config|
config.api_key = "OU812"
end
assert... |
github | pengwynn/transparency-data | https://github.com/pengwynn/transparency-data | test/helper.rb | Ruby | mit | 19 | master | 716 | require 'test/unit'
require 'pathname'
require 'shoulda'
require 'matchy'
require 'mocha'
require 'fakeweb'
require 'vcr'
require 'redgreen'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'transparency_data'
api_config = YAML.load_file(File.dirn... |
github | pengwynn/transparency-data | https://github.com/pengwynn/transparency-data | test/client_test.rb | Ruby | mit | 19 | master | 8,456 | require File.dirname(__FILE__) + '/helper'
class ClientTest < Test::Unit::TestCase
context "when using Client" do
context "when handling parameters" do
should "map arrays to delimited text" do
scenarios = [
[{:date => "2009-03-04"}, {:date => "2009-03-04"}],
[{:date =>... |
github | pengwynn/transparency-data | https://github.com/pengwynn/transparency-data | lib/transparency_data.rb | Ruby | mit | 19 | master | 787 | require 'hashie'
require 'json'
require 'monster_mash'
Hash.send :include, Hashie::HashExtensions
module TransparencyData
VERSION = "0.0.4".freeze
def self.configure
yield self
true
end
def self.api_version
@api_version || "1.0"
end
def self.api_version=(value)
@api_version =... |
github | pengwynn/transparency-data | https://github.com/pengwynn/transparency-data | lib/transparency_data/client.rb | Ruby | mit | 19 | master | 9,423 | module TransparencyData
class Client < MonsterMash::Base
defaults do
params :apikey => TransparencyData.api_key
end
get(:contributions) do |api_params|
uri TransparencyData.api_url("/contributions")
params TransparencyData::Client.prepare_params(api_params)
handler do |re... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | rupture.gemspec | Ruby | mit | 19 | master | 872 | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |gem|
gem.name = "rupture"
gem.version = IO.read('VERSION')
gem.authors = ["Justin Balthrop", "Alan Malloy"]
gem.email = ["git@justinbalthrop.com"]
gem.des... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | test/seq_test.rb | Ruby | mit | 19 | master | 7,999 | require File.dirname(__FILE__) + '/test_helper'
class SeqTest < Test::Unit::TestCase
empty_seqs = [nil, [], Rupture::Seq::Empty, F.lazy_seq{nil}, F.lazy_seq{[]}]
def numbers(i)
F.lazy_seq { F.cons(i, numbers(i.inc))}
end
should "empty seqs" do
empty_seqs.each do |s|
assert_nil s.seq
asser... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | test/list_test.rb | Ruby | mit | 19 | master | 515 | require File.dirname(__FILE__) + '/test_helper'
class ListTest < Test::Unit::TestCase
should "act like a seq" do
list = F.list(1, 2, 3, 4)
assert_equal list.count, 4
assert_equal list.first, 1
assert_equal list.rest.next.rest.first, 4
assert_nil list.next.next.next... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | test/map_test.rb | Ruby | mit | 19 | master | 1,071 | require File.dirname(__FILE__) + '/test_helper'
class MapTest < Test::Unit::TestCase
should "destructure" do
a,b,c,d = {:foo => 1, :bar => 3}.destruct(:bar, :foo, :bar, :baz)
assert_equal 3, a
assert_equal 1, b
assert_equal 3, c
assert_equal nil, d
{:foo => 1, :bar => 3}.destruct(:bar... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | test/function_test.rb | Ruby | mit | 19 | master | 1,700 | require File.dirname(__FILE__) + '/test_helper'
class FunctionTest < Test::Unit::TestCase
should "loop" do
n = F.loop(0) do |recur, i|
if i < 10
recur[i.inc]
else
i
end
end
assert_equal 10, n
end
should "loop lazily" do
s = F.lazy_loop(0) do |recur, i|
if ... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | test/meta_test.rb | Ruby | mit | 19 | master | 915 | require File.dirname(__FILE__) + '/test_helper'
class MetaTest < Test::Unit::TestCase
should "have meta data" do
a = "foo"
assert_equal({}, a.meta)
a.meta[:foo] = 1
a.meta[:bar] = 2
assert_equal({:foo => 1, :bar => 2}, a.meta)
b = a.clone
b.meta[:foo] = 3
assert_equal({:foo => 1, :... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | test/fn_test.rb | Ruby | mit | 19 | master | 1,668 | require File.dirname(__FILE__) + '/test_helper'
class FnTest < Test::Unit::TestCase
should "identity" do
assert_equal [1,2,3].seq, [1,2,3].seq.map(F[:identity])
end
should "juxt" do
assert_equal [[2,0],[3,1],[4,2]].seq, [1,2,3].seq.map(F.juxt(:inc, :dec))
end
# should "apply" do
# assert_equal ... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture.rb | Ruby | mit | 19 | master | 481 | module Rupture; end
require 'rupture/core_ext'
require 'rupture/rails_ext'
require 'rupture/utils'
require 'rupture/function'
require 'rupture/fn'
require 'rupture/lookup'
require 'rupture/symbol'
require 'rupture/meta'
require 'rupture/sequence'
require 'rupture/seq'
require 'rupture/lazy_seq'
require 'rupture/cons'
... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/hash_map.rb | Ruby | mit | 19 | master | 658 | require 'hamster'
module Rupture
class HashMap < Hamster::Hash
include Map
def as_map
self
end
def self.empty
@empty ||= HashMap.new
end
end
end
class Hash
include Rupture::Map
def as_map
F.hash_map(self)
end
alias ~ as_map
def assoc!(*vals)
vals.each_slice(2)... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/meta.rb | Ruby | mit | 19 | master | 468 | module Rupture::Meta
def meta
@_meta ||= {}
end
def clone(meta = nil)
meta ||= @_meta.clone if @_meta
raise "meta must be of type Hash, it is #{meta.class}" unless meta.nil? or meta.kind_of?(Hash) or meta.kind_of?(Rupture::HashMap)
copy = super()
copy.instance_variable_set(:@_meta, meta)
... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/map.rb | Ruby | mit | 19 | master | 727 | module Rupture
module Map
def map?
true
end
def associate(*kvs)
into(kvs.seq.partition(2))
end
def assoc(*kvs)
associate(*kvs)
end
def into(other)
other.seq.reduce(as_map) do |map, (k,v)|
map.put(k,v)
end
end
def update(key, fn = nil, *args... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/list.rb | Ruby | mit | 19 | master | 480 | module Rupture
class List < Seq
class << self
alias create new
end
private_class_method :create
attr_reader :seq, :size
def initialize(seq, size)
@seq = seq.seq
@size = size
end
def self.new(*args)
list = Empty
args.reverse_each do |x|
list = list.co... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/function.rb | Ruby | mit | 19 | master | 3,320 | module Rupture
module Function
def map(*colls, &fn)
fn ||= colls.shift
lazy_loop(colls.seq.map(:seq)) do |recur, seqs|
if seqs.every?
firsts = seqs.map(:first)
nexts = seqs.map(:next)
cons(fn[*firsts], recur[nexts])
end
end
end
def concat(*... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/seq.rb | Ruby | mit | 19 | master | 742 | module Rupture
class Seq
include Enumerable
include Sequence
def inspect
"(#{to_a.collect(&:inspect).join(',')})"
end
def [](index)
nth(index)
end
def to_ary
to_a
end
def eql?(other)
return false unless other.respond_to?(:seq)
s = self.seq
o... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/symbol.rb | Ruby | mit | 19 | master | 540 | require 'forwardable'
class Rupture::Symbol # Use for symbols
extend Forwardable
def_delegators :@symbol, :to_s, :name, :namespace
def initialize(*args)
Utils.verify_args(args, 1, 2)
@symbol = args.join("/").to_sym
end
alias inspect to_s
end
class Symbol # Use for keywords
def name
parse_nam... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/array_seq.rb | Ruby | mit | 19 | master | 905 | module Rupture
class ArraySeq < Seq
def initialize(array, index = 0)
@array = array
@index = index
end
def first
@array[@index]
end
def rest
ArraySeq.new(@array, @index.inc)
end
def seq
self if @index < @array.size
end
def size
@array.size - ... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/rails_ext.rb | Ruby | mit | 19 | master | 1,006 | class Hash
def symbolize_keys!
keys.each do |key|
self[(key.to_sym rescue key) || key] = delete(key)
end
self
end
def symbolize_keys
dup.symbolize_keys!
end
def deep_symbolize_keys!
values.each do |val|
val.deep_symbolize_keys! if val.is_a?(Hash)
end
symbolize_keys!
... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/lazy_seq.rb | Ruby | mit | 19 | master | 654 | require 'continuation'
module Rupture
class LazySeq < Seq
def initialize(block = nil)
@block = block
end
def seq
return @seq unless @block
@seq = @block.call.seq
@block = nil
@seq
end
end
end
module Enumerable
def seq
F.lazy_seq do
callcc do |external|
... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/reader.rb | Ruby | mit | 19 | master | 2,116 | require 'set'
module Rupture
class Reader
def initialize(input)
@input = input
@buffer = []
end
def ungetc(*chars)
@buffer.concat(chars)
@space = false
chars.last
end
def getc
while c = (@buffer.shift || @input.getc.chr)
if c =~ /[\s,;]/
ne... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/core_ext.rb | Ruby | mit | 19 | master | 348 | class Numeric
def inc
self + 1
end
def dec
self - 1
end
def pos?
self > 0
end
def neg?
self < 0
end
def zero?
self == 0
end
end
class Object
def map?
false
end
def let(*vals)
yield(self, *vals)
end
def fix(pred, f = nil, &fn)
Rupture::Function.fix(sel... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/cons.rb | Ruby | mit | 19 | master | 237 | module Rupture
class Cons < Seq
attr_reader :first
def initialize(first, rest)
@first, @rest = first, rest
super()
end
def seq
self
end
def rest
@rest ||= Seq::Empty
end
end
end |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/lookup.rb | Ruby | mit | 19 | master | 262 | module Rupture
module Lookup
def lookup
lambda do |a|
a[self]
end
end
end
end
class Symbol
include Rupture::Lookup
alias ~ lookup
end
class String
include Rupture::Lookup
end
class Numeric
include Rupture::Lookup
end |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/sequence.rb | Ruby | mit | 19 | master | 5,818 | module Rupture
module Sequence
def first
seq.first
end
def rest
seq.rest
end
def next
rest.seq
end
def second
rest.first
end
def empty?
not seq
end
def not_empty
self if seq
end
def divide
[first, rest]
end
de... |
github | ninjudd/rupture | https://github.com/ninjudd/rupture | lib/rupture/fn.rb | Ruby | mit | 19 | master | 1,622 | require 'set'
module Rupture
module Fn
def complement
lambda do |*args|
not call(*args)
end
end
alias -@ complement
def comp(fn)
lambda do |*args|
call(fn[*args])
end
end
alias * comp
def partial(*partials)
lambda do |*args, &block|
... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | Rakefile | Ruby | mit | 19 | v1.0 | 347 | gem 'rdoc', '>= 2.4.2'
require 'rdoc/task'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
desc 'Generate API documentation'
RDoc::Task.new do |rd|
rd.rdoc_files.include("README.md", "lib/**/*.rb")
rd.options << '--inline-source'
rd.options << '--line-numbers'
rd.options... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | tempodb.gemspec | Ruby | mit | 19 | v1.0 | 729 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "tempodb/version"
Gem::Specification.new do |s|
s.name = "tempodb"
s.version = TempoDB::VERSION
s.licenses = ['MIT']
s.authors = ["TempoDB, Inc."]
s.email = ["software@tempo-db.com"]
s.homepage = "http... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | spec/spec_helper.rb | Ruby | mit | 19 | v1.0 | 894 | # This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
requir... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | spec/client_spec.rb | Ruby | mit | 19 | v1.0 | 16,303 | require 'spec_helper'
describe TempoDB::Client do
it "encodes boolean values correctly" do
stub_request(:get, "https://api.tempo-db.com/v1/series/?hello=true").
to_return(:status => 200, :body => "{}", :headers => {})
client = TempoDB::Client.new("database_id", "key", "secret")
client.list_series(:... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb.rb | Ruby | mit | 19 | v1.0 | 214 | require 'rubygems'
require 'tempodb/client'
module TempoDB
API_HOST = "api.tempo-db.com"
API_PORT = 443
API_VERSION = "v1"
TRUSTED_CERT_FILE = File.join(File.dirname(__FILE__), "trusted-certs.crt")
end |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb/multi_write.rb | Ruby | mit | 19 | v1.0 | 493 | module TempoDB
# Used to send collections of datapoints to multiple Series
class MultiWrite
attr_reader :series
def initialize
@series = []
end
# Add a an array of DataPoint to the specific +series_key+
#
# * +series_key+ [String] - The key to write to
# * +data+ [Array] - An arr... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb/data_point_found.rb | Ruby | mit | 19 | v1.0 | 851 | module TempoDB
# A search result from calling +find_data+. In addition to the
# found DataPoint, contains the interval that the DataPoint was
# found in.
class DataPointFound
attr_reader :interval, :predicate, :data, :tz
def initialize(interval, predicate, data, tz)
@interval = interval
@pr... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb/session.rb | Ruby | mit | 19 | v1.0 | 4,096 | require 'httpclient'
require 'net/https'
require 'uri'
module TempoDB
# Encapsulates all HTTP interactions
class Session
def initialize(key, secret, host, port, secure)
@key = key
@secret = secret
@host = host
@port = port
@secure = secure
@http_client = HTTPClient.new
... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb/series.rb | Ruby | mit | 19 | v1.0 | 560 | module TempoDB
# Represents one logical stream of time series data
class Series
attr_accessor :id, :key, :name, :attributes, :tags
def initialize(id, key, name="", attributes={}, tags=[])
@id = id
@key = key
@name = name
@attributes = attributes
@tags = tags
end
def t... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb/multipoint.rb | Ruby | mit | 19 | v1.0 | 377 | module TempoDB
# A composite type that represents multiple datapoints at a single timestamp
class MultiPoint
attr_accessor :ts, :value
def initialize(ts, value)
@ts = ts
@value = value
end
def self.from_json(m)
ts = Time.parse(m["t"])
value = m["v"]
new(ts, value)
... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb/delete_summary.rb | Ruby | mit | 19 | v1.0 | 294 | module TempoDB
# Returned from 'delete' calls.
#
# * +deleted+ [Integer] - The number of items deleted
class DeleteSummary
attr_reader :deleted
def initialize(deleted)
@deleted = deleted
end
def self.from_json(hash)
new(hash["deleted"])
end
end
end |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb/single_value.rb | Ruby | mit | 19 | v1.0 | 279 | module TempoDB
class SingleValue
attr_accessor :series, :data
def initialize(series, data)
@series = series
@data = data
end
def self.from_json(json)
new(Series.from_json(json["series"]), DataPoint.from_json(json["data"]))
end
end
end |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb/cursor.rb | Ruby | mit | 19 | v1.0 | 3,441 | require 'enumerator'
require 'httpclient_link_header'
module TempoDB
# A Cursor represents the fundamental way in which large streams of data are
# read from the TempoDB API. Most read calls that return large collections of
# objects will return a Cursor. A Cursor represents one logical read of a query,
# but ... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb/client.rb | Ruby | mit | 19 | v1.0 | 30,124 | require 'time'
require 'json'
require 'tempodb/cursor'
require 'tempodb/data_point'
require 'tempodb/data_point_found'
require 'tempodb/data_set'
require 'tempodb/delete_summary'
require 'tempodb/multipoint'
require 'tempodb/multipoint_segment'
require 'tempodb/multi_write'
require 'tempodb/series'
require 'tempodb/se... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb/multipoint_segment.rb | Ruby | mit | 19 | v1.0 | 423 | module TempoDB
# A logical page of MultiPoint with additional metadata
class MultiPointSegment
attr_accessor :data, :rollup, :tz
def initialize(data, rollup, tz)
@data = data
@rollup = rollup
@tz = tz
end
def self.from_json(m)
data = m["data"].map { |mdp| MultiPoint.from_js... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb/data_point.rb | Ruby | mit | 19 | v1.0 | 450 | module TempoDB
# The fundamental unit of TempoDB. A compound type that holds both:
#
# * +ts+ [Time] - A timestamp
# * +value+ [Integer/Float] - A numeric value
#
class DataPoint
attr_reader :ts, :value
def initialize(ts, value)
@ts = ts
@value = value
end
def to_json(*a)
... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb/series_summary.rb | Ruby | mit | 19 | v1.0 | 479 | module TempoDB
# Used to return common aggregate metadata for datapoint reads
class SeriesSummary
attr_accessor :summary, :series, :start, :stop, :tz
def initialize(summary, series, start, stop, tz)
@summary = summary
@series = series
@start = start
@stop = stop
@tz = tz
e... |
github | tempodb/tempodb-ruby | https://github.com/tempodb/tempodb-ruby | lib/tempodb/data_set.rb | Ruby | mit | 19 | v1.0 | 510 | module TempoDB
# A page of DataPoints, with additional metadata
class DataSet
attr_accessor :series, :data, :rollup, :tz
def initialize(series, data, rollup, tz)
@series = series
@data = data
@rollup = rollup
@tz = tz
end
def self.from_json(m)
series = Series.from_jso... |
github | prontolabs/pronto-flay | https://github.com/prontolabs/pronto-flay | Rakefile | Ruby | mit | 19 | master | 338 | #!/usr/bin/env rake
require 'bundler'
require 'rspec/core/rake_task'
Bundler::GemHelper.install_tasks
RSpec::Core::RakeTask.new(:spec)
desc 'Bundle the gem'
task :bundle do
sh 'bundle check || bundle install'
sh 'gem build *.gemspec'
sh 'gem install *.gem'
sh 'rm *.gem'
end
task(:default).clear
task default:... |
github | prontolabs/pronto-flay | https://github.com/prontolabs/pronto-flay | pronto-flay.gemspec | Ruby | mit | 19 | master | 1,105 | # -*- encoding: utf-8 -*-
#
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'pronto/flay/version'
require 'English'
Gem::Specification.new do |s|
s.name = 'pronto-flay'
s.version = Pronto::FlayVersion::VERSION
s.platform = Gem::Platform::RUBY
s.author = 'Mindaugas Mozūras'
s.email = 'mindaugas.m... |
github | prontolabs/pronto-flay | https://github.com/prontolabs/pronto-flay | spec/spec_helper.rb | Ruby | mit | 19 | master | 528 | require 'fileutils'
require 'rspec'
require 'rspec/its'
require 'pronto/flay'
RSpec.shared_context 'test repo' do
let(:git) { 'spec/fixtures/test.git/git' }
let(:dot_git) { 'spec/fixtures/test.git/.git' }
before { FileUtils.mv(git, dot_git) }
let(:repo) { Pronto::Git::Repository.new('spec/fixtures/test.git') ... |
github | prontolabs/pronto-flay | https://github.com/prontolabs/pronto-flay | spec/pronto/flay_spec.rb | Ruby | mit | 19 | master | 2,126 | require 'spec_helper'
require 'ostruct'
module Pronto
describe Flay do
let(:flay) { Flay.new(patches) }
let(:patches) { nil }
let(:pronto_config) do
instance_double Pronto::ConfigFile, to_h: config_hash
end
let(:config_hash) { {} }
before do
allow(Pronto::ConfigFile).to receive(:... |
github | prontolabs/pronto-flay | https://github.com/prontolabs/pronto-flay | lib/pronto/flay.rb | Ruby | mit | 19 | master | 2,484 | require 'pronto'
require 'flay'
module Pronto
class Flay < Runner
DEFAULT_SEVERITY_LEVELS = {
identical: :error,
similar: :warning,
}.freeze
def run
if files.any?
flay.analyze
messages
else
[]
end
end
# The current Flay (2.8.0) takes care of... |
github | jronallo/mep-feature-time-rail-thumbnails | https://github.com/jronallo/mep-feature-time-rail-thumbnails | mep_feature_time_rail_thumbnails.gemspec | Ruby | mit | 19 | master | 728 | $:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "mep_feature_time_rail_thumbnails/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "mep_feature_time_rail_thumbnails"
s.version = MepFeatureTimeRailThumbnails::VERSION
... |
github | jronallo/mep-feature-time-rail-thumbnails | https://github.com/jronallo/mep-feature-time-rail-thumbnails | Gemfile | Ruby | mit | 19 | master | 557 | source "https://rubygems.org"
# Declare your gem's dependencies in mep_feature_time_rail_thumbnails.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 develop... |
github | bragi/site_meta | https://github.com/bragi/site_meta | site_meta.gemspec | Ruby | mit | 19 | master | 2,165 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{site_meta}
s.version = "1.0.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required... |
github | bragi/site_meta | https://github.com/bragi/site_meta | Rakefile | Ruby | mit | 19 | master | 1,571 | require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "site_meta"
gem.summary = %Q{helpers for easy adding of html meta information in web applications}
gem.description = %Q{Provides helpers for easy adding of html meta information to Rails applications.
* Ea... |
github | bragi/site_meta | https://github.com/bragi/site_meta | spec/site_meta_spec.rb | Ruby | mit | 19 | master | 5,490 | require File.dirname(__FILE__) + '/spec_helper.rb'
class SiteMetaInstance
include ActionView::Helpers::TagHelper
include SiteMetaHelper
end
class NilClass
def blank?
true
end
end
describe SiteMetaHelper do
before(:each) do
@helper = SiteMetaInstance.new
end
it "should use given name and cont... |
github | bragi/site_meta | https://github.com/bragi/site_meta | lib/app/helpers/site_meta_helper.rb | Ruby | mit | 19 | master | 6,418 | # Provides helpers for easily adding metadata to your views and layouts.
#
# In your layout use helpers +head_title+, +meta_description+, +meta_keywords+
# with optional defaults. In each view you can override the defaults using
# helpers +set_head_title+, +set_meta_description+, +set_meta_keywords+.
#
# == Providing d... |
github | ctagg/ebay_shopping | https://github.com/ctagg/ebay_shopping | ebay_shopping.gemspec | Ruby | mit | 19 | master | 711 | Gem::Specification.new do |s|
s.name = 'ebay_shopping'
s.version = "0.1.1"
s.summary = %q{A Ruby library for Ebay's Shopping API. By Chris Taggart}
s.description = %q{The ebay_shopping gem is a Ruby library for Ebay's Shopping API (http://developer.ebay.com/products/shopping/).}
s.authors = ["Chris Taggart"]... |
github | ctagg/ebay_shopping | https://github.com/ctagg/ebay_shopping | lib/ebay_shopping.rb | Ruby | mit | 19 | master | 18,655 | # TODO:
# -- Add hook and info level logging if request generates warning
# -- Add support for FindHalfProducts, FindPopularSearches, FindProducts, FindReviewsAndGuides, GetCategoryInfo, GeteBayTime, GetItemStatus, GetShippingCosts, GetUserProfile
# -- Add some documentation
require 'yaml'
require 'time'
require 'cgi'... |
github | ctagg/ebay_shopping | https://github.com/ctagg/ebay_shopping | test/test_ebay_shopping.rb | Ruby | mit | 19 | master | 21,663 | require File.dirname(__FILE__) + '/test_helper.rb'
# Tests EbayShopping::Request class.
class TestEbayShopping < Test::Unit::TestCase
def setup
setup_ebay_responses
YAML.stubs(:load_file).returns({:production => {:app_id => "foo123"}}) # stub getting of config file
end
#
# custom exception definit... |
github | ctagg/ebay_shopping | https://github.com/ctagg/ebay_shopping | config/hoe.rb | Ruby | mit | 19 | master | 2,626 | require 'ebay_shopping/version'
AUTHOR = 'Chris Taggart' # can also be an array of Authors
EMAIL = "chris.taggart@pushrodmedia.co.uk"
DESCRIPTION = "A Ruby library for Ebay's lightweight Shopping API"
GEM_NAME = 'ebay_shopping' # what ppl will type to install your gem
RUBYFORGE_PROJECT = 'ebayshopping' # The unix nam... |
github | aphyr/bitcask-ruby | https://github.com/aphyr/bitcask-ruby | Rakefile.rb | Ruby | mit | 19 | master | 1,212 | $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
require 'rubygems'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'bitcask/version'
require 'find'
# Don't include resource forks in tarballs on Mac OS X.
ENV['COPY_EXTENDED_ATTRIBUTES_DISABLE'] = 'true'
ENV['COPYFILE_DISABLE'] = 'true'
# Gemspec
... |
github | aphyr/bitcask-ruby | https://github.com/aphyr/bitcask-ruby | lib/bitcask.rb | Ruby | mit | 19 | master | 3,087 | class Bitcask
require 'zlib'
require 'stringio'
$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
require 'bitcask/hint_file'
require 'bitcask/data_file'
require 'bitcask/keydir'
require 'bitcask/errors'
require 'bitcask/version'
include Enumerable
TOMBSTONE = "bitcask_tombstone"
# Opens... |
github | aphyr/bitcask-ruby | https://github.com/aphyr/bitcask-ruby | lib/bitcask/data_file.rb | Ruby | mit | 19 | master | 2,120 | class Bitcask::DataFile
# A single Bitcask data file.
#
# This is most definitely not threadsafe, but it's so cheap you might as well
# make lots of copies.
Entry = Struct.new :tstamp, :key, :value
include Enumerable
def initialize(filename)
@file = File.open(filename)
end
# Reads [key, value]... |
github | aphyr/bitcask-ruby | https://github.com/aphyr/bitcask-ruby | lib/bitcask/hint_file.rb | Ruby | mit | 19 | master | 1,829 | class Bitcask::HintFile
# A single Bitcask hint file.
#
# This is most definitely not threadsafe, but it's so cheap you might as well
# make lots of copies.
Entry = Struct.new :tstamp, :value_sz, :value_pos, :key
include Enumerable
attr_accessor :data_file
def initialize(filename)
@file = File.op... |
github | aphyr/bitcask-ruby | https://github.com/aphyr/bitcask-ruby | spec/data_file.rb | Ruby | mit | 19 | master | 1,478 | #!/usr/bin/env ruby
require 'rubygems'
require 'bacon'
require 'bert'
require 'pp'
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/bitcask"
unless ARGV.first
puts "I need a bitcask directory."
exit 1
end
Bacon.summary_on_exit
describe 'Bitcask' do
before do
@b = Bitcask.new ARGV.first
@f =... |
github | aphyr/bitcask-ruby | https://github.com/aphyr/bitcask-ruby | spec/bitcask.rb | Ruby | mit | 19 | master | 1,557 | #!/usr/bin/env ruby
require 'bacon'
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/bitcask"
unless ARGV.first
puts "I need a bitcask directory."
exit 1
end
Bacon.summary_on_exit
describe 'Bitcask' do
before do
@b = Bitcask.new ARGV.first
end
should 'have DataFiles' do
@b.data_files.s... |
github | aphyr/bitcask-ruby | https://github.com/aphyr/bitcask-ruby | spec/hint_file.rb | Ruby | mit | 19 | master | 1,681 | #!/usr/bin/env ruby
require 'rubygems'
require 'bacon'
require 'bert'
require 'pp'
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/bitcask"
unless ARGV.first
puts "I need a bitcask directory."
exit 1
end
Bacon.summary_on_exit
describe 'HintFile' do
before do
@b = Bitcask.new ARGV.first
@f ... |
github | aphyr/bitcask-ruby | https://github.com/aphyr/bitcask-ruby | spec/gc.rb | Ruby | mit | 19 | master | 1,725 | #!/usr/bin/env ruby
require 'rubygems'
require 'bacon'
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/bitcask"
unless ARGV.first
puts "I need a bitcask directory."
exit 1
end
Bacon.summary_on_exit
describe 'Bitcask GC' do
def count(k)
c = 0
ObjectSpace.each_object(k) do |x|
c += 1
... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | litmus.gemspec | Ruby | mit | 19 | master | 3,876 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "litmus"
s.version = "0.5.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | Rakefile | Ruby | mit | 19 | master | 844 | require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "litmus"
gem.summary = %Q{A wrapper to the Litmus customer API}
gem.description = %Q{A wrapper to the Litmus customer API}
gem.email = "mail@matthewfawcett.co.uk"
gem.homepage = "http://github.com/m... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | Gemfile | Ruby | mit | 19 | master | 280 | source "http://rubygems.org"
gem "httparty", ">= 0.6.1"
group :development do
gem "rspec"
gem "bundler", "~> 1.0"
gem "jeweler", "~> 2.0.1"
gem "simplecov", ">= 0"
gem "fakeweb"
gem 'guard-rspec', '~> 4.3.1'
gem 'guard-bundler'
gem 'terminal-notifier-guard'
end |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | spec/result_spec.rb | Ruby | mit | 19 | master | 987 | require 'spec_helper'
describe Litmus::Result do
describe ".list" do
it "should give me an array of results" do
results = Litmus::Result.list(1715760, 1)
results.count.should == 17
results.first["result_images"].first["full_image"].should =~ /s3.amazonaws.com/
end
end
describe ".show" ... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | spec/litmus_spec.rb | Ruby | mit | 19 | master | 452 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Litmus" do
describe ".configure" do
it "should use the appropriate protocol for the given account" do
Litmus::Base.configure('host', 'user', 'password')
Litmus::Base.base_uri.should == 'http://host.litmus.com'
Litmus::... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | spec/test_version_spec.rb | Ruby | mit | 19 | master | 976 | require 'spec_helper'
describe Litmus::TestVersion do
describe ".show" do
it "should give me back a test version object" do
test_version = Litmus::TestVersion.show(1716450, 1)
test_version["version"].should == 1
end
end
describe ".list" do
it "should give me back a an array of test versi... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | spec/page_test_spec.rb | Ruby | mit | 19 | master | 836 | require 'spec_helper'
describe Litmus::PageTest do
describe ".list" do
it "should give me a list of page test objects" do
list = Litmus::PageTest.list
list.length.should eql(1)
list.first["name"].should eql("Home | Real Ale Hunter")
list.first["id"].should eql(1715752)
end
end
de... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | spec/report_spec.rb | Ruby | mit | 19 | master | 601 | require 'spec_helper'
describe Litmus::Result do
describe ".list" do
it "should give me an array of results" do
results = Litmus::Report.list
results.count.should == 3
results.first["id"].should == 24
end
end
describe ".show" do
it "should return a result object" do
result = ... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | spec/spec_helper.rb | Ruby | mit | 19 | master | 4,613 | $LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'litmus'
require 'rspec'
require 'fakeweb'
FakeWeb.allow_net_connect = false
RSpec.configure do |config|
FakeWeb.register_uri(:get, 'http://matt:yourpassword@matthewfawcett.litmus.com/tests.xml',
... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | spec/email_test_spec.rb | Ruby | mit | 19 | master | 1,452 | require 'spec_helper'
describe Litmus::EmailTest do
describe ".list" do
it "should give me a list of email test objects" do
list = Litmus::EmailTest.list
list.length.should eql(1)
list.first["name"].should eql("A really good email")
list.first["id"].should eql(1715760)
end
end
de... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | spec/test_spec.rb | Ruby | mit | 19 | master | 585 | require 'spec_helper'
describe Litmus::Test do
describe ".show" do
it "should give back the test object" do
test = Litmus::Test.show(1716450)
test["id"].should == 1716450
end
end
describe ".rename" do
it "should respond with the new name" do
test = Litmus::Test.rename(1716450, 'New... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | lib/litmus.rb | Ruby | mit | 19 | master | 233 | require "httparty"
require "builder"
require "litmus/base"
require "litmus/test"
require "litmus/email_test"
require "litmus/page_test"
require "litmus/test_version"
require "litmus/result"
require "litmus/report"
module Litmus
end |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | lib/litmus/page_test.rb | Ruby | mit | 19 | master | 572 | module Litmus
class PageTest < Test
def self.list
super.reject{|test| test["service"] != 'page'}
end
def self.create(url, name = nil, sandbox = false)
builder = Builder::XmlMarkup.new
builder.instruct! :xml, :version=>"1.0"
builder.test_set do |test_set|
test_set.use_defau... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | lib/litmus/result.rb | Ruby | mit | 19 | master | 750 | module Litmus
class Result < Base
def self.list(test_id, version_id)
get("/tests/#{test_id}/versions/#{version_id}/results.xml")["results"]
end
def self.show(test_id, version_id, id)
get("/tests/#{test_id}/versions/#{version_id}/results/#{id}.xml")["result"]
end
def self.update(test_... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | lib/litmus/report.rb | Ruby | mit | 19 | master | 506 | module Litmus
class Report < Base
def self.list
get("/reports.xml")["reports"]
end
def self.show(report_id)
get("/reports/#{report_id}.xml")["report"]
end
def self.create(name)
builder = Builder::XmlMarkup.new
builder.instruct! :xml, :version=>"1.0"
builder.report d... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | lib/litmus/email_test.rb | Ruby | mit | 19 | master | 1,219 | module Litmus
class EmailTest < Test
def self.list
super.reject{|test| test["service"] != 'email'}
end
def self.create(email={}, name = nil, sandbox = false, application_codes=[])
builder = Builder::XmlMarkup.new
builder.instruct! :xml, :version=>"1.0"
builder.test_set do |test_se... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | lib/litmus/test_version.rb | Ruby | mit | 19 | master | 478 | module Litmus
class TestVersion < Base
def self.show(test_id, id)
get("/tests/#{test_id}/versions/#{id}.xml")["test_set_version"]
end
def self.list(test_id)
get("/tests/#{test_id}/versions.xml")["test_set_versions"]
end
def self.create(test_id)
post("/tests/#{test_id}/versions.... |
github | mattfawcett/litmus | https://github.com/mattfawcett/litmus | lib/litmus/base.rb | Ruby | mit | 19 | master | 430 | module Litmus
class Base
include HTTParty
# debug_output $stderr
def initialize(company, username, password, ssl = false)
self.class.configure(company, username, password, ssl)
end
def self.configure(company, username, password, ssl = false)
protocol = ssl ? 'https' : 'http'
se... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.