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
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090608180644_create_tags.rb
Ruby
mit
47
master
332
class CreateTags < ActiveRecord::Migration def self.up create_table :tag do |t| t.string :name, :null => false t.string :full_name, :null => true t.text :description, :null => true t.boolean :task_view, :default => false t.timestamps end end def self.down drop_table :ta...
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20091012101842_change_column_default_for_package_score.rb
Ruby
mit
47
master
210
class ChangeColumnDefaultForPackageScore < ActiveRecord::Migration def self.up change_column_default :package, :score, 0.0 end def self.down change_column_default :package, :score, nil end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090619112911_add_latest_version_to_packages.rb
Ruby
mit
47
master
401
class AddLatestVersionToPackages < ActiveRecord::Migration def self.up add_column :package, :latest_version_id, :integer add_index :package, :latest_version_id Package.all.each do |pkg| pkg.update_attribute(:latest_version_id, pkg.versions[0].id) end end def self.down remove_index :pack...
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090803134959_create_weekly_digests.rb
Ruby
mit
47
master
289
class CreateWeeklyDigests < ActiveRecord::Migration def self.up create_table :weekly_digest do |t| t.string :param, :null => false t.timestamps end add_index :weekly_digest, :param, :unique => true end def self.down drop_table :weekly_digest end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090618134932_create_timeline_events.rb
Ruby
mit
47
master
561
class CreateTimelineEvents < ActiveRecord::Migration def self.up create_table :timeline_event do |t| t.string :event_type, :subject_type, :actor_type, :secondary_subject_type t.integer :subject_id, :actor_id, :secondary_subject_id t.timestamps end add_index :time...
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090812104328_drop_package_trigram_table.rb
Ruby
mit
47
master
438
class DropPackageTrigramTable < ActiveRecord::Migration def self.up drop_table :package_trigram end def self.down create_table :package_trigram, :force => true do |t| t.integer :package_id, :null => false t.string :tg, :length => 3, :null => false # trigrams t.integer :score, :default =...
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/006_create_reviews.rb
Ruby
mit
47
master
297
class CreateReviews < ActiveRecord::Migration def self.up create_table :review do |t| t.integer :package_id t.integer :user_id t.integer :rating t.text :review t.string :title t.timestamps end end def self.down drop_table :review end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090710142540_add_perishable_token_to_users.rb
Ruby
mit
47
master
211
class AddPerishableTokenToUsers < ActiveRecord::Migration def self.up add_column :user, :perishable_token, :string, :limit => 40 end def self.down remove_column :user, :perishable_token end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090728135649_remove_double_timeline_events_for_package_releases.rb
Ruby
mit
47
master
627
class RemoveDoubleTimelineEventsForPackageReleases < ActiveRecord::Migration def self.up # We don't want to list both the new_version and new_package events for new # packages, so we delete these from the db. New records will be handled by # the Version observer. events = TimelineEvent.all events....
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090430133227_fix_column_types.rb
Ruby
mit
47
master
552
class FixColumnTypes < ActiveRecord::Migration def self.up change_column :version, :description, :text change_column :version, :license, :text change_column :version, :depends, :text change_column :version, :suggests, :text change_column :version, :author, :text end def self.down change_c...
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090715162506_create_author_identities.rb
Ruby
mit
47
master
465
class CreateAuthorIdentities < ActiveRecord::Migration def self.up create_table :author_identity do |t| t.integer :user_id, :null => false t.integer :author_id, :null => false t.timestamps end add_index :author_identity, :user_id add_index :author_identity, :author_id, :unique => t...
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090706213623_add_votes_to_packages.rb
Ruby
mit
47
master
347
class AddVotesToPackages < ActiveRecord::Migration def self.up # Counter cache add_column :package, :package_votes_count, :integer, :default => 0, :null => false add_index :package, :package_votes_count end def self.down remove_index :package, :package_votes_count remove_column :package, :pac...
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090624205124_add_enhances_and_priority_to_versions.rb
Ruby
mit
47
master
364
class AddEnhancesAndPriorityToVersions < ActiveRecord::Migration def self.up add_column :version, :enhances, :text add_column :version, :priority, :string change_column :version, :imports, :text end def self.down remove_column :version, :enhances remove_column :version, :priority change_c...
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/009_create_taggings.rb
Ruby
mit
47
master
252
class CreateTaggings < ActiveRecord::Migration def self.up create_table :tagging do |t| t.integer :user_id t.integer :package_id t.string :tag t.timestamps end end def self.down drop_table :tagging end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20110315153114_add_use_index_field_to_sitemap_settings.rb
Ruby
mit
47
master
214
class AddUseIndexFieldToSitemapSettings < ActiveRecord::Migration def self.up add_column :sitemap_setting, :use_index, :boolean end def self.down remove_column :sitemap_setting, :use_index end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/001_create_packages.rb
Ruby
mit
47
master
206
class CreatePackages < ActiveRecord::Migration def self.up create_table :package do |t| t.string :name t.text :description end end def self.down drop_table :package end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090615144055_remove_rating_from_reviews.rb
Ruby
mit
47
master
317
class RemoveRatingFromReviews < ActiveRecord::Migration def self.up # I don't try to convert the old ratings since there was some confusion # if it was 1 or 5 that was the top of the rating scale. remove_column :review, :rating end def self.down add_column :review, :rating, :integer end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/002_create_versions.rb
Ruby
mit
47
master
438
class CreateVersions < ActiveRecord::Migration def self.up create_table :version do |t| t.integer :package_id t.string :name, :title, :description, :license, :version t.string :requires, :depends, :suggests t.string :maintainer, :author t.string :url t.date :date t.text ...
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090608181701_add_tag_id_to_taggings.rb
Ruby
mit
47
master
296
class AddTagIdToTaggings < ActiveRecord::Migration def self.up add_column :tagging, :tag_id, :integer add_index :tagging, [:user_id, :package_id, :tag_id] end def self.down remove_column :tagging, :tag_id remove_index :tagging, [:user_id, :package_id, :tag_id] end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20100824203925_drop_author_version_join_table.rb
Ruby
mit
47
master
361
class DropAuthorVersionJoinTable < ActiveRecord::Migration def self.up drop_table :author_version end def self.down create_table :author_version, :id => false do |t| t.integer :author_id, :null => false t.integer :version_id, :null => false end add_index :author_version, [:author_id,...
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090623170341_add_remember_to_users.rb
Ruby
mit
47
master
210
class AddRememberToUsers < ActiveRecord::Migration def self.up add_column :user, :remember, :boolean, :default => false, :null => false end def self.down remove_column :user, :remember end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20091010162956_add_score_to_packages.rb
Ruby
mit
47
master
253
class AddScoreToPackages < ActiveRecord::Migration def self.up add_column :package, :score, :real add_index :package, :score Package.all.each { |pkg| pkg.update_score! } end def self.down remove_column :package, :score end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20091207195137_add_missing_index_to_package_ratings.rb
Ruby
mit
47
master
200
class AddMissingIndexToPackageRatings < ActiveRecord::Migration def self.up add_index :package_rating, :package_id end def self.down remove_index :package_rating, :package_id end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20091207194048_add_missing_indexes_to_versions.rb
Ruby
mit
47
master
263
class AddMissingIndexesToVersions < ActiveRecord::Migration def self.up add_index :version, :package_id add_index :version, :maintainer_id end def self.down remove_index :version, :package_id remove_index :version, :maintainer_id end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090612152958_fix_date_for_version_columns.rb
Ruby
mit
47
master
281
class FixDateForVersionColumns < ActiveRecord::Migration def self.up Version.all.each do |version| begin version.date = Date.parse(version.date.to_s) rescue version.date = nil end version.save! end end def self.down end end
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090730143711_rename_token_to_single_access_token.rb
Ruby
mit
47
master
361
class RenameTokenToSingleAccessToken < ActiveRecord::Migration def self.up rename_column :user, :token, :single_access_token change_column :user, :single_access_token, :string, :null => false, :default => "" end def self.down rename_column :user, :single_access_token, :token change_column :user, ...
github
hadley/crantastic
https://github.com/hadley/crantastic
db/migrate/20090626124627_tag_sti.rb
Ruby
mit
47
master
443
class TagSti < ActiveRecord::Migration # Refactor to STI for tags/task views def self.up add_column :tag, :type, :string, :limit => 25 Tag.all(:conditions => {:task_view => true}).each do |t| t.update_attribute(:type, "TaskView") end remove_column :tag, :task_view add_index :tag, :type ...
github
hadley/crantastic
https://github.com/hadley/crantastic
lib/core_extensions.rb
Ruby
mit
47
master
594
require 'iconv' class Object def not_nil?; !nil?; end def not_blank?; !blank?; end end class Hash # NOTE: Currently only works for keys that are strings. Should ideally work # for symbols as well. def downcase_keys inject({}) do |options, (key, value)| options[key.downcase] = value options ...
github
hadley/crantastic
https://github.com/hadley/crantastic
lib/rails_extensions.rb
Ruby
mit
47
master
591
class ActionController::Base # From http://raindroprecords.blogspot.com/2009/02/post-request-in-rails.html def redirect_post(redirect_post_params) controller_name = redirect_post_params[:controller] controller = "#{controller_name.camelize}Controller".constantize # Throw out existing params and merge t...
github
hadley/crantastic
https://github.com/hadley/crantastic
lib/cran.rb
Ruby
mit
47
master
1,539
require "rubygems" require "nokogiri" module CRAN # Simple struct for one CRAN package class CranPackage < Struct.new(:name, :version) def to_s "#{name} (#{version})" end def to_hash { :name => name, :version => version } end # Packages should be sorted alphabetically, ignoring c...
github
hadley/crantastic
https://github.com/hadley/crantastic
lib/rfc822.rb
Ruby
mit
47
master
1,084
# encoding: ASCII-8BIT # # RFC822 Email Address Regex # -------------------------- # # Originally written by Cal Henderson # c.f. http://iamcal.com/publish/articles/php/parsing_email/ # # Translated to Ruby by Tim Fletcher, with changes suggested by Dan Kubb. # # Licensed under a Creative Commons Attribution-ShareAlike...
github
hadley/crantastic
https://github.com/hadley/crantastic
lib/string-wrap.rb
Ruby
mit
47
master
862
# From http://snippets.dzone.com/posts/show/2589 class String def wrap(width, hanging_indent = 0, magic_lists = false) lines = self.split(/\n/) lines.collect! do |line| if magic_lists line =~ /^([\s\-\d\.\:]*\s)/ else line =~ /^([\s]*\s)/ end indent = $1.length + ...
github
hadley/crantastic
https://github.com/hadley/crantastic
lib/gfm.rb
Ruby
mit
47
master
767
require 'digest/md5' # Borrowed from http://github.github.com/github-flavored-markdown/ def gfm(text) # Extract pre blocks extractions = {} text.gsub!(%r{<pre>.*?</pre>}m) do |match| md5 = Digest::MD5.hexdigest(match) extractions[md5] = match "{gfm-extraction-#{md5}}" end # prevent foo_bar_baz f...
github
hadley/crantastic
https://github.com/hadley/crantastic
lib/crantastic.rb
Ruby
mit
47
master
10,122
require "fileutils" require "digest/md5" require "cran" require "dcf" require "oauth" module Crantastic class UpdatePackages def start Log.log!("Starting task: UpdatePackages") `curl -s http://cran.r-project.org/src/contrib/PACKAGES.gz -o tmp/PACKAGES.gz` `gunzip -f tmp/PACKAGES.gz` pac...
github
hadley/crantastic
https://github.com/hadley/crantastic
lib/authenticated_system.rb
Ruby
mit
47
master
3,658
# Originally taken from restful_authentication, but many changes/additions has # been made to make it suit our needs better. module AuthenticatedSystem protected # Returns true or false if the user is logged in. # Preloads @current_user with the user model if they're logged in. def logged_in? current_user....
github
hadley/crantastic
https://github.com/hadley/crantastic
lib/authenticated_test_helper.rb
Ruby
mit
47
master
325
module AuthenticatedTestHelper # Sets the current user in the session from the user fixtures. def login_as(user) @request.session[:user] = user ? user(user).id : nil end def authorize_as(user) @request.env["HTTP_AUTHORIZATION"] = user ? "Basic #{Base64.encode64("#{users(user).login}:test")}" : nil en...
github
hadley/crantastic
https://github.com/hadley/crantastic
lib/tasks/manifest.rake
Ruby
mit
47
master
310
namespace :heroku do desc "Populates the .gems manifest file, to be used with Heroku" task :gems => :environment do File.open(File.join(RAILS_ROOT, ".gems"), "w") do |f| Rails.configuration.gems.each do |dep| f.puts dep.send(:install_command)[1..-1].join(' ') end end end end
github
hadley/crantastic
https://github.com/hadley/crantastic
lib/tasks/crantastic.rake
Ruby
mit
47
master
1,444
namespace :crantastic do desc "Cron task, updates package versions and task views" task :cron => :environment do begin # Update packages every hour Crantastic::UpdatePackages.new.start # Update task views four times per day Crantastic::UpdateTaskViews.new.start if [0,6,12,18].include?(...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/blueprints.rb
Ruby
mit
47
master
1,448
require 'machinist/active_record' require "sham" Sham.name { (1..10).map { ('a'..'z').to_a.rand }.join } Sham.login { (1..10).map { ('a'..'z').to_a.rand }.join } Sham.full_name { Faker::Name.name } Sham.email { Faker::Internet.email } Sham.url { "http://" + Faker::Internet.domain_name } Sham.title { Faker::Lorem.sent...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/spec_helper.rb
Ruby
mit
47
master
2,249
# This file is copied to ~/spec when you run 'ruby script/generate rspec' # from the project root directory. ENV["RAILS_ENV"] ||= 'test' require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment')) require 'spec/autorun' require 'spec/rails' require 'remarkable_rails' require 'authlogic/test_...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/tags_controler_spec.rb
Ruby
mit
47
master
435
require File.dirname(__FILE__) + '/../spec_helper' include AuthHelper describe TagsController do def setup @tag = Tag.make end it "should render the index successfully" do get :index response.should be_success response.should render_template(:index) end it "should have a atom feed for tag...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/taggings_controller_spec.rb
Ruby
mit
47
master
1,252
require File.dirname(__FILE__) + '/../spec_helper' describe TaggingsController do setup do Tagging.make User.make(:login => "malicious") end it "should redirect to login when attempting to tag without logging in first" do get :new, :package_id => "aaMI" response.should be_redirect response....
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/ratings_controller_spec.rb
Ruby
mit
47
master
568
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') include AuthHelper describe RatingsController do it "should require login" do post :create, :package_id => "aaMI" response.should be_redirect end it "should create new ratings" do login_as_user(:id => 1, :login => "test") pac...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/static_controller_spec.rb
Ruby
mit
47
master
665
require File.dirname(__FILE__) + '/../spec_helper' describe StaticController do integrate_views it "should set correct title for the about page" do get :about assigns[:title].should == "About" end describe "XHTML Markup" do it "should be valid for the about page" do get :about respo...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/versions_controller_spec.rb
Ruby
mit
47
master
388
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe VersionsController do setup do Version.make(:package => Package.make(:name => "rJython")) end integrate_views it "should have an atom feed" do get :feed, :format => "atom" response.should have_tag('title', "New package...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/search_controller_spec.rb
Ruby
mit
47
master
228
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe SearchController do describe "GET 'show'" do it "should be successful" do get 'show' response.should be_success end end end
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/review_comments_controller_spec.rb
Ruby
mit
47
master
277
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe ReviewCommentsController do #Delete this example and add some real ones it "should use ReviewCommentsController" do controller.should be_an_instance_of(ReviewCommentsController) end end
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/votes_controller_spec.rb
Ruby
mit
47
master
793
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe VotesController do setup do User.make.activate end before(:each) do @user = User.first end it "should be redirected if the token for the create action is invalid" do post :create, :user_credentials => "invalid" r...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/timeline_events_controller_spec.rb
Ruby
mit
47
master
678
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe TimelineEventsController do setup do make_timeline_event_for_version end integrate_views it "should set the page title" do get :index response.should have_tag('title', "It's crantastic!") response.should be_success...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/authors_controller_spec.rb
Ruby
mit
47
master
1,148
require File.dirname(__FILE__) + '/../spec_helper' describe AuthorsController do def setup @version = Version.make @author = @version.maintainer end integrate_views it "should do a 404 for unknown ids" do get :show, :id => 9999 response.status.should == "404 Not Found" response.should re...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/packages_controller_spec.rb
Ruby
mit
47
master
2,815
require File.dirname(__FILE__) + '/../spec_helper' include AuthHelper describe PackagesController do setup do Version.make(:package => Package.make(:name => "rJython")) Version.make(:package => Package.make(:name => "data.table")) end integrate_views it "should render the index successfully" do ...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/users_controller_spec.rb
Ruby
mit
47
master
1,920
require File.dirname(__FILE__) + '/../spec_helper' include AuthHelper describe UsersController do integrate_views it "should render the index successfully" do get :index response.should render_template(:index) end it "should have a atom feed for user activity" do User.should_receive(:find).twic...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/sessions_controller_spec.rb
Ruby
mit
47
master
1,589
require File.dirname(__FILE__) + '/../spec_helper' describe SessionsController do describe "RPX Now integration" do it "should return status forbidden if accessing rpx_token without a token" do get "rpx_token" response.status.should == "403 Forbidden" end it "should create a user from RPXN...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/controllers/reviews_controller_spec.rb
Ruby
mit
47
master
2,427
require File.dirname(__FILE__) + '/../spec_helper' include AuthHelper describe ReviewsController do setup do Version.make Review.make(:package => Package.first) end it "should render the index successfully" do Review.should_receive(:recent) get :index response.should render_template(:index...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/views/authors/index.html.erb_spec.rb
Ruby
mit
47
master
358
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe "/authors" do before(:each) do end it "should display the number of package maintainers" do assigns[:authors] = [ Author.make, Author.make ] render 'authors/index' response.should have_tag('p', %r[There are 2 package m...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/views/search/show.html.erb_spec.rb
Ruby
mit
47
master
363
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe "/search/show" do before(:each) do end it "should let the user know if there were no search results" do assigns[:results] = [] render 'search/show' response.should have_tag('h1', %r[Search]) response.should have_tag...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/views/timeline_events/show.html.erb_spec.rb
Ruby
mit
47
master
295
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe "/timeline_events/index" do before(:each) do assigns[:events] = [] render 'timeline_events/index' end it "should have a title" do response.should have_tag('h1', %r[Recent activity]) end end
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/views/reviews/show.html.erb_spec.rb
Ruby
mit
47
master
502
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe "/reviews" do setup do activate_authlogic end before(:each) do @review = Review.make_unsaved(:cached_rating => 4) assigns[:review] = @review end it "should display a review with rating" do render "reviews/show...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/views/users/show.html.erb_spec.rb
Ruby
mit
47
master
1,939
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe "/users" do setup do activate_authlogic User.make end before(:each) do @user = User.first assigns[:user] = @user assigns[:events] = [] end it "should display a blank user profile" do render "users/show...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/views/packages/show.html.erb_spec.rb
Ruby
mit
47
master
1,400
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe "/packages" do setup do activate_authlogic mypkg = Package.make(:name => "mypkg") Package.make(:name => "optmatch") imports = "graphics, stats, lattice, grid, SparseM, xtable" imports.split(", ").each { |pkg| Packag...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/lib/cran_spec.rb
Ruby
mit
47
master
831
require File.join(File.dirname(__FILE__) + "/../../lib/cran.rb") describe CRAN::TaskView do before(:each) do @data = File.read(File.join(File.dirname(__FILE__) + "/data/Bayesian.ctv")) end it "should parse a ctv file" do tv = CRAN::TaskView.new(@data) tv.name.should == "Bayesian" tv.topic.shoul...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/version_observer_spec.rb
Ruby
mit
47
master
686
require File.dirname(__FILE__) + '/../spec_helper' describe VersionObserver do before(:each) do Version.delete_observers @obs = VersionObserver.instance end it "should create new timeline events" do pkg = Version.make.package v = Version.make(:package => pkg, :version => "2.0") TimelineEven...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/weekly_digest_spec.rb
Ruby
mit
47
master
1,016
# == Schema Information # # Table name: weekly_digest # # id :integer(4) not null, primary key # param :string(255) not null # created_at :datetime # updated_at :datetime # require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe WeeklyDigest do setup do wd = Week...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/tag_spec.rb
Ruby
mit
47
master
2,403
# == Schema Information # # Table name: tag # # id :integer(4) not null, primary key # name :string(255) not null # full_name :string(255) # description :text # created_at :datetime # updated_at :datetime # type :string(25) # version :string(10) # require File.expand_pat...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/package_rating_spec.rb
Ruby
mit
47
master
1,371
# == Schema Information # # Table name: package_rating # # id :integer(4) not null, primary key # package_id :integer(4) # user_id :integer(4) # rating :integer(4) # created_at :datetime # updated_at :datetime # aspect :string(25) default("overall"), not null # require File.expand_p...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/author_spec.rb
Ruby
mit
47
master
1,802
# == Schema Information # # Table name: author # # id :integer(4) not null, primary key # name :string(255) # email :string(255) # created_at :datetime # updated_at :datetime # require File.dirname(__FILE__) + '/../spec_helper' describe Author do should_allow_values_for :name, "John Do...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/version_spec.rb
Ruby
mit
47
master
4,576
# == Schema Information # # Table name: version # # id :integer(4) not null, primary key # package_id :integer(4) # name :string(255) # title :string(255) # description :text # license :text # version ...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/package_user_spec.rb
Ruby
mit
47
master
654
# == Schema Information # # Table name: package_user # # id :integer(4) not null, primary key # package_id :integer(4) # user_id :integer(4) # created_at :datetime # updated_at :datetime # active :boolean(1) default(TRUE), not null # require File.expand_path(File.dirname(__FILE__) + '/.....
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/log_spec.rb
Ruby
mit
47
master
401
# == Schema Information # # Table name: log # # id :integer(4) not null, primary key # message :string(255) not null # created_at :datetime # updated_at :datetime # require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Log do it "should trim the entry count" do Lo...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/user_spec.rb
Ruby
mit
47
master
4,069
# == Schema Information # # Table name: user # # id :integer(4) not null, primary key # login :string(255) # email :string(255) # crypted_password :string(255) # password_salt :string(255) # created_at :datetime # updated_at :datetime #...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/timeline_event_spec.rb
Ruby
mit
47
master
1,367
# == Schema Information # # Table name: timeline_event # # id :integer(4) not null, primary key # event_type :string(255) # subject_type :string(255) # actor_type :string(255) # secondary_subject_type :string(255) # subject_id :integer(4) # a...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/package_spec.rb
Ruby
mit
47
master
4,811
# == Schema Information # # Table name: package # # id :integer(4) not null, primary key # name :string(255) # description :text # created_at :datetime # latest_version_id :integer(4) # updated_at :datetime # package_users_count :integer(4) de...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/review_spec.rb
Ruby
mit
47
master
971
# == Schema Information # # Table name: review # # id :integer(4) not null, primary key # package_id :integer(4) # user_id :integer(4) # review :text # title :string(255) # created_at :datetime # updated_at :datetime # version_id :integer(4) # cached_rating :int...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/tagging_spec.rb
Ruby
mit
47
master
308
# == Schema Information # # Table name: tagging # # id :integer(4) not null, primary key # user_id :integer(4) # package_id :integer(4) # created_at :datetime # updated_at :datetime # tag_id :integer(4) # require File.dirname(__FILE__) + '/../spec_helper' describe Tagging do end
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/models/review_comment_spec.rb
Ruby
mit
47
master
435
# == Schema Information # # Table name: review_comment # # id :integer(4) not null, primary key # review_id :integer(4) not null # user_id :integer(4) not null # title :string(45) not null # comment :text default(""), not null # created_at :datetime # updated_at...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/helpers/packages_helper_spec.rb
Ruby
mit
47
master
503
require File.dirname(__FILE__) + '/../spec_helper' describe PackagesHelper do def setup @pkg = Package.new end describe "rating helper" do it "should return blank if no ratings" do @pkg.stub(:rating_count).and_return(0) helper.rating(@pkg).should == "" end it "should return the av...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/helpers/versions_helper_spec.rb
Ruby
mit
47
master
302
require File.dirname(__FILE__) + '/../spec_helper' describe VersionsHelper do it "should give a message for versions that dont use any packages" do assigns[:version] = Version.make_unsaved(:imports => "", :suggests => "") helper.version_uses.should == "Does not use any package" end end
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/helpers/application_helper_spec.rb
Ruby
mit
47
master
525
require File.dirname(__FILE__) + '/../spec_helper' describe ApplicationHelper do it "should have a clear div helper" do helper.clear_div.should == %{<div class="clear"></div>} end it "should have a title helper that figures out if the title is plural or not" do helper.title.should == "It's crantastic!"...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/support/machinist.rb
Ruby
mit
47
master
253
require File.expand_path(File.dirname(__FILE__) + "/../blueprints") Spec::Runner.configure { |config| config.before(:each) { Sham.reset } } class ActiveRecord::Base def self.make_unvalidated(*args) self.make_unsaved(*args).save(false) end end
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/support/webrat.rb
Ruby
mit
47
master
281
Webrat.configure do |config| config.mode = :rails end module WebratHelpers def login_with_valid_credentials(login = "john", password = "test") visit login_url fill_in "login", :with => login fill_in "password", :with => password click_button "login" end end
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/support/auth_helper.rb
Ruby
mit
47
master
682
# Borrowed from mislav's tip over at StackOverflow: # http://stackoverflow.com/questions/64827 module AuthHelper protected def login_as(model, id_or_attributes = {}) attributes = id_or_attributes.is_a?(Fixnum) ? {:id => id} : id_or_attributes attributes.update({:valid? => true}) @current_user = stub_mo...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/integration/package_user_feature_spec.rb
Ruby
mit
47
master
649
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "Package users" do include WebratHelpers include AuthHelper setup do Version.make User.make(:login => "john").activate end before(:each) do @user = User.first @user.package_users.destroy_all @pkg = Package.fi...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/integration/tags_feature_spec.rb
Ruby
mit
47
master
1,144
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "Tags" do include WebratHelpers setup do Version.make User.make(:login => "john").activate end before(:each) do visit package_url(Package.first) click_link "Add tags" end it "should add tags to a package" do ...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/integration/auth_feature_spec.rb
Ruby
mit
47
master
2,319
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "Authentication" do include WebratHelpers it "should sign up users with valid credentials" do visit signup_url UserMailer.should_receive(:deliver_activation_instructions) fill_in "User name", :with => "john" fill_in "E...
github
hadley/crantastic
https://github.com/hadley/crantastic
spec/integration/search_feature_spec.rb
Ruby
mit
47
master
433
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "Search" do before(:each) do end it "should show search results" do visit root_url fill_in "q", :with => "test" Package.should_receive(:find_by_solr).and_return(nil) click_button "Search" response.should have_ta...
github
madeindjs/active_storage-send_zip
https://github.com/madeindjs/active_storage-send_zip
active_storage-send_zip.gemspec
Ruby
mit
47
master
2,079
# frozen_string_literal: true lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'active_storage/send_zip/version' Gem::Specification.new do |spec| spec.name = 'active_storage-send_zip' spec.version = ActiveStorage::SendZip::VERSION spec.authors...
github
madeindjs/active_storage-send_zip
https://github.com/madeindjs/active_storage-send_zip
test/active_storage/send_zip_helper_test.rb
Ruby
mit
47
master
7,637
# frozen_string_literal: true require 'test_helper' require 'pathname' class ActiveStorageMock attr_reader :filename, :download, :key, :service def initialize(filename = 'foo.txt', content = 'content of file') @filename = filename @download = content @key = 'service key' @service = ActiveStorageS...
github
madeindjs/active_storage-send_zip
https://github.com/madeindjs/active_storage-send_zip
lib/active_storage/send_zip_helper.rb
Ruby
mit
47
master
4,882
# frozen_string_literal: true require 'rails' require 'zip' require 'tempfile' require 'pathname' module ActiveStorage # This module contains some methods usefull for `ActiveStorage::SendZip.send_zip` # method. module SendZipHelper # Download active storage files on server in a temporary folder # # ...
github
madeindjs/active_storage-send_zip
https://github.com/madeindjs/active_storage-send_zip
lib/active_storage/send_zip.rb
Ruby
mit
47
master
1,044
require 'active_storage/send_zip/version' require 'active_storage/send_zip_helper' # I `ActiveStorage` namespace to monkey-path my methods into it module ActiveStorage # This is an `ActiveSupport::Concern` to include into your controller. # The purpose is just to add a `send_zip` method to your controller module...
github
francois/jaccard
https://github.com/francois/jaccard
jaccard.gemspec
Ruby
mit
47
master
850
Gem::Specification.new do |gem| gem.name = "jaccard" gem.version = "1.1.1" gem.summary = %(A library to make calculating the Jaccard Coefficient Index a snap) gem.description = %(The Jaccard Coefficient Index is a measure of how similar two sets are. This library makes calculating the coefficient very easy, and...
github
francois/jaccard
https://github.com/francois/jaccard
Rakefile
Ruby
mit
47
master
350
require "rubygems" require "rake" task :spec do specs = FileList["spec/**/*_spec.rb"] sh "rspec --color -I lib #{specs.join(" ")}" end task default: :spec begin require "yard" YARD::Rake::YardocTask.new rescue LoadError task :yardoc do abort "YARD is not available. In order to run yardoc, you must: sud...
github
francois/jaccard
https://github.com/francois/jaccard
spec/jaccard_spec.rb
Ruby
mit
47
master
1,880
require File.expand_path(File.dirname(__FILE__) + "/spec_helper") describe Jaccard do attr_reader :a, :b, :c before do @a = ["likes:jeans", "likes:blue"] @b = ["likes:jeans", "likes:women", "likes:red"] @c = ["likes:women", "likes:red"] end describe "#coefficient" do it "calculates the coeffi...
github
francois/jaccard
https://github.com/francois/jaccard
spec/spec_helper.rb
Ruby
mit
47
master
215
$LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib")) require "bundler" Bundler.setup require "rspec/core" require "jaccard" RSpec.configure do |config| end
github
francois/jaccard
https://github.com/francois/jaccard
lib/jaccard.rb
Ruby
mit
47
master
4,070
# We must keep this due to Ruby 2.7 being supported # rubocop:disable Lint/RedundantRequireStatement require "set" # rubocop:enable Lint/RedundantRequireStatement # Helpers to calculate the Jaccard Coefficient Index and related metrics easily. # # (from Wikipedia): The Jaccard coefficient measures similarity between s...
github
Shopify/dukpt
https://github.com/Shopify/dukpt
dupkt.gemspec
Ruby
mit
47
master
884
# -*- encoding: utf-8 -*- require File.expand_path('../lib/dukpt/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["David Seal", "Cody Fauser"] gem.email = ["david.seal@shopify.com", "cody@shopify.com"] gem.description = %q{Implements a Derived Unique Key Per Transaction (DUKPT) ...
github
Shopify/dukpt
https://github.com/Shopify/dukpt
Rakefile
Ruby
mit
47
master
234
#!/usr/bin/env rake require "bundler/gem_tasks" require "rake/testtask" task :default => :test Rake::TestTask.new(:test) do |t| t.pattern = 'test/**/*_test.rb' t.ruby_opts << '-rubygems' t.libs << 'test' t.verbose = true end
github
Shopify/dukpt
https://github.com/Shopify/dukpt
lib/dukpt/encryption.rb
Ruby
mit
47
master
4,358
# frozen_string_literal: true require 'openssl' module DUKPT module Encryption REG3_MASK = 0x1FFFFF SHIFT_REG_MASK = 0x100000 REG8_MASK = 0xFFFFFFFFFFE00000 LS16_MASK = 0x0000000000000000FFFFFFFFFFFFFFFF MS16_MASK = 0xFFFFFFFFFFFFFFFF0000000000000000 KEY_MASK ...
github
Shopify/dukpt
https://github.com/Shopify/dukpt
lib/dukpt/decrypter.rb
Ruby
mit
47
master
1,306
# frozen_string_literal: true module DUKPT class Decrypter include Encryption attr_reader :bdk def initialize(bdk, mode=nil) @bdk = bdk self.cipher_mode = mode.nil? ? 'cbc' : mode end def decrypt(cryptogram, ksn) ipek = derive_IPEK(bdk, ksn) pek = derive_PEK(ipek, k...
github
Shopify/dukpt
https://github.com/Shopify/dukpt
test/encryption_test.rb
Ruby
mit
47
master
4,174
require 'test/unit' require 'bundler/setup' require 'dukpt' class DUKPT::EncryptionTest < Test::Unit::TestCase include DUKPT::Encryption def test_least_signinficant_16_nibbles_mask expected = 0x00009876543210E00008 actual = 0xFFFF9876543210E00008 & LS16_MASK assert_equal expected, actual end ...
github
Shopify/dukpt
https://github.com/Shopify/dukpt
test/decrypter_test.rb
Ruby
mit
47
master
1,685
require 'bundler/setup' require 'test/unit' require 'dukpt' class DUKPT::DecrypterTest < Test::Unit::TestCase def test_decrypt_track_data bdk = "0123456789ABCDEFFEDCBA9876543210" ksn = "FFFF9876543210E00008" ciphertext = "C25C1D1197D31CAA87285D59A892047426D9182EC11353C051ADD6D0F072A6CB3436560B3071FC...