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
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
app/controllers/comments_controller.rb
Ruby
mit
19
master
412
class CommentsController < ApplicationController def create Comment.create(comment_params) redirect_to item_path(comment_params[:item_id]) end def destroy @comment = Comment.find(params[:id]) item_id = @comment.item_id @comment.destroy! redirect_to item_path(item_id) end private de...
github
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
app/controllers/welcome_controller.rb
Ruby
mit
19
master
559
class WelcomeController < ApplicationController def index from_date = Date.new(Constants::YEAR, Constants::MONTH, 1).beginning_of_week(:sunday) to_date = Date.new(Constants::YEAR, Constants::MONTH, -1).end_of_week(:sunday) @calendar_data = split_week(from_date.upto(to_date)) @advent_calendar_items = A...
github
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
app/controllers/advent_calendar_items_controller.rb
Ruby
mit
19
master
813
class AdventCalendarItemsController < ApplicationController def new @advent_calendar_item = AdventCalendarItem.new(date: params[:date]) end def create advent_calendar_item = AdventCalendarItem.create(advent_calendar_item_params) redirect_to advent_calendar_item end def show @advent_calendar_...
github
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
app/uploaders/image_uploader.rb
Ruby
mit
19
master
1,602
# encoding: utf-8 class ImageUploader < CarrierWave::Uploader::Base # Include RMagick or MiniMagick support: # include CarrierWave::RMagick # include CarrierWave::MiniMagick # Choose what kind of storage to use for this uploader: storage :file # storage :fog # Override the directory where uploaded fil...
github
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
config/application.rb
Ruby
mit
19
master
1,274
require File.expand_path('../boot', __FILE__) require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Radvent class Application < Rails::Application # Settings in config/environments/* take prece...
github
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
config/routes.rb
Ruby
mit
19
master
1,753
Rails.application.routes.draw do resources :items do member do get 'preview' end end resources :advent_calendar_items resources :attachments resources :comments # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake r...
github
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
config/initializers/time_formats.rb
Ruby
mit
19
master
216
Time::DATE_FORMATS[:default] = '%Y/%m/%d %H:%M' Time::DATE_FORMATS[:datetime] = '%Y/%m/%d %H:%M' Time::DATE_FORMATS[:date] = '%Y/%m/%d' Time::DATE_FORMATS[:time] = '%H:%M:%S' Date::DATE_FORMATS[:default] = '%Y/%m/%d'
github
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
config/environments/production.rb
Ruby
mit
19
master
3,162
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web serve...
github
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
db/schema.rb
Ruby
mit
19
master
1,909
# encoding: UTF-8 # 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. # # Note that this schema.rb definition is the authoritative sou...
github
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
db/migrate/20141107144438_create_advent_calendar_items.rb
Ruby
mit
19
master
228
class CreateAdventCalendarItems < ActiveRecord::Migration def change create_table :advent_calendar_items do |t| t.string :user_name t.string :comment t.integer :date t.timestamps end end end
github
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
db/migrate/20161117133632_add_comments_count_to_items.rb
Ruby
mit
19
master
273
class AddCommentsCountToItems < ActiveRecord::Migration def up add_column :items, :comments_count, :integer, null: false, default: 0 Item.find_each { |i| Item.reset_counters(i.id, :comments) } end def down remove_column :items, :comments_count end end
github
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
db/migrate/20141108104223_create_items.rb
Ruby
mit
19
master
210
class CreateItems < ActiveRecord::Migration def change create_table :items do |t| t.string :title t.string :body t.integer :advent_calendar_item_id t.timestamps end end end
github
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
db/migrate/20141123144821_create_comments.rb
Ruby
mit
19
master
217
class CreateComments < ActiveRecord::Migration def change create_table :comments do |t| t.references :item, index: true t.string :user_name t.string :body t.timestamps end end end
github
nanonanomachine/radvent
https://github.com/nanonanomachine/radvent
db/migrate/20141125152431_create_attachments.rb
Ruby
mit
19
master
214
class CreateAttachments < ActiveRecord::Migration def change create_table :attachments do |t| t.references :advent_calendar_item, index: true t.string :image t.timestamps end end end
github
tog/tog_user
https://github.com/tog/tog_user
init.rb
Ruby
mit
19
master
985
require_plugin 'tog_core' require_plugin 'restful_authentication' Dir[File.dirname(__FILE__) + '/locale/**/*.yml'].each do |file| I18n.load_path << file end Tog::Plugins.settings :tog_user, :captcha_enabled => false, :email_as_login => false, ...
github
tog/tog_user
https://github.com/tog/tog_user
Rakefile
Ruby
mit
19
master
571
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the tog_user plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the tog_user plugin.' Rak...
github
tog/tog_user
https://github.com/tog/tog_user
config/desert_routes.rb
Ruby
mit
19
master
1,320
# Add your custom routes here. If in config/routes.rb you would # add <tt>map.resources</tt>, here you would add just <tt>resources</tt> # resources :tog_users resources :users resource :session login '/login', :controller => 'sessi...
github
tog/tog_user
https://github.com/tog/tog_user
shoulda_macros/login_macro.rb
Ruby
mit
19
master
230
module LoginMacros def logged_in_as(user, &block) context "logged in as #{user.login}" do setup do @request.session[:user_id] = user.id end context '' do yield end end end end
github
tog/tog_user
https://github.com/tog/tog_user
test/test_helper.rb
Ruby
mit
19
master
865
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment") require 'test_help' require 'test/unit' require 'mocha' begin gem 'thoughtbot-shoulda', '>=2.10.1' require 'shoulda' rescue Exception => e puts "\n\nYou need shoulda 2.10.1 or greater to test tog_core....
github
tog/tog_user
https://github.com/tog/tog_user
test/factories.rb
Ruby
mit
19
master
283
Factory.define :user do |u| u.salt '7e3041ebc2fc05a40c60028e2c4901a81035d3cd' u.crypted_password '00742970dc9e6319f8019fd54864d3ea740f04b1' u.activation_code '8f24789ae988411ccf33ab0c30fe9106fab32e9a' u.state 'pending' u.email {|a| "#{a.login}@example.com".downcase } end
github
tog/tog_user
https://github.com/tog/tog_user
test/unit/user_test.rb
Ruby
mit
19
master
4,933
require File.dirname(__FILE__) + '/../test_helper' class UserTest < ActiveSupport::TestCase context "A visitor" do context "that filling sign up form" do Tog::Config["plugins.tog_user.email_as_login"] = 'false' user = User.new( :login=> '2', :email=> 'email@mail.com', :pa...
github
tog/tog_user
https://github.com/tog/tog_user
test/functional/admin/users_controller_test.rb
Ruby
mit
19
master
2,752
require File.dirname(__FILE__) + '/../../test_helper' class Admin::UsersControllerTest < ActionController::TestCase context "An admin user" do setup do @berlusconi = Factory(:user, :login => 'berlusconi', :admin => true) @berlusconi.activate! @request.session[:user_id]= @berlusconi.id ...
github
tog/tog_user
https://github.com/tog/tog_user
lib/authenticated_system.rb
Ruby
mit
19
master
6,561
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 end # Accesses the current user from the session. # Future calls avoid the database because nil is not ...
github
tog/tog_user
https://github.com/tog/tog_user
db/migrate/001_create_user_table.rb
Ruby
mit
19
master
691
class CreateUserTable < ActiveRecord::Migration def self.up create_table "users", :force => true do |t| t.string :login t.string :email t.string :crypted_password, :limit => 40 t.string :salt, :limit => 40 t.string :activation_code, :limit => 40 t.string ...
github
tog/tog_user
https://github.com/tog/tog_user
app/helpers/admin/user_helper.rb
Ruby
mit
19
master
1,022
module Admin module UserHelper def select_state_tag(user) default_state = user.new_record? ? :passive : user.aasm_current_state events = user.aasm_events_for_current_state.collect do |x| [ I18n.t("tog_user.model.states.actions.#{x}"), x ] end options = events.insert(0, [ ...
github
tog/tog_user
https://github.com/tog/tog_user
app/models/user.rb
Ruby
mit
19
master
4,559
require 'digest/sha1' class User < ActiveRecord::Base include Authentication include Authentication::ByPassword include Authentication::ByCookieToken include Authorization::AasmRoles validates_presence_of :login, :unless => :email_as_login? validates_length_of :login, :within...
github
tog/tog_user
https://github.com/tog/tog_user
app/models/user_mailer.rb
Ruby
mit
19
master
958
class UserMailer < ActionMailer::Base def signup_notification(user) setup_email(user) @subject = (@subject || "") + I18n.t("tog_user.mailer.activate_account") @body[:url] = activate_url(user.activation_code) @body[:activation_code] = user.activation_code end def activat...
github
tog/tog_user
https://github.com/tog/tog_user
app/controllers/sessions_controller.rb
Ruby
mit
19
master
1,030
# This controller handles the login/logout function of the site. class SessionsController < ApplicationController def create self.current_user = User.authenticate(params[:login], params[:password]) if logged_in? if params[:remember_me] == "1" current_user.remember_me unless current_user.rem...
github
tog/tog_user
https://github.com/tog/tog_user
app/controllers/users_controller.rb
Ruby
mit
19
master
2,845
class UsersController < ApplicationController layout "sessions" def create # cookies.delete :auth_token # protects against session fixation attacks, wreaks havoc with # request forgery protection. # uncomment at your own risk # reset_session @user = User.new(params[:user]) @user.login ...
github
tog/tog_user
https://github.com/tog/tog_user
app/controllers/application_controller.rb
Ruby
mit
19
master
221
class ApplicationController < ActionController::Base include AuthenticatedSystem filter_parameter_logging :password, :password_confirmation def admin? return logged_in? && current_user.admin? end end
github
tog/tog_user
https://github.com/tog/tog_user
app/controllers/member/users_controller.rb
Ruby
mit
19
master
1,121
class Member::UsersController < Member::BaseController before_filter :find_user def change_password return unless request.post? if User.authenticate(current_user.login, params[:old_password]) if (params[:password] == params[:password_confirmation]) current_user.password_confirmation ...
github
tog/tog_user
https://github.com/tog/tog_user
app/controllers/admin/users_controller.rb
Ruby
mit
19
master
2,179
class Admin::UsersController < Admin::BaseController before_filter :find_user, :except => :index def index @order_by = params[:order_by] || "login" @sort_order = params[:sort_order] || "asc" @page = params[:page] || '1' condition = "" conditions_values = Hash.new if ...
github
indieweb/indieweb-endpoints-ruby
https://github.com/indieweb/indieweb-endpoints-ruby
indieweb-endpoints.gemspec
Ruby
mit
19
main
1,248
# frozen_string_literal: true Gem::Specification.new do |spec| spec.required_ruby_version = ">= 2.7" spec.name = "indieweb-endpoints" spec.version = "10.0.2" spec.authors = ["Jason Garber"] spec.email = ["jason@sixtwothree.org"] spec.summary = "Discover a URL’s IndieAuth, Micropub, Microsub, and Webmenti...
github
indieweb/indieweb-endpoints-ruby
https://github.com/indieweb/indieweb-endpoints-ruby
Gemfile
Ruby
mit
19
main
325
# frozen_string_literal: true source "https://rubygems.org" # Specify your gem's dependencies in indieweb-endpoints.gemspec gemspec gem "irb" gem "rake" gem "rspec" gem "rubocop" gem "rubocop-packaging" gem "rubocop-performance" gem "rubocop-rake" gem "rubocop-rspec" gem "simplecov" gem "simplecov-console" gem "webm...
github
indieweb/indieweb-endpoints-ruby
https://github.com/indieweb/indieweb-endpoints-ruby
lib/indieweb/endpoints.rb
Ruby
mit
19
main
627
# frozen_string_literal: true require "http" require "link-header-parser" require "nokogiri/html-ext" require_relative "endpoints/exceptions" require_relative "endpoints/client" require_relative "endpoints/parser" module IndieWeb module Endpoints # Discover a URL's IndieAuth, Micropub, Microsub, and Webmentio...
github
indieweb/indieweb-endpoints-ruby
https://github.com/indieweb/indieweb-endpoints-ruby
lib/indieweb/endpoints/parser.rb
Ruby
mit
19
main
2,601
# frozen_string_literal: true module IndieWeb module Endpoints # @api private class Parser # @param response [HTTP::Response] def initialize(response) @response = response end # @param identifier [String] # @param node_names [Array<String>] # # @return [Arra...
github
indieweb/indieweb-endpoints-ruby
https://github.com/indieweb/indieweb-endpoints-ruby
lib/indieweb/endpoints/exceptions.rb
Ruby
mit
19
main
220
# frozen_string_literal: true module IndieWeb module Endpoints class Error < StandardError; end class HttpError < Error; end class InvalidURIError < Error; end class SSLError < Error; end end end
github
indieweb/indieweb-endpoints-ruby
https://github.com/indieweb/indieweb-endpoints-ruby
lib/indieweb/endpoints/client.rb
Ruby
mit
19
main
1,711
# frozen_string_literal: true module IndieWeb module Endpoints class Client # Create a new client with a URL to parse for IndieWeb endpoints. # # @example # client = IndieWeb::Endpoints::Client.new("https://aaronparecki.com") # # @param url [String, HTTP::URI, #to_s] an abso...
github
indieweb/indieweb-endpoints-ruby
https://github.com/indieweb/indieweb-endpoints-ruby
spec/spec_helper.rb
Ruby
mit
19
main
4,950
# frozen_string_literal: true # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause # this file to always be loaded, without a need to expl...
github
indieweb/indieweb-endpoints-ruby
https://github.com/indieweb/indieweb-endpoints-ruby
spec/support/webmention_rocks.rb
Ruby
mit
19
main
2,243
# frozen_string_literal: true module WebmentionRocks ENDPOINT_DISCOVERY_TESTS = [ ["https://webmention.rocks/test/1", %r{^https://webmention.rocks/test/1/webmention$}], ["https://webmention.rocks/test/2", %r{^https://webmention.rocks/test/2/webmention$}], ["https://webmention.rocks/test/3", %r{^https://w...
github
indieweb/indieweb-endpoints-ruby
https://github.com/indieweb/indieweb-endpoints-ruby
spec/support/fixture_helpers.rb
Ruby
mit
19
main
239
# frozen_string_literal: true module FixtureHelpers def read_fixture(url) file_name = "#{url.gsub(%r{^https?://}, "").gsub(%r{[/.]}, "_")}.html" File.read(File.join(Dir.pwd, "spec", "support", "fixtures", file_name)) end end
github
indieweb/indieweb-endpoints-ruby
https://github.com/indieweb/indieweb-endpoints-ruby
spec/lib/indieweb/endpoints_get_spec.rb
Ruby
mit
19
main
14,233
# frozen_string_literal: true RSpec.shared_examples "a Hash of endpoints" do subject { described_class.get(url) } before do stub_request(:get, url).to_return(response) end it { is_expected.to eq(endpoints) } end RSpec.describe IndieWeb::Endpoints, ".get" do context "when given a URL that publishes no ...
github
indieweb/indieweb-endpoints-ruby
https://github.com/indieweb/indieweb-endpoints-ruby
spec/lib/indieweb/endpoints/client_spec.rb
Ruby
mit
19
main
348
# frozen_string_literal: true RSpec.describe IndieWeb::Endpoints::Client do subject(:client) { described_class.new(url) } context "when given invalid arguments" do let(:url) { "1:" } it "raises an IndieWeb::Endpoints::InvalidURIError" do expect { client }.to raise_error(IndieWeb::Endpoints::Invalid...
github
indieweb/indieweb-endpoints-ruby
https://github.com/indieweb/indieweb-endpoints-ruby
spec/lib/indieweb/endpoints/client_response_spec.rb
Ruby
mit
19
main
698
# frozen_string_literal: true RSpec.describe IndieWeb::Endpoints::Client, "#response" do subject(:response) { described_class.new(url).response } let(:url) { "https://example.com" } context "when rescuing from an HTTP::Error" do it "raises an IndieWeb::Endpoints::HttpError" do stub_request(:get, url)...
github
indieweb/indieweb-endpoints-ruby
https://github.com/indieweb/indieweb-endpoints-ruby
spec/lib/indieweb/endpoints/client_endpoints_spec.rb
Ruby
mit
19
main
476
# frozen_string_literal: true RSpec.describe IndieWeb::Endpoints::Client, "#endpoints" do # TODO: Rework these specs to use WebMock: https://github.com/bblimke/webmock context "when running the webmention.rocks Endpoint Discovery tests" do WebmentionRocks::ENDPOINT_DISCOVERY_TESTS.each do |url, regexp| d...
github
zapnap/bitbank
https://github.com/zapnap/bitbank
Rakefile
Ruby
mit
19
master
1,115
# encoding: utf-8 require 'rubygems' require 'bundler' begin Bundler.setup(:default, :development) rescue Bundler::BundlerError => e $stderr.puts e.message $stderr.puts "Run `bundle install` to install missing gems" exit e.status_code end require 'rake' require 'jeweler' Jeweler::Tasks.new do |gem| # gem is...
github
zapnap/bitbank
https://github.com/zapnap/bitbank
Gemfile
Ruby
mit
19
master
611
source 'http://rubygems.org' # Add dependencies required to use your gem here. # Example: # gem 'activesupport', '>= 2.3.5' gem 'rest-client', '>= 1.6.3' gem 'activesupport', '>= 3.0.7' gem 'i18n', '>= 0.5.0' # Add dependencies to develop your gem here. # Include everything needed to run rake, tests, features, etc....
github
zapnap/bitbank
https://github.com/zapnap/bitbank
bitbank.gemspec
Ruby
mit
19
master
5,204
# 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 = %q{bitbank} s.version = "0.1.2" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubyge...
github
zapnap/bitbank
https://github.com/zapnap/bitbank
lib/bitbank.rb
Ruby
mit
19
master
985
require 'yaml' require 'json' require 'rest_client' require 'active_support/core_ext' Dir[File.join(File.dirname(__FILE__), 'bitbank', '*.rb')].each { |f| require f } module Bitbank @@defaults = { :host => 'localhost', :port => 8332 } def self.new(options={}) self.config = options Client.new(c...
github
zapnap/bitbank
https://github.com/zapnap/bitbank
lib/bitbank/transaction.rb
Ruby
mit
19
master
980
module Bitbank class Transaction attr_reader :txid, :address, :category, :amount, :confirmations def initialize(client, txid, data={}) @client = client @txid = txid load_details(data) end def account @account ? Account.new(@client, @account) : nil end def time ...
github
zapnap/bitbank
https://github.com/zapnap/bitbank
lib/bitbank/account.rb
Ruby
mit
19
master
1,961
module Bitbank class Account attr_reader :name def initialize(client, name, balance=nil, check=false) @client = client @name = name @balance = balance # currently unused # validate the address if a check is requested # (bitcoind creates it if it didn't previous exist) add...
github
zapnap/bitbank
https://github.com/zapnap/bitbank
lib/bitbank/client.rb
Ruby
mit
19
master
3,530
module Bitbank class Client def initialize(config={}) @config = config @endpoint = "http://#{config[:username]}:#{config[:password]}" + "@#{config[:host]}:#{config[:port]}" end # Retrieve a particular named account. def account(account_name) Bitbank::Account.new(se...
github
zapnap/bitbank
https://github.com/zapnap/bitbank
spec/client_spec.rb
Ruby
mit
19
master
6,838
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Bitbank::Client" do before(:each) do @client = Bitbank.new(File.join(File.dirname(__FILE__), '..', 'config.yml')) end describe 'request' do before(:each) do @json = '{"result":{"foo":"bar"}}' end it 'should post t...
github
zapnap/bitbank
https://github.com/zapnap/bitbank
spec/spec_helper.rb
Ruby
mit
19
master
601
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rspec' require 'mocha' require 'vcr' require 'bitbank' # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir["#{File.dirname(__FILE__)}/support...
github
zapnap/bitbank
https://github.com/zapnap/bitbank
spec/transaction_spec.rb
Ruby
mit
19
master
2,182
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Bitbank::Transaction" do before(:each) do @client = Bitbank.new(File.join(File.dirname(__FILE__), '..', 'config.yml')) @transaction = Bitbank::Transaction.new(@client, 'txid1', :account => ...
github
zapnap/bitbank
https://github.com/zapnap/bitbank
spec/account_spec.rb
Ruby
mit
19
master
3,398
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Bitbank::Account" do before(:each) do @client = Bitbank.new(File.join(File.dirname(__FILE__), '..', 'config.yml')) @account = Bitbank::Account.new(@client, 'adent') end it 'should have a name' do @account.name.should == 'ade...
github
zapnap/bitbank
https://github.com/zapnap/bitbank
spec/bitbank_spec.rb
Ruby
mit
19
master
1,209
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Bitbank" do describe 'initialization' do it 'should configure the client' do client = Bitbank.new(:username => 'prefect', :password => 'hoopy') client.is_a?(Bitbank::Client).should be_true end end describe 'configura...
github
zapnap/bitbank
https://github.com/zapnap/bitbank
spec/support/focused.rb
Ruby
mit
19
master
315
RSpec.configure do |config| # Configure RSpec to run focused specs, and also respect the alias 'fit' for focused specs config.filter_run :focused => true config.alias_example_to :fit, :focused => true config.alias_example_to :pit, :pending => true config.run_all_when_everything_filtered = true end
github
joelhawksley/rails-history
https://github.com/joelhawksley/rails-history
script.rb
Ruby
mit
19
main
5,528
require 'csv' require 'date' require 'json' require 'pstore' class RailsHistory attr_reader :path def initialize(path) @path = path end def run cache = PStore.new("cache.pstore") stats = [] start = Time.now current_date = nil output_filename = "output-#{Time.now.to_i}" # https://...
github
jmmastey/rspec-activerecord-formatter
https://github.com/jmmastey/rspec-activerecord-formatter
rspec-activerecord-formatter.gemspec
Ruby
mit
19
master
1,089
# encoding: utf-8 lib_dir = File.join(File.dirname(__FILE__),'lib') $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir) Gem::Specification.new do |gem| gem.name = "rspec-activerecord-formatter" gem.version = "2.2.1" gem.summary = "Adds object creations and queries to Rspec output." gem.descript...
github
jmmastey/rspec-activerecord-formatter
https://github.com/jmmastey/rspec-activerecord-formatter
spec/spec_helper.rb
Ruby
mit
19
master
2,551
require 'simplecov' require 'rspec/activerecord/formatter' # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause # this file to always be ...
github
jmmastey/rspec-activerecord-formatter
https://github.com/jmmastey/rspec-activerecord-formatter
lib/rspec-activerecord-formatter.rb
Ruby
mit
19
master
265
require "rspec/activerecord/helpers/collector" require "rspec/activerecord/helpers/report" require 'rspec/activerecord/base' require 'rspec/activerecord/progress_formatter' require 'rspec/activerecord/documentation_formatter' require 'rspec/activerecord/formatter'
github
jmmastey/rspec-activerecord-formatter
https://github.com/jmmastey/rspec-activerecord-formatter
lib/rspec/activerecord/documentation_formatter.rb
Ruby
mit
19
master
1,710
class ActiveRecordDocumentationFormatter < ::RSpec::Core::Formatters::DocumentationFormatter attr_reader :collector, :colorizer, :report ::RSpec::Core::Formatters.register self, :start, :dump_summary, :example_started, :example_group_started, ...
github
jmmastey/rspec-activerecord-formatter
https://github.com/jmmastey/rspec-activerecord-formatter
lib/rspec/activerecord/progress_formatter.rb
Ruby
mit
19
master
1,306
require_relative "helpers/collector" require_relative "helpers/report" class ActiveRecordProgressFormatter < ::RSpec::Core::Formatters::ProgressFormatter attr_reader :collector, :colorizer, :report ::RSpec::Core::Formatters.register self, :start, :dump_summary, :example_...
github
jmmastey/rspec-activerecord-formatter
https://github.com/jmmastey/rspec-activerecord-formatter
lib/rspec/activerecord/base.rb
Ruby
mit
19
master
1,412
class ActiveRecordFormatterBase attr_reader :colorizer, :summary, :collector def initialize(summary, collector) @colorizer = ::RSpec::Core::Formatters::ConsoleCodes @summary = summary @collector = collector end def colorized_summary formatted = "\nFinished in #{summary.formatted_duration}...
github
jmmastey/rspec-activerecord-formatter
https://github.com/jmmastey/rspec-activerecord-formatter
lib/rspec/activerecord/helpers/collector.rb
Ruby
mit
19
master
5,016
require 'active_support/notifications' module ActiveRecordFormatterHelpers class Collector attr_reader :query_count, :objects_count, :total_queries, :total_objects, :query_names, :active_groups, :group_counts, :groups_encountered SKIP_QUERIES = ["SELECT tablename FROM pg_tables", "select sum...
github
jmmastey/rspec-activerecord-formatter
https://github.com/jmmastey/rspec-activerecord-formatter
lib/rspec/activerecord/helpers/report.rb
Ruby
mit
19
master
1,289
module ActiveRecordFormatterHelpers class Report attr_reader :report_path, :default_path, :report_dir, :collector def initialize(collector) @collector = collector @report_dir = Rails.root.join("tmp", "profile") @report_path = report_dir.join(timestamped_filename) @default_path = r...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
cton.gemspec
Ruby
mit
19
master
1,623
# frozen_string_literal: true require_relative "lib/cton/version" Gem::Specification.new do |spec| spec.name = "cton" spec.version = Cton::VERSION spec.authors = ["Davide Santangelo"] spec.email = ["davide.santangelo@gmail.com"] spec.summary = "Compact Token-Oriented Notation encoder/decoder." spec.descr...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
bench/encode_decode_bench.rb
Ruby
mit
19
master
1,663
#!/usr/bin/env ruby # frozen_string_literal: true require "benchmark" require "json" require_relative "../lib/cton" ITERATIONS = Integer(ENV.fetch("ITERATIONS", 1_000)) STREAM_SIZE = Integer(ENV.fetch("STREAM_SIZE", 200)) sample_payload = { "context" => { "task" => "Our favorite hikes together", "location"...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
spec/cton_spec.rb
Ruby
mit
19
master
31,671
# frozen_string_literal: true require "bigdecimal" RSpec.describe Cton do let(:sample_data) do { "context" => { "task" => "Our favorite hikes together", "location" => "Boulder", "season" => "spring_2025" }, "friends" => %w[ana luis sam], "hikes" => [ { "id...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
spec/cli_spec.rb
Ruby
mit
19
master
1,614
# frozen_string_literal: true require "open3" require "json" RSpec.describe "cton CLI" do let(:repo_root) { File.expand_path("..", __dir__) } let(:bin_path) { File.expand_path("../../bin/cton", __dir__) } let(:schema_path) { File.expand_path("schema_helper.rb", __dir__) } let(:base_env) do { "BUNDLE...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
spec/schema_spec.rb
Ruby
mit
19
master
1,535
# frozen_string_literal: true RSpec.describe Cton::Schema do let(:schema) do Cton.schema do object do key "user" do object do key "id", integer key "name", string optional "role", enum("admin", "viewer") end end key "tags", arr...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
spec/decoder_stream_spec.rb
Ruby
mit
19
master
489
# frozen_string_literal: true require "stringio" RSpec.describe Cton::Decoder do it "provides a scan_stream helper" do io = StringIO.new("alpha=1\nbeta=2\n") values = described_class.scan_stream(io).to_a expect(values).to eq([{ "alpha" => 1 }, { "beta" => 2 }]) end it "supports custom separators" ...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
spec/binary_spec.rb
Ruby
mit
19
master
451
# frozen_string_literal: true RSpec.describe Cton::Binary do it "round-trips binary payloads" do data = { "user" => { "id" => 1, "name" => "Ada" }, "tags" => %w[a b] } binary = Cton.dump_binary(data) expect(Cton.load_binary(binary)).to eq(data) end it "supports uncompressed payloads" do data = ...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
spec/spec_helper.rb
Ruby
mit
19
master
367
# frozen_string_literal: true require "cton" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = ".rspec_status" # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching! config.expect_with ...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
spec/stream_spec.rb
Ruby
mit
19
master
953
# frozen_string_literal: true require "stringio" RSpec.describe "CTON streaming" do it "streams newline-delimited documents" do io = StringIO.new("a=1\nuser(name=Ana)\n") values = Cton.load_stream(io).to_a expect(values).to eq([ { "a" => 1 }, { "use...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
spec/support/cton_runner.rb
Ruby
mit
19
master
1,030
# frozen_string_literal: true $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__)) require "cton" require "json" schema_path = ENV.fetch("CTON_SCHEMA_PATH", nil) if schema_path require schema_path schema = if Object.const_defined?(:CTON_SCHEMA) Object.const_get(:CTON_SCHEMA) elsif Ob...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
lib/cton.rb
Ruby
mit
19
master
5,053
# frozen_string_literal: true require "bigdecimal" require_relative "cton/version" require_relative "cton/encoder" require_relative "cton/decoder" require_relative "cton/validator" require_relative "cton/stats" require_relative "cton/type_registry" require_relative "cton/schema" require_relative "cton/binary" require_...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
lib/cton/binary.rb
Ruby
mit
19
master
1,742
# frozen_string_literal: true require "zlib" module Cton module Binary MAGIC = "CTON".b VERSION = 1 FLAG_COMPRESSED = 1 module_function def dump(data, compress: true, **options) payload = Cton.dump(data, **options).b flags = 0 if compress payload = Zlib.deflate(paylo...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
lib/cton/stream.rb
Ruby
mit
19
master
991
# frozen_string_literal: true module Cton class StreamReader include Enumerable def initialize(io, separator: "\n", symbolize_names: false) @io = io @separator = separator @symbolize_names = symbolize_names end def each buffer = String.new @io.each_line(@separator) do ...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
lib/cton/encoder.rb
Ruby
mit
19
master
9,342
# frozen_string_literal: true require "stringio" require "time" require "date" module Cton class Encoder SAFE_TOKEN = /\A[0-9A-Za-z_.:-]+\z/ NUMERIC_TOKEN = /\A-?(?:\d+)(?:\.\d+)?(?:[eE][+-]?\d+)?\z/ RESERVED_LITERALS = %w[true false null].freeze FLOAT_DECIMAL_PRECISION = Float::DIG def initial...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
lib/cton/schema.rb
Ruby
mit
19
master
8,551
# frozen_string_literal: true module Cton module Schema PATH_ROOT = "root" class Error attr_reader :path, :message, :expected, :actual def initialize(path:, message:, expected: nil, actual: nil) @path = path @message = message @expected = expected @actual = actua...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
lib/cton/validator.rb
Ruby
mit
19
master
9,181
# frozen_string_literal: true module Cton # Result object for validation operations class ValidationResult attr_reader :errors def initialize(errors = []) @errors = errors.freeze end def valid? errors.empty? end def to_s return "Valid CTON" if valid? messages = e...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
lib/cton/type_registry.rb
Ruby
mit
19
master
3,666
# frozen_string_literal: true module Cton # Registry for custom type serializers # Allows users to define how custom classes should be encoded to CTON class TypeRegistry # Handler wraps a serialization block with metadata Handler = Struct.new(:klass, :mode, :block, keyword_init: true) def initialize...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
lib/cton/stats.rb
Ruby
mit
19
master
2,855
# frozen_string_literal: true require "json" module Cton # Token statistics for comparing JSON vs CTON efficiency class Stats # Rough estimate: GPT models average ~4 characters per token CHARS_PER_TOKEN = 4 attr_reader :data, :json_string, :cton_string def initialize(data, cton_string: nil, json...
github
davidesantangelo/cton
https://github.com/davidesantangelo/cton
lib/cton/decoder.rb
Ruby
mit
19
master
9,538
# frozen_string_literal: true require "strscan" module Cton class Decoder TERMINATORS = [",", ";", ")", "]", "}"].freeze KEY_VALUE_BOUNDARY_TOKENS = ["(", "[", "="].freeze SAFE_KEY_PATTERN = /[0-9A-Za-z_.:-]+/ SAFE_KEY_CHAR_PATTERN = /[0-9A-Za-z_.:-]/ SAFE_KEY_START_PATTERN = /[A-Za-z_.:-]/ ...
github
philnash/jekyll-brotli
https://github.com/philnash/jekyll-brotli
Gemfile
Ruby
mit
19
main
250
source "https://rubygems.org" git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } # Specify your gem's dependencies in jekyll-brotli.gemspec gemspec jekyll_version = ENV["JEKYLL_VERSION"] || "~> 4.0" gem "jekyll", jekyll_version
github
philnash/jekyll-brotli
https://github.com/philnash/jekyll-brotli
jekyll-brotli.gemspec
Ruby
mit
19
main
1,218
lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "jekyll/brotli/version" Gem::Specification.new do |spec| spec.name = "jekyll-brotli" spec.version = Jekyll::Brotli::VERSION spec.authors = ["Phil Nash"] spec.email = ["philnas...
github
philnash/jekyll-brotli
https://github.com/philnash/jekyll-brotli
spec/spec_helper.rb
Ruby
mit
19
main
1,152
require "yaml" require "bundler/setup" require "jekyll" require "simplecov" SimpleCov.start do add_filter "spec" end Jekyll.logger.log_level = :error RSpec.configure do |config| # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = ".rspec_status" # Disable RSp...
github
philnash/jekyll-brotli
https://github.com/philnash/jekyll-brotli
spec/jekyll/brotli/compressor_spec.rb
Ruby
mit
19
main
5,839
require "zlib" require "./lib/jekyll/brotli/compressor" RSpec.describe Jekyll::Brotli::Compressor do let(:site) { make_site } before(:each) { site.process } after(:each) { FileUtils.rm_r(dest_dir) } describe "given a file name" do it "creates a brotli file" do file_name = dest_dir("index.html") ...
github
philnash/jekyll-brotli
https://github.com/philnash/jekyll-brotli
lib/jekyll/brotli.rb
Ruby
mit
19
main
853
# frozen_string_literal: true require 'jekyll/brotli/version' require 'jekyll/brotli/config' require 'jekyll/brotli/compressor' require 'pathname' module Jekyll module Brotli end end Jekyll::Hooks.register :site, :post_write do |site| Jekyll::Brotli::Compressor.compress_site(site) if Jekyll.env == 'production'...
github
philnash/jekyll-brotli
https://github.com/philnash/jekyll-brotli
lib/jekyll/brotli/config.rb
Ruby
mit
19
main
346
# frozen_string_literal: true module Jekyll module Brotli DEFAULT_CONFIG = { 'quality' => 11, 'extensions' => [ '.html', '.css', '.js', '.json', '.txt', '.ttf', '.atom', '.stl', '.xml', '.svg', '.eot' ].free...
github
philnash/jekyll-brotli
https://github.com/philnash/jekyll-brotli
lib/jekyll/brotli/compressor.rb
Ruby
mit
19
main
3,871
# frozen_string_literal: true require 'jekyll/brotli/config' require 'brotli' module Jekyll ## # The main namespace for +Jekyll::Brotli+. Includes the +Compressor+ module # which is used to map over files, either using an instance of +Jekyll::Site+ # or a directory path, and compress them using Brotli. modu...
github
jage/elk
https://github.com/jage/elk
elk.gemspec
Ruby
mit
19
master
1,061
# frozen_string_literal: true $:.unshift File.expand_path("../lib", __FILE__) require 'elk/version' spec = Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "elk" s.version = Elk::VERSION s.author = "Johan Eckerström" s.email = "johan@duh.se" s.summary =...
github
jage/elk
https://github.com/jage/elk
Rakefile
Ruby
mit
19
master
313
# frozen_string_literal: true require 'bundler/gem_tasks' desc "Run specs" task :spec do begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) rescue LoadError end end desc "Synonym for spec" task :test => :spec desc "Synonym for spec" task :tests => :spec task :default => :spec
github
jage/elk
https://github.com/jage/elk
spec/spec_helper.rb
Ruby
mit
19
master
511
# frozen_string_literal: true require 'rspec' require 'webmock/rspec' def fixture_path File.expand_path(File.join('..', 'fixtures'), __FILE__) end def fixture(file) File.new(File.join(fixture_path, file)) end def configure_elk Elk.configure do |config| config.username = 'USERNAME' config.password = 'P...
github
jage/elk
https://github.com/jage/elk
spec/unit/elk_spec.rb
Ruby
mit
19
master
1,855
# frozen_string_literal: true require "spec_helper" require "elk" describe Elk do subject { Elk } it { is_expected.to respond_to(:client) } it { is_expected.to respond_to(:configure) } it { is_expected.to respond_to(:base_url) } it { is_expected.to respond_to(:base_domain) } it { is_expected.to respond_...
github
jage/elk
https://github.com/jage/elk
spec/unit/utils_spec.rb
Ruby
mit
19
master
1,294
# frozen_string_literal: true require "spec_helper" require "elk" describe Elk::Util do describe "#verify_parameters" do let(:parameters) { { from: "mom", to: "god" } } context "with all required parameters" do let(:required_parameters) { [:from, :to] } it "should not raise any exceptions" do ...
github
jage/elk
https://github.com/jage/elk
spec/unit/number_spec.rb
Ruby
mit
19
master
2,399
# frozen_string_literal: true require "spec_helper" require "elk" require "json" describe Elk::Number do subject(:number) { described_class.new({}) } let(:client) { instance_double(Elk::Client) } describe "#new" do context "when passing a client" do subject(:number) { described_class.new(client: cli...
github
jage/elk
https://github.com/jage/elk
spec/unit/sms_spec.rb
Ruby
mit
19
master
1,838
# frozen_string_literal: true require "spec_helper" require "elk" require "json" describe Elk::SMS do subject(:sms) { described_class.new({}) } let(:client) { instance_double(Elk::Client) } describe "#new" do context "when passing a client" do subject(:sms) { described_class.new(client: client) } ...