repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
ight/bazzar
app/views/shared/errors.rabl
object false node :errors do { messages: [@message] } end
ight/bazzar
app/views/api/v1/categories/index.rabl
<reponame>ight/bazzar object false node :categories do partial 'api/v1/categories/show', object: @categories end
ight/bazzar
app/models/user.rb
class User < ApplicationRecord rolify after_add: [:touch_updated_at], after_remove: [:touch_updated_at] # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :track...
ight/bazzar
app/views/api/v1/users/show.rabl
object @user attributes :id, :first_name, :last_name, :email, :contact_number
ight/bazzar
db/migrate/20171128082554_create_items.rb
<reponame>ight/bazzar<gh_stars>0 class CreateItems < ActiveRecord::Migration[5.0] def change create_table :items do |t| t.string :name, null: false t.string :price, null: false t.string :code, null: false t.timestamps end add_index :items, :code, unique: true end end
ight/bazzar
app/models/category.rb
class Category < ApplicationRecord # Associations has_many :items, inverse_of: :category has_many :brands, inverse_of: :category # callbacks after_commit :update_cat_list, on: [:create, :destroy] # Validations validates :category_name, uniqueness: true # Scope scope :active, -> { where(status: 0) ...
ight/bazzar
test/test_helper.rb
<reponame>ight/bazzar ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' require "minitest/reporters" Minitest::Reporters.use!(Minitest::Reporters::ProgressReporter.new, ENV, Minitest.backtrace_filter) class ActionController::TestCase include Devise::...
ight/bazzar
app/models/cart_item.rb
<gh_stars>0 class CartItem < ApplicationRecord # Association belongs_to :item, inverse_of: :cart_items belongs_to :user, inverse_of: :cart_items end
ight/bazzar
app/models/item.rb
class Item < ApplicationRecord # Associations belongs_to :category, inverse_of: :items belongs_to :brand, inverse_of: :items has_many :cart_items, inverse_of: :item has_many :users, through: :cart_items end
ight/bazzar
test/test_unit_extensions.rb
module TestUnitExtensions def json_response @json_response_body ||= ActiveSupport::JSON.decode @response.body end def assert_exception_messages(exception, message) assert_equal message, exception.message end end ActiveSupport::TestCase.send(:include, TestUnitExtensions)
ight/bazzar
config/initializers/custome_exception.rb
<reponame>ight/bazzar<gh_stars>0 module Bazzar module Exception class InvalidParameter < ArgumentError; end class NotImplementedError < NoMethodError; end class InsufficientPrivilege < StandardError; end class WebhookIntegration < StandardError; end class DocMigration < StandardError; end end en...
ight/bazzar
test/models/category_test.rb
<reponame>ight/bazzar<gh_stars>0 require 'test_helper' class CategoryTest < ActiveSupport::TestCase # Test Association test 'has_many items' do assert categories(:wrist_watch).items.exists? end test 'has_many brands' do assert categories(:wrist_watch).brands.exists? end # Test callback test 'u...
ight/bazzar
app/views/api/v1/categories/show.rabl
object @category attributes :id, :category_name
ight/bazzar
app/controllers/api/v1/categories_controller.rb
<reponame>ight/bazzar<filename>app/controllers/api/v1/categories_controller.rb class Api::V1::CategoriesController < ApplicationController swagger_controller :categories, "Handle Categories at Bazzar" swagger_api :create do summary 'Add a Category to Bazzar' param :form, :"category[category_name]", :strin...
ight/bazzar
app/models/brand.rb
class Brand < ApplicationRecord # Associations belongs_to :category, inverse_of: :brands has_many :items, inverse_of: :brand end
ight/bazzar
app/controllers/bazzar_controller.rb
<reponame>ight/bazzar<filename>app/controllers/bazzar_controller.rb class BazzarController < ApplicationController skip_before_action :authenticate_user_token! def index render layout: false end def welcome render layout: false end end
ight/bazzar
app/controllers/api/v1/items_controller.rb
<gh_stars>0 class Api::V1::ItemsController < ApplicationController swagger_controller :items, "Handle Item Actions" swagger_api :create do summery 'Add an Item to Bazzar' end end
ight/bazzar
db/migrate/20171129071621_add_columns_to_tables.rb
<reponame>ight/bazzar class AddColumnsToTables < ActiveRecord::Migration[5.0] def change add_column :items, :brand_id, :integer add_column :items, :category_id, :integer add_column :brands, :category_id, :integer add_index :items, :brand_id add_index :items, :category_id add_index :brands, :ca...
ight/bazzar
app/controllers/api/v1/users_controller.rb
<reponame>ight/bazzar<filename>app/controllers/api/v1/users_controller.rb class Api::V1::UsersController < ApplicationController # Checking authorization load_and_authorize_resource :user swagger_controller :users, "For User actions" swagger_api :profile do summary 'Fetches the profile details of curren...
ight/bazzar
config/initializers/swagger_docs.rb
<filename>config/initializers/swagger_docs.rb # Overriding the transform_path method in this class class Swagger::Docs::Config def self.transform_path(path, api_version) "api/v#{api_version.to_i}/#{path}" end Swagger::Docs::Config.base_api_controller = ApplicationController Swagger::Docs::Config.register_apis(...
ight/bazzar
config/initializers/1_bazzar_settings.rb
class BazzarSettings < Settingslogic # Load the source file for settings source "#{Rails.root}/config/bazzar.yml" namespace Rails.env def self.build_url custom_port = ":#{port}" unless [443.80].include?(port.to_i) app_path = [ protocol, "://", host, custom_port, r...
ight/bazzar
db/migrate/20171130103047_add_index_to_user.rb
<gh_stars>0 class AddIndexToUser < ActiveRecord::Migration[5.0] def change add_index :users, :contact_number add_index :users, :email add_index :cart_items, :item_id add_index :cart_items, :user_id end end
ight/bazzar
db/migrate/20171130095127_create_cart_items.rb
class CreateCartItems < ActiveRecord::Migration[5.0] def change create_table :cart_items do |t| t.integer :item_id t.integer :user_id t.boolean :processed, null: false, default: false t.timestamps end end end
ight/bazzar
app/controllers/application_controller.rb
<reponame>ight/bazzar<filename>app/controllers/application_controller.rb class ApplicationController < ActionController::Base include Swagger::Docs::ImpotentMethods # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception, unle...
ight/bazzar
app/controllers/users/registrations_controller.rb
<filename>app/controllers/users/registrations_controller.rb class Users::RegistrationsController < Devise::RegistrationsController skip_before_action :verify_authenticity_token before_filter :configure_permitted_parameters # skip_before_action :authenticate_user_token!, only: [:create] respond_to :json #A...
ight/bazzar
test/controllers/api/v1/categories_controller_test.rb
<reponame>ight/bazzar<filename>test/controllers/api/v1/categories_controller_test.rb<gh_stars>0 require 'test_helper' class Api::V1::CategoriesControllerTest < ActionController::TestCase test 'create' do post :create, params: { category: { category_name: 'sample category' } } assert_response :created [:...
joaodrp/homebrew-tap
Formula/gelf-pretty.rb
<filename>Formula/gelf-pretty.rb # This file was generated by GoReleaser. DO NOT EDIT. class GelfPretty < Formula desc "CLI to pretty-print Graylog Extended Log Format (GELF) log lines" homepage "https://github.com/joaodrp/gelf-pretty" url "https://github.com/joaodrp/gelf-pretty/releases/download/v0.1.0/gelf-pret...
Salvador-ON/Build-Your-Own-Scraper
lib/write_file.rb
# frozen_string_literal: true # Writting txt file class Filewrite attr_reader :file def initialize(search_arr) prefix = 'searches/search-related-to-' @file = File.open(prefix + "#{search_arr.join('-')}.html", 'w') end def build_html File.open('template/begin.txt').each do |line| @file.puts l...
Salvador-ON/Build-Your-Own-Scraper
lib/browser.rb
# frozen_string_literal: true # Browser Class, search for the target elements and save it in an array class Browser attr_reader :parsed_page, :last_page, :titles, :titles_arr attr_reader :ref_arr, :art_in_page def initialize @browser = Watir::Browser.new @browser.goto 'https://hackernoon.com/tagged/ruby'...
Salvador-ON/Build-Your-Own-Scraper
spec/browser_spec.rb
# frozen_string_literal: true require './lib/browser.rb' require 'nokogiri' require 'open-uri' require 'webdrivers' require 'watir' # rubocop: disable Metrics/BlockLength RSpec.describe Browser do describe '#Browser' do context 'when is initialize give true if the 2 arrays init' do test = Browser.new ...
Salvador-ON/Build-Your-Own-Scraper
spec/write_file_spec.rb
# frozen_string_literal: true require './lib/write_file.rb' # rubocop: disable Metrics/BlockLength RSpec.describe Filewrite do arr1 = %w[RSPEC-TEST-ruby rails] p_name = 'searches/search-related-to-' + "#{arr1.join('-')}.html" describe '#Filewrite' do context 'when is initialize create a new file give true...
Salvador-ON/Build-Your-Own-Scraper
bin/main.rb
<filename>bin/main.rb # frozen_string_literal: true require 'nokogiri' require 'open-uri' require 'byebug' require 'webdrivers' require 'watir' require_relative '../lib/browser.rb' require_relative '../lib/write_file.rb' # Start class that initizalize everything class Start attr_reader :page, :write def initializ...
youssef-abdallah/Reddit-Clone
app/controllers/communities_controller.rb
class CommunitiesController < ApplicationController before_action :authenticate_account!, except: [:show, :index] before_action :set_community, only: [:show] def index @communities = Community.all end def show @posts = @community.posts end def new @community = Comm...
youssef-abdallah/Reddit-Clone
app/models/post.rb
<reponame>youssef-abdallah/Reddit-Clone class Post < ApplicationRecord belongs_to :account belongs_to :community validates_presence_of :title, :body, :account_id, :community_id end
youssef-abdallah/Reddit-Clone
app/controllers/public_controller.rb
<reponame>youssef-abdallah/Reddit-Clone<gh_stars>0 class PublicController < ApplicationController def index @communities = Community.all.limit(5) @posts = Post.order(id: :desc).limit(20) end end
youssef-abdallah/Reddit-Clone
app/models/community.rb
<filename>app/models/community.rb class Community < ApplicationRecord belongs_to :account has_many :posts validates :name, presence: true validates :url, presence: true validates :rules, presence: true end
youssef-abdallah/Reddit-Clone
config/routes.rb
Rails.application.routes.draw do devise_for :accounts resources :communities do resources :posts end root to: "public#index" end
andypayne/basicsom
lib/som_main.rb
require './som_view_html.rb' ################################################################################ # Defaults win_width = 400 win_height = 400 x_num_nodes = 40 y_num_nodes = 40 # RGB input_vec_size = 3 num_iterations = 1000 init_learning_rate = 0.1 input_file_name = "" output_file_name = "" output_fi...
andypayne/basicsom
lib/som.rb
<filename>lib/som.rb<gh_stars>1-10 require 'csv' require 'optparse' require 'webrick' require './math_help.rb' ################################################################################ class SomNode attr_reader :weights, :dx, :dy def initialize(num_weights, left, right, top, bottom) @weights = Array.ne...
andypayne/basicsom
lib/som_view_html.rb
<reponame>andypayne/basicsom require './som.rb' ################################################################################ $html_page_data =<<END_HTML_BLOCK <html> <head> <script type="text/javascript"> function CreateReqObject() { var ro; var browser = navigator.appName; if (browser == "M...
andypayne/basicsom
lib/math_help.rb
################################################################################ def max(a, b) return (a > b) ? a : b end def min(a, b) return (a < b) ? a : b end # Squared Euclidean distance def euclidean_dist_sq(vec1, vec2) raise "Array sizes are not the same" unless vec1.size == vec2.size dist = 0.0 v...
notEthan/oauthenticator
lib/oauthenticator/rack_test_signer.rb
module OAuthenticator module RackTestSigner # takes a block. for the duration of the block, requests made with Rack::Test will be signed # with the given oauth_attrs. oauth_attrs are passed to {OAuthenticator::SignableRequest}. # # attributes of the request are set from the Rack::Test request, so you...
notEthan/oauthenticator
test/config_methods_test.rb
# encoding: utf-8 proc { |p| $:.unshift(p) unless $:.any? { |lp| File.expand_path(lp) == p } }.call(File.expand_path('.', File.dirname(__FILE__))) require 'helper' describe OAuthenticator::SignedRequest do %w(timestamp_valid_period consumer_secret token_secret nonce_used? use_nonce! token_belongs_to_consumer?).each ...
nrsantamaria/ruby_triangle
spec/triangle_spec.rb
<gh_stars>0 require('rspec') require('triangle') describe('Triangle#initialize') do it('creates a new triangle object based on the three provided side arguments') do expect(Triangle.new(3,4,5).class).to(eq(Triangle)) end end describe('Triangle#type') do it('will return the triangle type of equilateral if th...
nrsantamaria/ruby_triangle
lib/triangle.rb
<reponame>nrsantamaria/ruby_triangle class Triangle define_method(:initialize) do |side1, side2, side3| @sides = [side1, side2, side3].map{|s| s.to_i}.sort end define_method(:type) do if @sides.uniq.length == 1 "Equilateral" elsif @sides[0] + @sides[1] <= @sides[2] "Not a triangle" el...
Mosaics/BAPickView
BAPickView.podspec
<reponame>Mosaics/BAPickView<gh_stars>0 Pod::Spec.new do |s| s.name = "BAPickView" s.version = "1.1.3" s.summary = '目前为止,最为精简的 自定义 pickView 和 日期选择器 封装!' s.homepage = 'https://github.com/BAHome/BAPickView' s.license = 'MIT' s.authors = { 'boa' => '<EMAIL>' } s....
zhuhaow/aws-sam-cli
tests/integration/testdata/sync/infra/before/Ruby/function/app.rb
require 'statistics' require 'json' require 'layer' def lambda_handler(event:, context:) # Sample pure Lambda function that returns a message and a location normal = Statistics::Distribution::Normal.new(2,3) { statusCode: 200, body: { message: "#{layer()+1}", extra_message: normal.random ...
zhuhaow/aws-sam-cli
tests/integration/testdata/sync/infra/before/Ruby/layer/layer.rb
def layer() 6 end
zhuhaow/aws-sam-cli
tests/integration/testdata/sync/infra/after/Ruby/layer/layer.rb
def layer() 7 end
substancelab/acts-as-rated
test/fixtures/migrations/001_add_rating_tables.rb
<filename>test/fixtures/migrations/001_add_rating_tables.rb class AddRatingTables < ActiveRecord::Migration def self.up ActiveRecord::Base.create_ratings_table ActiveRecord::Base.create_ratings_table :with_rater => false, :table_name => 'no_rater_ratings' ActiveRecord::Base.create_ratings_table :with_stat...
substancelab/acts-as-rated
test/schema.rb
<reponame>substancelab/acts-as-rated ActiveRecord::Schema.define(:version => 0) do create_table :users, :force => true do |t| t.column :title, :text end create_table :ratings, :force => true do |t| t.column :rater_id, :integer t.column :rated_id, :integer t.column :rated_type, :string t...
substancelab/acts-as-rated
lib/acts-as-rated/acts_as_rated.rb
module ActiveRecord #:nodoc: module Acts #:nodoc: # == acts_as_rated # Adds rating capabilities to any ActiveRecord object. # It has the ability to work with objects that have or don't special fields to keep a tally of the # ratings and number of votes for each object. # In addition it will by de...
substancelab/acts-as-rated
lib/acts-as-rated.rb
require "acts-as-rated/acts_as_rated"
substancelab/acts-as-rated
test/dummy_classes.rb
<reponame>substancelab/acts-as-rated class User < ActiveRecord::Base end class Worker < ActiveRecord::Base set_table_name 'users' end class Movie < ActiveRecord::Base acts_as_rated end class Film < ActiveRecord::Base set_table_name 'movies' acts_as_rated :rating_range => 1..5 end class Book < ActiveRecord:...
substancelab/acts-as-rated
lib/acts-as-rated/version.rb
module Acts module As module Rated VERSION = "0.0.5" end end end
substancelab/acts-as-rated
test/migration_test.rb
ENV['NO_SCHEMA_LOAD'] = 'true' require File.join(File.dirname(__FILE__), 'abstract_unit') require File.join(File.dirname(__FILE__), 'dummy_classes') if ActiveRecord::Base.connection.supports_migrations? class MigrationTest < Test::Unit::TestCase self.use_transactional_fixtures = false # Defeat table cr...
substancelab/acts-as-rated
test/rated_test.rb
<reponame>substancelab/acts-as-rated<gh_stars>1-10 require File.join(File.dirname(__FILE__), 'abstract_unit') require File.join(File.dirname(__FILE__), 'dummy_classes') class RatedTest < Test::Unit::TestCase fixtures :cars, :movies, :books, :users, :ratings, :no_rater_ratings, :videos, :stats_ratings, :my_stats_rati...
substancelab/acts-as-rated
acts-as-rated.gemspec
# -*- encoding: utf-8 -*- require File.expand_path('../lib/acts-as-rated/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["<NAME>"] gem.email = ["<EMAIL>"] gem.description = %q{Flexible, configurable, and easy to use with the defaults. Supports 3 different ways to manage rating ...
dalen/puppet-puppetdbquery
spec/functions/query_nodes_spec.rb
#! /usr/bin/env ruby -S rspec require 'spec_helper' require 'puppetdb/connection' describe 'query_nodes' do context 'without fact parameter' do it do PuppetDB::Connection.any_instance.expects(:query) .with(:nodes, ['in', 'certname', ['extract', 'certname', ['select_fact_contents', ['and', ['=', 'p...
dalen/puppet-puppetdbquery
lib/puppet/application/puppetdbquery.rb
<reponame>dalen/puppet-puppetdbquery require 'puppet/application/face_base' class Puppet::Application::Puppetdbquery < Puppet::Application::FaceBase def self.setting use_ssl = true begin require 'puppet' require 'puppet/util/puppetdb' PuppetDB::Connection.check_version uri = URI(Puppe...
dalen/puppet-puppetdbquery
spec/functions/query_facts_spec.rb
<reponame>dalen/puppet-puppetdbquery<filename>spec/functions/query_facts_spec.rb #! /usr/bin/env ruby -S rspec require 'spec_helper' require 'puppetdb/connection' describe 'query_facts' do it do PuppetDB::Connection.any_instance.expects(:query) .with(:facts, ['or', ['=', 'name', 'ipaddress']], {:extract =...
dalen/puppet-puppetdbquery
lib/puppetdb.rb
<reponame>dalen/puppet-puppetdbquery module PuppetDB # Current version of this module VERSION ||= [3, 0, 1].freeze end
dalen/puppet-puppetdbquery
lib/puppet/functions/query_facts.rb
# Accepts two arguments, a query used to discover nodes, and a list of facts # that should be returned from those hosts. # # The query specified should conform to the following format: # (Type[title] and fact_name<operator>fact_value) or ... # Package[mysql-server] and cluster_id=my_first_cluster # # The facts list...
dalen/puppet-puppetdbquery
lib/puppetdb/parser_helper.rb
<gh_stars>10-100 # Helper methods for the parser, included in the parser class require 'puppetdb' module PuppetDB::ParserHelper # Parse a query string into a PuppetDB query # # @param query [String] the query string to parse # @param endpoint [Symbol] the endpoint for which the query should be evaluated # @re...
dalen/puppet-puppetdbquery
lib/puppet/functions/puppetdb_lookup_key.rb
# The `puppetdb_lookup_key` is a hiera 5 `lookup_key` data provider function. # See (https://docs.puppet.com/puppet/latest/hiera_custom_lookup_key.html) for # more info. # # See README.md#hiera-backend for usage. # Puppet::Functions.create_function(:puppetdb_lookup_key) do dispatch :puppetdb_lookup_key do param ...
dalen/puppet-puppetdbquery
lib/puppet/functions/query_nodes.rb
# Accepts two arguments, a query used to discover nodes, and an optional # fact that should be returned. # # The query specified should conform to the following format: # (Type[title] and fact_name<operator>fact_value) or ... # Package["mysql-server"] and cluster_id=my_first_cluster # # The second argument should ...
dalen/puppet-puppetdbquery
ruby-puppetdb.gemspec
<filename>ruby-puppetdb.gemspec # -*- encoding: UTF-8 lib = File.expand_path('../lib/', __FILE__) $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib) require 'puppetdb' Gem::Specification.new do |s| s.name = 'ruby-puppetdb' s.version = PuppetDB::VERSION.join '.' s.platform = Gem::Platform::RUB...
manuelmorales/forwarding-dsl
lib/forwarding_dsl/getsetter.rb
module ForwardingDsl module Getsetter NOT_SET = Object.new def self.included klass klass.extend ClassMethods end module ClassMethods def getsetter *names names.each do |name| define_method name do |value = NOT_SET| if value == NOT_SET instance_...
manuelmorales/forwarding-dsl
spec/forwarding_dsl_spec.rb
require_relative 'spec_helper' describe ForwardingDsl do it 'has a version' do expect(ForwardingDsl::VERSION).not_to be_nil end it 'delegates .run() to Dsl' do target = double('target') expect(target).to receive(:some_method) ForwardingDsl.run target do some_method end end end
manuelmorales/forwarding-dsl
lib/forwarding_dsl.rb
require "forwarding_dsl/version" module ForwardingDsl autoload :Dsl, 'forwarding_dsl/dsl' autoload :Getsetter, 'forwarding_dsl/getsetter' def self.run *args, &block Dsl.run *args, &block end end
manuelmorales/forwarding-dsl
lib/forwarding_dsl/dsl.rb
module ForwardingDsl class Dsl attr_accessor :this attr_accessor :that def self.run target, &block return target unless block_given? case block.arity when 0 then new(target, block.binding.eval('self')). send(:instance_exec, &block) when 1 then block.call...
manuelmorales/forwarding-dsl
spec/forwarding_dsl/dsl_spec.rb
<reponame>manuelmorales/forwarding-dsl require_relative '../spec_helper' describe ForwardingDsl::Dsl do let(:target_class) do Class.new do def a_method end private def a_private_emthod end end end let(:target) { target_class.new } let(:an_external_method) { :external_r...
manuelmorales/forwarding-dsl
spec/forwarding_dsl/getsetter_spec.rb
<filename>spec/forwarding_dsl/getsetter_spec.rb require_relative '../spec_helper' RSpec.describe ForwardingDsl::Getsetter do subject { subject_class.new } let(:subject_class) { Class.new { include ForwardingDsl::Getsetter } } describe 'getsetter()' do it 'allows setting an attribute passing it as an argumen...
manuelmorales/forwarding-dsl
forwarding_dsl.gemspec
# coding: utf-8 gem_name = "forwarding_dsl" # TODO: Rename this lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "#{gem_name}/version" Gem::Specification.new do |spec| spec.name = gem_name spec.version = ForwardingDsl::VERSION spec.authors...
teemutammela/contentful-middleman-dynamic-pages
config.rb
require "contentful" require "rich_text_renderer" require "redcarpet" require "redcarpet/render_strip" # Initialize Contentful Delivery API client. client = Contentful::Client.new( access_token: ENV["CONTENTFUL_DELIVERY_API_KEY"], space: ENV["CONTENTFUL_SPACE_ID"] ) helpers do # Custom helper for conver...
tigrish/iso
spec/lib/iso/tag_spec.rb
<gh_stars>10-100 require 'spec_helper' describe ISO::Tag do describe ".new(code)" do it "returns a tag containing the language and region" do tag = ISO::Tag.new('en-MX') expect(tag.language.code).to eq 'en' expect(tag.region.code).to eq 'MX' end it "returns a tag containing the languag...
tigrish/iso
iso.gemspec
# Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- # stub: iso 0.4.0 ruby lib Gem::Specification.new do |s| s.name = "iso".freeze s.version = "0.4.0" s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze...
tigrish/iso
spec/lib/iso/un/region_spec.rb
<reponame>tigrish/iso require 'spec_helper' describe ISO::UN::Region do let(:has_iso) { ISO::UN::Region.find('004') } let(:no_iso) { ISO::UN::Region.find('002') } describe "#iso_code" do it "returns the corresponding iso code" do expect(has_iso.iso_code).to eq 'AF' end it "returns nil when t...
tigrish/iso
spec/lib/iso/subtag_spec.rb
<gh_stars>10-100 require 'spec_helper' class Subtag < ISO::Subtag DEFINITIONS_FILE = "spec/fixtures/base.yml" DEFAULT_CODE = "fr" private def i18n_scope super << ".languages" end end describe ISO::Subtag do describe "#==(object)" do it "returns true when both have the same code" do expect(...
tigrish/iso
spec/lib/iso/language_spec.rb
<filename>spec/lib/iso/language_spec.rb require 'spec_helper' describe ISO::Language do let(:language) { ISO::Language.new('de', name: 'German') } it "is a ISO Subtag" do expect(language).to be_kind_of(ISO::Subtag) end it "has a code" do expect(language.code).to eq 'de' end it "has a name" do ...
tigrish/iso
lib/iso.rb
require 'i18n' I18n.load_path << Dir[File.join(File.expand_path(File.dirname(__FILE__) + '/../locales'), '*.yml')] I18n.load_path.flatten! require_relative 'iso/tag' require_relative 'iso/subtag' require_relative 'iso/language' require_relative 'iso/region' require_relative 'iso/un/region'
tigrish/iso
spec/lib/iso/region_spec.rb
require 'spec_helper' describe ISO::Region do let(:region) { ISO::Region.new('FR', name: 'France') } it "is a ISO Subtag" do expect(region).to be_kind_of(ISO::Subtag) end it "has a code" do expect(region.code).to eq 'FR' end it "has a name" do expect(region.name).to eq 'France' end desc...
dribbble/assorted
assorted.gemspec
<reponame>dribbble/assorted<filename>assorted.gemspec<gh_stars>10-100 # coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'assorted/version' Gem::Specification.new do |spec| spec.name = "assorted" spec.version = Assorted::VERSION...
dribbble/assorted
spec/lib/assorted/scopes_spec.rb
<reponame>dribbble/assorted require "spec_helper" RSpec.describe Assorted::Scopes do it "sorts by created_at by default" do first = ExampleRecord.create(created_at: 2.days.ago) second = ExampleRecord.create(created_at: 1.day.ago) expect(ExampleRecord.asc).to eq([first, second]) expect(ExampleRecord....
dribbble/assorted
lib/assorted/scopes.rb
module Assorted module Scopes def asc(column = sorting_column) sanitized_order(column, :asc) end def desc(column = sorting_column) sanitized_order(column, :desc) end def assorted(options) assorted_options.merge!(options) end private def sanitized_order(column, dir...
dribbble/assorted
spec/support/active_record.rb
<gh_stars>10-100 ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: "spec/test.db") class ExampleRecord < ActiveRecord::Base end RSpec.configure do |config| config.around do |example| ActiveRecord::Base.transaction do ActiveRecord::Migration.verbose = false ActiveRecord::Migration...
dribbble/assorted
lib/assorted.rb
require "active_record" require "assorted/version" require "assorted/scopes" module Assorted def self.options @options ||= { default_sort_column: :created_at, } end end ActiveSupport.on_load(:active_record) do extend Assorted::Scopes end
dribbble/assorted
spec/lib/assorted_spec.rb
<filename>spec/lib/assorted_spec.rb require "spec_helper" RSpec.describe Assorted do it "includes itself in ActiveRecord::Base" do expect(ActiveRecord::Base.ancestors).to include(Assorted::Scopes) end describe "#options" do it "defaults to sort with created_at" do expect(Assorted.options[:default_...
rubinius/rubinius-bridge
lib/rubinius/bridge/rubinius.rb
module Rubinius Config = { 'eval.cache' => false } def synchronize(obj) yield end end
rubinius/rubinius-bridge
lib/rubinius/bridge/version.rb
module Rubinius module Bridge VERSION = "3.0" end end
rubinius/rubinius-bridge
lib/rubinius/bridge/object.rb
class Object def StringValue(obj) return obj if obj.kind_of?(String) begin obj.to_str rescue Exception => orig raise TypeError, "Coercion error: #{obj.inspect}.to_str => String failed", orig end return ret if ret.kind_of?(String) msg = "Coercion error: ob...
rubinius/rubinius-bridge
lib/rubinius/bridge/tuple.rb
module Rubinius class Tuple < Array def copy_from(other, start, length, dest) length.times do |i| self[dest + i] = other[start + i] end end end end
rubinius/rubinius-bridge
lib/rubinius/bridge/array.rb
<reponame>rubinius/rubinius-bridge class Array def to_tuple Rubinius::Tuple.new self end end
rubinius/rubinius-bridge
lib/rubinius/bridge/executable.rb
<filename>lib/rubinius/bridge/executable.rb module Rubinius class Executable attr_accessor :primitive end end
rubinius/rubinius-bridge
lib/rubinius/bridge.rb
require "redcard" require "rubinius/bridge/version" unless RedCard.check :rubinius require "rubinius/bridge/object" require "rubinius/bridge/array" require "rubinius/bridge/string" require "rubinius/bridge/rubinius" require "rubinius/bridge/compiled_code" require "rubinius/bridge/encoding" require "rubin...
rubinius/rubinius-bridge
lib/rubinius/bridge/encoding.rb
unless RedCard.check "1.9" class Encoding attr_reader :name def initialize(name="US-ASCII") @name = name end ASCII_8BIT = new "ASCII-8BIT" end end
rubinius/rubinius-bridge
lib/rubinius/bridge/lookup_table.rb
<reponame>rubinius/rubinius-bridge module Rubinius LookupTable = Hash end
rubinius/rubinius-bridge
lib/rubinius/bridge/string.rb
<reponame>rubinius/rubinius-bridge class String alias_method :append, :<< alias_method :bytesize, :size unless method_defined?(:bytesize) def data self end unless RedCard.check "1.9" def encoding @encoding ||= Encoding.new end def force_encoding(encoding) @encoding = encoding ...
rubinius/rubinius-bridge
rubinius-bridge.gemspec
<reponame>rubinius/rubinius-bridge<gh_stars>1-10 # coding: utf-8 require './lib/rubinius/bridge/version' Gem::Specification.new do |spec| spec.name = "rubinius-bridge" spec.version = Rubinius::Bridge::VERSION spec.authors = ["<NAME>"] spec.email = ["<EMAIL>"] spec.description =...
rubinius/rubinius-bridge
lib/rubinius/bridge/exception.rb
<reponame>rubinius/rubinius-bridge class SyntaxError def self.from(message, column, line, code, file) message << " #{file}:#{line}:#{column}\n #{code}" SyntaxError.new message end end