knossoscli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cbf3eed14b624ac22809e9fbbdc58831bc94a718a80ead7a72c4bbf0fb03bd7b
4
+ data.tar.gz: 466d558726753210c52fd0b01390c7109303ec7e6b5f54073d88c77953211daa
5
+ SHA512:
6
+ metadata.gz: 85eccd063ec54ae6896acdc8b2eb800772ee0ed48d0d338e7981920fd0b4797bfe42a3deee6c3f32478b71a57cfdde7f38183fb8e637f44cbfed47e25ff4cfbd
7
+ data.tar.gz: 57b576cc61412590e51f4ebbd4893d27e65662b1845e94ab3df234cf2e060344eb7d5a89a6badf0390a22b104e29553e19689a28dd398f52d845c84bb6c9681b
data/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ This project uses [Semantic Versioning][semv].
5
+
6
+ ## [Unreleased][new]
7
+ - Create the project as a Ruby gem.
8
+ - Remove '-' from the project name and shorten the name of the executable.
9
+ - Add the Thor toolkit to build the command line interface.
10
+ - Add the `carve` sub-command
11
+ - Specify grid dimensions as arguments to the `carve` command
12
+ - Accept the maze-carving algorithm as an argument
13
+ - Add the Sidewinder algorithm
14
+ - Drop implicit, deprecated `Grid.to_s` and use `Renderer::Text.render` instead
15
+ - Automagically infer the list of available algorithms. At least until the
16
+ library provides a cleaner way.
17
+ - Provide an option to save a PNG image of the generated maze.
18
+
19
+ ## [0.0.0][0.0.0] — yyyy-mm-dd
20
+ ### Added
21
+
22
+ ---
23
+ _This file is composed with [GitHub Flavored Markdown][gfm]._
24
+
25
+ [gfm]: https://github.github.com/gfm/
26
+ [semv]: https://semver.org
27
+
28
+ [new]: https://github.com/petejh/knossoscli/compare/HEAD..v0.0.0
29
+ [0.0.0]: https://github.com/petejh/knossoscli/releases/tag/v0.0.0
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Peter J. Hinckley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # Knossos CLI
2
+ A command line companion to the [`knossos`][gem] Ruby gem for generating mazes.
3
+
4
+ ## Installation
5
+ Install globally with:
6
+ ```bash
7
+ ~$ gem install knossoscli
8
+ ```
9
+
10
+ ## Usage
11
+ The Knossos CLI actually comprises a suite of commands similar to familiar tools
12
+ like `git` and `bundler`. You can see a summary of the available sub-commands by
13
+ invoking:
14
+ ```bash
15
+ ~$ knossos help
16
+ ```
17
+ More detailed documentation for each sub-command is available with, for example:
18
+ ```bash
19
+ ~$ knossos help carve
20
+ ```
21
+
22
+ Generate a maze in your terminal:
23
+ ```bash
24
+ ~$ knossos carve --rows=5 --columns=7 --algorithm=RecursiveBacktracker
25
+ ```
26
+
27
+ ## Contributing
28
+ Bug reports and pull requests are welcome on [GitHub][orig]. Knossos provides
29
+ a safe, welcoming space for collaboration. Everyone contributing to our
30
+ project—including the codebase, issue trackers, chat, email, social media and
31
+ the like—is expected to uphold our [Code of Conduct][coc].
32
+
33
+ ### Setting Up
34
+ [Fork the project][fork] on GitHub and make a local clone. Install dependencies,
35
+ and run the tests:
36
+ ```bash
37
+ ~/knossoscli$ bin/setup
38
+ ~/knossoscli$ bundle exec rake rspec
39
+ ```
40
+
41
+ ### Running the Code
42
+ Run the command itself with:
43
+ ```bash
44
+ ~/knossoscli$ bundle exec exe/knossos
45
+ ```
46
+ Or, you can experiment directly with the code interactively using:
47
+ ```bash
48
+ ~/knossoscli$ bin/console
49
+ ```
50
+
51
+ ### Publishing
52
+ To release a new version of the library, first increment the version number in
53
+ `lib/knossoscli/version.rb` following [Semantic Versioning][semv] policy, and
54
+ update `CHANGELOG.md`. Commit your work, and finally, run:
55
+ ```bash
56
+ # Create a git tag, push commits and tags, and publish to rubygems.org
57
+ ~/knossoscli$ bundle exec rake release
58
+ ```
59
+
60
+ ## License
61
+ This gem is available as open source under the terms of the [MIT License][mit].
62
+
63
+ ---
64
+ _This file is composed with [GitHub Flavored Markdown][gfm]._
65
+
66
+ [coc]: https://github.com/petejh/knossoscli/blob/master/CODE_OF_CONDUCT.md
67
+ [fork]: https://help.github.co://help.github.com/en/github/getting-started-with-github/fork-a-repo
68
+ [gem]: https://github.com/petejh/knossos
69
+ [gfm]: https://github.github.com/gfm/
70
+ [orig]: https://github.com/petejh/knossoscli
71
+ [mit]: https://github.com/petejh/knossoscli/blob/master/LICENSE.txt
72
+ [semv]: https://semver.org
data/exe/knossos ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'knossoscli'
4
+
5
+ KnossosCLI::CLI.start(ARGV)
data/lib/knossoscli.rb ADDED
@@ -0,0 +1,7 @@
1
+ require_relative 'knossoscli/version'
2
+
3
+ require_relative 'knossoscli/cli'
4
+ require_relative 'knossoscli/error'
5
+
6
+ module KnossosCLI
7
+ end
@@ -0,0 +1,39 @@
1
+ require 'knossos'
2
+ require 'thor'
3
+
4
+ class KnossosCLI::CLI < Thor
5
+ desc 'carve', 'Carve a maze'
6
+ method_option :rows,
7
+ :type => :numeric,
8
+ :aliases => '-r'
9
+ method_option :columns,
10
+ :type => :numeric,
11
+ :aliases => '-c'
12
+ method_option :algorithm,
13
+ :type => :string,
14
+ :aliases => '-a',
15
+ :enum => Algorithm.constants.map(&:to_s).sort,
16
+ :default => 'BinaryTree'
17
+ method_option :image,
18
+ :type => :string,
19
+ :default => 'maze.png'
20
+ def carve
21
+ params = {}
22
+ params[:rows] = options[:rows].to_i if options[:rows]
23
+ params[:columns] = options[:columns].to_i if options[:columns]
24
+
25
+ grid = Knossos::Grid.new(params)
26
+
27
+ carver = Algorithm.const_get(options[:algorithm])
28
+ carver.carve(grid: grid)
29
+
30
+ text_renderer = Renderer::Text.new
31
+ puts text_renderer.render(grid: grid)
32
+
33
+ if options[:image]
34
+ image_renderer = Renderer::Image.new(grid)
35
+ image = image_renderer.render
36
+ image.save(options[:image])
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,2 @@
1
+ class KnossosCLI::Error < StandardError
2
+ end
@@ -0,0 +1,3 @@
1
+ module KnossosCLI
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: knossoscli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Peter J. Hinckley
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-01-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: knossos
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: A command line companion to the `knossos` Ruby gem.
84
+ email:
85
+ - petejh.code@q.com
86
+ executables:
87
+ - knossos
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - CHANGELOG.md
92
+ - LICENSE.txt
93
+ - README.md
94
+ - exe/knossos
95
+ - lib/knossoscli.rb
96
+ - lib/knossoscli/cli.rb
97
+ - lib/knossoscli/error.rb
98
+ - lib/knossoscli/version.rb
99
+ homepage: https://github.com/petejh/knossoscli
100
+ licenses:
101
+ - MIT
102
+ metadata:
103
+ homepage_uri: https://github.com/petejh/knossoscli
104
+ source_code_uri: https://github.com/petejh/knossoscli
105
+ changelog_uri: https://github.com/petejh/knossoscli/CHANGELOG.md
106
+ bug_tracker_uri: https://github.com/petejh/knossoscli/issues
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '2.6'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubygems_version: 3.0.3
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Generate mazes from the command line.
126
+ test_files: []