kwyktree 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 45c53da7e4aaef3c10161a6097dc952efb33313341b98e3d35c8e95a676bbc85
4
+ data.tar.gz: b5a5c985cf0e6346358e1da89b27c7dca8d8472baef50d27be750699acb0f20a
5
+ SHA512:
6
+ metadata.gz: 5760d32bf2597389a48aed31ffd321d2d82fe9126a6313158d087560cc967cb081f3491d12bcb45b3cf1f1d2b4a59078130a8c6d101e291d02b9a1c91bac9af0
7
+ data.tar.gz: 227e6028d424b047c7efcbda67d71f8bc882fc9953e0c8859d488ef00620fe1acae811160ce8df1930921bb0270a935e18a2518db3a90f4d60be272defba02b5
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /vendor
10
+ kwyktree.dot
11
+ kwyktree.svg
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at dave@dafyddcrosby.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "guard"
8
+ gem "guard-minitest"
9
+ gem "kwalify", "= 0.7.2"
10
+ gem "minitest", "~> 5.0"
11
+ gem "rake", "~> 13.0"
12
+ gem "rubocop", "~> 1.7"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,82 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ kwyktree (0.1.0)
5
+ ruby-graphviz (~> 1.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ coderay (1.1.3)
12
+ ffi (1.15.5)
13
+ formatador (1.1.0)
14
+ guard (2.18.0)
15
+ formatador (>= 0.2.4)
16
+ listen (>= 2.7, < 4.0)
17
+ lumberjack (>= 1.0.12, < 2.0)
18
+ nenv (~> 0.1)
19
+ notiffany (~> 0.0)
20
+ pry (>= 0.13.0)
21
+ shellany (~> 0.0)
22
+ thor (>= 0.18.1)
23
+ guard-compat (1.2.1)
24
+ guard-minitest (2.4.6)
25
+ guard-compat (~> 1.2)
26
+ minitest (>= 3.0)
27
+ kwalify (0.7.2)
28
+ listen (3.7.1)
29
+ rb-fsevent (~> 0.10, >= 0.10.3)
30
+ rb-inotify (~> 0.9, >= 0.9.10)
31
+ lumberjack (1.2.8)
32
+ method_source (1.0.0)
33
+ minitest (5.15.0)
34
+ nenv (0.3.0)
35
+ notiffany (0.1.3)
36
+ nenv (~> 0.1)
37
+ shellany (~> 0.0)
38
+ parallel (1.22.1)
39
+ parser (3.1.2.0)
40
+ ast (~> 2.4.1)
41
+ pry (0.14.1)
42
+ coderay (~> 1.1)
43
+ method_source (~> 1.0)
44
+ rainbow (3.1.1)
45
+ rake (13.0.6)
46
+ rb-fsevent (0.11.1)
47
+ rb-inotify (0.10.1)
48
+ ffi (~> 1.0)
49
+ regexp_parser (2.3.0)
50
+ rexml (3.2.5)
51
+ rubocop (1.28.1)
52
+ parallel (~> 1.10)
53
+ parser (>= 3.1.0.0)
54
+ rainbow (>= 2.2.2, < 4.0)
55
+ regexp_parser (>= 1.8, < 3.0)
56
+ rexml
57
+ rubocop-ast (>= 1.17.0, < 2.0)
58
+ ruby-progressbar (~> 1.7)
59
+ unicode-display_width (>= 1.4.0, < 3.0)
60
+ rubocop-ast (1.17.0)
61
+ parser (>= 3.1.1.0)
62
+ ruby-graphviz (1.2.5)
63
+ rexml
64
+ ruby-progressbar (1.11.0)
65
+ shellany (0.0.1)
66
+ thor (1.2.1)
67
+ unicode-display_width (2.1.0)
68
+
69
+ PLATFORMS
70
+ x86_64-linux
71
+
72
+ DEPENDENCIES
73
+ guard
74
+ guard-minitest
75
+ kwalify (= 0.7.2)
76
+ kwyktree!
77
+ minitest (~> 5.0)
78
+ rake (~> 13.0)
79
+ rubocop (~> 1.7)
80
+
81
+ BUNDLED WITH
82
+ 2.2.22
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ directories %w[lib test] \
4
+ .select { |d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist") }
5
+
6
+ guard :minitest do
7
+ watch(%r{^test/test_(.*)\.rb$}) { 'test' }
8
+ watch(%r{^lib/kwyktree/(.*)\.rb$}) { 'test' }
9
+ watch(%r{^lib/kwyktree\.rb$}) { 'test' }
10
+ watch(%r{^test/helper\.rb$}) { 'test' }
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,10 @@
1
+ Copyright (c) 2022, David Crosby
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # KwykTree
2
+
3
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dafyddcrosby/kwyktree
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "kwyktree"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/kwyktree ADDED
@@ -0,0 +1,41 @@
1
+ #!/bin/env ruby
2
+ require "yaml"
3
+ require "ruby-graphviz"
4
+ require "pathname"
5
+ require_relative "../lib/kwyktree"
6
+
7
+ nodes = {}
8
+ ARGV.each do |f|
9
+ if File.exist? f
10
+ y = YAML.load_file f
11
+ cluster = Pathname.new(f).basename.to_s.gsub('.yaml','')
12
+ nodes[cluster] = []
13
+ y['concepts'].each do |u|
14
+ nodes[cluster] << KwykTree::Concept.new(u)
15
+ end if y['concepts']
16
+ y['implementations'].each do |u|
17
+ nodes[cluster] << KwykTree::Implementation.new(u)
18
+ end if y['implementations']
19
+ end
20
+ pp nodes
21
+ end
22
+ pp nodes
23
+
24
+ g = GraphViz.digraph("kwyktree")
25
+ nodes.each do |k, nodelist|
26
+ nodelist.each do |n|
27
+ n.deps.each do |d|
28
+ g.add_edges d, n.graphviz_id
29
+ end
30
+ end
31
+ end
32
+ nodes.each do |k, nodelist|
33
+ nodelist.each do |n|
34
+ g.subgraph("cluster_#{k}", label: k) do |sg|
35
+ sg.add_nodes n.graphviz_id, n.graphviz_attributes
36
+ end
37
+ end
38
+ end
39
+
40
+ g.output dot: "kwyktree.dot"
41
+ g.output svg: "kwyktree.svg"
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/kwyktree.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/kwyktree/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "kwyktree"
7
+ spec.version = KwykTree::VERSION
8
+ spec.authors = ["David Crosby"]
9
+ spec.email = ["dave@dafyddcrosby.com"]
10
+
11
+ spec.summary = "Know-What-You-Know Tree"
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://daveops.net"
14
+ spec.required_ruby_version = ">= 2.5.0"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+
18
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_dependency "ruby-graphviz", "~> 1.2"
26
+ end
@@ -0,0 +1,93 @@
1
+ require "ruby-graphviz"
2
+
3
+ module KwykTree
4
+ class Unit
5
+ attr_reader :deps, :url
6
+ def initialize(unit)
7
+ if unit['name']
8
+ @name = unit['name']
9
+ else
10
+ raise "unit needs a name"
11
+ end
12
+
13
+ @details = {}
14
+ @details["anki"] = unit['anki'] || false
15
+ @details["grok"] = unit['grok'] || false
16
+ @desc = unit['desc'] || ""
17
+ @url = unit['url'] if unit['url']
18
+ @deps = unit['deps'] || []
19
+ @deps.each do |l|
20
+ l.downcase!
21
+ end
22
+ @title = unit['title'] || pretty_name
23
+ end
24
+
25
+ def type
26
+ raise "unit needs to be subclassed!"
27
+ end
28
+
29
+ def graphviz_record_label
30
+ # TODO: add desc
31
+ "{#{@title}#{graphviz_details}}"
32
+ end
33
+
34
+ def graphviz_id
35
+ "#{type}.#{@name.downcase.tr(' ', '_')}"
36
+ end
37
+
38
+ def graphviz_attributes
39
+ hsh = {
40
+ tooltip: @title,
41
+ label: graphviz_record_label,
42
+ shape: graphviz_record_shape
43
+ }
44
+ hsh[:URL] = @url if @url
45
+ hsh
46
+ end
47
+
48
+ def graphviz_record_shape
49
+ raise "unit needs to be subclassed!"
50
+ end
51
+
52
+ private
53
+
54
+ def pretty_name
55
+ # Not perfect, but fine for now
56
+ @name.capitalize.tr("_", " ")
57
+ end
58
+
59
+ def graphviz_details
60
+ details_bar = ""
61
+ details = ""
62
+ if @details["grok"] != true
63
+ details_bar = "|"
64
+ details << 'grok: false\\n'
65
+ end
66
+ if @details["anki"] != true
67
+ details_bar = "|"
68
+ details << 'anki: false\\n'
69
+ end
70
+ "#{details_bar}#{details}"
71
+ end
72
+ end
73
+
74
+ class Concept < Unit
75
+ def type
76
+ "concept"
77
+ end
78
+
79
+ def graphviz_record_shape
80
+ "Mrecord"
81
+ end
82
+ end
83
+
84
+ class Implementation < Unit
85
+ def type
86
+ "implementation"
87
+ end
88
+
89
+ def graphviz_record_shape
90
+ "record"
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KwykTree
4
+ VERSION = "0.1.0"
5
+ end
data/lib/kwyktree.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "kwyktree/version"
4
+ require_relative "kwyktree/unit"
5
+
6
+ module KwykTree
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
data/schema.yaml ADDED
@@ -0,0 +1,32 @@
1
+ type: map
2
+ mapping:
3
+ "concepts": &unit
4
+ type: seq
5
+ sequence:
6
+ - type: map
7
+ mapping:
8
+ "name":
9
+ type: str
10
+ required: yes
11
+ unique: yes
12
+ "desc":
13
+ type: str
14
+ "url":
15
+ type: str
16
+ "details":
17
+ type: str
18
+ "acronym":
19
+ type: str
20
+ "grok":
21
+ type: bool
22
+ "anki":
23
+ type: bool
24
+ "aka":
25
+ type: seq
26
+ sequence:
27
+ - type: str
28
+ "deps":
29
+ type: seq
30
+ sequence:
31
+ - type: str
32
+ "implementations": *unit
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kwyktree
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - David Crosby
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-05-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-graphviz
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ description: Know-What-You-Know Tree
28
+ email:
29
+ - dave@dafyddcrosby.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".rubocop.yml"
36
+ - CODE_OF_CONDUCT.md
37
+ - Gemfile
38
+ - Gemfile.lock
39
+ - Guardfile
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - bin/console
44
+ - bin/kwyktree
45
+ - bin/setup
46
+ - kwyktree.gemspec
47
+ - lib/kwyktree.rb
48
+ - lib/kwyktree/unit.rb
49
+ - lib/kwyktree/version.rb
50
+ - schema.yaml
51
+ homepage: https://daveops.net
52
+ licenses: []
53
+ metadata:
54
+ homepage_uri: https://daveops.net
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 2.5.0
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubygems_version: 3.2.22
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Know-What-You-Know Tree
74
+ test_files: []