kdl 0.1.2 → 1.0.1

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: dfb8d87e0f543090b994347f56085b076d82ce8050f52e49e112a2e723aafc09
4
- data.tar.gz: 33443ec26405e8cd235275ab262378d2afc6bfebf4bf186a22580d6c62d8db07
3
+ metadata.gz: e6560ca3f6df5d91a1a93832f8e5989f16d7e2ee100fa784dcc932e755425008
4
+ data.tar.gz: 76a907c6df892adf81898b03b204259284d08c43c4c9b2faff628d82d62c620d
5
5
  SHA512:
6
- metadata.gz: '0396991421855a4b2c9b40263a50b255c8ab78b493604254437a6fe2cae9a05d8ac967c6fa19893e8712f210d5e882d6f98338331d56fa2b80e01c24c33b980e'
7
- data.tar.gz: 9a3af62eae607011f76a1b154cf4604afd9d6cb38dacdaccc28f735720b8caec9789d6d75766904d395a4969a44b903e890363b7df17533349b8d8c2186a790e
6
+ metadata.gz: 05bff4830aa073df4e14ea87d9eb947ef83009afb5fc2e39ead76d54efe53836e9025e020b4d4a9cd139d52fd1e45bde55005d999ad4f1c2afccfc74d10f5a45
7
+ data.tar.gz: 7bea0334e44f33d2022ed2dfc9b59815ba0d380d04d79763958192b4e4146afe622d2e134208899a629f7638528227e50614476076f4e5de620510d8cc7d8e7f
@@ -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/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  Gemfile.lock
11
11
 
12
12
  lib/kdl/kdl.tab.rb
13
+ kdl.output
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/kdl ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kdl"
5
+
6
+ system 'bin/rake racc'
7
+
8
+ puts KDL.parse_document(ARGF.read).to_s
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)