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 | chaosdorf/mete | https://github.com/chaosdorf/mete | config/initializers/secret_token.rb | Ruby | mit | 48 | main | 616 | # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | config/initializers/sentry.rb | Ruby | mit | 48 | main | 253 | Sentry.init do |config|
config.enabled_environments = ['production']
if File.file?("/run/secrets/SENTRY_DSN")
config.dsn = File.read("/run/secrets/SENTRY_DSN").strip
end
config.breadcrumbs_logger = [:active_support_logger, :http_logger]
end |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | config/initializers/assets.rb | Ruby | mit | 48 | main | 490 | # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "1.0"
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile additional... |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/schema.rb | Ruby | mit | 48 | main | 2,095 | # 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 | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20170225163225_user_redirect.rb | Ruby | mit | 48 | main | 289 | class UserRedirect < ActiveRecord::Migration[5.0]
#via http://api.rubyonrails.org/classes/ActiveRecord/Migration.html
def up
add_column :users, :redirect, :boolean, default: true
User.all.each { |user| user.redirect = true }
end
def down
remove_column :users, :redirect
end
end |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20170929201659_delete_barcodes_without_drink.rb | Ruby | mit | 48 | main | 367 | class DeleteBarcodesWithoutDrink < ActiveRecord::Migration[5.0]
def up
Barcode.all.each do |barcode|
unless Drink.find_by(:id => barcode.drink)
puts "Deleting barcode #{barcode.id}, because the associated drink doesn't exist."
barcode.destroy!
end
end
end
def down
puts "... |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20131020154048_bottle_size_and_caffeine_to_int.rb | Ruby | mit | 48 | main | 243 | class BottleSizeAndCaffeineToInt < ActiveRecord::Migration[4.2]
def change
change_column :drinks, :bottle_size, :integer, using: 'bottle_size::integer'
change_column :drinks, :caffeine, :integer, using: 'caffeine::integer'
end
end |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20170317193125_drinks_barcode.rb | Ruby | mit | 48 | main | 298 | class DrinksBarcode < ActiveRecord::Migration[5.0]
#via http://api.rubyonrails.org/classes/ActiveRecord/Migration.html
def up
add_column :drinks, :barcode, :string
add_index :drinks, :barcode
end
def down
remove_index :drinks, column: :barcode
remove_column :drinks, :barcode
end
end |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20170323104606_create_barcodes.rb | Ruby | mit | 48 | main | 961 | class CreateBarcodes < ActiveRecord::Migration[5.0]
def up
create_table :barcodes, id: :string do |t|
t.integer :drink, null: false
end
puts "Migrating existing barcodes…"
Drink.all.each do |drink|
unless drink.barcode.nil?
unless drink.barcode.empty?
puts "Processing #{d... |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20160531170858_activate_all_users.rb | Ruby | mit | 48 | main | 296 | class ActivateAllUsers < ActiveRecord::Migration[4.2]
#via http://api.rubyonrails.org/classes/ActiveRecord/Migration.html
def up
add_column :users, :active, :boolean, default: true
User.all.each { |user| user.active = true }
end
def down
remove_column :users, :active
end
end |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20131019225323_normalize_column_names.rb | Ruby | mit | 48 | main | 250 | class NormalizeColumnNames < ActiveRecord::Migration[4.2]
def change
change_table :drinks do |t|
t.rename :bottleSize, :bottle_size
t.rename :donationRecommendation, :price
t.rename :logoUrl, :logo_file_name
end
end
end |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20160531175554_deactivate_renamed_users.rb | Ruby | mit | 48 | main | 446 | class DeactivateRenamedUsers < ActiveRecord::Migration[4.2]
#via http://api.rubyonrails.org/classes/ActiveRecord/Migration.html
def up
User.all.each do |user|
if user.name.start_with? "zz_"
user.active = false
user.name = user.name[3..-1]
user.save!
end
end
end
def down
User.where... |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20130313210611_create_drinks.rb | Ruby | mit | 48 | main | 280 | class CreateDrinks < ActiveRecord::Migration[5.0]
def change
create_table :drinks do |t|
t.string :name
t.string :bottleSize
t.string :caffeine
t.decimal :donationRecommendation
t.string :logoUrl
t.timestamps null: true
end
end
end |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20131020002631_add_attachment_logo_to_drink.rb | Ruby | mit | 48 | main | 396 | class AddAttachmentLogoToDrink < ActiveRecord::Migration[4.2]
def self.up
add_column :drinks, :logo_content_type, :string
add_column :drinks, :logo_file_size, :integer
add_column :drinks, :logo_updated_at, :datetime
end
def self.down
remove_column :drinks, :logo_content_type
remove_column :dr... |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20160719184610_user_audits.rb | Ruby | mit | 48 | main | 299 | class UserAudits < ActiveRecord::Migration[4.2]
#via http://api.rubyonrails.org/classes/ActiveRecord/Migration.html
def up
add_column :audits, :user, :int
add_column :users, :audit, :boolean, default: false
end
def down
remove_column :audits, :user
remove_column :users, :audit
end
end |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20130831113435_change_balances_to_decimal.rb | Ruby | mit | 48 | main | 808 | class ChangeBalancesToDecimal < ActiveRecord::Migration[4.2]
def up
add_column :users, :balance, :decimal, default: 0.0, precision: 20, scale: 2
add_column :audits, :difference, :decimal, default: 0.0, precision: 20, scale: 2
execute 'UPDATE users SET balance = balance_cents / 100'
execute 'UPDATE aud... |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20121226184524_add_balance_default.rb | Ruby | mit | 48 | main | 220 | class AddBalanceDefault < ActiveRecord::Migration[4.2]
def up
change_column :users, :balance_cents, :integer, default: 0
end
def down
change_column :users, :balance_cents, :integer, default: nil
end
end |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20160531151246_activate_all_drinks.rb | Ruby | mit | 48 | main | 294 | class ActivateAllDrinks < ActiveRecord::Migration[4.2]
#via http://api.rubyonrails.org/classes/ActiveRecord/Migration.html
def up
add_column :drinks, :active, :boolean, default: true
Drink.all.each { |drink| drink.active = true }
end
def down
remove_column :drinks, :active
end
end |
github | chaosdorf/mete | https://github.com/chaosdorf/mete | db/migrate/20120930012121_create_users.rb | Ruby | mit | 48 | main | 215 | class CreateUsers < ActiveRecord::Migration[4.2]
def change
create_table :users do |t|
t.string :name
t.string :email
t.integer :balance_cents
t.timestamps null: true
end
end
end |
github | RxSwiftCommunity/rxswiftcommunity.github.io | https://github.com/RxSwiftCommunity/rxswiftcommunity.github.io | Rakefile | Ruby | mit | 48 | source | 915 | require 'middleman-gh-pages'
task :lint_projects do
# TODO. See: https://github.com/chriseidhof/ios-videos/blob/89a5c6364254e03e16196c78c51653e56bab2df9/Rakefile#L21-L35 for example
end
desc "Performs CI deploy if on source branch"
task :travis do
branch = ENV['TRAVIS_BRANCH']
pull_request = ENV['TRAVIS_PULL_RE... |
github | RxSwiftCommunity/rxswiftcommunity.github.io | https://github.com/RxSwiftCommunity/rxswiftcommunity.github.io | Gemfile | Ruby | mit | 48 | source | 218 | source 'https://rubygems.org'
gem 'middleman'
gem 'httparty'
gem 'psych'
gem 'colorize'
# Publish to github pages
gem 'middleman-gh-pages', git: 'https://github.com/edgecase/middleman-gh-pages.git', branch: 'master' |
github | RxSwiftCommunity/rxswiftcommunity.github.io | https://github.com/RxSwiftCommunity/rxswiftcommunity.github.io | lib/custom_helpers.rb | Ruby | mit | 48 | source | 2,163 | module CustomHelpers
def item_to_html(item_hash)
name = item_hash['name']
link = item_hash['link'] || "https://github.com/#{item_hash['repo']}"
description = item_hash['description']
<<-EOS
<div class="js-grid-item grid-item">
<div class="panel panel-default">
<div class="pan... |
github | RxSwiftCommunity/rxswiftcommunity.github.io | https://github.com/RxSwiftCommunity/rxswiftcommunity.github.io | scripts/github_fetch.rb | Ruby | mit | 48 | source | 1,733 | #!/usr/bin/env ruby
require 'httparty'
require 'psych'
require 'colorize'
unless ENV.key?('GITHUB_USER') && ENV.key?('GITHUB_PERSONAL_ACCESS_TOKEN') then
puts "Please set GITHUB_USER and GITHUB_PERSONAL_ACCESS_TOKEN environment variables".red
exit 1
end
begin
ITEMS_FILE = "data/items.yml"
yaml = Psy... |
github | moiristo/dynamic_attributes | https://github.com/moiristo/dynamic_attributes | Rakefile | Ruby | mit | 48 | master | 2,125 | require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "dynamic_attributes"
gem.summary = %Q{dynamic_attributes is a gem that lets you dynamically specify attributes on ActiveRecord models, which will be serialized and
deserialized to a given text column.}
gem.... |
github | moiristo/dynamic_attributes | https://github.com/moiristo/dynamic_attributes | dynamic_attributes.gemspec | Ruby | mit | 48 | master | 1,713 | # 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{dynamic_attributes}
s.version = "1.2.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? ... |
github | moiristo/dynamic_attributes | https://github.com/moiristo/dynamic_attributes | test/helper.rb | Ruby | mit | 48 | master | 1,442 | require 'rubygems'
require 'test/unit'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
gem "activerecord"
require 'fileutils'
require 'active_record'
require 'dynamic_attributes'
require 'pp'
class DynamicNestedModel < ActiveRecord::Base
has_dynamic_att... |
github | moiristo/dynamic_attributes | https://github.com/moiristo/dynamic_attributes | test/schema.rb | Ruby | mit | 48 | master | 347 | ActiveRecord::Schema.define(:version => 0) do
create_table :dynamic_models, :force => true do |t|
t.string :title
t.text :dynamic_attributes
t.text :extra
end
create_table :dynamic_nested_models, :force => true do |t|
t.string :title
t.text :dynamic_attributes
t.integer :dyn... |
github | moiristo/dynamic_attributes | https://github.com/moiristo/dynamic_attributes | test/test_dynamic_attributes.rb | Ruby | mit | 48 | master | 4,840 | require 'helper'
class TestDynamicAttributes < Test::Unit::TestCase
load_schema
def setup
DynamicModel.dynamic_attribute_field = :dynamic_attributes
DynamicModel.dynamic_attribute_prefix = 'field_'
DynamicModel.destroy_dynamic_attribute_for_nil = false
@dynamic_model = DynamicModel.cr... |
github | moiristo/dynamic_attributes | https://github.com/moiristo/dynamic_attributes | lib/dynamic_attributes.rb | Ruby | mit | 48 | master | 7,117 | # Adds the has_dynamic_attributes method in ActiveRecord::Base, which can be used to configure the module.
class << ActiveRecord::Base
# Method to call in AR classes in order to be able to define dynamic attributes. The following options can be defined:
#
# * :dynamic_attribute_field - Defines the attribute ... |
github | grimen/link2 | https://github.com/grimen/link2 | Guardfile | Ruby | mit | 48 | master | 302 | guard 'bundler' do
watch('Gemfile')
watch(/^.+\.gemspec/)
end
guard 'test' do
watch(%r|^lib/(.*)\.rb|) { |m| "test/lib/#{m[1]}_test.rb" }
watch(%r|^test/(.*)_test.rb|)
watch(%r|^test/integration/(.*)\.rb|) { "test" }
watch(%r|^test/test_helper.rb|) { "test" }
end |
github | grimen/link2 | https://github.com/grimen/link2 | Rakefile | Ruby | mit | 48 | master | 719 | require 'bundler'
Bundler::GemHelper.install_tasks
require 'rake'
require 'rake/testtask'
require 'rdoc/task'
# Gem managment tasks.
#
# == Git tag & push to origin/master and push gem to Rubygems.org:
#
# $ rake release
#
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the plugin.'
Rake::TestTas... |
github | grimen/link2 | https://github.com/grimen/link2 | link2.gemspec | Ruby | mit | 48 | master | 1,377 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "link2/version"
Gem::Specification.new do |s|
s.name = "link2"
s.version = Link2::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Jonas Grimfelt"]
s.email = ["grimen@gmail.com"]
s.homepage = "ht... |
github | grimen/link2 | https://github.com/grimen/link2 | lib/link2.rb | Ruby | mit | 48 | master | 3,106 | # encoding: utf-8
require 'active_support'
require 'action_view'
module Link2
autoload :Brain, 'link2/brain'
autoload :Helpers, 'link2/helpers'
autoload :I18n, 'link2/i18n'
autoload :Support, 'link2/support'
autoload :VERSION, 'link2/version'
# include ::ActionController::UrlWriter
# Default... |
github | grimen/link2 | https://github.com/grimen/link2 | lib/link2/support.rb | Ruby | mit | 48 | master | 4,098 | # encoding: utf-8
module Link2
module Support
class << self
# Get resource class based on name, object, or class.
#
# == Example/Usage:
#
# resource_class(:post), resource_class(@post), resource_class(Post)
# # => Post, Post, Post
#
def find_resource_class(a... |
github | grimen/link2 | https://github.com/grimen/link2 | lib/link2/brain.rb | Ruby | mit | 48 | master | 15,349 | # encoding: utf-8
module Link2
module Brain
AutoDetectionFailed = Class.new(::ArgumentError)
NilArgument = Class.new(::ArgumentError)
URL_PATH_REGEX = /\//
CLASS_INSTANCE_STRING = /\#\<.*\:0x.*\>/
LINK_TO_OPTION_KEYS = [:method, :confirm, :popup, :html_options].freeze
BUTTON_TO_OPTION_KEYS... |
github | grimen/link2 | https://github.com/grimen/link2 | lib/link2/i18n.rb | Ruby | mit | 48 | master | 4,411 | # encoding: utf-8
module Link2
module I18n
ScopeInterpolationError = Class.new(::Link2::Error)
VALID_SCOPE_VARIABLES = [:controller, :action, :resource, :resources].freeze
INTERPOLATION_SYNTAX_PATTERN = /(\\)?\{\{([^\}]+)\}\}/
class << self
# Helper method to lookup I18n keys based on a add... |
github | grimen/link2 | https://github.com/grimen/link2 | lib/link2/helpers.rb | Ruby | mit | 48 | master | 610 | # encoding: utf-8
module Link2
module Helpers
include ::Link2::Brain
# Enhanced +link_to+ helper.
#
# TODO: Documentation for this helper. For now the README should be sufficient.
#
def link(*args, &block)
args = self.link_to_args(*args)
link_to(*args)
end
alias :link2 :... |
github | grimen/link2 | https://github.com/grimen/link2 | generators/link2/templates/initializer.rb | Ruby | mit | 48 | master | 524 | # encoding: utf-8
if defined?(::Link2)
::Link2.setup do |config|
# Configure how - and in what order - link labels should be looked up.
# config.i18n_scopes = ['{{model}}.links.{{action}}', 'links.{{action}}']
#
# Configure any custom action mappings.
# config.action_mappings = {
# :home =>... |
github | grimen/link2 | https://github.com/grimen/link2 | test/test_helper.rb | Ruby | mit | 48 | master | 1,072 | # -*- encoding: utf-8 -*-
require 'rubygems'
require 'bundler'
Bundler.require
ENV['RAILS_ENV'] = 'test'
TEST_ORM = (ENV['ORM'] || :active_record).to_sym unless defined?(TEST_ORM)
# ORM / Schema.
require File.join(File.dirname(__FILE__), 'orm', TEST_ORM.to_s)
require 'test/unit'
require 'mocha'
require 'webrat'
begi... |
github | grimen/link2 | https://github.com/grimen/link2 | test/support_test.rb | Ruby | mit | 48 | master | 2,086 | # encoding: utf-8
require 'test_helper'
class SupportTest < ActiveSupport::TestCase
def setup
end
test "#find_resource_class: should find proper class based on class, class instance, or (symbol) name" do
assert_nil ::Link2::Support.find_resource_class(nil)
assert_equal ::Fraggle, ::Link2::Support.find... |
github | grimen/link2 | https://github.com/grimen/link2 | test/helpers_test.rb | Ruby | mit | 48 | master | 19,123 | # encoding: utf-8
require 'test_helper'
class HelpersTest < ActionView::TestCase
include Link2::Helpers
ONE_HASH = {:confirm => 'Really?'}
TWO_HASHES = [{:confirm => 'Really?'}, {:class => 'funny'}]
def setup
::I18n.locale = :en
::Link2.dom_selectors = false
::Link2.i18n_scopes = [] # Keep it si... |
github | grimen/link2 | https://github.com/grimen/link2 | test/brain_test.rb | Ruby | mit | 48 | master | 6,800 | # encoding: utf-8
require 'test_helper'
class BrainTest < ActionView::TestCase
include ::Link2::Brain
def setup
::I18n.locale = :en
@mookey = ::Fraggle.create(:name => 'Mookey')
@wembley = ::Fraggle.create(:name => 'Wembley')
@tweaked_mookey = ::Fraggle.create(:name => 'Mookey 2.0')
@tweaked... |
github | grimen/link2 | https://github.com/grimen/link2 | test/i18n_test.rb | Ruby | mit | 48 | master | 3,034 | # encoding: utf-8
require 'test_helper'
class I18nTest < ActiveSupport::TestCase
def setup
::I18n.locale = :en
::Link2.i18n_scopes = ['links.{{action}}']
end
test "i18n: should load default translations automatically" do
options = {:scope => 'links', :resource => 'post', :resources => 'posts'}
... |
github | grimen/link2 | https://github.com/grimen/link2 | test/link2_test.rb | Ruby | mit | 48 | master | 1,657 | # encoding: utf-8
class Link2Test < ActiveSupport::TestCase
test "#setup: setup block yields self" do
Link2.setup do |config|
assert_equal Link2, config
end
end
test "#setup: should be configurable using setup helper" do
swap Link2, :i18n_scopes => ['links.{{action}}'] do
assert_equal [... |
github | grimen/link2 | https://github.com/grimen/link2 | test/integration/helpers_integration_test.rb | Ruby | mit | 48 | master | 285 | # encoding: utf-8
require 'test_helper'
class HelpersIntegrationTest < ActionController::IntegrationTest
test 'Link2 + Rails = ♥' do
visit '/'
assert_response :success
assert_template 'home/index'
# puts response.body.inspect
assert_contain "WIN"
end
end |
github | grimen/link2 | https://github.com/grimen/link2 | test/integration/rails_app/config/environment.rb | Ruby | mit | 48 | master | 487 | # Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.12' unless defined? RAILS_GEM_VERSION
TEST_ORM = :active_record unless defined? TEST_ORM
# Bootstrap the Rails environment, frameworks, and default configuration... |
github | grimen/link2 | https://github.com/grimen/link2 | test/integration/rails_app/config/initializers/link2.rb | Ruby | mit | 48 | master | 522 | Link2.setup do |config|
# Configure how - and in what order - link labels should be looked up.
config.i18n_scopes = [
'{{model}}.links.{{action}}',
'links.{{action}}'
]
# Configure any custom action mappings.
config.action_mappings = {
:home => lambda { '/' },
:back => lambda { |url| url || :... |
github | grimen/link2 | https://github.com/grimen/link2 | test/integration/rails_app/config/initializers/session_store.rb | Ruby | mit | 48 | master | 801 | # Be sure to restart your server when you modify this file.
# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Acti... |
github | grimen/link2 | https://github.com/grimen/link2 | test/integration/rails_app/config/initializers/new_rails_defaults.rb | Ruby | mit | 48 | master | 897 | # Be sure to restart your server when you modify this file.
# These settings change the behavior of Rails 2 apps and will be defaults
# for Rails 3. You can remove this initializer when Rails 3 is released.
if defined?(ActiveRecord)
# Include Active Record class name as root for JSON serialized output.
ActiveReco... |
github | grimen/link2 | https://github.com/grimen/link2 | test/orm/active_record.rb | Ruby | mit | 48 | master | 759 | # encoding: utf-8
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'integration', 'rails_app', 'config', 'environment'))
require 'test_helper'
ActiveRecord::Migration.verbose = false
ActiveRecord::Base.logger = Logger.new(nil)
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ... |
github | grimen/link2 | https://github.com/grimen/link2 | test/support/substitutions_helper.rb | Ruby | mit | 48 | master | 870 | # encoding: utf-8
require 'i18n'
module Link2
module SubstitutionsHelper
# Execute the block setting the given values and restoring old values after
# the block is executed.
def swap(object, new_values)
old_values = {}
new_values.each do |key, value|
old_values[key] = object.send key... |
github | grimen/link2 | https://github.com/grimen/link2 | test/support/debug_helper.rb | Ruby | mit | 48 | master | 307 | # encoding: utf-8
require 'i18n'
module Link2
module DebugHelper
def debug_routes
::ActionController::Routing::Routes.named_routes.each do |name, route|
puts "%20s: %s" % [name, route]
end
end
end
end
ActiveSupport::TestCase.class_eval do
include Link2::DebugHelper
end |
github | grimen/link2 | https://github.com/grimen/link2 | test/support/assertions_helper.rb | Ruby | mit | 48 | master | 533 | # encoding: utf-8
module Link2
module AssertionsHelper
def assert_not(assertion)
assert !assertion
end
def assert_blank(assertion)
assert assertion.blank?
end
def assert_not_blank(assertion)
assert !assertion.blank?
end
alias :assert_present :assert_not_blank
def ... |
github | cavvia/forgetsy | https://github.com/cavvia/forgetsy | forgetsy.gemspec | Ruby | mit | 48 | master | 895 | $:.unshift File.expand_path("../lib", __FILE__)
require 'forgetsy/version'
Gem::Specification.new do |gem|
gem.name = "forgetsy"
gem.homepage = "http://github.com/cavvia/forgetsy"
gem.license = "MIT"
gem.summary = %Q{A trending library built on redis.}
gem.version = Forgetsy::VERSION
gem.description = <<-... |
github | cavvia/forgetsy | https://github.com/cavvia/forgetsy | lib/forgetsy.rb | Ruby | mit | 48 | master | 1,263 | require 'active_support/core_ext'
require 'forgetsy/set'
require 'forgetsy/delta'
require 'redis/namespace'
module Forgetsy
extend self
# Accepts:
# 1. A 'hostname:port' string
# 2. A 'hostname:port:db' string (to select the Redis db)
# 3. A 'hostname:port/namespace' string (to set the Redis namespa... |
github | cavvia/forgetsy | https://github.com/cavvia/forgetsy | lib/forgetsy/delta.rb | Ruby | mit | 48 | master | 3,701 | require_relative './set'
module Forgetsy
# An abstraction used to extract trending scores
# from two Forgetsy::Set instances decaying at
# differing rates.
class Delta
attr_accessor :name, :conn
# the time multiplier to use for the
# normalising set.
NORM_T_MULT = 2
def initialize(name, op... |
github | cavvia/forgetsy | https://github.com/cavvia/forgetsy | lib/forgetsy/set.rb | Ruby | mit | 48 | master | 3,616 | module Forgetsy
# A data structure that decays counts exponentially
# over time. Decay is applied at read time.
class Set
attr_accessor :name, :conn
@@last_decayed_key = '_last_decay'
@@lifetime_key = '_t'
# scrub keys scoring lower than this.
@@hi_pass_filter = 0.0001
def initialize(na... |
github | cavvia/forgetsy | https://github.com/cavvia/forgetsy | spec/set_spec.rb | Ruby | mit | 48 | master | 3,201 | require 'spec_helper'
describe "Forgetsy::Set" do
before(:each) do
@redis = Forgetsy.redis
@set = Forgetsy::Set.create('foo', t: 1.week)
end
describe 'creation' do
it 'creates a redis set with the appropriate name and stores metadata' do
expect(@redis.zcount('foo', '-inf', '+inf')).to eq(2)
... |
github | cavvia/forgetsy | https://github.com/cavvia/forgetsy | spec/delta_spec.rb | Ruby | mit | 48 | master | 3,546 | require 'spec_helper'
describe "Forgetsy::Delta" do
before(:each) do
@redis = Forgetsy.redis
end
describe 'creation' do
it 'creates two set instances with appropriate keys' do
delta = Forgetsy::Delta.create('foo', t: 1.week)
expect(delta).to be_kind_of(Forgetsy::Delta)
set = delta.pri... |
github | cavvia/forgetsy | https://github.com/cavvia/forgetsy | spec/spec_helper.rb | Ruby | mit | 48 | master | 217 | require "active_support"
require File.expand_path("../../lib/forgetsy.rb", __FILE__)
RSpec.configure do |c|
c.before(:each) do
redis = Forgetsy.redis
redis.redis.flushdb # Avoid blind passthrough
end
end |
github | greensync/interval-tree | https://github.com/greensync/interval-tree | fast_interval_tree.gemspec | Ruby | mit | 48 | master | 1,387 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require_relative 'lib/interval_tree/version'
Gem::Specification.new do |s|
s.name = 'fast_interval_tree'
s.version = IntervalTree::VERSION
s.summary = 'A Ruby implementation of the C... |
github | greensync/interval-tree | https://github.com/greensync/interval-tree | lib/interval_tree.rb | Ruby | mit | 48 | master | 3,685 | #!/usr/bin/env ruby
module IntervalTree
class Tree
def initialize(ranges, &range_factory)
range_factory = lambda { |l, r| (l ... r+1) } unless block_given?
ranges_excl = ensure_exclusive_end([ranges].flatten, range_factory)
@top_node = divide_intervals(ranges_excl)
end
attr_reader :top... |
github | greensync/interval-tree | https://github.com/greensync/interval-tree | spec/interval_tree_spec.rb | Ruby | mit | 48 | master | 9,645 | require 'spec_helper'
describe "IntervalTree::Node" do
describe '.new' do
context 'given ([], [], [], [])' do
it 'returns a Node object' do
expect(IntervalTree::Node.new([], [], [], [])).to be_a(IntervalTree::Node)
end
end
end
describe '#search' do
subject(:result) { node.search(... |
github | ohler55/oj_mimic_json | https://github.com/ohler55/oj_mimic_json | oj_mimic_json.gemspec | Ruby | bsd-3-clause | 48 | master | 676 | Gem::Specification.new do |s|
s.name = "oj_mimic_json"
s.version = '1.0.1'
s.authors = "Peter Ohler"
s.date = Date.today.to_s
s.email = "peter@ohler.com"
s.homepage = "http://www.ohler.com/oj"
s.summary = "Simple gem to call Oj.mimic_JSON when using bundler or just want to limit code changes to just pulli... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | scrobbler.gemspec | Ruby | mit | 48 | master | 4,292 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{scrobbler}
s.version = "0.2.3"
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = ["John Nunemaker, Jonathan Rudenberg"]
s.date = %q{2009-04-13}
s.description = %q{wrapper... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | Rakefile | Ruby | mit | 48 | master | 1,016 | # Rakefile
require 'rubygems'
require 'rake'
require 'echoe'
require 'lib/scrobbler/version'
WEBSITE_PATH = 'jnunemaker@rubyforge.org:/var/www/gforge-projects/scrobbler'
Echoe.new('scrobbler', Scrobbler::Version) do |p|
p.description = "wrapper for audioscrobbler (last.fm) web services"
p.url = "h... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | test/test_helper.rb | Ruby | mit | 48 | master | 548 | require 'test/unit'
require File.dirname(__FILE__) + '/../lib/scrobbler'
require File.dirname(__FILE__) + '/mocks/rest'
class << Test::Unit::TestCase
def test(name, &block)
test_name = :"test_#{name.gsub(' ','_')}"
raise ArgumentError, "#{test_name} is already defined" if self.instance_methods.include? test_... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | test/mocks/rest.rb | Ruby | mit | 48 | master | 2,006 | require File.dirname(__FILE__) + '/../../lib/scrobbler/rest'
require 'digest/md5'
module Scrobbler
module REST
class Connection
# reads xml fixture file instead of hitting up the internets
def request(resource, method = "get", args = nil)
@now_playing_url = 'http://62.216.251.203:80/nowplaying'
... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | test/unit/chart_test.rb | Ruby | mit | 48 | master | 1,091 | require File.dirname(__FILE__) + '/../test_helper.rb'
class TestChart < Test::Unit::TestCase
def setup
@chart = Scrobbler::Chart.new('1108296002', '1108900802')
end
test 'should require from' do
assert_raise(ArgumentError) { Scrobbler::Chart.new('', '1108900802') }
end
test 'should require to'... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | test/unit/simpleauth_test.rb | Ruby | mit | 48 | master | 1,208 | require File.dirname(__FILE__) + '/../test_helper.rb'
class TestSimpleAuth < Test::Unit::TestCase
def setup
@auth = Scrobbler::SimpleAuth.new(:user => 'chunky', :password => 'bacon')
end
test 'should require a user' do
assert_raises(ArgumentError) { Scrobbler::SimpleAuth.new(:password => 'bacon') }... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | test/unit/scrobble_test.rb | Ruby | mit | 48 | master | 3,591 | require File.dirname(__FILE__) + '/../test_helper.rb'
class TestScrobble < Test::Unit::TestCase
def setup
@session_id = '17E61E13454CDD8B68E8D7DEEEDF6170'
@submission_url = 'http://62.216.251.205:80/protocol_1.2'
@artist = 'Coldplay'
@name = 'Viva La Vida'
@scrobble = Scrobbler::Scrobble.... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | test/unit/playing_test.rb | Ruby | mit | 48 | master | 2,390 | require File.dirname(__FILE__) + '/../test_helper.rb'
class TestPlaying < Test::Unit::TestCase
def setup
@session_id = '17E61E13454CDD8B68E8D7DEEEDF6170'
@now_playing_url = 'http://62.216.251.203:80/nowplaying'
@artist = 'Anberlin'
@track = 'A Day Late'
@album = 'Never Take Friendship Personal... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | test/unit/artist_test.rb | Ruby | mit | 48 | master | 3,524 | require File.dirname(__FILE__) + '/../test_helper.rb'
class TestArtist < Test::Unit::TestCase
def setup
@artist = Scrobbler::Artist.new('Metallica')
end
test 'should require name' do
assert_raises(ArgumentError) { Scrobbler::Artist.new('') }
end
test "should know it's name" do
assert_equal... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | test/unit/user_test.rb | Ruby | mit | 48 | master | 12,603 | require File.dirname(__FILE__) + '/../test_helper.rb'
class TestUser < Test::Unit::TestCase
def setup
@user = Scrobbler::User.new('jnunemaker')
end
test 'should be able to find one user' do
assert_equal(@user.username, Scrobbler::User.find('jnunemaker').username)
end
test 'should be able to fi... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | test/unit/track_test.rb | Ruby | mit | 48 | master | 1,399 | require File.dirname(__FILE__) + '/../test_helper.rb'
class TestTrack < Test::Unit::TestCase
def setup
@track = Scrobbler::Track.new('Carrie Underwood', 'Before He Cheats')
end
test 'should require the artist name' do
assert_raises(ArgumentError) { Scrobbler::Track.new('', 'Before He Cheats') }
end
... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | test/unit/tag_test.rb | Ruby | mit | 48 | master | 3,028 | require File.dirname(__FILE__) + '/../test_helper.rb'
class TestTag < Test::Unit::TestCase
def setup
@tag = Scrobbler::Tag.new('rock')
end
test 'should be able to find the top tags for the entire system' do
assert_equal(249, Scrobbler::Tag.top_tags.size)
assert_equal('rock', Scrobbler::Tag.top_tag... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | test/unit/album_test.rb | Ruby | mit | 48 | master | 3,548 | require File.dirname(__FILE__) + '/../test_helper.rb'
class TestAlbum < Test::Unit::TestCase
def setup
@album = Scrobbler::Album.new('Carrie Underwood', 'Some Hearts')
end
test 'should require the artist name' do
assert_raises(ArgumentError) { Scrobbler::Album.new('', 'Some Hearts') }
end
test... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | lib/scrobbler.rb | Ruby | mit | 48 | master | 436 | %w{cgi rubygems hpricot active_support}.each { |x| require x }
$: << File.expand_path(File.dirname(__FILE__))
require 'scrobbler/base'
require 'scrobbler/version'
require 'scrobbler/album'
require 'scrobbler/artist'
require 'scrobbler/chart'
require 'scrobbler/user'
require 'scrobbler/tag'
require 'scrobbler/track'... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | lib/scrobbler/playing.rb | Ruby | mit | 48 | master | 1,652 | module Scrobbler
class Playing
# you should read last.fm/api/submissions#np first!
attr_accessor :session_id, :now_playing_url, :artist, :track,
:album, :length, :track_number, :mb_track_id
attr_reader :status
def initialize(args = {})
@session_id = args[:session_id] # from S... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | lib/scrobbler/track.rb | Ruby | mit | 48 | master | 4,116 | # Below is an example of how to get the top fans for a track.
#
# track = Scrobbler::Track.new('Carrie Underwood', 'Before He Cheats')
# puts 'Fans'
# puts "=" * 4
# track.fans.each { |u| puts u.username }
#
# Which would output something like:
#
# track = Scrobbler::Track.new('Carrie Underwood', 'Before... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | lib/scrobbler/artist.rb | Ruby | mit | 48 | master | 4,360 | # Below are examples of how to find an artists top tracks and similar artists.
#
# artist = Scrobbler::Artist.new('Carrie Underwood')
#
# puts 'Top Tracks'
# puts "=" * 10
# artist.top_tracks.each { |t| puts "(#{t.reach}) #{t.name}" }
#
# puts
#
# puts 'Similar Artists'
# puts "=" * 15
# artist.simi... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | lib/scrobbler/rest.rb | Ruby | mit | 48 | master | 1,119 | require 'net/https'
module Scrobbler
module REST
class Connection
def initialize(base_url, args = {})
@base_url = base_url
@username = args[:username]
@password = args[:password]
end
def get(resource, args = nil)
request(resource, "get", args)
end
def post(resource, args ... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | lib/scrobbler/chart.rb | Ruby | mit | 48 | master | 543 | module Scrobbler
class Chart < Base
class << self
def new_from_xml(xml, doc)
Chart.new(xml['from'], xml['to'])
end
end
def initialize(from, to)
raise ArgumentError, "From is required" if from.blank?
raise ArgumentError, "To is required" if to.blank?
@from = from
... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | lib/scrobbler/simpleauth.rb | Ruby | mit | 48 | master | 1,836 | require 'digest/md5'
# exception definitions
class BadAuthError < StandardError; end
class BannedError < StandardError; end
class BadTimeError < StandardError; end
module Scrobbler
AUTH_URL = 'http://post.audioscrobbler.com'
AUTH_VER = '1.2.1'
class SimpleAuth
# you should read last.fm/api/submissions#han... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | lib/scrobbler/user.rb | Ruby | mit | 48 | master | 6,461 | # Probably the most common use of this lib would be to get your most recent tracks or your top tracks. Below are some code samples.
# user = Scrobbler::User.new('jnunemaker')
#
# puts "#{user.username}'s Recent Tracks"
# puts "=" * (user.username.length + 16)
# user.recent_tracks.each { |t| puts t.name }
#
# ... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | lib/scrobbler/base.rb | Ruby | mit | 48 | master | 967 | module Scrobbler
API_URL = 'http://ws.audioscrobbler.com/'
API_VERSION = '1.0'
class Base
class << self
def connection
@connection ||= REST::Connection.new(API_URL)
end
def fetch_and_parse(resource)
Hpricot::XML(connection.get(resource))
end
end
... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | lib/scrobbler/tag.rb | Ruby | mit | 48 | master | 3,261 | # Below is code samples for how to find the top albums and tracks for a tag.
#
# tag = Scrobbler::Tag.new('country')
#
# puts 'Top Albums'
# tag.top_albums.each { |a| puts "(#{a.count}) #{a.name} by #{a.artist}" }
#
# puts
#
# puts 'Top Tracks'
# tag.top_tracks.each { |t| puts "(#{t.count}) #{t.name} by... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | lib/scrobbler/album.rb | Ruby | mit | 48 | master | 6,032 | # Getting information about an album such as release date and the tracks on it is very easy.
#
# album = Scrobbler::Album.new('Carrie Underwood', 'Some Hearts', :include_info => true)
#
# puts "Album: #{album.name}"
# puts "Artist: #{album.artist}"
# puts "Reach: #{album.reach}"
# puts "URL: #{album.url}"
#... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | lib/scrobbler/scrobble.rb | Ruby | mit | 48 | master | 2,533 | # exception definitions
class BadSessionError < StandardError; end
class RequestFailedError < StandardError; end
module Scrobbler
class Scrobble
# you need to read last.fm/api/submissions#subs first!
attr_accessor :session_id, :submission_url, :artist, :track, :time,
:source, :length, :alb... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | examples/tag.rb | Ruby | mit | 48 | master | 312 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'scrobbler'))
tag = Scrobbler::Tag.new('country')
puts 'Top Albums'
tag.top_albums.each { |a| puts "(#{a.count}) #{a.name} by #{a.artist}" }
puts
puts 'Top Tracks'
tag.top_tracks.each { |t| puts "(#{t.count}) #{t.name} by #{t.artist}" } |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | examples/scrobble.rb | Ruby | mit | 48 | master | 1,449 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'scrobbler'))
auth = Scrobbler::SimpleAuth.new(:user => 'chunky', :password => 'bacon')
auth.handshake!
puts "Auth Status: #{auth.status}"
puts "Session ID: #{auth.session_id}"
puts "Now Playing URL: #{auth.now_playing_url}"
puts "Submission URL:... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | examples/track.rb | Ruby | mit | 48 | master | 339 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'scrobbler'))
require 'pp'
track = Scrobbler::Track.new('Carrie Underwood', 'Before He Cheats')
puts 'Fans'
puts "=" * 4
track.fans.each { |u| puts "(#{u.weight}) #{u.username}" }
track = Scrobbler::Track.new('U2 & Green Day', 'The Saints Are Com... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | examples/album.rb | Ruby | mit | 48 | master | 546 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'scrobbler'))
album = Scrobbler::Album.new('Carrie Underwood', 'Some Hearts', :include_info => true)
puts "Album: #{album.name}"
puts "Artist: #{album.artist}"
puts "Reach: #{album.reach}"
puts "URL: #{album.url}"
puts "Release Date: #{album.rele... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | examples/user.rb | Ruby | mit | 48 | master | 402 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'scrobbler'))
user = Scrobbler::User.new('jnunemaker')
puts "#{user.username}'s Recent Tracks"
puts "=" * (user.username.length + 16)
user.recent_tracks.each { |t| puts t.name }
puts
puts
puts "#{user.username}'s Top Tracks"
puts "=" * (user.us... |
github | jnunemaker/scrobbler | https://github.com/jnunemaker/scrobbler | examples/artist.rb | Ruby | mit | 48 | master | 334 | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'scrobbler'))
artist = Scrobbler::Artist.new('Carrie Underwood')
puts 'Top Tracks'
puts "=" * 10
artist.top_tracks.each { |t| puts "(#{t.reach}) #{t.name}" }
puts
puts 'Similar Artists'
puts "=" * 15
artist.similar.each { |a| puts "(#{a.match}%... |
github | terriblelabs/motion-juxtapose | https://github.com/terriblelabs/motion-juxtapose | motion-juxtapose.gemspec | Ruby | mit | 48 | master | 1,060 | # coding: utf-8
require File.expand_path('../lib/juxtapose/version', __FILE__)
Gem::Specification.new do |spec|
spec.name = "motion-juxtapose"
spec.version = Juxtapose::VERSION
spec.authors = ["Joe Lind", "Thomas Mayfield", "Jeffrey Chupp"]
spec.email = ["thomas@terriblelabs.com"]
... |
github | terriblelabs/motion-juxtapose | https://github.com/terriblelabs/motion-juxtapose | Rakefile | Ruby | mit | 48 | master | 401 | # -*- coding: utf-8 -*-
$:.unshift('/Library/RubyMotion/lib')
$:.unshift('~/.rubymotion/rubymotion-templates')
require 'motion/project/template/ios'
require "bundler/gem_tasks"
Bundler.setup
Bundler.require
require 'motion-juxtapose'
Motion::Project::App.setup do |app|
app.name = 'juxtapose-tests'
app.detect_depe... |
github | terriblelabs/motion-juxtapose | https://github.com/terriblelabs/motion-juxtapose | app/app_delegate.rb | Ruby | mit | 48 | master | 273 | class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@window.rootViewController = TestController.alloc.init
@window.makeKeyAndVisible
true
end
end |
github | terriblelabs/motion-juxtapose | https://github.com/terriblelabs/motion-juxtapose | app/controllers/test_controller.rb | Ruby | mit | 48 | master | 368 | class TestController < UIViewController
def viewDidLoad
super
self.view.backgroundColor = UIColor.whiteColor
@label = UILabel.alloc.initWithFrame(CGRectZero)
@label.text = "Juxtapose"
@label.sizeToFit
@label.center =
[self.view.frame.size.width / 2,
self.view.frame.size.height / ... |
github | terriblelabs/motion-juxtapose | https://github.com/terriblelabs/motion-juxtapose | spec/controllers/test_controller_spec.rb | Ruby | mit | 48 | master | 1,529 | describe 'screenshot testing under bacon' do
extend Juxtapose
tests TestController
it "raises an error when no accepted screenshot is present" do
error = nil
begin
it_should_look_like "no accepted screenshot"
rescue RuntimeError => e
error = e
end
error.should.not.be.nil
erro... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.