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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27d22aaf844ad47e14321925d2ef8d3346b0960fe5d284ca191fb25231571d2c
4
- data.tar.gz: c22e4025f6ed2f42654e899123f46a46f195ce7b14d002b2c240d6b24222871a
3
+ metadata.gz: 9ded4c2fceb98dde6ae4421034c52e2c26ca36894da75def6bc358de10339dce
4
+ data.tar.gz: 00c0e2c08400aed4edddd124c337cd3a5169557bb74666d9cb5cbbc3821fd7aa
5
5
  SHA512:
6
- metadata.gz: a810a2fbd5c1d3336e89bff3a59af3e93aa9d1c1fc80c37e5f02e93d9b96bec0a6cf6ad448b8c6d624d380dee65a5c99290c4352edb3acca5b673a4728c8aa45
7
- data.tar.gz: b1af0ff7997fac32d3d4640866b788cf884cfac8ca342e6de02296c59f5ef58b4d230d0a67be17cc687c98dd6ad15f0f21b729c2dbcd27f3ffadf2d5169f70ee
6
+ metadata.gz: 655e6cb06085648a3aab37298e1214ebda9cc64c8576e5b6ca8528f2d86e8376c14755fdcbd946999f30598189d95f31850de223f563a3c08099d71912714f61
7
+ data.tar.gz: cb7e37ea4400ec877fa7c3cbb584d88eb6686194a0c1545b99c2331725195da826a62f33bfe2e01f3b5d371c1d0429db7f550d26ad8b15cbc84e2c7b6fc0a580
@@ -17,18 +17,19 @@ jobs:
17
17
  test:
18
18
  strategy:
19
19
  matrix:
20
- ruby: [2.3, 2.4, 2.5, 2.6, 2.7, 3.0.0-preview1]
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
- - name: Install dependencies
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
@@ -0,0 +1,3 @@
1
+ [submodule "test/kdl-org"]
2
+ path = test/kdl-org
3
+ url = git@github.com:kdl-org/kdl
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # KDL
2
2
 
3
- [![Actions Status](https://github.com/jellymann/kdl-rb/workflows/Ruby/badge.svg)](https://github.com/jellymann/kdl-rb\/actions)
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/jellymann/kdl-rb.
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 "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
3
 
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
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
@@ -10,5 +10,7 @@ require "kdl"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
+ system 'bin/rake racc'
14
+
13
15
  require "irb"
14
16
  IRB.start(__FILE__)
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
@@ -6,3 +6,4 @@ set -vx
6
6
  bundle install
7
7
 
8
8
  # Do any other automated setup that you need to do here
9
+ bin/rake racc
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 = ["Daniel Smith"]
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.3.0")
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/jellymann/kdl-rb"
17
- spec.metadata["changelog_uri"] = "https://github.com/jellymann/kdl-rb/releases"
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
data/lib/kdl/document.rb CHANGED
@@ -7,9 +7,8 @@ module KDL
7
7
  end
8
8
 
9
9
  def to_s
10
- @nodes.map(&:to_s).join("\n")
10
+ @nodes.map(&:to_s).join("\n") + "\n"
11
11
  end
12
- alias inspect to_s
13
12
 
14
13
  def ==(other)
15
14
  return false unless other.is_a?(Document)