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
traels-it/kommandant
https://github.com/traels-it/kommandant
app/controllers/kommandant/commands_controller.rb
Ruby
mit
47
main
1,863
class Kommandant::CommandsController < ApplicationController before_action :set_command, except: [:index, :new, :create] before_action :set_resource_classes, only: [:new, :edit] layout "kommandant/application" def index @commands = Kommandant::Command.all end def new @command = Kommandant::Comman...
github
traels-it/kommandant
https://github.com/traels-it/kommandant
app/controllers/kommandant/commands/searches_controller.rb
Ruby
mit
47
main
1,426
class Kommandant::Commands::SearchesController < ApplicationController include Kommandant.config.pagination.module.constantize if Kommandant.config.pagination.enabled before_action :set_command helper_method :partial_exists_for_result? def show @results = filtered_resources.map do |resource| Komman...
github
traels-it/kommandant
https://github.com/traels-it/kommandant
app/models/kommandant/command.rb
Ruby
mit
47
main
746
module Kommandant class Command < ApplicationRecord include MeiliSearch::Rails meilisearch do attribute :translations end def name return "no translation for #{I18n.locale}.name in Meilisearch" unless translator.exists?(I18n.locale, "name") translator.translate(I18n.locale, "name"...
github
traels-it/kommandant
https://github.com/traels-it/kommandant
app/models/kommandant/commands/search_result.rb
Ruby
mit
47
main
857
module Kommandant class Commands::SearchResult def initialize(command:, resource:) @command = command @resource = resource end attr_reader :resource delegate :icon, to: :command def name if command.translator.exists?(I18n.locale, "result_text") command.translator.transl...
github
juanroldan1989/shaken_not_stirred
https://github.com/juanroldan1989/shaken_not_stirred
Rakefile
Ruby
mit
47
master
265
require "rake/testtask" Rake::TestTask.new do |t| t.libs << "test" t.test_files = FileList[ "test/test_helper.rb", "test/*_test.rb" ] t.verbose = true end desc "Run tests" task :default => :test require "bundler" Bundler::GemHelper.install_tasks
github
juanroldan1989/shaken_not_stirred
https://github.com/juanroldan1989/shaken_not_stirred
shaken_not_stirred.gemspec
Ruby
mit
47
master
738
$:.push File.expand_path("../lib", __FILE__) Gem::Specification.new do |s| s.name = "shaken_not_stirred" s.version = "0.0.7" s.date = "2020-06-08" s.summary = "Shaken Not Stirred" s.description = "Ruby client to interact with Cocktails API - https://juanroldan.com.ar/cocktails-api-landi...
github
juanroldan1989/shaken_not_stirred
https://github.com/juanroldan1989/shaken_not_stirred
lib/shaken_not_stirred.rb
Ruby
mit
47
master
2,141
require "configuration" require "httparty" class ShakenNotStirred include HTTParty # testing purposes # BASE_URL = "http://localhost:3000/api/v1".freeze BASE_URL = "https://api-cocktails.herokuapp.com/api/v1".freeze attr_accessor :filters, :resource class << self attr_accessor :configuration end ...
github
juanroldan1989/shaken_not_stirred
https://github.com/juanroldan1989/shaken_not_stirred
test/configuration_test.rb
Ruby
mit
47
master
507
require "test_helper" describe Configuration do describe "#api_key" do before do @configuration = Configuration.new end describe "when api_key is not set" do it "should return default api_key" do @configuration.api_key.must_equal "default_api_key" end end describe "wh...
github
juanroldan1989/shaken_not_stirred
https://github.com/juanroldan1989/shaken_not_stirred
test/shaken_not_stirred_test.rb
Ruby
mit
47
master
6,931
require "test_helper" describe ShakenNotStirred do describe ".configure" do before do ShakenNotStirred.configure { |config| config.api_key = "abc123" } end it "should set main class with api_key" do ShakenNotStirred.configuration.api_key.must_equal "abc123" end end before do @fi...
github
juanroldan1989/shaken_not_stirred
https://github.com/juanroldan1989/shaken_not_stirred
test/test_helper.rb
Ruby
mit
47
master
239
require "coveralls" Coveralls.wear! require "minitest/spec" require "minitest/autorun" require "shaken_not_stirred" require "vcr" VCR.configure do |config| config.cassette_library_dir = "test/fixtures" config.hook_into :webmock end
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
rails_graph.gemspec
Ruby
mit
47
main
1,332
# frozen_string_literal: true require_relative "lib/rails_graph/version" Gem::Specification.new do |spec| spec.name = "rails_graph" spec.version = RailsGraph::VERSION spec.authors = ["Ahmad Elassuty"] spec.email = ["ahmad.elassuty@gmail.com"] spec.summary = "Graph visualization for Rails applications." s...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
spec/spec_helper.rb
Ruby
mit
47
main
374
# frozen_string_literal: true require "rails_graph" 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.expec...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph.rb
Ruby
mit
47
main
736
# frozen_string_literal: true require "rails_graph/version" require "rails_graph/error" require "rails_graph/configuration" require "rails_graph/railtie" require "rails_graph/commands/build_graph" require "rails_graph/commands/export_graph" require "rails_graph/inspector" module RailsGraph module_function def l...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/inspector.rb
Ruby
mit
47
main
672
# frozen_string_literal: true require "set" module RailsGraph class Inspector def initialize @classes = Set.new @associations = Set.new end def add_class(klass) @classes.add(klass) end def add_association(association) @associations.add(association) end def log ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/railtie.rb
Ruby
mit
47
main
269
# frozen_string_literal: true require "rails" module RailsGraph class Railtie < ::Rails::Railtie railtie_name :rails_graph rake_tasks do path = File.expand_path(__dir__) Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f } end end end
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/configuration.rb
Ruby
mit
47
main
700
# frozen_string_literal: true module RailsGraph class Configuration attr_reader :include_classes attr_writer :columns, :inheritance, :include_packwerk, :databases, :gems def initialize @include_classes = [] @include_packwerk = false @databases = true @columns = false @inher...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/graph.rb
Ruby
mit
47
main
807
# frozen_string_literal: true module RailsGraph module Graph class Graph def initialize(nodes: {}, relationships: {}) @nodes = nodes @relationships = relationships end def add_node(node) @nodes[node.identifier] = node end def nodes @nodes.values ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/entity.rb
Ruby
mit
47
main
357
# frozen_string_literal: true require "securerandom" module RailsGraph module Graph class Entity attr_reader :id, :name, :properties def initialize(name:, id: SecureRandom.uuid, properties: {}) @id = id @name = name @properties = properties end def identifier ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/relationship.rb
Ruby
mit
47
main
668
# frozen_string_literal: true require_relative "entity" module RailsGraph module Graph class Relationship < Entity attr_reader :source, :target, :label def initialize(source:, target:, label:, **opts) @source = source @target = target @label = label super(**opts) ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/node.rb
Ruby
mit
47
main
430
# frozen_string_literal: true require_relative "entity" module RailsGraph module Graph class Node < Entity attr_reader :labels def initialize(labels: [], **opts) @labels = Array(labels) super(**opts) end def as_json(_options = nil) { id: id, ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/relationships/inheritance.rb
Ruby
mit
47
main
421
# frozen_string_literal: true require_relative "../relationship" module RailsGraph module Graph module Relationships class Inheritance < Relationship def initialize(source, target) super( source: source, target: target, label: "InheritsFrom", ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/relationships/pack_model.rb
Ruby
mit
47
main
389
# frozen_string_literal: true require_relative "../relationship" module RailsGraph module Graph module Relationships class PackModel < Relationship def initialize(source, target) super( source: source, target: target, label: "PartOfPack", n...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/relationships/attribute.rb
Ruby
mit
47
main
506
# frozen_string_literal: true require_relative "../relationship" module RailsGraph module Graph module Relationships class Attribute < Relationship def initialize(source, target) super( source: source, target: target, label: "HasAttribute", ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/relationships/pack_dependency.rb
Ruby
mit
47
main
397
# frozen_string_literal: true require_relative "../relationship" module RailsGraph module Graph module Relationships class PackDependency < Relationship def initialize(source, target) super( source: source, target: target, label: "DependsOnPack", ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/relationships/association.rb
Ruby
mit
47
main
1,606
# frozen_string_literal: true require_relative "../relationship" module RailsGraph module Graph module Relationships class Association < Relationship attr_reader :association def initialize(association, source, target) @association = association super( sou...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/nodes/model.rb
Ruby
mit
47
main
1,004
# frozen_string_literal: true require_relative "../node" module RailsGraph module Graph module Nodes class Model < Node attr_reader :model def initialize(model) @model = model super(labels: "Model", name: model.name, properties: build_properties) end ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/nodes/database.rb
Ruby
mit
47
main
890
# frozen_string_literal: true require_relative "../node" module RailsGraph module Graph module Nodes class Database < Node attr_reader :configs def initialize(configs) @configs = configs super(labels: "Database", name: configs.name, properties: build_properties) ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/nodes/column.rb
Ruby
mit
47
main
616
# frozen_string_literal: true require_relative "../node" module RailsGraph module Graph module Nodes class Column < Node attr_reader :column def initialize(column) @column = column super(labels: "Column", name: column.name, properties: build_properties) end ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/nodes/pack.rb
Ruby
mit
47
main
489
# frozen_string_literal: true require_relative "../node" module RailsGraph module Graph module Nodes class Pack < Node attr_reader :pack_owner def initialize(name, owner) @pack_owner = owner super(labels: "Pack", name: name, properties: build_properties) end ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/nodes/table.rb
Ruby
mit
47
main
581
# frozen_string_literal: true require_relative "../node" module RailsGraph module Graph module Nodes class Table < Node attr_reader :name, :database_name def initialize(name, database_name) @database_name = database_name super(labels: "Table", name: name, properties: ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/nodes/virtual_model.rb
Ruby
mit
47
main
377
# frozen_string_literal: true require_relative "../node" module RailsGraph module Graph module Nodes class VirtualModel < Node def initialize(name) super( labels: "VirtualModel", name: name, properties: {} ) end def identifie...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/nodes/abstract_model.rb
Ruby
mit
47
main
481
# frozen_string_literal: true require_relative "../node" module RailsGraph module Graph module Nodes class AbstractModel < Node attr_reader :model def initialize(model) @model = model super( labels: "AbstractModel", name: model.name, ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/graph/nodes/gem.rb
Ruby
mit
47
main
764
# frozen_string_literal: true require_relative "../node" module RailsGraph module Graph module Nodes class Gem < Node attr_reader :specifications def initialize(specifications) @specifications = specifications super(labels: "Gem", name: specifications.name, properties...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/helpers/options_parser.rb
Ruby
mit
47
main
404
# frozen_string_literal: true require "optparse" module RailsGraph module Helpers module OptionsParser def parse_options(banner, arguments) parser = OptionParser.new parser.banner = banner options = {} arguments.each { |argument| parser.on(*argument) } parser.pars...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/helpers/associations.rb
Ruby
mit
47
main
711
# frozen_string_literal: true module RailsGraph module Helpers module Associations module_function def source_identifier(association) RailsGraph::Helpers::Models.identifier(association.active_record) end def source_node(graph, association) identifier = source_identifier(...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/helpers/models.rb
Ruby
mit
47
main
231
# frozen_string_literal: true module RailsGraph module Helpers module Models module_function def identifier(model) return unless model model.to_s.delete_prefix("::") end end end end
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/exporters/neo4j.rb
Ruby
mit
47
main
730
# frozen_string_literal: true require_relative "base" require "neo4j_ruby_driver" module RailsGraph module Exporters class Neo4j < Base def self.export(graph:, host:, username:, password:) auth = ::Neo4j::Driver::AuthTokens.basic(username, password) ::Neo4j::Driver::GraphDatabase.driver(h...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/exporters/cypher.rb
Ruby
mit
47
main
1,775
# frozen_string_literal: true require_relative "base" module RailsGraph module Exporters class Cypher < Base BASE_CYPHER = "MATCH (n) DETACH DELETE n;" def self.export(graph:, filename:) queries = build_queries(graph) File.write(filename, queries.join("\n"), mode: "w") end ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/exporters/json.rb
Ruby
mit
47
main
275
# frozen_string_literal: true require_relative "base" require "json" module RailsGraph module Exporters class Json < Base def self.export(graph:, filename:) json = graph.to_json File.write(filename, json, mode: "w") end end end end
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/tasks/rails_graph.rake
Ruby
mit
47
main
732
# frozen_string_literal: true require_relative "../helpers/options_parser" namespace :rails_graph do include RailsGraph::Helpers::OptionsParser namespace :export do desc "Export graph to Neo4j graph database" task neo4j: :environment do options = parse_options( "Usage: rails rails_graph:exp...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/commands/build_graph.rb
Ruby
mit
47
main
2,423
# frozen_string_literal: true require_relative "../graph/graph" require_relative "../graph/node" require_relative "../graph/relationship" require_relative "../graph/nodes/abstract_model" require_relative "../graph/nodes/column" require_relative "../graph/nodes/database" require_relative "../graph/nodes/gem" require_r...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/commands/export_graph.rb
Ruby
mit
47
main
516
# frozen_string_literal: true require_relative "../exporters/cypher" require_relative "../exporters/json" require_relative "../exporters/neo4j" module RailsGraph module Commands class ExportGraph EXPORTERS = { cypher: RailsGraph::Exporters::Cypher, json: RailsGraph::Exporters::Json, ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/commands/builders/models.rb
Ruby
mit
47
main
3,499
# frozen_string_literal: true module RailsGraph module Commands module Builders class Models attr_reader :graph, :inspector def self.enrich(...) new(...).enrich end def enrich build_model_nodes build_associations build_column_nodes i...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/commands/builders/packs.rb
Ruby
mit
47
main
2,841
# frozen_string_literal: true module RailsGraph module Commands module Builders class Packs def self.enrich(graph:, configuration:) return unless configuration.include_packwerk? new(graph: graph).enrich graph end def enrich build_pack_nodes...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/commands/builders/associations.rb
Ruby
mit
47
main
1,841
# frozen_string_literal: true module RailsGraph module Commands module Builders class Associations attr_reader :graph, :inspector def self.enrich(...) new(...).enrich end def enrich build_associations_relationships end private ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/commands/builders/gems_builder.rb
Ruby
mit
47
main
1,813
# frozen_string_literal: true module RailsGraph module Commands module Builders class GemsBuilder def self.enrich(graph:, configuration:) return unless configuration.gems? new(graph: graph).enrich graph end def enrich build_gems_nodes ...
github
ahmad-elassuty/rails_graph
https://github.com/ahmad-elassuty/rails_graph
lib/rails_graph/commands/builders/databases.rb
Ruby
mit
47
main
1,749
# frozen_string_literal: true module RailsGraph module Commands module Builders class Databases def self.enrich(graph:, configuration:) return unless configuration.databases? new(graph: graph).enrich graph end def enrich build_databases_nod...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
kdl.gemspec
Ruby
mit
47
main
1,318
require_relative 'lib/kdl/version' Gem::Specification.new do |spec| spec.name = "kdl" spec.version = KDL::VERSION spec.authors = ["Danielle Smith"] spec.email = ["danini@hey.com"] spec.summary = %q{KDL Document Language} spec.description = %q{Ruby implementation of the...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
Rakefile
Ruby
mit
47
main
585
require 'bundler/gem_tasks' require 'rake/testtask' file 'lib/kdl/kdl.tab.rb' => ['lib/kdl/kdl.yy'] do raise "racc command failed" unless system 'bin/racc lib/kdl/kdl.yy' end task :racc => 'lib/kdl/kdl.tab.rb' file 'lib/kdl/v1/kdl.tab.rb' => ['lib/kdl/v1/kdl.yy'] do raise "racc command failed (v1)" unless system ...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
Gemfile
Ruby
mit
47
main
233
source "https://rubygems.org" # Specify your gem's dependencies in kdl.gemspec gemspec gem "rake", "~> 13.0" group :test do gem "minitest", "~> 6.0" gem "simplecov", require: false gem "coveralls_reborn", require: false end
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/examples_test.rb
Ruby
mit
47
main
2,887
# frozen_string_literal: true require "test_helper" class ExamplesTest < Minitest::Test def example_path(name) File.join(__dir__, "kdl-org/examples/#{name}.kdl") end def test_ci doc = ::KDL.load_file(example_path('ci')) nodes = KDL.build { name "CI" on "push", "pull_request" env {...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/test_helper.rb
Ruby
mit
47
main
327
# frozen_string_literal: true require "simplecov" require "coveralls" SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter ] SimpleCov.start $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "kdl" require 'minitest' Minitest.load_plugins require "minitest/au...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/builder_test.rb
Ruby
mit
47
main
1,786
# frozen_string_literal: true require "test_helper" class BuilderTest < Minitest::Test def test_build doc = KDL.build do |kdl| kdl.node "foo" kdl.node "bar", type: "baz" kdl.node "qux" do kdl.arg 123 kdl.prop "norf", "wat" kdl.prop "when", "2025-01-30", type: "date" ...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/document_test.rb
Ruby
mit
47
main
3,142
# frozen_string_literal: true require "test_helper" class DocumentTest < Minitest::Test def test_ref doc = KDL::Document.new([ KDL::Node.new("foo"), KDL::Node.new("bar") ]) assert_equal doc.nodes[0], doc[0] assert_equal doc.nodes[1], doc[1] assert_equal doc.nodes[0], doc["foo"] ...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/parser_test.rb
Ruby
mit
47
main
22,873
# frozen_string_literal: true require "test_helper" class ParserTest < Minitest::Test def setup @parser = ::KDL::Parser.new end def test_parse_empty_string assert_equal ::KDL::Document.new([]), @parser.parse('') assert_equal ::KDL::Document.new([]), @parser.parse(' ') assert_equal ::KDL::Docume...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/tokenizer_test.rb
Ruby
mit
47
main
10,339
# frozen_string_literal: true require "test_helper" class TokenizerTest < Minitest::Test def test_identifier assert_equal t(:IDENT, "foo"), ::KDL::Tokenizer.new("foo").next_token assert_equal t(:IDENT, "foo-bar123"), ::KDL::Tokenizer.new("foo-bar123").next_token assert_equal t(:IDENT, "-"), ::KDL::Token...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/value_test.rb
Ruby
mit
47
main
4,955
# frozen_string_literal: true require "test_helper" class ValueTest < Minitest::Test def test_to_s assert_equal "1", ::KDL::Value::Int.new(1).to_s assert_equal "1.5", ::KDL::Value::Float.new(1.5).to_s assert_equal "#inf", ::KDL::Value::Float.new(Float::INFINITY).to_s assert_equal "#-inf", ::KDL::Val...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types_test.rb
Ruby
mit
47
main
3,890
# frozen_string_literal: true require 'test_helper' class TypesTest < Minitest::Test def test_types doc = KDL.parse <<-KDL node (date-time)"2021-01-01T12:12:12" \\ (date)"2021-01-01" \\ (time)"22:23:12" \\ (duration)"P3Y6M4DT12H30M5S" \\ (currency)"ZAR" \\ (count...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/kdl_test.rb
Ruby
mit
47
main
535
# frozen_string_literal: true require "test_helper" class KDLTest < Minitest::Test def test_that_it_has_a_version_number refute_nil ::KDL::VERSION end def test_parse_document assert_equal KDL.parse('node 1 2 3'), KDL.parse_document('node 1 2 3') end def test_unsupported_version assert_raises(K...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/node_test.rb
Ruby
mit
47
main
5,256
# frozen_string_literal: true require "test_helper" class NodeTest < Minitest::Test def test_ref node = KDL::Node.new("node", arguments: [v(1), v("two")], properties: { "three" => v(3), "four" => v(4) }) assert_equal 1, node[0] assert_equal "two", node[1] assert_nil node[2] assert_equal 3, nod...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/spec_test.rb
Ruby
mit
47
main
947
# frozen_string_literal: true require 'test_helper' class SpecTest < Minitest::Test TEST_CASES_DIR = File.join(__dir__, 'kdl-org/tests/test_cases') INPUTS_DIR = File.join(TEST_CASES_DIR, 'input') EXPECTED_DIR = File.join(TEST_CASES_DIR, 'expected_kdl') Dir.glob(File.join(INPUTS_DIR, '*.kdl')).each do |input_...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/currency_test.rb
Ruby
mit
47
main
407
# frozen_string_literal: true require 'test_helper' class CurrencyTest < Minitest::Test def test_currency value = KDL::Types::Currency.call(::KDL::Value::String.new('ZAR')) assert_equal({ numeric_code: 710, minor_unit: 2, name: 'South African rand' }, value.value) ...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/irl_test.rb
Ruby
mit
47
main
2,475
# frozen_string_literal: true require "test_helper" class IRLTest < Minitest::Test def test_irl value = KDL::Types::IRL.call(::KDL::Value::String.new('https://bücher.example/foo/Ῥόδος')) assert_equal URI('https://xn--bcher-kva.example/foo/%E1%BF%AC%CF%8C%CE%B4%CE%BF%CF%82'), value.value assert_equal 'ht...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/ip_test.rb
Ruby
mit
47
main
872
# frozen_string_literal: true require "test_helper" class IPTest < Minitest::Test def test_ipv4 value = KDL::Types::IPV4.call(::KDL::Value::String.new('127.0.0.1')) assert_equal ::IPAddr.new('127.0.0.1'), value.value assert_raises { KDL::Types::IPV4.call(::KDL::Value::String.new('not an ipv4 address'))...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/country_test.rb
Ruby
mit
47
main
1,302
# frozen_string_literal: true require 'test_helper' class CountryTest < Minitest::Test def test_country3 value = KDL::Types::Country3.call(::KDL::Value::String.new('ZAF')) assert_equal({ alpha3: 'ZAF', alpha2: 'ZA', numeric_code: 710, name: 'South Afr...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/duration_test.rb
Ruby
mit
47
main
1,541
# frozen_string_literal: true require "test_helper" class DurationTest < Minitest::Test def test_duration value = KDL::Types::Duration.call(::KDL::Value::String.new('P3Y6M4DT12H30M5S')) assert_equal({ years: 3, months: 6, days: 4, hours: 12, minutes: 30, seconds: 5 }, value.value) value = KDL::Types::Du...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/hostname_test.rb
Ruby
mit
47
main
1,368
# frozen_string_literal: true require "test_helper" class HostnameTest < Minitest::Test def test_hostname value = KDL::Types::Hostname.call(::KDL::Value::String.new('www.example.com')) assert_equal 'www.example.com', value.value refute_nil KDL::Types::Hostname.call(::KDL::Value::String.new('a'*63 + '.co...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/regex_test.rb
Ruby
mit
47
main
311
# frozen_string_literal: true require "test_helper" class RegexTest < Minitest::Test def test_regex value = KDL::Types::Regex.call(::KDL::Value::String.new('asdf')) assert_equal(/asdf/, value.value) assert_raises { KDL::Types::Regex.call(::KDL::Value::String.new('invalid(regex]')) } end end
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/uuid_test.rb
Ruby
mit
47
main
535
# frozen_string_literal: true require "test_helper" class UUIDTest < Minitest::Test def test_uuid value = KDL::Types::UUID.call(::KDL::Value::String.new('f81d4fae-7dec-11d0-a765-00a0c91e6bf6')) assert_equal 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6', value.value value = KDL::Types::UUID.call(::KDL::Value::S...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/email_test.rb
Ruby
mit
47
main
3,104
# frozen_string_literal: true require "test_helper" class EmailTest < Minitest::Test def test_email value = KDL::Types::Email.call(::KDL::Value::String.new('danielle@example.com')) assert_equal 'danielle@example.com', value.value assert_equal 'danielle', value.local assert_equal 'example.com', value...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/date_time_test.rb
Ruby
mit
47
main
1,337
# frozen_string_literal: true require "test_helper" class DateTimeTest < Minitest::Test def test_date_time value = KDL::Types::DateTime.call(::KDL::Value::String.new('2011-10-05T22:26:12-04:00')) assert_equal ::Time.iso8601('2011-10-05T22:26:12-04:00'), value.value assert_raises { KDL::Types::DateTime....
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/decimal_test.rb
Ruby
mit
47
main
349
# frozen_string_literal: true require "test_helper" class DecimalTest < Minitest::Test def test_decimal value = KDL::Types::Decimal.call(::KDL::Value::String.new('10000000000000')) assert_equal(BigDecimal('10000000000000'), value.value) assert_raises { KDL::Types::Decimal.call(::KDL::Value::String.new('...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/base64_test.rb
Ruby
mit
47
main
349
# frozen_string_literal: true require "test_helper" class Base64Test < Minitest::Test def test_base64 value = KDL::Types::Base64.call(::KDL::Value::String.new('U2VuZCByZWluZm9yY2VtZW50cw==')) assert_equal 'Send reinforcements', value.value assert_raises { KDL::Types::Base64.call(::KDL::Value::String.ne...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/url_test.rb
Ruby
mit
47
main
884
# frozen_string_literal: true require "test_helper" class URLTest < Minitest::Test def test_url value = KDL::Types::URL.call(::KDL::Value::String.new('https://www.example.com/foo/bar')) assert_equal URI('https://www.example.com/foo/bar'), value.value assert_raises { KDL::Types::URL.call(::KDL::Value::S...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/types/url_template_test.rb
Ruby
mit
47
main
8,417
# frozen_string_literal: true require "test_helper" class URLTemplateTest < Minitest::Test def setup @variables = { count: ['one', 'two', 'three'], dom: ['example', 'com'], dub: 'me/too', hello: 'Hello World!', half: '50%', var: 'value', who: 'fred', base: 'http:/...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/v1/value_test.rb
Ruby
mit
47
main
1,652
# frozen_string_literal: true require "test_helper" class KDL::V1::ValueTest < Minitest::Test def test_to_s assert_equal "1", ::KDL::V1::Value::Int.new(1).to_s assert_equal "1.5", ::KDL::V1::Value::Float.new(1.5).to_s assert_equal "null", ::KDL::V1::Value::Float.new(Float::INFINITY).to_s assert_equa...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/v1/node_test.rb
Ruby
mit
47
main
777
# frozen_string_literal: true require "test_helper" class KDL::V1::NodeTest < Minitest::Test def test_version node = KDL::V1::Node.new("foo") assert_equal 1, node.version end def test_to_v2 node = KDL::V1::Node.new("foo", arguments: [v(true)], properties: { bar: v("baz") }, childr...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/v1/examples_test.rb
Ruby
mit
47
main
2,771
# frozen_string_literal: true require "test_helper" class KDL::V1::ExamplesTest < Minitest::Test def example_path(name) File.join(__dir__, "kdl-org/examples/#{name}.kdl") end def test_ci doc = ::KDL.load_file(example_path('ci')) nodes = KDL.build { name "CI" on "push", "pull_request" ...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/v1/tokenizer_test.rb
Ruby
mit
47
main
9,890
# frozen_string_literal: true require "test_helper" class KDL::V1::TokenizerTest < Minitest::Test def test_identifier assert_equal t(:IDENT, "foo"), ::KDL::V1::Tokenizer.new("foo").next_token assert_equal t(:IDENT, "foo-bar123"), ::KDL::V1::Tokenizer.new("foo-bar123").next_token assert_equal t(:IDENT, "...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/v1/document_test.rb
Ruby
mit
47
main
650
# frozen_string_literal: true require "test_helper" class KDL::V1::DocumentTest < Minitest::Test def test_version assert_equal 1, KDL::V1::Document.new([]).version end def test_to_v2 doc = KDL.parse <<~KDL, version: 1 foo "lorem" 1 true null { bar " baz qux "...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/v1/spec_test.rb
Ruby
mit
47
main
1,047
# frozen_string_literal: true require 'test_helper' class KDL::V1::SpecTest < Minitest::Test TEST_CASES_DIR = File.join(__dir__, 'kdl-org/tests/test_cases') INPUTS_DIR = File.join(TEST_CASES_DIR, 'input') EXPECTED_DIR = File.join(TEST_CASES_DIR, 'expected_kdl') EXCLUDE = %w[ escline_comment_node ] D...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
test/v1/parser_test.rb
Ruby
mit
47
main
19,795
# frozen_string_literal: true require "test_helper" class KDL::V1::ParserTest < Minitest::Test def setup @parser = ::KDL::V1::Parser.new end def test_parse_empty_string assert_equal ::KDL::Document.new([]), @parser.parse('') assert_equal ::KDL::Document.new([]), @parser.parse(' ') assert_equal ...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl.rb
Ruby
mit
47
main
2,120
# frozen_string_literal: true require "kdl/version" require "kdl/error" require "kdl/tokenizer" require "kdl/document" require "kdl/value" require "kdl/node" require "kdl/string_dumper" require "kdl/types" require "kdl/parser_common" require "kdl/kdl.tab" require "kdl/builder" require "kdl/v1" module KDL class << s...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/parser_common.rb
Ruby
mit
47
main
878
# frozen_string_literal: true module KDL module ParserCommon private def init(parse_types: true, type_parsers: {}, output_module: ::KDL) @output_module = output_module if parse_types @type_parsers = ::KDL::Types::MAPPING.merge(type_parsers) else @type_parsers = {} en...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/error.rb
Ruby
mit
47
main
941
# frozen_string_literal: true module KDL class Error < StandardError attr_reader :filename, :line, :column def initialize(message, filename = nil, line = nil, column = nil) message += " (#{line}:#{column})" if line message = "#{[filename, line, column].compact.join(':')}: #{message}" if filename...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/tokenizer.rb
Ruby
mit
47
main
18,866
# frozen_string_literal: true require 'bigdecimal' module KDL class Tokenizer class Token attr_reader :type, :value, :line, :column, :meta def initialize(type, value, line, column, meta = {}) @type = type @value = value @line = line @column = column @meta = m...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/value.rb
Ruby
mit
47
main
3,642
# frozen_string_literal: true module KDL class Value attr_reader :value, :format, :type def initialize(value, format: nil, type: nil) @value = value @format = format @type = type end def as_type(type, parser = nil) if parser.nil? self.class.new(value, format: format,...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/string_dumper.rb
Ruby
mit
47
main
890
# frozen_string_literal: true module KDL module StringDumper def call(string) return string if bare_identifier?(string) %("#{string.each_char.map { |char| escape(char) }.join}") end private def escape(char) case char when "\n" then '\n' when "\r" then '\r' when ...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/types.rb
Ruby
mit
47
main
494
# frozen_string_literal: true module KDL module Types MAPPING = {} end end require 'kdl/types/date_time' require 'kdl/types/duration' require 'kdl/types/currency' require 'kdl/types/country' require 'kdl/types/ip' require 'kdl/types/url' require 'kdl/types/uuid' require 'kdl/types/regex' require 'kdl/types/ba...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/v1.rb
Ruby
mit
47
main
219
# frozen_string_literal: true require "kdl/v1/tokenizer" require "kdl/v1/document" require "kdl/v1/value" require "kdl/v1/node" require "kdl/v1/string_dumper" require "kdl/v1/kdl.tab" module KDL module V1 end end
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/node.rb
Ruby
mit
47
main
3,571
# frozen_string_literal: true module KDL class Node class Custom < Node def self.call(node, type) new(node.name, arguments: node.arguments, properties: node.properties, children: node.children, type:) end def version nil end def to_v1 self end ...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/document.rb
Ruby
mit
47
main
1,343
# frozen_string_literal: true module KDL class Document include Enumerable attr_accessor :nodes def initialize(nodes = []) @nodes = nodes end def [](key) case key when Integer nodes[key] when String, Symbol nodes.find { _1.name == key.to_s } else ...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/builder.rb
Ruby
mit
47
main
1,538
# frozen_string_literal: true module KDL class Builder < BasicObject class Error < ::KDL::Error; end def initialize @nesting = [] @document = Document.new end def document(&block) yield if block @document end def node(name = nil, *args, type: nil, **props, &block) ...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/v1/string_dumper.rb
Ruby
mit
47
main
638
# frozen_string_literal: true module KDL module V1 module StringDumper include ::KDL::StringDumper def call(string) %("#{string.each_char.map { |char| escape(char) }.join}") end def stringify_identifier(ident) if bare_identifier?(ident) ident else ...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/v1/document.rb
Ruby
mit
47
main
262
# frozen_string_literal: true module KDL module V1 class Document < ::KDL::Document def version 1 end def to_v1 self end def to_v2 ::KDL::Document.new(nodes.map(&:to_v2)) end end end end
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/v1/value.rb
Ruby
mit
47
main
1,924
# frozen_string_literal: true module KDL module V1 class Value < ::KDL::Value module Methods def to_s return stringify_value unless type "(#{StringDumper.stringify_identifier type})#{stringify_value}" end def ==(other) return self == other.value if ot...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/v1/tokenizer.rb
Ruby
mit
47
main
9,257
# frozen_string_literal: true module KDL module V1 class Tokenizer < KDL::Tokenizer NON_IDENTIFIER_CHARS = Regexp.escape "#{SYMBOLS.keys.join}()/\\<>[]\",#{WHITESPACE.join}#{OTHER_NON_IDENTIFIER_CHARS.join}" IDENTIFIER_CHARS = /[^#{NON_IDENTIFIER_CHARS}]/ INITIAL_IDENTIFIER_CHARS = /[^#{NON_IDE...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/v1/node.rb
Ruby
mit
47
main
572
# frozen_string_literal: true module KDL module V1 class Node < ::KDL::Node def version 1 end def to_v1 self end def to_v2 ::KDL::Node.new(name, arguments: arguments.map(&:to_v2), properties: properties.transform_values(&:to_v2), ...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/types/date_time.rb
Ruby
mit
47
main
1,137
# frozen_string_literal: true require 'time' module KDL module Types class DateTime < Value::Custom def self.call(value, type = 'date-time') return nil unless value.is_a? ::KDL::Value::String time = ::Time.iso8601(value.value) new(time, type: type) end end MAPPING['d...
github
danini-the-panini/kdl-rb
https://github.com/danini-the-panini/kdl-rb
lib/kdl/types/uuid.rb
Ruby
mit
47
main
477
# frozen_string_literal: true module KDL module Types class UUID < Value::Custom RGX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/ def self.call(value, type = 'uuid') return nil unless value.is_a? ::KDL::Value::String uuid = value.value.downcase raise Ar...