wordz 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d05083af32ff497031e91e20de1606526e492e1787a77427fd38a0e635d8459
4
- data.tar.gz: 7bac7ddae0032a039cf47b71105c7f2b2715a530b5b791bfb5389de9f5b0aacb
3
+ metadata.gz: ec2263a33b331dbee70fbfa5735b144f373e9e5f4ff51fda803779f5131d5dbe
4
+ data.tar.gz: dfd3a764d11b2df3e6d8fc4d2c91fd9b3290d55033c7b46dd70a0655bd8923cd
5
5
  SHA512:
6
- metadata.gz: eee6ff9c0859037276b4d59e3278cf426fd71729925d5f79244010671a9fd91ce6fbeb8db3393491757fd7f62071f95c4747a1bc4795e96c0878cb477eac12da
7
- data.tar.gz: 2ca72d0759b30bbcd92b51a23b8041840a52f99d476e0b5fc435392e1d0e272e670d1c4a145dec5f22ff7211df36465569b712d3f210b013ca982feb06e5893a
6
+ metadata.gz: 6597a9cab7daf0c95f80fd9dd646a7c3ccfea124c8d9b62ceef3d20fb5a7ac3694b83e0a29dd32aca2168b891bbb806ce7ded9ce380f6821b50a1bfd4a977313
7
+ data.tar.gz: df517cb56e8ebea912ce8a1f21be556045d82c057a8ae2d1ede6c2716e0c348f75f30a638ba4d066a62b978bee116585be314b3e3013423d8c34db7707524e13
data/README.md CHANGED
@@ -5,3 +5,32 @@
5
5
  # Wordz
6
6
 
7
7
  A minimalist generative grammar library. For use in bots and other mischief.
8
+
9
+ # Usage
10
+
11
+ ```ruby
12
+ grammar = {
13
+ "<root>" => [
14
+ ["#dog#name#", "says", "<bark>", "."],
15
+ ],
16
+ "<bark>" => [
17
+ ["ruff"],
18
+ ["woof"],
19
+ ]
20
+ }
21
+
22
+ class Dog
23
+ def name
24
+ "Daisy"
25
+ end
26
+ end
27
+
28
+ Wordz.generate(
29
+ grammar: grammar,
30
+ subjects: { dog: Dog.new },
31
+ )
32
+
33
+ # Will return one of the following, at random.
34
+ # => "Daisy says ruff."
35
+ # => "Daisy says arf."
36
+ ```
data/Rakefile CHANGED
@@ -4,3 +4,11 @@ require "rspec/core/rake_task"
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task default: :spec
7
+
8
+ namespace :irb do
9
+ desc "Open interactive REPL with our application preloaded"
10
+
11
+ task :console do
12
+ system("irb -r ./lib/wordz.rb")
13
+ end
14
+ end
@@ -4,6 +4,9 @@ WORDZ_APP_PATH = File.expand_path("../", __FILE__) + "/wordz"
4
4
 
5
5
  module Wordz
6
6
  autoload(:PostProcessor, "#{WORDZ_APP_PATH}/post_processor.rb")
7
+ autoload(:Client, "#{WORDZ_APP_PATH}/client.rb")
8
+
9
+ extend Wordz::Client
7
10
  end
8
11
 
9
12
  Dir["#{WORDZ_APP_PATH}/**/*.rb"].each { |file| require file }
@@ -0,0 +1,10 @@
1
+ module Wordz
2
+ module Client
3
+ def generate(grammar: {}, subjects: {}, root: nil)
4
+ Generator.new(
5
+ grammar: grammar,
6
+ subjects: subjects,
7
+ ).call(root)
8
+ end
9
+ end
10
+ end
@@ -8,13 +8,14 @@ module Wordz
8
8
 
9
9
  ROOT_NODE = "<root>".freeze
10
10
 
11
- def initialize(grammar = {}, subjects: {})
11
+ def initialize(grammar: {}, subjects: {})
12
12
  @output = []
13
13
  @subjects = subjects
14
14
  @grammar = grammar
15
15
  end
16
16
 
17
- def generate(root_node = ROOT_NODE)
17
+ def call(root_node = nil)
18
+ root_node ||= ROOT_NODE
18
19
  post_process(generate_list(root_node))
19
20
  end
20
21
 
@@ -1,3 +1,3 @@
1
1
  module Wordz
2
- VERSION = "0.1.1".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hoffman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-27 00:00:00.000000000 Z
11
+ date: 2017-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,6 +84,7 @@ files:
84
84
  - bin/console
85
85
  - bin/setup
86
86
  - lib/wordz.rb
87
+ - lib/wordz/client.rb
87
88
  - lib/wordz/generator.rb
88
89
  - lib/wordz/instruction.rb
89
90
  - lib/wordz/post_processor.rb