kdl 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +4 -3
- data/.gitmodules +3 -0
- data/README.md +16 -2
- data/Rakefile +11 -6
- data/bin/console +2 -0
- data/bin/racc +29 -0
- data/bin/rake +29 -0
- data/bin/setup +1 -0
- data/kdl.gemspec +5 -5
- data/lib/kdl/document.rb +1 -2
- data/lib/kdl/kdl.tab.rb +237 -167
- data/lib/kdl/kdl.yy +40 -24
- data/lib/kdl/node.rb +33 -8
- data/lib/kdl/string_dumper.rb +45 -0
- data/lib/kdl/tokenizer.rb +163 -71
- data/lib/kdl/types/base64.rb +15 -0
- data/lib/kdl/types/country/iso3166_countries.rb +512 -0
- data/lib/kdl/types/country/iso3166_subdivisions.rb +3927 -0
- data/lib/kdl/types/country.rb +69 -0
- data/lib/kdl/types/currency/iso4217_currencies.rb +189 -0
- data/lib/kdl/types/currency.rb +26 -0
- data/lib/kdl/types/date_time.rb +41 -0
- data/lib/kdl/types/decimal.rb +13 -0
- data/lib/kdl/types/duration/iso8601_parser.rb +147 -0
- data/lib/kdl/types/duration.rb +28 -0
- data/lib/kdl/types/email/parser.rb +151 -0
- data/lib/kdl/types/email.rb +43 -0
- data/lib/kdl/types/hostname/validator.rb +51 -0
- data/lib/kdl/types/hostname.rb +32 -0
- data/lib/kdl/types/ip.rb +32 -0
- data/lib/kdl/types/irl/parser.rb +123 -0
- data/lib/kdl/types/irl.rb +46 -0
- data/lib/kdl/types/regex.rb +13 -0
- data/lib/kdl/types/url.rb +30 -0
- data/lib/kdl/types/url_template.rb +328 -0
- data/lib/kdl/types/uuid.rb +17 -0
- data/lib/kdl/types.rb +22 -0
- data/lib/kdl/value.rb +42 -10
- data/lib/kdl/version.rb +1 -1
- data/lib/kdl.rb +4 -2
- metadata +47 -8
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ded4c2fceb98dde6ae4421034c52e2c26ca36894da75def6bc358de10339dce
|
4
|
+
data.tar.gz: 00c0e2c08400aed4edddd124c337cd3a5169557bb74666d9cb5cbbc3821fd7aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 655e6cb06085648a3aab37298e1214ebda9cc64c8576e5b6ca8528f2d86e8376c14755fdcbd946999f30598189d95f31850de223f563a3c08099d71912714f61
|
7
|
+
data.tar.gz: cb7e37ea4400ec877fa7c3cbb584d88eb6686194a0c1545b99c2331725195da826a62f33bfe2e01f3b5d371c1d0429db7f550d26ad8b15cbc84e2c7b6fc0a580
|
data/.github/workflows/ruby.yml
CHANGED
@@ -17,18 +17,19 @@ jobs:
|
|
17
17
|
test:
|
18
18
|
strategy:
|
19
19
|
matrix:
|
20
|
-
ruby: [2.
|
20
|
+
ruby: [2.4, 2.5, 2.6, 2.7, 3.0, head]
|
21
21
|
|
22
22
|
runs-on: ubuntu-latest
|
23
23
|
|
24
24
|
steps:
|
25
25
|
- uses: actions/checkout@v2
|
26
|
+
with:
|
27
|
+
submodules: true
|
26
28
|
- name: Set up Ruby
|
27
29
|
uses: ruby/setup-ruby@v1
|
28
30
|
with:
|
29
31
|
ruby-version: ${{ matrix.ruby }}
|
30
|
-
|
31
|
-
run: gem install bundler && bundle install
|
32
|
+
bundler-cache: true # install and cache dependencies
|
32
33
|
- name: Build parser
|
33
34
|
run: bundle exec racc lib/kdl/kdl.yy
|
34
35
|
- name: Run tests
|
data/.gitmodules
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# KDL
|
2
2
|
|
3
|
-
[![Actions Status](https://github.com/
|
3
|
+
[![Actions Status](https://github.com/danini-the-panini/kdl-rb/workflows/Ruby/badge.svg)](https://github.com/danini-the-panini/kdl-rb/actions)
|
4
4
|
|
5
5
|
This is a Ruby implementation of the [KDL Document Language](https://kdl.dev)
|
6
6
|
|
@@ -28,6 +28,20 @@ require 'kdl'
|
|
28
28
|
KDL.parse_document(a_string) #=> KDL::Document
|
29
29
|
```
|
30
30
|
|
31
|
+
You can optionally provide your own type annotation handlers:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
KDL.parse_document(a_string, type_parsers: {
|
35
|
+
'foo' => -> (value, type) {
|
36
|
+
Foo.new(value.value, type: type)
|
37
|
+
}
|
38
|
+
})
|
39
|
+
```
|
40
|
+
|
41
|
+
The `foo` proc will be called with instances of Value or Node with the type annotation `(foo)`.
|
42
|
+
|
43
|
+
Parsers are expected to have a `call` method that takes the Value or Node, and the type annotation itself, as arguments, and is expected to return either an instance of Value or Node (depending on the input type) or `nil` to return the original value as is. Take a look at [the built in parsers](lib/kdl/types) as a reference.
|
44
|
+
|
31
45
|
## Development
|
32
46
|
|
33
47
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -36,7 +50,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
36
50
|
|
37
51
|
## Contributing
|
38
52
|
|
39
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/danini-the-panini/kdl-rb.
|
40
54
|
|
41
55
|
|
42
56
|
## License
|
data/Rakefile
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
file 'lib/kdl/kdl.tab.rb' => ['lib/kdl/kdl.yy'] do
|
5
|
+
raise "racc command failed" unless system 'bin/racc lib/kdl/kdl.yy'
|
6
|
+
end
|
7
|
+
task :racc => 'lib/kdl/kdl.tab.rb'
|
8
|
+
|
9
|
+
Rake::TestTask.new(:test => :racc) do |t|
|
10
|
+
t.libs << 'test'
|
11
|
+
t.libs << 'lib'
|
12
|
+
t.test_files = FileList['test/**/*_test.rb']
|
8
13
|
t.options = '--pride'
|
9
14
|
end
|
10
15
|
|
data/bin/console
CHANGED
data/bin/racc
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'racc' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("racc", "racc")
|
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/setup
CHANGED
data/kdl.gemspec
CHANGED
@@ -3,18 +3,18 @@ require_relative 'lib/kdl/version'
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "kdl"
|
5
5
|
spec.version = KDL::VERSION
|
6
|
-
spec.authors = ["
|
6
|
+
spec.authors = ["Danielle Smith"]
|
7
7
|
spec.email = ["danini@hey.com"]
|
8
8
|
|
9
9
|
spec.summary = %q{KDL Document Language}
|
10
10
|
spec.description = %q{Ruby implementation of the KDL Document Language Spec}
|
11
11
|
spec.homepage = "https://kdl.dev"
|
12
12
|
spec.license = "MIT"
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
14
14
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
-
spec.metadata["source_code_uri"] = "https://github.com/
|
17
|
-
spec.metadata["changelog_uri"] = "https://github.com/
|
16
|
+
spec.metadata["source_code_uri"] = "https://github.com/danini-the-panini/kdl-rb"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/danini-the-panini/kdl-rb/releases"
|
18
18
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
23
|
end + ['lib/kdl/kdl.tab.rb']
|
24
24
|
spec.bindir = "exe"
|
25
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
25
|
spec.require_paths = ["lib"]
|
27
26
|
|
28
27
|
spec.add_development_dependency 'racc', '~> 1.5'
|
28
|
+
spec.add_dependency 'simpleidn', '~> 0.2.1'
|
29
29
|
end
|