pax_global_header00006660000000000000000000000064151735103040014511gustar00rootroot0000000000000052 comment=686fcc3eda57e40998c3f77cbbe3d8e838baa7ae emancu-toml-rb-686fcc3/000077500000000000000000000000001517351030400147575ustar00rootroot00000000000000emancu-toml-rb-686fcc3/.github/000077500000000000000000000000001517351030400163175ustar00rootroot00000000000000emancu-toml-rb-686fcc3/.github/workflows/000077500000000000000000000000001517351030400203545ustar00rootroot00000000000000emancu-toml-rb-686fcc3/.github/workflows/codeql-analysis.yml000066400000000000000000000044371517351030400241770ustar00rootroot00000000000000# For most projects, this workflow file will not need changing; you simply need # to commit it to your repository. # # You may wish to alter this file to override the set of languages analyzed, # or to provide custom queries or build logic. # # ******** NOTE ******** # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # name: "CodeQL" on: push: branches: [ master ] pull_request: # The branches below must be a subset of the branches above branches: [ master ] schedule: - cron: '31 9 * * 4' jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write strategy: fail-fast: false matrix: language: [ 'ruby' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://git.io/codeql-language-support steps: - name: Checkout repository uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v3 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines # and modify them (or add more) to build your code if your project # uses a compiled language #- run: | # make bootstrap # make release - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 emancu-toml-rb-686fcc3/.github/workflows/ruby.yml000066400000000000000000000026221517351030400220620ustar00rootroot00000000000000# This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by # separate terms of service, privacy policy, and support # documentation. # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby name: CI on: push: branches: [ master ] pull_request: branches: [ master ] workflow_dispatch: schedule: - cron: '0 6 * * *' # Every day at 6 AM jobs: test: runs-on: ubuntu-latest strategy: fail-fast: false matrix: ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0', truffleruby-head] steps: - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Run tests run: bundle exec rake lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: '3.4' bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Run standardrb run: bundle exec rake standard STANDARDOPTS="--format progress" emancu-toml-rb-686fcc3/.gitignore000066400000000000000000000000501517351030400167420ustar00rootroot00000000000000*.gem .config test/tmp tmp Gemfile.lock emancu-toml-rb-686fcc3/.standard.yml000066400000000000000000000002201517351030400173520ustar00rootroot00000000000000parallel: true # default: false format: progress # default: Standard::Formatter ruby_version: 2.5 # default: RUBY_VERSION emancu-toml-rb-686fcc3/Gemfile000066400000000000000000000001061517351030400162470ustar00rootroot00000000000000# frozen_string_literal: true source "https://rubygems.org" gemspec emancu-toml-rb-686fcc3/LICENSE000066400000000000000000000020261517351030400157640ustar00rootroot00000000000000The MIT License (MIT) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. emancu-toml-rb-686fcc3/README.md000066400000000000000000000055131517351030400162420ustar00rootroot00000000000000![TOML Logo](https://github.com/toml-lang/toml/blob/main/logos/toml-100.png) toml-rb ======= [![Gem Version](https://badge.fury.io/rb/toml-rb.svg)](http://badge.fury.io/rb/toml-rb) [![Build Status](https://github.com/emancu/toml-rb/actions/workflows/ruby.yml/badge.svg)](https://github.com/emancu/toml-rb/actions/workflows/ruby.yml) [![Code Climate](https://codeclimate.com/github/emancu/toml-rb/badges/gpa.svg)](https://codeclimate.com/github/emancu/toml-rb) [![RubyGem](https://img.shields.io/gem/dt/toml-rb.svg)](https://rubygems.org/gems/toml-rb) A [TOML](https://github.com/toml-lang/toml) parser using [Citrus](http://mjackson.github.io/citrus) library. TOML specs supported: `1.0.0` Installation ------------ $ gem install toml-rb Parser Usage ------------ ```ruby require 'toml-rb' # From a file! path = File.join(File.dirname(__FILE__), 'path', 'to', 'file') TomlRB.load_file(path) # From a stream! stream = <<-EOS title = "wow!" [awesome] you = true others = false EOS TomlRB.parse(stream) # => {"title"=>"wow!", "awesome"=>{"you"=>true, "others"=>false}} # You want symbols as your keys? No problem! TomlRB.load_file(path, symbolize_keys: true) # Works the same for TomlRB.parse ``` Dumper Usage ------------ ```ruby require 'toml-rb' # Simple example TomlRB.dump( simple: true) # => "simple = true\n" # Complex example hash = { "title"=>"wow!", "awesome"=> { "you"=>true, "others"=>false } } TomlRB.dump(hash) # => "title = \"wow!\"\n[awesome]\nothers = false\nyou = true\n" ``` Contributing ------------ 1. Fork it 2. Create your feature branch `git checkout -b my-new-feature` 3. Add tests and commit your changes `git commit -am 'Add some feature'` 4. Run tests `$ rake` 5. Push the branch `git push origin my-new-feature` 6. Create new Pull Request License ------- MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. emancu-toml-rb-686fcc3/Rakefile000066400000000000000000000002021517351030400164160ustar00rootroot00000000000000require "rake/testtask" require "standard/rake" Rake::TestTask.new do |t| t.pattern = "test/*_test.rb" end task default: :test emancu-toml-rb-686fcc3/lib/000077500000000000000000000000001517351030400155255ustar00rootroot00000000000000emancu-toml-rb-686fcc3/lib/toml-rb.rb000066400000000000000000000052551517351030400174350ustar00rootroot00000000000000require "citrus" require_relative "toml-rb/errors" require_relative "toml-rb/array" require_relative "toml-rb/string" require_relative "toml-rb/datetime" require_relative "toml-rb/table" require_relative "toml-rb/table_array" require_relative "toml-rb/inline_table" require_relative "toml-rb/keyvalue" require_relative "toml-rb/parser" require_relative "toml-rb/dumper" File.dirname(File.expand_path(__FILE__)).tap do |root| Citrus.load "#{root}/toml-rb/grammars/helper.citrus" Citrus.load "#{root}/toml-rb/grammars/primitive.citrus" Citrus.load "#{root}/toml-rb/grammars/document.citrus" end module TomlRB # Public: Returns a hash from *TomlRB* content. # # content - TomlRB string to be parsed. # :symbolize_keys - true | false (default: false). # # # Examples # # TomlRB.parse('[group]') # # => {"group"=>{}} # # TomlRB.parse('title = "TomlRB parser"') # # => {"title"=>"TomlRB parser"} # # TomlRB.parse('[group]', symbolize_keys: true) # # => {group: {}} # # TomlRB.parse('title = "TomlRB parser"', symbolize_keys: true) # # => {title: "TomlRB parser"} # # # Returns a Ruby hash representation of the content according to TomlRB spec. # Raises ValueOverwriteError if a key is overwritten. # Raises ParseError if the content has invalid TomlRB. def self.parse(content, symbolize_keys: false) Parser.new(content, symbolize_keys: symbolize_keys).hash end # Public: Returns a hash from a *TomlRB* file. # # path - TomlRB File path # :symbolize_keys - true|false (optional). # # # Examples # # TomlRB.load_file('/tmp/simple.toml') # # => {"group"=>{}} # # TomlRB.load_file('/tmp/simple.toml', symbolize_keys: true) # # => {group: {}} # # # Returns a Ruby hash representation of the content. # Raises ValueOverwriteError if a key is overwritten. # Raises ParseError if the content has invalid TomlRB. # Raises Errno::ENOENT if the file cannot be found. # Raises Errno::EACCES if the file cannot be accessed. def self.load_file(path, symbolize_keys: false) TomlRB.parse(File.read(path), symbolize_keys: symbolize_keys) end # Public: Returns a *TomlRB* string from a Ruby Hash. # # hash - Ruby Hash to be dumped into *TomlRB* # # # Examples # # TomlRB.dump(title: 'TomlRB dump') # # => "simple = true\n" # # hash = { # "title"=>"wow!", # "awesome"=> { # "you"=>true, # "others"=>false # } # } # # TomlRB.dump(hash) # # => "title = \"wow!\"\n[awesome]\nothers = false\nyou = true\n" # # # Returns a TomlRB string representing the hash. def self.dump(hash) Dumper.new(hash).toml_str end end emancu-toml-rb-686fcc3/lib/toml-rb/000077500000000000000000000000001517351030400171015ustar00rootroot00000000000000emancu-toml-rb-686fcc3/lib/toml-rb/array.rb000066400000000000000000000002311517351030400205400ustar00rootroot00000000000000module TomlRB module ArrayParser def value elements = captures[:array_elements].first elements ? elements.value : [] end end end emancu-toml-rb-686fcc3/lib/toml-rb/datetime.rb000066400000000000000000000017671517351030400212350ustar00rootroot00000000000000module TomlRB module OffsetDateTimeParser def value skeleton = captures[:datetime_skeleton].first year, mon, day, hour, min, sec, sec_frac = skeleton.value offset = captures[:date_offset].first || "+00:00" sec = "#{sec}.#{sec_frac}".to_f Time.new(year, mon, day, hour, min, sec, offset.to_s) end end module LocalDateTimeParser def value year, mon, day = captures[:date_skeleton].first.value hour, min, sec, sec_frac = captures[:time_skeleton].first.value usec = sec_frac.to_s.ljust(6, "0") Time.local(year, mon, day, hour, min, sec, usec) end end module LocalDateParser def value year, mon, day = captures[:date_skeleton].first.value Time.local(year, mon, day) end end module LocalTimeParser def value hour, min, sec, sec_frac = captures[:time_skeleton].first.value usec = sec_frac.to_s.ljust(6, "0") Time.at(3600 * hour.to_i + 60 * min.to_i + sec.to_i, usec.to_i) end end end emancu-toml-rb-686fcc3/lib/toml-rb/dumper.rb000066400000000000000000000060121517351030400207210ustar00rootroot00000000000000# frozen_string_literal: true require "date" module TomlRB class Dumper attr_reader :toml_str def initialize(hash) @toml_str = "" visit(hash, []) end private def visit(hash, prefix, extra_brackets = false) simple_pairs, nested_pairs, table_array_pairs = sort_pairs hash if prefix.any? && (simple_pairs.any? || hash.empty?) print_prefix prefix, extra_brackets end dump_pairs simple_pairs, nested_pairs, table_array_pairs, prefix end def sort_pairs(hash) nested_pairs = [] simple_pairs = [] table_array_pairs = [] hash.keys.sort.each do |key| val = hash[key] element = [key, val] if val.is_a? Hash nested_pairs << element elsif val.is_a?(Array) && val.first.is_a?(Hash) table_array_pairs << element else simple_pairs << element end end [simple_pairs, nested_pairs, table_array_pairs] end def dump_pairs(simple, nested, table_array, prefix = []) # First add simple pairs, under the prefix dump_simple_pairs simple dump_nested_pairs nested, prefix dump_table_array_pairs table_array, prefix end def dump_simple_pairs(simple_pairs) simple_pairs.each do |key, val| key = quote_key(key) unless bare_key? key @toml_str += "#{key} = #{to_toml(val)}\n" end end def dump_nested_pairs(nested_pairs, prefix) nested_pairs.each do |key, val| key = quote_key(key) unless bare_key? key visit val, prefix + [key], false end end def dump_table_array_pairs(table_array_pairs, prefix) table_array_pairs.each do |key, val| key = quote_key(key) unless bare_key? key aux_prefix = prefix + [key] val.each do |child| print_prefix aux_prefix, true args = sort_pairs(child) << aux_prefix dump_pairs(*args) end end end def print_prefix(prefix, extra_brackets = false) new_prefix = prefix.join(".") new_prefix = "[" + new_prefix + "]" if extra_brackets @toml_str += "[" + new_prefix + "]\n" end def to_toml(obj) if obj.is_a?(Time) || obj.is_a?(DateTime) obj.strftime("%Y-%m-%dT%H:%M:%SZ") elsif obj.is_a?(Date) obj.strftime("%Y-%m-%d") elsif obj.is_a?(Regexp) obj.inspect.inspect elsif obj.is_a?(String) obj.inspect.gsub(/\\(#[$@{])/, '\1') elsif obj.is_a?(Array) "[" + obj.map(&method(:to_toml)).join(", ") + "]" else obj.inspect end end def bare_key?(key) !!key.to_s.match(/^[a-zA-Z0-9_-]+$/) end # The key needs to use quotes according to TOML specs. # Ruby representation of literals or strings, mixed with special characters # made the concatenation error-prone, luckiley the `#inspect` method returns # exactly what we need. I decided to keep the method `quote_key/1` # for readability. def quote_key(key) key.inspect end end end emancu-toml-rb-686fcc3/lib/toml-rb/errors.rb000066400000000000000000000005371517351030400207470ustar00rootroot00000000000000module TomlRB # Parent class for all TomlRB errors Error = Class.new(StandardError) # Error related to parsing. ParseError = Class.new(Error) # Overwrite error class ValueOverwriteError < Error attr_accessor :key def initialize(key) @key = key super("Key #{key.inspect} is defined more than once") end end end emancu-toml-rb-686fcc3/lib/toml-rb/grammars/000077500000000000000000000000001517351030400207125ustar00rootroot00000000000000emancu-toml-rb-686fcc3/lib/toml-rb/grammars/document.citrus000066400000000000000000000024231517351030400237640ustar00rootroot00000000000000grammar TomlRB::Document include TomlRB::Primitive rule document (comment | table_array | table | keyvalue | line_break)* end rule table_array (space? '[[' stripped_key ']]' comment?) end rule table (space? '[' stripped_key ']' comment?) end rule keyvalue (stripped_key '=' space? v:(toml_values) comment? space) end ### Values rule inline_table (space? '{' array_comments (keyvalue (array_comments ',' array_comments keyvalue)* (array_comments ',')?)? array_comments '}' ) end rule array ("[" array_comments (array_elements)? space ","? array_comments "]" indent?) end rule array_array (array (space "," array_comments array)*) { captures[:array].map(&:value) } end rule array_elements (toml_values (indent? "," array_comments toml_values)*) { captures[:toml_values].map(&:value).map do |v| v.respond_to?(:value) ? v.value : v end } end ### Helpers rule stripped_key (space? key space?) { captures[:key].first.value } end rule array_comments (indent? (comment indent?)*) end rule toml_values primitive | inline_table | array end end emancu-toml-rb-686fcc3/lib/toml-rb/grammars/helper.citrus000066400000000000000000000003641517351030400234270ustar00rootroot00000000000000grammar TomlRB::Helper rule comment (space? "#" (~line_break)* line_break?) { nil } end rule space [ \t]* end rule indent [ \t\r\n]* end rule line_break (space "\n" space | space "\r\n" space) { nil } end end emancu-toml-rb-686fcc3/lib/toml-rb/grammars/primitive.citrus000066400000000000000000000062051517351030400241600ustar00rootroot00000000000000grammar TomlRB::Primitive include TomlRB::Helper rule primitive datetime | bool | number | string end ## # String rules ## rule string multiline_string | multiline_literal | basic_string | literal_string end rule basic_string (/(["])(?:\\?.)*?\1/ space) end rule literal_string (/(['])(?:\\?.)*?\1/ space) end rule multiline_string ('"""' line_break* (text:~('"""' !'"')|'') '"""' space) end rule multiline_literal ("'''" line_break* (text:~("'''" !"'")|'') "'''" space) end ## # Date time rules ## rule datetime offset_datetime | local_datetime | local_date | local_time end rule offset_datetime ( skeleton:datetime_skeleton ("Z" | date_offset) ) end rule local_datetime datetime_skeleton end rule local_date (date_skeleton space) end rule local_time (time_skeleton space) end rule datetime_skeleton (date_skeleton ("T"|" ") time_skeleton) { capture(:date_skeleton).value + capture(:time_skeleton).value } end rule date_skeleton (year:/\d\d\d\d/ "-" mon:/\d\d/ "-" day:/\d\d/) { [:year,:mon,:day].map{ |s| capture(s).value } } end rule time_skeleton ( hour:([0-2][0-9]) ":" mim:([0-6][0-9]) ":" sec:([0-6][0-9]) ([,\.] sec_frac:(/\d/1*6))? ) { [:hour,:mim,:sec].map{ |s| capture(s).value } + [capture(:sec_frac) || '0'] } end rule date_offset offset:(sign /\d\d/ ":" /\d\d/) end ## # Number rules ## rule number float | integer end rule float inf | nan | exponential_float | fractional_float end rule inf (s:sign? 'inf') { sign = (capture(:s).value != '-') ? 1 : -1 sign * Float::INFINITY } end rule nan (sign? 'nan') { Float::NAN } end rule exponential_float ((fractional_float | decimal_integer) [eE] decimal_integer) { to_str.to_f } end rule fractional_float (decimal_integer '.' [0-9] ([0-9] | '_' [0-9])*) { to_str.to_f } end rule integer hexadecimal_integer | octal_integer | binary_integer | decimal_integer end rule hexadecimal_integer ('0x' [a-fA-F0-9] ([a-fA-F0-9] | '_' [a-fA-F0-9])*) { to_str.to_i(16) } end rule octal_integer ('0o' [0-7] ([0-7] | '_' [0-7])*) { to_str.to_i(8) } end rule binary_integer ('0b' [01] ([01] | '_' [01])*) { to_str.to_i(2) } end rule decimal_integer (sign? [0-9] ([0-9] | '_' [0-9])*) { to_str.to_i } end rule sign '+' | '-' end ## # Boolean rules ## rule bool true | false end rule true 'true' { true } end rule false 'false' { false } end ## # Key rules ## rule key dotted_key end rule bare_key [a-zA-Z0-9_-]+ end rule quoted_key basic_string | literal_string end rule single_key quoted_key | bare_key end rule dotted_key (space? single_key space? ("." space? single_key space?)* ) { captures[:single_key].map(&:value) } end end emancu-toml-rb-686fcc3/lib/toml-rb/inline_table.rb000066400000000000000000000010601517351030400220500ustar00rootroot00000000000000module TomlRB class InlineTable def initialize(keyvalue_pairs) @pairs = keyvalue_pairs end def accept_visitor(keyvalue) value keyvalue.symbolize_keys end def value(symbolize_keys = false) result = {} @pairs.each do |kv| update = kv.assign({}, [], symbolize_keys) result.merge!(update) { |key, _, _| fail ValueOverwriteError.new(key) } end result end end module InlineTableParser def value TomlRB::InlineTable.new(captures[:keyvalue].map(&:value)) end end end emancu-toml-rb-686fcc3/lib/toml-rb/keyvalue.rb000066400000000000000000000034721517351030400212610ustar00rootroot00000000000000require_relative "inline_table" module TomlRB class Keyvalue attr_reader :dotted_keys, :value, :symbolize_keys def initialize(dotted_keys, value) @dotted_keys = dotted_keys @value = value @symbolize_keys = false end def assign(hash, fully_defined_paths, symbolize_keys = false) @symbolize_keys = symbolize_keys keys = symbolize_keys ? @dotted_keys.map(&:to_sym) : @dotted_keys depth = @dotted_keys.size update = keys.reverse.inject(visit_value(@value)) { |k1, k2| {k2 => k1} } parent_inline_table = fully_defined_paths.find { |k| k.size < depth && @dotted_keys.first(k.size) == k } fail ValueOverwriteError.new(@dotted_keys.first) if parent_inline_table if @value.is_a?(InlineTable) child_keys_exist = fully_defined_paths.find { |k| k.size > depth && k.first(depth) == @dotted_keys } fail ValueOverwriteError.new(@dotted_keys.first) if child_keys_exist existing_hash = hash.dig(*keys) fail ValueOverwriteError.new(@dotted_keys.first) if existing_hash.is_a?(Hash) && !existing_hash.empty? fully_defined_paths << @dotted_keys end dotted_key_merge(hash, update) end def dotted_key_merge(hash, update) hash.merge!(update) do |key, old, new| if old.is_a?(Hash) && new.is_a?(Hash) dotted_key_merge(old, new) else fail ValueOverwriteError.new(key) end end end def accept_visitor(parser) parser.visit_keyvalue self end private def visit_value(a_value) return a_value unless a_value.respond_to? :accept_visitor a_value.accept_visitor self end end # Used in document.citrus module KeyvalueParser def value TomlRB::Keyvalue.new(capture(:stripped_key).value, capture(:v).value) end end end emancu-toml-rb-686fcc3/lib/toml-rb/parser.rb000066400000000000000000000026441517351030400207300ustar00rootroot00000000000000module TomlRB class Parser attr_reader :hash def initialize(content, symbolize_keys: false) @hash = {} @visited_keys = [] @fully_defined_paths = [] @current = @hash @symbolize_keys = symbolize_keys begin parsed = TomlRB::Document.parse(content) parsed.matches.map(&:value).compact.each { |m| m.accept_visitor(self) } rescue Citrus::ParseError => e raise TomlRB::ParseError.new(e.message) rescue Encoding::CompatibilityError => e raise TomlRB::ParseError.new("Encoding error: #{e.message}") rescue ArgumentError => e if e.message.include?("invalid byte sequence") || e.message.include?("encoding") raise TomlRB::ParseError.new("Encoding error: #{e.message}") else raise end end end # Read about the Visitor pattern # http://en.wikipedia.org/wiki/Visitor_pattern def visit_table_array(table_array) @fully_defined_paths = [] table_array_key = table_array.full_key @visited_keys.reject! { |k| k.start_with? table_array_key } @current = table_array.navigate_keys @hash, @symbolize_keys end def visit_table(table) @fully_defined_paths = [] @current = table.navigate_keys @hash, @visited_keys, @symbolize_keys end def visit_keyvalue(keyvalue) keyvalue.assign @current, @fully_defined_paths, @symbolize_keys end end end emancu-toml-rb-686fcc3/lib/toml-rb/string.rb000066400000000000000000000027041517351030400207370ustar00rootroot00000000000000module TomlRB # Used in primitive.citrus module BasicString SPECIAL_CHARS = { "\\0" => "\0", "\\t" => "\t", "\\b" => "\b", "\\f" => "\f", "\\n" => "\n", "\\r" => "\r", '\\"' => '"', "\\\\" => "\\" }.freeze def value aux = TomlRB::BasicString.transform_escaped_chars first.value aux[1...-1] end # Replace the unicode escaped characters with the corresponding character # e.g. \u03B4 => ? def self.decode_unicode(str) [str[2..-1].to_i(16)].pack("U") end def self.transform_escaped_chars(str) str.gsub(/\\(u[\da-fA-F]{4}|U[\da-fA-F]{8}|.)/) do |m| if m.size == 2 SPECIAL_CHARS[m] || parse_error(m) else decode_unicode(m).force_encoding("UTF-8") end end end def self.parse_error(m) fail ParseError.new "Escape sequence #{m} is reserved" end end module LiteralString def value first.value[1...-1] end end module MultilineString def value return "" if captures[:text].empty? aux = captures[:text].first.value # Remove spaces on multilined Singleline strings aux.gsub!(/\\\r?\n[\n\t\r ]*/, "") TomlRB::BasicString.transform_escaped_chars aux end end module MultilineLiteral def value return "" if captures[:text].empty? aux = captures[:text].first.value aux.gsub(/\\\r?\n[\n\t\r ]*/, "") end end end emancu-toml-rb-686fcc3/lib/toml-rb/table.rb000066400000000000000000000026411517351030400205200ustar00rootroot00000000000000module TomlRB class Table def initialize(dotted_keys) @dotted_keys = dotted_keys end def navigate_keys(hash, visited_keys, symbolize_keys = false) ensure_key_not_defined(visited_keys) current = hash keys = symbolize_keys ? @dotted_keys.map(&:to_sym) : @dotted_keys keys.each_with_index do |key, index| current[key] = {} unless current.key?(key) element = current[key] # If this is the final key and it's already an array (from [[key]]), that's invalid is_final_key = (index == keys.length - 1) if is_final_key && element.is_a?(Array) fail ValueOverwriteError.new(key) end current = element.is_a?(Array) ? element.last : element # check that key has not been defined before as a scalar value fail ValueOverwriteError.new(key) unless current.is_a?(Hash) end current end def accept_visitor(parser) parser.visit_table self end def full_key @dotted_keys.join(".") end private # Fail if the key was already defined with a ValueOverwriteError def ensure_key_not_defined(visited_keys) fail ValueOverwriteError.new(full_key) if visited_keys.include?(full_key) visited_keys << full_key end end # Used in document.citrus module TableParser def value TomlRB::Table.new(captures[:stripped_key].map(&:value).first) end end end emancu-toml-rb-686fcc3/lib/toml-rb/table_array.rb000066400000000000000000000022361517351030400217160ustar00rootroot00000000000000module TomlRB class TableArray def initialize(dotted_keys) @dotted_keys = dotted_keys end def navigate_keys(hash, symbolize_keys = false) current = hash keys = symbolize_keys ? @dotted_keys.map(&:to_sym) : @dotted_keys last_key = keys.pop # Go over the parent keys keys.each do |key| current[key] = {} unless current[key] if current[key].is_a? Array current[key] << {} if current[key].empty? current = current[key].last else current = current[key] end end # Define Table Array if current[last_key].is_a? Hash fail TomlRB::ParseError, "#{last_key} was defined as hash but is now redefined as a table!" end current[last_key] = [] unless current[last_key] current[last_key] << {} current[last_key].last end def accept_visitor(parser) parser.visit_table_array self end def full_key @dotted_keys.join(".") end end # Used in document.citrus module TableArrayParser def value TomlRB::TableArray.new(captures[:stripped_key].map(&:value).first) end end end emancu-toml-rb-686fcc3/lib/toml-rb/version.rb000066400000000000000000000001051517351030400211070ustar00rootroot00000000000000# frozen_string_literal: true module TomlRB VERSION = "4.2.0" end emancu-toml-rb-686fcc3/test/000077500000000000000000000000001517351030400157365ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/dumper_test.rb000066400000000000000000000100271517351030400206160ustar00rootroot00000000000000require_relative "helper" require "date" class DumperTest < Minitest::Test def test_dump_empty dumped = TomlRB.dump({}) assert_equal("", dumped) end def test_dump_types dumped = TomlRB.dump(string: 'TomlRB "dump"') assert_equal("string = \"TomlRB \\\"dump\\\"\"\n", dumped) dumped = TomlRB.dump(float: -13.24) assert_equal("float = -13.24\n", dumped) dumped = TomlRB.dump(int: 1234) assert_equal("int = 1234\n", dumped) dumped = TomlRB.dump(truthy: true) assert_equal("truthy = true\n", dumped) dumped = TomlRB.dump(falsey: false) assert_equal("falsey = false\n", dumped) dumped = TomlRB.dump(array: [1, 2, 3]) assert_equal("array = [1, 2, 3]\n", dumped) dumped = TomlRB.dump(array: [[1, 2], %w[weird one]]) assert_equal("array = [[1, 2], [\"weird\", \"one\"]]\n", dumped) dumped = TomlRB.dump(array: %w[#$ #@ #{}]) assert_equal("array = [\"\#$\", \"\#@\", \"\#{}\"]\n", dumped) dumped = TomlRB.dump(time: Time.utc(1986, 8, 28, 15, 15)) assert_equal("time = 1986-08-28T15:15:00Z\n", dumped) dumped = TomlRB.dump(datetime: DateTime.new(1986, 8, 28, 15, 15)) assert_equal("datetime = 1986-08-28T15:15:00Z\n", dumped) dumped = TomlRB.dump(date: Date.new(1986, 8, 28)) assert_equal("date = 1986-08-28\n", dumped) dumped = TomlRB.dump(regexp: /abc\n*\{/) assert_equal("regexp = \"/abc\\\\n*\\\\{/\"\n", dumped) end def test_dump_nested_attributes hash = {nested: {hash: {deep: true}}} dumped = TomlRB.dump(hash) assert_equal("[nested.hash]\ndeep = true\n", dumped) hash[:nested][:other] = 12 dumped = TomlRB.dump(hash) assert_equal("[nested]\nother = 12\n[nested.hash]\ndeep = true\n", dumped) hash[:nested][:nest] = {again: "it never ends"} dumped = TomlRB.dump(hash) toml = <<-EOS.gsub(/^ {6}/, "") [nested] other = 12 [nested.hash] deep = true [nested.nest] again = "it never ends" EOS assert_equal(toml, dumped) hash = {non: {'bare."keys"' => {"works" => true}}} dumped = TomlRB.dump(hash) assert_equal("[non.\"bare.\\\"keys\\\"\"]\nworks = true\n", dumped) hash = {hola: [{chau: 4}, {chau: 3}]} dumped = TomlRB.dump(hash) assert_equal("[[hola]]\nchau = 4\n[[hola]]\nchau = 3\n", dumped) end def test_print_empty_tables hash = {plugins: {cpu: {foo: "bar", baz: 1234}, disk: {}, io: {}}} dumped = TomlRB.dump(hash) toml = <<-EOS.gsub(/^ {6}/, "") [plugins.cpu] baz = 1234 foo = "bar" [plugins.disk] [plugins.io] EOS assert_equal toml, dumped end def test_dump_array_tables hash = {fruit: [{physical: {color: "red"}}, {physical: {color: "blue"}}]} dumped = TomlRB.dump(hash) toml = <<-EOS.gsub(/^ {6}/, "") [[fruit]] [fruit.physical] color = "red" [[fruit]] [fruit.physical] color = "blue" EOS assert_equal toml, dumped end def test_dump_interpolation_curly hash = {"key" => "includes \#{variable}"} dumped = TomlRB.dump(hash) assert_equal %(key = "includes \#{variable}") + "\n", dumped end def test_dump_interpolation_at hash = {"key" => 'includes #@variable'} dumped = TomlRB.dump(hash) assert_equal 'key = "includes #@variable"' + "\n", dumped end def test_dump_interpolation_dollar hash = {"key" => 'includes #$variable'} dumped = TomlRB.dump(hash) assert_equal 'key = "includes #$variable"' + "\n", dumped end def test_dump_special_chars_in_literals hash = {'\t' => "escape special chars in string literals"} dumped = TomlRB.dump(hash) assert_equal %("\\\\t" = "escape special chars in string literals") + "\n", dumped end def test_dump_special_chars_in_strings hash = {"\t" => "escape special chars in strings"} dumped = TomlRB.dump(hash) assert_equal %("\\t" = "escape special chars in strings") + "\n", dumped end def test_dump_empty_key hash = {"" => "empty key"} dumped = TomlRB.dump(hash) assert_equal %("" = "empty key") + "\n", dumped end end emancu-toml-rb-686fcc3/test/encoding_test.rb000066400000000000000000000023611517351030400211120ustar00rootroot00000000000000require_relative "helper" class EncodingTest < Minitest::Test def test_binary_data_raises_parse_error binary_data = String.new("\x80\x81\x82", encoding: "ASCII-8BIT") assert_raises(TomlRB::ParseError) do TomlRB.parse(binary_data) end end def test_comment_with_high_bytes_raises_parse_error # This triggers Encoding::CompatibilityError in Citrus # which should be wrapped in TomlRB::ParseError data = String.new("# \xFF\xFE comment\nkey = 1", encoding: "ASCII-8BIT") assert_raises(TomlRB::ParseError) do TomlRB.parse(data) end end def test_invalid_utf8_sequence_raises_parse_error invalid_utf8 = String.new("key = \"\xC3\x28\"", encoding: "UTF-8") error = assert_raises(TomlRB::Error) do TomlRB.parse(invalid_utf8) end assert_match(/encoding/i, error.message) end def test_valid_ascii_8bit_toml_parses valid_ascii = String.new('key = "value"', encoding: "ASCII-8BIT") result = TomlRB.parse(valid_ascii) assert_equal({"key" => "value"}, result) end def test_null_bytes_raise_parse_error data_with_nulls = String.new("key\x00=\x00value", encoding: "ASCII-8BIT") assert_raises(TomlRB::ParseError) do TomlRB.parse(data_with_nulls) end end end emancu-toml-rb-686fcc3/test/errors_test.rb000066400000000000000000000050621517351030400206410ustar00rootroot00000000000000require_relative "helper" class ErrorsTest < Minitest::Test def test_text_after_table str = "[error] if you didn't catch this, your parser is broken" assert_raises(TomlRB::ParseError) { TomlRB.parse(str) } end def test_text_after_string str = 'string = "Anything other than tabs, spaces and newline after a ' str += "table or key value pair has ended should produce an error " str += 'unless it is a comment" like this' assert_raises(TomlRB::ParseError) { TomlRB.parse(str) } end def test_multiline_array_bad_string str = <<-EOS array = [ "This might most likely happen in multiline arrays", Like here, "or here, and here" ] End of array comment, forgot the # EOS assert_raises(TomlRB::ParseError) { TomlRB.parse(str) } end def test_multiline_array_string_not_ended str = <<-EOS array = [ "This might most likely happen in multiline arrays", "or here, and here" ] End of array comment, forgot the # EOS assert_raises(TomlRB::ParseError) { TomlRB.parse(str) } end def test_text_after_multiline_array str = <<-EOS array = [ "This might most likely happen in multiline arrays", "or here", "and here" ] End of array comment, forgot the # EOS assert_raises(TomlRB::ParseError) { TomlRB.parse(str) } end def test_text_after_number str = "number = 3.14 pi <--again forgot the #" assert_raises(TomlRB::ParseError) { TomlRB.parse(str) } end def test_value_overwrite str = "a = 1\na = 2" e = assert_raises(TomlRB::ValueOverwriteError) { TomlRB.parse(str) } assert_equal "Key \"a\" is defined more than once", e.message assert_equal "a", e.key str = "a = false\na = true" assert_raises(TomlRB::ValueOverwriteError) { TomlRB.parse(str) } end def test_table_overwrite str = "[a]\nb=1\n[a]\nc=2" e = assert_raises(TomlRB::ValueOverwriteError) { TomlRB.parse(str) } assert_equal "Key \"a\" is defined more than once", e.message str = "[a]\nb=1\n[a]\nb=1" e = assert_raises(TomlRB::ValueOverwriteError) { TomlRB.parse(str) } assert_equal "Key \"a\" is defined more than once", e.message end def test_value_overwrite_with_table str = "[a]\nb=1\n[a.b]\nc=2" e = assert_raises(TomlRB::ValueOverwriteError) { TomlRB.parse(str) } assert_equal "Key \"b\" is defined more than once", e.message str = "[a]\nb=1\n[a.b.c]\nd=3" e = assert_raises(TomlRB::ValueOverwriteError) { TomlRB.parse(str) } assert_equal "Key \"b\" is defined more than once", e.message end end emancu-toml-rb-686fcc3/test/example-v0.4.0.toml000066400000000000000000000121731517351030400211150ustar00rootroot00000000000000################################################################################ ## Comment # Speak your mind with the hash symbol. They go from the symbol to the end of # the line. ################################################################################ ## Table # Tables (also known as hash tables or dictionaries) are collections of # key/value pairs. They appear in square brackets on a line by themselves. [table] key = "value" # Yeah, you can do this. # Nested tables are denoted by table names with dots in them. Name your tables # whatever crap you please, just don't use #, ., [ or ]. [table.subtable] key = "another value" # You don't need to specify all the super-tables if you don't want to. TomlRB # knows how to do it for you. # [x] you # [x.y] don't # [x.y.z] need these [x.y.z.w] # for this to work ################################################################################ ## Inline Table # Inline tables provide a more compact syntax for expressing tables. They are # especially useful for grouped data that can otherwise quickly become verbose. # Inline tables are enclosed in curly braces `{` and `}`. No newlines are # allowed between the curly braces unless they are valid within a value. [table.inline] name = { first = "Tom", last = "Preston-Werner" } point = { x = 1, y = 2 } ################################################################################ ## String # There are four ways to express strings: basic, multi-line basic, literal, and # multi-line literal. All strings must contain only valid UTF-8 characters. [string.basic] basic = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." [string.multiline] # The following strings are byte-for-byte equivalent: key1 = "One\nTwo" key2 = """One\nTwo""" key3 = """ One Two""" [string.multiline.continued] # The following strings are byte-for-byte equivalent: key1 = "The quick brown fox jumps over the lazy dog." key2 = """ The quick brown \ fox jumps over \ the lazy dog.""" key3 = """\ The quick brown \ fox jumps over \ the lazy dog.\ """ [string.literal] # What you see is what you get. winpath = 'C:\Users\nodejs\templates' winpath2 = '\\ServerX\admin$\system32\' quoted = 'Tom "Dubs" Preston-Werner' regex = '<\i\c*\s*>' [string.literal.multiline] regex2 = '''I [dw]on't need \d{2} apples''' lines = ''' The first newline is trimmed in raw strings. All other whitespace is preserved. ''' ################################################################################ ## Integer # Integers are whole numbers. Positive numbers may be prefixed with a plus sign. # Negative numbers are prefixed with a minus sign. [integer] key1 = +99 key2 = 42 key3 = 0 key4 = -17 [integer.underscores] # For large numbers, you may use underscores to enhance readability. Each # underscore must be surrounded by at least one digit. key1 = 1_000 key2 = 5_349_221 key3 = 1_2_3_4_5 # valid but inadvisable ################################################################################ ## Float # A float consists of an integer part (which may be prefixed with a plus or # minus sign) followed by a fractional part and/or an exponent part. [float.fractional] key1 = +1.0 key2 = 3.1415 key3 = -0.01 [float.exponent] key1 = 5e+22 key2 = 1e6 key3 = -2E-2 [float.both] key = 6.626e-34 [float.underscores] key1 = 9_224_617.445_991_228_313 key2 = 1e1_00 ################################################################################ ## Boolean # Booleans are just the tokens you're used to. Always lowercase. [boolean] True = true False = false ################################################################################ ## Datetime # Datetimes are RFC 3339 dates. [datetime] key1 = 1979-05-27T07:32:00Z key2 = 1979-05-27T00:32:00-07:00 key3 = 1979-05-27T00:32:00.999999-07:00 ################################################################################ ## Array # Arrays are square brackets with other primitives inside. Whitespace is # ignored. Elements are separated by commas. Data types may not be mixed. [array] key1 = [ 1, 2, 3 ] key2 = [ "red", "yellow", "green" ] key3 = [ [ 1, 2 ], [3, 4, 5] ] key4 = [ [ 1, 2 ], ["a", "b", "c"] ] # this is ok # Arrays can also be multiline. So in addition to ignoring whitespace, arrays # also ignore newlines between the brackets. Terminating commas are ok before # the closing bracket. key5 = [ 1, 2, 3 ] key6 = [ 1, 2, # this is ok ] ################################################################################ ## Array of Tables # These can be expressed by using a table name in double brackets. Each table # with the same double bracketed name will be an element in the array. The # tables are inserted in the order encountered. [[products]] name = "Hammer" sku = 738594937 [[products]] [[products]] name = "Nail" sku = 284758393 color = "gray" # You can create nested arrays of tables as well. [[fruit]] name = "apple" [fruit.physical] color = "red" shape = "round" [[fruit.variety]] name = "red delicious" [[fruit.variety]] name = "granny smith" [[fruit]] name = "banana" [[fruit.variety]] name = "plantain" emancu-toml-rb-686fcc3/test/example-v0.5.0.toml000066400000000000000000000227771517351030400211310ustar00rootroot00000000000000[keys] # Bare keys may only contain ASCII letters, ASCII digits, # underscores, and dashes (A-Za-z0-9_-). # Note that bare keys are allowed to be composed of only ASCII digits, # e.g. 1234, but are always interpreted as strings. key = "value" bare_key = "value" bare-key = "value" 1234 = "value" # Quoted keys follow the exact same rules as either basic strings # or literal strings and allow you to use a much broader set of key names. # Best practice is to use bare keys except when absolutely necessary. "127.0.0.1" = "value" "character encoding" = "value" "ʎǝʞ" = "value" 'key2' = "value" 'quoted "value"' = "value" # Dotted keys are a sequence of bare or quoted keys joined with a dot. # This allows for grouping similar properties together: name = "Orange" physical.color = "orange" physical.shape = "round" site."google.com" = true # Since bare keys are allowed to compose of only ASCII integers, # it is possible to write dotted keys that look like floats # but are 2-part dotted keys. # Don't do this unless you have a good reason to (you probably don't). 3.14159 = "pi" # As long as a key hasn't been directly defined, # you may still write to it and to names within it. a.b.c = 1 a.d = 2 # Defining dotted keys out-of-order is discouraged. # VALID BUT DISCOURAGED a.type = '' b.type = '' a.name = '' b.name = '' a.data = '' b.data = '' [string] # Multi-line basic strings are surrounded by three quotation marks # on each side and allow newlines. # A newline immediately following the opening delimiter will be trimmed. # All other whitespace and newline characters remain intact. str1 = """ Roses are red Violets are blue""" # On a Unix system, the above multi-line string will most likely be the same as: str2 = "Roses are red\nViolets are blue" # On a Windows system, it will most likely be equivalent to: str3 = "Roses are red\r\nViolets are blue" # All of the escape sequences that are valid for basic strings are # also valid for multi-line basic strings. same.str1 = "The quick brown fox jumps over the lazy dog." same.str2 = """ The quick brown \ fox jumps over \ the lazy dog.""" same.str3 = """\ The quick brown \ fox jumps over \ the lazy dog.\ """ # Literal strings are surrounded by single quotes. # Like basic strings, they must appear on a single line: winpath = 'C:\Users\nodejs\templates' winpath2 = '\\ServerX\admin$\system32\' quoted = 'Tom "Dubs" Preston-Werner' regex = '<\i\c*\s*>' # Multi-line literal strings are surrounded by three single quotes # on each side and allow newlines. Like literal strings, # there is no escaping whatsoever. # A newline immediately following the opening delimiter will be trimmed. # All other content between the delimiters is # interpreted as-is without modification. regex2 = '''I [dw]on't need \d{2} apples''' lines = ''' The first newline is trimmed in raw strings. All other whitespace is preserved. ''' [integer] # Integers are whole numbers. # Positive numbers may be prefixed with a plus sign. # Negative numbers are prefixed with a minus sign. int1 = +99 int2 = 42 int3 = 0 int4 = -17 # For large numbers, you may use underscores between digits # to enhance readability. # Each underscore must be surrounded by at least one digit on each side. int5 = 1_000 int6 = 5_349_221 int7 = 1_2_3_4_5 # Non-negative integer values may also be expressed # in hexadecimal, octal, or binary. # In these formats, leading + is not allowed and leading zeros are # allowed (after the prefix). # Hex values are case insensitive. # Underscores are allowed between digits # (but not between the prefix and the value). # hexadecimal with prefix `0x` hex1 = 0xDEADBEEF hex2 = 0xdeadbeef hex3 = 0xdead_beef # octal with prefix `0o` oct1 = 0o01234567 oct2 = 0o755 # useful for Unix file permissions # binary with prefix `0b` bin1 = 0b11010110 [float] # Floats should be implemented as IEEE 754 binary64 values. # A float consists of an integer part # (which follows the same rules as decimal integer values) followed # by a fractional part and/or an exponent part. # If both a fractional part and exponent part are present, # the fractional part must precede the exponent part. # fractional flt1 = +1.0 flt2 = 3.1415 flt3 = -0.01 # exponent flt4 = 5e+22 flt5 = 1e06 flt6 = -2E-2 # both flt7 = 6.626e-34 # Similar to integers, you may use underscores to enhance readability. # Each underscore must be surrounded by at least one digit. flt8 = 224_617.445_991_228 # Float values -0.0 and +0.0 are valid and should map according to IEEE 754. flt9 = -0.0 flt10 = +0.0 # Special float values can also be expressed. They are always lowercase. # infinity sf1 = inf # positive infinity sf2 = +inf # positive infinity sf3 = -inf # negative infinity # not a number sf4 = nan # actual sNaN/qNaN encoding is implementation specific sf5 = +nan # same as `nan` sf6 = -nan # valid, actual encoding is implementation specific [boolean] # Booleans are just the tokens you're used to. Always lowercase. bool1 = true bool2 = false [offset-date-time] # To unambiguously represent a specific instant in time, # you may use an RFC 3339 formatted date-time with offset. odt1 = 1979-05-27T07:32:00Z odt2 = 1979-05-27T00:32:00-07:00 odt3 = 1979-05-27T00:32:00.999999-07:00 # For the sake of readability, you may replace the T delimiter # between date and time with a space (as permitted by RFC 3339 section 5.6). odt4 = 1979-05-27 07:32:00Z [local-date-time] # If you omit the offset from an RFC 3339 formatted date-time, # it will represent the given date-time without any relation # to an offset or timezone. # It cannot be converted to an instant in time without additional information. # Conversion to an instant, if required, is implementation specific. ldt1 = 1979-05-27T07:32:00 ldt2 = 1979-05-27T00:32:00.999999 [local-date] # If you include only the date portion of an RFC 3339 formatted date-time, # it will represent that entire day without any relation # to an offset or timezone. ld1 = 1979-05-27 [local-time] # If you include only the time portion of an RFC 3339 formatted date-time, # it will represent that time of day without any relation to a specific day # or any offset or timezone. lt1 = 07:32:00 lt2 = 00:32:00.999999 [array] # Arrays are square brackets with values inside. # Whitespace is ignored. Elements are separated by commas. # Data types may not be mixed (different ways to define strings # should be considered the same type, # and so should arrays with different element types). arr1 = [ 1, 2, 3 ] arr2 = [ "red", "yellow", "green" ] arr3 = [ [ 1, 2 ], [3, 4, 5] ] arr4 = [ "all", 'strings', """are the same""", '''type'''] arr5 = [ [ 1, 2 ], ["a", "b", "c"] ] # Arrays can also be multiline. # A terminating comma (also called trailing comma) is # ok after the last value of the array. # There can be an arbitrary number of newlines and comments # before a value and before the closing bracket. arr7 = [ 1, 2, 3 ] arr8 = [ 1, 2, # this is ok ] [table] # Tables (also known as hash tables or dictionaries) are # collections of key/value pairs. # They appear in square brackets on a line by themselves. # You can tell them apart from arrays because arrays are only ever values. # Under that, and until the next table or EOF are the key/values of that table. # Key/value pairs within tables are not guaranteed to be in any specific order. [table.table-1] key1 = "some string" key2 = 123 [table.table-2] key1 = "another string" key2 = 456 # Naming rules for tables are the same as for keys (see definition of Keys above). [table.dog."tater.man"] type.name = "pug" # Whitespace around the key is ignored, however, best practice is to not use any extraneous whitespace. [table.a.b.c] # this is best practice [ table.d.e.f ] # same as [d.e.f] [ table . g . h . i ] # same as [g.h.i] [ table . j . "ʞ" . 'l' ] # same as [j."ʞ".'l'] # You don't need to specify all the super-tables if you don't want to. # TOML knows how to do it for you. # [x] you # [x.y] don't # [x.y.z] need these [table.x.y.z.w] # for this to work [table.x] # defining a super-table afterwards is ok # Defining tables out-of-order is discouraged. # VALID BUT DISCOURAGED [table.a.x] [table.b] [table.a.y] # Dotted keys define everything to the left of each dot as a table. # Since tables cannot be defined more than once, # redefining such tables using a [table] header is not allowed. # Likewise, using dotted keys to redefine tables already defined # in [table] form is not allowed. # The [table] form can, however, # be used to define sub-tables within tables defined via dotted keys. [table.fruit] apple.color = "red" apple.taste.sweet = true # [table.fruit.apple] # INVALID # [table.fruit.apple.taste] # INVALID [table.fruit.apple.texture] # you can add sub-tables smooth = true [inline-table] # Inline tables provide a more compact syntax for expressing tables. name = { first = "Tom", last = "Preston-Werner" } point = { x = 1, y = 2 } animal = { type.name = "pug" } [array-of-tables] # Array of Tables are inserted in the order encountered. # A double bracketed table without any key/value pairs # will be considered an empty table. [[array-of-tables.products]] name = "Hammer" sku = 738594937 [[array-of-tables.products]] [[array-of-tables.products]] name = "Nail" sku = 284758393 color = "gray" [[array-of-tables.fruit]] name = "apple" [array-of-tables.fruit.physical] color = "red" shape = "round" [[array-of-tables.fruit.variety]] name = "red delicious" [[array-of-tables.fruit.variety]] name = "granny smith" [[array-of-tables.fruit]] name = "banana" [[array-of-tables.fruit.variety]] name = "plantain" emancu-toml-rb-686fcc3/test/example.toml000066400000000000000000000014671517351030400202760ustar00rootroot00000000000000# This is a TomlRB document. Boom. title = "TomlRB Example" [owner] name = "Tom Preston-Werner" organization = "GitHub" bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." dob = 1979-05-27T07:32:00Z # First class dates? Why not? [database] server = "192.168.1.1" ports = [ 8001, 8001, 8002 ] connection_max = 5000 enabled = true [servers] # You can indent as you please. Tabs or spaces. TomlRB don't care. [servers.alpha] ip = "10.0.0.1" dc = "eqdc10" [servers.beta] ip = "10.0.0.2" dc = "eqdc10" [clients] data = [ ["gamma", "delta"], [1, 2] ] # Line breaks are OK when inside arrays hosts = [ "alpha", "omega" ] [amqp] exchange = {durable = true, auto_delete = false} [[products]] name = "Hammer" sku = 738594937 [[products]] [[products]] name = "Nail" sku = 284758393 color = "gray" emancu-toml-rb-686fcc3/test/examples/000077500000000000000000000000001517351030400175545ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/000077500000000000000000000000001517351030400212025ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/array/000077500000000000000000000000001517351030400223205ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/array/double-comma-1.toml000066400000000000000000000000301517351030400257100ustar00rootroot00000000000000double-comma-1 = [1,,2] emancu-toml-rb-686fcc3/test/examples/invalid/array/double-comma-2.toml000066400000000000000000000000311517351030400257120ustar00rootroot00000000000000double-comma-2 = [1,2,,] emancu-toml-rb-686fcc3/test/examples/invalid/array/extend-defined-aot.toml000066400000000000000000000000351517351030400266570ustar00rootroot00000000000000[[tab.arr]] [tab] arr.val1=1 emancu-toml-rb-686fcc3/test/examples/invalid/array/missing-separator-1.toml000066400000000000000000000000241517351030400270160ustar00rootroot00000000000000arrr = [true false] emancu-toml-rb-686fcc3/test/examples/invalid/array/missing-separator-2.toml000066400000000000000000000000221517351030400270150ustar00rootroot00000000000000wrong = [ 1 2 3 ] emancu-toml-rb-686fcc3/test/examples/invalid/array/no-close-1.toml000066400000000000000000000000271517351030400250710ustar00rootroot00000000000000no-close-1 = [ 1, 2, 3 emancu-toml-rb-686fcc3/test/examples/invalid/array/no-close-2.toml000066400000000000000000000000211517351030400250640ustar00rootroot00000000000000no-close-2 = [1, emancu-toml-rb-686fcc3/test/examples/invalid/array/no-close-3.toml000066400000000000000000000000241517351030400250700ustar00rootroot00000000000000no-close-3 = [42 #] emancu-toml-rb-686fcc3/test/examples/invalid/array/no-close-4.toml000066400000000000000000000000311517351030400250670ustar00rootroot00000000000000no-close-4 = [{ key = 42 emancu-toml-rb-686fcc3/test/examples/invalid/array/no-close-5.toml000066400000000000000000000000321517351030400250710ustar00rootroot00000000000000no-close-5 = [{ key = 42} emancu-toml-rb-686fcc3/test/examples/invalid/array/no-close-6.toml000066400000000000000000000000351517351030400250750ustar00rootroot00000000000000no-close-6 = [{ key = 42 #}] emancu-toml-rb-686fcc3/test/examples/invalid/array/no-close-7.toml000066400000000000000000000000351517351030400250760ustar00rootroot00000000000000no-close-7 = [{ key = 42} #] emancu-toml-rb-686fcc3/test/examples/invalid/array/no-close-8.toml000066400000000000000000000000171517351030400250770ustar00rootroot00000000000000no-close-8 = [ emancu-toml-rb-686fcc3/test/examples/invalid/array/no-close-table-1.toml000066400000000000000000000000201517351030400261470ustar00rootroot00000000000000x = [{ key = 42 emancu-toml-rb-686fcc3/test/examples/invalid/array/no-close-table-2.toml000066400000000000000000000000221517351030400261520ustar00rootroot00000000000000x = [{ key = 42 # emancu-toml-rb-686fcc3/test/examples/invalid/array/no-comma-1.toml000066400000000000000000000000321517351030400250540ustar00rootroot00000000000000no-comma-1 = [true false] emancu-toml-rb-686fcc3/test/examples/invalid/array/no-comma-2.toml000066400000000000000000000000271517351030400250610ustar00rootroot00000000000000no-comma-2 = [ 1 2 3 ] emancu-toml-rb-686fcc3/test/examples/invalid/array/no-comma-3.toml000066400000000000000000000000251517351030400250600ustar00rootroot00000000000000no-comma-3 = [ 1 #,] emancu-toml-rb-686fcc3/test/examples/invalid/array/tables-2.toml000066400000000000000000000002741517351030400246310ustar00rootroot00000000000000# INVALID TOML DOC [[fruit]] name = "apple" [[fruit.variety]] name = "red delicious" # This table conflicts with the previous table [fruit.variety] name = "granny smith" emancu-toml-rb-686fcc3/test/examples/invalid/array/text-after-array-entries.toml000066400000000000000000000001061517351030400300600ustar00rootroot00000000000000array = [ "Is there life after an array separator?", No "Entry" ] emancu-toml-rb-686fcc3/test/examples/invalid/array/text-before-array-separator.toml000066400000000000000000000001071517351030400305510ustar00rootroot00000000000000array = [ "Is there life before an array separator?" No, "Entry" ] emancu-toml-rb-686fcc3/test/examples/invalid/array/text-in-array.toml000066400000000000000000000000701517351030400257160ustar00rootroot00000000000000array = [ "Entry 1", I don't belong, "Entry 2", ] emancu-toml-rb-686fcc3/test/examples/invalid/bool/000077500000000000000000000000001517351030400221355ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/bool/almost-false-with-extra.toml000066400000000000000000000000421517351030400275070ustar00rootroot00000000000000almost-false-with-extra = falsify emancu-toml-rb-686fcc3/test/examples/invalid/bool/almost-false.toml000066400000000000000000000000371517351030400254210ustar00rootroot00000000000000almost-false = fals emancu-toml-rb-686fcc3/test/examples/invalid/bool/almost-true-with-extra.toml000066400000000000000000000000411517351030400273730ustar00rootroot00000000000000almost-true-with-extra = truthy emancu-toml-rb-686fcc3/test/examples/invalid/bool/almost-true.toml000066400000000000000000000000361517351030400253050ustar00rootroot00000000000000almost-true = tru emancu-toml-rb-686fcc3/test/examples/invalid/bool/bool.multi000066400000000000000000000007421517351030400241470ustar00rootroot00000000000000almost-false-with-extra = falsify almost-false = fals almost-true-with-extra = truthy almost-true = tru just-f = f just-t = t mixed-case = valid = False starting-same-false = falsey starting-same-true = truer wrong-case-false = FALSE wrong-case-true = TRUE mixed-case-false = falsE mixed-case-true = trUe capitalized-false = False capitalized-true = True emancu-toml-rb-686fcc3/test/examples/invalid/bool/capitalized-false.toml000066400000000000000000000000411517351030400264060ustar00rootroot00000000000000capitalized-false = False emancu-toml-rb-686fcc3/test/examples/invalid/bool/capitalized-true.toml000066400000000000000000000000401517351030400262720ustar00rootroot00000000000000capitalized-true = True emancu-toml-rb-686fcc3/test/examples/invalid/bool/just-f.toml000066400000000000000000000000341517351030400242370ustar00rootroot00000000000000just-f = f emancu-toml-rb-686fcc3/test/examples/invalid/bool/just-t.toml000066400000000000000000000000341517351030400242550ustar00rootroot00000000000000just-t = t emancu-toml-rb-686fcc3/test/examples/invalid/bool/mixed-case-false.toml000066400000000000000000000000401517351030400261330ustar00rootroot00000000000000mixed-case-false = falsE emancu-toml-rb-686fcc3/test/examples/invalid/bool/mixed-case-true.toml000066400000000000000000000000371517351030400260260ustar00rootroot00000000000000mixed-case-true = trUe emancu-toml-rb-686fcc3/test/examples/invalid/bool/mixed-case.toml000066400000000000000000000000521517351030400250460ustar00rootroot00000000000000mixed-case = valid = False emancu-toml-rb-686fcc3/test/examples/invalid/bool/starting-same-false.toml000066400000000000000000000000411517351030400266730ustar00rootroot00000000000000starting-same-false = falsey emancu-toml-rb-686fcc3/test/examples/invalid/bool/starting-same-true.toml000066400000000000000000000000401517351030400265570ustar00rootroot00000000000000starting-same-true = truer emancu-toml-rb-686fcc3/test/examples/invalid/bool/wrong-case-false.toml000066400000000000000000000000401517351030400261610ustar00rootroot00000000000000wrong-case-false = FALSE emancu-toml-rb-686fcc3/test/examples/invalid/bool/wrong-case-true.toml000066400000000000000000000000371517351030400260540ustar00rootroot00000000000000wrong-case-true = TRUE emancu-toml-rb-686fcc3/test/examples/invalid/control/000077500000000000000000000000001517351030400226625ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/control/bare-cr.toml000066400000000000000000000001131517351030400250650ustar00rootroot00000000000000# The following line contains a single carriage return control character emancu-toml-rb-686fcc3/test/examples/invalid/control/bare-formfeed.toml000066400000000000000000000000261517351030400262530ustar00rootroot00000000000000bare-formfeed = emancu-toml-rb-686fcc3/test/examples/invalid/control/bare-null.toml000066400000000000000000000000431517351030400254350ustar00rootroot00000000000000bare-null = "some value" emancu-toml-rb-686fcc3/test/examples/invalid/control/bare-vertical-tab.toml000066400000000000000000000000261517351030400270410ustar00rootroot00000000000000bare-vertical-tab = emancu-toml-rb-686fcc3/test/examples/invalid/control/control.multi000066400000000000000000000017351517351030400254240ustar00rootroot00000000000000# "\x.." sequences are replaced with literal control characters. comment-null = "null" # \x00 comment-ff = "0x7f" # \x0c comment-lf = "ctrl-P" # \x10 comment-cr = "CR" # \x0d comment-us = "ctrl-_" # \x1f comment-del = "0x7f" # \x7f comment-cr = "Carriage return in comment" # \x0da=1 string-null = "null\x00" string-lf = "null\x10" string-cr = "null\x0d" string-us = "null\x1f" string-del = "null\x7f" string-bs = "backspace\x08" rawstring-null = 'null\x00' rawstring-lf = 'null\x10' rawstring-cr = 'null\x0d' rawstring-us = 'null\x1f' rawstring-del = 'null\x7f' multi-null = """null\x00""" multi-lf = """null\x10""" multi-cr = """null\x0d""" multi-us = """null\x1f""" multi-del = """null\x7f""" rawmulti-null = '''null\x00''' rawmulti-lf = '''null\x10''' rawmulti-cd = '''null\x0d''' rawmulti-us = '''null\x1f''' rawmulti-del = '''null\x7f''' bare-null = "some value" \x00 bare-formfeed = \x0c bare-vertical-tab = \x0b emancu-toml-rb-686fcc3/test/examples/invalid/datetime-malformed-no-leads.toml000066400000000000000000000000371517351030400273370ustar00rootroot00000000000000no-leads = 1987-7-05T17:45:00Z emancu-toml-rb-686fcc3/test/examples/invalid/datetime-malformed-no-secs.toml000066400000000000000000000000341517351030400272010ustar00rootroot00000000000000no-secs = 1987-07-05T17:45Z emancu-toml-rb-686fcc3/test/examples/invalid/datetime-malformed-no-t.toml000066400000000000000000000000331517351030400265060ustar00rootroot00000000000000no-t = 1987-07-0517:45:00Z emancu-toml-rb-686fcc3/test/examples/invalid/datetime-malformed-with-milli.toml000066400000000000000000000000441517351030400277120ustar00rootroot00000000000000with-milli = 1987-07-5T17:45:00.12Z emancu-toml-rb-686fcc3/test/examples/invalid/datetime/000077500000000000000000000000001517351030400227765ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/datetime/no-leads-month.toml000066400000000000000000000001321517351030400265140ustar00rootroot00000000000000# Month "7" instead of "07"; the leading zero is required. no-leads = 1987-7-05T17:45:00Z emancu-toml-rb-686fcc3/test/examples/invalid/datetime/no-leads-with-milli.toml000066400000000000000000000001351517351030400274510ustar00rootroot00000000000000# Day "5" instead of "05"; the leading zero is required. with-milli = 1987-07-5T17:45:00.12Z emancu-toml-rb-686fcc3/test/examples/invalid/datetime/no-leads.toml000066400000000000000000000001321517351030400253710ustar00rootroot00000000000000# Month "7" instead of "07"; the leading zero is required. no-leads = 1987-7-05T17:45:00Z emancu-toml-rb-686fcc3/test/examples/invalid/datetime/no-t.toml000066400000000000000000000001061517351030400245450ustar00rootroot00000000000000# No "t" or "T" between the date and time. no-t = 1987-07-0517:45:00Z emancu-toml-rb-686fcc3/test/examples/invalid/datetime/time-no-leads.toml000066400000000000000000000000701517351030400263260ustar00rootroot00000000000000# Leading 0 is always required. d = 2023-10-01T1:32:00Z emancu-toml-rb-686fcc3/test/examples/invalid/datetime/y10k.toml000066400000000000000000000000721517351030400244560ustar00rootroot00000000000000# Maximum RFC3399 year is 9999. d = 10000-01-01 00:00:00z emancu-toml-rb-686fcc3/test/examples/invalid/duplicate-key-table.toml000066400000000000000000000000631517351030400257230ustar00rootroot00000000000000[fruit] type = "apple" [fruit.type] apple = "yes" emancu-toml-rb-686fcc3/test/examples/invalid/duplicate-keys.toml000066400000000000000000000000311517351030400250140ustar00rootroot00000000000000dupe = false dupe = true emancu-toml-rb-686fcc3/test/examples/invalid/duplicate-tables.toml000066400000000000000000000000101517351030400253100ustar00rootroot00000000000000[a] [a] emancu-toml-rb-686fcc3/test/examples/invalid/empty-implicit-table.toml000066400000000000000000000000231517351030400261250ustar00rootroot00000000000000[naughty..naughty] emancu-toml-rb-686fcc3/test/examples/invalid/empty-table.toml000066400000000000000000000000031517351030400243130ustar00rootroot00000000000000[] emancu-toml-rb-686fcc3/test/examples/invalid/encoding/000077500000000000000000000000001517351030400227705ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/encoding/utf16-comment.toml000066400000000000000000000000521517351030400262670ustar00rootroot00000000000000# UTF-16 without BOM emancu-toml-rb-686fcc3/test/examples/invalid/encoding/utf16-key.toml000066400000000000000000000000201517351030400254100ustar00rootroot00000000000000k = "v" emancu-toml-rb-686fcc3/test/examples/invalid/float-no-leading-zero.toml000066400000000000000000000000441517351030400261720ustar00rootroot00000000000000answer = .12345 neganswer = -.12345 emancu-toml-rb-686fcc3/test/examples/invalid/float-no-trailing-digits.toml000066400000000000000000000000341517351030400267030ustar00rootroot00000000000000answer = 1. neganswer = -1. emancu-toml-rb-686fcc3/test/examples/invalid/float/000077500000000000000000000000001517351030400223075ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/float/double-point-1.toml000066400000000000000000000000261517351030400257410ustar00rootroot00000000000000double-point-1 = 0..1 emancu-toml-rb-686fcc3/test/examples/invalid/float/double-point-2.toml000066400000000000000000000000271517351030400257430ustar00rootroot00000000000000double-point-2 = 0.1.2 emancu-toml-rb-686fcc3/test/examples/invalid/float/exp-double-e-1.toml000066400000000000000000000000261517351030400256260ustar00rootroot00000000000000exp-double-e-1 = 1ee2 emancu-toml-rb-686fcc3/test/examples/invalid/float/exp-double-e-2.toml000066400000000000000000000000271517351030400256300ustar00rootroot00000000000000exp-double-e-2 = 1e2e3 emancu-toml-rb-686fcc3/test/examples/invalid/float/exp-double-us.toml000066400000000000000000000000271517351030400256740ustar00rootroot00000000000000exp-double-us = 1e__23 emancu-toml-rb-686fcc3/test/examples/invalid/float/exp-leading-us.toml000066400000000000000000000000271517351030400260250ustar00rootroot00000000000000exp-leading-us = 1e_23 emancu-toml-rb-686fcc3/test/examples/invalid/float/exp-point-1.toml000066400000000000000000000000241517351030400252610ustar00rootroot00000000000000exp-point-1 = 1e2.3 emancu-toml-rb-686fcc3/test/examples/invalid/float/exp-point-2.toml000066400000000000000000000000231517351030400252610ustar00rootroot00000000000000exp-point-2 = 1.e2 emancu-toml-rb-686fcc3/test/examples/invalid/float/exp-point-3.toml000066400000000000000000000000251517351030400252640ustar00rootroot00000000000000exp-point-3 = 3.e+20 emancu-toml-rb-686fcc3/test/examples/invalid/float/exp-trailing-us-1.toml000066400000000000000000000000311517351030400263640ustar00rootroot00000000000000exp-trailing-us-1 = 1_e2 emancu-toml-rb-686fcc3/test/examples/invalid/float/exp-trailing-us-2.toml000066400000000000000000000000331517351030400263670ustar00rootroot00000000000000exp-trailing-us-2 = 1.2_e2 emancu-toml-rb-686fcc3/test/examples/invalid/float/exp-trailing-us.toml000066400000000000000000000000301517351030400262250ustar00rootroot00000000000000exp-trailing-us = 1e23_ emancu-toml-rb-686fcc3/test/examples/invalid/float/float.multi000066400000000000000000000014021517351030400244650ustar00rootroot00000000000000leading-zero = 03.14 leading-zero-neg = -03.14 leading-zero-plus = +03.14 leading-point = .12345 leading-point-neg = -.12345 leading-point-plus = +.12345 trailing-point = 1. trailing-point-min = -1. trailing-point-plus = +1. trailing-us = 1.2_ leading-us = _1.2 us-before-point = 1_.2 us-after-point = 1._2 double-point-1 = 0..1 double-point-2 = 0.1.2 exp-point-1 = 1e2.3 exp-point-2 = 1.e2 exp-point-3 = 3.e+20 exp-double-e-1 = 1ee2 exp-double-e-2 = 1e2e3 exp-leading-us = 1e_23 exp-trailing-us = 1e23_ exp-double-us = 1e__23 exp-trailing-us-1 = 1_e2 exp-trailing-us-2 = 1.2_e2 inf-incomplete-1 = in inf-incomplete-2 = +in inf-incomplete-3 = -in nan-incomplete-1 = na nan-incomplete-2 = +na nan-incomplete-3 = -na nan_underscore = na_n inf_underscore = in_f emancu-toml-rb-686fcc3/test/examples/invalid/float/inf-capital.toml000066400000000000000000000000101517351030400253620ustar00rootroot00000000000000v = Inf emancu-toml-rb-686fcc3/test/examples/invalid/float/inf-incomplete-1.toml000066400000000000000000000000261517351030400262510ustar00rootroot00000000000000inf-incomplete-1 = in emancu-toml-rb-686fcc3/test/examples/invalid/float/inf-incomplete-2.toml000066400000000000000000000000271517351030400262530ustar00rootroot00000000000000inf-incomplete-2 = +in emancu-toml-rb-686fcc3/test/examples/invalid/float/inf-incomplete-3.toml000066400000000000000000000000271517351030400262540ustar00rootroot00000000000000inf-incomplete-3 = -in emancu-toml-rb-686fcc3/test/examples/invalid/float/inf_underscore.toml000066400000000000000000000000261517351030400262070ustar00rootroot00000000000000inf_underscore = in_f emancu-toml-rb-686fcc3/test/examples/invalid/float/leading-point-neg.toml000066400000000000000000000000341517351030400265020ustar00rootroot00000000000000leading-point-neg = -.12345 emancu-toml-rb-686fcc3/test/examples/invalid/float/leading-point-plus.toml000066400000000000000000000000351517351030400267150ustar00rootroot00000000000000leading-point-plus = +.12345 emancu-toml-rb-686fcc3/test/examples/invalid/float/leading-point.toml000066400000000000000000000000271517351030400257350ustar00rootroot00000000000000leading-point = .12345 emancu-toml-rb-686fcc3/test/examples/invalid/float/leading-us.toml000066400000000000000000000000221517351030400252260ustar00rootroot00000000000000leading-us = _1.2 emancu-toml-rb-686fcc3/test/examples/invalid/float/nan-capital.toml000066400000000000000000000000101517351030400253620ustar00rootroot00000000000000v = NaN emancu-toml-rb-686fcc3/test/examples/invalid/float/nan-incomplete-1.toml000066400000000000000000000000261517351030400262510ustar00rootroot00000000000000nan-incomplete-1 = na emancu-toml-rb-686fcc3/test/examples/invalid/float/nan-incomplete-2.toml000066400000000000000000000000271517351030400262530ustar00rootroot00000000000000nan-incomplete-2 = +na emancu-toml-rb-686fcc3/test/examples/invalid/float/nan-incomplete-3.toml000066400000000000000000000000271517351030400262540ustar00rootroot00000000000000nan-incomplete-3 = -na emancu-toml-rb-686fcc3/test/examples/invalid/float/nan_underscore.toml000066400000000000000000000000261517351030400262070ustar00rootroot00000000000000nan_underscore = na_n emancu-toml-rb-686fcc3/test/examples/invalid/float/trailing-point-min.toml000066400000000000000000000000311517351030400267170ustar00rootroot00000000000000trailing-point-min = -1. emancu-toml-rb-686fcc3/test/examples/invalid/float/trailing-point-plus.toml000066400000000000000000000000321517351030400271200ustar00rootroot00000000000000trailing-point-plus = +1. emancu-toml-rb-686fcc3/test/examples/invalid/float/trailing-point.toml000066400000000000000000000000241517351030400261400ustar00rootroot00000000000000trailing-point = 1. emancu-toml-rb-686fcc3/test/examples/invalid/float/trailing-us-exp-1.toml000066400000000000000000000000311517351030400263640ustar00rootroot00000000000000trailing-us-exp-1 = 1_e2 emancu-toml-rb-686fcc3/test/examples/invalid/float/trailing-us-exp-2.toml000066400000000000000000000000331517351030400263670ustar00rootroot00000000000000trailing-us-exp-2 = 1.2_e2 emancu-toml-rb-686fcc3/test/examples/invalid/float/trailing-us.toml000066400000000000000000000000231517351030400254350ustar00rootroot00000000000000trailing-us = 1.2_ emancu-toml-rb-686fcc3/test/examples/invalid/float/us-after-point.toml000066400000000000000000000000261517351030400260570ustar00rootroot00000000000000us-after-point = 1._2 emancu-toml-rb-686fcc3/test/examples/invalid/float/us-before-point.toml000066400000000000000000000000271517351030400262210ustar00rootroot00000000000000us-before-point = 1_.2 emancu-toml-rb-686fcc3/test/examples/invalid/inline-table-duplicate-key.toml000066400000000000000000000003421517351030400271770ustar00rootroot00000000000000# Inline tables fully define the keys and sub-tables within them. # So, inline tables can not be used to add keys # or sub-tables to an already-defined table. [product] type.name = "Nail" type = { edible = false } # INVALID emancu-toml-rb-686fcc3/test/examples/invalid/inline-table-duplicate-key2.toml000066400000000000000000000002541517351030400272630ustar00rootroot00000000000000# Inline tables fully define the keys and sub-tables within them. # New keys and sub-tables cannot be added to them. [product] type = { name = "Nail" } type.edible = false emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/000077500000000000000000000000001517351030400235455ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/add-key-01.toml000066400000000000000000000001021517351030400261670ustar00rootroot00000000000000[product] type = { name = "Nail" } type.edible = false # INVALID emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/add-key-02.toml000066400000000000000000000001021517351030400261700ustar00rootroot00000000000000[product] type.name = "Nail" type = { edible = false } # INVALID emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/bad-key-syntax.toml000066400000000000000000000000251517351030400272770ustar00rootroot00000000000000tbl = { a = 1, [b] } emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/double-comma.toml000066400000000000000000000000171517351030400270040ustar00rootroot00000000000000t = {x=3,,y=4} emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/duplicate-key-1.toml000066400000000000000000000001011517351030400273300ustar00rootroot00000000000000# Duplicate keys within an inline table are invalid a={b=1, b=2} emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/duplicate-key-2.toml000066400000000000000000000000561517351030400273420ustar00rootroot00000000000000table1 = { table2.dupe = 1, table2.dupe = 2 } emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/duplicate-key-3.toml000066400000000000000000000001241517351030400273370ustar00rootroot00000000000000tbl = { fruit = { apple.color = "red" }, fruit.apple.texture = { smooth = true } } emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/duplicate-key-4.toml000066400000000000000000000000471517351030400273440ustar00rootroot00000000000000tbl = { a.b = "a_b", a.b.c = "a_b_c" } emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/empty-1.toml000066400000000000000000000000101517351030400257250ustar00rootroot00000000000000t = {,} emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/empty-2.toml000066400000000000000000000000111517351030400257270ustar00rootroot00000000000000t = {, } emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/empty-3.toml000066400000000000000000000000121517351030400257310ustar00rootroot00000000000000t = { , } emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/no-close-1.toml000066400000000000000000000000041517351030400263110ustar00rootroot00000000000000a={ emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/no-close-2.toml000066400000000000000000000000071517351030400263150ustar00rootroot00000000000000a={b=1 emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/no-comma-1.toml000066400000000000000000000000221517351030400263000ustar00rootroot00000000000000t = {x = 3 y = 4} emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/no-comma-2.toml000066400000000000000000000000631517351030400263060ustar00rootroot00000000000000arrr = { comma-missing = true valid-toml = false } emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/overwrite-01.toml000066400000000000000000000001321517351030400267020ustar00rootroot00000000000000a.b=0 # Since table "a" is already defined, it can't be replaced by an inline table. a={} emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/overwrite-03.toml000066400000000000000000000000261517351030400267060ustar00rootroot00000000000000a = { b = 1 } a.b = 2 emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/overwrite-04.toml000066400000000000000000000000541517351030400267100ustar00rootroot00000000000000inline-t = { nest = {} } [[inline-t.nest]] emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/overwrite-06.toml000066400000000000000000000000271517351030400267120ustar00rootroot00000000000000a = { b = 1, b.c = 2 } emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/overwrite-07.toml000066400000000000000000000000651517351030400267150ustar00rootroot00000000000000tab = { inner.table = [{}], inner.table.val = "bad" }emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/overwrite-08.toml000066400000000000000000000000671517351030400267200ustar00rootroot00000000000000tab = { inner = { dog = "best" }, inner.cat = "worst" }emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/overwrite-09.toml000066400000000000000000000001061517351030400267130ustar00rootroot00000000000000[tab.nested] inline-t = { nest = {} } [tab] nested.inline-t.nest = 2 emancu-toml-rb-686fcc3/test/examples/invalid/inline-table/overwrite-10.toml000066400000000000000000000002521517351030400267050ustar00rootroot00000000000000# Set implicit "b", overwrite "b" (illegal!) and then set another implicit. # # Caused panic: https://github.com/BurntSushi/toml/issues/403 a = {b.a = 1, b = 2, b.c = 3} emancu-toml-rb-686fcc3/test/examples/invalid/integer/000077500000000000000000000000001517351030400226375ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/integer/capital-bin.toml000066400000000000000000000000221517351030400257110ustar00rootroot00000000000000capital-bin = 0B0 emancu-toml-rb-686fcc3/test/examples/invalid/integer/capital-hex.toml000066400000000000000000000000221517351030400257250ustar00rootroot00000000000000capital-hex = 0X1 emancu-toml-rb-686fcc3/test/examples/invalid/integer/capital-oct.toml000066400000000000000000000000221517351030400257260ustar00rootroot00000000000000capital-oct = 0O0 emancu-toml-rb-686fcc3/test/examples/invalid/integer/double-sign-nex.toml000066400000000000000000000000271517351030400265330ustar00rootroot00000000000000double-sign-nex = --99 emancu-toml-rb-686fcc3/test/examples/invalid/integer/double-sign-plus.toml000066400000000000000000000000301517351030400267160ustar00rootroot00000000000000double-sign-plus = ++99 emancu-toml-rb-686fcc3/test/examples/invalid/integer/double-us.toml000066400000000000000000000000221517351030400254250ustar00rootroot00000000000000double-us = 1__23 emancu-toml-rb-686fcc3/test/examples/invalid/integer/incomplete-bin.toml000066400000000000000000000000241517351030400264350ustar00rootroot00000000000000incomplete-bin = 0b emancu-toml-rb-686fcc3/test/examples/invalid/integer/incomplete-hex.toml000066400000000000000000000000241517351030400264510ustar00rootroot00000000000000incomplete-hex = 0x emancu-toml-rb-686fcc3/test/examples/invalid/integer/incomplete-oct.toml000066400000000000000000000000241517351030400264520ustar00rootroot00000000000000incomplete-oct = 0o emancu-toml-rb-686fcc3/test/examples/invalid/integer/integer.multi000066400000000000000000000013341517351030400253510ustar00rootroot00000000000000leading-zero-1 = 01 leading-zero-2 = 00 leading-zero-3 = 0_0 leading-zero-sign-1 = -01 leading-zero-sign-2 = +01 leading-zero-sign-3 = +0_1 double-sign-plus = ++99 double-sign-nex = --99 negative-hex = -0xff negative-bin = -0b11010110 negative-oct = -0o755 positive-hex = +0xff positive-bin = +0b11010110 positive-oct = +0o755 trailing-us = 123_ leading-us = _123 double-us = 1__23 us-after-hex = 0x_1 us-after-oct = 0o_1 us-after-bin = 0b_1 trailing-us-hex = 0x1_ trailing-us-oct = 0o1_ trailing-us-bin = 0b1_ leading-us-hex = _0x1 leading-us-oct = _0o1 leading-us-bin = _0b1 invalid-hex-1 = 0xaafz invalid-hex-2 = 0xgabba00f1 invalid-oct = 0o778 invalid-bin = 0b0012 capital-hex = 0X1 capital-oct = 0O0 capital-bin = 0B0 emancu-toml-rb-686fcc3/test/examples/invalid/integer/invalid-bin.toml000066400000000000000000000000251517351030400257250ustar00rootroot00000000000000invalid-bin = 0b0012 emancu-toml-rb-686fcc3/test/examples/invalid/integer/invalid-hex-1.toml000066400000000000000000000000271517351030400261010ustar00rootroot00000000000000invalid-hex-1 = 0xaafz emancu-toml-rb-686fcc3/test/examples/invalid/integer/invalid-hex-2.toml000066400000000000000000000000341517351030400261000ustar00rootroot00000000000000invalid-hex-2 = 0xgabba00f1 emancu-toml-rb-686fcc3/test/examples/invalid/integer/invalid-hex.toml000066400000000000000000000000251517351030400257410ustar00rootroot00000000000000invalid-hex = 0xaafz emancu-toml-rb-686fcc3/test/examples/invalid/integer/invalid-oct.toml000066400000000000000000000000241517351030400257410ustar00rootroot00000000000000invalid-oct = 0o778 emancu-toml-rb-686fcc3/test/examples/invalid/integer/leading-us-bin.toml000066400000000000000000000000261517351030400263300ustar00rootroot00000000000000leading-us-bin = _0b1 emancu-toml-rb-686fcc3/test/examples/invalid/integer/leading-us-hex.toml000066400000000000000000000000261517351030400263440ustar00rootroot00000000000000leading-us-hex = _0x1 emancu-toml-rb-686fcc3/test/examples/invalid/integer/leading-us-oct.toml000066400000000000000000000000261517351030400263450ustar00rootroot00000000000000leading-us-oct = _0o1 emancu-toml-rb-686fcc3/test/examples/invalid/integer/leading-us.toml000066400000000000000000000000221517351030400255560ustar00rootroot00000000000000leading-us = _123 emancu-toml-rb-686fcc3/test/examples/invalid/integer/negative-bin.toml000066400000000000000000000000331517351030400261000ustar00rootroot00000000000000negative-bin = -0b11010110 emancu-toml-rb-686fcc3/test/examples/invalid/integer/negative-hex.toml000066400000000000000000000000251517351030400261150ustar00rootroot00000000000000negative-hex = -0xff emancu-toml-rb-686fcc3/test/examples/invalid/integer/negative-oct.toml000066400000000000000000000000261517351030400261170ustar00rootroot00000000000000negative-oct = -0o755 emancu-toml-rb-686fcc3/test/examples/invalid/integer/positive-bin.toml000066400000000000000000000000331517351030400261400ustar00rootroot00000000000000positive-bin = +0b11010110 emancu-toml-rb-686fcc3/test/examples/invalid/integer/positive-hex.toml000066400000000000000000000000251517351030400261550ustar00rootroot00000000000000positive-hex = +0xff emancu-toml-rb-686fcc3/test/examples/invalid/integer/positive-oct.toml000066400000000000000000000000261517351030400261570ustar00rootroot00000000000000positive-oct = +0o755 emancu-toml-rb-686fcc3/test/examples/invalid/integer/text-after-integer.toml000066400000000000000000000000411517351030400272450ustar00rootroot00000000000000answer = 42 the ultimate answer? emancu-toml-rb-686fcc3/test/examples/invalid/integer/trailing-us-bin.toml000066400000000000000000000000271517351030400265370ustar00rootroot00000000000000trailing-us-bin = 0b1_ emancu-toml-rb-686fcc3/test/examples/invalid/integer/trailing-us-hex.toml000066400000000000000000000000271517351030400265530ustar00rootroot00000000000000trailing-us-hex = 0x1_ emancu-toml-rb-686fcc3/test/examples/invalid/integer/trailing-us-oct.toml000066400000000000000000000000271517351030400265540ustar00rootroot00000000000000trailing-us-oct = 0o1_ emancu-toml-rb-686fcc3/test/examples/invalid/integer/trailing-us.toml000066400000000000000000000000231517351030400257650ustar00rootroot00000000000000trailing-us = 123_ emancu-toml-rb-686fcc3/test/examples/invalid/integer/us-after-bin.toml000066400000000000000000000000241517351030400260240ustar00rootroot00000000000000us-after-bin = 0b_1 emancu-toml-rb-686fcc3/test/examples/invalid/integer/us-after-hex.toml000066400000000000000000000000241517351030400260400ustar00rootroot00000000000000us-after-hex = 0x_1 emancu-toml-rb-686fcc3/test/examples/invalid/integer/us-after-oct.toml000066400000000000000000000000241517351030400260410ustar00rootroot00000000000000us-after-oct = 0o_1 emancu-toml-rb-686fcc3/test/examples/invalid/key-empty.toml000066400000000000000000000000051517351030400240160ustar00rootroot00000000000000 = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key-hash.toml000066400000000000000000000000071517351030400236050ustar00rootroot00000000000000a# = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key-newline.toml000066400000000000000000000000061517351030400243220ustar00rootroot00000000000000a = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key-open-bracket.toml000066400000000000000000000000111517351030400252270ustar00rootroot00000000000000[abc = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key-single-open-bracket.toml000066400000000000000000000000011517351030400265050ustar00rootroot00000000000000[emancu-toml-rb-686fcc3/test/examples/invalid/key-space.toml000066400000000000000000000000071517351030400237550ustar00rootroot00000000000000a b = 1emancu-toml-rb-686fcc3/test/examples/invalid/key-start-bracket.toml000066400000000000000000000000211517351030400254240ustar00rootroot00000000000000[a] [xyz = 5 [b] emancu-toml-rb-686fcc3/test/examples/invalid/key-two-equals.toml000066400000000000000000000000111517351030400247560ustar00rootroot00000000000000key= = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key/000077500000000000000000000000001517351030400217725ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/key/bare-invalid-character.toml000066400000000000000000000000171517351030400271540ustar00rootroot00000000000000bare!key = 123 emancu-toml-rb-686fcc3/test/examples/invalid/key/dotted-redefine-table-1.toml000066400000000000000000000000251517351030400271510ustar00rootroot00000000000000a = false a.b = true emancu-toml-rb-686fcc3/test/examples/invalid/key/dotted-redefine-table-2.toml000066400000000000000000000001141517351030400271510ustar00rootroot00000000000000# Defined a.b as int a.b = 1 # Tries to access it as table: error a.b.c = 2 emancu-toml-rb-686fcc3/test/examples/invalid/key/duplicate-keys-1.toml000066400000000000000000000000361517351030400257470ustar00rootroot00000000000000name = "Tom" name = "Pradyun" emancu-toml-rb-686fcc3/test/examples/invalid/key/duplicate-keys-2.toml000066400000000000000000000000311517351030400257430ustar00rootroot00000000000000dupe = false dupe = true emancu-toml-rb-686fcc3/test/examples/invalid/key/duplicate-keys-3.toml000066400000000000000000000000611517351030400257470ustar00rootroot00000000000000spelling = "favorite" "spelling" = "favourite" emancu-toml-rb-686fcc3/test/examples/invalid/key/duplicate-keys-4.toml000066400000000000000000000000611517351030400257500ustar00rootroot00000000000000spelling = "favorite" 'spelling' = "favourite" emancu-toml-rb-686fcc3/test/examples/invalid/key/empty.toml000066400000000000000000000000051517351030400240200ustar00rootroot00000000000000 = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key/end-in-escape.toml000066400000000000000000000000351517351030400252750ustar00rootroot00000000000000"backslash is the last char\ emancu-toml-rb-686fcc3/test/examples/invalid/key/escape.toml000066400000000000000000000000551517351030400241270ustar00rootroot00000000000000\u00c0 = "latin capital letter A with grave" emancu-toml-rb-686fcc3/test/examples/invalid/key/hash.toml000066400000000000000000000000071517351030400236070ustar00rootroot00000000000000a# = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key/newline-1.toml000066400000000000000000000000171517351030400244640ustar00rootroot00000000000000barekey = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key/newline-2.toml000066400000000000000000000000211517351030400244600ustar00rootroot00000000000000"quoted key" = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key/newline-3.toml000066400000000000000000000000211517351030400244610ustar00rootroot00000000000000'quoted key' = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key/newline-4.toml000066400000000000000000000000231517351030400244640ustar00rootroot00000000000000"""long key""" = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key/newline-5.toml000066400000000000000000000000231517351030400244650ustar00rootroot00000000000000'''long key''' = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key/open-bracket.toml000066400000000000000000000000111517351030400252310ustar00rootroot00000000000000[abc = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key/partial-quoted.toml000066400000000000000000000000241517351030400256160ustar00rootroot00000000000000partial"quoted" = 5 emancu-toml-rb-686fcc3/test/examples/invalid/key/quoted-unclosed-1.toml000066400000000000000000000000111517351030400261300ustar00rootroot00000000000000"key = x emancu-toml-rb-686fcc3/test/examples/invalid/key/quoted-unclosed-2.toml000066400000000000000000000000051517351030400261340ustar00rootroot00000000000000"key emancu-toml-rb-686fcc3/test/examples/invalid/key/single-open-bracket.toml000066400000000000000000000000021517351030400265100ustar00rootroot00000000000000[ emancu-toml-rb-686fcc3/test/examples/invalid/key/space.toml000066400000000000000000000000101517351030400237510ustar00rootroot00000000000000a b = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key/special-character.toml000066400000000000000000000000351517351030400262370ustar00rootroot00000000000000μ = "greek small letter mu" emancu-toml-rb-686fcc3/test/examples/invalid/key/start-bracket.toml000066400000000000000000000000211517351030400254260ustar00rootroot00000000000000[a] [xyz = 5 [b] emancu-toml-rb-686fcc3/test/examples/invalid/key/start-dot.toml000066400000000000000000000000111517351030400246000ustar00rootroot00000000000000.key = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key/two-equals-1.toml000066400000000000000000000000111517351030400251160ustar00rootroot00000000000000key= = 1 emancu-toml-rb-686fcc3/test/examples/invalid/key/two-equals-2.toml000066400000000000000000000000051517351030400251220ustar00rootroot00000000000000a==1 emancu-toml-rb-686fcc3/test/examples/invalid/key/two-equals-3.toml000066400000000000000000000000061517351030400251240ustar00rootroot00000000000000a=b=1 emancu-toml-rb-686fcc3/test/examples/invalid/key/without-value-1.toml000066400000000000000000000000041517351030400256340ustar00rootroot00000000000000key emancu-toml-rb-686fcc3/test/examples/invalid/key/without-value-2.toml000066400000000000000000000000071517351030400256400ustar00rootroot00000000000000key = emancu-toml-rb-686fcc3/test/examples/invalid/key/without-value-3.toml000066400000000000000000000000061517351030400256400ustar00rootroot00000000000000"key" emancu-toml-rb-686fcc3/test/examples/invalid/key/without-value-4.toml000066400000000000000000000000111517351030400256350ustar00rootroot00000000000000"key" = emancu-toml-rb-686fcc3/test/examples/invalid/key/without-value-5.toml000066400000000000000000000000061517351030400256420ustar00rootroot00000000000000fs.fw emancu-toml-rb-686fcc3/test/examples/invalid/key/without-value-6.toml000066400000000000000000000000101517351030400256360ustar00rootroot00000000000000fs.fw = emancu-toml-rb-686fcc3/test/examples/invalid/key/without-value-7.toml000066400000000000000000000000041517351030400256420ustar00rootroot00000000000000fs. emancu-toml-rb-686fcc3/test/examples/invalid/local-date/000077500000000000000000000000001517351030400232075ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/local-date/no-leads-with-milli.toml000066400000000000000000000001201517351030400276540ustar00rootroot00000000000000# Day "5" instead of "05"; the leading zero is required. with-milli = 1987-07-5 emancu-toml-rb-686fcc3/test/examples/invalid/local-date/no-leads.toml000066400000000000000000000001201517351030400255770ustar00rootroot00000000000000# Month "7" instead of "07"; the leading zero is required. no-leads = 1987-7-05 emancu-toml-rb-686fcc3/test/examples/invalid/local-date/trailing-t.toml000066400000000000000000000000621517351030400261540ustar00rootroot00000000000000# Date cannot end with trailing T d = 2006-01-30T emancu-toml-rb-686fcc3/test/examples/invalid/local-date/y10k.toml000066400000000000000000000000601517351030400246640ustar00rootroot00000000000000# Maximum RFC3399 year is 9999. d = 10000-01-01 emancu-toml-rb-686fcc3/test/examples/invalid/local-datetime/000077500000000000000000000000001517351030400240665ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/local-datetime/no-leads-with-milli.toml000066400000000000000000000001341517351030400305400ustar00rootroot00000000000000# Day "5" instead of "05"; the leading zero is required. with-milli = 1987-07-5T17:45:00.12 emancu-toml-rb-686fcc3/test/examples/invalid/local-datetime/no-leads.toml000066400000000000000000000001311517351030400264600ustar00rootroot00000000000000# Month "7" instead of "07"; the leading zero is required. no-leads = 1987-7-05T17:45:00 emancu-toml-rb-686fcc3/test/examples/invalid/local-datetime/no-t.toml000066400000000000000000000001051517351030400256340ustar00rootroot00000000000000# No "t" or "T" between the date and time. no-t = 1987-07-0517:45:00 emancu-toml-rb-686fcc3/test/examples/invalid/local-datetime/time-no-leads.toml000066400000000000000000000000701517351030400274160ustar00rootroot00000000000000# Leading 0 is always required. d = 2023-10-01T1:32:00Z emancu-toml-rb-686fcc3/test/examples/invalid/local-datetime/y10k.toml000066400000000000000000000000711517351030400255450ustar00rootroot00000000000000# Maximum RFC3399 year is 9999. d = 10000-01-01 00:00:00 emancu-toml-rb-686fcc3/test/examples/invalid/local-time/000077500000000000000000000000001517351030400232305ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/local-time/time-no-leads-2.toml000066400000000000000000000000541517351030400267210ustar00rootroot00000000000000# Leading 0 is always required. d = 01:32:0 emancu-toml-rb-686fcc3/test/examples/invalid/local-time/time-no-leads.toml000066400000000000000000000000541517351030400265620ustar00rootroot00000000000000# Leading 0 is always required. d = 1:32:00 emancu-toml-rb-686fcc3/test/examples/invalid/spec/000077500000000000000000000000001517351030400221345ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/spec/inline-table-2-0.toml000066400000000000000000000001021517351030400256610ustar00rootroot00000000000000[product] type = { name = "Nail" } type.edible = false # INVALID emancu-toml-rb-686fcc3/test/examples/invalid/spec/inline-table-3-0.toml000066400000000000000000000001021517351030400256620ustar00rootroot00000000000000[product] type.name = "Nail" type = { edible = false } # INVALID emancu-toml-rb-686fcc3/test/examples/invalid/spec/key-value-pair-1.toml000066400000000000000000000000201517351030400260120ustar00rootroot00000000000000key = # INVALID emancu-toml-rb-686fcc3/test/examples/invalid/spec/keys-2.toml000066400000000000000000000001551517351030400241440ustar00rootroot00000000000000= "no key name" # INVALID "" = "blank" # VALID but discouraged '' = 'blank' # VALID but discouraged emancu-toml-rb-686fcc3/test/examples/invalid/spec/string-4-0.toml000066400000000000000000000005511517351030400246360ustar00rootroot00000000000000str4 = """Here are two quotation marks: "". Simple enough.""" str5 = """Here are three quotation marks: """.""" # INVALID str5 = """Here are three quotation marks: ""\".""" str6 = """Here are fifteen quotation marks: ""\"""\"""\"""\"""\".""" # "This," she said, "is just a pointless statement." str7 = """"This," she said, "is just a pointless statement."""" emancu-toml-rb-686fcc3/test/examples/invalid/spec/string-7-0.toml000066400000000000000000000004421517351030400246400ustar00rootroot00000000000000quot15 = '''Here are fifteen quotation marks: """""""""""""""''' apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID apos15 = "Here are fifteen apostrophes: '''''''''''''''" # 'That,' she said, 'is still pointless.' str = ''''That,' she said, 'is still pointless.'''' emancu-toml-rb-686fcc3/test/examples/invalid/string-bad-byte-escape.toml000066400000000000000000000000211517351030400263210ustar00rootroot00000000000000naughty = "\xAg" emancu-toml-rb-686fcc3/test/examples/invalid/string-bad-escape.toml000066400000000000000000000000761517351030400253720ustar00rootroot00000000000000invalid-escape = "This string has a bad \a escape character." emancu-toml-rb-686fcc3/test/examples/invalid/string-byte-escapes.toml000066400000000000000000000000201517351030400257570ustar00rootroot00000000000000answer = "\x33" emancu-toml-rb-686fcc3/test/examples/invalid/string-no-close.toml000066400000000000000000000000521517351030400251170ustar00rootroot00000000000000no-ending-quote = "One time, at band camp emancu-toml-rb-686fcc3/test/examples/invalid/string/000077500000000000000000000000001517351030400225105ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-byte-escape.toml000066400000000000000000000000211517351030400263230ustar00rootroot00000000000000naughty = "\xAg" emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-concat.toml000066400000000000000000000000351517351030400253760ustar00rootroot00000000000000no_concat = "first" "second" emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-escape-1.toml000066400000000000000000000000761517351030400255320ustar00rootroot00000000000000invalid-escape = "This string has a bad \a escape character." emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-escape-2.toml000066400000000000000000000000771517351030400255340ustar00rootroot00000000000000invalid-escape = "This string has a bad \ escape character." emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-hex-esc-1.toml000066400000000000000000000000271517351030400256220ustar00rootroot00000000000000bad-hex-esc-1 = "\x0g" emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-hex-esc-2.toml000066400000000000000000000000271517351030400256230ustar00rootroot00000000000000bad-hex-esc-2 = "\xG0" emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-hex-esc-3.toml000066400000000000000000000000251517351030400256220ustar00rootroot00000000000000bad-hex-esc-3 = "\x" emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-hex-esc-4.toml000066400000000000000000000000301517351030400256170ustar00rootroot00000000000000bad-hex-esc-4 = "\x 50" emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-hex-esc-5.toml000066400000000000000000000000301517351030400256200ustar00rootroot00000000000000bad-hex-esc-5 = "\x 50" emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-multiline.toml000066400000000000000000000000411517351030400261260ustar00rootroot00000000000000multi = "first line second line" emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-slash-escape.toml000066400000000000000000000000761517351030400265040ustar00rootroot00000000000000invalid-escape = "This string has a bad \/ escape character." emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-uni-esc-1.toml000066400000000000000000000000311517351030400256240ustar00rootroot00000000000000bad-uni-esc-1 = "val\ue" emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-uni-esc-2.toml000066400000000000000000000000311517351030400256250ustar00rootroot00000000000000bad-uni-esc-2 = "val\Ux" emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-uni-esc-3.toml000066400000000000000000000000371517351030400256340ustar00rootroot00000000000000bad-uni-esc-3 = "val\U0000000" emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-uni-esc-4.toml000066400000000000000000000000341517351030400256320ustar00rootroot00000000000000bad-uni-esc-4 = "val\U0000" emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-uni-esc-5.toml000066400000000000000000000000401517351030400256300ustar00rootroot00000000000000bad-uni-esc-5 = "val\Ugggggggg" emancu-toml-rb-686fcc3/test/examples/invalid/string/bad-uni-esc-7.toml000066400000000000000000000000311517351030400256320ustar00rootroot00000000000000bad-uni-esc-7 = "\uabag" emancu-toml-rb-686fcc3/test/examples/invalid/string/basic-multiline-quotes.toml000066400000000000000000000000621517351030400300020ustar00rootroot00000000000000str5 = """Here are three quotation marks: """.""" emancu-toml-rb-686fcc3/test/examples/invalid/string/basic-multiline-unknown-escape.toml000066400000000000000000000000151517351030400314150ustar00rootroot00000000000000a = """\@""" emancu-toml-rb-686fcc3/test/examples/invalid/string/basic-unknown-escape.toml000066400000000000000000000000111517351030400274110ustar00rootroot00000000000000a = "\@" emancu-toml-rb-686fcc3/test/examples/invalid/string/missing-quotes.toml000066400000000000000000000000151517351030400263700ustar00rootroot00000000000000name = value emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-bad-escape-1.toml000066400000000000000000000000171517351030400275250ustar00rootroot00000000000000k = """t\a""" emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-bad-escape-2.toml000066400000000000000000000000611517351030400275250ustar00rootroot00000000000000# \ is not a valid escape. k = """t\ t""" emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-bad-escape-3.toml000066400000000000000000000000611517351030400275260ustar00rootroot00000000000000# \ is not a valid escape. k = """t\ """ emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-escape-space-1.toml000066400000000000000000000000341517351030400300710ustar00rootroot00000000000000a = """ foo \ \n bar""" emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-escape-space-2.toml000066400000000000000000000000351517351030400300730ustar00rootroot00000000000000bee = """ hee \ gee \ """ emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-lit-no-close-1.toml000066400000000000000000000000411517351030400300430ustar00rootroot00000000000000invalid = ''' this will fail emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-lit-no-close-2.toml000066400000000000000000000000061517351030400300450ustar00rootroot00000000000000x=''' emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-lit-no-close-3.toml000066400000000000000000000000501517351030400300450ustar00rootroot00000000000000not-closed= ''' diibaa blibae ete eteta emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-lit-no-close-4.toml000066400000000000000000000000251517351030400300500ustar00rootroot00000000000000bee = ''' hee gee '' emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-no-close-1.toml000066400000000000000000000000411517351030400272550ustar00rootroot00000000000000invalid = """ this will fail emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-no-close-2.toml000066400000000000000000000000061517351030400272570ustar00rootroot00000000000000x=""" emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-no-close-3.toml000066400000000000000000000000501517351030400272570ustar00rootroot00000000000000not-closed= """ diibaa blibae ete eteta emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-no-close-4.toml000066400000000000000000000000251517351030400272620ustar00rootroot00000000000000bee = """ hee gee "" emancu-toml-rb-686fcc3/test/examples/invalid/string/multiline-no-close-5.toml000066400000000000000000000000251517351030400272630ustar00rootroot00000000000000bee = """ hee gee\ emancu-toml-rb-686fcc3/test/examples/invalid/string/no-close-1.toml000066400000000000000000000000521517351030400252570ustar00rootroot00000000000000no-ending-quote = "One time, at band camp emancu-toml-rb-686fcc3/test/examples/invalid/string/no-close-2.toml000066400000000000000000000000351517351030400252610ustar00rootroot00000000000000"a-string".must-be = "closed emancu-toml-rb-686fcc3/test/examples/invalid/string/no-close-3.toml000066400000000000000000000000521517351030400252610ustar00rootroot00000000000000no-ending-quote = 'One time, at band camp emancu-toml-rb-686fcc3/test/examples/invalid/string/no-close-4.toml000066400000000000000000000000351517351030400252630ustar00rootroot00000000000000'a-string'.must-be = 'closed emancu-toml-rb-686fcc3/test/examples/invalid/string/string.multi000066400000000000000000000005171517351030400250750ustar00rootroot00000000000000bad-hex-esc-1 = "\x0g" bad-hex-esc-2 = "\xG0" bad-hex-esc-3 = "\x" bad-hex-esc-4 = "\x 50" bad-uni-esc-1 = "val\ue" bad-uni-esc-2 = "val\Ux" bad-uni-esc-3 = "val\U0000000" bad-uni-esc-4 = "val\U0000" bad-uni-esc-5 = "val\Ugggggggg" bad-uni-esc-6 = "This string contains a non scalar unicode codepoint \uD801" bad-uni-esc-7 = "\uabag" emancu-toml-rb-686fcc3/test/examples/invalid/string/text-after-string.toml000066400000000000000000000000541517351030400267730ustar00rootroot00000000000000string = "Is there life after strings?" No. emancu-toml-rb-686fcc3/test/examples/invalid/string/wrong-close.toml000066400000000000000000000000471517351030400256450ustar00rootroot00000000000000bad-ending-quote = "double and single' emancu-toml-rb-686fcc3/test/examples/invalid/table-array-implicit.toml000066400000000000000000000011601517351030400261100ustar00rootroot00000000000000# This test is a bit tricky. It should fail because the first use of # `[[albums.songs]]` without first declaring `albums` implies that `albums` # must be a table. The alternative would be quite weird. Namely, it wouldn't # comply with the TomlRB spec: "Each double-bracketed sub-table will belong to # the most *recently* defined table element *above* it." # # This is in contrast to the *valid* test, table-array-implicit where # `[[albums.songs]]` works by itself, so long as `[[albums]]` isn't declared # later. (Although, `[albums]` could be.) [[albums.songs]] name = "Glory Days" [[albums]] name = "Born in the USA" emancu-toml-rb-686fcc3/test/examples/invalid/table-array-malformed-bracket.toml000066400000000000000000000000371517351030400276570ustar00rootroot00000000000000[[albums] name = "Born to Run" emancu-toml-rb-686fcc3/test/examples/invalid/table-array-malformed-empty.toml000066400000000000000000000000321517351030400273750ustar00rootroot00000000000000[[]] name = "Born to Run" emancu-toml-rb-686fcc3/test/examples/invalid/table-array-override-table-name.toml000066400000000000000000000002761517351030400301270ustar00rootroot00000000000000# INVALID TomlRB DOC [[fruit]] name = "apple" [[fruit.variety]] name = "red delicious" # This table conflicts with the previous table [fruit.variety] name = "granny smith" emancu-toml-rb-686fcc3/test/examples/invalid/table-empty.toml000066400000000000000000000000031517351030400243130ustar00rootroot00000000000000[] emancu-toml-rb-686fcc3/test/examples/invalid/table-nested-brackets-close.toml000066400000000000000000000000171517351030400273430ustar00rootroot00000000000000[a]b] zyx = 42 emancu-toml-rb-686fcc3/test/examples/invalid/table-nested-brackets-open.toml000066400000000000000000000000171517351030400271770ustar00rootroot00000000000000[a[b] zyx = 42 emancu-toml-rb-686fcc3/test/examples/invalid/table-whitespace.toml000066400000000000000000000000151517351030400253140ustar00rootroot00000000000000[invalid key]emancu-toml-rb-686fcc3/test/examples/invalid/table-with-double-period.toml000066400000000000000000000000171517351030400266650ustar00rootroot00000000000000[invalid..key] emancu-toml-rb-686fcc3/test/examples/invalid/table-with-ending-period.toml000066400000000000000000000000131517351030400266530ustar00rootroot00000000000000[invalid.] emancu-toml-rb-686fcc3/test/examples/invalid/table-with-pound.toml000066400000000000000000000000271517351030400252610ustar00rootroot00000000000000[key#group] answer = 42emancu-toml-rb-686fcc3/test/examples/invalid/table-with-starting-period.toml000066400000000000000000000000131517351030400272420ustar00rootroot00000000000000[.invalid] emancu-toml-rb-686fcc3/test/examples/invalid/table/000077500000000000000000000000001517351030400222715ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/invalid/table/append-to-array-with-dotted-keys.toml000066400000000000000000000000251517351030400313710ustar00rootroot00000000000000[[a.b]] [a] b.y = 2 emancu-toml-rb-686fcc3/test/examples/invalid/table/array-empty.toml000066400000000000000000000000321517351030400254330ustar00rootroot00000000000000[[]] name = "Born to Run" emancu-toml-rb-686fcc3/test/examples/invalid/table/array-implicit.toml000066400000000000000000000011561517351030400261170ustar00rootroot00000000000000# This test is a bit tricky. It should fail because the first use of # `[[albums.songs]]` without first declaring `albums` implies that `albums` # must be a table. The alternative would be quite weird. Namely, it wouldn't # comply with the TOML spec: "Each double-bracketed sub-table will belong to # the most *recently* defined table element *above* it." # # This is in contrast to the *valid* test, table-array-implicit where # `[[albums.songs]]` works by itself, so long as `[[albums]]` isn't declared # later. (Although, `[albums]` could be.) [[albums.songs]] name = "Glory Days" [[albums]] name = "Born in the USA" emancu-toml-rb-686fcc3/test/examples/invalid/table/array-no-close-1.toml000066400000000000000000000000371517351030400261570ustar00rootroot00000000000000[[albums] name = "Born to Run" emancu-toml-rb-686fcc3/test/examples/invalid/table/array-no-close-2.toml000066400000000000000000000000421517351030400261540ustar00rootroot00000000000000[[closing-bracket.missing] blaa=2 emancu-toml-rb-686fcc3/test/examples/invalid/table/array-then-table.toml000066400000000000000000000001571517351030400263300ustar00rootroot00000000000000# Defining [[foo]] as array of tables then [foo] as regular table is invalid [[foo]] a = true [foo] b = false emancu-toml-rb-686fcc3/test/examples/invalid/table/duplicate-key-dotted-array.toml000066400000000000000000000000551517351030400303230ustar00rootroot00000000000000[fruit] apple.color = "red" [[fruit.apple]] emancu-toml-rb-686fcc3/test/examples/invalid/table/duplicate-key-table.toml000066400000000000000000000000631517351030400270120ustar00rootroot00000000000000[fruit] type = "apple" [fruit.type] apple = "yes" emancu-toml-rb-686fcc3/test/examples/invalid/table/duplicate-table-array.toml000066400000000000000000000000161517351030400273360ustar00rootroot00000000000000[tbl] [[tbl]] emancu-toml-rb-686fcc3/test/examples/invalid/table/duplicate.toml000066400000000000000000000000251517351030400251350ustar00rootroot00000000000000[a] b = 1 [a] c = 2 emancu-toml-rb-686fcc3/test/examples/invalid/table/empty-implicit-table.toml000066400000000000000000000000231517351030400272140ustar00rootroot00000000000000[naughty..naughty] emancu-toml-rb-686fcc3/test/examples/invalid/table/empty.toml000066400000000000000000000000031517351030400243150ustar00rootroot00000000000000[] emancu-toml-rb-686fcc3/test/examples/invalid/table/equals-sign.toml000066400000000000000000000000131517351030400254100ustar00rootroot00000000000000[name=bad] emancu-toml-rb-686fcc3/test/examples/invalid/table/llbrace.toml000066400000000000000000000000131517351030400245640ustar00rootroot00000000000000[ [table]] emancu-toml-rb-686fcc3/test/examples/invalid/table/nested-brackets-close.toml000066400000000000000000000000171517351030400273450ustar00rootroot00000000000000[a]b] zyx = 42 emancu-toml-rb-686fcc3/test/examples/invalid/table/nested-brackets-open.toml000066400000000000000000000000171517351030400272010ustar00rootroot00000000000000[a[b] zyx = 42 emancu-toml-rb-686fcc3/test/examples/invalid/table/no-close-1.toml000066400000000000000000000000411517351030400250360ustar00rootroot00000000000000[where will it end name = value emancu-toml-rb-686fcc3/test/examples/invalid/table/no-close-2.toml000066400000000000000000000000421517351030400250400ustar00rootroot00000000000000[closing-bracket.missingö blaa=2 emancu-toml-rb-686fcc3/test/examples/invalid/table/no-close-3.toml000066400000000000000000000000431517351030400250420ustar00rootroot00000000000000["where will it end] name = value emancu-toml-rb-686fcc3/test/examples/invalid/table/no-close-4.toml000066400000000000000000000000021517351030400250360ustar00rootroot00000000000000[ emancu-toml-rb-686fcc3/test/examples/invalid/table/no-close-5.toml000066400000000000000000000000131517351030400250410ustar00rootroot00000000000000[fwfw.wafw emancu-toml-rb-686fcc3/test/examples/invalid/table/overwrite-array-in-parent.toml000066400000000000000000000000701517351030400302200ustar00rootroot00000000000000[[parent-table.arr]] [parent-table] not-arr = 1 arr = 2 emancu-toml-rb-686fcc3/test/examples/invalid/table/overwrite-with-deep-table.toml000066400000000000000000000000161517351030400301620ustar00rootroot00000000000000a=1 [a.b.c.d] emancu-toml-rb-686fcc3/test/examples/invalid/table/redefine-1.toml000066400000000000000000000001161517351030400251030ustar00rootroot00000000000000# Define b as int, and try to use it as a table: error [a] b = 1 [a.b] c = 2 emancu-toml-rb-686fcc3/test/examples/invalid/table/rrbrace.toml000066400000000000000000000000131517351030400246000ustar00rootroot00000000000000[[table] ] emancu-toml-rb-686fcc3/test/examples/invalid/table/super-twice.toml000066400000000000000000000000161517351030400254320ustar00rootroot00000000000000[a.b] [a] [a] emancu-toml-rb-686fcc3/test/examples/invalid/table/text-after-table.toml000066400000000000000000000000371517351030400263360ustar00rootroot00000000000000[error] this shouldn't be here emancu-toml-rb-686fcc3/test/examples/invalid/table/whitespace.toml000066400000000000000000000000161517351030400253170ustar00rootroot00000000000000[invalid key] emancu-toml-rb-686fcc3/test/examples/invalid/table/with-pound.toml000066400000000000000000000000301517351030400252550ustar00rootroot00000000000000[key#group] answer = 42 emancu-toml-rb-686fcc3/test/examples/invalid/text-after-array-entries.toml000066400000000000000000000001061517351030400267420ustar00rootroot00000000000000array = [ "Is there life after an array separator?", No "Entry" ] emancu-toml-rb-686fcc3/test/examples/invalid/text-after-integer.toml000066400000000000000000000000411517351030400256100ustar00rootroot00000000000000answer = 42 the ultimate answer? emancu-toml-rb-686fcc3/test/examples/invalid/text-after-string.toml000066400000000000000000000000541517351030400254650ustar00rootroot00000000000000string = "Is there life after strings?" No. emancu-toml-rb-686fcc3/test/examples/invalid/text-after-table.toml000066400000000000000000000000371517351030400252470ustar00rootroot00000000000000[error] this shouldn't be here emancu-toml-rb-686fcc3/test/examples/invalid/text-before-array-separator.toml000066400000000000000000000001071517351030400274330ustar00rootroot00000000000000array = [ "Is there life before an array separator?" No, "Entry" ] emancu-toml-rb-686fcc3/test/examples/invalid/text-in-array.toml000066400000000000000000000000701517351030400246000ustar00rootroot00000000000000array = [ "Entry 1", I don't belong, "Entry 2", ] emancu-toml-rb-686fcc3/test/examples/valid/000077500000000000000000000000001517351030400206535ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/valid/array-empty.json000066400000000000000000000000361517351030400240170ustar00rootroot00000000000000{ "thevoid": [[[[[]]]]] } emancu-toml-rb-686fcc3/test/examples/valid/array-empty.toml000066400000000000000000000000251517351030400240170ustar00rootroot00000000000000thevoid = [[[[[]]]]] emancu-toml-rb-686fcc3/test/examples/valid/array-mixed-types.json000066400000000000000000000003641517351030400251350ustar00rootroot00000000000000{ "numbers": [ 0.1, 0.2, 0.5, 1, 2, 5 ], "contributors": [ "Foo Bar ", { "email": "bazqux@example.com", "name": "Baz Qux", "url": "https://example.com/bazqux" } ] } emancu-toml-rb-686fcc3/test/examples/valid/array-mixed-types.toml000066400000000000000000000003201517351030400251270ustar00rootroot00000000000000# Mixed-type arrays are allowed numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ] contributors = [ "Foo Bar ", { name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" } ] emancu-toml-rb-686fcc3/test/examples/valid/array-nested.json000066400000000000000000000001171517351030400241430ustar00rootroot00000000000000{ "nest": [["a"], ["b"]], "nested_mixed": [[ 1, 2], ["a", "b", "c"]] } emancu-toml-rb-686fcc3/test/examples/valid/array-nested.toml000066400000000000000000000001031517351030400241400ustar00rootroot00000000000000nest = [["a"], ["b"]] nested_mixed = [ [ 1, 2 ], ["a", "b", "c"] ] emancu-toml-rb-686fcc3/test/examples/valid/array-nospaces.json000066400000000000000000000000301517351030400244660ustar00rootroot00000000000000{ "ints": [1,2,3] } emancu-toml-rb-686fcc3/test/examples/valid/array-nospaces.toml000066400000000000000000000000171517351030400244750ustar00rootroot00000000000000ints = [1,2,3] emancu-toml-rb-686fcc3/test/examples/valid/array.json000066400000000000000000000005211517351030400226620ustar00rootroot00000000000000{ "ints": [1, 2, 3], "floats": [1.1, 2.1, 3.1, 410000.0], "strings": ["all", "strings", "are the same", "type"], "multiline_strings": ["This is a test string", "Other test string"], "multiline_literal": ["This is a test string", "Other test string"], "ignore_whitespace": [1,2,3,4], "trailing_comma": [1,2] } emancu-toml-rb-686fcc3/test/examples/valid/array.toml000066400000000000000000000010011517351030400226560ustar00rootroot00000000000000ints = [1, 2, 3] floats = [1.1, 2.1, 3.1, 4.1E+5] strings = [ "all", 'strings', """are the same""", '''type''' ] multiline_strings = ["""\ This \ is \ a \ test \ string""", "Other test string"] multiline_literal = ['''\ This \ is \ a \ test \ string''', "Other test string"] ignore_whitespace = [ 1 ,2 ,3 ,4 ] trailing_comma = [ 1, 2, # this is ok ] emancu-toml-rb-686fcc3/test/examples/valid/bool.json000066400000000000000000000000421517351030400224750ustar00rootroot00000000000000{ "f": false, "t": true } emancu-toml-rb-686fcc3/test/examples/valid/bool.toml000066400000000000000000000000231517351030400224760ustar00rootroot00000000000000t = true f = false emancu-toml-rb-686fcc3/test/examples/valid/comments-everywhere.json000066400000000000000000000001161517351030400255540ustar00rootroot00000000000000{ "group": { "answer": 42, "more": [ 42, 42 ] } } emancu-toml-rb-686fcc3/test/examples/valid/comments-everywhere.toml000066400000000000000000000007251517351030400255640ustar00rootroot00000000000000# Top comment. # Top comment. # Top comment. # [no-extraneous-groups-please] [group] # Comment answer = 42 # Comment # no-extraneous-keys-please = 999 # Between comment. more = [ # Comment # What about multiple # comments? # Can you handle it? # # Evil. # Evil. 42, 42, # Comments within arrays are fun. # What about multiple # comments? # Can you handle it? # # Evil. # Such evil # Evil. # ] Did I fool you? ] # Hopefully not. emancu-toml-rb-686fcc3/test/examples/valid/empty.json000066400000000000000000000000031517351030400226750ustar00rootroot00000000000000{} emancu-toml-rb-686fcc3/test/examples/valid/empty.toml000066400000000000000000000000001517351030400226740ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/valid/example.json000066400000000000000000000001451517351030400232010ustar00rootroot00000000000000{ "numtheory": { "boring": false, "perfection": [ 6, 28, 496 ] } } emancu-toml-rb-686fcc3/test/examples/valid/example.toml000066400000000000000000000000651517351030400232040ustar00rootroot00000000000000[numtheory] boring = false perfection = [6, 28, 496] emancu-toml-rb-686fcc3/test/examples/valid/float.json000066400000000000000000000000471517351030400226540ustar00rootroot00000000000000{ "pi": 3.14, "negpi": -3.14 } emancu-toml-rb-686fcc3/test/examples/valid/float.toml000066400000000000000000000000301517351030400226460ustar00rootroot00000000000000pi = 3.14 negpi = -3.14 emancu-toml-rb-686fcc3/test/examples/valid/implicit-and-explicit-after.json000066400000000000000000000002021517351030400270300ustar00rootroot00000000000000{ "a": { "better": 43, "b": { "c": { "answer": 42 } } } } emancu-toml-rb-686fcc3/test/examples/valid/implicit-and-explicit-after.toml000066400000000000000000000000451517351030400270370ustar00rootroot00000000000000[a.b.c] answer = 42 [a] better = 43 emancu-toml-rb-686fcc3/test/examples/valid/implicit-and-explicit-before.json000066400000000000000000000002021517351030400271710ustar00rootroot00000000000000{ "a": { "better": 43, "b": { "c": { "answer": 42 } } } } emancu-toml-rb-686fcc3/test/examples/valid/implicit-and-explicit-before.toml000066400000000000000000000000451517351030400272000ustar00rootroot00000000000000[a] better = 43 [a.b.c] answer = 42 emancu-toml-rb-686fcc3/test/examples/valid/implicit-groups.json000066400000000000000000000001541517351030400246750ustar00rootroot00000000000000{ "a": { "b": { "c": { "answer": 42 } } } } emancu-toml-rb-686fcc3/test/examples/valid/implicit-groups.toml000066400000000000000000000000241517351030400246730ustar00rootroot00000000000000[a.b.c] answer = 42 emancu-toml-rb-686fcc3/test/examples/valid/inline-table/000077500000000000000000000000001517351030400232165ustar00rootroot00000000000000emancu-toml-rb-686fcc3/test/examples/valid/inline-table/multiline.json000066400000000000000000000005201517351030400261100ustar00rootroot00000000000000{ "dependencies": { "windows-sys": { "version": "0.61.2", "features": [ "Win32_System_Environment", "Win32_Storage_FileSystem", "Win32_System_Memory" ] }, "empty": {}, "single": { "a": 1, "b": 2 }, "with-comments": { "x": 1, "y": 2 } } } emancu-toml-rb-686fcc3/test/examples/valid/inline-table/multiline.toml000066400000000000000000000004351517351030400261170ustar00rootroot00000000000000[dependencies] windows-sys = { version = "0.61.2", features = [ "Win32_System_Environment", "Win32_Storage_FileSystem", "Win32_System_Memory", ], } empty = { } single = { a = 1, b = 2 } with-comments = { # leading comment x = 1, # trailing comment y = 2, } emancu-toml-rb-686fcc3/test/examples/valid/inline-table/with-dotted-keys.json000066400000000000000000000007131517351030400273170ustar00rootroot00000000000000{ "tool": { "ruff": { "target-version": "py310", "lint": { "ignore": [ "B008", "C901", "RUF012", "RUF029", "UP007" ], "integer": 81, "per-file-ignores": { "__init__.py": [ "F401" ], "migrations/versions/*.py": [ "E501", "W291" ] }, "enable": true } } } } emancu-toml-rb-686fcc3/test/examples/valid/inline-table/with-dotted-keys.toml000066400000000000000000000003551517351030400273230ustar00rootroot00000000000000[tool.ruff] target-version = "py310" lint.enable = true lint.per-file-ignores = { "__init__.py" = ["F401"], "migrations/versions/*.py" = ["E501", "W291"] } lint.ignore = [ "B008", "C901", "RUF012", "RUF029", "UP007" ] lint.integer = 81 emancu-toml-rb-686fcc3/test/examples/valid/inline-table/with-quoted-dotted-keys.json000066400000000000000000000004211517351030400306120ustar00rootroot00000000000000{ "package": [ { "name": "bleak", "dependencies": { "winrt-Windows.Devices.Bluetooth": { "version": ">=3.1" }, "winrt-Windows.Devices.Bluetooth.Advertisement": { "version": ">=3.1" } } } ] } emancu-toml-rb-686fcc3/test/examples/valid/inline-table/with-quoted-dotted-keys.toml000066400000000000000000000002611517351030400306160ustar00rootroot00000000000000[[package]] name = "bleak" [package.dependencies] "winrt-Windows.Devices.Bluetooth" = {version = ">=3.1"} "winrt-Windows.Devices.Bluetooth.Advertisement" = {version = ">=3.1"} emancu-toml-rb-686fcc3/test/examples/valid/integer.json000066400000000000000000000000471517351030400232040ustar00rootroot00000000000000{ "answer": 42, "neganswer": -42 } emancu-toml-rb-686fcc3/test/examples/valid/integer.toml000066400000000000000000000000341517351030400232020ustar00rootroot00000000000000answer = 42 neganswer = -42 emancu-toml-rb-686fcc3/test/examples/valid/key-equals-nospace.json000066400000000000000000000000251517351030400252510ustar00rootroot00000000000000{ "answer": 42 } emancu-toml-rb-686fcc3/test/examples/valid/key-equals-nospace.toml000066400000000000000000000000121517351030400252470ustar00rootroot00000000000000answer=42 emancu-toml-rb-686fcc3/test/examples/valid/key-space.json000066400000000000000000000000211517351030400234200ustar00rootroot00000000000000{ "a b": 1 } emancu-toml-rb-686fcc3/test/examples/valid/key-space.toml000066400000000000000000000000121517351030400234220ustar00rootroot00000000000000"a b" = 1 emancu-toml-rb-686fcc3/test/examples/valid/key-special-chars.json000066400000000000000000000000611517351030400250470ustar00rootroot00000000000000{ "~!@$^&*()_+-`1234567890[]|/?><.,;:'": 1 } emancu-toml-rb-686fcc3/test/examples/valid/key-special-chars.toml000066400000000000000000000000521517351030400250510ustar00rootroot00000000000000"~!@$^&*()_+-`1234567890[]|/?><.,;:'" = 1 emancu-toml-rb-686fcc3/test/examples/valid/key-starts-with-number.json000066400000000000000000000000531517351030400261110ustar00rootroot00000000000000{ "123-key": "value", "12345": 67890 } emancu-toml-rb-686fcc3/test/examples/valid/key-starts-with-number.toml000066400000000000000000000000401517351030400261070ustar00rootroot00000000000000123-key = "value" 12345 = 67890 emancu-toml-rb-686fcc3/test/examples/valid/key-with-pound.json000066400000000000000000000000261517351030400244300ustar00rootroot00000000000000{ "key#name": 5 } emancu-toml-rb-686fcc3/test/examples/valid/key-with-pound.toml000066400000000000000000000000171517351030400244320ustar00rootroot00000000000000"key#name" = 5 emancu-toml-rb-686fcc3/test/examples/valid/long-float.json000066400000000000000000000001051517351030400236040ustar00rootroot00000000000000{ "longpi": 3.141592653589793, "neglongpi": -3.141592653589793 } emancu-toml-rb-686fcc3/test/examples/valid/long-float.toml000066400000000000000000000000721517351030400236110ustar00rootroot00000000000000longpi = 3.141592653589793 neglongpi = -3.141592653589793 emancu-toml-rb-686fcc3/test/examples/valid/long-integer.json000066400000000000000000000001111517351030400241310ustar00rootroot00000000000000{ "answer": 9223372036854775807, "neganswer": -9223372036854775808 } emancu-toml-rb-686fcc3/test/examples/valid/long-integer.toml000066400000000000000000000000761517351030400241450ustar00rootroot00000000000000answer = 9223372036854775807 neganswer = -9223372036854775808 emancu-toml-rb-686fcc3/test/examples/valid/multiline-string.json000066400000000000000000000005521517351030400250560ustar00rootroot00000000000000{ "multiline_empty_one": "", "multiline_empty_two": "", "multiline_empty_three": "", "multiline_empty_four": "", "equivalent_one": "The quick brown fox jumps over the lazy dog.", "equivalent_two": "The quick brown fox jumps over the lazy dog.", "equivalent_three": "The quick brown fox jumps over the lazy dog.", "issue_89": "\"Hello\nWorld\"" } emancu-toml-rb-686fcc3/test/examples/valid/multiline-string.toml000066400000000000000000000006511517351030400250600ustar00rootroot00000000000000multiline_empty_one = "" multiline_empty_two = """\ """ multiline_empty_three = """\ """ multiline_empty_four = """\ \ \ """ equivalent_one = "The quick brown fox jumps over the lazy dog." equivalent_two = """ The quick brown \ fox jumps over \ the lazy dog.""" equivalent_three = """\ The quick brown \ fox jumps over \ the lazy dog.\ """ issue_89 = """\"Hello World\"""" emancu-toml-rb-686fcc3/test/examples/valid/raw-multiline-string.json000066400000000000000000000003101517351030400256350ustar00rootroot00000000000000{ "oneline": "This string has a ' quote character.", "firstnl": "This string has a ' quote character.", "multiline": "This string\nhas ' a quote character\nand more than\none newline\nin it." } emancu-toml-rb-686fcc3/test/examples/valid/raw-multiline-string.toml000066400000000000000000000003031517351030400256410ustar00rootroot00000000000000oneline = '''This string has a ' quote character.''' firstnl = ''' This string has a ' quote character.''' multiline = ''' This string has ' a quote character and more than one newline in it.''' emancu-toml-rb-686fcc3/test/examples/valid/raw-string.json000066400000000000000000000006341517351030400236460ustar00rootroot00000000000000{ "backspace": "This string has a \\b backspace character.", "tab": "This string has a \\t tab character.", "newline": "This string has a \\n new line character.", "formfeed": "This string has a \\f form feed character.", "carriage": "This string has a \\r carriage return character.", "slash": "This string has a \\/ slash character.", "backslash": "This string has a \\\\ backslash character." } emancu-toml-rb-686fcc3/test/examples/valid/raw-string.toml000066400000000000000000000005651517351030400236530ustar00rootroot00000000000000backspace = 'This string has a \b backspace character.' tab = 'This string has a \t tab character.' newline = 'This string has a \n new line character.' formfeed = 'This string has a \f form feed character.' carriage = 'This string has a \r carriage return character.' slash = 'This string has a \/ slash character.' backslash = 'This string has a \\ backslash character.' emancu-toml-rb-686fcc3/test/examples/valid/string-empty.json000066400000000000000000000000251517351030400242050ustar00rootroot00000000000000{ "answer": "" } emancu-toml-rb-686fcc3/test/examples/valid/string-empty.toml000066400000000000000000000000141517351030400242050ustar00rootroot00000000000000answer = "" emancu-toml-rb-686fcc3/test/examples/valid/string-escapes.json000066400000000000000000000013151517351030400244750ustar00rootroot00000000000000{ "backspace": "This string has a \u0008 backspace character.", "tab": "This string has a \u0009 tab character.", "newline": "This string has a \u000A new line character.", "formfeed": "This string has a \u000C form feed character.", "carriage": "This string has a \u000D carriage return character.", "quote": "This string has a \u0022 quote character.", "backslash": "This string has a \u005C backslash character.", "notunicode1": "This string does not have a unicode \\u escape.", "notunicode2": "This string does not have a unicode \u005Cu escape.", "notunicode3": "This string does not have a unicode \\u0075 escape.", "notunicode4": "This string does not have a unicode \\\u0075 escape." } emancu-toml-rb-686fcc3/test/examples/valid/string-escapes.toml000066400000000000000000000012021517351030400244720ustar00rootroot00000000000000backspace = "This string has a \b backspace character." tab = "This string has a \t tab character." newline = "This string has a \n new line character." formfeed = "This string has a \f form feed character." carriage = "This string has a \r carriage return character." quote = "This string has a \" quote character." backslash = "This string has a \\ backslash character." notunicode1 = "This string does not have a unicode \\u escape." notunicode2 = "This string does not have a unicode \u005Cu escape." notunicode3 = "This string does not have a unicode \\u0075 escape." notunicode4 = "This string does not have a unicode \\\u0075 escape." emancu-toml-rb-686fcc3/test/examples/valid/string-simple.json000066400000000000000000000000661517351030400243450ustar00rootroot00000000000000{ "answer": "You are not drinking enough whisky." } emancu-toml-rb-686fcc3/test/examples/valid/string-simple.toml000066400000000000000000000000571517351030400243470ustar00rootroot00000000000000answer = "You are not drinking enough whisky." emancu-toml-rb-686fcc3/test/examples/valid/string-with-pound.json000066400000000000000000000001451517351030400251500ustar00rootroot00000000000000{ "pound": "We see no # comments here.", "poundcomment": "But there are # some comments here." } emancu-toml-rb-686fcc3/test/examples/valid/string-with-pound.toml000066400000000000000000000001611517351030400251500ustar00rootroot00000000000000pound = "We see no # comments here." poundcomment = "But there are # some comments here." # Did I # mess you up? emancu-toml-rb-686fcc3/test/examples/valid/table-array-implicit.json000066400000000000000000000001301517351030400255530ustar00rootroot00000000000000{ "albums": { "songs": [ { "name": "Glory Days" } ] } } emancu-toml-rb-686fcc3/test/examples/valid/table-array-implicit.toml000066400000000000000000000000451517351030400255620ustar00rootroot00000000000000[[albums.songs]] name = "Glory Days" emancu-toml-rb-686fcc3/test/examples/valid/table-array-many.json000066400000000000000000000003511517351030400247120ustar00rootroot00000000000000{ "people": [ { "first_name": "Bruce", "last_name": "Springsteen" }, { "first_name": "Eric", "last_name": "Clapton" }, { "first_name": "Bob", "last_name": "Seger" } ] } emancu-toml-rb-686fcc3/test/examples/valid/table-array-many.toml000066400000000000000000000002431517351030400247140ustar00rootroot00000000000000[[people]] first_name = "Bruce" last_name = "Springsteen" [[people]] first_name = "Eric" last_name = "Clapton" [[people]] first_name = "Bob" last_name = "Seger" emancu-toml-rb-686fcc3/test/examples/valid/table-array-nest.json000066400000000000000000000005771517351030400247310ustar00rootroot00000000000000{ "fruit": [ { "name": "apple", "physical": { "color": "red", "shape": "round" }, "variety": [ { "name": "red delicious" }, { "name": "granny smith" } ] }, { "name": "banana", "physical": { "color": "yellow" }, "variety": [ { "name": "plantain" } ] } ] } emancu-toml-rb-686fcc3/test/examples/valid/table-array-nest.toml000066400000000000000000000004451517351030400247250ustar00rootroot00000000000000[[fruit]] name = "apple" [fruit.physical] color = "red" shape = "round" [[fruit.variety]] name = "red delicious" [[fruit.variety]] name = "granny smith" [[fruit]] name = "banana" [fruit.physical] color = "yellow" [[fruit.variety]] name = "plantain" emancu-toml-rb-686fcc3/test/examples/valid/table-array-one.json000066400000000000000000000001401517351030400245230ustar00rootroot00000000000000{ "people": [ { "first_name": "Bruce", "last_name": "Springsteen" } ] } emancu-toml-rb-686fcc3/test/examples/valid/table-array-one.toml000066400000000000000000000000721517351030400245310ustar00rootroot00000000000000[[people]] first_name = "Bruce" last_name = "Springsteen" emancu-toml-rb-686fcc3/test/examples/valid/table-array-whitespace.json000066400000000000000000000001751517351030400261060ustar00rootroot00000000000000{ "people": { "attrs": [ { "first_name": "Bruce", "last_name": "Springsteen" } ] } } emancu-toml-rb-686fcc3/test/examples/valid/table-array-whitespace.toml000066400000000000000000000001031517351030400260770ustar00rootroot00000000000000[[ people .attrs ]] first_name = "Bruce" last_name = "Springsteen" emancu-toml-rb-686fcc3/test/examples/valid/table-empty.json000066400000000000000000000000201517351030400237610ustar00rootroot00000000000000{ "a": {} } emancu-toml-rb-686fcc3/test/examples/valid/table-empty.toml000066400000000000000000000000041517351030400237650ustar00rootroot00000000000000[a] emancu-toml-rb-686fcc3/test/examples/valid/table-sub-empty.json000066400000000000000000000000311517351030400245520ustar00rootroot00000000000000{ "a": { "b": {} } } emancu-toml-rb-686fcc3/test/examples/valid/table-sub-empty.toml000066400000000000000000000000121517351030400245530ustar00rootroot00000000000000[a] [a.b] emancu-toml-rb-686fcc3/test/examples/valid/table-whitespace.json000066400000000000000000000001601517351030400247640ustar00rootroot00000000000000{ "valid key": {}, "also": { "valid": {} }, "apparently": { "this.is": { "valid": { "too": {} }}} } emancu-toml-rb-686fcc3/test/examples/valid/table-whitespace.toml000066400000000000000000000001031517351030400247630ustar00rootroot00000000000000["valid key"] [ also.valid ] [ apparently . "this.is". valid.too ] emancu-toml-rb-686fcc3/test/examples/valid/table-with-pound.json000066400000000000000000000000521517351030400247260ustar00rootroot00000000000000{ "key#group": { "answer": 42 } } emancu-toml-rb-686fcc3/test/examples/valid/table-with-pound.toml000066400000000000000000000000321517351030400247260ustar00rootroot00000000000000["key#group"] answer = 42 emancu-toml-rb-686fcc3/test/examples/valid/unicode-escape.json000066400000000000000000000000611517351030400244270ustar00rootroot00000000000000{ "answer4": "\u03B4", "answer8": "\u03B4" } emancu-toml-rb-686fcc3/test/examples/valid/unicode-escape.toml000066400000000000000000000000521517351030400244310ustar00rootroot00000000000000answer4 = "\u03B4" answer8 = "\U000003B4" emancu-toml-rb-686fcc3/test/examples/valid/unicode-literal.json000066400000000000000000000000251517351030400246230ustar00rootroot00000000000000{ "answer": "δ" } emancu-toml-rb-686fcc3/test/examples/valid/unicode-literal.toml000066400000000000000000000000161517351030400246250ustar00rootroot00000000000000answer = "δ" emancu-toml-rb-686fcc3/test/grammar_test.rb000066400000000000000000000256311517351030400207570ustar00rootroot00000000000000require_relative "helper" class GrammarTest < Minitest::Test def test_comment match = TomlRB::Document.parse(" # A comment", root: :comment) assert_nil(match.value) end def test_key match = TomlRB::Document.parse("bad_key-", root: :key) assert_equal("bad_key-", match.value.first) match = TomlRB::Document.parse('"123.ʎǝʞ.#?"', root: :key) assert_equal("123.ʎǝʞ.#?", match.value.first) end def test_table indentation_alternatives_for("[akey]") do |str| match = TomlRB::Document.parse(str, root: :table) assert_equal(TomlRB::Table, match.value.class) assert_equal(["akey"], match.value.instance_variable_get(:@dotted_keys)) end match = TomlRB::Document.parse("[owner.emancu]", root: :table) assert_equal(%w[owner emancu], match.value.instance_variable_get(:@dotted_keys)) match = TomlRB::Document.parse('["owner.emancu"]', root: :table) assert_equal(%w[owner.emancu], match.value.instance_variable_get(:@dotted_keys)) match = TomlRB::Document.parse('["first key"."second key"]', root: :table) assert_equal(["first key", "second key"], match.value.instance_variable_get(:@dotted_keys)) match = TomlRB::Document.parse("[ owner . emancu ]", root: :table) assert_equal(%w[owner emancu], match.value.instance_variable_get(:@dotted_keys)) assert_raises Citrus::ParseError do TomlRB::Document.parse("[ owner emancu ]", root: :table) end end def test_keyvalue indentation_alternatives_for('key = "value"') do |str| match = TomlRB::Document.parse(str, root: :keyvalue) assert_equal(TomlRB::Keyvalue, match.value.class) keyvalue = match.value assert_equal("key", keyvalue.instance_variable_get(:@dotted_keys).first) assert_equal("value", keyvalue.instance_variable_get(:@value)) end indentation_alternatives_for('key1."key2".key3 = "value"') do |str| match = TomlRB::Document.parse(str, root: :keyvalue) assert_equal(TomlRB::Keyvalue, match.value.class) keyvalue = match.value assert_equal("key1", keyvalue.instance_variable_get(:@dotted_keys)[0]) assert_equal("key2", keyvalue.instance_variable_get(:@dotted_keys)[1]) assert_equal("key3", keyvalue.instance_variable_get(:@dotted_keys)[2]) assert_equal("value", keyvalue.instance_variable_get(:@value)) end end def test_string match = TomlRB::Document.parse('"TomlRB-Example, should work."', root: :string) assert_equal("TomlRB-Example, should work.", match.value) end def test_multiline_string match = TomlRB::Document.parse('"""\tOne\nTwo"""', root: :multiline_string) assert_equal "\tOne\nTwo", match.value to_parse = '"""\ One \ Two\ """' match = TomlRB::Document.parse(to_parse, root: :multiline_string) assert_equal "One Two", match.value end def test_empty_multiline_string to_parse = '""""""' match = TomlRB::Document.parse(to_parse, root: :multiline_string) assert_equal "", match.value end def test_special_characters match = TomlRB::Document.parse('"\0 \" \t \n \r"', root: :string) assert_equal("\0 \" \t \n \r", match.value) match = TomlRB::Document.parse('"C:\\\\Documents\\\\nada.exe"', root: :string) assert_equal("C:\\Documents\\nada.exe", match.value) end def test_bool match = TomlRB::Document.parse("true", root: :bool) assert_equal(true, match.value) match = TomlRB::Document.parse("false", root: :bool) assert_equal(false, match.value) end def test_integer match = TomlRB::Document.parse("+99", root: :integer) assert_equal(99, match.value) match = TomlRB::Document.parse("42", root: :integer) assert_equal(42, match.value) match = TomlRB::Document.parse("0", root: :integer) assert_equal(0, match.value) match = TomlRB::Document.parse("-17", root: :integer) assert_equal(-17, match.value) match = TomlRB::Document.parse("1_000", root: :integer) assert_equal(1_000, match.value) match = TomlRB::Document.parse("5_349_221", root: :integer) assert_equal(5_349_221, match.value) match = TomlRB::Document.parse("1_2_3_4_5", root: :integer) assert_equal(1_2_3_4_5, match.value) match = TomlRB::Document.parse("0xDEADBEEF", root: :integer) assert_equal(0xDEADBEEF, match.value) match = TomlRB::Document.parse("0xdeadbeef", root: :integer) assert_equal(0xdeadbeef, match.value) match = TomlRB::Document.parse("0xdead_beef", root: :integer) assert_equal(0xdead_beef, match.value) match = TomlRB::Document.parse("0o01234567", root: :integer) assert_equal(0o01234567, match.value) match = TomlRB::Document.parse("0o755", root: :integer) assert_equal(0o755, match.value) match = TomlRB::Document.parse("0b11010110", root: :integer) assert_equal(0b11010110, match.value) end def test_float match = TomlRB::Document.parse("+1.0", root: :float) assert_equal(+1.0, match.value) match = TomlRB::Document.parse("3.1415", root: :float) assert_equal(3.1415, match.value) match = TomlRB::Document.parse("-0.01", root: :float) assert_equal(-0.01, match.value) match = TomlRB::Document.parse("5e+22", root: :float) assert_equal(5e+22, match.value) match = TomlRB::Document.parse("1e6", root: :float) assert_equal(1e6, match.value) match = TomlRB::Document.parse("-2E-2", root: :float) assert_equal(-2E-2, match.value) match = TomlRB::Document.parse("6.626e-34", root: :float) assert_equal(6.626e-34, match.value) match = TomlRB::Document.parse("224_617.445_991_228", root: :float) assert_equal(224_617.445_991_228, match.value) match = TomlRB::Document.parse("inf", root: :float) assert_equal(Float::INFINITY, match.value) match = TomlRB::Document.parse("+inf", root: :float) assert_equal(Float::INFINITY, match.value) match = TomlRB::Document.parse("-inf", root: :float) assert_equal(-Float::INFINITY, match.value) match = TomlRB::Document.parse("nan", root: :float) assert(match.value.nan?) match = TomlRB::Document.parse("+nan", root: :float) assert(match.value.nan?) match = TomlRB::Document.parse("-nan", root: :float) assert(match.value.nan?) end def test_signed_numbers match = TomlRB::Document.parse("+26", root: :number) assert_equal(26, match.value) match = TomlRB::Document.parse("-26", root: :number) assert_equal(-26, match.value) match = TomlRB::Document.parse("1.69", root: :number) assert_equal(1.69, match.value) match = TomlRB::Document.parse("-1.69", root: :number) assert_equal(-1.69, match.value) end def test_expressions_with_comments match = TomlRB::Document.parse("[shouldwork] # with comment", root: :table) assert_equal(["shouldwork"], match.value.instance_variable_get(:@dotted_keys)) match = TomlRB::Document.parse("works = true # with comment", root: :keyvalue).value assert_equal("works", match.instance_variable_get(:@dotted_keys).first) assert_equal(true, match.instance_variable_get(:@value)) end def test_array match = TomlRB::Document.parse("[]", root: :array) assert_equal([], match.value) match = TomlRB::Document.parse("[ 2, 4]", root: :array) assert_equal([2, 4], match.value) match = TomlRB::Document.parse("[ 2.4, 4.72]", root: :array) assert_equal([2.4, 4.72], match.value) match = TomlRB::Document.parse('[ "hey", "TomlRB"]', root: :array) assert_equal(%w[hey TomlRB], match.value) match = TomlRB::Document.parse('[ ["hey", "TomlRB"], [2,4] ]', root: :array) assert_equal([%w[hey TomlRB], [2, 4]], match.value) match = TomlRB::Document.parse("[ { one = 1 }, { two = 2, three = 3} ]", root: :array) assert_equal([{"one" => 1}, {"two" => 2, "three" => 3}], match.value) end def test_empty_array # test that [] is parsed as array and not as inline table array match = TomlRB::Document.parse("a = []", root: :keyvalue).value assert_equal [], match.value end def test_multiline_array multiline_array = "[ \"hey\",\n \"ho\",\n\t \"lets\", \"go\",\n ]" match = TomlRB::Document.parse(multiline_array, root: :array) assert_equal(%w[hey ho lets go], match.value) multiline_array = "[\n#1,\n2,\n# 3\n]" match = TomlRB::Document.parse(multiline_array, root: :array) assert_equal([2], match.value) multiline_array = "[\n# comment\n#, more comments\n4]" match = TomlRB::Document.parse(multiline_array, root: :array) assert_equal([4], match.value) multiline_array = "[\n 1,\n # 2,\n 3 ,\n]" match = TomlRB::Document.parse(multiline_array, root: :array) assert_equal([1, 3], match.value) multiline_array = "[\n 1 , # useless comment\n # 2,\n 3 #other comment\n]" match = TomlRB::Document.parse(multiline_array, root: :array) assert_equal([1, 3], match.value) end # Dates are really hard to test from JSON, due the imposibility to represent # datetimes without quotes. def test_datetime match = TomlRB::Document.parse("1979-05-27T07:32:00Z", root: :datetime) assert_equal(Time.utc(1979, 5, 27, 7, 32, 0), match.value) match = TomlRB::Document.parse("1979-05-27T00:32:00-07:00", root: :datetime) assert_equal(Time.new(1979, 5, 27, 0, 32, 0, "-07:00"), match.value) match = TomlRB::Document.parse("1979-05-27T00:32:00.999999-07:00", root: :datetime) assert_equal(Time.new(1979, 5, 27, 0, 32, 0.999999, "-07:00"), match.value) match = TomlRB::Document.parse("1979-05-27 07:32:00Z", root: :datetime) assert_equal(Time.utc(1979, 5, 27, 7, 32, 0), match.value) match = TomlRB::Document.parse("1979-05-27T07:32:00", root: :datetime) assert_equal(Time.local(1979, 5, 27, 7, 32, 0), match.value) match = TomlRB::Document.parse("1979-05-27T00:32:00.999999", root: :datetime) assert_equal(Time.local(1979, 5, 27, 0, 32, 0, 999999), match.value) match = TomlRB::Document.parse("1979-05-27", root: :datetime) assert_equal(Time.local(1979, 5, 27), match.value) match = TomlRB::Document.parse("07:32:00", root: :datetime) assert_equal(Time.at(3600 * 7 + 60 * 32), match.value) match = TomlRB::Document.parse("00:32:00.999999", root: :datetime) assert_equal(Time.at(60 * 32, 999999), match.value) end def test_inline_table match = TomlRB::Document.parse("{ }", root: :inline_table) assert_equal({}, match.value.value) match = TomlRB::Document.parse("{ simple = true, params = 2 }", root: :inline_table) assert_equal({"simple" => true, "params" => 2}, match.value.value) match = TomlRB::Document.parse("{ nest = { really = { hard = true } } }", root: :inline_table) assert_equal({"nest" => {"really" => {"hard" => true}}}, match.value.value) assert_equal({nest: {really: {hard: true}}}, match.value.value(true)) end private # Creates all the alternatives of valid indentations to test def indentation_alternatives_for(str) [str, " #{str}", "\t#{str}", "\t\t#{str}"].each do |alternative| yield(alternative) end end end emancu-toml-rb-686fcc3/test/hard_example.toml000066400000000000000000000027721517351030400212740ustar00rootroot00000000000000# Test file for TomlRB # Only this one tries to emulate a TomlRB file written by a user of the kind of parser writers probably hate # This part you'll really hate [the] test_string = "You'll hate me after this - #" # " Annoying, isn't it? [the.hard] test_array = [ "] ", " # "] # ] There you go, parse this! test_array2 = [ "Test #11 ]proved that", "Experiment #9 was a success" ] # You didn't think it'd as easy as chucking out the last #, did you? another_test_string = " Same thing, but with a string #" harder_test_string = " And when \"'s are in the string, along with # \"" # "and comments are there too" # Things will get harder [the.hard."bit#"] "what?" = "You don't think some user won't do that?" multi_line_array = [ "]", # ] Oh yes I did ] [parent.child1] key = 'value' [[parent.child2]] key2 = 'value' [[parent.child2]] key3 = 'value' [[a.b]] c = 3 # Each of the following table/key value pairs should produce an error. Uncomment to them to test #[error] if you didn't catch this, your parser is broken #string = "Anything other than tabs, spaces and newline after a table or key value pair has ended should produce an error unless it is a comment" like this #array = [ # "This might most likely happen in multiline arrays", # Like here, # "or here, # and here" # ] End of array comment, forgot the # #number = 3.14 pi <--again forgot the # emancu-toml-rb-686fcc3/test/helper.rb000066400000000000000000000002121517351030400175350ustar00rootroot00000000000000# Disable plugins to avoid loading Activesupport ENV["MT_NO_PLUGINS"] = "1" require "minitest/autorun" require_relative "../lib/toml-rb" emancu-toml-rb-686fcc3/test/toml_examples.rb000066400000000000000000000246421517351030400211440ustar00rootroot00000000000000class TomlRB::Examples def self.example_v_0_4_0 { "table" => { "key" => "value", "subtable" => { "key" => "another value" }, "inline" => { "name" => { "first" => "Tom", "last" => "Preston-Werner" }, "point" => { "x" => 1, "y" => 2 } } }, "x" => { "y" => { "z" => { "w" => {} } } }, "string" => { "basic" => { "basic" => "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." }, "multiline" => { "key1" => "One\nTwo", "key2" => "One\nTwo", "key3" => "One\nTwo", "continued" => { "key1" => "The quick brown fox jumps over the lazy dog.", "key2" => "The quick brown fox jumps over the lazy dog.", "key3" => "The quick brown fox jumps over the lazy dog." } }, "literal" => { "winpath" => "C:\\Users\\nodejs\\templates", "winpath2" => "\\\\ServerX\\admin$\\system32\\", "quoted" => "Tom \"Dubs\" Preston-Werner", "regex" => "<\\i\\c*\\s*>", "multiline" => { "regex2" => "I [dw]on't need \\d{2} apples", "lines" => "The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n" } } }, "integer" => { "key1" => 99, "key2" => 42, "key3" => 0, "key4" => -17, "underscores" => { "key1" => 1000, "key2" => 5349221, "key3" => 12345 } }, "float" => { "fractional" => { "key1" => 1.0, "key2" => 3.1415, "key3" => -0.01 }, "exponent" => { "key1" => 5.0e+22, "key2" => 1000000.0, "key3" => -0.02 }, "both" => { "key" => 6.626e-34 }, "underscores" => { "key1" => 9224617.445991227, "key2" => 1e1_00 } }, "boolean" => { "True" => true, "False" => false }, "datetime" => { "key1" => Time.utc(1979, 5, 27, 7, 32, 0), "key2" => Time.new(1979, 5, 27, 0, 32, 0, "-07:00"), "key3" => Time.new(1979, 5, 27, 0, 32, 0.999999, "-07:00") }, "array" => { "key1" => [1, 2, 3], "key2" => %w[red yellow green], "key3" => [[1, 2], [3, 4, 5]], "key4" => [[1, 2], %w[a b c]], "key5" => [1, 2, 3], "key6" => [1, 2] }, "products" => [ {"name" => "Hammer", "sku" => 738594937}, {}, {"name" => "Nail", "sku" => 284758393, "color" => "gray"} ], "fruit" => [ { "name" => "apple", "physical" => { "color" => "red", "shape" => "round" }, "variety" => [ {"name" => "red delicious"}, {"name" => "granny smith"} ] }, { "name" => "banana", "variety" => [ {"name" => "plantain"} ] } ] } end def self.example_v_0_5_0 { "keys" => { "key" => "value", "bare_key" => "value", "bare-key" => "value", "1234" => "value", "127.0.0.1" => "value", "character encoding" => "value", "ʎǝʞ" => "value", "key2" => "value", 'quoted "value"' => "value", "name" => "Orange", "physical" => { "color" => "orange", "shape" => "round" }, "site" => {"google.com" => true}, "3" => {"14159" => "pi"}, "a" => { "b" => {"c" => 1}, "d" => 2, "type" => "", "name" => "", "data" => "" }, "b" => { "type" => "", "name" => "", "data" => "" } }, "string" => { "str1" => "Roses are red\nViolets are blue", "str2" => "Roses are red\nViolets are blue", "str3" => "Roses are red\r\nViolets are blue", "same" => { "str1" => "The quick brown fox jumps over the lazy dog.", "str2" => "The quick brown fox jumps over the lazy dog.", "str3" => "The quick brown fox jumps over the lazy dog." }, "winpath" => "C:\\Users\\nodejs\\templates", "winpath2" => "\\\\ServerX\\admin$\\system32\\", "quoted" => 'Tom "Dubs" Preston-Werner', "regex" => "<\\i\\c*\\s*>", "regex2" => "I [dw]on't need \\d{2} apples", "lines" => "The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n" }, "integer" => { "int1" => +99, "int2" => 42, "int3" => 0, "int4" => -17, "int5" => 1000, "int6" => 5349221, "int7" => 12345, "hex1" => 0xDEADBEEF, "hex2" => 0xdeadbeef, "hex3" => 0xdead_beef, "oct1" => 0o01234567, "oct2" => 0o755, "bin1" => 0b11010110 }, "float" => { "flt1" => 1.0, "flt2" => 3.1415, "flt3" => -0.01, "flt4" => 5e+22, "flt5" => 1e06, "flt6" => -2E-2, "flt7" => 6.626e-34, "flt8" => 224_617.445_991_228, "flt9" => -0.0, "flt10" => +0.0, "sf1" => Float::INFINITY, "sf2" => Float::INFINITY, "sf3" => -Float::INFINITY, "sf4" => Float::NAN, "sf5" => Float::NAN, "sf6" => Float::NAN }, "boolean" => { "bool1" => true, "bool2" => false }, "offset-date-time" => { "odt1" => Time.new(1979, 5, 27, 7, 32, 0, "+00:00"), "odt2" => Time.new(1979, 5, 27, 0, 32, 0, "-07:00"), "odt3" => Time.new(1979, 5, 27, 0, 32, 0.999999, "-07:00"), "odt4" => Time.new(1979, 5, 27, 7, 32, 0, "+00:00") }, "local-date-time" => { "ldt1" => Time.local(1979, 5, 27, 7, 32, 0), "ldt2" => Time.local(1979, 5, 27, 0, 32, 0, 999999) }, "local-date" => { "ld1" => Time.local(1979, 5, 27) }, "local-time" => { "lt1" => Time.at(3600 * 7 + 60 * 32 + 0, 0), "lt2" => Time.at(3600 * 0 + 60 * 32 + 0, 999999) }, "array" => { "arr1" => [1, 2, 3], "arr2" => ["red", "yellow", "green"], "arr3" => [[1, 2], [3, 4, 5]], "arr4" => ["all", "strings", "are the same", "type"], "arr5" => [[1, 2], ["a", "b", "c"]], "arr7" => [1, 2, 3], "arr8" => [1, 2] }, "table" => { "table-1" => { "key1" => "some string", "key2" => 123 }, "table-2" => { "key1" => "another string", "key2" => 456 }, "dog" => { "tater.man" => { "type" => { "name" => "pug" } } }, "a" => { "b" => { "c" => {} }, "x" => {}, "y" => {} }, "d" => { "e" => { "f" => {} } }, "g" => { "h" => { "i" => {} } }, "j" => { "ʞ" => { "l" => {} } }, "x" => { "y" => { "z" => { "w" => {} } } }, "b" => {}, "fruit" => { "apple" => { "color" => "red", "taste" => { "sweet" => true }, "texture" => { "smooth" => true } } } }, "inline-table" => { "name" => { "first" => "Tom", "last" => "Preston-Werner" }, "point" => { "x" => 1, "y" => 2 }, "animal" => { "type" => { "name" => "pug" } } }, "array-of-tables" => { "products" => [ {"name" => "Hammer", "sku" => 738594937}, {}, {"name" => "Nail", "sku" => 284758393, "color" => "gray"} ], "fruit" => [ { "name" => "apple", "physical" => { "color" => "red", "shape" => "round" }, "variety" => [ {"name" => "red delicious"}, {"name" => "granny smith"} ] }, { "name" => "banana", "variety" => [ {"name" => "plantain"} ] } ] } } end def self.example { "title" => "TomlRB Example", "owner" => { "name" => "Tom Preston-Werner", "organization" => "GitHub", "bio" => "GitHub Cofounder & CEO\nLikes tater tots and beer.", "dob" => Time.utc(1979, 5, 27, 7, 32, 0) }, "database" => { "server" => "192.168.1.1", "ports" => [8001, 8001, 8002], "connection_max" => 5000, "enabled" => true }, "servers" => { "alpha" => { "ip" => "10.0.0.1", "dc" => "eqdc10" }, "beta" => { "ip" => "10.0.0.2", "dc" => "eqdc10" } }, "clients" => { "data" => [%w[gamma delta], [1, 2]], "hosts" => %w[alpha omega] }, "amqp" => { "exchange" => { "durable" => true, "auto_delete" => false } }, "products" => [ {"name" => "Hammer", "sku" => 738_594_937}, {}, {"name" => "Nail", "sku" => 284_758_393, "color" => "gray"} ] } end def self.hard_example { "the" => { "test_string" => "You'll hate me after this - #", "hard" => { "test_array" => ["] ", " # "], "test_array2" => ["Test #11 ]proved that", "Experiment #9 was a success"], "another_test_string" => " Same thing, but with a string #", "harder_test_string" => " And when \"'s are in the string, along with # \"", "bit#" => { "what?" => "You don't think some user won't do that?", "multi_line_array" => ["]"] } } }, "parent" => { "child1" => {"key" => "value"}, "child2" => [ {"key2" => "value"}, {"key3" => "value"} ] }, "a" => { "b" => [ {"c" => 3} ] } } end end emancu-toml-rb-686fcc3/test/toml_test.rb000066400000000000000000000102301517351030400202710ustar00rootroot00000000000000require_relative "helper" require_relative "toml_examples" require "json" class TomlTest < Minitest::Test def test_file_v_0_4_0 path = File.join(File.dirname(__FILE__), "example-v0.4.0.toml") parsed = TomlRB.load_file(path) hash = TomlRB::Examples.example_v_0_4_0 assert_equal hash["array"], parsed["array"] assert_equal hash["boolean"], parsed["boolean"] assert_equal hash["datetime"], parsed["datetime"] assert_equal hash["float"], parsed["float"] assert_equal hash["integer"], parsed["integer"] assert_equal hash["string"], parsed["string"] assert_equal hash["table"], parsed["table"] assert_equal hash["products"], parsed["products"] assert_equal hash["fruit"], parsed["fruit"] end def test_file_v_0_5_0 path = File.join(File.dirname(__FILE__), "example-v0.5.0.toml") parsed = TomlRB.load_file(path) hash = TomlRB::Examples.example_v_0_5_0 assert_equal hash["keys"], parsed["keys"] assert_equal hash["string"], parsed["string"] assert_equal hash["integer"], parsed["integer"] assert_equal hash["float"], parsed["float"] assert_equal hash["boolean"], parsed["boolean"] assert_equal hash["offset-date-time"], parsed["offset-date-time"] assert_equal hash["local-date-time"], parsed["local-date-time"] assert_equal hash["local-date"], parsed["local-date"] assert_equal hash["local-time"], parsed["local-time"] assert_equal hash["array"], parsed["array"] assert_equal hash["table"], parsed["table"] assert_equal hash["inline-table"], parsed["inline-table"] assert_equal hash["array-of-tables"], parsed["array-of-tables"] end def test_file path = File.join(File.dirname(__FILE__), "example.toml") parsed = TomlRB.load_file(path) assert_equal TomlRB::Examples.example, parsed end def test_hard_example path = File.join(File.dirname(__FILE__), "hard_example.toml") parsed = TomlRB.load_file(path) assert_equal TomlRB::Examples.hard_example, parsed end def test_symbolize_keys path = File.join(File.dirname(__FILE__), "example.toml") parsed = TomlRB.load_file(path, symbolize_keys: true) hash = { title: "TomlRB Example", owner: { name: "Tom Preston-Werner", organization: "GitHub", bio: "GitHub Cofounder & CEO\nLikes tater tots and beer.", dob: Time.utc(1979, 0o5, 27, 0o7, 32, 0o0) }, database: { server: "192.168.1.1", ports: [8001, 8001, 8002], connection_max: 5000, enabled: true }, servers: { alpha: { ip: "10.0.0.1", dc: "eqdc10" }, beta: { ip: "10.0.0.2", dc: "eqdc10" } }, clients: { data: [%w[gamma delta], [1, 2]], hosts: %w[alpha omega] }, amqp: { exchange: { durable: true, auto_delete: false } }, products: [ {name: "Hammer", sku: 738_594_937}, {}, {name: "Nail", sku: 284_758_393, color: "gray"} ] } assert_equal(hash, parsed) end def test_line_break parsed = TomlRB.parse("hello = 'world'\r\nline_break = true") assert_equal({"hello" => "world", "line_break" => true}, parsed) end def test_trailing_whitespace_after_keyvalue parsed = TomlRB.parse("a = 1 ") assert_equal({"a" => 1}, parsed) end def test_trailing_whitespace_after_line_break parsed = TomlRB.parse("[table]\r\na = 1\r\n ") assert_equal({"table" => {"a" => 1}}, parsed) end def test_valid_cases Dir["test/examples/valid/**/*.json"].each do |json_file| toml_file = File.join(File.dirname(json_file), File.basename(json_file, ".json")) + ".toml" begin toml = TomlRB.load_file(toml_file) rescue TomlRB::Error => e assert false, "Error: #{e} in #{toml_file}" end json = JSON.parse(File.read(json_file)) assert_equal json, toml, "In file '#{toml_file}'" end end def test_invalid_cases Dir["test/examples/invalid/**/*.toml"].each do |toml_file| assert_raises(TomlRB::Error, "For file #{toml_file}") do TomlRB.load_file(toml_file) end end end end emancu-toml-rb-686fcc3/toml-rb.gemspec000066400000000000000000000016141517351030400177020ustar00rootroot00000000000000# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "toml-rb/version" Gem::Specification.new do |s| s.name = "toml-rb" s.version = TomlRB::VERSION s.summary = "Toml parser in ruby, for ruby." s.description = "A Toml parser using Citrus parsing library. " s.authors = ["Emiliano Mancuso", "Lucas Tolchinsky"] s.email = ["emiliano.mancuso@gmail.com", "lucas.tolchinsky@gmail.com"] s.homepage = "https://github.com/emancu/toml-rb" s.license = "MIT" s.files = Dir[ "README.md", "lib/**/*.rb", "lib/**/*.citrus", "LICENSE" ] s.required_ruby_version = ">= 2.5" s.add_dependency "citrus", "~> 3.0", "> 3.0" s.add_dependency "racc", "~> 1.7" s.add_development_dependency "minitest", "~> 5.7" s.add_development_dependency "standard", "~> 1.4" s.add_development_dependency "rake" end