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
jamonholmgren/motion-table
https://github.com/jamonholmgren/motion-table
lib/motion-table/grouped_table.rb
Ruby
mit
19
master
316
module MotionTable module GroupedTable include MotionTable::SectionedTable def tableView @tableView ||= UITableView.alloc.initWithFrame(self.view.frame, style:UITableViewStyleGrouped) @tableView.dataSource = self; @tableView.delegate = self; return @tableView end end end
github
jamonholmgren/motion-table
https://github.com/jamonholmgren/motion-table
app/app_delegate.rb
Ruby
mit
19
master
349
class AppDelegate attr_accessor :window def application(application, didFinishLaunchingWithOptions:launchOptions) @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) @window.rootViewController = UINavigationController.alloc.initWithRootViewController(MainViewController.alloc.init) @windo...
github
jamonholmgren/motion-table
https://github.com/jamonholmgren/motion-table
app/controllers/main_view_controller.rb
Ruby
mit
19
master
1,461
class MainViewController < UIViewController def viewDidLoad super self.title = "MotionTable" rightButton = UIBarButtonItem.alloc.initWithTitle("Table Demo", style: UIBarButtonItemStyleBordered, target: self, action: 'grouped_table') self.navigationItem.rightBarButtonItem = rightButton self.view....
github
jamonholmgren/motion-table
https://github.com/jamonholmgren/motion-table
app/controllers/test_view_controller.rb
Ruby
mit
19
master
1,012
class TestViewController < UITableViewController include MotionTable::GroupedTable def viewDidLoad super self.title = "GroupedTable" grouped_table_view_data = [ { title: "Your Account", cells: [ { title: "Edit Profile", action: :edit_profile }, { title: "Log O...
github
aschmidt75/mcollective-docker-agent
https://github.com/aschmidt75/mcollective-docker-agent
agent/docker.rb
Ruby
mit
19
master
3,206
require 'docker' include Docker module MCollective module Agent class Docker<RPC::Agent metadata :name => "Docker Access Agent", :description => "Agent to access the Docker API via MCollective", :author => "Andreas Schmidt [@aschmidt75]", :license => "Ap...
github
aschmidt75/mcollective-docker-agent
https://github.com/aschmidt75/mcollective-docker-agent
application/docker.rb
Ruby
mit
19
master
2,770
require 'pp' class MCollective::Application::Docker<MCollective::Application description "Client side application for the MCollective Docker agent" usage "mco docker [options] [command] [extra args]" usage "mco docker [options] [command] [extra args]" option :id, :description => "Container or Images ID...
github
semaphoreci-demos/semaphore-demo-ruby-kubernetes
https://github.com/semaphoreci-demos/semaphore-demo-ruby-kubernetes
spec/spec_helper.rb
Ruby
mit
19
master
232
require 'rack/test' require 'rspec' ENV['RACK_ENV'] = 'test' require File.expand_path '../../app.rb', __FILE__ module RSpecMixin include Rack::Test::Methods def app() App end end RSpec.configure { |c| c.include RSpecMixin }
github
semaphoreci-demos/semaphore-demo-ruby-kubernetes
https://github.com/semaphoreci-demos/semaphore-demo-ruby-kubernetes
spec/app_spec.rb
Ruby
mit
19
master
336
require File.expand_path '../spec_helper.rb', __FILE__ RSpec.describe "My Sinatra Application" do it "has a home" do get "/" expect(last_response).to be_ok expect(last_response.body).to include("hello") end it "says something funny" do get "/says" expect(last_response.body).to include("smoke...
github
robertdfrench/cmake-refuckulator
https://github.com/robertdfrench/cmake-refuckulator
refuckulate.rb
Ruby
mit
19
master
2,173
#!/usr/bin/env ruby # CMake Refuckulator # Converts CMake projects into Autotools projects # Copyright 2014 Robert D. French class Logger def initialize @log_count = 0 end def log(msg) @log_count += 1 sleep(1.1) puts "[CMKREF #{@log_count}] #{msg}" end end def log(msg) @logger.log(msg) end def is_cmake...
github
apiaframework/apia
https://github.com/apiaframework/apia
apia.gemspec
Ruby
mit
19
main
628
# frozen_string_literal: true require_relative 'lib/apia/version' Gem::Specification.new do |s| s.name = 'apia' s.description = 'A framework for building HTTP APIs.' s.summary = 'This gem provides a friendly DSL for constructing HTTP APIs.' s.homepage = 'https://github.com/krystal/apia' ...
github
apiaframework/apia
https://github.com/apiaframework/apia
Gemfile
Ruby
mit
19
main
376
# frozen_string_literal: true source 'https://rubygems.org' git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } gemspec group :development, :test do gem 'appraisal' gem 'pry' gem 'rake' gem 'rspec' gem 'rspec-core' gem 'rspec-expectations' gem 'rspec-mocks' gem 'rubocop' gem 'ruby-...
github
apiaframework/apia
https://github.com/apiaframework/apia
Rakefile
Ruby
mit
19
main
232
# frozen_string_literal: true require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'rubocop/rake_task' RSpec::Core::RakeTask.new(:spec) RuboCop::RakeTask.new task default: :spec task test: :spec task lint: :rubocop
github
apiaframework/apia
https://github.com/apiaframework/apia
examples/config.ru
Ruby
mit
19
main
414
# frozen_string_literal: true $LOAD_PATH.unshift(File.expand_path('../lib', __dir__)) $LOAD_PATH.unshift(File.expand_path(__dir__)) require 'apia' require 'apia/rack' require 'core_api/base' use Apia::Rack, CoreAPI::Base, '/core/v1', development: true app = proc do [400, { 'Content-Type' => 'text/plain' }, ['Apia...
github
apiaframework/apia
https://github.com/apiaframework/apia
examples/core_api/base.rb
Ruby
mit
19
main
908
# frozen_string_literal: true require 'core_api/main_authenticator' require 'core_api/controllers/time_controller' module CoreAPI class Base < Apia::API authenticator MainAuthenticator scopes do add 'time', 'Allows time telling functions' end routes do schema get 'example/forma...
github
apiaframework/apia
https://github.com/apiaframework/apia
examples/core_api/main_authenticator.rb
Ruby
mit
19
main
1,084
# frozen_string_literal: true module CoreAPI class MainAuthenticator < Apia::Authenticator type :bearer potential_error 'InvalidToken' do code :invalid_token description 'The token provided is invalid. In this example, you should provide "example".' http_status 403 field :given_tok...
github
apiaframework/apia
https://github.com/apiaframework/apia
examples/core_api/endpoints/time_now_endpoint.rb
Ruby
mit
19
main
399
# frozen_string_literal: true module CoreAPI module Endpoints class TimeNowEndpoint < Apia::Endpoint description 'Returns the current time' field :time, type: Objects::Time, include: 'unix,day_of_week' scope 'time' def call response.add_field :time, get_time_now end ...
github
apiaframework/apia
https://github.com/apiaframework/apia
examples/core_api/objects/day.rb
Ruby
mit
19
main
265
# frozen_string_literal: true module CoreAPI module Objects class Day < Apia::Enum value 'Sunday' value 'Monday' value 'Tuesday' value 'Wednesday' value 'Thursday' value 'Friday' value 'Saturday' end end end
github
apiaframework/apia
https://github.com/apiaframework/apia
examples/core_api/objects/time.rb
Ruby
mit
19
main
522
# frozen_string_literal: true require 'core_api/objects/day' module CoreAPI module Objects class Time < Apia::Object description 'Represents a time' field :unix, type: :integer do backend(&:to_i) end field :day_of_week, type: Objects::Day do backend { |t| t.strftime('%...
github
apiaframework/apia
https://github.com/apiaframework/apia
examples/core_api/argument_sets/time_lookup_argument_set.rb
Ruby
mit
19
main
586
# frozen_string_literal: true module CoreAPI module ArgumentSets class TimeLookupArgumentSet < Apia::LookupArgumentSet argument :unix, type: :string argument :string, type: :string potential_error 'InvalidTime' do code :invalid_time http_status 400 end def resolve...
github
apiaframework/apia
https://github.com/apiaframework/apia
examples/core_api/controllers/time_controller.rb
Ruby
mit
19
main
745
# frozen_string_literal: true require 'core_api/objects/time' require 'core_api/argument_sets/time_lookup_argument_set' require 'core_api/endpoints/time_now_endpoint' module CoreAPI module Controllers class TimeController < Apia::Controller name 'Time API' description 'Returns the current time in v...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/spec_helper.rb
Ruby
mit
19
main
543
# frozen_string_literal: true SPEC_ROOT = __dir__ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__)) require 'apia' Dir[File.join(SPEC_ROOT, 'specs', 'support', '**', '*.rb')].sort.each { |path| require path } RSpec.configure do |config| config.color = true config.expect_with :rspec do |expectations| e...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/support/paginated_set.rb
Ruby
mit
19
main
1,165
# frozen_string_literal: true # This is a set of data that will behave appropriately for use by the pagnation system. class PaginatedSet def initialize(quantity_or_items, **options) if quantity_or_items.is_a?(Integer) @items = quantity_or_items.times.map { |i| "s#{i + 1}" } else @items = quantit...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/support/has_fields.rb
Ruby
mit
19
main
2,550
# frozen_string_literal: true shared_examples 'has fields dsl' do context '#field' do it 'should add a field' do dsl.field :name, type: :string expect(definition.fields[:name]).to be_a Apia::Definitions::Field expect(definition.fields[:name].type.klass).to eq Apia::Scalars::String expect...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/hook_set_spec.rb
Ruby
mit
19
main
1,121
# frozen_string_literal: true require 'spec_helper' require 'apia/hook_set' describe Apia::HookSet do subject(:hook_set) { described_class.new } context '#add' do it 'should add items by providing a proc' do example_proc = proc {} hook_set.add(example_proc) expect(hook_set).to include examp...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/request_environment_spec.rb
Ruby
mit
19
main
11,058
# frozen_string_literal: true require 'spec_helper' require 'apia/request_environment' require 'rack/mock' describe Apia::RequestEnvironment do def setup_api request = Apia::Request.new(Rack::MockRequest.env_for('/', 'CONTENT_TYPE' => 'application/json', :input => '{"name":"Phillip"}')) request.api = Apia:...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/authenticator_spec.rb
Ruby
mit
19
main
3,920
# frozen_string_literal: true require 'spec_helper' require 'apia/authenticator' require 'apia/error' require 'apia/object_set' require 'apia/request_environment' describe Apia::Authenticator do context '.collate_objects' do it 'should add potential errors' do error = Apia::Error.create('ExampleError') ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/endpoint_spec.rb
Ruby
mit
19
main
13,595
# frozen_string_literal: true require 'spec_helper' require 'apia/controller' require 'apia/endpoint' require 'apia/request' require 'apia/api' require 'apia/authenticator' require 'rack/mock' describe Apia::Endpoint do context '.execute' do context 'authenticators' do it 'should call the endpoint authent...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/notifications_spec.rb
Ruby
mit
19
main
1,239
# frozen_string_literal: true require 'spec_helper' require 'apia/notifications' RSpec.describe Apia::Notifications do after do described_class.clear_handlers end describe '.add_handler' do it 'adds a handler by providing a block' do handler = proc {} described_class.add_handler(&handler) ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/request_spec.rb
Ruby
mit
19
main
7,050
# frozen_string_literal: true require 'apia/request' describe Apia::Request do context '#headers' do it 'should return a RequestHeaders instance' do request = Apia::Request.new(Rack::MockRequest.env_for('/', 'HTTP_X_TEST' => 'HelloWorld')) expect(request.headers).to be_a Apia::RequestHeaders e...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/route_set_spec.rb
Ruby
mit
19
main
1,890
# frozen_string_literal: true require 'apia/route_set' require 'apia/route' describe Apia::RouteSet do subject(:route_set) { described_class.new } context '#add' do it 'should add new routes to the route set' do route = route_set.add(Apia::Route.new('users')) expect(route_set.map['users']).to be_...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/api_spec.rb
Ruby
mit
19
main
4,160
# frozen_string_literal: true require 'spec_helper' require 'apia/api' require 'apia/authenticator' require 'apia/controller' describe Apia::API do context '.objects' do it 'should return itself' do api = Apia::API.create('ExampleAPI') expect(api.objects).to include api end it 'should retur...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/version_spec.rb
Ruby
mit
19
main
215
# frozen_string_literal: true require 'spec_helper' require 'apia/version' describe Apia do context '::VERSION' do it 'should return a tsring' do expect(Apia::VERSION).to be_a String end end end
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/response_spec.rb
Ruby
mit
19
main
8,329
# frozen_string_literal: true require 'spec_helper' require 'apia/request' require 'apia/response' require 'apia/endpoint' describe Apia::Response do subject(:request) { Apia::Request.empty } context '#hash' do it 'should return a hash of all fields added to the response' do endpoint = Apia::Endpoint.c...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/field_set_spec.rb
Ruby
mit
19
main
9,650
# frozen_string_literal: true require 'spec_helper' require 'apia/definitions/field' require 'apia/field_set' require 'rack/mock' describe Apia::FieldSet do subject(:field_set) { Apia::FieldSet.new } context '#generate_hash' do it 'should set fields to nil if they are nil' do field = Apia::Definitions:...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/rack_spec.rb
Ruby
mit
19
main
15,595
# frozen_string_literal: true require 'spec_helper' require 'apia/rack' require 'apia/api' require 'rack/mock' describe Apia::Rack do context '#find_route' do subject(:rack) { Apia::Rack.new(nil, nil, '/api/core') } it 'should return nil if there is no matching route' do expect(rack.find_route(:get, ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/defineable_spec.rb
Ruby
mit
19
main
1,510
# frozen_string_literal: true require 'spec_helper' require 'apia/defineable' describe Apia::Defineable do # We'll test this using `API` but it could be any object that # extends Defineable. context 'IDs' do it 'should not be allowed to be created without an ID' do expect do Apia::API.create ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/request_headers_spec.rb
Ruby
mit
19
main
1,417
# frozen_string_literal: true require 'apia/request' require 'apia/request_headers' describe Apia::RequestHeaders do context '#fetch' do it 'should return a header' do headers = described_class.new('X_TEST' => 'Hello') expect(headers.fetch('X_TEST')).to eq 'Hello' end it 'should be case-ins...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/lookup_argument_set_spec.rb
Ruby
mit
19
main
2,511
# frozen_string_literal: true require 'spec_helper' require 'apia/lookup_argument_set' describe Apia::LookupArgumentSet do context '#validate' do subject(:lookup_as) do described_class.create('LookupAS') do argument :id, type: :integer argument :permalink, type: :string argument :n...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/deep_merge_spec.rb
Ruby
mit
19
main
794
# frozen_string_literal: true require 'spec_helper' require 'apia/deep_merge' describe Apia::DeepMerge do describe '.merge' do it 'merges root level items' do expect(described_class.merge({ a: 1 }, { b: 2 })).to eq({ a: 1, b: 2 }) end it 'merges hashes' do expect(described_class.merge({ ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/object_spec.rb
Ruby
mit
19
main
5,952
# frozen_string_literal: true require 'spec_helper' require 'apia/object' require 'apia/request' require 'apia/enum' describe Apia::Object do context '.collate_objects' do it 'should add the types from all fields' do cat_type = Apia::Object.create('CatType') type = Apia::Object.create('ExampleType')...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/error_spec.rb
Ruby
mit
19
main
978
# frozen_string_literal: true require 'spec_helper' require 'apia/error' require 'apia/manifest_errors' require 'apia/object_set' describe Apia::Error do context '.collate_objects' do it 'should return the types of any fields on the object' do nested_type = Apia::Object.create('ExampleNestedType') do ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/helpers_spec.rb
Ruby
mit
19
main
838
# frozen_string_literal: true require 'apia/helpers' describe Apia::Helpers do context '.class_name_to_id' do { 'Example' => 'Example', 'Example::Inner' => 'Example/Inner' }.each do |input, output| it "should convert #{input.inspect} to #{output.inspect}" do expect(Apia::Helpers.cl...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/polymorph_spec.rb
Ruby
mit
19
main
975
# frozen_string_literal: true require 'spec_helper' describe Apia::Polymorph do context '.option_for_value' do it 'should the option for the given value' do polymorph = Apia::Polymorph.create('MyPolymorph') do option :string, type: :string, matcher: proc { |s| s.is_a?(String) } option :int...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/field_spec_spec.rb
Ruby
mit
19
main
3,985
# frozen_string_literal: true require 'apia/field_spec' describe Apia::FieldSpec do context '.parse' do { '' => [], 'example1' => ['example1'], 'example1,example2' => %w[example1 example2], 'example1[*]' => %w[example1 example1.*], 'example1[name,description],example2' => ['example...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/enum_spec.rb
Ruby
mit
19
main
803
# frozen_string_literal: true require 'spec_helper' require 'apia/enum' describe Apia::Enum do context '#cast' do it 'should return the casted value' do enum = Apia::Enum.create('ExampleEnum') do value 'active' end expect(enum.cast('active')).to eq 'active' end it 'should use ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/cors_spec.rb
Ruby
mit
19
main
2,535
# frozen_string_literal: true require 'spec_helper' require 'apia/cors' describe Apia::CORS do describe '#to_headers' do subject(:cors) { described_class.new } context 'with the details' do it 'returns a wildcard origin and methods' do expect(cors.to_headers).to eq({ 'access-control-allow-ori...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/route_spec.rb
Ruby
mit
19
main
951
# frozen_string_literal: true require 'apia/route' describe Apia::Route do context '#extract_arguments' do it 'should extract arguments' do route = Apia::Route.new('users/:user_id') args = route.extract_arguments('users/123') expect(args['user_id']).to eq '123' end it 'should be able ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/argument_set_spec.rb
Ruby
mit
19
main
17,169
# frozen_string_literal: true require 'spec_helper' require 'apia/argument_set' require 'rack/mock' describe Apia::ArgumentSet do context '.collate_objects' do it 'should add types from arguments to the set' do author_as = Apia::ArgumentSet.create('AuthorSet') book_as = Apia::ArgumentSet.create('Exa...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/definitions/lookup_argument_set_spec.rb
Ruby
mit
19
main
779
# frozen_string_literal: true require 'spec_helper' require 'apia/definitions/lookup_argument_set' describe Apia::Definitions::LookupArgumentSet do subject(:definition) { described_class.new('MyLookupArgumentSet') } context '#dsl' do it 'should be a DSL instance' do expect(definition.dsl).to be_a Apia:...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/definitions/api_spec.rb
Ruby
mit
19
main
2,497
# frozen_string_literal: true require 'spec_helper' require 'apia/definitions/api' require 'apia/manifest_errors' require 'apia/authenticator' require 'apia/enum' describe Apia::Definitions::API do context '#validate' do it 'should have no errors for a valid API' do api = described_class.new('MyAPI') ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/definitions/field_spec.rb
Ruby
mit
19
main
7,083
# frozen_string_literal: true require 'spec_helper' require 'apia/definitions/field' require 'apia/object' describe Apia::Definitions::Field do context '#array?' do it 'should be true if the field can be an array' do field = Apia::Definitions::Field.new(:id) field.type = :string field.array = ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/definitions/enum_spec.rb
Ruby
mit
19
main
430
# frozen_string_literal: true require 'spec_helper' require 'apia/definitions/enum' describe Apia::Definitions::Enum do context '#validate' do it 'should raise an error if the cast block is not a proc' do enum = described_class.new('MyEnum') enum.cast = Class.new errors = Apia::ManifestErrors...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/definitions/polymorph_spec.rb
Ruby
mit
19
main
1,795
# frozen_string_literal: true require 'spec_helper' describe Apia::Definitions::Polymorph do context '#validate' do it 'should not add any errors for a valid polymorph' do polymorph = described_class.new('ExamplePolymorph') polymorph.options[:string] = Apia::Definitions::PolymorphOption.new('StringO...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/definitions/controller_spec.rb
Ruby
mit
19
main
1,571
# frozen_string_literal: true require 'apia/definitions/controller' describe Apia::Definitions::Controller do context '#validate' do it 'should have no errors for a valid controller' do controller = described_class.new('MyController') controller.endpoints[:test] = Apia::Endpoint.create('MyController...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/definitions/argument_set_spec.rb
Ruby
mit
19
main
797
# frozen_string_literal: true require 'spec_helper' require 'apia/definitions/argument_set' describe Apia::Definitions::ArgumentSet do context '#validate' do it 'should not raise an error with valid arguments' do as = described_class.new('MyArgumentSet') as.arguments[:name] = Apia::Definitions::Argu...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/definitions/endpoint_spec.rb
Ruby
mit
19
main
2,791
# frozen_string_literal: true require 'apia/definitions/endpoint' require 'apia/argument_set' require 'apia/manifest_errors' describe Apia::Definitions::Endpoint do context '#argument_set' do it 'should provide a default argument set for the endpoint' do as = Apia::Definitions::Endpoint.new('ExampleEndpoi...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/definitions/error_spec.rb
Ruby
mit
19
main
2,468
# frozen_string_literal: true require 'spec_helper' require 'apia/definitions/error' describe Apia::Definitions::Error do context '#validate' do it 'should not raise an error for a valid object' do error = described_class.new('MyError') error.code = :invalid_username error.http_status = 403 ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/definitions/argument_spec.rb
Ruby
mit
19
main
4,692
# frozen_string_literal: true require 'spec_helper' require 'apia/definitions/argument' require 'apia/manifest_errors' require 'apia/argument_set' require 'apia/enum' require 'apia/object' describe Apia::Definitions::Argument do context '#type' do it 'should return the type' do arg = Apia::Definitions::Ar...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/definitions/authenticator_spec.rb
Ruby
mit
19
main
1,648
# frozen_string_literal: true require 'spec_helper' require 'apia/definitions/authenticator' describe Apia::Definitions::Authenticator do context '#validate' do it 'should not add any errors if everything is OK' do auth = described_class.new('MyAuthenticator') auth.type = :bearer auth.action =...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/error_spec.rb
Ruby
mit
19
main
1,310
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/error' require 'apia/definitions/error' describe Apia::DSLs::Error do subject(:error) { Apia::Definitions::Error.new('TestError') } subject(:dsl) { Apia::DSLs::Error.new(error) } include_examples 'has fields dsl' do subject(:definition)...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/route_set_spec.rb
Ruby
mit
19
main
2,266
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/route_set' require 'apia/route_set' describe Apia::DSLs::RouteSet do subject(:route_set) { Apia::RouteSet.new } subject(:dsl) { described_class.new(route_set) } context '#route' do it 'should add a route' do controller = Apia::Con...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/api_spec.rb
Ruby
mit
19
main
2,394
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/api' require 'apia/definitions/api' describe Apia::DSLs::API do subject(:api) { Apia::Definitions::API.new('TestAPI') } subject(:dsl) { Apia::DSLs::API.new(api) } context '#name' do it 'should define the name' do dsl.name 'My API'...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/controller_spec.rb
Ruby
mit
19
main
2,595
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/controller' require 'apia/definitions/controller' require 'apia/authenticator' require 'apia/endpoint' describe Apia::DSLs::Controller do subject(:controller) { Apia::Definitions::Controller.new('TestController') } subject(:dsl) { Apia::DSLs::...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/authenticator_spec.rb
Ruby
mit
19
main
1,969
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/authenticator' require 'apia/definitions/authenticator' require 'apia/error' describe Apia::DSLs::Authenticator do subject(:authenticator) { Apia::Definitions::Authenticator.new('TestAuthenticator') } subject(:dsl) { Apia::DSLs::Authenticator....
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/argument_set_spec.rb
Ruby
mit
19
main
2,650
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/argument_set' require 'apia/definitions/argument_set' describe Apia::DSLs::ArgumentSet do subject(:argument_set) { Apia::Definitions::ArgumentSet.new('TestArguemtnSet') } subject(:dsl) { Apia::DSLs::ArgumentSet.new(argument_set) } context '...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/endpoint_spec.rb
Ruby
mit
19
main
5,595
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/endpoint' require 'apia/definitions/endpoint' require 'apia/authenticator' describe Apia::DSLs::Endpoint do subject(:endpoint) { Apia::Definitions::Endpoint.new('TestEndpoint') } subject(:dsl) { Apia::DSLs::Endpoint.new(endpoint) } include_...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/field_spec.rb
Ruby
mit
19
main
1,710
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/field' require 'apia/definitions/field' describe Apia::DSLs::Field do subject(:field) { Apia::Definitions::Field.new('TestField') } subject(:dsl) { Apia::DSLs::Field.new(field) } context '#description' do it 'should define the descripti...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/lookup_argument_set_spec.rb
Ruby
mit
19
main
1,072
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/lookup_argument_set' describe Apia::DSLs::LookupArgumentSet do subject(:as) { Apia::Definitions::LookupArgumentSet.new('TestLookupArgumentSet') } subject(:dsl) { Apia::DSLs::LookupArgumentSet.new(as) } context '#potential_error' do it '...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/enum_spec.rb
Ruby
mit
19
main
1,160
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/enum' require 'apia/definitions/enum' describe Apia::DSLs::Enum do subject(:enum) { Apia::Definitions::Enum.new('TestEnum') } subject(:dsl) { Apia::DSLs::Enum.new(enum) } context '#name' do it 'should define the name' do dsl.name ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/argument_spec.rb
Ruby
mit
19
main
1,201
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/argument' require 'apia/definitions/argument' describe Apia::DSLs::Argument do subject(:argument) { Apia::Definitions::Argument.new('TestArgument') } subject(:dsl) { Apia::DSLs::Argument.new(argument) } context '#description' do it 'sho...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/object_spec.rb
Ruby
mit
19
main
923
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/object' require 'apia/definitions/object' describe Apia::DSLs::Object do subject(:type) { Apia::Definitions::Object.new('TestType') } subject(:dsl) { Apia::DSLs::Object.new(type) } include_examples 'has fields dsl' do subject(:definitio...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/route_group_spec.rb
Ruby
mit
19
main
3,004
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/route_group' require 'apia/route_set' require 'apia/route_group' describe Apia::DSLs::RouteGroup do subject(:route_set) { Apia::RouteSet.new } subject(:route_group) { Apia::RouteGroup.new(:example, nil) } subject(:dsl) { described_class.new(...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/dsls/polymorph_spec.rb
Ruby
mit
19
main
1,326
# frozen_string_literal: true require 'spec_helper' require 'apia/dsls/polymorph' require 'apia/definitions/polymorph' describe Apia::DSLs::Polymorph do subject(:polymorph) { Apia::Definitions::Polymorph.new('TestPolymorph') } subject(:dsl) { Apia::DSLs::Polymorph.new(polymorph) } context '#name' do it 'sh...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/scalars/unix_time_spec.rb
Ruby
mit
19
main
1,650
# frozen_string_literal: true require 'spec_helper' require 'apia/scalars/unix_time' describe Apia::Scalars::UnixTime do context '.cast' do it 'should return a string' do expect(Apia::Scalars::UnixTime.cast(Time.new(2020, 2, 22, 12, 33, 22))).to eq 1_582_374_802 end end context '.valid?' do {...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/scalars/boolean_spec.rb
Ruby
mit
19
main
1,264
# frozen_string_literal: true require 'spec_helper' require 'apia/scalars/boolean' describe Apia::Scalars::Boolean do context '.cast' do it 'should return an integer' do expect(Apia::Scalars::Boolean.cast(true)).to eq true expect(Apia::Scalars::Boolean.cast(false)).to eq false end end conte...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/scalars/base64_spec.rb
Ruby
mit
19
main
613
# frozen_string_literal: true require 'spec_helper' require 'apia/scalars/base64' describe Apia::Scalars::Base64 do context '.cast' do it 'should return an string' do expect(described_class.cast('hello')).to eq 'aGVsbG8=' end end context '.parse' do it 'should decode base64 encoded data' do ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/scalars/date_spec.rb
Ruby
mit
19
main
1,768
# frozen_string_literal: true require 'spec_helper' require 'apia/scalars/date' describe Apia::Scalars::Date do context '.cast' do it 'should return a string' do expect(Apia::Scalars::Date.cast(Date.new(2020, 3, 22))).to eq '2020-03-22' end end context '.valid?' do { Date.new(2019, 2, 1...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/scalars/string_spec.rb
Ruby
mit
19
main
624
# frozen_string_literal: true require 'spec_helper' require 'apia/scalars/string' describe Apia::Scalars::String do context '.cast' do it 'should return an string' do expect(Apia::Scalars::String.cast('hello')).to eq 'hello' end end context '.valid?' do { 'hello' => true, :hello =...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/scalars/decimal_spec.rb
Ruby
mit
19
main
1,276
# frozen_string_literal: true require 'spec_helper' require 'apia/scalars/decimal' describe Apia::Scalars::Decimal do context '.cast' do it 'should return an integer' do expect(described_class.cast(12.34)).to eq 12.34 end end context '.valid?' do { 1234 => false, 12.23 => true, ...
github
apiaframework/apia
https://github.com/apiaframework/apia
spec/specs/apia/scalars/integer_spec.rb
Ruby
mit
19
main
1,165
# frozen_string_literal: true require 'spec_helper' require 'apia/scalars/integer' describe Apia::Scalars::Integer do context '.cast' do it 'should return an integer' do expect(Apia::Scalars::Integer.cast(1234)).to eq 1234 end end context '.valid?' do { 1234 => true, 12.23 => fals...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia.rb
Ruby
mit
19
main
517
# frozen_string_literal: true require 'apia/api' require 'apia/argument_set' require 'apia/authenticator' require 'apia/controller' require 'apia/endpoint' require 'apia/enum' require 'apia/error' require 'apia/lookup_argument_set' require 'apia/scalar' require 'apia/object' require 'apia/polymorph' require 'apia/sca...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/notifications.rb
Ruby
mit
19
main
484
# frozen_string_literal: true module Apia class Notifications class << self def handlers @handlers ||= [] end def notify(event, args = {}) handlers.each do |handler| handler.call(event, args) end end def add_handler(handler = nil, &block) ...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/scalar.rb
Ruby
mit
19
main
1,105
# frozen_string_literal: true require 'apia/helpers' require 'apia/definitions/scalar' require 'apia/defineable' module Apia class Scalar extend Defineable # Return the definition for this type # # @return [Apia::Definitions::Object] def self.definition @definition ||= Definitions::Scala...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/defineable.rb
Ruby
mit
19
main
1,363
# frozen_string_literal: true module Apia module Defineable # Inspect an object # # @return [String] def inspect type = ancestors.find { |c| c.name =~ /\AApia::/ } "<#{definition.id} [#{type}]>" end # Create a new object # # @param id [String] # @return [Class] d...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/cors.rb
Ruby
mit
19
main
847
# frozen_string_literal: true module Apia class CORS attr_accessor :methods attr_accessor :headers attr_accessor :origin def initialize @origin = '*' @methods = '*' @headers = [] end def to_headers return {} if @origin.nil? headers = {} headers['access-...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/dsl.rb
Ruby
mit
19
main
341
# frozen_string_literal: true module Apia class DSL def initialize(definition) @definition = definition end def name(name) @definition.name = name end def description(description) @definition.description = description end def no_schema @definition.schema = fals...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/rack.rb
Ruby
mit
19
main
6,480
# frozen_string_literal: true require 'json' require 'apia/rack_error' require 'apia/request' require 'apia/response' require 'apia/notifications' module Apia class Rack def initialize(app, api, namespace, **options) @app = app @api = api @namespace = '/' + namespace.sub(/\A\/+/, '').sub(/\/+...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/request_environment.rb
Ruby
mit
19
main
2,467
# frozen_string_literal: true require 'apia/environment_error_handling' require 'apia/errors/invalid_helper_error' require 'apia/cors' module Apia class RequestEnvironment attr_reader :request attr_reader :response include EnvironmentErrorHandling def initialize(request, response) @request ...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/field_set.rb
Ruby
mit
19
main
2,273
# frozen_string_literal: true require 'apia/helpers' require 'apia/scalar' require 'apia/object' require 'apia/enum' require 'apia/field_spec' require 'apia/generated_hash' module Apia class FieldSet < Hash # Add a new field to the fieldset # # @param field [Apia::Field] # @return [Apia::Field] ...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/pagination_object.rb
Ruby
mit
19
main
889
# frozen_string_literal: true require 'apia/object' require 'apia/scalars/integer' require 'apia/scalars/boolean' module Apia class PaginationObject < Apia::Object name 'Pagination Details' description 'Provides information about how data has been paginated' field :current_page, type: Scalars::Integer...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/error_set.rb
Ruby
mit
19
main
406
# frozen_string_literal: true module Apia class ErrorSet < Array def validate(errors, object) each_with_index do |error, index| unless error.respond_to?(:ancestors) && error.ancestors.include?(Apia::Error) errors.add object, 'InvalidPotentialError', "Potential error at index #{index} mus...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/helpers.rb
Ruby
mit
19
main
690
# frozen_string_literal: true require 'apia/scalars' module Apia module Helpers class << self # Convert a ruby class name into an ID for use by objects # # @param name [String] # @return [String] def class_name_to_id(name) name.to_s.gsub('::', '/') end # Conv...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/definition.rb
Ruby
mit
19
main
341
# frozen_string_literal: true module Apia class Definition attr_accessor :id attr_accessor :name attr_accessor :description attr_accessor :schema def initialize(id) @id = id setup end def schema? @schema != false end def validate(errors) end def setu...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/manifest_errors.rb
Ruby
mit
19
main
954
# frozen_string_literal: true require 'apia/errors/manifest_error' module Apia class ManifestErrors attr_reader :errors def initialize @errors = {} end def add(object, code, message) @errors[object] ||= Errors.new @errors[object].add(code: code, message: message) end de...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/enum.rb
Ruby
mit
19
main
928
# frozen_string_literal: true require 'apia/helpers' require 'apia/defineable' require 'apia/definitions/enum' require 'apia/errors/invalid_enum_option_error' module Apia class Enum extend Defineable class << self # Return the definition object for the enum # # @return [Apia::Definition...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/mock_request.rb
Ruby
mit
19
main
270
# frozen_string_literal: true require 'apia/request' module Apia class MockRequest < Request def json_body @json_body ||= {} end def ip @ip ||= '127.0.0.1' end attr_writer :ip def params @params ||= {} end end end
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/generated_hash.rb
Ruby
mit
19
main
423
# frozen_string_literal: true module Apia class GeneratedHash < Hash attr_reader :object attr_reader :source attr_reader :path def initialize(object, source, path: nil) super() @object = object @source = source @path = path end class << self def enabled? ...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/authenticator.rb
Ruby
mit
19
main
1,447
# frozen_string_literal: true require 'apia/defineable' require 'apia/definitions/authenticator' require 'apia/helpers' require 'apia/callable_with_environment' module Apia class Authenticator extend Defineable include CallableWithEnvironment class << self # Return the definition for this authe...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/request_headers.rb
Ruby
mit
19
main
737
# frozen_string_literal: true module Apia class RequestHeaders def initialize(headers) @headers = headers end def fetch(key, default = nil) @headers[self.class.make_key(key)] || default end def [](key) fetch(key) end def []=(key, value) @headers[self.class.make...
github
apiaframework/apia
https://github.com/apiaframework/apia
lib/apia/controller.rb
Ruby
mit
19
main
655
# frozen_string_literal: true require 'apia/defineable' require 'apia/definitions/controller' require 'apia/helpers' module Apia class Controller extend Defineable class << self # Return the definition object for the controller # # @return [Apia::Definitions::Controller] def defin...